akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n; cin  >> n;
    vi a(1e6+1), cnt(1e6+1);
    rep(i,n) {
        i32 tmp;
        cin >> tmp;
        a[tmp] = 1;
        ++cnt[tmp];
    }

    rep1(i, 1e6) {
        if(!a[i]) continue;
        for(i32 j = 2*i; j <= 1e6; j += i) {
            if(a[j]) a[j] ^= 1;
        }
    }

    i32 ans = 0;
    rep1(i, 1e6) {
        if(a[i] && cnt[i] == 1) ++ans;
    }

    cout << ans << '\n';


    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 18836
//       THIS IS MY NINJA WAY
#include<bits/stdc++.h>
#include<ctime>
#include<vector>
#include<algorithm>

#define str string
#define dbl double
#define ll long long
#define vl vector<ll> 
#define vs vector<str>
#define pll  pair<ll,ll> 
#define vll vector<pll>
#define sl set<ll>
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define fr(i,a,b) for(long long i=a; i<b; i++)
#define nfr(i,a,b) for(long long i=a; i<=b; i++)
#define psl pair<str,ll>
#define pls pair<ll,str>
#define pss pair<str,str>
#define ALL(a) a.begin(),a.end()
#define stl stack<ll>
#define coml complex<ll>
#define INF 0x3f3f3f3f3f3f3f3f
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
const ll MOD = 1e9+7;
using namespace std;
ll knapSack(ll W,vl wt,vl val,ll n){
	ll K[n+1][W+1];
	fr(i,0,n+1){
		fr(j,0,W+1){
			if(i==0 || j==0)K[i][j]=0;
			else if(wt[i-1]<=j)K[i][j]=max(val[i-1]+K[i-1][j-wt[i-1]],K[i-1][j]);
			else K[i][j]=K[i-1][j];
		}
	}
	return K[n][W];
}
int main()
{
	fast
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r" , stdin);
		freopen("output.txt", "w" , stdout);
	#endif*/
		ll n,W;
		cin>>n>>W;
		vl wt(n),val(n);
		fr(i,0,n){
			cin>>wt[i]>>val[i];
		}
		cout<<knapSack(W,wt,val,n);
		return 0;
	}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  int ans=0;
  for(int i=1;i<=n;i++)ans+=i;
  
  cout << ans << endl;
  return 0;
}


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

using namespace std;

long long init;
int year;

long long tanri(double r, long long t) {
    long long A = init;
    long long sum = 0;
    for (int i = 0; i < year; i++) {
        sum += A * r;
        A -= t;
    }
    return sum + A;
}

long long hukuri(double r, long long t) {
    long long A = init;
    
    for (int i = 0; i < year; i++) {
        A = A + A * r - t;
    }
    return A;
}

int main()
{
    int m;

    cin >> m;
    while (m--) {
        long long ans = 0;
        int n;

        cin >> init >> year >> n;
        while (n--) {
            int type;
            long long tesu;
            double ritu;

            cin >> type >> ritu >> tesu;
            if (type == 0) 
                ans = max(ans, tanri(ritu, tesu));
            else if (type == 1)
                ans = max(ans, hukuri(ritu, tesu));
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;



void chmax(ll &a,ll b) {
	if (a < b)a = b;
}


int main() {
	int n;
	cin >> n;
	int ans = 0;
	vector<int>v(n);

	rep(i, 0, n) {
		cin >> v[i];
	}





	rep(i, 0, n - 1) {
		if (v[i] == i + 1) {
			swap(v[i], v[i + 1]);
			ans++;
		}
	}
	if (v[n - 1] == n)ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
// Implementation practice (Have seen the editorial)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef set<int> si;
typedef priority_queue<int> pqi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define loop(i, a) for (int i = 0; i < (a); i++)
#define loop1(i, a) for (int i = 1; i <= (a); i++)
#define loopr(i, a, b) for (int i = (a); i <= (b); i++)
#define dloop(i, a) for (int i = (a) - 1; i >= 0; i--)
#define dloopr(i, b, a) for (int i = (b); i >= (a); i--)
#define tr(it, container) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define vpresent(container, element) (find(container.being(), container.end() ,element) != container.end())
#define show(a) cout << a << "\n"
#define showloop(a, len) for (int i = 0; i < len; i++) cout << a[i] << "\n"
#define debug(a) cout << #a << ": " << (a) << "\n"
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) ((int)x.size())
#define ran(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
const int MOD = 1000000007;
const double PI = acos(-1);

int main() {
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	//ios::sync_with_stdio(false);cin.tie(NULL);

	int n, a;
	cin >> n >> a;
	cout << n*n - a << endl;

	return 0;
}


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

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;

ll dp[100005][105][2];

int main(){
	string k;
	int d;
	cin>>k;
	cin>>d;
	int n = k.size();
	for(int rem=1;rem<d;rem++){
		dp[n][rem][0] = dp[n][rem][1] = 0; 
	}
	dp[n][0][0] = dp[n][0][1] = 1;
	for(int i=n-1;i>=0;i--){
		for(int rem=0;rem<d;rem++){
			dp[i][rem][0] = dp[i][rem][1] = 0;
			for(int j=0;j<=9;j++){
				dp[i][rem][1] = (dp[i][rem][1]+dp[i+1][(rem+j)%d][1])%MOD;
				if(j<k[i]-'0')
					dp[i][rem][0] = (dp[i][rem][0]+dp[i+1][(rem+j)%d][1])%MOD;
				else if(j==k[i]-'0')
					dp[i][rem][0] = (dp[i][rem][0]+dp[i+1][(rem+j)%d][0])%MOD;	
			}
		}
	}
	cout<<(dp[0][0][0]+MOD-1)%MOD<<"\n";
	return 0;
}

/*
dp[i][rem][0] = No. of ways to put the digits in such a way that their sum%D is D-rem such that digits put till now are matching with s.
dp[i][rem][1] = No. of ways to put the digits in such a way that their sum%D is D-rem
*/

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

using namespace std;
typedef long long int lld;


int main(void){
	int n;
	scanf("%d",&n);
	n%=10;
	if(n==2||n==4||n==5||n==7||n==9) printf("hon");
	else if(n==3) printf("bon");
	else printf("pon");
	return 0;
}


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

using pii = pair<int, int>;
using vi = vector<int>;
using ll = long long;

constexpr int INF = 1e9;

int main() {
    string s;
    int n;
    cin >> s >> n;
    int res = 0;
    for(int i = 0; i < n; ++i) {
        string t;
        cin >> t;
        t = t + t;
        for(int j = 0; j + s.size() <= t.size(); ++j) {
            if(t.substr(j, s.size()) == s) {
                res += 1;
                break;
            }
        }
    }
    cout << res << endl;
}


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

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using i32 = int_fast32_t;
using u32 = uint_fast32_t;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using usize = size_t;

namespace chrono = std::chrono;
using namespace std::literals;

#define all(c) (c).begin(), (c).end()

__attribute__((constructor))
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}

using vec = std::pair<i64, i64>;

i64 inf = std::numeric_limits<i64>::max();

int main() {
  i32 n, k;
  cin >> n >> k;
  std::vector<vec> ps(n);
  for (auto& p: ps) {
    cin >> p.first >> p.second;
  }
  std::sort(all(ps));

  i64 ans = inf;
  for (i32 i = 0; i < n; ++i) {
    std::vector<i64> ys;
    for (i32 j = i; j < i + k - 1; ++j) {
      ys.push_back(ps[j].second);
    }
    for (i32 j = i + k - 1; j < n; ++j) {
      ys.push_back(ps[j].second);
      sort(all(ys));
      i64 dx = ps[j].first - ps[i].first;
      i64 dy = inf;
      for (i32 u = 0; u + k - 1 < (i32)ys.size(); ++u) {
        dy = std::min(dy, ys[u + k - 1] - ys[u]);
      }
      ans = std::min(ans, dx * dy);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    int i, j, n, y;
    cin >> n >> y;
    REP (i,0,n) REP (j,0,n-i) {
        if (i * 10000 + j * 5000 + (n - i - j) * 1000 == y) {
            printf("%d %d %d\n",i,j,n-i-j);
            return 0;
        }
    }
    puts("-1 -1 -1");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll t;cin>>t;
    while(t){
        t--;
        ll n;cin>>n;
        vector<ll>a(n);
        rep(i,n)cin>>a[i];
        string s;cin>>s;
        bool f=1;
        set<ll,greater<ll> >st;
        for(int i=n-1;i>=0;i--){
            if(s[i]=='0'){
                for(auto e:st){
                    a[i]=min(a[i],a[i]^e);
                }
                if(a[i])st.insert(a[i]);
            }else{
                for(auto e:st){
                    a[i]=min(a[i],a[i]^e);
                }
                if(a[i])f=0;
            }
        }
        if(f)cout<<0<<endl;
        else cout<<1<<endl;
    }
}

Measured memory_bytes: 3560
n,p = map(int,input().split())
a = list(map(int,input().split()))

odd = 0
for i in a:
    if i%2:
        odd += 1
even = n-odd

ans = 0

for i in range(0,odd+2,2):
    if i+p > odd:
        break
    for j in range(0,even+1):
        if j > even:
            break
        
        a = 1
        for k in range(i+p):
            a *= (odd-k)
            a /= k+1
    
        b = 1
        for k in range(j):
            b *= (even-k)
            b /= k+1
       
        
        ans += a*b
print(int(ans))



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<char>> masu(N, vector<char>(M)) ;
  for (int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++){
      cin >> masu.at(i).at(j);
    }
  }
  
  vector<bool> goodx(N, false);
  vector<bool> goody(M, false);
  for (int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      if(masu.at(i).at(j) == '#'){
        goodx.at(i) = true;
        goody.at(j) = true;
      }
    }
  }
  
  for (int i =0; i < N; i++){
    if(goodx.at(i)){
      for(int j =0; j < M; j++){
        if(goody.at(j)){
          cout << masu.at(i).at(j);
        }
      }
     cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main()
{

char c;
cin>>c;

bool vowel=(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');

if(vowel)
    cout<<"vowel"<<endl;
else
    cout<<"consonant"<<endl;
    return 0;
    }

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,X = II()
l = [1]*(N+1)
for i in range(1,N+1):
    l[i] = l[i-1]*2+3

p = [1]*(N+1)
for i in range(1,N+1):
    p[i] = p[i-1]*2+1

#階層h，先頭i枚の中のパティの数
def rec(h,i):
    if h==0:
        if i>0:
            return 1
        else:
            return 0
    else:
        if i>=l[h]-1:
            return p[h]
        elif i<=1:
            return 0
        elif 2<=i<=l[h-1]+1:
            return rec(h-1,i-1)
        elif i==l[h-1]+2:
            return p[h-1]+1
        else:
            return p[h-1]+1+rec(h-1,i-l[h-1]-2)

print(rec(N,X))

Measured memory_bytes: 38384
#include <stdio.h>

int main(void) {
    int h, w, a, b;
    scanf("%d%d%d%d", &h, &w, &a, &b);
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if((j < a && i < b) || (i >= b && j >= a)) printf("0");
            else printf("1");
        }
        printf("\n");
    }
}

Measured memory_bytes: 1152
#include<iostream>
#include<map>
#include<algorithm>
#include<string>
using namespace std;

const int MAX = 100;
int main() {
	int N, M;
	string s, t;
	map<string, int> m;
	cin >> N;
	for (int i = 0;i < N;++ i) {
		cin >> s;
		++ m[s];
	}
	cin >> M;
	for (int i = 0;i < M;++ i) {
		cin >> t;
		-- m[t];
	}
	int ans = 0;
	for (map<string, int>::iterator i = m.begin();i != m.end();++ i) ans = max(ans, i->second);
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、存在しない文字列を言えば0円なので0円以上にはなる
後は、赤を+1, 青を-1として数えれば良いので、mapとかを使えば簡単に分かる
*/

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
using namespace std;
const int num = 45;
int f[num];
inline int getNumber(int i) {
	if (i == 0 || i == 1)
		return 1;
	int j;
	for (j = 2; j <= i; j++) {
		f[j] = f[j - 1] + f[j - 2];
	}
	j--;
	return f[j];
}
int main() {
	int n;
	cin >> n;
	f[0] = 1;
	f[1] = 1;
	int x = getNumber(n);
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	unsigned long long n;
	cin >> n;
	unsigned long long a,b;
	cin >> a >> b;
	
	unsigned long long ans = 0;
	if((b-a)%2==1)
	{
		ans = min(min(n-a,n-b),min(a-1,b-1));
		ans += (b-a)/2;
		ans++;
	}
	else
	{
		ans = (b-a)/2;
	}
	
	cout<<ans<<endl;
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    rep(i, N) {
        cin >> A[i];
        sum ^= A[i];
    }
    rep(i, N) {
        cout << (sum ^ A[i]);
        if(i != N - 1) cout << ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int A, B;
    cin >> A >> B;
    if (A <= 5) B = 0;
    else if (A <= 12) B /= 2;
    cout << B << '\n';
    return 0;
}

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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  if (s.size() >= t.size()) {
    cout << "No" << endl;
  } else {
    int m = s.size(), n = t.size();
    bool yes = true;
    for (int i = 0; i < m && i < n; i++) {
      if (s[i] != t[i]) {
        yes = false;
        break;
      }
    }
    cout << (yes ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 3628
loop do
  h,w = gets.chomp.split.map(&:to_i)
  break if h == 0 && w == 0
  count_h = 0
  count_w = 0
  h.times{
    w.times{
      if count_w % 2 == 0 || count_w == 0
        print "#"
      else
        print "."
      end
      count_w += 1
     }

     if count_h % 2 == 0 || count_h == 0
       count_w = 1
     else
       count_w = 0
     end
     count_h += 1
    puts
   }
   puts
end


Measured memory_bytes: 8896
#include <stdio.h>
int main(void)
{
	int a,b;
	b=2;
	scanf("%d",&a);
	while(1){
		b=b*2;
	if(b>a){
		b=b/2;
		break;
	}
	}
	printf("%d\n",b);
	
	return 0;
}


Measured memory_bytes: 2124
n = int(input())
s = input()
ans = 0
for l in range(n):
    ss = s[l:]
    length = n - l
    i, j = 1, 0
    a = [0 for _ in range(length)]
    while i < length:
        while i + j < length and ss[j] == ss[i + j]:
            j += 1
        a[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < length and k + a[k] < j:
            a[i + k] = a[k]
            k += 1
        i += k
        j -= k
    for ll, al in enumerate(a):
        if al <= ll:
            ans = max(ans, al)
print(ans)


Measured memory_bytes: 57180
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	string a,b;
	cin >> a >> b;
	cout << b << a << endl;
	return 0;
}



Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=2e5+10;
int n,x,y,ans,vis[maxn];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);puts("");}
struct Heavy_Light_Decomposition{
    struct edge{int to,nxt;}e[maxn<<1];int tot,head[maxn];
    int idx,fa[maxn],dfn[maxn],dep[maxn],son[maxn],top[maxn],size[maxn];
    void add(int u,int v){e[++tot].to=v;e[tot].nxt=head[u];head[u]=tot;}
    void insert(int u,int v){add(u,v);add(v,u);}
    void build(int x){
        dep[x]=dep[fa[x]]+1;size[x]=1;int mx=0;
        for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to){
            if(v==fa[x])continue;
            fa[v]=x;build(v);size[x]+=size[v];
            if(size[v]>mx)mx=size[v],son[x]=v;
        }
    }
    void dfs(int x){
        if(!x)return ;dfn[x]=++idx;
        top[x]=son[fa[x]]==x?top[fa[x]]:x;
        dfs(son[x]);
        for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
            if(v!=fa[x]&&v!=son[x])dfs(v);
    }
    int query(int u,int v){
        while(top[u]!=top[v]){
            if(dep[top[u]]<dep[top[v]])swap(u,v);
            u=fa[top[u]];
        }if(dep[u]>dep[v])swap(u,v);
        return u;
    }
    int get_dis(int u,int v){return dep[u]+dep[v]-2*dep[query(u,v)];}
}HLD[2];
void init(int S){
    queue<int >q;
    q.push(S);vis[S]=1;
    while(!q.empty()){
        int x=q.front();q.pop();
        for(int i=HLD[0].head[x],v=HLD[0].e[i].to;i;i=HLD[0].e[i].nxt,v=HLD[0].e[i].to)
            if(!vis[v]&&HLD[0].dep[v]<HLD[1].dep[v])vis[v]=1,q.push(v);
    }
}
void solve(){
    for(int x=1;x<=n;x++){
        if(!vis[x])continue;
        ans=max(ans,HLD[1].dep[x]-1);
        for(int i=HLD[0].head[x],v=HLD[0].e[i].to;i;i=HLD[0].e[i].nxt,v=HLD[0].e[i].to)
            if(HLD[1].get_dis(v,x)>2){puts("-1");return ;}
    }write(ans<<1);
}
int main(){
    n=read();x=read();y=read();
    if(x==y){puts("0");return 0;}
    for(int i=1;i<n;i++)HLD[0].insert(read(),read());
    for(int i=1;i<n;i++)HLD[1].insert(read(),read());
    HLD[0].build(x);HLD[0].dfs(x);HLD[1].build(y);HLD[1].dfs(y);
    init(x);solve();
    return 0;
}
 

Measured memory_bytes: 34868
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        long sum = 0;
        long max = 0;

        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        for(int i=0; i<k; i++) {
            sum += (a[i] + 1);
        }
        max = sum;
        for(int i=k; i<n; i++) {
            sum += (a[i] + 1);
            sum -= (a[i-k] + 1);
            max = Math.max(max, sum);
        }
      System.out.println((double)(max) / 2) ;
  }
}


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

typedef long long ll;

ll n, m;
bool check(ll x) {
    if(n * x <= m) {
        if((m - n * x) % x == 0) return true;
    }
    return false;
}

vector<int> divs;

void getDivs() {
    for(int i = 1; i * i <= m; i++) {
        if(m % i == 0) {
            divs.push_back(i);
            divs.push_back(m / i);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    getDivs();
    int ans = 0;
    sort(divs.begin(), divs.end());
    for(int i : divs) {
        if(check(i * 1LL)) {
            ans = i;
        }
    }
    cout << ans << endl;
}


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------

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

  ll n;
  cin >> n;

  vector<ll> h;

  rep(i, n) {
    ll a;
    cin >> a;

    auto result = find(all(h), a);

    if (result == h.end()) {
      h.push_back(a);
    } else {
      h.erase(result);
    }
  }
  cout << h.size() << endl;
  return 0;
}

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

using namespace std;

const int N=1e5+10;
long long int n, W, weight[101], value[101], dp[101][N];

long long int calc(int index, int w)
    {
        if(w < 0) return -2e12;//base case 1
        if(index == n) return 0;//base case 2
        if(dp[index][w] != -1)//if we already calculated the case dont calculate it again
            return dp[index][w];
        long long int c1, c2;
        c1 = calc(index+1, w);//dont take the item
        c2 = calc(index+1, w-weight[index]) + value[index];//take the item
        return dp[index][w] = max(c1,c2);//store and return the calculated value
    }

int main()
    {
        cin >> n >> W;
        for (int i=0; i < n; i++)
            cin>> weight[i] >> value[i];
        memset(dp,-1,sizeof(dp));//set all items in dp[][] to -1
        cout << calc(0,W);
        return 0;
    }


Measured memory_bytes: 79104
n = int(input())
strNums = input().split()
intNums = [int(i) for i in strNums]
step = []
initialValue = intNums[0]
for i in range(len(intNums)):
    if intNums[i] < initialValue:
        step.append(initialValue - intNums[i])
    else:
        step.append(0)
        initialValue = intNums[i]
print(sum(step))

Measured memory_bytes: 39944
#include <stdio.h>

int main(void) {
	int n;
	int i;
	int a[100] ={};
	int j;
	int tmp;
	int flag = 1;
	int count = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for (j = n - 1; j > 0; j --){
		if (flag == 0){
			break;
		}
		flag = 0;
		for (i = 0; i < j; i++){
			if (a[i] > a[i+1]){
				tmp = a[i];
				a[i] = a[i+1];
				a[i+1] = tmp;
				flag = 1;
				count++;
			}
			
		}
	}
	for (i = 0; i < n - 1; i++){
		printf("%d ", a[i]);
	}
	printf("%d", a[n-1]);
	printf("\n");
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 1820
#include<stdio.h>
#include<math.h>

typedef struct {double x, y;}Point;
void koch(int, Point, Point);

int main()
{
  Point a, b;
  int n;
  
  scanf("%d",&n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
  
  return 0;
}

void koch(int n, Point a, Point b)
{
  if(n == 0)return;

  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;/*th = (π/3)*/

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;/*内分点sのx座標*/
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;/*内分点sのy座標*/
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;/*内分点tのx座標*/
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;/*内分点tのy座標*/
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;/*点tのx座標を60°回転*/
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;/*点tのy座標を60°回転*/

  koch(n - 1, a, s);                 /*線分asについて上記と同じ処理をする*/
  printf("%.8f %.8f\n",s.x,s.y);    
  koch(n - 1, s, u);                 /*線分suについて上記と同じ処理をする*/
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n - 1, u ,t);                 /*線分utについて上記と同じ処理をする*/
  printf("%.8f %.8f\n",t.x,t.y);    
  koch(n - 1, t, b);                 /*線分tbについて上記と同じ処理をする*/
}



Measured memory_bytes: 2048
// -YDK- {{{
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <numeric>
#include <string>
#include <cstdio>
#include <vector>
#include <tuple>
#include <cmath>
#include <queue>
#include <regex>
#include <set>
#include <map>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
#define debug(...) fprintf(stderr, __VA_ARGS__ )
#define outl(x) cout << (x) << '\n'
#define outl2(x,y) cout << (x) << ' ' << (y) << '\n'
#define endl '\n'
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
#define ALL(x) x.begin(), x.end()
#define YES(f,y,n) cout << ((f)? (#y):(#n)) << '\n'
#define ODD(n) ((n)&1)
#define EVEN(n) (!ODD(n))
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
template<class T>using MaxHeap = priority_queue< T, vector<T>, greater<T> >;
using ll = long long;
using pii = pair<int, int>;
using byte= unsigned char;
inline bool inside(int x, int y, int W, int H) { return x>=0 && y>=0 && x<W && y<H; }
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int dx[] = {1, 0, -1, 0};
constexpr int dy[] = {0, 1, 0, -1};
struct Point: public pii {
    int &x = this->first,   &y = this->second;
    Point(int x, int y): pii(x, y) {}
};
// }}}
constexpr int LIM = (int)1e5 + 5;

int N, F, M;

using P = pair<string, string>;

string str[12];

void sortP(P &p) { if (p.first > p.second) swap(p.first, p.second); return; }

map<P, int> cnt;
set< pair<P, int> > st;

signed main(void)
{
    cin.tie(nullptr), ios::sync_with_stdio(false);

    cin >> N >> F;
    rep(i, N) {
        cin >> M;
        rep(j, M) cin >> str[j];

        for (int a=0; a < M-1; ++a) {
            for (int b=a+1; b < M; ++b) {
                auto p = P(str[a], str[b]);
                sortP(p);
                //cout << ":::: " << p.first << "\t" << p.se << endl;
                ++cnt[p];
            }
        }

    }

    for (auto e: cnt) {
        if (e.second >= F) {
            st.emp(e);
        }
    }

    outl(st.size());
    for (auto e: st) {
        cout << e.fi.fi << ' '  << e.fi.se << endl;
    }

    return 0;
}




Measured memory_bytes: 3872
n = list(map(int,input().split()))
l = [list(map(int,input().split())) for i in range(n[1])]
minp = l[0][0]
maxp = l[0][1]
for t in range(n[1]):
    minp = max(minp,l[t][0])
    maxp = min(maxp,l[t][1])
print(max(0,maxp-minp+1))

Measured memory_bytes: 27332
import math

def comb(n,r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

n,m=list(map(int,input().split()))
a=list(map(int,input().split()))

s=[0 for i in range(n+1)]
mod={}
mod[0]=[0]

for i in range(n):
    s[i+1]=(s[i]+a[i])%m
    if s[i+1] not in mod:
        mod[s[i+1]]=[i+1]
    else:
        mod[s[i+1]].append(i+1)

ans=0
for i in mod.keys():
    if len(mod[i])>=2:
        ans+=comb(len(mod[i]),2)
print(ans)

Measured memory_bytes: 23912
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
	fast;
	ll arr[5],n;
	cin>>n;
	for(int i=0;i<5;i++)
		cin>>arr[i];
	sort(arr,arr+5);
	ll min=arr[0];
	ll t=4;
	if(n%min==0)
		t+=n/min;
	else
		t+=n/min+1;
	cout<<t;
	return 0;
}


Measured memory_bytes: 3632
S = list(input())

S1 = int(S[0]+S[1])
S2 = int(S[2]+S[3])

if((S1 == 0 and S2 == 0) or (S1 > 12 and S2 > 12)):
    print('NA')
elif(S1 == 0 or S2 ==0):
    if(S1 < 13 and S1 > 0):
        print('MMYY')
    elif(S2 < 13 and S2 > 0):
        print('YYMM')
    else:
        print('NA')
elif(S1 < 13 and S2 < 13):
    print('AMBIGUOUS')
elif(S1 < 13 and S1 > 0):
    print('MMYY')
elif(S2 < 13 and S2 > 0):
    print('YYMM')


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	static int ans;
	static int n;
	static int m;
	static int[][] e;
	static int[] c;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = Integer.parseInt(sc.next());
		m = Integer.parseInt(sc.next());

		e = new int [n][n];
		c = new int [n];

		for(int i=0; i<m; i++){
			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());
			e[a-1][b-1] = 1;
			e[b-1][a-1] = 1;
		}

		c[0] = 1;
		dfs(0, n);
		System.out.println(ans);
	}
	public static void dfs(int number, int q){
		if (q == 1){
			ans ++;
			return;
		}
		for (int i=1; i<n; i++){
			if (e[number][i] == 1 && c[i] != 1){
				c[i] = 1;
				dfs(i, q-1);
				c[i] = 0;
			}
		}
	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cctype>
#include <utility>
#include <string>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template<typename T>
#define _HT template<typename H,typename... T>
_T _DEF(T,in,int c){T n{};int m{1};while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
_T _SCAN(T &n){int c{gcu()};return c==EOF?false:(n=in<T>(c),true);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
_OUT(string s){for(char c:s)pcu(c);}
#endif
_OUT(const char *s){while(*s)pcu(*s++);}
_T _OUT(T n){static char b[20];char *p{b};T m=n<0?pcu('-'),-1:1;if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{int e,b{0},s{1};range(int _b,int _e,int _s):e(_e),b(_b),s(_s){}range(int _b,int _e):e(_e),b(_b){}range(int _e):e(_e){}
	struct it{int v,s;it(int _v,int _s):v(_v),s(_s){}operator int()const{return v;}operator int&(){return v;}int operator*()const{return v;}it& operator++(){v+=s;return *this;}};
	it begin(){return{b, s};}it end(){return{e,s};}bool inner(int n){return b<=n&&n<e;}};

int main() {
	for (string a; scan(a);) {
		if (a.size() % 2) {
			outl("NA");
			continue;
		}
		string b;
		for (auto i {begin(a)}; i != end(a); i += 2) {
			int r = i[1] - '1', s {*i - '1'};
			if (!(range(5).inner(r) && range(6).inner(s))) {
				b = "NA";
				break;
			}
			int c {'a' + s * 5 + r};
			b.push_back(c > 'z' ? ".?! "[c - '{'] : c);
		}
		outl(b);
	}
}


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


int main() {
long h,w;
cin>>h>>w;

if(h>=2&&w>=2){
  long ans=h*w;
  if(ans%2) cout<<ans/2+1<<endl;
  else cout<<ans/2<<endl;
}
else cout<<1<<endl;

}


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

int main(void)
{
	using namespace std;
	string string1, string2, string3;
	int flag = 1;
	cin >> string1 >> string2;
	string3 = string1 + string1;
	for(
	int i = 0; i < 	string1.size(); i++)
	{
		for(int j = 0; j < string2.size(); j++)
		{
			if(string3[i + j] != string2[j])
			{
				flag = 0;
				break;
			}
			flag = 1;
		}
		if(flag == 1)
			break;
	}
	if(flag == 0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3232
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        sc.close();

        String s = "";

        while(n > 0) {
            n--;
            s = (char)('a' + n % 26) + s;
            n /= 26;
        }
        System.out.println(s);
    }
}


Measured memory_bytes: 38988
n, m = map(int, input().split())
a = []
for i in range(m):
    a.append(int(input()))

flag = 0
for i in range(m-1):
    if a[i+1] - a[i] == 0:
        flag = 1
        print(0)
        break

if flag == 0:
    b = [1]
    if len(a) != 0 and a[0] == 1:
        b.append(0)
        a.pop(0)
    else:
        b.append(1)
    for i in range(2, n+1):
        if len(a) != 0 and a[0] == i:
            b.append(0)
            a.pop(0)
        else:
            b.append((b[i-1]+b[i-2])%1000000007)

    print(b[-1])

Measured memory_bytes: 7080
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

///////////////////////////




int main() {

	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;

	ll m = min(a, min(b, min(c, min(d, e))));

	cout << 4 + (n + m - 1) / m;

	system("PAUSE");
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
const int N = 300 + 10;
string s[N];
int ans;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	for (int dif = 0; dif < n; dif++) {
		int z = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (s[i][(j + dif) % n] != s[j][(i + dif) % n]) {
					z = 1;
					break;
				}		
			}
		}
		if (!z)
		ans += n;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>

int D, N;
int dp[101][101];
int A[100], E[100], R[100];

int main(){
    while(scanf("%d %d", &D, &N), D || N){
        for(int i=0;i<N;i++){
            scanf("%d %d %d", A+i, E+i, R+i);
        }

        for(int i=0;i<=D;i++){
            for(int j=0;j<=100;j++){
                dp[i][j] = 1001001001;
            }
        }

        dp[D][0] = 0;
        for(int i=D;i>=0;i--){
            for(int j=0;j<=100;j++){
                for(int k=0;k<N;k++){
                    if(j >= R[k]){
                        int ni = std::max(i-A[k],0),
                            nj = std::min(j+E[k],100);
                        dp[ni][nj] = std::min(dp[ni][nj], dp[i][j] + 1);
                    }
                }
            }
        }

        int res = 1001001001;
        for(int i=0;i<=100;i++){
            res = std::min(res, dp[0][i]);
        }

        if(res != 1001001001){printf("%d\n", res);}
        else{puts("NA");}
    }
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
    string s;
    string t;
    cin>>s>>t;
    char a[26],b[26];
    for(int i=0;i<26;i++){
        a[i]='/';
        b[i]='/';
    }
    for(int i=0;i<s.size();i++){
        if(a[t[i]-'a']=='/'){
            a[t[i]-'a']=s[i];
        }
        else{
            if(a[t[i]-'a']!=s[i]){
                // deb(i);
                cout<<"No\n";
                return 0;
            }
        }
    }
    for(int i=0;i<s.size();i++){
        if(b[s[i]-'a']=='/'){
            b[s[i]-'a']=t[i];
        }
        else{
            if(b[s[i]-'a']!=t[i]){
                 // deb(i);
                cout<<"No\n";
                return 0;
            }
        }
    }
    // for(int i=0;i<26;i++){
    //     int f=0;
    //     for(int j=0;j<s.size();j++){
    //         if()
    //     }
    // }
    cout<<"Yes\n";


	return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 100001
#define MOD 1000000007
typedef long long ll;
 
int par[MAX],rank[MAX];
 
void init(int N){
  for(int i = 0 ; i < N ; i++){
    par[i] = i;
    rank[i] = 0;
  }
}
 
int find(int x){
  if(par[x] == x){
    return x;
  }
  return par[x] = find(par[x]);
}
 
void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y){ return; }
  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]){
      rank[x]++;
    }
  }
}
 
bool same(int x,int y){
  return (find(x) == find(y));
}
 
ll mod_pow(ll x,ll n){
  if(n == 0){ return 1; }
  ll res = mod_pow(x*x%MOD,n/2);
  if(n & 1){ res = res*x%MOD; }
  return res;
}
 
int main(){
  int N,M,a,b;
  while(cin >> N >> M,N){
    init(N);
    for(int i = 0 ; i < M ; i++){
      cin >> a >> b; a--; b--;
      unite(a,b);
    }
    ll cnt = 0;
    bool visited[MAX] = {false};
    for(int i = 0 ; i < N ; i++){
      int x = find(i);
      if(!visited[x]){
        visited[x] = true;
        cnt++;
      }
    }
    ll res = mod_pow(2,cnt);
    if(cnt != N){ ++res; }
    cout << res%MOD << endl;
  }
  return 0;
}

Measured memory_bytes: 2040
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<char> s(n);
    rep(i, 0, n) cin >> s[i];
    vector<ll> cusum(n, 0);
    if (s[0] == 'W')
        cusum[0] = 1;
    rep(i, 0, n - 1)
    {
        if (s[i + 1] == 'W')
            cusum[i + 1] = cusum[i] + 1;
        else
            cusum[i + 1] = cusum[i];
    }
    ll ans = INF;
    rep(i, 0, n)
    {
        ll left, right;
        if (i == 0)
            left = 0, right = n - 1 - i - (cusum[n - 1] - cusum[i]);
        else if (i == n - 1)
            left = cusum[i], right = 0;
        else
            left = cusum[i], right = n - 1 - i - (cusum[n - 1] - cusum[i]);
        ans = min(ans, right + left);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
 
string chmax(string a, string b){
  if(a.size() < b.size()) return b;
  else if(a.size() > b.size()) return a;
  else return a > b ? a : b;
}
 
int main(){
  int W, H;
  char C[70][70];
  string dp[70][70];
 
  while(cin >> W >> H, W){
    for(int i = 0; i < H; ++i){
      for(int j = 0; j < W; ++j){
        cin >> C[i][j];
      }
    }
    for(int i = 0; i < H; ++i){
      for(int j = 0; j < W; ++j){
        if(isdigit(C[i][j])) dp[i][j] = string( 1, C[i][j]);
        else dp[i][j] = "0";
      }
    }
    for(int j = 0; j < H; ++j){
      for(int k = 0; k < W; ++k){
        if(dp[j][k] == "0") continue;
        if(k + 1 < W && isdigit(C[j][k + 1])) dp[j][k + 1] = chmax( dp[j][k + 1], dp[j][k] + C[j][k + 1]);
        if(j + 1 < H && isdigit(C[j + 1][k])) dp[j + 1][k] = chmax( dp[j + 1][k], dp[j][k] + C[j + 1][k]);
      }
    }
    string ret = "0";
    for(int i = 0; i < H; ++i){
      for(int j = 0; j < W; ++j) ret = chmax( ret, dp[i][j]);
    }
    cout << ret << endl;
  }
}


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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (998244353)
#define umap unordered_map

int main()
{
    long t = 1;

    while (t--) {
        long n = 5;

        long j;
        for (long i = 0; i < n; i++) {
            long x;
            cin >> x;
            if (x == 0) j = i;
        }
        printf("%lld\n", j+1);
    }
}


Measured memory_bytes: 3704
#include <iostream>
#include <math.h>
#include <stdio.h>

int main(){

	double x1,y1,x2,y2,x3,y3;
	double a,b,c,x,y;
	double n,px,py,r;
	
	std::cin >> n;
	
	while(n--){
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		
		a = sqrt(pow(x2-x1,2) + pow(y2-y1,2));
		b = sqrt(pow(x3-x2,2) + pow(y3-y2,2));
		c = sqrt(pow(x3-x1,2) + pow(y3-y1,2));
		
		x = ((a*a)-((b*b)+(c*c)))/(-2*b*c);
		y = sqrt(1-x*x);
		r = a/(2*y);
		px = ((y1-y3)*(y1*y1 -y2*y2 +x1*x1 -x2*x2) -(y1-y2)*(y1*y1 -y3*y3 +x1*x1 -x3*x3)) / (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));
		py = ((x1-x3)*(x1*x1 -x2*x2 +y1*y1 -y2*y2) -(x1-x2)*(x1*x1 -x3*x3 +y1*y1 -y3*y3)) / (2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3));
		
		printf("%.3f %.3f %.3f\n", px, py, r);
	}
}

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

class name
{
    static void Main()
    {

        long[] day = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long[] money = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long d = day[0];
        long g = 1000;
        long st = 0;
       for(int s = 0; s < d-1; s++)
        {

            if (money[s] < money[s + 1])
            {
                st = g / money[s];
                g += (money[s + 1] - money[s]) * st;

            }


        }
        Console.WriteLine(g);
    }



}


Measured memory_bytes: 28192
# -*- coding: utf-8 -*-
N, M = map(int, input().split())

X = [-1 for i in range(N)]
flg = 0

for i in range(M):
  s,c = map(int, input().split())
  s -= 1
  if N!=1 and s==0 and c==0:
    print(-1)
    flg = 1
    break
  if X[s]==-1:
    X[s] = c
  elif X[s]!=c:
    print(-1)
    flg = 1
    break

if flg==0:
  if N==1:
    print(0, end='') if X[0]==-1 else print(X[0], end='')
  else:
    for i in range(N):
      print(max(0,1-i), end='') if X[i]==-1 else print(X[i], end='')

Measured memory_bytes: 3064