akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  struct node *prev;
  struct node *next;
  long key;
};
typedef struct node * NP;
NP MN(long);
void IN(NP);
void DN(NP);
void FI(long);
NP dummy;
 
int main(){
  long int val,i,n;
  char op[12];
  NP roop;
 
  scanf("%ld",&n);
  dummy = MN(0);
 
   
 
  for(i=0;i<n;i++){
    scanf("%s",op);
     
    if(strcmp(op,"insert") == 0){
      scanf("%ld",&val);
      IN(MN(val));
    }
    else if(strcmp(op,"delete") == 0){
      scanf("%ld",&val);
      FI(val);
    }
    else if(strcmp(op,"deleteFirst") == 0){
      DN(dummy->next);
    }
    else if(strcmp(op,"deleteLast") == 0){
      DN(dummy->prev);
    }
  }
 
  for(roop=dummy->next;roop!=dummy;roop =roop->next){
    printf("%ld",roop->key);
    if(roop->next != dummy)printf(" ");
  }  
  printf("\n");
 
  return 0;
}
 
 
void FI(long value){
  NP n;
  dummy->key = value;
  for(n = dummy->next;;n=n->next){
    if(n->key == value)break;
  }
  if(n != dummy)DN(n);
     
}
 
 
void DN(NP th){
  th->prev->next = th->next;
  th->next->prev = th->prev;
  th->prev = th->next = th;
  free(th);
  //delete th;
}
 
 
void IN(NP newn){
  newn->next = dummy->next;
  newn->next->prev = newn;
  dummy->next = newn;
  newn->prev = dummy;
}
 
NP MN(long key){
  NP no = (NP)malloc(sizeof(struct node));
  //n = new struct node();
  no->prev = no;
  no->next = no;
  no->key = key;
  return no;
} 


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

int main(){
  long long N, A, B; cin >> N >> A >> B;
  long long C = A + B;
  cout << (N / C) * A + min(A, N % C) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    char array[3];
    int ans = 0;
    scanf("%s", array);
    for(int i = 0;i<=2;i++){
        if(array[i]=='1'){
            ans++;
        }
        else;
    }
    printf("%d\n", ans);
    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M, sum;
    sum = 0;
    cin >> N >> M;
    int A[N];
    for(int i=0;i<N;i++){
    	cin >> A[i];
    	sum += A[i];
    }
    int cnt = 0;
    if(sum % (4 * M) > 0){
    	sum /= (4 * M);
    	sum++;
	}
	else sum /= (4 * M);
    for(int i=0;i<N;i++){
    	if(sum <= A[i])cnt++;
    }
    if(cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e5+5;
ll mod=1e9+7;
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
vector<int> graph[205];
int color[205];
int nCk[100][100];
bool bipartite_jugding(int v, int c){
    color[v] = c;
    for(int i = 0; i < graph[v].size(); ++i){
        if(color[graph[v][i]] == c) return false;
        if(color[graph[v][i]] == 0 && !bipartite_jugding(graph[v][i], -c)){
            return false;
        }
    }
    return true;
}

 void combi() {
	for (int i = 0; i <= 99; ++i) nCk[i][0] = 1;
	for (int i = 1; i <= 99; ++i) for (int j = 1; j <= i; ++j) {
		nCk[i][j] = (nCk[i-1][j] + nCk[i-1][j-1]) % mod;
	}
}

long long expo(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}

void solve(){
  int n;
  string s;
  cin>>n>>s;ll ans=0;
  for(int i=0;i<(n-2);i++)
  {
      string ss=s.substr(i,3);
      if(ss=="ABC")
        ans++;
  }cout<<ans;
}

int main(){
boost;
  solve();
}


Measured memory_bytes: 256
(x, y, A, B, C) = map(int, raw_input().split())

ps = sorted(map(int, raw_input().split()), reverse=True)[:x]
qs = sorted(map(int, raw_input().split()), reverse=True)[:y]
cs = sorted(map(int, raw_input().split()))

tot = sum(ps) + sum(qs)

while cs and ((ps and cs[-1] > ps[-1]) or (qs and cs[-1] > qs[-1])):
    if ps and qs:
        if ps[-1] < qs[-1]:
            tot -= ps.pop()
            tot += cs.pop()
        else:
            tot -= qs.pop()
            tot += cs.pop()
    elif ps:
        tot -= ps.pop()
        tot += cs.pop()
    elif qs:
        tot -= qs.pop()
        tot += cs.pop()
    else:
        break
# print ps, qs

print tot



Measured memory_bytes: 57752
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int N, H, W;
	cin >> N >> H >> W;

	cout << (N - H + 1) * (N - W + 1) << endl;

}


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

int main(void) {
  int x, a, b;
   cin >> x >> a >> b;

   cout << (x-a)%b << endl;
   return 0;
 }

Measured memory_bytes: 256
a, b, c, k = map(int, input().split())

result = 0

m = [1, 0, -1]
options = [a, b, c]

idx = 0
while k > 0:
    get = min(k, options[idx])
    result += get*m[idx]

    idx += 1
    k -= get
print(result)

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

int main() {
	int a, b;
	cin >> a >> b;
	
	int ans = 1<<30;
	if (a <= b) {
		ans = min(ans, b - a);
	}
	if (-a <= b) {
		ans = min(ans, b + a + 1);
	}
	if (a <= -b) {
		ans = min(ans, -b - a + 1);
	}
	if (-a <= -b) {
		ans = min(ans,-b + a + 2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define f first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
typedef long long ll ;
typedef long double ld ;
typedef long long int lli;

using namespace std;
//reference: geeks
ll mult(ll a,ll b, ll p=mod){	return ((a%p)*(b%p))%p;	}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll sub(ll a, ll b, ll p=mod){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = mod) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2, p);}
#define INF 10000000000
ll dp[105][100005]={{0}};

int main()
{
	ll n,w;
	cin>>n>>w;
	ll p[n],W[n];
	for(int i=0;i<n;i++)	cin>>W[i]>>p[i];
	
	for(int i=0;i<n;i++)	for(int j=0;j<100005;j++)	dp[i][j]=INF;
	
	if(W[0]<=w)	dp[0][p[0]]=W[0];	
	dp[0][0]=0;
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<100005;j++)
		{
			if(j<p[i])
				dp[i][j]=dp[i-1][j];
			else
			{
				if(dp[i-1][j-p[i]]+W[i]<=w)
					dp[i][j]=min(dp[i-1][j],dp[i-1][j-p[i]]+W[i]);
				else	dp[i][j]=dp[i-1][j];
			}
		}
	}
	ll ans=0;
	for(int j=100004;j>=0;j--)
	{
		if(dp[n-1][j]<=w)
		{	ans=j;
			break;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 80128
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = m = 0
for i in range(N):
    m = min(A[i], B[i])
    A[i] -= m
    B[i] -= m
    ans += m
    m = min(A[i + 1], B[i])
    A[i + 1] -= m
    B[i] -= m
    ans += m
print(ans)


Measured memory_bytes: 82148
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <type_traits>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using ISS = istringstream;
using OSS = ostringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define NUMBERED( name, number ) NUMBERED2( name, number )
#define NUMBERED2( name, number ) name ## _ ## number
#define REP1( n ) REP2( NUMBERED( REP_COUNTER, __LINE__ ), n )
#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2, REP1 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a ) ( remove_all_extents< decltype( a ) >::type * )a, ( remove_all_extents< decltype( a ) >::type * )a + sizeof( a ) / sizeof( remove_all_extents< decltype( a ) >::type )
#define DRANGE( c, p ) begin( c ), begin( c ) + ( p ), end( c )

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

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

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );
	cout << setprecision( 12 ) << fixed;

	string S;
	cin >> S;

	const int L = SZ( S );

	const int l = L - 2 - ( S[0] == S.back() );
	
	cout << ( l % 2 ? "First" : "Second" ) << endl;

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int a,b,x=0,y=0,z=0;

	scanf("%d%d",&a,&b);
	x = a+b;
	y = a-b;
	z = a*b;
	if(x>=y && x>=z) printf("%d\n",x);
	else if(y>=x && y>=z) printf("%d\n",y);
	else printf("%d\n",z);
	return 0;
}



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

using namespace std;

inline int gi()
{
	int f = 1, x = 0; 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 f * x;
}

const int maxn = 100003;

struct Node
{
	int fro, to, bh, col;
} p[maxn];
struct IN
{
	int ds, idx;
} in[maxn];
int n, tot, head[maxn], ver[maxn * 2], nxt[maxn * 2];
int cnt;
map <pair <int, int>, int> ap;

inline bool cmp(IN x, IN y) {return x.ds > y.ds;}

void dfs(int u, int f)
{
	int yy = 0;
	for (int i = head[u]; i; i = nxt[i])
	{
		int v = ver[i]; if (v == f) continue;
		++yy;
		//cout << "fa=" << f << "u=" << u << "v=" << v << "yy=" << yy << endl;
		if (yy == p[ap[make_pair(u, f)]].col) ++yy;
		p[ap[make_pair(u, v)]].col = yy;
		dfs(v, u);
	}
}

inline void add(int u, int v)
{
	p[++cnt].fro = u, p[cnt].to = v, p[cnt].bh = cnt;
	ap[make_pair(u, v)] = cnt;
	ap[make_pair(v, u)] = cnt;
	ver[++tot] = v, nxt[tot] = head[u], head[u] = tot;
	ver[++tot] = u, nxt[tot] = head[v], head[v] = tot;
	++in[u].ds, ++in[v].ds;
}

int main()
{
	n = gi();
	for (int i = 1; i <= n; i+=1) in[i].idx = i;
	for (int i = 1; i < n; i+=1)
	{
		int u = gi(), v = gi();
		add(u, v);
	}
	sort(in + 1, in + 1 + n, cmp);
	printf("%d\n", in[1].ds);
	dfs(in[1].idx, 0);
	for (int i = 1; i < n; i+=1) 
	{
		printf("%d\n", p[i].col);
	}
	return 0;
}


Measured memory_bytes: 17280
#include<bits/stdc++.h>
    #define F first
    #define S second
    using ll = long long;
    const ll mod = 1000000007;
    const ll infi = 1000000000000000;
    const ll md = 998244353;
    using namespace std;
    using vl = vector<ll>;
    using pll =  pair<ll,ll>;
    
    vector<vl> a;
    vl visi;
    map<pll,ll> mp;
    
    void dfs(int n,int c){
        visi[n] = 1;
        int k = 1;
        if(k==c) k++;
        for(int i=0;i<a[n].size();i++){
            int u = a[n][i];
            if(visi[u]==0){
                dfs(u,k);
                mp[{u,n}] = k;
                mp[{n,u}] = k;
                k++;
                if(k==c) k++;
            }
        }
    }
   
    void solve(){
        int m,x,y;
        cin>>m;
        a.resize(m);
        visi.resize(m);
        vector<pll> b;
        
        for(int i=0;i<m-1;i++){
            cin>>x>>y;
            x--;y--;
            b.push_back({x,y});
            a[x].push_back(y);
            a[y].push_back(x);
        }
        
        int mx=-1;
        
        for(int i=0;i<m;i++){
            visi[i] = 0;
            mx  = max((int)a[i].size(),mx);
        }
        
        cout<<mx<<endl;
        dfs(0,0);
        
        for(int i=0;i<m-1;i++){
            cout<<mp[b[i]]<<endl;
        }
    }
     
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
       // int n; cin>>n; for(int i=0;i<n;i++)
        solve();
        return 0;
    } 
    

Measured memory_bytes: 21360
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if((a+b)>(c+d))
    cout << "Left" << endl;
  else if ((a+b)==(c+d))
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    double v,t;
    while (cin >> v) {
        t = v/9.8;
        n = ((4.9*t*t)+5)/5;
        cout << n+1 << endl;
    }
    
    
    
    
    
    
    //4.9*t*t=5*n-5
    //25.4=9.8*t
}


Measured memory_bytes: 3180
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//Searching Constellation
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		long W = 1000001;
		while(true){
			int m = sc.nextInt();
			if(m==0)break;
			long[][] star = new long[m][2];
			for(int i=0;i<m;i++){
				for(int j=0;j<2;j++){
					star[i][j] = sc.nextLong();
					if(i>0)star[i][j]-=star[0][j];
				}
			}
			Set<Long> set = new HashSet<Long>();
			int n = sc.nextInt();
			long[][] a = new long[n][2];
			for(int i=0;i<n;i++){
				for(int j=0;j<2;j++){
					a[i][j]=sc.nextLong();
				}
				set.add(a[i][0]*W+a[i][1]);
			}
			for(int i=0;i<n;i++){
				long bx = a[i][0];
				long by = a[i][1];
				boolean f = true;
				for(int j=1;j<m;j++){
					if(!set.contains((bx+star[j][0])*W+by+star[j][1])){
						f = false;
						break;
					}
				}
				if(f){
					System.out.println((bx-star[0][0])+" "+(by-star[0][1]));
					break;
				}
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int arr[100005];

int main()
{
    BeatMeScanf;
    //freopen("G:/C++/in.txt", "r", stdin);
    //freopen("G:/C++/out.txt", "w", stdout);

    int h, n, sum = 0;
    cin>>h>>n;

    for(int i = 0; i<n; i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    if(sum>=h)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <climits>
using namespace std;

template<class T>
class SegmentTree{
    public:
        SegmentTree(T size){
            mSize = 1;
            while(size > mSize) mSize *= 2;
            mData.assign(mSize*2-1, INT_MAX);
        }

        void update(int i, T x){
            i += mSize - 1;
            mData[i] = x;
            while(i > 0){
                i = (i - 1) / 2;
                mData[i] = min(mData[i*2+1],mData[i*2+2]);
            }
        }

        T query(int a, int b, T k, int l, int r){
            if(a <= l && r <= b) return mData[k];
            if(r <= a || b <= l) return INT_MAX;
            T vl = query(a,b,k*2+1,l,(l+r)/2);
            T vr = query(a,b,k*2+2,(l+r)/2,r);
            return min(vl,vr);
        }

        T query(int a, int b){
            return query(a,b,0,0,mSize);
        }

    private:
        vector<T> mData;
        int mSize;
};

int main(){
    int n,q,c,x,y;
    cin >> n >> q;
    SegmentTree<int> st(n);
    for(int i = 0; i < q; ++i){
        cin >> c >> x >> y;
        if(c==0){
            st.update(x,y);
        } else {
            cout << st.query(x,y+1) << '\n';
        }
    }
    return 0;
}



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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll w,h,n;cin>>w>>h>>n;
  vector<ll>x(n),y(n),a(n);
  ll lx=0,rx=w,ly=0,ry=h;
  for(i=0;i<n;i++){
    cin>>x[i]>>y[i]>>a[i];
    switch(a[i]){
      case 2:chmin(rx,x[i]);break;
      case 1:chmax(lx,x[i]);break;
      case 4:chmin(ry,y[i]);break;
      case 3:chmax(ly,y[i]);break;
    }
  }
  //cout<<rx spa lx spa ry spa ly<<endl;
  if(rx-lx<=0||ry-ly<=0)cout<<0<<endl;
  else cout<<max(buf4,(rx-lx)*(ry-ly))<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,C,x=0,a;cin>>N>>M>>C;
  int B[M];
  for(int i=0;i<M;i++)cin>>B[i];
  for(int i=0;i<N;i++){
    long int p=0;
    for(int j=0;j<M;j++){
      cin>>a;p+=a*B[j];
    }
    if(p+C>0)x++;
  }
  cout<<x<<endl;
}

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

using namespace std;

int main() {
    long long a, b;
    cin >> a >> b;
    cout << std::max(0ll, a - 2 * b) << endl;
    return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

#define int ll

int dp[2001][2001];
ll inv(int now) {
    int b = MAX_MOD - 2LL;
    int ans = 1;
    while (b) {
        if (b % 2) {
            ans *= now;
            ans %= MAX_MOD;
        }
        now *= now;
        now %= MAX_MOD;
        b /= 2LL;
    }
    return ans;
}

int comb(int a, int b) {
    int ans = 1;
    for (int i = 1; i <= b; ++i) {
        ans *= (a - i + 1LL) % MAX_MOD;
        ans %= MAX_MOD;
        ans *= inv(i);
        ans %= MAX_MOD;
    }
    return ans;
}

void solve(){
    while (true) {
        int n, d, x;
        cin >> n >> d >> x;
        if (n == 0) return;

        REP(i, n) {
            for (int q = i; q <= n; ++q) {
                dp[i][q] = 0;
            }
        }
        dp[0][0] = 1;

        for (int i = 0; i < n; ++i) {
            ll hoge = 0;
            for (int q = i+1; q <= n; ++q) {
                hoge += dp[i][q - 1];
                if (q - x >= 0) {
                    hoge += MAX_MOD - dp[i][q - x];
                }
                hoge %= MAX_MOD;
                dp[i + 1][q] = hoge;
            }
        }

        int ans = 0;
        for (int i = 1; i <= min(n,d); ++i) {
            ans += dp[i][n] * comb(d, i) % MAX_MOD;
            ans %= MAX_MOD;
        }
        cout << ans << endl;
    }
}

#undef int
int main() {
    init();
    solve();
}


Measured memory_bytes: 25824
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main(){
  map<string,int> blooddata;
  blooddata.insert(map<string,int>::value_type("A",0));
  blooddata.insert(map<string,int>::value_type("B",0));
  blooddata.insert(map<string,int>::value_type("AB",0));
  blooddata.insert(map<string,int>::value_type("O",0));

  int ID;
  char c;
  string blood;
  while(cin>>ID>>c>>blood){
    blooddata[blood]++;
  }

  cout<<blooddata["A"]<<endl;
  cout<<blooddata["B"]<<endl;
  cout<<blooddata["AB"]<<endl;
  cout<<blooddata["O"]<<endl;
}

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

int main(){
	int n, x;

	while(1){
		cin>>n>>x;
		if(n==0 && x==0) break;

		int count = 0;
		for(int i=1;i<=n-2;i++){
			for(int j=i+1;j<=n-1;j++){
				for(int k=j+1;k<=n;k++){
					if(i+j+k == x) count++;
				}
			}
		}
		cout<<count<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
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;

// dp[x][y][ツ可コ(0)ツつゥツづァツつゥツ債カ(1)ツつゥツづァツつゥ][ツ前ツづ可凝按つェツづづつ「ツづゥ(1)ツつゥツつ「ツづ按つ「(0)ツつゥ]
int main() {
  int dp[100][100][2][2];
  memset(dp,0,sizeof(dp));
  REP(x,100) {
    REP(y,100) {
      if (x==0&&y==0) continue;
      if (x==1&&y==0)
        dp[x][y][1][0] = 1;
      else if (x==0&&y==1)
        dp[x][y][0][0] = 1;
      else {
        if (y > 0) {
          dp[x][y][0][0] = (dp[x][y-1][0][0] + dp[x][y-1][0][1]) % 100000;
          dp[x][y][0][1] = dp[x][y-1][1][0];
        }
        if (x > 0) {
          dp[x][y][1][0] = (dp[x-1][y][1][0] + dp[x-1][y][1][1]) % 100000;
          dp[x][y][1][1] = dp[x-1][y][0][0];
        }
      }
    }
  }
    int w,h;
  while(cin >> w >> h, w + h) {
    int res = 0;
    REP(i,2) REP(j,2)
      res = (res+dp[w-1][h-1][i][j]) % 100000;
    cout << res << endl;
  }
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
import copy
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n-1)]
point = [[] for _ in range(n+1)]
for l in ab:
  point[l[0]].append(l[1])
  point[l[1]].append(l[0])
adone = set()
bdone = set()
adone.add(1)
bdone.add(n)
da,db = [0]*(n+1),[0]*(n+1)
alist = [1]
blist = [n]
anext,bnext = [],[]
c = 0
while alist:
  c += 1
  for i in alist:
    for j in point[i]:
      if j not in adone:
        adone.add(j)
        anext.append(j)
        da[j] = c
  alist = copy.deepcopy(anext)
  anext = []
c = 0
while blist:
  c += 1
  for i in blist:
    for j in point[i]:
      if j not in bdone:
        bdone.add(j)
        bnext.append(j)
        db[j] = c
  blist = copy.deepcopy(bnext)
  bnext = []
a,b = 0,0
for i in range(1,n+1):
  if da[i] <= db[i]:
    a += 1
  else:
    b += 1
if a > b:
  print("Fennec")
else:
  print("Snuke")

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

int main(){
  int H,W; cin >> H >> W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      string S; cin >> S;
      if(S=="snuke"){
        cout << (char)('A'+j);
        cout << i+1 << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int G[8][8];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  cin >> n >> m;
  REP(i,m){
    int a,b;
    cin >> a >> b;
    a--,b--;
    G[a][b]=1;
    G[b][a]=1;
  }
  vector<int> arr(n-1);
  REP(i,n-1) arr[i] = i+1;
  int cnt = 0;
  do{
    if(G[0][arr[0]]!=1) continue;
    bool flag = true;
    REP(i,n-2){
      if(G[arr[i]][arr[i+1]]!=1) flag = false;
    }
    if(flag)cnt++;
  }while(next_permutation(ALL(arr)));
  cout << cnt << '\n';
  return 0;
}


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

int main() {
    string S; cin >> S;
    int K; cin >> K;

    int i = 0;
    while( S[i] == '1') {
        if ( i == K - 1) {
            cout << 1 << endl;
            break;
        }
        i ++;
    }
    if ( i != K - 1 || (i == K - 1 && S[K - 1] != '1')) cout << S[i] << endl;
}

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

using namespace std;

int main() {
  int N,a,b,c;
  cin >> N;
  
  a=N/100; 
  b=(N-a*100)/10;
  c=(N-a*100-b*10);
  

  if (c == 2 || c==4 || c==5 || c==7 || c==9) {
    cout << "hon" << endl;
  }
  

  else if ( c==0 || c==1 || c==6 || c==8) {
   cout << " pon" << endl;
  }
  
  else if ( c==3) {
   cout << "bon" << endl;
  }
  
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

const int maxd = 80 * 80 * 1;

char memo[80][80][maxd];

char doit(vector <vector <char> > &diff, int x, int y, int d)
{
    if (x < 0 || y < 0 || d >= maxd) {
        return 0;
    }
    if (x == 0 && y == 0) {
        return d == diff[0][0];
    }
    if (memo[y][x][d] < 0) {
        memo[y][x][d] = (doit(diff, x - 1, y, abs(d + diff[y][x])) |
                         doit(diff, x - 1, y, abs(d - diff[y][x])) |
                         doit(diff, x, y - 1, abs(d + diff[y][x])) |
                         doit(diff, x, y - 1, abs(d - diff[y][x])));
    }
    return memo[y][x][d];
}

int main()
{
    int h, w;
    cin >> h >> w;
    vector <vector <char> > diff(h);
    for (int y = 0; y < h; y++) {
	for (int x = 0; x < w; x++) {
            int a;
            cin >> a;
            diff[y].push_back(a);
	}
    }
    for (int y = 0; y < h; y++) {
	for (int x = 0; x < w; x++) {
            int b;
            cin >> b;
            diff[y][x] = abs(diff[y][x] - b);
	}
    }
    memset(memo, -1, sizeof(memo));

    int ret;
    for (ret = 0; ret < maxd; ret++) {
	if (doit(diff, w - 1, h - 1, ret)) {
            break;
	}
    }
    cout << ret << endl;
    return 0;
}


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

int main(){
    string s;
    cin>>s;
    int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0',sum=0;
    int t1,t2;
    for(int k=1;k<=2;k++){
        sum=a;
        if(k==1) sum=sum+b;
        else if(k==2) sum=sum-b;
        t1=sum;
		for(int i=1;i<=2;i++){
			sum=t1;
            if(i==1) sum=sum+c;
            else if(i==2) sum=sum-c;
            t2=sum;
            for(int j=1;j<=2;j++){
            	sum=t2;
                if(j==1) sum=sum+d;
                else if(j==2) sum=sum-d;
                if(sum==7){
                	//cout<<k<<"  "<<i<<"  "<<j<<endl;
                    cout<<a;
                    if(k==1) cout<<"+";
                    else if(k==2) cout<<"-";
                    cout<<b;
                    if(i==1) cout<<"+";
                    else if(i==2) cout<<"-";
                    cout<<c;
                    if(j==1) cout<<"+";
                    else if(j==2) cout<<"-";
                    cout<<d<<"=7";
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

public class Hello{
    public static void Main(){
        // Your code here!
        
        var d = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        int a = d[0];
        int b = d[1];
        int c = d[2];
        int nokori = b-(a-c);
        
        if(nokori<0){
            nokori = 0;
        }
        
        Console.WriteLine(nokori);
        
    }
}


Measured memory_bytes: 13268
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::{BinaryHeap, VecDeque};

const MOD: i64 = 1e9 as i64 + 7; 

fn main(){
    let n: usize = read();
    let mut s: Vec<usize> = (0..n).map(|_| read()).collect();
    s.sort();
    let mut sum = s.iter().fold(0, |t, x| t + x);
    if sum % 10 == 0{
    let pos = s.iter().position(|a| a % 10 != 0);
        match pos{
            Some(p) => sum -= s[p],
            None => {},
        }
    }
    let ans = if sum % 10 != 0 {sum} else {0};
    println!("{}", ans);
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 302;
int n,m,dp[N][N][N];
vector<vector<pii>> g(N);

int main(){
    read2i(n,m);
    lp(i,1,m){
        int l,r,x;
        read3i(l,r,x);
        g[r].pb({l,x});
    }

    dp[0][0][0] = 1;
    lp(i,0,n) lp(j,0,n) lp(k,0,n){
        if(i and (i == j or i == k)) continue;
        if(j and j == k) continue;

        int nxt = max({i,j,k})+1;

        for(pii p : g[nxt-1]){
            int distinct = (i >= p.f) + (j >= p.f) + (k >= p.f);
            if(distinct != p.s){
                dp[i][j][k] = 0;
                break;
            }
        }

        dp[i][j][nxt] = (dp[i][j][nxt] + dp[i][j][k]) % mod;
        dp[i][nxt][k] = (dp[i][nxt][k] + dp[i][j][k]) % mod;
        dp[nxt][j][k] = (dp[nxt][j][k] + dp[i][j][k]) % mod;
    }

    ll ans = 0;
    lp(i,0,n-1) lp(j,0,n-1) if((!i and !j) or i != j) ans = (ans + dp[i][j][n]) % mod;
    lp(i,0,n-1) lp(j,0,n-1) if((!i and !j) or i != j) ans = (ans + dp[i][n][j]) % mod;
    lp(i,0,n-1) lp(j,0,n-1) if((!i and !j) or i != j) ans = (ans + dp[n][i][j]) % mod;
    cout <<ans;
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


Measured memory_bytes: 107904
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    string s;
    cin >> s;
    int ans = 0;
    rep(i, SZ(s)) ans += s[i] - '0';
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();


        int y = Y/1000;
        for (int i = 0 ; i <= N; i++) {
            for (int j = 0 ; (i + j) <= N; j++) {
                int k = N - (i + j);
                if (i * 10 + j * 5 + k == y) {
                    System.out.println(String.format("%d %d %d", i, j, k));
                    return;
                }
            }
        }
        System.out.println(String.format("%d %d %d", -1, -1, -1));

        return;
    }

}

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

#define pii pair<int,int>
#define maxn 51
#define m_p make_pair

int main(){
	int n;
	cin>>n;
	int x[maxn],y[maxn];
	set<pii> st;
	for (int i=0;i<n;i++){
		cin>>x[i]>>y[i];
		st.insert(m_p(x[i],y[i]));
	}
	int res=0;
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++){
			if (i==j) continue;
			int dx=x[i]-x[j];
			int dy=y[i]-y[j];
			int cnt=0;
			for (int k=0;k<n;k++){
				pii qq=pii(dx+x[k],dy+y[k]);
				if (st.count(qq)) cnt++;
			}
			res=max(res,cnt);
		}
	printf("%d\n",n-res);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back
const ll mod = 1000000007;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

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

	int h; cin >> h;
	h--;
	for (int i = 1; i < N; i++) {
		int nh; cin >> nh;
		if (h > nh ) {
			No();
			return 0;
		}

		if (h == nh) {
			continue;
		}

		if (h < nh) {
			h = nh - 1;
		}
	}

	Yes();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;
double key[100][100];
double table[100][100];

void Init(int n, int m){
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) table[i][j] = 0;
}

double memo(int cur, int count, int limit, int kind){
	if(table[cur][count]) return table[cur][count];
	if(count==limit) return 1.0;
	for(int i = 0; i < kind; i++) table[cur][count] = max(table[cur][count], memo(i, count+1, limit, kind)*key[i][cur]);
	return table[cur][count];
}

int main(){
	int n, m;
	while(cin >> n >> m && ((n!=0)||(m!=0))){
		Init(n, m);
		for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> key[i][j];
		for(int i = 0; i < n; i++) table[i][0] = memo(i, 0, m-1, n);
		double max = 0;
		for(int i = 0; i < n; i++) if(max < table[i][0]) max = table[i][0];
		printf("%0.2f\n", max);
	}

	return 0;
}

Measured memory_bytes: 1400
N, K = input().split()
K = int(K)
NL = list(map(int, N[::-1]))

D = [int(_) for _ in input().split()]

min_d = min([i for i in range(10) if i not in D])

mod_idx = -1
i = 0
while len(NL) > i:
    n = NL[i]
    for j in range(n, 10):
        if j in D:
            NL[i] += 1
            mod_idx = i
        else:
            break

    if NL[i] >= 10:
        if i + 1 >= len(NL):
            NL.append(0)
        NL[i + 1] += 1
        mod_idx = i + 1
    i += 1

if mod_idx >= 0:
    for i in range(0, mod_idx):
        NL[i] = min_d
print(*reversed(NL), sep='')


Measured memory_bytes: 3188
#include<iostream>
#include<cstring>
using namespace std;
char s[100], t[100];
int main()
{
	cin >> s >> t;
	int len = strlen(s);
	int flag = 0;
	for(int i = 0; i < len; i++)
		if(s[i] != t[i]) flag = 1;
	if(flag == 1) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

int N, M;
vector<int> H;
vector<vector<int>> roads;

int main() {
    cin >> N >> M;
    H.resize(N);
    roads.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> H.at(i);
    }

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        roads.at(a).push_back(b);
        roads.at(b).push_back(a);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int good = true;
        for (int j = 0; j < roads.at(i).size(); j++) {
            if (H.at(i) <= H.at(roads.at(i).at(j))) {
                good = false;
            }
        }
        if (good) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 8720
#include <cstdio>           // printf(), scanf()
#include <cstdlib>          // abs()
#include <string>
#include <algorithm>        // max(), min(), swap()

using namespace std;
static const int N = 4;
static const int N2 = 16;
static const int LIMIT = 100;

struct puzzle
{
	int f[N2];
	int space;
	int MD;
};

puzzle state;
int limit;
int path[LIMIT];
int MDT[N2][N2];

int
get_all_MD(puzzle pz)
{
	int sum = 0;
	for (int i = 0; i < N2; ++i)
	{
		if (pz.f[i] != N2)
			sum += MDT[i][pz.f[i] - 1];
	}

	return sum;
}

bool
is_solved()
{
	for (int i = 0; i < N2; ++i)
	{
		if (state.f[i] != i + 1)
			return false;
	}

	return true;
}

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

bool
dfs(int depth, int prev)
{
	puzzle u;

	if (state.MD == 0)
		return true;

	/* ?????¨?????±???????????\??????????????£??????????¶?????????¶???????¶?????????????????????? */
	if (depth + state.MD > limit)
		return false;

	int sx = state.space / N;
	int sy = state.space % N;
	for (int r = 0; r < 4; ++r)
	{
		int tx = sx + dx[r];
		int ty = sy + dy[r];
		if (tx < 0 || N <= tx || ty < 0 || N <= ty || (max(prev, r) - min(prev, r) == 2))
			continue;

		u = state;
		/* ???????????????????????¢?????????????¨???????????????????????????????????????? */
		int s = sx * N + sy;
		int t = tx * N + ty;
		state.MD -= MDT[t][state.f[t] - 1];
		state.MD += MDT[s][state.f[t] - 1];
		swap(state.f[t], state.f[s]);
		state.space = t;
		if (dfs(depth + 1, r))
		{
			path[depth] = r;
			return true;
		}

		state = u;
	}

	return false;
}

/* ????????±??? */
string
iterative_deepening(puzzle in)
{
	in.MD = get_all_MD(in); /* ????????????????????????????????¢ */
	for (limit = in.MD; limit <= LIMIT; ++limit)
	{
		state = in;
		if (dfs(0, -100))
		{
			string ans = "";
			for (int i = 0; i < limit; ++i)
				ans += dir[path[i]];

			return ans;
		}
	}

	return "unsolvable";
}

int
main(int argc, char** argv)
{
	puzzle in;

	for (int i = 0; i < N2; ++i)
	{
		for (int j = 0; j < N2; ++j)
			MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
	}

	for (int i = 0; i < N2; ++i)
	{
		scanf("%d", &in.f[i]);
		if (in.f[i] == 0)
		{
			in.f[i] = N2;
			in.space = i;
		}
	}

	string ans = iterative_deepening(in);
	printf("%lu\n", ans.size());
	return 0;
}

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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  vector<int>H(N);
  for(int i=0; i<N; i++)cin >> H.at(i);
  
  double kion=A-(T-H.at(0)*0.006);
  int ans =1;
  
  for(int i=0; i<N; i++){
    double sa = A-(T-H.at(i)*0.006);
    if(kion*kion>sa*sa){
      kion = sa;
      ans = i+1;
    }
  }
  
  cout << ans << endl;
}

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

#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,n) for(int i = (s); i < (n); i++)
#define asort(x) sort(x.begin(),x.end())

#define M 1000001
int main() {
    ll n,in,cnt = 0;
    cin >> n;
    vector<ll> a(n), f(M), g(M,1);
    rep(i,n) {
        cin>>a[i];
        f[a[i]]++; //同じ数が何個あるか数えている
    }
    rep(i,M) if(f[i] != 1) g[i] = 0; //複数ある数はないものとする（0）
    srep(i,1,M){
        if(f[i] == 0) continue; //個数が0である数は飛ばす
        int ii = i * 2; 
        /* 存在する数を倍々にし、定義域までを0とする */
        while(ii < M) {
            g[ii] = 0;
            ii += i;
        }
    }
    rep(i,M) cnt += f[i] * g[i];
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 20368
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	int a,b;
	cin >> a >> b;
	int ans = (a-1)*(b-1);
	cout << ans << endl;
	
	return 0;
}

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

int main(){
  int K,S;
  cin >>K>>S;
  
  
  int ans = 0;
  repeat(i,0,K){
    repeat(j,0,K){
      int k = S-i-j;
      if(k>=0 and k<=K) ans++;
    }
  }
  cout <<ans<< endl;
}

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

using namespace std;


#define N 200005



int32_t main()
{
   // ios_base::sync_with_stdio(false);
    int t,x;
    cin>>t>>x;

    double ans=t*1.0;
    ans/=x;
   // cout<<ans<<endl;
    printf("%.5lf",ans);
    return 0;
}

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

int main(){
	int h,w;
	cin >> h >> w;
	while(h!=0 || w!=0){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
		cin >> h >> w;
	}
}

Measured memory_bytes: 1152
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = 0
for i in range(N-1):
    ans += B[A[i]-1]
    if A[i]+1 == A[i+1]:
        ans += C[A[i]-1]

ans += B[A[N-1]-1]
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	int d=scan.nextInt();
	//int e=scan.nextInt();
	//int f=scan.nextInt();
	//String str1=scan.next();
	//String str2=scan.next();
	boolean bool=false;
	System.out.println(a*b-c*b-a*d+c*d);
	}
}


Measured memory_bytes: 23252
from collections import deque

n, k = map(int, input().split())
a = tuple(map(int, input().split()))

tere = {}
for i in range(n):
    tere[i+1] = a[i]

mati = deque([1])
mark = set([1])
tugi = 1
for i in range(1, k+1):
    if tere[tugi] not in mark:
        mati.append(tere[tugi])
        mark.add(tere[tugi])
    else:
        mati.append(tere[tugi])
        mark.add(tere[tugi])
        break
    tugi = tere[tugi]
else:
    print(tugi)
    exit()

mati = list(mati)
cnta = len(mati)-1
i = mati.index(mati[-1]) + 1
cntroop = cnta - i + 1
roop = mati[i:]

print(roop[(k-cnta)%cntroop-1])

Measured memory_bytes: 149784
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
struct edge{
    int to;
    int cost;
    edge(int _to,int _cost){
        to=_to,cost=_cost;
    }
};
struct node{
    int num;
    int cost;
    node(int _num,int _cost){
        num=_num,cost=_cost;
    }
    bool operator<(const node &a)const{
        if(cost==a.cost)num>a.num;
        return cost>a.cost;
    }
};
int N,M;
vector<edge> E[1000];
int main(){
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b,c,d;
        scanf("%d,%d,%d,%d",&a,&b,&c,&d);
        a--;b--;
        E[a].push_back(edge(b,c));
        E[b].push_back(edge(a,d));
    }
    int x1,x2,y1,y2;
    scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
    x1--;
    x2--;
    int karians=0;

    priority_queue<node> Q;
    int mini[1000]={1};
    //??????
    for(int i=0;i<1000;i++)mini[i]=2000000000;
    Q.push(node(x1,0));
    mini[x1]=0;
    while(!Q.empty()){
        node now=Q.top();Q.pop();
        for(int i=0;i<E[now.num].size();i++){
            if(mini[E[now.num][i].to]>mini[now.num]+E[now.num][i].cost){
                mini[E[now.num][i].to]=mini[now.num]+E[now.num][i].cost;
                Q.push(node(E[now.num][i].to,mini[now.num]+E[now.num][i].cost));
            }
        }
    }
    karians+=mini[x2];

    //??°???
    for(int i=0;i<1000;i++)mini[i]=2000000000;
    Q.push(node(x2,0));
    mini[x2]=0;
    while(!Q.empty()){
        node now=Q.top();Q.pop();
        for(int i=0;i<E[now.num].size();i++){
            if(mini[E[now.num][i].to]>mini[now.num]+E[now.num][i].cost){
                mini[E[now.num][i].to]=mini[now.num]+E[now.num][i].cost;
                Q.push(node(E[now.num][i].to,mini[now.num]+E[now.num][i].cost));
            }
        }
    }
    karians+=mini[x1];

    cout<<y1-y2-karians<<endl;
}

Measured memory_bytes: 1272
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();
        int d = sc.nextInt();
        int res = 0;
        
        if(l%d==0){
            res = 1;
        }
        res = res + r/d - l/d; 
        
        System.out.println(res);
                
            
        
        
        
        
        
        }
    }

Measured memory_bytes: 35632
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[66666];

int main(){
	int n,i,l;
	
	cin>>s;
	
	l=strlen(s);
	
	cout<<s[0];
	cout<<l-2;
	cout<<s[l-1];
		
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;
int main()
{
	long long N;
	long long Y;
	bool flag = false;
	long long a, b, c;
	long long Ans;

	cin >> N >> Y;

	long long y = Y / 1000;

	for (int i = 0; i < N+1; i++) {
		for (int j = 0; j < N+1 - i; j++) {
			if (flag == true) {
				break;
			}
			Ans = 10 * i + 5 * j + (N - i - j);
			if (Ans == y) {
				flag = true;
			}
			if (flag == true) {
				a = i;
				b = j;
				c = N - i - j;
			}
		}
	}


	if (flag == true) {
		cout << a << " " << b << " " << c;
	}
	else { cout << "-1 -1 -1"; }

	return 0;
}


Measured memory_bytes: 256