akhauriyash/Code-Regression huggingface dataset:
/* Author rumoisen */
/* created 2018/10/24 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no() { cout << "No" << endl;exit(0);}
void yes() { cout << "Yes" << endl;exit(0);}
void No() { cout << "NO" << endl;exit(0);}
void Yes() { cout << "YES" << endl;exit(0);}

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main(void)
{
    int n, a[112345];
    cin >> n;
    REP(i, n){
        cin >> a[i];
    }
    bool two = false;
    int ans = 0, light = 1;
    for (int i = 0; i < n; i++ ){
        int d = light;
        light = a[d-1], ans++;
        if(light==2){
            two = true;
            break;
        }
        else
            continue;
    }
    if(two==true)
        cout << ans << endl;
        else
            cout << -1 << endl;
        return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007
#define iP pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define inf 1e15
#define mod1 998244353
#define pi 3.141592653589793238
#define lcm(a,b) a*(b/__gcd(a,b))
#define sz(x) (int)x.size()
#define cmp complex<double> 
int power(int x,int y){
    int res=1;
    x=x%mod1;
    while(y>0){
        if(y&1)res=(res*x)%mod1;
        x=(x*x)%mod1;
        y/=2;
    }
    return res;
}
void inline precompute(){
}
// void dfs(vector<int> adj[],int x,int par){
//     intime[x]=t++;
//     for(int i=1;i<=k;i++){
        
//     }
//     for(auto it: adj[x]){
//         if(it!=par){
//             dfs(adj,it,x);
//         }
//     }
//     outtime[x]=t++;
// }
void solve(int tc){
    double a,b;
    cin>>a>>b;
    cout<<(int)(a*b);
}
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(12);
    int t=1,ctr=0;
    // precompute();
    // cin>>t;
    while(t--){
        solve(ctr+1);
        ctr++;
    }
}

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

int main() {
  int N;
  cin >> N;
  
  if (N % 1111 == 0) {
    cout << "Yes" << endl;
  }
  else if (N / 10 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else if (N % 1000 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>
using namespace std;
typedef long long int ll;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; ll k; cin >> n >> k;
    vector<ll> a(n),f(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> f[i];
    }
    sort(a.rbegin(),a.rend());
    sort(f.begin(),f.end());
    vector<pair<ll,ll>> v;
    for(int i=0;i<n;i++){
        v.push_back({a[i]*f[i],f[i]});
    }
    sort(v.rbegin(),v.rend());
    ll left=-1,right=1e15;
    while(right-left>1){
        ll mid=(left+right)/2;
        ll sum=0;
        for(int i=0;i<n;i++){
            if(v[i].first>mid){
                sum+=(v[i].first-mid+v[i].second-1)/v[i].second;
            }
            else break;
        }
        if(sum<=k){
            right=mid;
        }
        else{
            left=mid;
        }
    }
    cout << right << endl;
}


Measured memory_bytes: 9584
#include<cstdio>
#include<algorithm>
#define N_ 310
using namespace std;
int D[2*N_][N_][N_], pv, Mod = 1000000007;
int chk[610], w[610], n, vis[610], cc;
int main() {
	int i, j, k, l;
	scanf("%d", &n);
	for (i = 1; i <= 2*n; i++) {
		scanf("%d", &w[i]);
		if (w[i] != -1)vis[w[i]] = 1;
	}
	for (i = 1; i <= 2 * n; i += 2) {
		if (w[i] != -1 && w[i + 1] != -1) {
			chk[w[i]] = chk[w[i + 1]] = 1;
		}
		if (w[i] == -1 && w[i + 1] == -1)cc++;
	}
	D[0][0][0] = 1;
	for (i = 1; i <= n + n; i++) {
		if (chk[i]) {
			for (j = 0; j <= n; j++)for (k = 0; k <= n; k++)D[i][j][k] = D[i - 1][j][k];
			continue;
		}
		for (j = 0; j <= n; j++) {
			for (k = 0; k <= n; k++) {
				long long t = D[i - 1][j][k];
				if (!t)continue;
				if (vis[i]) {
					D[i][j][k + 1] = (D[i][j][k + 1] + t) % Mod;
					if (j) {
						D[i][j - 1][k] = (D[i][j - 1][k] + t *j) % Mod;
					}
				}
				else {
					D[i][j][k + 1] = (D[i][j][k + 1] + t) % Mod;
					D[i][j + 1][k] = (D[i][j + 1][k] + t) % Mod;
					if (k) {
						D[i][j][k - 1] = (D[i][j][k - 1] + t) % Mod;
					}
				}
			}
		}
	}
	int res = D[n+n][0][0];
	for (i = 1; i <= cc; i++)res = 1ll * res*i%Mod;
	printf("%d\n",res);
}

Measured memory_bytes: 227072
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdio>

using namespace std;

typedef long long ll;


#define rep(i,b) for(ll i=0;i<(b);++i)
#define rep1(i,b) for(ll i=1;i<=(b);++i)
#define vec vector
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;


int H, W, _h, _w;

int main() {
   cin >> H >> W;
   cin >> _h >> _w;
   cout << H*W-W*_h - H*_w+_h*_w << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int a[101];
int temp=101;
int ans=0;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
		if(a[i]==a[i-1])
		{
			a[i]=temp;
			temp++;
			ans++;
		}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
signed main(){
    int a,b;
    cin>>a>>b;
    cout<<a+b/2<<endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>

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

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io 
	int a,b; cin>>a>>b;
	int ans=a-2*b;
	cout<<((ans>=0)?ans:0);
	
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   
    long int n;
    cin >> n;

    vector<long int> ai(1e5);

    REP(i, n) {
        long int a;
        cin >> a;

        ai[a]++;
        ai[a+1]++;
        ai[a+2]++;
    }

    cout << *max_element(ai.begin(), ai.end()) << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

vector< int > divisor(int n) {
  vector< int > ret;
  for(int 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),greater<int>());
  return (ret);
}

signed main(){
  string s,t;cin>>s>>t;
  int ans = 0;
  rep(i,3){
    if(s[i] == t[i])ans++;
  }
  cout << ans << endl;
}


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

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,k;
	cin >> n >>k;
	vector<ll> h(n);
	for(auto &i: h) cin >> i;
	vector<ll> dp(n);
	dp[0] = 0;
	if(n==1){
		cout<< 0;
		return 0;
	}
	for(int i=1;i<n;i++){
		dp[i] = 1e18;
		for(int j = i-1;j>=0 && i-j<=k;j--){
			dp[i] = min(dp[i],dp[j]+labs(h[j]-h[i]));
		}
	}
	cout << dp[n-1];
	
	return 0;
}

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

int main() {
  int N, A = 0, B = 0;
  cin >> N;
  vector<int> card(N);
  for (int i=0; i < N; i++) {
    cin >> card.at(i);
  }
  sort(card.begin(),card.end());
  for (int i=N - 1; i >= 0; i--) {
    if ((N - i) % 2 == 1) {
      A += card.at(i);
    }
    else {
      B += card.at(i);
    }
  }
  cout << A - B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;


const int INF = 1001001001;
int dp[1000005][2];

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

    reverse(N.begin(), N.end());

    N += '0';
    int n = N.size();
    rep(i, 0, n + 1) {
        rep(j, 0, 2) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    rep(i, 0, n) {
        rep(j, 0, 2) {
            int x = N[i] - '0';
            x += j;
            rep(a, 0, 10) {
                int ni = i + 1, nj = 0;
                int b = a - x;
                if (b < 0) {
                    nj = 1;
                    b += 10;
                }
                dp[ni][nj] = min(dp[ni][nj], dp[i][j] + a + b);
            }
        }
    }

    int ans = dp[n][0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9220
#include<iostream>
#include <algorithm>
#include <queue>

#define fr(i,y) for(int i=0;i<y;i++)

using namespace std;
long long int s;
	int main() {
		long long  n, m,a[10000];
		cin >> n >> m;
		fr(i, m)
		{
			cin >> a[i];
		}
		fr(i, m) {

			s += a[i];
			
		}
		if (s <= n)
				return cout << n - s , 0;
		cout << -1;
	}


Measured memory_bytes: 3668
def main():
    N, A, B = list(map(int, input().split()))
    ans = 0
    for i in range(1, N+1):
        i_str = str(i)
        sum_digit =  sum([int(i_str[j]) for j in range(len(i_str))])
        if (A <= sum_digit <= B):
            ans = ans + i
    print(ans)

main()


Measured memory_bytes: 41708
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdbool.h>

typedef  long long ll;

ll int_cmp(const void *a, const void *b) 
{ 
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib; 

} 



int max(int a,int b){
	if(a<b)
		a=b;
	return a;	
}

int min(int a,int b){
	if(a>b)
		a=b;
	return a;	
}

int absolu(int n){
	if(n<0)
		n*=-1;
	
	return n;	
}

void solve(){
	int l,r,d,ans=0,i;
	
	scanf("%d%d%d",&l,&r,&d);
	
	for(i=l ; i<=r ; i++){
		if(i%d==0)
			ans++;
	}
	
	printf("%d\n",ans);
}



int main(){
/*int t;
	scanf("%d",&t);
	while(t--)*/
		solve();
	
	return 0;
}	
					


Measured memory_bytes: 2152
#include<stdio.h>
#include<queue>
#include<math.h>
#include<time.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<map>
#include<stack>
#define LL long long
#define mem(a,b) memset(a,b,sizeof(a))
#define lowbit(a) a&(-a)
#define PI acos(-1)
#define shortime(a)  std::ios::sync_with_stdio(a);
using  namespace std;
//const LL mod=1e9+7;
//long long cmp(node a,node b){ if(a.x==b.x) return a.r>b.r;return a.x>b.x;}
LL  quick(LL x,LL n,LL mod){ LL ans=1,temp=x; while(n){if(n%2==1){ ans=(ans*temp)%mod;} n/=2;temp=temp*temp%mod;}return ans%mod;}
int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}
LL min(LL a,LL b) {return a<b?a:b;}
int gcd (int a,int b){return b==0?a:gcd(b,a%b);}
typedef pair <int ,int >node;
deque<node> Q;
int main()
{
   int n;
   scanf("%d",&n);
   node x;
   int vis[100005]={0};
   x.first=1;x.second=1;
   Q.push_front(x);
   while (!Q.empty())
   {
       node x=Q.front();
       Q.pop_front();
       if(vis[x.first]) continue;
       vis[x.first]=1;
       if(x.first==0) {
        printf("%d\n",x.second);
        return 0;
       }
       node temp=x;
       temp.first=(x.first*10)%n;
       Q.push_front(temp);
       temp=x;
       temp.first=(x.first+1)%n;
       temp.second++;
       Q.push_back(temp);
   }
   return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;

struct Tree {
  ll node_num;
  ll edge_num;
  ll diameter = -1;
  ll far_index = -1;
  vector<vector<ll>> to;
  vector<bool> visited;
  vector<int> depth;
  vector<int> point;

  Tree(ll nn) : node_num(nn){
    edge_num = node_num - 1;
    to = vector<vector<ll>> (node_num);
    visited = vector<bool> (node_num, false);
    depth = vector<int> (node_num);
    point = vector<int> (node_num);
  }


  pair<ll, ll> get_far(ll from, ll d){
    visited[from] = true;
    for(auto a : to[from]){
      if(!visited[a]){
        get_far(a, d+1);
      }
    }
    if(diameter < d){
      diameter = d;
      far_index = from;
    }
    return {far_index, diameter};
  }

  ll get_diameter(ll from){
    pair<ll, ll> i_and_d = get_far(0, 0);
    init();
    diameter = get_far(i_and_d.first, 0).second;
    init();
    return diameter;
  }

  void init(){
    visited = vector<bool> (node_num, false);
  }

  int now = 0;
  int set_depth(int from, int d){
    visited[from] = true;
    for(auto a : to[from]){
      if(!visited[a]) set_depth(a, d+1);
    }
    depth[from] = point[now];
    now++;
    return depth[from] = d;
  }
};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  Tree t(n);
  ll res = 0;
  vector<p> bridge(n-1);
  for (ll i = 0; i < n-1; i++) {
    ll from, to;
    cin >> from >> to;
    from--;to--;
    t.to[from].push_back(to);
    t.to[to].push_back(from);
    bridge[i] = {from, to};
  }
  vector<int> point(n);
  for (int i = 0; i < n; i++) {
    cin >> point[i];
  }
  sort(RALL(point));
  t.point = point;
  t.set_depth(0, 0);
  t.init();
  vector<p> tmp(n);
  for (int i = 0; i < n; i++) {
    tmp[i] = {t.depth[i], i};
  }
  sort(ALL(tmp));
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int index = tmp[i].second;
    mp[index] = t.point[i];
  }

  for(auto a : bridge){
    res += min(mp[a.first], mp[a.second]);
  }

  cout << res << endl;
  for(auto a : mp){
    cout << a.second << " ";
  }
  cout << endl;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= (m); --(i))
typedef long long ll;
using namespace std;
int main() {
    int n; ll l; cin >> n >> l;
    vector<ll> a(n); repeat (i,n) cin >> a[i];
    vector<int> ans;
    repeat (i,n-1) {
        if (a[i] + a[i+1] >= l) {
            repeat (j,i) ans.push_back(j);
            repeat_from_reverse (j,i,n-1) ans.push_back(j);
            break;
        }
    }
    if (ans.empty()) {
        assert (n >= 2);
        cout << "Impossible" << endl;
    } else {
        cout << "Possible" << endl;
        for (int i : ans) cout << i+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 4676
#include <stdio.h>

int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    while(1) {
        c=c-b; if(c<=0) { break; }
        a=a-d; if(a<=0) { break; }
    }
    if(c<=0) { printf("Yes\n"); }
    else { printf("No\n"); }

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int dNum = 0;
  for(int i = N; i > 0; i /= 10){
    dNum += i % 10;
  }
  if(N % dNum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import numpy as np
n=int(input())
x=np.array(list(map(int, input().split())))

lo=min(x)
hi=max(x)
ans=float('inf')
for p in range(lo, hi+1):
    newx=(x-p)**2
    tmp=np.sum(newx)
    ans=min(ans,tmp)
print(ans)

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

using namespace std;

int main()
{
	int n;
	cin>>n;
	int array[n] = {0};
	for(int i=0; i<n; i++)
	{
		cin>>array[i];
	}
	int sum=1;
	int min = array[0];
	for(int i=2; i<=n; i++)
	{
		if(array[i-1]<min)
		{
			sum+=1;
			min = array[i-1];
		}
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 1024
c = [list(map(int, input().split())) for _ in range(3)]

for b1 in range(101):
    a = [c[0][0] - b1, c[1][0] - b1, c[2][0] - b1]
    b = [b1, c[0][1] - a[0], c[0][2] - a[0]]
    if all(a[i] + b[j] == c[i][j] for j in range(3) for i in range(3)):
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
const int max_n = 200000;
long long cnt[111];
long long m,n,a,b;
const int INF = 1e8;
const int mod = 1e9 + 7;
long dist[max_n];
vector<vector<int> > G;
bool isprime(long long xx){
    if(xx == 2) return true;
    if(xx % 2==0 || xx<2)    return false;
    long long ii = 3;
    while(ii*ii <= xx){
        if(xx %ii == 0) return false;
        ii += 2;
    }
    return true;
}
long long gcd(long long xx, long long yy){
    if(yy == 0) return xx;
    long long k = xx/yy;
    long long c = xx - k*yy;
    return gcd(yy, c);
}
void solve(){
    long long count = 0;
    for(int i=0 ; i<n ; i++){
        if(isprime(dist[i]))    count++;
    }
    cout << count << endl;
}
int main(){
    cin >> n;
    for(int i=0 ; i<n ; i++){
        cin >> dist[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
  //cin>>t;
  int tt=1;
  while(t--){
    int a,b;
    cin>>a>>b;
    if(a>12)
      cout<<b;
    else if(a>5)
      cout<<(b/2);
    else cout<<0;
       //cout<<"Case #"<<tt<<": ";
       //tt++;
    }
  return 0;
}



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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n;

void read() {
  cin >> n;
}

void solve() {
  for(int i = 1; i < 10; ++i) {
    if (i * 111 >= n) {
      cout << i * 111;
      return;
    }
  }
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
from itertools import permutations

n, m = map(int, raw_input().split())

adj = [[] for _ in xrange(n)]
for i in xrange(m):
    a, b = map(int, raw_input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

ans = 0
for p in permutations(range(1, n)):
    f = True
    pos = 0
    for i in p:
        if i in adj[pos]:
            pos = i
        else:
            f = False
            break
    if f:
        ans += 1

print ans


Measured memory_bytes: 2692
i,c,a[2000];main(n,m){for(;scanf("%d%d",&n,&m),n;i=0){for(;n+m-i;scanf("%d",a+i++));for(i=c=0;c<n-1&(c+=a[c])<n-1;c+=a[n+i++]);printf("%d\n",i);}exit(0);}

Measured memory_bytes: 0
#include <stdio.h>

int n, A[50];

int solve(int i, int m) {
    if(m==0) return 1;
    if(i>=n || m<0) return 0;
    int res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main() {
    int q, M, i;
    
    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i=0; i<q; i++) {
        scanf("%d", &M);
        if (solve(0, M)) printf("yes\n");
        else printf("no\n");
    }
    
    return 0;
}


Measured memory_bytes: 2612
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<vector<ll>>ed(n);
  vector<pair<ll,ll>>e(n);
  rep(i,n-1){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    ed[a].push_back(b);
    ed[b].push_back(a);
    e[i]={a,b};
  }
  ll ma=0;
  rep(i,n){
    chmax(ma,(ll)ed[i].size());
  }
  cout<<ma<<endl;
  map<ll,ll> col;
  function<void(ll,ll,ll)> dfs=[&](ll no,ll pr,ll tc){
    ll dc=1;
    for(auto nn:ed[no]){
      if(nn==pr)continue;
      ll en1=(nn*n)+no;
      ll en2=(no*n)+nn;
      col[en1]=(tc+dc);
      col[en2]=(tc+dc);
      dfs(nn,no,(tc+dc));
      dc++;
    }
  };
  dfs(0,-1,1);
  rep(i,n-1){
    cout<<(col[e[i].first*n+e[i].second])%ma+1<<endl;
  }

  return 0;

}


Measured memory_bytes: 20864
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int num1 = scanner.nextInt();
			int num2 = scanner.nextInt();
			if (num1 == 0 && num2 == 0)
				break;
			else {
				if (num1 < num2)
					System.out.println(String.format("%s %s", num1, num2));
				else
					System.out.println(String.format("%s %s", num2, num1));
			}
		}
	}
}

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

using namespace std;

char a[100010];

int main()
{
    int l;
    scanf("%s",a);
    l=strlen(a);
    if(a[l-1]==a[0])
    {
        if(l%2==0)
            printf("First");
        else
            printf("Second");
    }
    else
    {
        if(l%2!=0)
            printf("First");
        else
            printf("Second");
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

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

int main(){
    int a, b;
    string s;
    cin >> a >> s >> b;
    if (s == "+"){
        cout << a + b << endl;
    }else if (s == "-"){
        cout << a - b << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int sumOf4(int n){
  int a, b, c, d, cout=0;
  for(a=0; a<=9; a++){
    for(b=0; b<=9; b++){
      for(c=0; c<=9; c++){
        for(d=0; d<=9; d++){
          if(a+b+c+d == n){
            cout += 1;
          }
        }
      }
    }
  }
  return cout;
}

int main(){
  int n;
  int cout;
  while(scanf("%d", &n)!=EOF){
    cout = sumOf4(n);
    printf("%d\n", cout);
  }
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int main(){
  int n,x;cin >> n;
  set<int> pool;
  REP(i,n){
    cin >> x;
    pool.insert(x);
  }
  cout << pool.size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=n;
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1]){
            ans--;
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  int n;
  cin >> n;
  set<int> st;
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    st.insert(a);
  }
  if((int)st.size()==n) puts("YES");
  else puts("NO");  
}

Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int N;
    long long p=0;
    cin >> N;
    vector<int> b(N);
    for(int i = 0; i < N; i++){
        cin >> b[i];
    }
    sort(b.begin(),b.end());
    for(int i = N-1; i > 1;i--){
        for(int j=i-1; j > 0;j--){
            int s =b[i]-b[j],k=j-1;
            while(s < b[k] && k>=0){
                p++;
                k--;
            }
        }
    }
    cout << p << endl;
}

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

int main()
{
	double a[100];
	double sum = 0;

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

	int max = *max_element(a ,a + n);

	double ans = sum - (max / 2.0);
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int maze[30][30];
int d[30][30];

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

  int H, W;
  cin >> H >> W;

  for(int i = 0; i < H+2; i++){
    for(int j = 0; j < W+2; j++){
      maze[i][j] = 0;
    }
  }

  string s;
  for(int i = 1; i <= H; i++){
    cin >> s;
    for(int j = 1; j <= W; j++){
      if(s[j-1] == '.'){
        maze[i][j] = 1;
      }
    }
  }

  int ans = -1;

  vector<int> dx({1, -1, 0,  0});
  vector<int> dy({0,  0, 1, -1});

  for(int i = 1; i <= H; i++){

    for(int j = 1; j <= W; j++){

      if(maze[i][j] == 0) continue;

      for(int h = 0; h < H+2; h++){
        for(int w = 0; w < W+2; w++){
          d[h][w] = -1;
        }
      }

      queue<pair<int, int>> q;
      q.push(make_pair(i, j));

      d[i][j] = 0;

      while(!q.empty()){

        auto cur = q.front();
        q.pop();
        
        int ci = cur.first;
        int cj = cur.second;

        for(int t = 0; t < 4; t++){

          int ni = ci + dx[t];
          int nj = cj + dy[t];

          if(maze[ni][nj] == 0) continue;

          if(d[ni][nj] >= 0) continue;

          d[ni][nj] = d[ci][cj] + 1;

          q.push(make_pair(ni, nj)); 
        }
      }

      for(int h = 1; h <= H; h++){
        for(int w = 1; w <= W; w++){
          chmax(ans, d[h][w]);
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
string s, r;

bool dfs(ll x, string t){
    if (x == 4) {
        return t == s;
    } else if (x == 0) {
        if (dfs(1, "KIH")) return true;
        if (dfs(1, "AKIH")) return true;
    } else if (x == 1) {
        if (dfs(2, t)) return true;
        if (dfs(2, t + 'A')) return true;
    } else if (x == 2) {
        if (dfs(3, t + 'B')) return true;
        if (dfs(3, t + "BA")) return true;
    } else if (x == 3) {
        if (dfs(4, t + 'R')) return true;
        if (dfs(4, t + "RA")) return true;
    }
    return false;
}

int main(void){
    // Your code here!
    cin >> s;
    if (dfs(0, r)) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
to_bin = dict(zip([chr(i) for i in range(ord("A"), ord("Z") + 1)] + [" ", ".", ",", "-", "'", "?"],
                  [bin(i)[2:7].zfill(5) for i in range(2 ** 5)]))
to_chr = {"101": " ", "000000": "'", "000011": ",", "10010001": "-", "010001": ".", "000001": "?", "100101": "A",
          "10011010": "B",
          "0101": "C", "0001": "D", "110": "E", "01001": "F", "10011011": "G", "010000": "H", "0111": "I",
          "10011000": "J",
          "0110": "K", "00100": "L", "10011001": "M", "10011110": "N", "00101": "O", "111": "P", "10011111": "Q",
          "1000": "R",
          "00110": "S", "00111": "T", "10011100": "U", "10011101": "V", "000010": "W", "10010010": "X", "10010011": "Y",
          "10010000": "Z"}

while 1:
    try:
        N=list(input())
        first = ""
        for i in N:
           if i in to_bin:first +=to_bin[i]
        first = list(first)
        key=""
        answer = ""
        for j in first:
            key +=j
            if key in to_chr:
                answer +=to_chr[key]
                key = ""
        print(answer)
    except:break


Measured memory_bytes: 5592
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
	int r;
	cin>>r;
	print(r*r);
  return 0;
}

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

#define   ll     long long int

int main( )
{
    int i, mx, mn, j, n;
    cin >> n;
    mx = 0, mn = 1e9;
    for (i = 1; i <= n; i++) {
        cin >> j;
        mx = max(mx, j);
        mn = min(mn, j);
    }
    cout << (mx - mn) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
//O(n)で すべての(n,k)の組での nCk%MOD を求める(n=MAX)

const int MAX = 200000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long int POW(int n,int k){
	long long int r;
	if(k==0)return 1;
	r=POW(n,k/2)%MOD;
	r=(r*r)%MOD;
	if(k%2)r=(n*r)%MOD;
	return r;
}
int main(){
	COMinit();
	int N,M,K,ans=0;
	cin>>N>>M>>K;
	for(int i=0;i<=K;i++){
		ans+=M*POW(M-1,N-1-i)%MOD*COM(N-1,i)%MOD;
		ans%=MOD;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8296
#include <iostream>
#include <algorithm>
using namespace std;

#define MAX_VERTEX 100
#define INF 1000000

int vertex_num;   // ???????????°

int cost[MAX_VERTEX][MAX_VERTEX]; // ????????????cost[?§????][??????]??§?§?????????????????????????????????¨???
int d[MAX_VERTEX];                // ????????????d[u]??§?§??????¨u??????????????¢?????¨??????
bool used[MAX_VERTEX];            // ????????????????????£????????¢????±???????????????????

void Input() {
	cin >> vertex_num;

	// (a1) ??\???????????¶??§?????????
	// d??¨cost?????¨???INF
	// used????????????false
	for (int i = 0; i < vertex_num;i++){
		d[i] = INF;
		used[i] = false;
		for (int j = 0; j < vertex_num;j++){
			cost[i][j] = INF;
		}
	}

	for (int i = 0; i < vertex_num; i++) {
		int from, out_num;
		cin >> from >> out_num;
		for (int j = 0; j < out_num; j++) {
			int to, c;
			cin >> to >> c;
			cost[from][to] = c;
		}
	}
}

void Dijkstra() {
	// (b1) ?§????????????????
	d[0] = 0;
	while (true) {
		// ????????????????????¨???
		int vertex = -1;

		// (b2) ????????????????????£????????¢????±??????????????????????
		// ?????????????????????????????????????????§????????¢???????°???????????????¢???
		for (int i = 0; i < vertex_num; i++){
			if (!used[i] && (vertex == -1 || d[i] < d[vertex])){
				vertex = i;
			}
		}

		// ??¨????????????????????????????¨?????????????????????´????????????????????????
		if (vertex == -1) break;

		used[vertex] = true;

		// ???????????¢????¨????????????????
		for (int u = 0; u < vertex_num; u++) {
			d[u] = min(d[u], d[vertex] + cost[vertex][u]);
		}

	}

}

void Output() {
	for (int i = 0; i < vertex_num; i++) {
		cout << i << " " << d[i] << endl;
	}
}

int main() {

	Input();
	Dijkstra();
	Output();

	return 0;
}

Measured memory_bytes: 3120
N = gets.to_i
prev_t = 0
prev_x = 0
prev_y = 0
N.times.each do
  t, x, y = gets.split.map(&:to_i)
  move_count = (prev_x - x).abs + (prev_y - y).abs
  can_move_count = t - prev_t
  if move_count > can_move_count || (can_move_count - move_count).odd?
    puts 'No'
    exit
  end
  prev_t = t
  prev_x = x
  prev_y = y
end
puts 'Yes'


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include <bits/stdc++.h>

using namespace std;
using Graph = vector<vector<int>>;
typedef unsigned long long ll;
ll mod = (10e+8)+ 7;

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


int main(){
	
	int N;
	cin>>N;
	cout<<N*N/1<<endl;
	
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll count[n][3]={};
	for(ll i=1;i<n;i++){
		count[i][0]=count[i-1][0];
		count[i][1]=count[i-1][1];
		count[i][2]=count[i-1][2];
		if(s[i-1]=='R') count[i][0]++;
		else if(s[i-1]=='G') count[i][1]++;
		else count[i][2]++;		
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<i;j++){
			if(s[j]==s[i]) continue;
			ll ind= 2*j-i;
			if(s[i]=='R' && s[j]=='G'){
				ans+= count[j][2];
				if(ind>=0 && s[ind]=='B') ans--;
			}
			if(s[i]=='R' && s[j]=='B'){
				ans+= count[j][1];
				if(ind>=0 && s[ind]=='G') ans--;
			}
			if(s[i]=='G' && s[j]=='R'){
				ans+= count[j][2];
				if(ind>=0 && s[ind]=='B') ans--;
			}
			if(s[i]=='G' && s[j]=='B'){
				ans+= count[j][0];
				if(ind>=0 && s[ind]=='R') ans--;
			}
			if(s[i]=='B' && s[j]=='R'){
				ans+= count[j][1];
				if(ind>=0 && s[ind]=='G') ans--;
			}
			if(s[i]=='B' && s[j]=='G'){
				ans+= count[j][0];
				if(ind>=0 && s[ind]=='R') ans--;
			}
		}
	}
 	cout<<ans;
	return 0;
}

Measured memory_bytes: 3752
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        char[] S = s.toCharArray();
        char[] T = t.toCharArray();
        int slen = S.length;
        int tlen = T.length;
        char[] ans = null;
        for(int i=0;i<slen-tlen+1;i++){
            if(diffCheck(S, T, i)){
                char[] tans = S.clone();
                for(int j=i;j<i+tlen;j++){
                    tans[j] = T[j-i];
                }
                if(ans == null || diff(ans,tans)>0){
                    ans = tans;
                }
            }
        }
        if(ans == null){
            System.out.println("UNRESTORABLE");
        }else{
            for(int i=0;i<ans.length;i++) ans[i]=ans[i]=='?'?'a':ans[i];
            System.out.println(String.valueOf(ans));
        }
    }
    private static int diff(char[] a, char[] b){
        for(int i=0,e=Math.min(a.length,b.length);i<e;i++){
            char c1 = a[i]=='?'?'a':a[i];
            char c2 = b[i]=='?'?'a':b[i];
            if(c1<c2) return -1;
            if(c1>c2) return 1;
        }
        return 0;
    }
    private static boolean diffCheck(char[] a, char[] b, int as){
        for(int i=0;i<b.length;i++){
            if(a[i+as] != b[i]){
                if(a[i+as] != '?'){
                    return false;
                }
            }
        }
        return true;
    }
}


Measured memory_bytes: 23888
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int n,q,a;
int vec[100005],sz;
int f[100005];
void go(int x,int mul){
	if(x<=n){
		f[x]+=mul;
		return;
	}
	int pos=lower_bound(vec+1,vec+sz+1,x)-vec-1;
//	if(pos<0)cerr<<x<<" "<<vec[0]<<endl,assert(0);
	int val=vec[pos];
	go(val,mul*(x/val));
	go(x%val,mul);
}
map<int,int>mul;
signed main(){
//	freopen("input.txt","r",stdin);
	cin>>n>>q;
	vec[++sz]=n;
	while(q--){
		int x;cin>>x;
		while(sz&&vec[sz]>=x)sz--;
		vec[++sz]=x;
	}
	int nn=n;n=min(n,vec[1]);
	mul[vec[sz]]=1;
	for(auto itr=mul.rbegin();itr!=mul.rend();itr++){
		int x=itr->first,v=itr->second;
		if(x<=n)break;
		int pos=lower_bound(vec+1,vec+sz+1,x)-vec-1;
		int val=vec[pos];
//		cerr<<x<<" "<<val<<" "<<x%val<<" "<<v<<endl;
		mul[val]+=(x/val)*v;
		mul[x%val]+=v;
	}
	for(int i=1;i<=n;i++)f[i]=mul[i];
	for(int i=n-1;i>=1;i--)f[i]+=f[i+1];
	for(int i=1;i<=nn;i++){
		cout<<f[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 29652
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
int a,b,c,d,e,f,mx,cnt,sum,suger;
double mxm; 
bool p[3010],w[3010];
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main()
{
	a=read();b=read();
	c=read();d=read();
	e=read();f=read();
	w[0]=true;
	for(int i=1;i<=f;i++)
	{
		if(i>=a&&w[i-a])w[i]=true;
		if(i>=b&&w[i-b])w[i]=true;
	}
	p[0]=true;
	for(int i=1;i<=f;i++)
	{
		if(i>=c&&p[i-c])p[i]=true;
		if(i>=d&&p[i-d])p[i]=true;
	}
	for(int i=1;i<=f;i++)
	{
		if(!p[i])continue;
		int water=-1;
		for(int j=((i-1)/e)+1;j<=(f-i)/100;j++)
			if(w[j]){water=j;break;}
		if(water==-1)continue;
		if(100.0*i/(i+water*100)>mxm)
		{
			mxm=100.0*i/(i+water*100);
			sum=i+water*100;
			suger=i;
		}
//		printf("%d %d %.6lf\n",i,water,mxm);
	}
	if(sum==0&&suger==0)sum=a*100;
	printf("%d %d",sum,suger);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
    char c;
    cin >> c;
    if(c == 'A') cout << 'T' << endl;
    if(c == 'T') cout << 'A' << endl;
    if(c == 'C') cout << 'G' << endl;
    if(c == 'G') cout << 'C' << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stack>
using namespace std;
int main()
{
	int n,m,s;
	char a[100];
	scanf("%s",a);
	if(strcmp(a,"SUN")==0)
	printf("7\n");
	if(strcmp(a,"MON")==0)
	printf("6\n");
	if(strcmp(a,"TUE")==0)
	printf("5\n");
	if(strcmp(a,"WED")==0)
	printf("4\n");
	if(strcmp(a,"THU")==0)
	printf("3\n");
	if(strcmp(a,"FRI")==0)
	printf("2\n");
	if(strcmp(a,"SAT")==0)
	printf("1\n");
 } 

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
using namespace std;
int T, n, m, k, x;
#define ll long long
const int maxn = 1e5 + 5;
int a[51][51];
bool r[51], c[51];
void init()
{
	for (int i = 0; i < 51; i++)r[i] = 0;
	for (int i = 0; i < 51; i++)c[i] = 0;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++)
	{
		cout << s[i];
	}
}


Measured memory_bytes: 3648
#include<iostream>

using namespace std;

typedef long long ll;

ll modpow(ll a,ll p){
  if(p==0) return 1;
  if(p%2==0){
    ll halfP = p/2;
    ll half = modpow(a,halfP);
    return half * half;
  }
  else{
    return a * modpow(a,p - 1);
  }
}

void chmin(ll &a,ll b){
  if(a > b) a = b;
}

int main(){
  int N,i,j;
  cin >> N;
  ll dp[111111];
  dp[0] = 0;
  for(i=1;i<=N;i++)
    dp[i] = 11111111111;
  for(i=1;i<=N;i++){
    chmin(dp[i],dp[i-1]+1);
    for(j=1;modpow(6,j)<=i;j++) chmin(dp[i],dp[i-modpow(6,j)]+1);
    for(j=1;modpow(9,j)<=i;j++) chmin(dp[i],dp[i-modpow(9,j)]+1);
    }
  cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

void solve (int n, int st, int s) {
    if (n <= 0) return;
    // n keta st start sum s
    vector<vector<int> > dp(n, vector<int>(10));
    rep (i, 10) dp[n - 1][i] = 1;
    reprev (i, n - 1) {
        rep (j, 10) {
            rep (k, -1, 2) {
                if (j + k >= 0 && j + k < 10) dp[i][j] += dp[i + 1][j + k];
            }
        }
    }
    eprintf("ok ");
    if (st == -1) {
        int sum = 0, tmp_sum = 0;
        rep (i, 1, 10) {
            tmp_sum = sum;
            sum += dp[0][i];
            if (tmp_sum < s && sum >= s) {
                cout << i;
                eprintf(": %d\n", tmp_sum);
                solve (n - 1, i, s - tmp_sum);
                break;
            }
        }
    } else {
        // cout << n;
        int sum = 0, tmp_sum = 0;
        rep (i, max(st - 1, 0), min(10, st + 2)) {
            tmp_sum = sum;
            sum += dp[0][i];
            if (tmp_sum < s && sum >= s) {
                cout << i;
                eprintf(": %d(%d)\n", tmp_sum, n);
                solve (n - 1, i, s - tmp_sum);
                break;
            }
        }
    }
}

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k; cin >> k;
    int sum = 0, ket = 0;
    int n = 11;
    vector<vector<int> > dp(n, vector<int>(10));
    rep (i, 10) dp[n - 1][i] = 1;
    reprev (i, n - 1) {
        rep (j, 10) {
            rep (l, -1, 2) {
                if (j + l >= 0 && j + l < 10) dp[i][j] += dp[i + 1][j + l];
            }
        }
    }
    sum = 0;
    int tmp_sum = 0;
    while (sum <= k) {
        tmp_sum = sum;
        rep (j, 1, 10) sum += dp[n - 1 - ket][j];
        rep (j, 1, 10) eprintf("%d ", dp[n - ket - 1][j]); eprintf("\n");
        ket++;
    }
    eprintf("%d %d\n", ket, k - tmp_sum);
    solve(ket, -1, k - tmp_sum);
    return 0;
}

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

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

int N,M,Q;

bool ok[36][1000];
bool state[1000],nxstate[1000];

void solve(){
    rep(i,N)rep(j,M)ok[i][j]=true;
    rep(i,M)state[i]=false;
    bool isput[36];
    rep(i,Q){
        rep(j,N){
            char c;scanf(" %c",&c);
            isput[j]=c=='1';
        }
        rep(j,M){
            char c;scanf(" %c",&c);
            nxstate[j]=c=='1';
        }

        rep(j,M){
            rep(k,N){
                if(state[j]==nxstate[j]&&isput[k])ok[k][j]=false;
                else if(state[j]!=nxstate[j]&&!isput[k])ok[k][j]=false;
            }
        }
        rep(j,M)state[j]=nxstate[j];
    }

    rep(i,M){
        int cnt=0;
        rep(j,N)cnt+=ok[j][i];
        if(cnt!=1)printf("?");
        else{
            int s;
            rep(j,N)if(ok[j][i])s=j;
            if(s<10)printf("%d",s);
            else printf("%c",'A'+s-10);
        }
    }
    puts("");
}

signed main(){
    while(scanf("%d%d%d",&N,&M,&Q),N||M||Q)solve();
    return 0;
}

Measured memory_bytes: 1236