akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int ba[8][8];
int dx[] ={0,1,0,-1};
int dy[] ={-1,0,1,0};
typedef pair<int,int> pii;
vector<pair<int, pii> > v;
int n;

bool solve(int);

bool visited[8][8];
int cnt = 0;
bool rec(int x, int y, int sum, int k) {
//  printf("x=%d,y=%d, sum=%d, k=%d\n",x,y,sum,k);
  REP(i,4) {
    int xx = x+dx[i];
    int yy = y+dy[i];
    if (xx<0||xx>=n||yy<0||yy>=n) continue;
    if (visited[xx][yy] || ba[xx][yy] < 0) continue;

    if (sum + ba[xx][yy] > v[k].first) continue;
    visited[xx][yy] = 1;
    cnt++;
    if (sum + ba[xx][yy] == v[k].first) {
      //        printf("OK %d,%d\n", xx,yy);
      if(solve(k+1))
        return 1;
    } else  if (rec(xx,yy,sum+ba[xx][yy],k))
      return 1;
    visited[xx][yy] = 0;
    cnt--;
  }
  return 0;
}

bool solve(int k) {
//  cout << "k="<<k <<  endl;
  if (k==v.size()) {
    if (cnt == n*n-v.size()) return 1;
    else return 0;
  }
  pii p = v[k].second;
  int x = p.first, y = p.second;
//  cout << x << " " << y << endl;
  if (rec(x,y,0,k))
    return 1;
  return 0;
}

int main() {
  while(cin >> n,n) {
    v.clear();
    REP(y,n) {
      REP(x,n) {
        cin >> ba[x][y];
        if (ba[x][y] < 0) {
          v.push_back(make_pair(-ba[x][y], pii(x,y)));
        }
      }
    }
    sort(ALL(v));
    // FOR(it, v) {
    //   pii p = it->second;
    //   cout << it->first << " " << p.first << ", " << p.second << endl;
    // }
    memset(visited,0,sizeof(visited));
    cnt = 0;
    if (solve(0))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <list>
#include <string>
#include <vector>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstring>

using namespace std;

const char* INSERT       = "insert";
const char* DELETE       = "delete";
const char* DELETE_FIRST = "deleteFirst";
const char* DELETE_LAST  = "deleteLast";

int main(void) {

    int n;
    cin >> n;

    list<int> nodes;
    char command[15];
    for (int i = 0; i < n; ++i) {
//        cin >> command;       // NG?
        scanf("%s", command);   // OK?
//        printf("[echo] %s\n", command);
//        cout << "[echo] " << command << endl;
        if (strncmp(command, INSERT, 6) == 0) {
//            printf("[command] Insert\n");
            int x;
            cin >> x;
            nodes.push_front(x);
        }
        else if (strncmp(command, DELETE_FIRST, 11) == 0) {
//            printf("[command] Delete First\n");
            nodes.pop_front();
        }
        else if (strncmp(command, DELETE_LAST, 10) == 0) {
//            printf("[command] Delete Last\n");
            nodes.pop_back();
        }
        else if (strncmp(command, DELETE, 6) == 0) {
//            printf("[command] Delete\n");
            int x;
            cin >> x;
            list<int>::iterator it;
            for (it = nodes.begin(); it != nodes.end(); ++it) {
                if (*it == x) {
                    break;
                }
            }
            if (it != nodes.end()) {
                nodes.erase(it);
            }
        }
    }

    list<int>::iterator it = nodes.begin();
    printf("%d", *it);
    for ( ++it ; it != nodes.end(); ++it) {
        printf(" %d", *it);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 32460
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

struct UnionFind {
    vector<ll> d;
    UnionFind(ll n = 0): d(n, -1) {}
    ll find(ll x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(ll x, ll y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(ll x, ll y) { return find(x) == find(y); }
    ll size(ll x) { return -d[find(x)]; }
};

int main() {
    ll N, M; cin >> N >> M;
    vector<ll> A(M), B(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
    }
    vector<ll> ans(M);
    ll cnt = N * (N-1) / 2;
    UnionFind uf(N);
    for (int i = M-1; i >= 0; i--) {
        ans[i] = cnt;
        if (!uf.same(A[i], B[i])) {
            cnt -= uf.size(A[i]) * uf.size(B[i]);
            uf.unite(A[i], B[i]); 
        }
    }
    for (int i = 0; i < M; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 6432
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
#include<time.h>
#include<map>
#include<set>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e16
using namespace std;
typedef pair<ll, ll> P;
vector<ll>a[100000];

int main(void) {
	ll n, a, b;
	cin >> n >> a;
	if (n < a)cout << 0 << endl;
	else cout << 10 << endl;
	return 0;
}

Measured memory_bytes: 2560
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(e,t){e.exports=function(e){var t=e.split(" "),r=Number(t[0]),n=Number(t[1]);r<=8&&n<=8?console.log("Yay!"):console.log(":(")}},,,,function(e,t,r){r(0)(r(5).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 21064
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<utility>
#include<functional>
#include<iomanip>
#include<sstream>
#include<ctime>
#include<cassert>
using namespace std;
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fil(a,b) memset((a),(b),sizeof(a))
#define cl(a) fil(a,0)
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define rep(i,a,b) for (int i=(a),_ed=(b);i<_ed;i++)
#define per(i,a,b) for (int i=(b)-1,_ed=(a);i>=_ed;i--)
#define forg(i,gu) for (int i=gu;~i;i=e[i].next)
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
void getre(){int x=0;printf("%d\n",1/x);}
void gettle(){int res=1;while(1)res<<=1;printf("%d\n",res);}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}
template<typename N,typename PN>inline N flo(N a,PN b){return a>=0?a/b:-((-a-1)/b)-1;}
template<typename N,typename PN>inline N cei(N a,PN b){return a>0?(a-1)/b+1:-(-a/b);}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
template<typename N>inline int sgn(N a){return a>0?1:(a<0?-1:0);}
#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
#define lld "%I64d"
#else
#define lld "%lld"
#endif
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
#ifdef JCVB
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
typedef long long ll;
typedef double db;
inline ll sqr(ll a){return a*a;}
inline db sqrf(db a){return a*a;}
const int inf=0x3f3f3f3f;
const db pi=3.14159265358979323846264338327950288L;
const db eps=1e-6;
//const int mo=0;
//int qp(int a,ll b){int n=1;do{if(b&1)n=1ll*n*a%mo;a=1ll*a*a%mo;}while(b>>=1);return n;}

char s[111111];
int main()
{
#ifdef JCVB
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	int _time_jc=clock();
#endif
	int n;
	gs(s+1);
	n=strlen(s+1);

	int su=0;
	rep(i,1,n+1)
		if(s[i]=='p')su--;
	su+=n/2;
	printf("%d\n",su);


#ifdef JCVB
	debug("time: %d\n",int(clock()-_time_jc));
#endif
	return 0;
}




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

const int N = 5010;
long long dp[N];

int main() {
  int n;
  int m;
  scanf("%d%d", &n, &m);
  dp[0] = 1;
  for (int i = 1; i < n; i++) {
    int coef = min(i, n - i + 1);
    for (int j = coef; j < n; j++) {
      dp[j] += dp[j - coef];
      dp[j] %= m;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += dp[i] * (n - i) % m;
    ans %= m;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ABC_095_C
//
//  Created by Joe Mori on 2020/06/28.
//  Copyright © 2020 Joe Mori. All rights reserved.
//

#include <iostream>
#include<vector>

int main(int argc, const char * argv[]) {
    // insert code here...
    long long int A,B,C,X,Y,count;
    std::cin>>A>>B>>C>>X>>Y;
    count=A*X+B*Y+2*C*(X+Y);
    long long int zero=0;
    for(long long int i=0;i<=std::max(X,Y);i++){
        count=std::min(count,C*2*i+A*std::max((X-i),zero)+B*std::max((Y-i),zero));
    }
    std::cout<<count<<std::endl;
    return 0;
}


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

// headers {{{
using namespace std;
// using namespace rel_ops;
 
const double pi=acos(-1.0);
const double eps=1e-11;
const int INF=0x7FFFFFFF;
template<class T> inline bool checkmin(T &a,T b){return b<a?a=b,1:0;}
template<class T> inline bool checkmax(T &a,T b){return b>a?a=b,1:0;}
template<class T> inline T sqr(T x){return x*x;}
template<class T> inline bool bit(T a, int b) {return (a>>b)&1;}
inline int popcount(int n) { return __builtin_popcount(n); }
inline int popcount(long long n) { return __builtin_popcountll(n); }
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define eb(args...) emplace_back(args)
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ff first
#define ss second
#define sz(g) int(g.size())
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
#ifdef LOCAL
#define dout cerr 
void out() { dout << endl; }
template<typename A, typename... B> void out(A a, B... b) { dout << ' ' << a; out(b...); }
#define dbg(args...) dout << __LINE__ << ":(" << #args << ") -> ", out(args)
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
constexpr bool local = true;
#else
#define dbg(...)
#define dout if(true);else cerr
#define out(...)
#define show(...)
constexpr bool local = false;
#endif
// }}}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    int n, k;
    while (cin >> n >> k) {
        VI v(n);
        rep(i, n) cin >> v[i];
        sort(v.begin(), v.end());
        int s = 0;
        rep(i, k) s += v[i];
        cout << s << endl;
    }
    return 0;
}



Measured memory_bytes: 3616
i = false

while true
  cost = gets.to_i/10
  break if cost==0

  puts "" if i
  i = true
  
  m1,m5,m10,m50 = gets.split(" ").map{|s| s.to_i}

  n = m1+5*m5+10*m10+50*m50

  for i in 0..m1
    for j in 0..m5
      for k in 0..m10
        for l in 0..m50
          change = i + j*5 + k*10 + l*50 - cost
          if change >= 0
            mm1 = m1-i+change%5
            mm5 = m5-j+(change%10)/5
            mm10 = m10-k+(change%50)/10
            mm50 = m50-l+(change/50)

            nn = mm1+mm5+mm10+mm50
            a1,a5,a10,a50,n = i,j,k,l,nn if n>nn

          end
        end
      end
    end
  end

  puts "10 #{a1}" if a1!=0
  puts "50 #{a5}" if a5!=0
  puts "100 #{a10}" if a10!=0
  puts "500 #{a50}" if a50!=0
end

Measured memory_bytes: 8816
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,d=0,e=0,f=0;
	string c;
	cin>>a>>b>>c;
	for(int i=0;i<c.size();i++){
		if(c[i]!='-' && i<a){
			d++;
		}else if(c[i]=='-' && i==a){
			e++;
		}else if(c[i]!='-' && i>a){
			f++;
		}
	}
	if(d==a&&e==1&&f==b){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n=0,kaisu=0;
	while(cin>>n){
		for(int a=0;a<10;a++){
			for(int b=0;b<10;b++){
				for(int c=0;c<10;c++){
					for(int d=0;d<10;d++){
						if(a+b+c+d==n){
							kaisu++;
						}
					}
				}
			}
		}
		cout<<kaisu<<endl;
		kaisu=0;
	}
}

Measured memory_bytes: 3012
#include<stdio.h>
#include<string.h>

int main()
{
	char s[205],a[205],b[205];
	scanf("%s",a);
	scanf("%s",b);
	int l=strlen(a);
	int i;
	for(i=0;i<l;i++)
	{
		s[i]=b[i];
		s[i+l]=b[i];
	}
	int f=1;
	int j;
	for(i=0;i<l;i++)
	{
		f=1;
		for(j=0;j<l;j++)
		{
			if(s[j+i]!=a[j])f=0;
		}
		if(f) break;
	}
	if(f) printf("Yes\n");
	else printf("No\n");
	
		
	
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 int main()
 {
 int N,A,B,C,D,i,j,flags,flagh;
   flags=1;
   flagh=-1;
   
   string s;
   
   cin >> N >> A >> B >> C >> D >> s;
   int mass[N];
   for(i=0;i<N;i++)
   {
     if(s.at(i)=='.')
       mass[i]=1;
     if(s.at(i)=='#')
       mass[i]=-1;
   }
    if(C<D)
            {
              for(i=A;i<C-1;i++)
              {
                 if((mass[i]==-1)&&(mass[i-1]==-1||mass[i+1]==-1))
                 {
                    flags=-1;
                   break;
                 }
              }
              
              for(i=B;i<D-1;i++)
              {
                  if((mass[i]==-1)&&(mass[i-1]==-1||mass[i+1]==-1))
                 {
                    flags=-1;
                   break;
                 }
              }
              if(flags==1)
              {
                cout << "Yes" << endl;
              }
              else
                
              {
                cout << "No" << endl;
              }
            }
            
  if(D<C)
            {  for(i=A;i<C-1;i++)
              {
                 if((mass[i]==-1)&&(mass[i-1]==-1||mass[i+1]==-1))
                 {
                    flags=-1;
                   break;
                 }
              }
             for(i=B-1;i<D;i++)
             {
               if((mass[i]==1)&&(mass[i-1]==1&&mass[i+1]==1))
               {
                 flagh=1;
                 break;
               }
             }
            if(flags==1&&flagh==1)
            {
              cout << "Yes" << endl;
            }
             else
             {
               cout << "No" << endl;
             }
            }
             
              
              
                
              
              
              
              
              
              
            }
            

Measured memory_bytes: 1284
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const ll INF = 1e11;
int w,h;

ll solve(int ww, int hh, int x, int xy, bool vert){
	if(!x || !(ww-x))return INF;
	ll s1=x*hh, s2, s3;
	if(vert){
		if(!xy || !(ww-xy))return INF;
		s2 = (xy-x)*hh;
		s3 = (ww-xy)*hh;
	}else{
		if(!xy || !(hh-xy))return INF;
		s2 = (ww-x)*xy;
		s3 = (ww-x)*(hh-xy);
	}
	return max(abs(s1-s2),max(abs(s2-s3),abs(s3-s1)));
}

int main() {
	cin>>w>>h;
	ll ans=INF;

	REP(i,2)
		ans=min(ans,solve(w,h,w/3 + i, h/2, false));
	ans=min(ans,solve(w,h,w/3, w*2/3, true));
	REP(i,2)
		ans=min(ans,solve(h,w,h/3 + i, w/2, false));
	ans=min(ans,solve(h,w,h/3, h*2/3, true));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		int a=s.nextInt();
		for(int i=0;i<a;i++){
			String str=s.next();
			boolean A=true;
			boolean B=true;
			if(str.charAt(0)!='>')A=B=false;
			if(str.length()<6||str.length()%2==1)A=B=false;
			if(str.length()>=6&&str.length()%2==0){
				if(str.charAt(1)!='\'')A=false;
				if(str.charAt(1)!='^')B=false;
				if(str.charAt(str.length()-1)!='~')A=B=false;
				if(str.charAt(str.length()-2)!='~')B=false;
				if(A){
					String [] dat=str.split("#");
					if(dat.length!=2)A=false;
					if(A){
						if(dat[0].length()==dat[1].length()+1||dat[0].length()>2){
							for(int j=0;j<dat[1].length()-1;j++){
								if(dat[0].charAt(2+j)!='='||dat[1].charAt(j)!='=')A=false;
							}
						}else A=false;
					}
				}
				if(B){
					for(int j=2;j<str.length()-2;j+=2){
						if(str.charAt(j)!='Q'||str.charAt(j+1)!='=')B=false;
					}
				}
			}
			if(A)System.out.println("A");
			else if(B)System.out.println("B");
			else System.out.println("NA");
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll M=4002,mod=998244353;
ll comb[M][M],pw[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll k,n;
	cin>>k>>n;
	for(ll i=0;i<M;i++)
	{
		comb[i][0]=1;
		for(ll j=1;j<=i;j++)
			comb[i][j]=(comb[i-1][j-1]+comb[i-1][j])%mod;
	}
	pw[0]=1;
	for(ll i=1;i<M;i++)
		pw[i]=(2*pw[i-1])%mod;
	for(ll i=2;i<=2*k;i++)
	{
		ll res = 0;
		ll z=0,y=0;
		for(ll j=1;j<=k;j++)
		{
			ll p=i-j;
			if(p>j && p<=k)
				z++;
			if(j>=i || j+k<i)
				y++;
		}
		// cout<<y<<" "<<z<<endl;
		for(ll j=0;j<=z;j++)
		{
			ll val=(pw[j]*comb[z][j])%mod;
			ll val2=(val*comb[n+y-1][y+j-1])%mod;
			res=(res+val2)%mod;
			if(i%2==0)
			{
				if(n+y-2>=0)
				{
					val=(val*comb[n+y-2][y+j-1])%mod;
					res=(res+val)%mod;
				}
			}
		}
		cout<<res<<"\n";
	}
	return 0;
}

Measured memory_bytes: 123776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1001,M=1e6+10,OO=0x3f3f3f3f,mod=1e9+7;
#define set(A) memset(A,-1,sizeof(A))
#define f first
#define s second
#define bs binary_search
#define all(A) A.begin(),A.end()
#define pb push_back
#define pii pair<int,int>
int n,m,dp[N][N];
char grid[N][N];
int di[]={1,0};
int dj[]={0,1};
bool valid(int x,int y){
    return x>=0&&y>=0&&x<n&&y<m&&grid[x][y]!='#';
}
int solve(int i=0,int j=0){
    if(i==(n-1)&&j==(m-1)) return 1;
    int& ret=dp[i][j];
    if(~ret) return ret;
    ret=0;
    for(int k=0;k<2;++k){
        int ni=i+di[k],nj=j+dj[k];
        if(valid(ni,nj))
            ret+=solve(ni,nj)%mod;
        
    }
    return ret;
}
int main(){
    cin>>n>>m;
    for(int i=0;i<n;++i)
        for(int j=0;j<m;++j)
            cin>>grid[i][j];
    set(dp);
    cout<<solve()%mod<<"\n";
}

Measured memory_bytes: 5248
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 1e2 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes"); exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No"); exit(0); }
void one() { puts("-1"); exit(0); }

void solve()
{
	int x;
	cin >> x;
	int i = 1;
	for (i = 1; (i+1)*i/2 < x; i++);
	cout << i << endl;
}

int main()
{

	solve();
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

int main(){
  ll n,ans=0; cin>>n;
  vector<ll>l(n);
  rep(i,n) cin>>l[i];
  sort(all(l));
  rep(i,n-1){
  ans+=l[i];
  }
  if(ans>l[n-1]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
using ll = long long;
#define INF 1e9
int main() {
	ll N, M;
	cin >> N >> M;
	if (N ==1&&M == 1)
		cout << 1 << endl;
	else if (N == 1 && M != 1)
		cout << M - 2 << endl;
	else if (N != 1 && M == 1)
		cout << N - 2 << endl;
	else
		cout << (N-2)*(M-2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int A[202020]; // 評点.

int main(){

    // 1. 入力情報.
    int N, K;
    scanf("%d %d", &N, &K);
    rep(i, N) scanf("%d", &A[i]);
    
    // 2. 出力.
    // i学期末 A[i]点 と (i - 1)学期末 A[i - K]点 を 比較.
    repx(i, K, N) printf("%s\n", (A[i] > A[i - K]) ? "Yes" : "No");
    return 0;
    
}


Measured memory_bytes: 4456
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
    return 0;
}

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

int main()
{
	int D, N;
	cin >> D >> N;
	if (N == 100) N++;
	if (D == 0) {
		cout << N << endl;
	}
	else if (D == 1) {
		cout << N * 100 << endl;
	}
	else {
		cout << N * 10000 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define A 100005
#define B -1

struct Node{int p,l,r;};
struct Node C[A];
int x,y,z[A];

void BB(int u){
  int i,e;
  printf("node %d: ",u);
  printf("parent = %d, ",C[u].p);
  printf("depth = %d, ",z[u]);

  if(C[u].p==B){
    printf("root, ");
  }else if(C[u].l==B){
    printf("leaf, ");
  }else{
    printf("internal node, ");
  }

  printf("[");
  for(i=0,e=C[u].l;e!=B;i++,e=C[e].r){
    if(i){
      printf(", ");
    }
    printf("%d",e);
  }
  printf("]\n");
}
 
int main(){
  int a,b,c,i,j,l;
  
  scanf("%d",&x);
  for(i=0;i<x;i++){
    C[i].p=C[i].l=C[i].r=B;
  }
  for(i=0;i<x;i++){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&c);
      if(j==0){
	C[a].l=c;
      }else{
	C[l].r=c;
      }
      l=c;
      C[c].p=a;
    }
  }

  y=0;
  for(i=0;i<x;i++){
    z[i]=AA(i);
    if(z[i]>y){
      y=z[i];
    }
  }

  for(i=0;i<x;i++){
    BB(i);
  }
  return 0;
}

int AA(int u){
  int d=0;
  for(; C[u].p!=B;d++){
    u=C[u].p;
  }
  return d;
}



  



Measured memory_bytes: 3304
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
applyBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
applyBin op f g x = op (f x) $ g x
applyUni :: (a -> b -> c) -> (a -> b) -> a -> c
applyUni op f x = op x $ f x
applyTuple :: (a -> b, a -> c) -> a -> (b, c)
applyTuple (f,g) a = (f a, g a)
-- end of templete

encode ' ' = "101"
encode '\'' = "000000"
encode ',' = "000011"
encode '-' = "10010001"
encode '.' = "010001"
encode '?' = "000001"
encode 'A' = "100101"
encode 'B' = "10011010"
encode 'C' = "0101"
encode 'D' = "0001"
encode 'E' = "110"
encode 'F' = "01001"
encode 'G' = "10011011"
encode 'H' = "010000"
encode 'I' = "0111"
encode 'J' = "10011000"
encode 'K' = "0110"
encode 'L' = "00100"
encode 'M' = "10011001"
encode 'N' = "10011110"
encode 'O' = "00101"
encode 'P' = "111"
encode 'Q' = "10011111"
encode 'R' = "1000"
encode 'S' = "00110"
encode 'T' = "00111"
encode 'U' = "10011100"
encode 'V' = "10011101"
encode 'W' = "000010"
encode 'X' = "10010010"
encode 'Y' = "10010011"
encode 'Z' = "10010000"

decode n = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?" !! n

binToInt r [] = r
binToInt r (c:cs) = binToInt (r*2 + digitToInt c) cs 

splitl _ [] = []
splitl n s = (take n s : splitl n (drop n s))


fill s = s ++ replicate (mod (-(length s)) 5) '0'


main = map (map (decode . binToInt 0) . splitl 5 . fill . foldMap encode) . lines <$> getContents >>= mapM_ putStrLn

Measured memory_bytes: 4264
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
//26

vector<int> pos[30], vec, ans;
int a[400000], n;
int f[30], cnt = 0;
signed main(){
	string str;
	cin >> str;
	n = str.size();
	vec.pb(n);
	rep(i,30)pos[i].pb(inf);
	rep(i,n)a[i] = str[i]-'a';
	drep(i,n-1,0){
		if(f[a[i]] == 0)cnt++;
		f[a[i]] = 1;
		if(cnt == 26){
			fill(f, f+30, 0);
			cnt = 0;
			vec.pb(i);
		}
		pos[a[i]].pb(i);
	}
	rep(i,30)sort(all(pos[i]));
	sort(all(vec));
	
	//int m = pos[19].size();
	//printf("%lld ", *upper_bound(all(pos[19]), -1));
	int m = vec.size(), now = -1;
	rep(i,m){
		int c = 0;
		rep(j,26){
			int p = *upper_bound(all(pos[j]), now);
			//printf("%lld %lld\n", vec[i], p);
			//printf("%c %lld\n", ('a'+j), p);
			if(vec[i] <= p){c = j;now = p;break;}
		}
		ans.pb(c);
	}
	
	for(int x: ans){
		printf("%c", x+'a');
	}
	printf("\n");
	return 0;
}





Measured memory_bytes: 3972
N = int(input())

dic = {}
for _ in range(N):
    A = input()
    if A in dic:
        dic[A] += 1
    else:
        dic[A] = 1

dic_sorted = sorted(dic.items(), key=lambda x:x[1], reverse = True)
ans = []
flag = 0
for i in range(len(dic_sorted)):
    if dic_sorted[i][1] < flag:
        break
    else:
        flag = dic_sorted[i][1]
        ans.append(dic_sorted[i][0])

ans.sort()
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 45788
N, x = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

a = A[0]
c = 0
ret = 0
for a_post in A[1:]:
  s = a + a_post
  c = min(a_post, max(0, (a + a_post) - x))
  c2 = max(0, a + a_post - c - x)
  a = a_post - c
  ret += c + c2
else:
  c += max(0, a_post - x)
print(ret)

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 1; i < (n); i++)
#define all(c) (c).begin, (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

int main() {
  int N;
  ll T[105];
  ll ans;
  cin >> N;
  rep(i, N)
    cin >> T[i];
  ans = T[0];
  repto(i, N) {
    ans *= T[i] / gcd(T[i], ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;
static const int LENGTH =200;

int main()
{
	
	int A[LENGTH];
	int n;
	
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		cin >> A[i];
	}
	for(int m = 0; m < n; ++m)
	{
		cout << A[m];
		if(m != n - 1)
		{
			cout << " ";
		}
	}
			cout << endl;
			
	for(int i = 1; i < n; ++i)
	{
		int value = A[i];
		int j = i-1;
		while(j >= 0 && A[j] > value)
		{
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = value;
		
		for(int m = 0; m < n; ++m)
		{
			cout << A[m];
			if(m != n - 1)
			{
				cout << " ";
			}
		}
			cout << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3104
# from math import factorial as fac
from collections import defaultdict
# from copy import deepcopy
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange
# print(f.readline())
# sys.setrecursionlimit(10**6)

	
def print_case_iterable(case_num, iterable):
	print("Case #{}: {}".format(case_num," ".join(map(str,iterable))))

def print_case_number(case_num, iterable):
	print("Case #{}: {}".format(case_num,iterable))

def print_iterable(A):
	print (' '.join(A))

def read_int():
	return int(f.readline().strip())
def read_int_array():
	return [int(x) for x in f.readline().strip().split(" ")]
def rns():
	a =  [x for x in f.readline().split(" ")]
	return int(a[0]), a[1].strip()
def read_string():
	return list(f.readline().strip())
def bi(x):
	return bin(x)[2:]





from collections import deque
import math


def solution(s):
	sol = []
	for x in s:
		if x == 'P':
			sol.append('P')
		else:
			sol.append('D')
	return ''.join(sol)
	
			


def main():
	T = 1
	for i in range(T):
		s = read_string()
	
		x = solution(s)

		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			print >>output,str(x)# "Case #"+str(i+1)+':',
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()

if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
#example usage:
#    for l in res:
#       print >>output, str(len(l)) + ' ' +  ' '.join(l)

if __name__ == '__main__':
	main()



Measured memory_bytes: 12520
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <set>
using namespace std;

int main(int argc, char const *argv[]) {
  long long n;cin>>n;
  vector<long long> a(n);
  for(int i=0;i<n;++i)cin>>a[i];
  long long k=(n*(n+1))/2;
  long long su=0;
  vector<long long> b(n);
  for(int i=0;i<n;++i){
    su+=a[i];
    b[i]=a[(i+1)%n]-a[i];
  }
  if(su%k!=0){
    cout<<"NO"<<endl;
    return 0;
  }
  long long p=su/k;
  long long res=0;
  for(int i=0;i<n;++i){
    b[i]-=p;
    if(b[i]>0||-b[i]%n!=0){
      cout<<"NO"<<endl;
      return 0;
    }
    res+=(-b[i]/n);
  }
  if(res==p){
    cout<<"YES"<<endl;
  }
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 1792
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

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

int N;
vi A;
vi l,r;
int ans=0;

signed main(){

    in(N);
    resz(N,A,l,r);
    in(A);
    rep(i,N-1){
        l[i+1]=gcd(l[i],A[i]);
    }
    REPEAT(i,1,N,false){
        r[i-1]=gcd(r[i],A[i]);
    }

    show(l,r);

    rep(i,N){
        ans=max(ans,gcd(l[i],r[i]));
    }
    out(ans);

    return 0;
}


Measured memory_bytes: 2560
h,w,k=map(int,input().split())
field=[list(input()) for i in range(h)]
numf=[[0 for i in range(w)] for j in range(h)]
name=0
empty=[]
for i in range(h):
  if field[i].count("#")==0:
    continue
  else:
    name+=1
    lim=field[i].count("#")+name-1
    for j in range(w):
      
      if field[i][j]==".":
        numf[i][j]=name
      elif field[i][j]=="#":
        if name==lim:
          numf[i][j]=name
        else:
          numf[i][j]=name
          name+=1
for i in range(w):
  for j in range(1,h):
    if numf[j-1][i]==0:
      continue
    else:
      if numf[j][i]==0:
        numf[j][i]=numf[j-1][i]
for i in range(w):
  for j in range(h-1)[::-1]:
    if numf[j][i]==0:
      numf[j][i]=numf[j+1][i]
for i in numf:
  print(*i)


Measured memory_bytes: 50652
//
//  CPlibrary
//
//  Created by Tanmay Singh on 3/03/2020.
// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI
//  Copyright © 2020 Tanmay Singh. All rights reserved.
//#pragma GCC target ("1avx2")
#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define FAST(); ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define mod 1000000007
typedef long long int  bigint ;
typedef std::vector< int > vi;
typedef std::vector< long long int > vll;
typedef std::vector< vi > vvi;

using namespace std ;

int main(){
    FAST() ;
    bigint R , C ; cin >> R >> C ;
    bigint A = R * C ;
    if( R == 1 || C == 1 ){
        cout << 1 << endl ;
        return 0 ;
    }
    if( A % 2 == 0 )
        cout << A / 2 << endl ;
    else
        cout << A / 2 + 1 << endl ;
    return 0 ;
}


Measured memory_bytes: 256
import sys
def can_load(num_baggages, baggages, num_truck, max_load):
    bag_no = 0

    for i in range(num_truck):
        load_cap = max_load
        while load_cap > 0:
            if bag_no >= num_baggages:
                #print(max_load, "True")
                return True
            if load_cap >= baggages[bag_no]:
                load_cap -= baggages[bag_no]
                bag_no += 1
            else:
                break
    #print(max_load, bag_no >= num_baggages)
    return bag_no >= num_baggages

def main():
    num_baggages, num_trucks = map(int, input().split())
    baggages = tuple(map(int, sys.stdin.read().splitlines()))

    start = max(sum(baggages) // num_trucks, min(baggages))
    end = sum(baggages)

    while start < end:
        mid = (start + end) // 2
        if can_load(num_baggages, baggages, num_trucks, mid):
            end = mid
        else:
            start = mid + 1

    print(start)
    return


main()


Measured memory_bytes: 16500
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  const int64_t MOD = std::pow(10, 9) + 7;
  int n;
  cin >> n;
  std::vector<int64_t> color;
  for (int i = 0; i < n; i++) {
    int m1;
    cin >> m1;
    if (color.size() == 0 || color.back() != m1) {
      color.push_back(m1);
    }
  }
  int64_t dp[200001]   = {};
  dp[0]                = 1;
  int64_t memo[200001] = {};
  memo[color[0]]       = 1;
  for (int i = 1; i < color.size(); i++) {
    int64_t sum = 0;
    sum += memo[color[i]];
    memo[color[i]] += dp[i - 1];
    dp[i] = dp[i - 1] + sum;
    dp[i] %= MOD;
  }
  cout << dp[color.size() - 1] << endl;

  return 0;
}


Measured memory_bytes: 5104
let m=1000000open Array;;let a,b=make m 1,make m 0;;a.(0)<-0;;let rec($)i j=if i*j<m then(a.(i*j)<-0;i$(j+1));;for i=2to m-1do if a.(i)=1then i$2;b.(i)<-b.(i-1)+a.(i)done;;let rec f()=f(Printf.printf"%d
"b.(read_int()));;try f()with _->()

Measured memory_bytes: 18092
#include <cstdio>
#include <cstring>

const int MaxLen = 3000 + 5;

int N, M;
char S[MaxLen], T[MaxLen];
int Dp[MaxLen][MaxLen], Pre[MaxLen][MaxLen][2];

void init() {
  scanf("%s", S + 1);
  scanf("%s", T + 1);
  N = strlen(S + 1), M = strlen(T + 1);
}

void printAns(int i, int j) {
  if (i == 0 || j == 0) return;
  int x = Pre[i][j][0], y = Pre[i][j][1];
  printAns(x, y);
  if (Dp[x][y] + 1 == Dp[i][j]) putchar(S[i]);
}

void solve() {
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j) {
      Dp[i][j] = Dp[i][j - 1];
      Pre[i][j][0] = i, Pre[i][j][1] = j - 1;
      if (Dp[i - 1][j] > Dp[i][j]) {
        Dp[i][j] = Dp[i - 1][j];
        Pre[i][j][0] = i - 1;
        Pre[i][j][1] = j;
      }
      if (S[i] == T[j]) {
        if (Dp[i - 1][j - 1] + 1 > Dp[i][j]) {
          Dp[i][j] = Dp[i - 1][j - 1] + 1;
          Pre[i][j][0] = i - 1;
          Pre[i][j][1] = j - 1;
        }
      }
    }
  printAns(N, M);
  putchar('\n');
}

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

Measured memory_bytes: 106112
import sys
sys.setrecursionlimit(1010)

N = int(input())
src = []
for i in range(N):
    k = int(input())
    s = input()
    src.append((s,[]))
    if i == 0: continue
    src[k-1][1].append(i)

def dfs(i,depth):
    s,ch = src[i]
    print('.'*depth + s)
    for c in ch:
        dfs(c,depth+1)

dfs(0,0)

Measured memory_bytes: 6780
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>



int main() {
	ll n;
	cin >> n;
	vector<ll> s(n);
	REP(i, n)cin >> s[i];
	vector<ll> v(n);
	REP(i, n) {
		v[i] = s[i] + i;
	}
	map<ll, ll> mp;
	ll ans = 0;
	REP(i, n) {
		ans += mp[i - s[i]];
		mp[s[i] + i]++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 29016
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
using namespace std;

int m,ans;
string s;
int a[30];
vector<int> v;
bool f;

int stoi(string s){
  int res=0,k=1;
  for(int i=(int)s.size()-1;i>=0;i--){
    res += k*(s[i]-'0');
    k *= 10;
  }
  return res;
}

int parse(string s){
  //cout << ans << " " << s << endl;
  if(f)return 0;
  if(s[0]=='(')return parse(s.substr(1,(int)s.size()-2));
  if('A'<=s[0] && s[0] <= 'Z'){
    if(s.size()>1 && s[1] == '='){
      int tmp = parse(s.substr(2,(int)s.size() - 2));
      if(tmp==-1)return -1;
      a[s[0]-'A'] = tmp;
      return tmp;
    }else if(s.size()==1){
      return a[s[0]-'A'];
    }else{
      v.push_back(-2);
      return (int)v.size()-1;
    }
  }else{
    if(s[0] == 'm'){
      int tmp = stoi(s.substr(7,(int)s.size()-8));
      if(ans+tmp>m)tmp = 0;
      v.push_back(tmp);
      ans += tmp;
      return (int)v.size()-1;
    }else if(s[0] == 'c'){
      int tmp = parse(s.substr(6,(int)s.size()-7));
      if(tmp==-1 || v[tmp]==-1)return -1;
      if(v[tmp]==-2){
	f = true;
	return 0;
      }
      if(ans+v[tmp]<=m){
	v.push_back(v[tmp]);
	ans += v[tmp];
      }else{
	v.push_back(0);
      }
      return (int)v.size()-1;
    }else{
      int tmp = parse(s.substr(5,(int)s.size()-6));
      if(tmp==-1 || v[tmp]==-1)return -1;
      if(v[tmp]==-2){
	f = true;
	return 0;
      }
      ans -= v[tmp];
      v[tmp] = -1;
      return 0;
    }
  }
}

int main(){
  cin >> m;
  ans = 0;

  for(int i=0;i<26;i++)a[i] = 0;
  v.clear(); v.push_back(-1);

  while(cin >> s){
    f = false;
    if(parse(s)<0){
      cout << "Error\n";
      return 0;
    }
  }

  //cout << ans << endl;
  set<int> s;
  for(int i=0;i<26;i++)s.insert(a[i]);
  for(set<int>::iterator it=s.begin();it!=s.end();it++)
    if(v[(*it)]>0)ans -= v[(*it)];

  cout << ans << endl;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
using namespace std;

int main(){
    char str[1001];
    cin>>str;
    for(int i=0;str[i]!='\0';i++){
        str[i]=(str[i]-'A'+23)%26+'A';
        printf("%c",str[i]);
    }puts("");
    return 0;
}

Measured memory_bytes: 1100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Complex = complex<double>;
const double PI = acos(-1);

vector<Complex> dft(vector<Complex> A, int inverse = 1) {
    int n = A.size(), mask = n - 1;
    vector<Complex> tmp(n);
    for (int i = n >> 1; i >= 1; i >>= 1) {
        double theta = 2 * PI * i * inverse / n;
        Complex zeta(cos(theta), sin(theta));
        Complex powzeta = 1;
        for (int j = 0; j < n; j += i) {
            for (int k = 0; k < i; ++k) {
                // a[jk] = a[j0k] + powzeta * a[j1k]
                tmp[j | k] = A[((j << 1) | k) & mask] +
                             powzeta * A[((j << 1) | i | k) & mask];
            }
            powzeta *= zeta;
        }
        swap(A, tmp);
    }
    if (inverse == -1)
        for (int i = 0; i < n; ++i)
            A[i] /= n;
    return A;
}

vector<Complex> conv(vector<Complex> A) {
    int siz = 2 * A.size() + 1, n = 1;
    while (n < siz)
        n <<= 1;
    A.resize(n);
    A = dft(A);
    for (int i = 0; i < n; ++i)
        A[i] *= A[i];
    A = dft(A, -1);
    return A;
}

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

    int N, maxA = 0;
    ll M;
    cin >> N >> M;
    vector<int> cnt(100001);
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        maxA = max(maxA, a);
        cnt[a]++;
    }

    vector<Complex> A(maxA + 1);
    for (int i = 0; i <= maxA; ++i)
        A[i] = cnt[i];

    vector<Complex> f = conv(A);
    ll ans = 0;
    for (int i = 2 * maxA; i >= 1; --i) {
        ll tmp = f[i].real() + 0.5;
        if (tmp > 0) {
            if (M > tmp) {
                ans += (ll)i * tmp;
                M -= tmp;
            } else {
                ans += i * M;
                M = 0;
                break;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14564
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))

def mex(L):
  L.sort()
  ans = 0
  for i in L:
    if i <= ans:
      ans += 1
    else:
      break
  return ans

DP = [0] * (K + 1)
M = 100000

for i in range(a[0], K + 1):
  L = []
  for j in range(N):
    if i - a[j] < 0:
      break
    L.append(DP[i - a[j]])
  DP[i] = mex(L)

if DP[-1] == 0:
  print("Second")
else:
  print("First")


Measured memory_bytes: 43868
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
    	try(Scanner sc = new Scanner(System.in)) {

    		int N = sc.nextInt();
    		if(N == 1)	System.out.println("Hello World");
    		else {
    			int a = sc.nextInt();
    			int b = sc.nextInt();
    			System.out.println(a+b);
    		}

    	}
    }
}


Measured memory_bytes: 21716