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

typedef long long ll;
const int MAX=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int d[4][2]={{1,0},{-1,0},{0,1},{0,-1}};

void Solve(int n,int* a,int sum){
    int q;
    cin>>q;
    while(q--){
        int x,y,ans=0;
        cin>>x>>y;
        cout<<sum-a[x]+y<<endl;
    }
}

int main(){
    int n;
    while(cin>>n){
        int a[128],sum=0;
        for(int i=1;i<=n;i++) cin>>a[i],sum+=a[i];
        Solve(n,a,sum);
    }
    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long

struct Point {
	int x, y;

	double dis(Point a, Point b) {
		return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y) * (a.y - b.y));
	}
};



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

	int N, Y;
	int ans1 = -1, ans2 = -1, ans3 = -1;
	cin >> N >> Y;
	for (int i = 0; i <= N; i++)
	{
		for (int j = 0; j <= N; j++)
		{
			int k = N - i - j;
			if (k < 0) {
				continue;
			}
			if (i * 10000 + j * 5000 + k * 1000 == Y) {
				ans1 = i;
				ans2 = j;
				ans3 = k;
				break;
			}
		}
	}

	printf("%d %d %d\n", ans1, ans2, ans3);

	return 0;
}


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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")   */


//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 3e5 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 2e12;

mt19937 Flash_new_51(51515);

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

pair <int, int> aa[N];

int a[N];

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> k >> n;
    int ans = INF;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        int j = (i + 1) % n;
        int j1 = (i - 1 + n) % n;
        if (a[j1] > a[i]) ans = min(a[j1] - a[i], ans);
        else  ans = min(ans, a[j1] + k - a[i]);

        if (a[j] < a[i]) ans = min(a[i] - a[j], ans);
        else ans = min(ans, a[i] + k - a[j]);
    }
    cout << ans;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1000000000
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

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

int main() {
  ll X;
  cin >> X;

  ll i = 0;

  while (true) {
    if (i * (i + 1) / 2 >= X) {
      cout << i << endl;
      break;
    }
    i++;
  }
  return 0;
}


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


void solve() {
  int N = 5;
  std::vector<int> arr(N, 0);
  rep(i,N) {
    scanf("%d", &arr[i]);
  }
  int ans = 0;
  rep(i, N) {
    if (arr[i] == 0) {
      ans = i+1;
    }
  }

  cout << ans << "\n";
}

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


Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>
//#include <bits/stdc++.h>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

void move(vector<vector<int>> &stn, int num)
{
	rep(i, num)
	{
		rep(j, 5)
		{
			if (stn[i][j] == 0)
			{
				stn[i][j] = stn[i + 1][j];
				stn[i + 1][j] = 0;
			}
		}
	}
}
int check(vector<vector<int>> &stn, int num)
{
	int poi = 0;
	rep(i, num)
	{
		int tmp = 0;
		rep(j, 3)
		{
			if (stn[i][j] == stn[i][j + 1] && stn[i][j + 1] == stn[i][j + 2])
			{
				tmp += stn[i][j] * 3;
				if (j < 2 && stn[i][j + 2] == stn[i][j + 3])
				{
					if (j == 0 && stn[i][j + 3] == stn[i][j + 4])
					{
						tmp += stn[i][j + 4];
						stn[i][j + 4] = 0;
					}
					tmp += stn[i][j + 3];
					stn[i][j + 3] = 0;
				}
				stn[i][j] = 0, stn[i][j + 1] = 0,	stn[i][j + 2] = 0;
			}
		}
		poi += tmp;
	}
	return poi;
}

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

	int num = 0;
	while (cin >> num && num != 0)
	{
		vector< vector<int> > stn(num + 1, vector<int>(5));
		rep(i, num) { cin >> stn[num - i - 1][0] >> stn[num - i - 1][1] >> stn[num - i - 1][2] >> stn[num - i - 1][3] >> stn[num - i - 1][4]; }
		int ans = 0, tmp = 0;
		rep(i, 10)
		{
			ans += check(stn, num);
			rep(i, 10) { move(stn, num); }
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3228
N=io.read("n")
Y=io.read("n")
local x=-1
local y=-1
local z=-1
local I=Y//10000
local J=Y//5000
for i=0,I do
  for j=0,J do
    if i+j<=N and i*10000+j*5000+(N-i-j)*1000==Y then
      x=i
      y=j
      z=N-i-j
      break
    end
  end
  if x~=-1 then
    break
  end
end
print(string.format("%d %d %d",x,y,z))
      

Measured memory_bytes: 376
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>

using namespace std;
using  ull = unsigned long long int;

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


int main() {

	
	int x, a, b;
	cin >> x >> a >> b;

	if (abs(x - a) < abs(x - b))cout << "A" << endl;
	else cout << "B" << endl;


	return 0;
}

Measured memory_bytes: 256
r, g, b, n = map(int, input().split())
r, g, b = sorted([r, g, b], reverse=True)
cnt = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        rg = r*i + g*j
        k = (n-rg)//b
        if k >= 0 and i+j+k >= 1 and rg+b*k == n:
            cnt += 1
print(cnt) 


Measured memory_bytes: 40684
fun main() {
  val n = readLine()!!.toInt()
  val a = readLine()!!.split(" ").map(String::toInt).toList().sorted()
  
  val boolArray = BooleanArray(a.max()!!)
  
  var a_before = 0
  for(a_i in a) {
    if(boolArray[a_i-1]) {
      a_before = a_i
      continue
    }
    
    if(a_i==a_before) {
      boolArray[a_i-1] = true
      a_before = a_i
      continue
    }
    
    for(j in 0 until (a.last()/a_i - 1)){
      boolArray[(a_i)*(j+2)-1] = true
    }
    
    a_before = a_i
  }
  
  var ans = 0
  for(a_i in a) if(!boolArray[a_i-1]) ans++
  println(ans)
}

Measured memory_bytes: 66996
h,w=map(int,input().split())
alp=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
l=[]
for i in range(h):
    a=list(map(str,input().split()))
    l.append(a)
for j in range(h):
    for k in range(w):
        if l[j][k]=='snuke':
            print(alp[k]+str(j+1))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const int inf=100000;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	int l,r,d;
	cin>>l>>r>>d;
	int ans=0;
	for(int i=l;i<=r;i++)
	{
		if((i%d)==0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	ld l;
	cin >> l;
	l /= 3;
	printf("%Lf\n", l * l * l);

	return 0;
}


Measured memory_bytes: 256
s = int(input())
a = int(s/100)
b = s%100

#YYMM
if 0 < b and b <= 12 and 0<a and a <= 12:
    print("AMBIGUOUS")
elif 0<a and a <= 12:
    print("MMYY")
elif 0 < b and b <= 12:
    print("YYMM")
else:
    print("NA")


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {
	set<string> mset;
	string s;
	int k;
	cin >> s;
	cin >> k;
	int n = (int)s.length();
	for (int l=1; l <= min(n,k); ++l) {
		for (int i = 0; i <= n-l; ++i) {
			int j = i+l-1;
			string t = "";
			for (int p = i; p <= j; ++p) {
				t += s[p];
			}
			mset.insert(t);
		}
	}

	--k;
	while (k--) {
		mset.erase(mset.begin());
	}
	cout << *mset.begin() << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////


Measured memory_bytes: 1664
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
#include <map>
#include <limits>
#include <algorithm>
#include <numeric>

using namespace std;


int _main(int n, int k, vector<int> lengths){
  sort(lengths.rbegin(), lengths.rend());
  int culm = 0;
  for(int i = 0; i < k; i++){
    culm += lengths[i];
  }
  return culm;
}


int main(int argc, char *argv[])
{
  string line;
  getline(cin, line);
  int n = 0;
  int k = 0;
  istringstream iss_first(line);
  iss_first >> n;
  iss_first >> k;
  vector<int> lengths;
  getline(cin, line);
  istringstream iss_second(line);
  for(int i = 0; i < n; i++){
    int l = 0;
    iss_second >> l;
    lengths.push_back(l);
  }
  cout << _main(n, k, lengths) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define EREP(i,n) for(int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#define BEG cout<<"D::";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#define BEG {}
#endif
const int MOD = 1000000007;
const ll INF = 50000000000000000;


    ll N,a[500000];
    ll ans=-INF;
    ll front,back;
    ll cnt=0;
    char S[1000];
    bool up=false;
    deque<char> A,B;
    ll f,b;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    cin>>S;
    REP(i,N){
        if(S[i] == '('){
         f++;
     }else if(S[i] == ')'){
      if(f == 0){
       b++;
      }else{
       f--;
        }

    }
    A.push_back(S[i]);
}
    REP(i,b)cout<<"(";
    for(auto x:A){
        cout<<x;
    }
    REP(i,f)cout<<")";
    //cout << ans << endl;

    return 0;
}

//ABC 062 D-3N Numbers


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s[101],t[101];
    int n,m;
    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>s[i];
    }
    cin>>m;
    for (int i=1; i<=m; i++)
    {
        cin>>t[i];
    }
    int score=0,ans=0;
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=n; j++)
        {
            if (s[i]==s[j]) score++;
        }
        for (int j=1; j<=m; j++)
        {
            if (s[i]==t[j]) score--;
        }
        if (score>ans) ans=score;
        score=0;
    }
    if (ans>=0) cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mod (1e9+7)
#define inf (1e9+7)
#define nil -1
int main() {
	int N;
	cin >> N;
	/*
	int len = to_string(N).length();
	int num = pow(10,len-1);
	int total = -1;
	for (int i = 1; i <= len; i++)
	{
		if (to_string(pow(10,i-1)).length()%2==1) {
			total += pow(10, i-1)-pow(10,i-1);
		}
	}
	if (len % 2 == 1)total++;*/
	int c = 0;
	for (int i = 1; i <= N; i++)
	{
		if (to_string(i).length()%2==1) {
			c++;
		}
	}
	cout <<c<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int x, a;
    cin>>x>>a;
    if(a > x) cout<<0<<endl;
    else cout<<10<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

using namespace std;

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

int di[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dj[] = {-1,  0,  1,-1, 1,-1, 0, 1};
int field[60][60];
int w, h;
bool inrange(int i, int j){
    return i >= 0 && j >= 0 && i < h && j < w;
}

void rec(int i, int j){
    field[i][j] = 0;
    rep(k, 8){
        int ni = i+di[k];
        int nj = j+dj[k];
        if(inrange(ni, nj) && field[ni][nj] == 1){
            rec(ni, nj);
        }
    }
}


int main(){
    int n,p;
    while(cin>>w>>h,w||h){
        rep(i, h){
            rep(j, w){
                cin >> field[i][j];
            }
        }
        int ans = 0;
        rep(i, h){
            rep(j, w){
                if(field[i][j] == 1) {
                    rec(i, j);
                    ans++;/*
                    rep(a, h) {
                        rep(b, w){
                            cout << field[a][b] << " ";
                        }
                        cout << endl;
                    }
                    cout << endl;*/
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair < int , int > Pi;
typedef pair < ll , ll > Pl;
const int INF = (1 << 30) - 1;
const ll LLINF = 1LL << 60;

int N, M;
string S[50005], R[50005];
inline int search(string T)
{
    if(T[T.size() - 1] == '*') {
        T = T.substr(0, T.size() - 1);
        string C = T;
        C += 'z' + 1;
        return (lower_bound(S, S + N, C) - lower_bound(S, S + N, T));
    } else if(T[0] == '*') {
        string C;
        T = T.substr(1);
        reverse(T.begin(), T.end());
        C = T;
        C += 'z' + 1;
        return (lower_bound(R, R + N, C) - lower_bound(R, R + N, T));
    } else {
        if(binary_search(S, S + N, T)) {
            return (1);
        } else {
            return (0);
        }
    }
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 0; i < N; i++) {
        cin >> S[i];
        R[i] = S[i];
        reverse(R[i].begin(), R[i].end());
    }
    sort(S, S + N); sort(R, R + N);
    while(M--) {
        string T;
        int pos = -1, sum = 0;
        cin >> T;
        for(int i = 0; i < T.size(); i++) {
            if(T[i] == '?') pos = i;
        }
        if(pos == -1) {
            cout << search(T) << endl;
        } else {
            for(int i = 0; i < 26; i++) {
                T[pos] = i + 'a';
                sum += search(T);
            }
            cout << sum << endl;
        }
    }
    return (0);
}



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

#define pb push_back
const int inf=0x3f3f3f3f;
const int N=10,M=1000;
int n,m,s;
char a[N+1][M+5];

int main()
{
	cin>>n>>m>>s;
	for(int i=1;i<=n;i++)
	    cin>>a[i]+1;
	int ans=inf;
	for(int i=0;i<1<<n-1;i++)
	{
		vector<int> pos;
		pos.pb(0);
		for(int j=1;j<n;j++)
		    if(i&1<<j-1)
			    pos.pb(j);
		pos.pb(n);
		int now=pos.size()-2;
		vector<int> cnt(pos.size()-1,0);
		for(int j=1;j<=m;j++)
		{
			bool ok=true; 
			vector<int> cnt0(pos.size()-1,0);
			for(int k=0;k<cnt.size();k++)
			{ 
				for(int o=pos[k]+1;o<=pos[k+1];o++)
				    cnt0[k]+=a[o][j]^48;
				if(cnt0[k]>s)
				    goto label_end;
				if(cnt[k]+cnt0[k]>s)
				    ok=false;
			}
			if(ok)for(int k=0;k<cnt.size();k++)cnt[k]+=cnt0[k];
			else now++,cnt=cnt0;
		}
		ans=min(ans,now);
	label_end:;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
stack<char> cube;
int main()
{
  string a;
  cin>>a;
	int x;
	int ans=0;
	for(x=0;x<a.size();x++)
	{
		if(cube.size()==0)
		{
			cube.push(a[x]);
		}
		else
		{
			if(cube.top()!=a[x])
			{
			ans+=2;
			cube.pop();	
			}
			else
			{
				cube.push(a[x]);
			}
		}

	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var array = Console.ReadLine().Split(' ');
        var A = long.Parse(array[0]);
        var B = long.Parse(array[1]);
        var N = long.Parse(array[2]);
        
        long ans = 0;

        if(N >= B)
        {
            ans = (long)Math.Truncate((decimal)((A * (B - 1)) / B)) - A * (long)Math.Truncate((decimal)((B - 1) / B));
        }
        else
        {
            ans = (long)Math.Truncate((decimal)((A * N) / B)) - A * (long)Math.Truncate((decimal)(N / B));
        }

        Console.WriteLine(ans);
        Console.ReadLine();
    }
}



Measured memory_bytes: 17996
#include <iostream>

using namespace std;

int main()
{
   int n, sum;
   int b[100000];

   cin >> n;
   for(int i = 0; i < n - 1; i++){
      cin >> b[i];
   }

   sum = b[0];

   for(int i = 1; i < n; i++){
      if(b[i] < b[i - 1]){
         sum += b[i];
      }
      else{
         sum += b[i - 1];
      }
   }

   sum += b[n - 2];

   cout << sum;

   return 0;
}

Measured memory_bytes: 256
// Gaurav Nuti
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define ar array
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define INF 1e9 

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

bool comparep(pair<ll, ll> i1, pair<ll, ll> i2){
	return (i1.S < i2.S);
} 

ll modInverse(ll a)
{
    return power(a , mod - 2);
}

vector<vector<ll>> graph;
vector<bool> visited;
vector<ll> dist;
map<ll,ll> mymap;
ll max_dist = 1;

void bfs(int u1){
    visited[u1] = 1;
    dist[u1] = 1;
    mymap[1] = u1;
    queue<ll> q;
    q.push({u1});
    while(!q.empty()){
        ll u = q.front();
        q.pop();
        for(auto i=graph[u].begin();i!=graph[u].end();i++){
            if(!visited[*i]){
                dist[*i] = dist[u] + 1;
                visited[*i] = 1;
                max_dist = max(dist[*i],max_dist);
                mymap[dist[*i]] = *i;
                q.push({*i});
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif  
	
    ll t;
    // cin>>t;
    t = 1;
    for(ll z=0;z<t;z++){
        ll n,m;
        cin>>n>>m;
        ll h[n];
        inp_arr(h,n);
        vector<ll> good(n,1);
        for(ll i = 0;i<m;i++){
            ll a,b;
            cin>>a>>b;
            a--;b--;
            if(h[a] <= h[b])
                good[a] = 0;
            if(h[b] <= h[a])
                good[b] = 0;
        }
        ll count = 0;
        for(ll i=0;i<n;i++)count+=good[i];

        cout<<count;
    }
}

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

using namespace std;

int main()
{
    int a,b,c,d;
    cin >> a;
    int x[a];
    b = 0;
    for(int i = 0;i < a;i++){
        cin >> x[i];
    }
    for(int i = 1;i < (a-1);i++){
        c = 0;
        if(x[i] > x[i+1]){
            c++;
        }
        if(x[i] > x[i-1]){
            c++;
        }
        if(c == 1){
            b++;
        }
    }
    cout <<b<<endl;

    return 0;
}

Measured memory_bytes: 3632
ma = lambda :map(int,input().split())
h,w,d = ma()
area_d = [[] for i in range(d)]
rs = [[0] for i in range(d)]
for i in range(h):
    for j,a in enumerate(ma()):
        area_d[a%d].append((a,i,j))
for i in range(d):
    area_d[i].sort()

for i in range(d):
    yp,xp = 0,0
    for a,y,x in area_d[i]:
        rs[i].append(rs[i][-1] + abs(y-yp)+abs(x-xp))
        yp,xp = y,x
q = int(input())
for i in range(q):
    l,r = ma()
    lq,lr = divmod(l,d)
    rq,rr = divmod(r,d)
    if lr==0:print(rs[lr][rq] - rs[lr][lq])
    else:print(rs[lr][rq+1] - rs[lr][lq+1])


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

#define inf 2000000000  // 1e17
template <class T>
struct Dinic {
  struct edge {
    int to;
    T cap;
    int rev;
  };
  vector<vector<edge>> edges;
  vector<int> id;
  vector<int> d;
  Dinic(int n = 1) {
    edges.clear();
    edges.resize(n);
    id.resize(n);
    d.resize(n);
  }
  bool add(int start, int goal, T capacity) {
    edges[start].push_back((edge){goal, capacity, (int)edges[goal].size()});
    edges[goal].push_back((edge){start, 0, (int)edges[start].size() - 1});
    return 1;
  }
  void bfs(int st) {
    d.assign(d.size(), -1);
    queue<int> qu;
    d[st] = 0;
    qu.push(st);
    while (qu.size()) {
      int now = qu.front();
      qu.pop();
      for (auto e : edges[now])
        if (e.cap > 0 && d[e.to] < 0) {
          d[e.to] = d[now] + 1;
          qu.push(e.to);
        }
    }
  }
  T pathdfs(int now, int goal, T nf) {
    if (now == goal) return nf;
    for (int& i = id[now]; i < (int)edges[now].size(); ++i) {
      edge* e = &edges[now][i];
      if (e->cap > 0 && d[now] < d[e->to]) {
        T res = pathdfs(e->to, goal, min(nf, e->cap));
        if (res > 0) {
          e->cap -= res;
          edges[e->to][e->rev].cap += res;
          return res;
        }
      }
    }
    return 0;
  }
  T solve(int start, int goal) {
    T res = 0, nf = 0;
    while (1) {
      bfs(start);
      if (d[goal] < 0) return res;
      id.assign(id.size(), 0);
      while ((nf = pathdfs(start, goal, inf)) > 0) res += nf;
    }
    return -1;
  }
};

int n, m;
int d[] = {0, 1, 0, -1};
string c1 = ">v<^", c2 = "<^>v";
vector<string> s;
Dinic<int> din;

bool isvalid(int x, int y) {
  return x >= 0 && x < n && y >= 0 && y < m && s[x][y] == '.';
}

int main() {
  cin >> n >> m;
  s.resize(n);
  for (auto& p : s) cin >> p;
  if (n == m && n == 1) {
    cout << 0 << endl;
    cout << s[0] << endl;
    return 0;
  }
  din = Dinic<int>(n * m + 2);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (s[i][j] == '.') {
        if ((i ^ j) & 1)
          din.add(i * m + j, n * m + 1, 1);
        else {
          din.add(n * m, i * m + j, 1);
          for (int k = 0; k < 4; ++k) {
            int nx = i + d[k], ny = j + d[k ^ 1];
            if (isvalid(nx, ny)) din.add(i * m + j, nx * m + ny, 1);
          }
        }
      }
  cout << din.solve(n * m, n * m + 1) << endl;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (!((i ^ j) & 1)) {
        for (auto e : din.edges[i * m + j])
          if (e.cap == 0) {
            int nx = e.to / m, ny = e.to % m;
            for (int k = 0; k < 4; ++k)
              if (i + d[k] == nx && j + d[1 ^ k] == ny) {
                s[i][j] = c1[k];
                s[nx][ny] = c2[k];
              }
          }
      }
  for (auto p : s) cout << p << endl;
  return 0;
}


Measured memory_bytes: 4928
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){ _;
  int a,b;cin>>a>>b;
  if(b%a==0)
    cout<<a+b<<endl;
  else
    cout<<b-a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000007
#define MAX 100001
#define INF LLONG_MAX
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,tmp;
    cin>>n;
    vector<ll> v;
    for(int i=0;i<n;i++){
        cin>>tmp;
        v.pb(tmp);
    }
    vector<ll> dp(n+1);
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct tri {
    ll b,l,u,v;
    bool operator<(const tri& a) const {
        return v < a.v;
    }
};

int main() {
    int n;
    ll x,t = 0;
    cin >> n >> x;
    vector<tri> a(n);
    vector<ll> sums(n+1,0);
    for (int i = 0;i < n;++i) {
        cin >> a[i].b >> a[i].l >> a[i].u;
        a[i].v = x*a[i].u-(a[i].u-a[i].l)*a[i].b;
        t += a[i].b*a[i].l;
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for (int i = 0;i < n;++i) {
        sums[i+1] += sums[i]+a[i].v;
    }
    ll ng = -1,ok = 1e10;
    while (ok-ng > 1) {
        ll mid = (ok+ng)/2;
        ll q = mid/x,m = mid%x;
        bool f = false;
        if (q >= n) f = true;
        else {
            for (int i = 0;i < n;++i) {
                ll s = 0;
                if (a[i].b > m) s += a[i].l*m;
                else s += a[i].u*m-(a[i].u-a[i].l)*a[i].b;
                s += sums[q];
                if (q >= i) s += a[q].v-a[i].v;
                if (s-t >= 0) {
                    f = true;
                    break;
                }
            }
        }
        (f ? ok : ng) = mid;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>
int main(){
  int a;
  scanf("%d",&a);
  long long int b,c=1,d=2;
  if(a==1){printf("1");}
  else{
    for(int i=2; i<=a; i++){
      b=c+d;
      d=c;c=b;
    }
    printf("%lld",b);
  }
  return 0;}

Measured memory_bytes: 128
a, b, c, k = map(int,input().split())
if k >= a:
    sum = 1 * a
else:
    sum = 1 * k

if k >= a + b + c:
    sum = sum - (1 * c)
if k < a + b + c and k > a + b:
    sum = sum - (1 * (k - a - b))
print(sum)

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

int main() {
    int64_t X, year = 1, money = 100;
    cin >> X;
    while (1) {
        money *= 1.01;
        if (money >= X) {
            break;
        } else {
            year++;
        }
    }
    cout << year << endl;
    return 0;
}


Measured memory_bytes: 3520
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_set>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main(int argc, char* argv[]) {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }

  vector<int> l(n);
  int count = 0;
  bool smaller = true;
  while (smaller) {
    int i = 0;
    smaller = false;
    while (i < n) {
      while (i < n && l[i] == h[i]) {
        ++i;
      }
      if (i < n) {
        ++count;
      }
      while (i < n && l[i] < h[i]) {
        smaller = true;
        ++l[i];
        ++i;
      }
    }
  }

  cout << count;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<fstream>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int main() {
	llong  int a, b;
	cin >> a >> b;
	llong gcd = GCD(a, b);
	vector<llong> cand;
	for (llong i = 1; i <= sqrt(gcd);++i) {
		if (gcd % i == 0) {
			if(i == gcd / i){
				cand.push_back(i);
			}
			else {
				cand.push_back(i);
				cand.push_back(gcd / i);
			}
		}
	}
	sort(cand.begin(),cand.end());
	vector<llong> take;
	REP(c, cand.size()) {
		bool is_so = true;
		REP(t, take.size()) {
			llong result = GCD(cand[c], take[t]);
			if (result != 1) {
				is_so = false;
			}
		}
		if (is_so) {
			take.push_back(cand[c]);
		}
	}
	cout << take.size() << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 1; i <= (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int n, m;
vector< vi > A(100005);
vector<bool> seen(100005);

void dfs(int x) {
    seen[x] = true;
    for (int i : A[x]) {
        if (seen[i]) continue;
        dfs(i);
    }
}

int main(void) {

    cin >> n >> m;
    
    rep (i, m) {
        int a, b; cin >> a >> b;
        A[a].push_back(b);
        A[b].push_back(a);
    }
    
    rep(i, n) seen[i] = false;
    int areas = 0;

    rep(i, n) {
        if (!seen[i]) {
            // cout << i << endl;
            areas++;
            dfs(i);
        }
    }
    cout << areas - 1 <<endl;

    return 0;
}

Measured memory_bytes: 9280
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(int, h, w);
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#') {
        bool f = false;
        // ue
        if (i - 1 >= 0)
          if (s[i - 1][j] == '#') f = true;
        // shita
        if (i + 1 <= h - 1)
          if (s[i + 1][j] == '#') f = true;
        // hidari
        if (j - 1 >= 0)
          if (s[i][j - 1] == '#') f = true;
        // migi
        if (j + 1 <= w - 1)
          if (s[i][j + 1] == '#') f = true;
        if (!f) {
          cout << "No" << endl;
          return;
        }
      }
    }
  }
  cout << "Yes" << endl;
}

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

int main() {
  int N; cin >> N;
  double ans = 0;
  for (int i = 0; i < N; i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "BTC") {
      ans += 380000 * x;
    }
    else ans += x;
  }
  cout << fixed << setprecision(8);
  cout << ans << endl;
  return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> t(n);
    for(int i = 0; i < n; i ++) cin >> t.at(i);
    int sum = accumulate(t.begin(), t.end(), 0);
    int m; cin >> m;
    vector<int> p(m);
    vector<int> x(m);
    for(int i = 0; i < m; i ++) cin >> p.at(i) >> x.at(i);
    for(int i = 0; i < m; i ++) {
        int ans = sum - t[p[i]-1] + x[i];
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int N,S[110];
	int PI=0;
	S[0]=0;
	cin>>N;
	for(int i = 1;i<=N;i++)
	{
		cin>>S[i];
	}
	sort(S,S+N+1,less<int>());
	for(int i = 1;i<=N;i++){
		if(S[i-1]-S[i] ==0)
		{

		}
		else
		{
		PI++;


		}
		
		
	}

	
		cout<<PI<<endl;
	

}

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

int main()
{
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < 2000; ++i)
	{
		if ((int)((double)i*0.08) == a && (int)((double)i*0.1) == b)
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main(){
  int i,ans;
  char N[4];
  ans = 0;
  for(i = 0;i < 4;i++)cin >> N[i];
  i = 0;
  while(i < 4){
    if(N[i] == '-')
      ans--;
    else
      ans++;
    i++;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;

int main() {
	int K, X;
	cin >> K >> X;

	for(int i=X-K+1; i<X+K; i++) {
		cout << i <<  ' ';
	}
	cout << endl;

  return 0;
}

Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    S = str(input().strip())
    L = len(S)

    i = 0
    if L % 2 == 1:
        mid = (L - 1) // 2
        m = S[mid]
        while i <= mid and S[mid-i] == S[mid+i] == m:
            i += 1

        print(mid + i)
    else:
        mid =  (L - 1) // 2
        m0 = S[mid]
        m1 = S[mid+1]
        while i <= mid and S[mid-i] == S[mid+i+1] == m0 == m1:
            i += 1

        print(mid + i + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <queue>

using ll = long long int;

std::queue<ll> que;

int main()
{

    int k;

    std::cin >> k;

    for (int i = 1; i <= 9; ++i)
        que.push(i);

    ll ans;

    for (int i = 0; i < k; ++i)
    {
        ll x = que.front();
        que.pop();
        if (x % 10 == 0)
        {
            que.push(x * 10);
            que.push(x * 10 + 1);
        }
        else if (x % 10 == 9)
        {
            que.push(x * 10 + 8);
            que.push(x * 10 + 9);
        }
        else
        {
            que.push(x * 10 + x % 10 - 1);
            que.push(x * 10 + x % 10);
            que.push(x * 10 + x % 10 + 1);
        }

        if (i == k - 1)
            ans = x;
    }
    std::cout << ans << std::endl;
}

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

using namespace std;

int main(){
 string s; 
  cin >> s;
 
   int res=0;
  
  if(s[0]=='1') res++;
  if(s[1]=='1') res++;
  if(s[2]=='1') res++;
  if(s[3]=='1') res++;
  if(s[4]=='1') res++;
  if(s[5]=='1') res++;
  
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int l,r,ans;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>l>>r;
        ans+=r-l+1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
program main
   implicit none
   integer(8)::a,b,k,cou=0
   integer(8)::i,j
   
  ! integer,allocatable,dimension(:)::c
   read(*,*)a,b,k
   do i=min(a,b),1,-1
      
      if(mod(a,i)==0 .and. mod(b,i)==0)then
         cou=cou+1
         if(cou==k)exit
      endif
   enddo
   write(*,*)i
end program main


Measured memory_bytes: 640
import heapq
q = []
heapq.heapify(q)

n = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

zeros = [False]*n
Cs = [Bs[(i-1)%n]+Bs[(i+1)%n] for i in range(n)]
# Dが大きい順に操作していく
for i, (b,c,a) in enumerate(zip(Bs,Cs,As)):
    d = b-(c+a) 
    if d < 0: continue
    heapq.heappush(q,(-d,i))

cnt = 0
while len(q) > 0:
    d,i = heapq.heappop(q)
    # 自分と周りの影響を更新
    cnt_ = (Bs[i%n]-As[i%n]) // Cs[i%n]
    Bs[i%n] -= cnt_*Cs[i%n]    
    Cs[(i-1)%n] = Bs[(i-2)%n]+Bs[i%n]
    Cs[(i+1)%n] = Bs[(i+2)%n]+Bs[i%n]
    # 周りとの差
    d_m = Bs[(i-1)%n]-Cs[(i-1)%n]-As[(i-1)%n] 
    d_p = Bs[(i+1)%n]-Cs[(i+1)%n]-As[(i+1)%n]
    if d_m >= 0:
        heapq.heappush(q,(-d_m,i-1))
    if d_p >= 0:
        heapq.heappush(q,(-d_p,i+1))
    cnt += cnt_

if As == Bs:
    print(cnt)
else:
    print(-1)
    


Measured memory_bytes: 130252
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

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

int main() {
    int d,n;
    cin>>d>>n;
    int a;
    if(d==0){
        a=1;
    }
    if(d==1){
        a=100;
    }
    if(d==2){
        a=10000;
    }
    int b=a*n;

    if(n==100){
        b+=a;
    }
    cout<<b<<endl;




    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>

const int ms = 303;

int n, k, m;
int memo[ms][ms];
int memo2[ms][ms];
int comb[ms][ms];

int dp(int size, int lim);
int sum(int i, int j) {
	if(j > k) return 0;
	int &ans = memo2[i][j];
	if(ans != -1) return ans;
	return ans = (dp(i, j) + sum(i, j + 1)) % m;
}

int dp(int size, int lim) {
	if(size <= 0) return 1;
	int &ans = memo[size][lim];
	if(ans != -1) return ans;
	ans = 0;
	for(int i = 0; i < size; i++) {
		ans = (ans + (long long) sum(i, lim + 1) * dp(size - i - 1, lim) % m * comb[size - 1][i]) % m;
	}
	//std::cout << "on " << size << ", " << lim << " got " << ans << std::endl;
	return ans;
}

int main() {
	std::cin >> n >> k >> m;
	memset(memo, -1, sizeof memo);
	memset(memo2, -1, sizeof memo2);
	for(int i = 0; i < ms; i++) {
		comb[i][0] = 1;
		for(int j = 1; j <= i; j++) {
			comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % m;
		}
	}
	std::cout << dp(n, 0) << std::endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <string>
using namespace std;

#define MAX_N 1000
#define MAX_M 100

struct spot{ int id, num; };

int main(){
	int n, m, cand[MAX_N][MAX_M + 1];
	spot sum[MAX_M + 1];
	int res, count;
	
	while(true){
		scanf("%d%d", &n, &m);
		if(n == 0 && m == 0) break;
		for(int i = 0; i < n; i++){
			for(int j = 1; j <= m; j++){
				scanf("%d", &cand[i][j]);
			}
		}
		
		for(int i = 1; i <= m; i++){
			sum[i].id = i; sum[i].num = 0;
		}
		for(int i = 0; i < n; i++){
			for(int j = 1; j <= m; j++){
				sum[j].num += cand[i][j];
			}
		}
		for(int i = 1; i <= m; i++){
			for(int j = i + 1; j <= m; j++){
				if(sum[i].num < sum[j].num || (sum[i].num == sum[j].num && sum[i].id > sum[j].id)){
					spot sub = sum[i];
					sum[i] = sum[j];
					sum[j] = sub;
				}
			}
		}
		
		for(int i = 1; i <= m; i++){
			printf("%d", sum[i].id);
			if(i < m) printf(" ");
			else printf("\n");
		}
	}
	
	return 0;
}

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

using namespace std;

int main()
{
    //system("chcp 65001");

    string S;
    cin >> S;
    int i,j;

    int ans = 0;

    for(i = 0;i <= 3;i++)
    {
        for(j = i;j <= 3;j++)
        {
            if(S[i] == S[j] && i != j)
            {
                ans++;
            }
        }
    }

    if(ans == 2)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    

    return 0;
}

Measured memory_bytes: 256
#define DEBUG 0

/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 4/13/2019, 9:08:24 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, K;
string S;
vector<int> V;

int main()
{
  cin >> N >> K >> S;
  bool one = true;
  int t = 0;
  for (auto i = 0; i < N; i++)
  {
    if (S[i] == '0' && one)
    {
      V.push_back(t);
      one = false;
      t = 1;
    }
    else if (S[i] == '1' && one)
    {
      t++;
    }
    else if (S[i] == '0' && !one)
    {
      t++;
    }
    else
    {
      V.push_back(t);
      one = true;
      t = 1;
    }
  }
  V.push_back(t);
  if (!one)
  {
    V.push_back(0);
  }
#if DEBUG == 1
  for (auto x : V)
  {
    cerr << x << " ";
  }
  cerr << endl;
#endif
  vector<int> imos(V.size() + 1, 0);
  for (auto i = 0; i < (int)V.size(); i++)
  {
    imos[i + 1] = imos[i] + V[i];
  }
#if DEBUG == 1
  for (auto x : imos)
  {
    cerr << x << " ";
  }
  cerr << endl;
#endif
  int seg = min(2 * K + 1, (int)V.size());
  int ans = 0;
  for (auto i = 0; i + seg <= (int)V.size(); i++)
  {
    if (i % 2 == 0)
    {
      ans = max(ans, imos[i + seg] - imos[i]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1272
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = int.Parse(ReadLine());
		var a = ReadLine().Split().Select(long.Parse).ToArray();
		var sum = 0L;
		for(int i = 1; i < n; i++)
		{
			if(a[i] < a[i - 1])
			{
				sum += a[i - 1] - a[i];
				a[i] = a[i - 1];
			}
		}
		WriteLine(sum);
	}
}


Measured memory_bytes: 44500
N = gets.to_i
edges = {}

N.pred.times {
  u, v, w = gets.split(' ').map(&:to_i)
  edges[u] ||= {}
  edges[u][v] = w
  edges[v] ||= {}
  edges[v][u] = w
}

def flip(c)
  c == 0 ? 1 : 0
end

colors = Array.new(N)

colors[0] = 0
nexts = [1]
loop do
  break if nexts.empty?

  nn = []
  nexts.each do |i|
    c = colors[i.pred]
    es = edges[i]
    es.keys.each do |j|
      next unless colors[j.pred].nil?

      cc = es[j] % 2 == 0 ? c : flip(c)
      colors[j.pred] = cc

      nn.push(j)
    end
  end
  nexts = nn
end

puts colors


Measured memory_bytes: 39164
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
  	string S;
  	cin >> S;
  	int N = stoi(S);
  	int SN = 0;
  	for(const char ch : S){
      	SN += static_cast<int>(ch - '0');
    }
  	if(N % SN == 0) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
  int n,a,r=0,s=1000;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    if(r<a)r=a;
    if(s>a)s=a;
  }
  printf("%d",r-s);
  return 0;
}

Measured memory_bytes: 128
from collections import deque
def bfs(si):
  q = deque()
  q.append([si,-1])
  used.add(si)
  while len(q)>0:
    prvi, prvcol = q.popleft()
    col = 1 
    for i in g[prvi]:
      if i in used:continue
      if col == prvcol: col += 1
      cols[eds[str(min(prvi,i))+'-'+str(max(prvi,i))]] = col
      q.append([i,col])
      used.add(i)
      col += 1

N = int(input())
g = {i:[] for i in range(N)}
eds = {}
for i in range(N-1):
  a,b = map(int,input().split())
  eds[str(a-1)+'-'+str(b-1)] = i
  g[a-1].append(b-1)
  g[b-1].append(a-1)

used = set([])
cols = [-1 for _ in range(N-1)]  
bfs(0)
print(max(cols))
[print(col) for col in cols]

Measured memory_bytes: 108260
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int y, m, d;
  for (int i = 0; i < n;i++){
    cin >> y >> m >> d;
    int tmp = y;
    if(y%3==0){
      d = 20 - d;
    }else{
      if(m%2==0){
        d = 19 - d;
      }else{
        d = 20 - d;
      }
    }
    d++;
    m = 10 - m;
    if(m<0)
      m = 0;
    int ans = m / 2 * 20 + (m - m / 2) * 19 + d;
    if(y%3==0){
      ans += (m - m / 2);
    }
    y++;
    while(y<1000){
      if(y%3==0){
        ans += 200;
      }else{
        ans += 195;
      }
      y++;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n;
pp d[210];

const ll M = 998244353;
const ll inv2 = (M+1)/2;

pp operator-(pp a, pp b){
	return {a.x-b.x, a.y-b.y};
}
ll gcd(ll a, ll b){ return b?gcd(b,a%b):a; }
pp regu(pp a, bool noneg=true){
	if((a.x<0 || (a.x==0 && a.y<0)) && noneg) a.x=-a.x, a.y=-a.y;
	ll g=gcd(abs(a.x), abs(a.y));
	if(g) a.x/=g, a.y/=g;
	return a;
}

int pow2[210];

int main()
{
	read(n);
	for(int i=1; i<=n; ++i) read(d[i].x, d[i].y);
	pow2[0]=1;
	for(int i=1; i<=n; ++i) (pow2[i]=pow2[i-1]*2)%=M;
	ll ans=0;
	for(int i=1; i<=n; ++i){
		map<pp, vector<int>> v;
		for(int j=1; j<=n; ++j){
			if(i==j) continue;
			v[regu(d[j]-d[i])].pb(j);
		}
		for(auto& T:v){
			auto& v=T.second;
			bool flg=1;
			for(int x:v){
				if(regu(d[x]-d[i],0) != regu(d[v[0]]-d[i], 0)){
					flg=0; break;
				}
			}
			if(flg){
				int k = v.size()+1;
				(ans += (pow2[k]-1-k+2*M)%M)%=M;
			}
		}
	}
	printf("%lld\n", (pow2[n]-1-n-inv2*ans%M+M)%M);
	return 0;
}


Measured memory_bytes: 256