akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main()
{
    int A,B,C,get;
    scanf("%d %d %d",&A,&B,&C);
    get = A + B;
    if(get >= C)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
/*
                ____________    ______________       __
               / _________  /\ /_____   _____/\     / /\
              / /\       / /  \\    /  /\    \ \   / /  \
             / /  \_____/ /   / \__/  /  \____\/  / /   /
            / /   /    / /   /    /  /   /       / /   /
           / /   /    / /   /    /  /   /       / /   /
          / /   /    / /   /    /  /   /       / /   /
         / /___/____/ /   /    /  /   /       / /___/________
        /____________/   /    /__/   /       /______________/\
        \            \  /     \  \  /        \              \ \
         \____________\/       \__\/          \______________\/
           ___       ___               ___    __________
          /  /\     /  /\             /  /\  /_______  /\
         /  /__\___/  /  \           /  /  \ \      /  /  \
        /____    ____/   /          /  /   /  \____/  /   /
        \   /   /\   \  /          /  /   /       /  /   /
         \_/   /  \___\/ ___      /  /   /       /  /   /
          /   /   /     /  /\    /  /   /       /  /   /
         /   /   /     /  /__\__/  /   /       /  /___/____
        /___/   /     /___________/   /       /___________/\
        \   \  /      \           \  /        \           \ \
         \___\/        \___________\/          \___________\/
       
          A FAN OF FIZZYDAVID
           
*/

#include<bits/stdc++.h>

#define HEAP priority_queue
#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,n) for(int i=(n)-1;i>=0;i--)
#define forn(i,l,r) for(int i=(l);i<=(r);i++)
#define nrof(i,r,l) for(int i=(r);i>=(l);i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-20
#define pi 3.1415926535897932384626433832795
#define orz int
#define yjz main
#define fizzydavid return
#define ak 0
#define la ;
#define debug puts("OK");
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(),x.end()

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int iinf=1e9+7;
const LL linf=1ll<<60;
const flt dinf=1e10;

template <typename T>
inline void scf(T &x)
{
	bool f=0; x=0; char c=getchar();
	while((c<'0' || c>'9') && c!='-') c=getchar();
	if(c=='-') { f=1; c=getchar(); }
	while(c>='0' && c<='9') { x=x*10+c-'0'; c=getchar(); }
	if(f) x=-x; return;
}

template <typename T1,typename T2>
void scf(T1 &x,T2 &y) { scf(x); return scf(y); }

template <typename T1,typename T2,typename T3>
void scf(T1 &x,T2 &y,T3 &z) { scf(x); scf(y); return scf(z); }

#ifdef ONLINE_JUDGE
#else
#define DEBUG
#endif

//---------------------------head----------------------------

string str;
int cnt[2],pos;

orz yjz()
{
	cin>>str;
	rep(i,SZ(str))
	{
		if(i && str[i]==str[i-1]) continue;
		pos^=1; cnt[pos]++;
	}
	printf("%d\n",cnt[0]+cnt[1]-1);
	fizzydavid ak la
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int h, w, k, sx, sy, ex, ey;
queue<pi> q;
int dx[] = {-1, 0, 0, 1}, dy[] = {0, -1, 1, 0};

int main() {
	fastio; cin >> h >> w >> k >> sx >> sy >> ex >> ey;
	char grid[h+5][w+5]; FOR(i, 1, h) FOR(j, 1, w) cin >> grid[i][j];
	int dist[h+5][w+5]; memset(dist, -1, sizeof dist);
	dist[sx][sy] = 0; q.push(pi(sx, sy));
	while (!q.empty()) {
		auto [x, y] = q.front(); q.pop();
		FOR(i, 0, 3) {
			FOR(j, 1, k) {
				int nx = x + j*dx[i], ny = y + j*dy[i];
				if (nx < 1 or ny < 1 or nx > h or ny > w or grid[nx][ny] == '@') break;
				if (dist[nx][ny] == -1 or dist[nx][ny] >= dist[x][y] + 1) {
					if (dist[nx][ny] != dist[x][y] + 1) q.push(pi(nx, ny));
					dist[nx][ny] = dist[x][y] + 1;
				} else break;
			}
		}
	}
	cout << dist[ex][ey];
}


Measured memory_bytes: 28084
#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>

#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>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> s(3);
  cin >> s[0] >> s[1] >> s[2];
  reverse(s[0].begin(), s[0].end());
  reverse(s[1].begin(), s[1].end());
  reverse(s[2].begin(), s[2].end());
  int crr = 0;

  while(true) {

    if(s[crr].empty()) {
      //cout << crr << " =>";
      //print_array(s);
      if(crr == 0) cout << "A" << endl;
      if(crr == 1) cout << "B" << endl;
      if(crr == 2) cout << "C" << endl;
      return 0;
    }

    else {

      //cout << crr << " =>";
      //print_array(s);

      string a = s[crr];
      s[crr].pop_back();
      if(a[a.size()-1] == 'a') crr = 0;
      if(a[a.size()-1] == 'b') crr = 1;
      if(a[a.size()-1] == 'c') crr = 2;
    }

  }
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 4001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

// MOD確認

int main(){
    double R;
    cin >> R;
    cout << setprecision(25) << fixed;
    cout << 2 * PI * R << endl;
}


Measured memory_bytes: 3788
l = []
200.times do |i|
  l << i ** 2
end

n, d = gets.chomp.split.map(&:to_i)
x = []
n.times do |i|
  x[i] = gets.chomp.split.map(&:to_i)
end
cnt = 0
n.times do |i|
  i.times do |j|
    sum = 0
    d.times do |k|
      sum += (x[i][k] - x[j][k]) ** 2
    end
    if l.include?(sum)
      cnt += 1
    end
  end
end
puts cnt


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f first
#define s second
#define SIZE 26 
const long double PI = 3.141592653589793238L;
int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}


int main()
{
  fast;
 int x,n;
cin >> x >> n;
vector<int> v(100,0);
	for(int i = 0;i < n;++i)
	{
		int tmp;
		cin >> tmp;
		v[tmp] = 1;
	}
 
	int diff = abs(9999-x);
	int ans = 9999;
	for(int i = 0;i <= 101;++i)
	{
		int tmp = abs(i-x);
		if(tmp < diff && !v[i])
		{
			diff = tmp;
			ans = i;
		}
	}
 
	cout << ans << endl;
 



 

 return 0;
}
  

Measured memory_bytes: 3652
(let ((s (read-line)))
  (if (or (and (eql (aref s 0) (aref s 1)) (eql (aref s 2) (aref s 3)) (not (eql (aref s 0) (aref s 2))))
          (and (eql (aref s 0) (aref s 2)) (eql (aref s 1) (aref s 3)) (not (eql (aref s 0) (aref s 1))))
          (and (eql (aref s 0) (aref s 3)) (eql (aref s 1) (aref s 2)) (not (eql (aref s 0) (aref s 1)))))
      (format t "Yes~%")
      (format t "No~%")))


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

typedef long long ll;

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

    int res = 0;
    for (int i = 0; i < 4; i++){
        if (s[i] == '+') res ++;
        if (s[i] == '-') res--;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
let () = Scanf.scanf "%d %d %d\n" @@ fun n m k ->
  let acum = Array.make (n+1) 0 in
  let bcum = Array.make (m+1) 0 in
  let ok = ref 0 in
  let ng = ref (n+m+1) in
  let check x =
    let ids = List.init (n+1) Fun.id in
    let predicate i = x-m <= i && i <= x && acum.(i) + bcum.(x-i) <= k in
    List.exists predicate ids in
  for i = 1 to n do
    if i < n
    then Scanf.scanf " %d" @@ fun a -> acum.(i) <- acum.(i-1) + a
    else Scanf.scanf " %d\n" @@ fun a -> acum.(i) <- acum.(i-1) + a
  done;
  for i = 1 to m do
    if i < m
    then Scanf.scanf " %d" @@ fun b -> bcum.(i) <- bcum.(i-1) + b
    else Scanf.scanf " %d\n" @@ fun b -> bcum.(i) <- bcum.(i-1) + b
  done;
  while !ng - !ok > 1 do
    let mid = (!ok + !ng) / 2 in
    if check mid
    then ok := mid
    else ng := mid
  done;
  Printf.printf "%d\n" !ok

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

using namespace std;

#define intt long long 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 105;

int n, W;

struct Item {
	int w;
	int v;
};

Item a[N];

intt pref[N][4];

int main() {

	FAST;

	cin >> n >> W;
	cin >> a[0].w >> a[0].v;
	int w = a[0].w;
	vector <int> v[4];
	v[0].push_back(a[0].v);
	for (int i = 1; i < n; i ++) {
		cin >> a[i].w >> a[i].v;
		v[a[i].w - w].push_back(a[i].v);
	}
	for (int i = 0; i < 4; i ++) {
		sort(v[i].begin(), v[i].end());
		reverse(v[i].begin(), v[i].end());
	}
	for (int i = 0; i < 4; i ++) {
		for (int j = 0; j < v[i].size(); j ++) {
			pref[j + 1][i] = pref[j][i] + v[i][j];
		}
	}
	intt ans = 0;
	for (int i = 0; i <= min(int(v[0].size()), max(0, n)); i ++) {
		for (int j = 0; j <= min(int(v[1].size()), max(0, n - i)); j ++) {
			for (int k = 0; k <= min(int(v[2].size()), max(0, n - i - j)); k ++) {
				for (int c = 0; c <= min(int(v[3].size()), max(0, n - i - j - k)); c ++) {
					intt tw = 1LL * i * w + 1LL * j * (w + 1) + 1LL * k * (w + 2) + 1LL * c * (w + 3);
					if (tw <= 1LL * W) {
						ans = max(ans, pref[i][0] + pref[j][1] + pref[k][2] + pref[c][3]);
					}
				}
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int i, j, k;
	int max;
	int min;
	char num[16];
	char t;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%s", num);
		
		for (j = 0; j < 7; j++){
			for (k = 0; k < 7 - j; k++){
				if (num[k] > num[k + 1]){
					t = num[k + 1];
					num[k + 1] = num[k];
					num[k] = t;
				}
			}
		}
		max = 0; min = 0;
		for (j = 0; j < 8; j++){
			min *= 10;
			min += num[j] - '0';
		}
		for (j = 7; j >= 0; j--){
			max *= 10;
			max += num[j] - '0';
		}
		
		printf("%d\n", max - min);
	}
	
	return (0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x, N, sum;
  cin >> N;
  sum = 0;
  x = N;
  while(x != 0){
    sum += x % 10;
    x = (x - x % 10) / 10;
  }
  
  if (N % sum ==0) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
 
using namespace std;
 
const int MAXN=512;
double dp[MAXN][MAXN][MAXN];
int num[8];
int n;
 
double dfs(int a,int b,int c){
	if(a==n) return 0;
	if(dp[a][b][c]) return dp[a][b][c];
	double res=(double)n/(n-a);
	if(b) res+=dfs(a+1,b-1,c)*b/(n-a);
	if(c) res+=dfs(a,b+1,c-1)*c/(n-a);
	if(n-a-b-c) res+=dfs(a,b,c+1)*(n-a-b-c)/(n-a);
	return dp[a][b][c]=res;
}
 
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		num[x]++;
	}
	double ans=dfs(num[0],num[1],num[2]);
	printf("%.10lf\n",ans);
	return 0;
}

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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int t;cin>>t;t++;
	
	const int inf=LLONG_MAX/3;
	int ans=inf;
	
	rep(i,50){
		int s=0;
		int w=1;
		int num=0;
		rep(j,i){
			s+=w*2;
			w*=3;
			num+=2;
		}
		s+=w;
		num++;
		if(s>t)break;
		int x=t-s;
		while(w>=1){
			num+=x/w;
			x%=w;
			w/=3;
		}
		chmin(ans,num);
	}
	
	cout<<ans-1<<endl;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 2000009
#define mod 1000000007
ll n,m,i,j,k,tt,a[sz],arr[sz];
char c[sz],d[sz];
int main()
{
scanf("%s %s",&c,&d);
n=strlen(c);
for(i=0;i<n;i++)
{
    if(c[i]!=d[i])
        k++;
}
printf("%lld\n",k);
}


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

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
int main(){
  int n, a, d;
  while(cin >> n, n){
    int x[n], y[n];
    int mx, my, mix, miy;
    x[0] = y[0] = 0;
    mx = my = mix = miy = 0;
    for(int i = 1; i < n; i++){
      cin >> a >> d;
      y[i] = y[a] + dy[d];
      x[i] = x[a] + dx[d];
      my = max(my, y[i]);
      miy = min(miy, y[i]);
      mx = max(mx, x[i]);
      mix = min(mix, x[i]);
    }
    cout << mx - mix + 1 << " " << my - miy + 1 << endl;
  }
  return 0;
}



Measured memory_bytes: 3076
//35
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

bool chk(const int *p,int f){
  if(f==12){
    return true;
  }else{
    bool r=false;
    const int *t;
    for(t=p;*t==0;t++) ;
    if((f&8)==0&&*t>=2){
      int cp[10];
      memcpy(cp,p,sizeof(cp));
      cp[t-p]-=2;
      r|=chk(cp,f|8);
    }
    if((f&7)<4){
      if(*t>=3){
	int cp[10];
	memcpy(cp,p,sizeof(cp));
	cp[t-p]-=3;
	r|=chk(cp,f+1);
      }
      if(t-p<=7&&*t&&t[1]&&t[2]){
	int cp[10];
	memcpy(cp,p,sizeof(cp));
	for(int i=0;i<3;i++){
	  cp[t-p+i]--;
	}
	r|=chk(cp,f+1);
      }
    }
    return r;
  }
}

int main(){
  for(;;){
    int p[10]={};
    for(int i=0;i<13;i++){
      char c;
      cin>>c;
      if(!cin)return 0;
      p[c-'0']++;
    }
    bool com=false;
    for(int i=1;i<=9;i++){
      int cp[10];
      memcpy(cp,p,sizeof(cp));
      cp[i]++;
      if(*max_element(cp,cp+10)<=4&&chk(cp,0)){
	if(com){
	  cout<<' ';
	}
	cout<<i;
	com=true;
      }
    }
    if(!com){
      cout<<0;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

#define MAX 30
#define NIL -1

struct Node {
	int parent;
	int left;
	int right;
};

void preorder(struct Node *tree, int cur) {
	if (cur == NIL) return;
	printf(" %d", cur);
	preorder(tree, tree[cur].left);
	preorder(tree, tree[cur].right);
}

void inorder(struct Node *tree, int cur) {
	if (cur == NIL) return;
	inorder(tree, tree[cur].left);
	printf(" %d", cur);
	inorder(tree, tree[cur].right);
}

void postorder(struct Node *tree, int cur) {
	if (cur == NIL) return;
	postorder(tree, tree[cur].left);
	postorder(tree, tree[cur].right);
	printf(" %d", cur);
}

int main() {
	int i, n, id, left, right, root;
	struct Node tree[MAX];

	scanf("%d", &n);
	for (i = 0; i < n; i++) tree[i].parent = NIL;

	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &id, &left, &right);
		tree[id].left = left;
		tree[id].right = right;
		if (left != NIL) tree[left].parent = id;
		if (right != NIL) tree[right].parent = id;
	}

	for (i = 0; i < n; i++) {
		if (tree[i].parent == NIL) {
			root = i;
			break;
		}
	}

	printf("Preorder\n");
	preorder(tree, root);
	printf("\n");
	printf("Inorder\n");
	inorder(tree, root);
	printf("\n");
	printf("Postorder\n");
	postorder(tree, root);
	printf("\n");

	return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define ll long long
#define double long double
#define INF 2000000000
#define INF2 2000000000000000000
 
using namespace std;
using cd = complex<double>;

const double PI = acos(-1);
const int mod = 200003;
const int primitive = 2;

int power(int x, int y) {
	if(y == 0)
		return 1;
	int a = power(x, y/2);
	a = (1LL * a * a)%mod;
	if(y%2)
		a = (1LL * a * x)%mod;
	return a;
}

void fft(vector<cd> & a, bool invert) 
{
    int n = a.size();

    for (int i = 1, j = 0; i < n; i++) 
    {
        int bit = n >> 1;
        for (; j & bit; bit >>= 1)
            j ^= bit;
        j ^= bit;

        if (i < j)
            swap(a[i], a[j]);
    }

    for (int len = 2; len <= n; len <<= 1) 
    {
        double ang = 2 * PI / len * (invert ? -1 : 1);
        cd wlen(cos(ang), sin(ang));
        for (int i = 0; i < n; i += len) 
        {
            cd w(1);
            for (int j = 0; j < len / 2; j++) 
            {
                cd u = a[i+j], v = a[i+j+len/2] * w;
                a[i+j] = u + v;
                a[i+j+len/2] = u - v;
                w *= wlen;
            }
        }
    }

    if (invert) 
    {
        for (cd & x : a)
            x /= n;
    }
}

void selfMultiply(vector<ll> &a) {

	vector<cd>fa(a.begin(), a.end());
	int n = 2*(a.size()) - 1;
	int N = 1;
	while(N < n)
		N *= 2;
	fa.resize(N, 0);
	fft(fa, false);	
	for(int i = 0; i < N; i++)
		fa[i] *= fa[i];
	fft(fa, true);
	fa.resize(n);
	a.resize(n, 0);
	for(int i = 0; i < n; i++)
		a[i] = round(fa[i].real());

}

int main() {
    
    IOS;
    int n;
    cin >> n;
    int freq[mod];
    memset(freq, 0, sizeof(freq));
    for(int i = 1; i <= n; i++) {
    	int x;
    	cin >> x;
    	freq[x]++;
    }
    vector<ll>polynomial(mod - 1, 0);
    for(int i = 0; i < mod - 1; i++) {
    	int val = power(primitive, i);
    	polynomial[i] = freq[val];
    }
    selfMultiply(polynomial);
   	ll sum = 0;
   	for(int i = 0; i < polynomial.size(); i++) {
   		ll val = polynomial[i];
   		val *= power(primitive, i);
   		sum += val;
   	}	
   	for(int i = 0; i < mod; i++) {
   		ll val = (1LL * i * i)%mod;
   		val *= freq[i];
   		sum -= val;
   	}
   	sum /= 2;
   	cout << sum;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    string s,t;
    cin >> s >> t;
    cout << t+s << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
C = LI()
mod = 10**9+7

C = [0] + sorted(C,reverse=True)

ans = 0
for i in range(1,N+1):
    ans += C[i]*(i+1)
    ans %= mod

ans *= pow(4,N-1,mod)
ans %= mod

print(ans)

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

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector <int> cnt(26);
    for (int i = 0; i < n; i++) {
        cnt[s[i] - 'a']++;
    }
    int ans = 1;
    for (int i = 0; i < 26; i++) {
        ans = (ans * (ll) (cnt[i] + 1)) % mod;
    }
    ans--;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main ()
{
    ll n;
    cin>>n;
    vector<ll> v;
    for(ll i=0;i<n;i++)
    {
        ll h;
        cin>>h;
        v.push_back(h);
    }
    ll a[n]={0};
    a[n-2]=abs(v[n-2]-v[n-1]);
    for(ll i=n-3;i>=0;i--)
    {
    a[i]=min(abs(v[i]-v[i+1])+a[i+1],abs(v[i]-v[i+2])+a[i+2]);
    }
    cout<<a[0]<<endl;
}

Measured memory_bytes: 1908
from collections import deque
k=int(input())
def bfs():
    q=deque([])
    for i in range(1,10):
        q.append(str(i))
    cnt=0
    while cnt<k:
        cnt+=1
        x=q.popleft()
        r=int(x[-1])
        if 1<=r:
            q.append(x+str(r-1))
        q.append(x+str(r))
        if r<=8:
            q.append(x+str(r+1))
    return x
print(bfs())

Measured memory_bytes: 17012
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int MIN=1e13;
    for(long long int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
           MIN=min(MIN,(i+n/i));
        }
    }
    cout<<MIN-2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define vstroku() to_string()
#define vchislo() to_ulong()
#define gcd(x,y) __builtin_gcd(x,y)
#define numberof1(x) __builtin_popcount(x)
#define povsemelementam(i,mnozh) for(auto i: mnozh)
#define podotrezok(i,j) substr(i-1,j) // like prefix sum, (i,j)=s[j]-s[i-1]
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back 
#define pii pair <int, int>
#define F first
#define S second
#define mipletsplay ios_base::sync_with_stdio(0); cin.tie(0); 


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 3e5;
const ll INF = 1e9;
const ll kek=998244353;
const ll mod=1e9+7;


ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
}

ll rec(ll n, ll k)
{
    if(n==k)
        return 1;
    if(k==1)
        return n;
    if (k==0)
    return 1;
    return (rec(n-1, k-1)%mod+rec(n-1, k)%mod)%mod;
}
int main() {
mipletsplay;
ll rec[2003][2003];
for (int i=0;i<2002;i++)
rec[i][1]=i;
for (int i=0;i<2002;i++)
rec[i][0]=1;
for (int i=0;i<2002;i++)
rec[i][i]=1;
for (int i=1;i<2002;i++)
{
for (int j=1;j<=i;j++)
{
if (j==1)
rec[i][j]=i;
else{
if (i==j)
rec[i][j]=1;
else{
if (j==0)
rec[i][j]=1;
else
rec[i][j]=rec[i-1][j-1]+rec[i-1][j];
rec[i][j]%=mod;}}}
}
int k,n;
cin>>n>>k;
for (int i=1;i<=k;i++)
{
ll h=rec[k-1][i-1];
ll f=rec[n-k+1][i];
cout<<(h*f)%mod<<endl;
}
}

Measured memory_bytes: 31488
#include "bits/stdc++.h"
using namespace std;
const int N = 505;
int n;
int c[N] , s[N] , f[N];
int main(){
	scanf("%d" , &n);
	for(int i = 1 ; i < n ; ++i){
		scanf("%d %d %d" , c + i , s + i , f + i);
	}
	for(int i = 1 ; i <= n ; ++i){
		int cur = 0;
		for(int j = i ; j < n ; ++j){
			int when;
			if(cur <= s[j]){
				when = s[j];
			}
			else{
				if((cur % f[j]) == 0){
					when = cur;
				}
				else{
					when = cur + f[j] - (cur % f[j]);
				}
			}
			cur = when + c[j];
		}
		printf("%d\n" , cur);
	}
}

Measured memory_bytes: 256
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS


   int a, p; cin>>a>>p;

   p += a*3;

   cout<<p/2;









   
   


}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, t, x, k, d;
int main() {
	cin >> x >> k >> d;
	x = abs(x);
	if (k < x / d) {
		cout << x - k * d << endl;
	}
	else if (x % d == 0) {
		ll t = x / d;
		k -= t;
		if (k & 1)cout << d << endl;
		else cout << 0 << endl;
	}
	else {
		ll t = x / d;
		k -= t;
		x -= t * d;
		if (k & 1)cout << abs(x - d) << endl;
		else cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int A[1000005],B[1000005],dp[100005][1],i,n,sum,say,a,b,c,d,e,f,mak,S,g,sum2,x,y,m,j,C[1000005],l,r,D[200005],k,T,say1,say2,say3 ;
 char s[1000005],ch;
vector<int> v1,v2,v;

 

int main(){
scanf("%d %d",&a,&b);
 c=a+b;
  if(c%2==1){printf("IMPOSSIBLE"); return 0; }
  if(c%2==0){printf("%d",c/2); return 0; }

	return 0;
}

Measured memory_bytes: 2304
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    k = int(input())
    s = input().strip()
    if k >= len(s):
        print(s)
    else:
        print(s[:k] +'...')


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 61784
#include<iostream>
#include<math.h>
using namespace std;

int main(){
	int N,M,X,i;
	cin >> N >> M >> X;
	int A[M+1];
	for (i=1;i<=M;i++){
		cin >> A[i];
	}
	i=1;
	while(1==1){
		if((i==M+1)||(X<=A[i])){
			break;
		}
		else i++;
	}
	cout <<(min(i-1,M-i+1)) <<endl;
	return 0;
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void solve(long long N, long long M, std::vector<long long> X) {
  sort(X.begin(), X.end());
  vector<ll> Y;
  for(int i = 0 ; i + 1 < X.size() ; i++) Y.push_back(X[i+1] - X[i]);
  sort(Y.rbegin(), Y.rend());
  ll sum = 0;
  for(int i = 0 ; i < N - 1 && i < Y.size() ; i++){
    sum += Y[i];
  }
  cout << X.back() - X.front() - sum << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> X(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &X[i]);
  }
  solve(N, M, std::move(X));
  return 0;
}



Measured memory_bytes: 4984
n = int(input())
val = []
for i in map(int, input().split()):
    val.append(i)
cost = []
for i in map(int, input().split()):
    cost.append(i)

ans = 0
for i in range(n):
    m = val[i] - cost[i]
    if m > 0:
        ans += m

print(ans)

Measured memory_bytes: 3064
#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define pb(n) push_back(n)
#define endl '\n'
#define debug(x) cout << #x << " = " << (x) << endl
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int ii = 0; ii < (V).size(); ii++) {cin >> (V).at(ii);}
#define OUT(n) cout << n << endl
#define OUT2(n1,n2) cout << n1 << " " << n2 << endl
#define OUT3(n1,n2,n3) cout << n1 << " " << n2 << " " << n3 << endl
#define VOUT(V) REP(ii,(V).size()){cout << (V)[ii] << " ";} cout<<endl;
#define VOUT2(V) REP(jj,(V).size()){VOUT(V[jj])}
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi > vvi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, cnt = 0; string s; char c; bool flg;

vi divisor(ll n) {
  vi ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  IN(n);
  FOR(i,1,n+1) {
    if (i%2==1 && divisor(i).size() == 8) ++ans;
  }
  OUT(ans);
}


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

int cnt[100010];
void init() {
    int p6 = 1, p9 = 1;
    for(int i = 1; i <= 100000; i++) {
        if(i == p6 * 6)
            p6 *= 6;
        if(i == p9 * 9)
            p9 *= 9;
        cnt[i] = min(cnt[i - p6], cnt[i - p9]) + 1;
    }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    init();
    int N;
    cin >> N;
    cout << cnt[N] << endl;
    return 0;
}

Measured memory_bytes: 640
from math import ceil

if __name__ == '__main__':
    n, k = map(int, input().split())
    a_str = input().split()
    a = []
    a_min = n + 1
    a_min_index = 0
    for i, a_i_str in enumerate(a_str):
        a_i = int(a_i_str)
        if a_i < a_min:
            a_min = a_i
            a_min_index = i

    n_left_elements = a_min_index
    left_count = ceil(n_left_elements / (k - 1))

    right_index_start = left_count * (k - 1)
    right_count = ceil((n - right_index_start - 1) / (k - 1))

    ans = left_count + right_count
    print(ans)


Measured memory_bytes: 11132
givenNumber = int(input())
honList = '2', '4', '5', '7', '9'
ponList = '0', '1', '6', '8'

if str(givenNumber).endswith(honList):
    print('hon')
elif str(givenNumber).endswith(ponList):
    print('pon')
elif str(givenNumber).endswith('3'):
    print('bon')


Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
 
int H, W;
vector<string> fi;
 
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
 
int main() {
    cin >> H >> W;
    fi.resize(H);
    for (int i = 0; i < H; ++i) cin >> fi[i];
 
    
    vector<vector<int> > dist(H, vector<int>(W, -1));
    using pint = pair<int,int>;
    queue<pint> que;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (fi[i][j] == '#') {
                dist[i][j] = 0;
                que.push(pint(i, j));
            }
        }
    }
    while (!que.empty()) {
        auto cur = que.front();
        que.pop();
        for (int dir = 0; dir < 4; ++dir) {
            int nx = cur.first + dx[dir];
            int ny = cur.second + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[cur.first][cur.second] + 1;
                que.push(pint(nx, ny));
            }
        }
    }
    int res = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            res = max(res, dist[i][j]);
        }
    }
    cout << res << endl;
}

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

int main() {
	int h,w,n;
	cin >> h;
	cin	>> w;
	cin >> n;
	if(h < w){
		if(n%w==0){
			cout << n / w << endl;
		}else{
			cout << n / w + 1 << endl;
		}
	}else{
		if(n%h==0){
			cout << n / h << endl;
		}else{
			cout << n / h + 1 << endl;
		}
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <limits>

using namespace std;

#define ll long long

#define in(x) cin >> x
#define out(x) cout << x << endl

#define PI acos(-1)
#define pp push_back

#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl

#define vec2(type) vector<vector<type>>
#define vec3(type) vector<vector<vector<type>>>

#define For(i, n) for(int i = 0; i < n; i++)

template<typename T> void input(T *data, int n){
	For(i, n){
		cin >> data[i];
	}
}

template<typename T> void input(vector<T> &vec, int n){
	T temp;
	For(i, n){
		cin >> temp;
		vec.push_back(temp);
	}
}

template<typename T> void sort(vector<T> &ary){
	sort(ary.begin(), ary.end());
}

template<typename T> void rsort(vector<T> &ary){
	sort(ary.rbegin(), ary.rend());
}

void rstring(string &str){
	string temp = str;

	For(i, (int)str.size()){
		str[i] = temp[(str.size() - 1) - i];
	}
}

struct Vec{
	int x, y;
	Vec():
	x(0), y(0){}
	Vec(int _x, int _y):
	x(_x), y(_y){}
};

template<typename T> void print(T *x, int n){
	For(i, n){
		cout << x[i] << " ";
	}
	cout << endl;
}

template<typename T> void print(vector<T> &x){
	For(i, (int)x.size()){
		cout << x[i] << " ";
	}
	cout << endl;
}

int gcd(int n, int m){
	if(n % m == 0){
		return m;
	}
	else{
		return gcd(m, n % m);
	}
}

int main(){

	int a, b, c;
	scanf("%d/%d/%d", &a, &b, &c);	

	if(a > 2019 || (a == 2019 && b > 4)){
		out("TBD");
	}
	else{
		out("Heisei");
	}

	return 0;

}

Measured memory_bytes: 256
R,G,B,N = map(int,input().split())

ans = 0
for b in range(N//B+1):
    for g in range((N-B*b)//G+1):
        Rr = N-B*b-G*g
        if Rr >= 0 and Rr%R == 0:
            ans += 1
print(ans)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MAX_N = (int)1e5 + 5;

bool used[MAX_N];

int main()
{
	memset(used, false, sizeof(used));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> A(N, 0), B(N, 0);
	rep (i, N){
		cin >> A[i] >> B[i];
	} // end rep

	vector<P> sum(N);
	rep (i, N){
		sum[i].first = - A[i] - B[i]; sum[i].second = i;
	} // end rep
	
	sort(ALL(sum));
	ll sumT = 0LL, sumA = 0LL;
	rep (i, N){
		if (i % 2 == 0){
			sumT += (ll)A[sum[i].second];
		}else{
			sumA += (ll)B[sum[i].second];
		} // end if
	} // end rep

	cout << sumT - sumA << endl;

	return 0;
}

Measured memory_bytes: 1920
#include<stdio.h>

int main(void){

  char c[10001];
  int i,sum;

  while(1){
    scanf("%s",c);
    if(c[0]=='0')
      break;
    sum=0;
    for(i=0;c[i]!='\0';i++){
      sum+=c[i]-'0';
    }
    printf("%d\n",sum);
  }
 return 0;
}

Measured memory_bytes: 1836
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    
    int ans = 0;
    
    for(int i = 0;i < S.length(); i++){        
        if(S.charAt(i)==T.charAt(i)){
            
        }else{
            ans++;
        }
    }
    
    System.out.println(ans);
    }
}

Measured memory_bytes: 32040
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;

string S;
string solve() {
    rep(msk, 0, 1 << 4) {
        string s = "";
        if (msk & (1 << 0)) s += "A";
        s += "KIH";
        if (msk & (1 << 1)) s += "A";
        s += "B";
        if (msk & (1 << 2)) s += "A";
        s += "R";
        if (msk & (1 << 3)) s += "A";

        if (S == s) return "YES";
    }
    return "NO";
}
signed main() {
    cin >> S;
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
const int MOD = 1000000007;

int main() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  printf("%.15lf ", W * H / 2);
  double mx = W / 2, my = H / 2;
  if(x == mx && y == my) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod = 1e9+7;
long double PI = acosl(-1);
const ll infl = 1e18;
const int inf = 2e9;
const int nmax = 1e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;



int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n;
    cin>>n;
    n%=1000;
    if(n) n=1000-n;
    cout<<n<<endl;

}
/*

*/


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 10000;

int main(void){
    bool isP[N + 1];
    MEMSET(isP, true);
    rep(i, 2) isP[i] = false;
    COUNT(i, N) if(isP[i]) for(int j = i; i * j <= N; j ++) isP[i * j] = false;

    vi res(N + 1);
    COUNT(i, N - 2) if(isP[i] & isP[i + 2]) fill(res.begin() + i + 2, res.end(), i + 2);
    
    for(int n; cin >> n, n; cout << res[n] - 2 << ' ' << res[n] << endl);
 
    return 0;
}

Measured memory_bytes: 1248
#include<iostream>
#include<cstdio>

int main(){
  int per;
  int num;
  scanf(" %d %d", &per, &num);
  int fir,las, prev, cur;
  int mx = 0;
  int cd = 0;
  scanf(" %d", &fir);
  prev = fir;
  for(int i = 1;i<num-1;i++){
    scanf(" %d", &cur);
    cd = cur-prev;
    mx = (mx>cd)?mx:cd;
    prev = cur;
  }
  scanf(" %d", &las);
  cur = las;
  cd = cur-prev;
  mx = (mx>cd)?mx:cd;
  prev = cur;
  
  cd = fir + per - las;
  mx = (mx>cd)?mx:cd;
  prev = cur;
  
  printf("%d\n",per-mx);
  return 0;
  
    
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int n;

int main() {

	FAST;

	cin >> n;
	vector <int> a(n + 1);
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	intt ans = 1000;
	intt cur_cnt = 0, cur_money = 1000;
	// k indicates whether we go up or down in stack
	// 0 --> we go down;
	// 1 --> we go up;
	a[0] = 201;
	a[n + 1] = 99;
	int k = ((a[0] <= a[1]) ? 0 : 1);
	for (int i = 1; i <= n + 1; i ++) {
		// cout << i << ' ' << k << '\n';
		if (k == 0) {
			if (a[i] >= a[i - 1]) continue;
			else {
				cur_money += cur_cnt * a[i - 1];
				cur_cnt = 0;
				k = 1;
			}
		}
		else {
			if (a[i] <= a[i - 1]) continue;
			else {
				cur_cnt += cur_money / a[i - 1];
				cur_money %= a[i - 1];
				k = 0;
			}
		}
		ans = max(ans, cur_money);
	}
	cout << ans << '\n';
	return 0;
}

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

#define nl '\n'
#define F fisrt
#define S second
#define pb push_back
#define mp make_pair
#define REP(i,a,b) for(int i = a; i < b; i++)
#define ForeachTC int t; cin >> t; while(t--)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef stack<int> si;
typedef deque<int> di;
typedef pair<int,int> pi;

class Solution {
public:
    int climbStairs(int n) {
		if(n <= 2)
			return n;
		else{
			return climbStairs(n-1) + climbStairs(n-2);
		}
    }
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	//code here
	int n; cin >> n;
	set<string> s;
	while(n--){
		string ss;
		cin >> ss;
		s.insert(ss);
	}
	cout << s.size();
}


Measured memory_bytes: 19240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

typedef pair<pll,ll> ppll;

int main() {
  ll n;
  cin >> n;
  vector<ppll> a(n);
  for(ll i=0;i<n;i++) {
    ll w,s,v;
    cin >> w >> s >> v;
    a[i]={{w+s,s},v};
  }
  sort(a.begin(),a.end());
  mat dp(n+1,vec(2e4+10));
  for(ll i=0;i<n;i++) {
    ll w=a[i].first.first-a[i].first.second;
    ll s=a[i].first.second;
    ll v=a[i].second;
    for(ll j=0;j<=2e4;j++) {
      dp[i+1][j]=dp[i][j];
      if(j>=1) dp[i+1][j] = max(dp[i+1][j],dp[i+1][j-1]);
      if(j>=w&&j-w<=s) {
        dp[i+1][j]=max(dp[i+1][j],dp[i][j-w]+v);
      }
    }
  }
  cout << dp[n][2e4] << endl;
}

Measured memory_bytes: 160640
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    if(n < 1200){
        P("ABC");
    }else if(n < 2800){
        P("ARC");
    }else{
        P("AGC");
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<iostream>
#define f(i,n) for (int i=0;i<(n);i++)
#define f1(i,n) for (int i=1;i<=(n);i++)
#define pb push_back
#define ms(a) memset((a),0,sizeof(a))
#define ll long long
#define vi vector<int>
#define mp make_pair
#define die assert(fasle)
#define pii pair<int,int>
#define INF 0x3f3f3f3f
#define N (int)1e5+5
using namespace std;
int n, m, q;
vi g[N];
int v[N], d[N], c[N];
int ans[N];
int lft;
int mds[N];
void dfs(int vv, int dd, int cc) {
	if (!lft) return;
	if (dd < 0) return;
	if (!ans[vv])ans[vv] = cc;
	if (dd <= mds[vv]) return;
	mds[vv] = dd;
	//printf("%d %d %d\n", vv, dd, cc);
	for (int i = 0; i < g[vv].size(); i ++) {
		if (!g[vv][i])lft --;
		dfs(g[vv][i], dd-1, cc);
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i ++) {
		int x, y;
		scanf("%d%d", &x, &y);
		g[x].pb(y);
		g[y].pb(x);
	}
	scanf("%d", &q);
	for (int i = 1; i <= q; i ++) {
		scanf("%d%d%d", &v[i], &d[i], &c[i]);
	}
	for (int i = 1; i <= n; i ++) {
		mds[i] = -1;
	}
	lft = n;
	for (int i = q; i >= 1; i --) {
		//puts("");
		dfs(v[i], d[i], c[i]);
//		for (int j = 1; j <= n; j ++) {
//			printf("%d ", ans[j]);
//		}
//		puts("");
//		printf("%d\n", lft);
//		puts("");
		if (!lft) break;
	}
	for (int i = 1; i <= n; i ++) {
		printf("%d\n", ans[i]);
	}
	return 0;
}


Measured memory_bytes: 8440
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        String a = values[0];
        String b = values[1];
        String c = values[2];
        if (a.equals(b) && a.equals(c)) {
            System.out.println("No");
        } else {
            if (a.equals(b) || a.equals(c) || b.equals(c)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 22228
def solve(inp):
    import math
    (A, B) = map(int, inp.readline().strip().split(' '))

    r = math.ceil((B - 1) / (A - 1))

    return str(r)


def main():
    import sys
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        private int R;
        private int G;
        private int B;

        private Dictionary<int, int> gbNumTable = new Dictionary<int, int>();
        private Dictionary<int, int> bNumTable = new Dictionary<int, int>();

        private int GetGBNum(int gbNum)
        {
            if (gbNumTable.ContainsKey(gbNum))
            {
                return gbNumTable[gbNum];
            }

            var answer = 0;
            for (int j = 0; j * this.G <= gbNum; j++)
            {
                var bNum = gbNum - (j * this.G);
                if (bNum == 0)
                {
                    answer++;
                    continue;
                }

                answer += this.GetBNum(bNum);
            }

            this.gbNumTable[gbNum] = answer;
            return answer;
        }

        private int GetBNum(int bNum)
        {
            if (bNumTable.ContainsKey(bNum))
            {
                return bNumTable[bNum];
            }

            var answer = 0;
            for (int k = 0; k * this.B <= bNum; k++)
            {
                var num = bNum - (k * this.B);
                if (num == 0)
                {
                    answer++;
                }
            }

            this.bNumTable[bNum] = answer;
            return answer;
        }

        public void Solve()
        {
            var inputs = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            this.R = inputs[0];
            this.G = inputs[1];
            this.B = inputs[2];
            var N = inputs[3];

            var answer = 0;
            for (int i = 0; i * R <= N; i++)
            {
                var gbNum = N - (i * R);
                if (gbNum == 0)
                {
                    answer++;
                    continue;
                }

                answer += this.GetGBNum(gbNum);
            }

            Console.WriteLine(answer.ToString());
        }
    }
}


Measured memory_bytes: 13536
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    double[] A=new double[N];
	    
	    double s=0;
	    for(int i=0; i<N;i++) {
	    	A[i]=gd();
	    	s+=(1/A[i]);
	    }
	   
        System.out.print(1/s);
//        if (c<=2) {
//        	System.out.println("YES");
//        }else {
//        	System.out.println("NO");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35908