akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <array>

using namespace std;

int data[100002] = {};

int main ()
{
	int N;
	cin >> N;
	vector<int>D;
	D.resize ( N +1);
	for( size_t i = 0; i < N; i++ )
	{
		cin >> D[i];
	}
	data[0] = 1;
	for( size_t i = 1; i <= N*2; i++ )
	{
		for( size_t j = 0; j <= N; j++ )
		{
			if( data[j] == i &&D[j]==0)
			{
				stack<int>S;
				if( j + 6 >= N -1) { 
					if( data[N - 1] == 0 )
					{
						cout << data[j] << endl;
					} else
					{
						cout<<data[N - 1]-1<<endl;
					}
					return 0;
				}
				for( size_t k = 1; k <=6&&k+j<=N ; k++ )
				{
					if( data[k + j] == 0 )
					{
						S.push ( k + j );
						data[k + j] = data[j] + 1;
					}
				}
				while( S.size () )
				{
					int x = S.top (); S.pop ();
					if( data[x + D[x]] == 0 )
					{
						S.push ( x + D[x] );
						data[x + D[x]] = data[x];
					}
				}
			}
		}
	}
	//cout << data[N - 1] - 1 << endl;
}

Measured memory_bytes: 1928
import numpy as np

K, S = map(int, input().split())
fft_len = 1 << (K * 3).bit_length()

x = np.ones(K + 1)
Fx = np.fft.rfft(x, fft_len)
Fx3 = Fx * Fx * Fx
conv = np.fft.irfft(Fx3, fft_len)

ans = conv[S]
ans = int(ans + 0.5)
print(ans)


Measured memory_bytes: 12872
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a,b,c; cin >> a >> b >> c;
  int k; cin >> k;
  vector<int> d,e,f;
  d.pb(a), e.pb(b), f.pb(c);
  rep(i,0,k){
    a*=2;
    b*=2;
    c*=2;
    d.pb(a);
    e.pb(b);
    f.pb(c);
  }
  int ok=0;
  rep(i,0,k+1){
    rep(j,0,k+1){
      rep(l,0,k+1){
        if(i+j+l>k) continue;
        //cout << i+j+l << endl;
        //cout << d[i] << " " << e[j] << " " << f[l] << endl;
        if(d[i] < e[j] && e[j] < f[l]) ok=1;
      }
    }
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 3640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  vector<pii> o(0);
  for(int i=1;i<n-1;i++){
    if(a[i]<0){
      o.push_back(pii(a[n-1],a[i]));
      a[n-1]-=a[i];
    }
    else{
      o.push_back(pii(a[0],a[i]));
      a[0]-=a[i];
    }
  }
  o.push_back(pii(a[n-1],a[0]));
  cout << o[n-2].first-o[n-2].second << endl;
  rep(i,o.size()){
    cout << o[i].first << " " << o[i].second << endl;
  }
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
#define RIGHT " → "
using ll = long long;
using namespace std;

ll gcd( ll x, ll y ){
	return ( y == 0 ) ? x : gcd( y, x%y );
}

int main(){
	int t; cin >> t;
	while( t-- ){
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		bool schleife;
		/*
		b > d : 購入ペースのほうが早いのでなくなる
		b > a : 最初の時点で購入不可
		c >= b : 購入すると必ず補充ゾーンに入る
		*/
		if( b > d || b > a ){
			schleife = false;
		} else if( c >= b ){
			schleife = true;
		} else {
			/*
			現在の本数を s とすると s = a%b-b*m+d*n と表せ，これを最大公約数でくくると s = a%g-k*g となる
			s が c より大きいとき（補充されない）で s-b < 0（購入するとマイナスになる）となるような場合
			次の購入でジュースがなくなってしまうので No
			これをまとめると c < s における s において s < b のときジュースがなくなる
			s の最小値についてこの範囲に含まれているかどうか考えれば判定可能
			m = a%g-k*g とおくと c < s から k = ceil( (c-a%g+1)/g ) と求まる
			*/
			ll g = gcd( b, d );
			schleife = ( a%g + g*((c-a%g+g)/g) < b ) ? false : true;
		}
		cout << ( schleife ? "Yes" : "No" ) << endl; 
	}
	return 0;
}

/*
	// シミュレーション用
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int n = 20;
	cout << a << RIGHT;
	int cur = a;
	while( n-- ){
		cur -= b;
		if( cur < 0 ){
			cout << "verkauft" << endl;
			return 0;
		} else {
			cout << cur << RIGHT;
			( cur > c ) ?: ( cur += d );
			cout << cur << RIGHT;
		}
	}
	cout << "......" << endl;
*/

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

//?????????????????????????????\?????????
void insertionSort(int A[],int n,int g){
	for(int i=g;i<n;i++){
		int v = A[i];
		int j = i-g;
		while( j>=0 && A[j]>v ){
			A[j+g] = A[j];
			j = j-g;
			cnt++;
		} 
		A[j+g] = v;
	}
}

void shellSort(int A[],int n){
	//??°??????G = {1, 4, 13, 40, 121, 364, 1093, ...} ?????????
	for(int h=1; ; ){
		if(h > n) break;//??\????????????????????????????????£????????????????????§?????????
		G.push_back(h);
		h = 3*h + 1;
	}
	//?????????G?????????
	for(int i = G.size()-1;i>=0;i--){
		insertionSort(A,n,G[i]);
	}
}

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	cnt = 0;
	
	shellSort(A,n);
	
	cout<<G.size()<<endl;
	for(int i=G.size()-1;i>=0;i--){
		if(i != G.size()-1) cout<<" ";
		cout<<G[i];
	}
	cout<<endl;
	cout<<cnt<<endl;
	
	for(int i=0;i<n;i++){
		cout<<A[i]<<endl;
	}
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A,B,C,K,count;
  cin >> A >> B >> C >> K;
  count = 0;
  
  while(K != 0 && A != 0){
    K--;
    A--;
    count++;
    if(A == 0)
      break;
  }
  while(K != 0 && B != 0){
    K--;
    B--;
    if(B == 0)
      break;
  }
  while(K != 0 && C != 0){
    K--;
    C--;
    count--;
    if(C == 0)
      break;
  }
  cout << count << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
    string s;
    cin >> s;

    vector<char> check;

    for(int i =0; i < s.size(); ++i) {
        if(find(check.begin(), check.end(), s[i]) != check.end()) {
            cout  << "no" << endl;
            return 0;

        } else {
            check.push_back(s[i]);
        }
        
    } 
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
    int n,d,mx=0,mn=2000000000;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> d;
        if(mx<d) mx=d;
        if(mn>d) mn=d;
    }
    cout << mx-mn;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

void process(ll x,ll k,ll d)
{
    if (k % 2 == 0)
        cout << abs(x) << endl;
    else
    {
        ll ret = min(abs(x - d),abs(x + d));
        cout << ret << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll x,k,d;
    cin >> x >> k >> d;
    if (x == 0)
    {
        if (k % 2 == 0)
            cout << 0 << endl;
        else
            cout << d << endl;
    }
    else
    if (x < 0)
    {
        ll mx = -x / d;
        if (mx >= k)
        {
            ll ans = x + k * d;
            cout << abs(ans) << endl;
        }
        else
        {
            k -= mx;
            x += mx * d;
            ll nxt = x + d;
            if (abs(nxt) < abs(x))
                process(nxt,k - 1,d);
            else
                process(x,k,d);
        }
    }
    else
    {
        ll mx = x / d;
        // cout << mx << endl;
        if (mx >= k)
        {
            ll ans = x - k * d;
            cout << ans << endl;
        }
        else
        {
            k -= mx;
            x -= mx * d;
            ll nxt = x - d;
            if (abs(nxt) < abs(x))
                process(nxt,k - 1,d);
            else
                process(x,k,d);
        }
    }
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(void)
{
	int a,b,c,d;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    d=a;
    a=b;
    b=d;
  }
  if(b>c){
    d=b;
    b=c;
    c=d;
  }
  if(a>b){
    d=a;
    a=b;
    b=d;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, a, b;
	cin >> n >> a >> b;
	if((b-a)%2==0){
		cout << "Alice";
	}
	else{
		cout << "Borys";
	}
	return 0;
}


Measured memory_bytes: 764
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		int N = input();

		for (int i = 0; i < N; i++) {

			ArrayList<Integer> numList = new ArrayList<>();

			for (int j = 0; j < 3; j++) {

				numList.add(input());

			}

			Collections.sort(numList);

			if (isRight(numList.get(2), numList.get(1), numList.get(0))) {

				System.out.println("YES");

			} else {

				System.out.println("NO");

			}
		}

		close();

	}

	public static boolean isRight(int longSide, int shortSideA, int shortSideB) {

		return Math.pow(longSide, 2) == Math.pow(shortSideA, 2) + Math.pow(shortSideB, 2);

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 33044
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define U1 unsigned char
#define S1 char
#define	S4 int
#define S8 long

#define MAX_NUM_CHARACTERS            (200)    /* 文字数の上限 */
#define DIF_UPPERCACE_LOWERCASE       ('a'-'A')/* 大文字と小文字の文字コードの差 */

char* gets_s(char *s, int n) {
   if (fgets(s, n, stdin) == NULL) return NULL;
   char *ln = strchr(s, '\n');
   if (ln) *ln = '\0';
   else while (1) {
      int c = getchar();
      if (c == '\n' || c == EOF) break;
   }
   return s;
}

/* 小文字(a～z)を大文字に変換する関数 */
/* 入力文字列の領域を置換する */
void vd_d_toUpperCase(S1* s1_ap_arrCharacters)
{
	S1* s1_tp_indexArrCharacters;		/* 入力文字列操作用インデックス */

	/* a-zなら、A-Zに変換 */
	s1_tp_indexArrCharacters = &s1_ap_arrCharacters[0];
	while (*s1_tp_indexArrCharacters != (S1)'\0')
	{
		if ((*s1_tp_indexArrCharacters >= (S1)'a') &&
			(*s1_tp_indexArrCharacters <= (S1)'z'))
		{
			*s1_tp_indexArrCharacters -= (S1)DIF_UPPERCACE_LOWERCASE;
		}
		s1_tp_indexArrCharacters++;
	}
}

S4 main(void)
{
	S1 s1_tp_inputCharacters[MAX_NUM_CHARACTERS + 1];    /* 終端文字のために余分に配列を確保 */

	(void)gets_s(s1_tp_inputCharacters, sizeof(s1_tp_inputCharacters));

	/* 小文字を大文字に変換 */
	vd_d_toUpperCase(s1_tp_inputCharacters);

	/* 結果を出力 */
	printf("%s\n", s1_tp_inputCharacters);

	return((S4)0);
}



Measured memory_bytes: 2036
import sys
def is_unique(seq):
    return len(seq) == len(set(seq))

## 最初に入力回数が与えられて、そのあとデータが入力される。といったパターン
N = int(input())
a = []
for i in range(N):
    a.append(input()) # ３度の入力に対して、1, 2, 3 と入力。
#print(a) # ['1', '2', '3']

if not(is_unique(a)):
	print("No")
	sys.exit()

last_char=""
counter=0
for item in a:
	if counter == 0:
		last_char = item[-1]
		counter = 1
	else:
		if(len(item) > 11):
			print("No")
			sys.exit()
		if not (item[0] == last_char):
			print("No")
			sys.exit()
		else:
			last_char = item[-1]
			
print("Yes")

Measured memory_bytes: 3064
# from sys import exit
N, M = [int(n) for n in input().split()]
ss = [0 for i in range(M)]
for i in range(M):
    ss[i] = set([int(n)-1 for n in input().split()][1:])
p = [int(n) for n in input().split()]
ans = 0
for pt in range((1 << N)):#1 == 線あり 0 == 線なし　とする
    each = [0]*M
    for i in range(N):
        if (1 << i) & pt:
            for iss in range(len(ss)):
                if i in ss[iss]:
                    each[iss] +=1
    OK = True

    for i in range(len(each)):
        if each[i]%2 != p[i]:
            OK = False
    if OK:
        ans+=1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<array<int,2>> XL(N);
    for(int i=0;i<N;i++){
        cin >> XL[i][0] >> XL[i][1];
    }
    sort(XL.begin(), XL.end(), [](array<int,2>& a, array<int,2>& b){
        return a[0] + a[1] < b[0] + b[1];
    });
    int res = 1;
    int iprev = 0;
    for(int i=1;i<N;i++){
        if(XL[iprev][0] + XL[iprev][1] + XL[i][1] <= XL[i][0]){
            res++;
            iprev = i;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>

using namespace std;

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795


const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

#define int long long
#define trace(x) cerr << #x << ": " << x << " " << endl;
int MOD;


inline int add(int a, int b){a += b; if(a >= MOD)a -= MOD; return a;}
inline int sub(int a, int b){a -= b; if(a < 0)a += MOD; return a;}
inline int mul(int a, int b){return (int)((int) a * b %MOD);}


#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

vector<int> G[100000 + 1];

map<int, int> dp1[100000 + 1];
int dp0[100000 + 1];
int dp2[100000 + 1];
int p1[100000 + 1];
int p2[100000 + 1];
int ans = 0;


int dfs1(int u, int c)
{
	vector<int> l;
	for (int x : G[u])
	{
		if (x != c)
			l.push_back(add(1, dfs1(x, u)));
	}
	if (l.size() == 0)
	{
		dp0[u] = 1;
		return 1;
	}
	int res = 1;
	p1[0] = 1;
	p2[l.size()] = 1;
	FOR(i, 1, l.size()+1, 1)
	{
		p1[i] = mul(p1[i - 1], l[i-1]);
		p2[l.size() - i] = mul(p2[l.size() - i + 1], l[l.size() - i]);
	}
	int ind = 0;
	for (int x : G[u])
	{
		if (x != c)
		{
			dp1[u][x] = mul(p1[ind], p2[ind + 1]);
			ind++;
		}
	}
	dp0[u] = p2[0];
	return p2[0];
}

int dfs2(int u, int c, int cv)
{
	if (cv != -1)
	{
		dp2[u] = mul(dp0[u], add(cv, 1));
	}
	else
		dp2[u] = dp0[u];
	for (int x : G[u])
	{
		if (x != c)
			dfs2(x, u, mul(add(cv,1), dp1[u][x]));
	}

	return 0;
}

signed main()
{
	IOS

		int n;
	cin >> n >> MOD;

	REP(i, n - 1)
	{
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}

	dfs1(0, -1);
	dfs2(0, -1, 0);

	REP(i, n)
	{
		cout << dp2[i] << "\n";
	}
}

Measured memory_bytes: 28288
#include <stdlib.h>
#include <stdio.h>

int hr[2001][2001];
int vr[2001][2001];
char S[2001][2001];

int main(void){
  int H, W;
  scanf("%d %d", &H, &W);
  for (int i = 0; i < H; ++i) {
    scanf("%s", &S[i]);
  }

  // 横
  for (int i = 0; i < H; ++i) {
    int l = 0;
    for (int j = 0; j <= W; ++j) {
      if (S[i][j] == '#' || j == W) {
        int len = j - l;
        for (int k = l; k < j; ++k) {
          hr[i][k] = len;
        }
        l = j + 1;
      }
    }
  }

  // 縦
  for (int i = 0; i < W; ++i) {
    int u = 0;
    for (int j = 0; j <= H; ++j) {
      if (S[j][i] == '#' || j == H) {
        int len = j - u;
        for (int k = u; k < j; ++k) {
          vr[k][i] = len;
        }
        u = j + 1;
      }
    }
  }

  // for (int i = 0; i < H; ++i) {
  //   for (int j = 0; j < W; ++j) {
  //     printf("%d", hr[i][j]);
  //   }
  //   puts("");
  // }

  // for (int i = 0; i < H; ++i) {
  //   for (int j = 0; j < W; ++j) {
  //     printf("%d", vr[i][j]);
  //   }
  //   puts("");
  // }

  // printf("%d %d\n", H, W);
  // for (int i = 0; i < H; ++i) {
  //   printf("%s\n", &S[i]);
  // }

  int ans = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      int val = hr[i][j] + vr[i][j] - 1;
      if (val > ans)
        ans = val;
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 35328
#include <bits/stdc++.h>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    string S,T; cin >> S >> T;
    int ch[26]; REP(i,26) ch[i] = -1;

    REP(i,S.size()){
        if(ch[S[i]-'a'] >= 0){
            if(ch[S[i]-'a'] != T[i]-'a'){
                cout << "No" << endl;
                return 0;
            }
        }
        else ch[S[i]-'a'] = T[i]-'a';
    }

    int ch2[26]; REP(i,26) ch2[i] = -1;

    REP(i,T.size()){
        if(ch2[T[i]-'a'] >= 0){
            if(ch2[T[i]-'a'] != S[i]-'a'){
                cout << "No" << endl;
                return 0;
            }
        }
        else ch2[T[i]-'a'] = S[i]-'a';
    }


    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll a, b;
  cin >> a >> b;
  if(a > 9 || b > 9) cout << -1 << endl;
  else cout << a * b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
// constexpr long double EPS = 1e-15;
// const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    REP(i,b) {
        REP(j,a) {
            cout << 0;
        }
        REP(j,w-a) {
            cout << 1;
        }
        cout << endl;
    }
    REP(i,h-b) {
        REP(j,a) {
            cout << 1;
        }
        REP(j,w-a) {
            cout << 0;
        }
        cout << endl;
    }
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    rep(i,n-1){
        if(a[i]==a[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  int A[N][2];
  int B[N];
  for (int i = 0; i < N; i++) cin >> A[i][0] >> A[i][1];
  for (int i = 0; i < N; i++) B[i] = i;

  long double sum = 0;
  int total = 0;
  do {
    for (int i = 0; i < N-1; i++) {
      sum += sqrt(pow(A[B[i]][0] - A[B[i+1]][0], 2) + pow(A[B[i]][1] - A[B[i+1]][1], 2));
    }
    total++;
  } while(next_permutation(B, B+N));

  printf("%.7Lf\n", sum/total);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

typedef pair<int,int>pint;
typedef vector<int>vint;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

const int dx[]={0,-1,0,1};
const int dy[]={-1,0,1,0};

struct data{
    int y,x,m,d;
    data(int y,int x,int m,int d):y(y),x(x),m(m),d(d){}
};

int H,W;
char fld[32][32];

bool memo[20][20][16][4];

data go(data tmp){
    int ny=tmp.y+dy[tmp.d],nx=tmp.x+dx[tmp.d];
    if(ny<0)ny=H-1;
    if(ny>=H)ny=0;
    if(nx<0)nx=W-1;
    if(nx>=W)nx=0;
    return data(ny,nx,tmp.m,tmp.d);
}

int main(){
    cin>>H>>W;
    rep(i,H)cin>>fld[i];

    queue<data>que;
    que.push(data(0,0,0,3));
    memo[0][0][0][3]=true;

    while(que.size()){
        data tmp=que.front();que.pop();

        char c=fld[tmp.y][tmp.x];
        if(c=='<'){
            tmp.d=1;
        }
        if(c=='>'){
            tmp.d=3;
        }
        if(c=='^'){
            tmp.d=0;
        }
        if(c=='v'){
            tmp.d=2;
        }
        if(c=='_'){
            if(tmp.m==0)tmp.d=3;
            else tmp.d=1;
        }
        if(c=='|'){
            if(tmp.m==0)tmp.d=2;
            else tmp.d=0;
        }
        if(c=='.'){

        }
        if(c=='@'){
            cout<<"YES"<<endl;
            return 0;
        }
        if(isdigit(c)){
            tmp.m=c-'0';
        }
        if(c=='+'){
            tmp.m=(tmp.m+1)%16;
        }
        if(c=='-'){
            tmp.m=(tmp.m+15)%16;
        }

        if(c=='?'){
            rep(i,4){
                tmp.d=i;
                data nxt=go(tmp);
                if(memo[nxt.y][nxt.x][nxt.m][nxt.d])continue;
                memo[nxt.y][nxt.x][nxt.m][nxt.d]=true;
                que.push(nxt);
            }
        }
        else{
            tmp=go(tmp);
            if(memo[tmp.y][tmp.x][tmp.m][tmp.d])continue;
            memo[tmp.y][tmp.x][tmp.m][tmp.d]=true;
            que.push(tmp);
        }
    }

    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 1260
#include<stdio.h>
int dp[50];
int fib(int n){
  if( n==0 || n==1) return dp[n]=1;
  if( dp[n] != -1 ) return dp[n];
  return dp[n]= fib(n-1)+fib(n-2);

}

int main(){
  int i,n;
  for(i=0;i<50;i++) dp[i]=-1;

  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}



Measured memory_bytes: 2068
import java.util.*;
import java.io.*;
class Main {
	static int n,arr[];
	static long dp[];
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=1;
//		Integer.parseInt(br.readLine().trim());
		StringBuilder printans=new StringBuilder();
		while(t-->0)
		{
			n=Integer.parseInt(br.readLine().trim());
			arr=new int[n];
			int sum=0;
			StringTokenizer tok=new StringTokenizer(br.readLine()," ");
			for(int i=0;i<n;i++) {
				arr[i]=Integer.parseInt(tok.nextToken());
				sum+=arr[i];
			}
			dp=new long[n];
			memset();
			
			printans.append(call());
		    
		}
		System.out.println(printans);

	}
	static void memset() {
		
			
		
	}
	static long call() {
		for(int i=0;i<n;i++) {
			if(i<2) {
				dp[0]=0;
				dp[1]=Math.abs(arr[1]-arr[0]);
			}
			else {
				dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
			}
		}
		return dp[dp.length-1];
	}

}


Measured memory_bytes: 32624
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll dp[51][51];
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  vector<double> s(n);
  for(int i=0;i<n;i++)cin>>s[i];
  sort(all(s),greater<double>());
  double sum=0.0;
  for(int i=0;i<a;i++)sum+=s[i];
  printf("%.8f\n",sum/(double)a);
  for(int i=0;i<=n;i++)dp[i][i]=1;
  for(int i=0;i<n;i++){
    dp[i+1][0]=1;
    for(int j=1;j<i+1;j++){
      dp[i+1][j]=dp[i][j-1]+dp[i][j];
      }
   }
     ll cnt=0,cn=0;
     for(int i=0;i<n;i++){
     if(s[a-1]==s[i]){
            cnt++;
            if(i<a)cn++;
            }
            }
      if(s[0]==s[a-1]){
        ll ans=0;
        for(int i=a;i<=b;i++)ans+=dp[cnt][i];
        cout<<ans<<endl;
        }
        else cout<<dp[cnt][cn]<<endl;
     
      
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int x,y,a[]={0,2,0,1,0,1,0,0,1,0,1,0};
    scanf("%d%d",&x,&y);
    if(a[x-1]==a[y-1])
    printf("Yes");
    else 
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

struct Sieve
{
  int n;
  vector<int> f, primes;
  Sieve(int n = 1) : n(n), f(n + 1)
  {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i)
    {
      if (f[i])
        continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i)
      {
        if (!f[j])
          f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x; }
  vector<int> factorList(int x)
  {
    vector<int> res;
    while (x != 1)
    {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x)
  {
    vector<int> fl = factorList(x);
    if (fl.size() == 0)
      return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl)
    {
      if (res.back().first == p)
      {
        res.back().second++;
      }
      else
      {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main()
{
  int lim = 10e6;
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n)
  {
    int num;
    cin >> num;
    a[i] = num;
  }

  Sieve sieve(lim + 1);
  vector<int> memo(lim + 1);

  auto is_p = [&]() {
    for (int i = 0; i < n; i++)
    {
      auto list = sieve.factor(a[i]);
      for (auto p : list)
      {
        int num = p.first;
        // cout << num << endl;
        if (memo[num] > 0)
          return false;
        memo[num]++;
      }
    }
    return true;
  };

  if (is_p())
  {
    cout << "pairwise coprime" << endl;
    return 0;
  }

  auto is_s = [&]() {
    int g = a[0];
    for (int i = 1; i < n; i++)
    {
      g = gcd(g, a[i]);
      if (g == 1)
      {
        return true;
      }
    }
    return false;
  };

  if (is_s())
  {
    cout << "setwise coprime" << endl;
    return 0;
  }

  cout << "not coprime" << endl;
  return 0;
}


Measured memory_bytes: 88156
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int h,w; cin>>h>>w;
	int a[h][w], b[h][w];
	const int max_k=(h+w)*80+5;
	rep(i,h) rep(j,w) cin>>a[i][j];
	rep(i,h) rep(j,w) cin>>b[i][j];
	bool dp[h][w][max_k]; memset(dp,false,sizeof(dp));
	const int dh[2]={1,0}, dw[2]={0,1};
	dp[0][0][abs(a[0][0]-b[0][0])]=true;
	rep(now_h,h)rep(now_w,w){
		rep(i,2){
			int next_h=now_h+dh[i], next_w=now_w+dw[i];
			if(next_h>=h||next_w>=w) continue;
			int d=abs(a[next_h][next_w]-b[next_h][next_w]);
			rep(k,max_k){
				if(!dp[now_h][now_w][k]) continue;
				if(k+d<max_k) dp[next_h][next_w][k+d]=true;
				if(abs(k-d)<max_k) dp[next_h][next_w][abs(k-d)]=true;
			}
		}
	}
	int ans=max_k;
	rep(k,max_k){
		if(dp[h-1][w-1][k]) return cout<<k<<endl,0;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 80384
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll a, b, c;
  cin >> a >> b >> c;
  ll ta = a;
  rep(i,b) {
    if (a%b == c) {
      cout << "YES\n";
      return 0;
    }
    a += ta;
    a %= b;
  }
  cout << "NO\n";

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

/*
クエリA_iは次のように言い換えられる
「値がA_iの要素を1つ選び，インクリメントする．」
初期状態は値が0の要素*3
選ぶ際の選択肢の数だけ組み合わせがかけられる．
*/

int main(){

    ll N;
    cin >> N;
    ll ans = 1;
    map<ll, ll>cnt;
    cnt[0] = 3;
    rep(i, N){
        ll A;
        cin >> A;
        ans = (ans * cnt[A]) % MOD;
        cnt[A]--;
        cnt[A + 1]++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<queue>
#include<map>
#define LEN 100
#define BASE 25

using namespace std;

int maps[LEN][LEN];
int off[LEN][LEN];

int checker[4];
int ncheck[4];

map<int, int> points[LEN];

class State {
public:
	char where;
	int enemy;
	int budget;
	int check[4];
	State() {check[0]=0;check[1]=0;check[2]=0;check[3]=0;}
	State(char w, int e, int b ) {
		where = w;
		enemy = e;
		budget = b; 
		check[0] = ncheck[0];
		check[1] = ncheck[1];
		check[2] = ncheck[2];
		check[3] = ncheck[3];
	}
};


inline bool operator< ( const State& a, const State& b) {
	if( a.enemy == b.enemy )
		return a.budget < b.budget;
	return a.enemy < b.enemy;
}

inline bool operator> ( const State& a, const State& b) {
	if ( a.enemy == b.enemy )
		return a.budget > b.budget;
	return a.enemy > b.enemy;
}

priority_queue<State, deque<State>, greater<State> > status;

inline void copy ( State now ) {
	checker[0] = now.check[0];
	checker[1] = now.check[1];
	checker[2] = now.check[2];
	checker[3] = now.check[3];
}

inline void ncopy ( ) {
	ncheck[0] = checker[0];
	ncheck[1] = checker[1];
	ncheck[2] = checker[2];
	ncheck[3] = checker[3];
}

inline bool check ( int i ) {
	return 0 == ((1<<(i%25)) & checker[i/BASE]);
}

inline void add ( int i ) {
	ncheck[i/BASE] = ((1<<(i%25)) | checker[i/BASE]);
}

inline void insert ( int i, int e, int b ) {
	
	map<int,int>::iterator itr = points[i].find(e);
	if ( itr == points[i].end() ) {
		points[i][e] = b;
		status.push(State(i,e,b));
	} else if ( (*itr).second < b ) {
		(*itr).second = b;
		status.push(State(i,e,b));
	}
}

int main () {


	while ( true ) {
		int n,m,l;
		cin >> n >> m >> l;

		if ( n == 0 )
			break;

		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				maps[i][j] = -1;
				off[i][j] = 0;
			}
			points[i].clear();
		}

		for ( int i=0; i<m; i++ ) {
			int a,b,d,e;
			cin >> a >> b >> d >> e;

			maps[a-1][b-1] = maps[b-1][a-1] = d;
			off[a-1][b-1] = off[b-1][a-1] = e;
		}

		for ( int i=0; i<4; i++ ) {
			ncheck[i] = 0;
			checker[i] = 0;
		}

		priority_queue<State, deque<State>, greater<State> > empty;
		status = empty;

		ncheck[0] = 1;
		status.push(State(0,0,l));
		int count = 0;
		while(!status.empty()) {
			State now = status.top();
			status.pop();
			if ( now.where == n-1 ) {
				cout << now.enemy << endl;
				break;
			}

			copy(now);

			for ( int i=0; i<n; i++ ) {
				if ( maps[now.where][i] > 0 ) {
					if ( check( i ) ) {
						ncopy();
						add(i);
						int e, b;
						if ( off[now.where][i] == 0 ) {
							e = now.enemy;
							b = now.budget;
							insert(i,e,b);
						} else {
							if ( now.budget - maps[now.where][i] >= 0 ) {
								e = now.enemy;
								b = now.budget - maps[now.where][i];
								insert(i,e,b);
							}
							e = now.enemy + off[now.where][i];
							b = now.budget;
							insert(i,e,b);
						}
					}
				}
			}
		}
	}
}

		

Measured memory_bytes: 3504
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a;
	for (int i = 1; i <= n; i++) {
		int j;
		cin >> j;
		a.push_back(j);
	}
	for (int j = 1; j <= m; j++) {
		for (int i = 1; i <= n; i++) {
			if (i == n) {
				break;
			}
			else {
				if ((a[i - 1] % j) > (a[i] % j)) {
					int aj, bj;
					aj = a[i - 1], bj = a[i];
					a[i - 1] = bj, a[i] = aj;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << a[i] << endl;
	}
}


Measured memory_bytes: 3096
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
#include <deque>

#define NL << endl

using namespace std;
using ll = long long;
using ull = unsigned long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;



signed main() {
	string s;
	cin >> s;
	int min = INTMAX;
	for (int i = 0; i < s.size() - 2; i++) {
		min = std::min(min, abs((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0' - 753));
	}

	cout << min NL;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
using namespace std;
#define EPS (1e-10)
#define equals(a,b) (fabs((a) - (b)) < EPS)
class Point{
public:
  double x,y;
  Point(double x = 0, double y = 0):x(x), y(y) {}
  Point operator + (Point p){
    return Point(x+p.x,y+p.y);
  }
  Point operator - (Point p){
    return Point(x-p.x,y-p.y);
  }
  Point operator * (double k){
    return Point(x*k,y*k);
  }
  Point operator / (double k){
    return Point(x/k,y/k);
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};
typedef Point Vector;
double norm(Vector a){
  return pow(a.x,2.0)+pow(a.y,2.0);
}
double abs(Vector a){
  return sqrt(norm(a));
}
struct Circle{
  Point c;
  double r;
};
int check(Circle a,Circle b){
  double d1 = abs(b.c-a.c) , d2 = (a.r+b.r);
  
  if(d1+b.r-a.r<0) return 2;
  if(d1+a.r-b.r<0) return -2;
  if(d1-d2<=0) return 1;
  return 0;
}
int main(){
  int n;
  cin >> n;
  Point a;
  vector<Circle> v;
  Circle c;
  double r;
  cin >> r;
  c.c.x=r;c.c.y=r;c.r=r;
  v.push_back(c);
  for(int i=1;i<n;i++){
    cin >> r;
    c.c.x=r;c.c.y=r;c.r=r;
    for(int j=0;j<i;j++){
      
      c.c.x=max(c.c.x,v[j].c.x+sqrt((v[j].r+c.r)*(v[j].r+c.r)-(v[j].c.y-c.c.y)*(v[j].c.y-c.c.y)));
      
    }
    if(c.c.x<0) c.c.x=0;
    v.push_back(c);
  }
  //cout << v[n-1].c.x+v[n-1].r << endl;
  double o=0;
  for(int i=0;i<n;i++) o=max(o,v[i].c.x+v[i].r);
  printf("%.5f\n",o);
  return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;


int main() {

  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  
  vector<long long> A(X);
  for (int i = 0; i < X; i++) {
    cin >> A[i];
  }

  vector<long long> B(Y);
  for (int i = 0; i < Y; i++) {
    cin >> B[i];
  }

  vector<long long> C(Z);
  for (int i = 0; i < Z; i++) {
    cin >> C[i];
  }

  // C は大きい順に並び替えておく
  sort(C.begin(), C.end(), std::greater<long long>());

  // A + B を全部作る
  vector<long long> AB;
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
      AB.push_back(A[i] + B[j]);
    }
  }

  // A + B を大きい順に並び替える
  sort(AB.begin(), AB.end(), std::greater<long long>());

  // (A + B) + C を作る
  // (A + B) は、大きい方から K 個と(A + B)の個数との小さい方を使う
  vector<long long> ABC;
  for (int i = 0; i < min(K, (int) AB.size()); i++) {
    for (int j = 0; j < Z; j++) {
      ABC.push_back(AB[i] + C[j]);
    }
  }

  // (A + B) + C を大きい順に並び替える
  sort(ABC.begin(), ABC.end(), std::greater<long long>());

  // 出力する
  for (int i = 0; i < K; i++) {
    cout << ABC[i] << endl;
  }

  return 0;

}

Measured memory_bytes: 43240
#include<bits/stdc++.h>
using namespace std;

vector<vector<int>> dist;
const int dx[4]={0,0,-1,1};
const int dy[4]={1,-1,0,0};

int main(){
  int height,width; cin >> height >> width;
  int sx,sy;
  int gx,gy;
  vector<string> field(height);
  for(int h=0;h<height;h++) cin >> field[h];
  
  int ans=0;
  int count=0;
  for(int sx=0;sx<height;sx++){
    for(int sy=0;sy<width;sy++){
      if(field[sx][sy]=='#') continue;

      vector<vector<int>> dist(height,vector<int>(width,-1));
      vector<vector<int>> prev_x(height,vector<int>(width,-1));
      vector<vector<int>> prev_y(height,vector<int>(width,-1));

      queue<pair<int,int>> que;
      
      dist[sx][sy]=0;
      que.push(make_pair(sx,sy));
      int x,y;
      while(!que.empty()){
        const auto current=que.front();
        x=current.first;
        y=current.second;
        que.pop();

        for(int direction=0;direction<4;direction++){
          int next_x=x+dx[direction];
          int next_y=y+dy[direction];
          if(next_x<0||next_x>=height||next_y<0||next_y>=width) continue;
          if(field[next_x][next_y]=='#') continue;

          if(dist[next_x][next_y]==-1){
            que.push(make_pair(next_x,next_y));
            dist[next_x][next_y]=dist[x][y]+1;
            prev_x[next_x][next_y]=x;
            prev_y[next_x][next_y]=y;
          }
        }
      }  
      while(x!=-1&&y!=-1){
        count++;
        field[x][y]='o';
        int px=prev_x[x][y];
        int py=prev_y[x][y];
        x=px,y=py;
      }
      // if(ans<count){
      //   for(int h=0;h<height;h++){
      //     for(int w=0;w<width;w++){
      //       cout << field[h][w];
      //     }
      //     cout << endl;
      //   }
      //   ans=count;
      // }
      ans=max(ans,count);
      count=0;
    }
  }
  cout << ans-1 <<endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
Alice = 0
Bob = 0
i = 0
while i < N:
  Alice += a[i]
  i += 1 
  if i >= N:
    break
  Bob += a[i]
  i += 1
  
print(Alice - Bob)  

Measured memory_bytes: 9112
n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n
hizero=0
for i in range(n):
    x[i],y[i],h[i]=map(int,input().split())
    if(h[i]!=0):
        hizero=i

for i in range(101):
    for j in range(101):
        tmp_h=h[hizero]+abs(x[hizero]-i)+abs(y[hizero]-j)
        for k in range(0,n):
            if(max([0,tmp_h-abs(x[k]-i)-abs(y[k]-j)])!=h[k]):
                break
        if(max([0,tmp_h-abs(x[k]-i)-abs(y[k]-j)])==h[k]):
            break
    if(max([0,tmp_h-abs(x[k]-i)-abs(y[k]-j)])==h[k]):
        break
print("{} {} {}".format(i,j,tmp_h))

Measured memory_bytes: 3064
nums = gets.split(' ').map { |i| i.to_i }
takahashi = nums[0]
aoki = nums[1]
exec = nums[2]

if takahashi + aoki <= exec
  puts "0 0"
else
  takahashi -= exec
  takahashi = 0 if takahashi.negative?
  exec -= nums[0]
  aoki -= exec if exec > 0
  puts "#{takahashi} #{aoki}"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long n, d;
    cin >> n >> d;
    vector<long long> x(n);
    vector<long long> y(n);

    for(int i = 0; i<n; i++) {
        cin >> x[i] >> y[i];
    }

    int ans = 0;
    for(int i = 0; i<n; i++) {
        long double m = sqrt(x[i] *x[i] + y[i] * y[i]);
        if( m <= d) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6424
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#define ll long long
#define INF 0x3f3f3f3f
#define N 1005
using namespace std;

ll a[100];

int main()
{
	int n;
	a[0]=2;
	a[1]=1;
	for(int i=2;i<=86;i++)
	a[i]=a[i-1]+a[i-2];
	scanf("%d",&n);
	printf("%lld\n",a[n]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    uint64_t x;
    cin >> x;
    uint64_t i=0,sum;
    for (i=0,sum=100; sum<x; i++,sum+=sum/100)
    {
    }

    cout << i << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll p[200010];
bool validPreInLeft[200010]={};
bool valid[200010]={};
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        cin>>p[i];
    }
    for(ll i=0;i<N;i++){
        if(valid[p[i]-1]){
            validPreInLeft[p[i]]=true;
        }
        valid[p[i]]=true;
    }
    ll maxLen=1;
    ll nowLen=1;
    for(ll i=N;i>=1;i--){
        if(validPreInLeft[i]){
            nowLen++;
        }else{
            maxLen=max(maxLen,nowLen);
            nowLen=1;
        }
    }
    cout<<N-maxLen;
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}


//最小公倍数、最大公約数を使って求める
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main(){
    ll N, M; cin >> N >> M;
    string S, T; cin >> S >> T;
    ll LCM = lcm(N, M);
    string X = "";
    map<ll, char> Map;
    //for(ll i = 0; i < LCM; i++) Map[i] = '0';

    for(int i = 0; i < N; i++){
        int idx = LCM/N*i;
        if(Map.find(idx) == Map.end()) Map[idx] = S[i];
        else {
            if(Map[idx] != S[i]){
                cout << -1 << endl;
                return 0;
            }
        }

    }
    for(int i = 0; i < M; i++){
        int idx = LCM/M*i;
        if(Map.find(idx) == Map.end()) Map[idx] = T[i];
        else {

            if(Map[idx] != T[i]){
                cout << -1 << endl;
                return 0;
            }
        }

    }
    cout << LCM << endl;

}

Measured memory_bytes: 10880
#include <iostream>

using namespace std;

int main(void)
{
    long long A, B, K, i;

    cin >> A >> B >> K;

    for(i=A; i<=B; i++){
        if(i<=A+K-1 || i>=B-K+1){
            cout << i << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import itertools


def resolve(in_):
    N = int(next(in_))
    P = tuple(map(int, next(in_).split()))
    Q = tuple(map(int, next(in_).split()))

    p = 0
    q = 0
    for i, R in enumerate(itertools.permutations(range(1, N + 1), N), 1):
        if not p and P == R:
            p = i
            if q:
                break
        if not q and Q == R:
            q = i
            if p:
                break
    
    answer = abs(p - q)

    return answer


def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
dp=[[0 for i in range(3)] for _ in range(N)] #dp[i][0]はグー、dp[i][1]はチョキ、dp[i][2]はパーを出す
b=[]
cnt=0
#print(dp)
def janken(machine,hand):
    p=0
    if ((machine=="r")and(hand==2)):
        p=p+P
    elif((machine=="s")and(hand==0)):
        p=p+R
    elif((machine=="p")and(hand==1)):
        p=p+S
    return p
c=0
for i in range(N):
    machine=T[i]
    if i>=K:
        dp[i][0]=janken(machine,0)+max(dp[i-K][1],dp[i-K][2])
        dp[i][1]=janken(machine,1)+max(dp[i-K][0],dp[i-K][2])
        dp[i][2]=janken(machine,2)+max(dp[i-K][0],dp[i-K][1])
    else:
        for j in range(3):
            dp[i][j]=(janken(T[i],j))
for i in range(K):
    cnt=cnt+max(dp[len(dp)-i-1])
print(cnt)



Measured memory_bytes: 67548
left, right = gets.chomp.split(" ").map(&:to_i)
mod = 2019

if right-left >= mod then
    puts 0
else
    ans = 1 << 40
    left.upto(right) do |i|
        left.upto(right) do |j|
            next if i == j
            tmp = i*j % mod
            ans = ans > tmp ? tmp : ans
        end
    end
    puts ans
end

Measured memory_bytes: 14328