akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const ll INF=1<<30;

vector<vector<ll>> next_path(201,vector<ll>(201,0));
ll d[201][201];// d[u][v]は辺e=(u,v)のコスト(存在しない場合はINF、ただしd[i][i]=0とする) 
ll V;// 頂点数
void warshall_floyd() {
	for (ll k = 1; k <=V; k++){
		for (ll i = 1; i <= V; i++){
			for (ll j = 1;j <= V; j++){ 
			if (d[i][j] > d[i][k] + d[k][j]){
				d[i][j] = d[i][k] + d[k][j];
			}
			}
		}
	}
}

void printPath3(ll start, ll goal) {
	cout << start << " " << goal << endl;
    for (ll cur = start; cur != goal; cur = next_path[cur][goal]){
       d[cur][next_path[cur][goal]] = LINF;
	   cout << cur << " " << next_path[cur][goal] << endl;
	}
	cout << goal << endl;
	cout << endl;
}

int main(){
	ll m;cin>>V>>m;
	for(int i = 0; i <= 200; i++) {
		for(int j = 0; j <= 200; j++) {
			if(i != j){
				d[i][j] = INF;
			}
		}
	}
	vector<int> a(m);
	vector<int> b(m);
	vector<int> c(m);
	for(ll i = 0; i < m; i++) {
		ll x,y,z;cin>>x>>y>>z;
		a[i] = x;
		b[i] = y;
		c[i] = z;
		d[x][y] = z;
		d[y][x] = z;
	}
	for(ll i = 1; i <= V; i++) {
		for(ll j = 1; j <= V; j++) {
			next_path[i][j] = j;
		}
	}
	warshall_floyd();
	int ans = 0;
	for(int i = 0; i < m; i++) {
		bool flag = false;
		for(int j = 1; j <= V; j++) {
			for(int k = 1; k <= V; k++) {
				if(j != k){
					if (d[j][a[i]] + c[i] + d[b[i]][k] == d[j][k]){
						flag = true;
					}
				}
			}
		}
		if(!flag)ans++;
	}
	cout << ans << endl;

	return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 330;
const ll inf = 1e18;

int n, k;
ll dp[maxn][maxn][maxn];
ll a[maxn];


ll go(int i, int remove, int p) {
    if (i>n) return 0;
    if (~dp[i][remove][p]) return dp[i][remove][p];
    ll &res = dp[i][remove][p] = inf;

    if (remove>0) {
	res = min(res, go(i+1, remove-1, p));
    }
    res = min(res, max(0ll,a[i+1]-a[p])+go(i+1,remove,i+1));
    return res;
}

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

    cin>>n>>k;
    for (int i=1; i<=n; i++) {
	cin>>a[i];
    }
    
    memset(dp,-1,sizeof(dp));
    cout<<go(0,k,0)<<endl;    
    return 0;
}


Measured memory_bytes: 284440
<?php
fscanf(STDIN, "%d", $n);
$in=array();
While ($line = fgets(STDIN) ) {
  $stdin = str_split(trim($line));
  sort($stdin);
  $str=implode($stdin);
  if(isset($in[$str])){
    $in[$str]++;
  }else{
    $in[$str]=1;
  }
}

$ans=0;
foreach($in as $v){
  $ans+=$v*($v-1)/2;
}
echo $ans;


Measured memory_bytes: 21492
#include <iostream>
#include<string>
#include <vector>
const std::string cmd[3]{ "print","reverse","replace" };
int main() {
	std::string s;
	std::cin >> s;
	int a;
	std::cin >> a;
	while(a--){
		std::string t; 
		std::cin >> t;
		if (t == cmd[0]) {
			int a, b; 
			std::cin >> a >> b;
			std::cout << s.substr(a, b - a + 1) << std::endl;
		}
		if (t == cmd[1]) {
			int a, b; 
			std::cin >> a >> b;
			//なぜかCompile Error
			//reverse(s.begin() + a, s.begin() + b + 1);
			for (int i = a; i < b; ++i) {
				std::swap(s[b], s[i]);
				b--;
			}
		}
		if (t == cmd[2]) {
			int a, b; 
			std::string p; 
			std::cin >> a >> b >> p;
			s.replace(a, b - a + 1, p);
		}
	}
}


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

int main()
{
  int  n,W;
    cin>>n>>W;
    long long  dp[n+1][W+1]={0};
    long long w[n],v[n];
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=W;j++)
        {

           if (i==0 || j==0)
               dp[i][j] = 0;
            else if(w[i-1]<=j)
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
            }
            else

                 dp[i][j] = dp[i-1][j];
        }
    }
    cout<<dp[n][W];


    return 0;
}


Measured memory_bytes: 79104
#include <iostream>
using namespace std;
int main()
{
  int r, D, x[11];
  cin >> r >> D >> x[0];
  
  for (int i = 1; i <= 10; i++) {
    x[i] = r * x[i-1] - D;
    cout << x[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ans = []
p = 1
q = 2 * ((m + 1) // 2)
for i in range((m + 1) // 2):
    ans.append((p, q))
    p += 1
    q -= 1
p = 2 * ((m + 1) // 2) + 1
q = p + (m // 2) * 2
for i in range(m // 2):
    ans.append((p, q))
    p += 1
    q -= 1
for row in ans[:m]:
    print(row[0], row[1])


Measured memory_bytes: 21880
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N, A[2020];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    
    int sm = 0;
    rep(i, 0, N) sm += A[i];

    bitset<4000001> dp;
    dp.set(0);
    rep(i, 0, N) {
        bitset<4000001> pd;
        pd |= dp;
        pd |= dp << A[i];
        swap(dp, pd);
    }

    rep(i, (sm + 1) / 2, 4000001) if (dp[i]) {
        printf("%d\n", i);
        return;
    }
}

Measured memory_bytes: 2176
#include<iostream>

using namespace std;

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

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

class prog{
  static void Main(){
    
    string a = Console.ReadLine();
    string b = Console.ReadLine();
    string ans = "EQUAL";
    
    if(a.Length > b.Length) ans = "GREATER";
    else if(a.Length < b.Length) ans = "LESS";
    else{
      if(a.CompareTo(b) < 0) ans = "LESS";
      else if(a.CompareTo(b) > 0) ans = "GREATER";
    }
    
    Console.WriteLine(ans);
    
  }
}

Measured memory_bytes: 13280
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
#define fi first
#define se second
ll p=pow(10,9)+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
    x = x % p;  
   while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,j,i,k,x,y,z,m;
    string s;
    
    cin>>n>>m;
    ll arr[n],sum=0;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    float t=sum;
    float f=t/4;
    f/=m;
    
    ll ctr=0;
    for(i=0;i<n;i++)
    {
        if(arr[i]>=f)
        ctr++;
    }
    if(ctr>=m)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
    
}
    


Measured memory_bytes: 256
/**
 * Sergey Kopeliovich (burunduk30@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;

int main() {
	int a0, a1, a2, a3, n;
	cin >> a0 >> a1 >> a2 >> a3 >> n;
	a1 = min(a1, 2 * a0);
	a2 = min(a2, 2 * a1);
	a3 = min(a3, 2 * a2);
	// printf("%d %d %d %d\n", a0, a1, a2, a3);
	printf("%lld\n", (ll)(n >> 1) * a3 + (n & 1) * a2);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    long long N,a,b,i,f=0,t;
    scanf("%lld",&N);
    for(a=1;a<N;a++)
    {
        /*
        if(N>a*a) f++;
        for(b=a+1;b<N;b++){
            if (N>a*b) f=f+2;
            else if (b==2){
                f=f+N-a;
                printf("%lld",f);
                return 0;
            }
        }
        */
        f+=N/a;
        if(N%a==0)f--;

    }
    printf("%lld",f);

    return 0;
}

Measured memory_bytes: 1732
//code by lynmisakura.wish to be accepted!
/*************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef long long ijt;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
void getZarr(string str, int Z[]);

bool search(string text, string pattern)
{

	string concat = pattern + "$" + text;
	int l = concat.length();
	int c = 0;
	int Z[l];
	getZarr(concat, Z);
	
	for (int i = 0; i < l; ++i)
	{
		if (Z[i] == pattern.length()) {
			return true;
		}
	}
	return false;
}

void getZarr(string str, int Z[])
{
	int n = str.length();
	int L, R, k;

	L = R = 0;
	for (int i = 1; i < n; ++i)
	{
		if (i > R)
		{
			L = R = i;
			while (R < n && str[R - L] == str[R])
				R++;
			Z[i] = R - L;
			R--;
		}
		else
		{
			k = i - L;

			if (Z[k] < R - i + 1)
				Z[i] = Z[k];
			else
			{
				L = i;
				while (R < n && str[R - L] == str[R])
					R++;
				Z[i] = R - L;
				R--;
			}
		}
	}
}
int main(void) {
	int n; cin >> n; string s; cin >> s;
	int l = 0, r = n;

	while (r - l > 1) {
		int m = (l + r) / 2;

		bool check = false;
		for (int i = 0; i < n - m; i++) {
			//i文字目からm文字
			string p = s.substr(i, m);//cout << p << endl;
			string r;
			for (int j = i; j < i+m; j++)
			{
				r += (char)s[j];
			}
			string q;
			for (int j = i + m; j < n; j++) {
				q += (char)s[j];
			}
			//cout << p << " " << q << endl;
			if (search(q, r)) {
				check = true; break;
			}
		}
		if (check) {
			l = m;
		}
		else {
			r = m;
		}
	}
	cout << l << endl;
}
//kotti tadasii

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string binex(long long a){
    string s = "";
    while(a>0){
        if(a%2==0) s='0'+s;
        else s='1'+s;
        a/=2;
    }
    return s;
}
long long bin(int a){
    long long meu = 1;
    for(int i = 0;i<a;i++)meu*=2;
    return meu;
}
long long func(pair<long long,long long> pr[],int n,long long k){
    long long ans = 0;
    for(int i = 0;i<n;i++) if((k|pr[i].first) == k) ans+=pr[i].second;
    return ans;
}
int main(){
    int n;
    long long k;
    cin >> n >> k;
    pair<long long,long long> pr[n];
    for(int i = 0;i<n;i++) cin >> pr[i].first >> pr[i].second;
    long long ans = 0;
    string sk = binex(k);
    int sksize = sk.size();
    long long now = 0;
    for(int i = 0;i<sksize;i++){
        if(sk[i]=='1'){
            ans = max(ans,func(pr,n,now+bin(sksize-1-i)-1));
            now+= bin(sksize-1-i);
        }
    } 
    ans = max(ans,func(pr,n,k));
    cout << ans << endl;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
void debug(vector<ll>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
vector<vector<ll>>vec(ll x, ll y, ll w){
  vector<vector<ll>>v(x,vector<ll>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->se++;

struct UnionFind {
  vector<ll> data;
  vector<ll> difweight;
  UnionFind(ll size){
    data.assign(size,-1);
    difweight.assign(size,0);
  }
  bool unite(ll x, ll y, ll w) { //xがyの親に
    w += weight(x); w -= weight(y);
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y), w = -w;
      data[x] += data[y]; 
      data[y] = x;
      difweight[y] = w;
    }
    return x != y;
  }
  bool find(ll x, ll y) {
    return root(x) == root(y);
  }
  ll diff(ll x,ll y){
    return weight(y)-weight(x);
  }
  ll weight(ll x){
    root(x);
    return difweight[x];
  }
  ll root(ll x) {
    if(data[x] < 0){
      return x;
    }
    else{
      ll tmp = root(data[x]);
      difweight[x] += difweight[data[x]];
      return data[x] = tmp;
    }
  }
  ll size(ll x) {
    return -data[root(x)];
  }
  ll debug(){
    rep(i,0,data.size()){
      root(i);
      cout<<i spa data[i] spa difweight[i] spa weight(i)<<endl;
    }
    cout<<endl;
  }
};

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll>l(m),r(m),d(m);
  UnionFind uf(n);
  rep(i,0,m)cin>>l[i]>>r[i]>>d[i];
  rep(i,0,m){
    l[i]--,r[i]--;
    if(uf.find(l[i],r[i])){
      if(uf.diff(l[i],r[i])!=d[i]){
        judge=false;
        break;
      }
    }
    else{
      uf.unite(l[i],r[i],d[i]);
    }
    //cout<<uf.diff(l[i],r[i])<<endl;
    //uf.debug();
  }
  ans1(judge);
  return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
typedef __int128_t it;
int main(int argc, char const *argv[]) {
  it n, x;
  ll o, p;std::cin >> o >> p;
  n = o, x = p;
  vector<it> a(n);
  for(int i=0;i<n;i++) scanf("%lld", &o), a[i] = o;
  it ans = 1000000000000000000;
  ans = ans * ans;
  vector<it> L(n, 0);
  L[0] = a[n-1];
  for(int i=1;i<n;i++) L[i] = L[i-1] + a[n-1-i];

  for(it k=1;k<=n;k++){
    it cost = (n+k)*x, tmp = 0;
    it tm = (n/k)+(n%k?1:0);
    for(it j=1;j<=tm;j++){//j番目に取る
      it y = (j==1?5:(2*j + 1));
      ll st = (j-1) * k;
      st = (st==0?0:L[st-1]);
      ll ed = L[min(n, j*k)-1];
      tmp += y * (ed - st);
    }
    //std::cout << k << " " << cost << " " << tmp << '\n';
    ans = min(ans, cost + tmp);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 9188
S = input()
l = len(S)
flag=0
for k in range(0,l):
    if k %2 == 1:
        continue
    if not S[k] in 'RDU':
        flag=1
        break

flag2=0
for k in range(0,l):
    if k%2 == 0:
        continue
    if not S[k] in 'LUD':
        flag2=2
        break

if flag==1 or flag2==2:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <fstream>

using std::cin;
using std::cout;
using std::endl;
using std::terminate;

long series(long n, long a, long d) {
    return n * (2 * a + (n - 1) * d) / 2;
}

void solve() {
    long n; cin >> n;

    long n3 = n / 3;
    long n5 = n / 5;
    long n15 = n / 15;

    long y = series(n, 1, 1) - series(n3, 3, 3) - series(n5, 5, 5) + series(n15, 15, 15);

    cout << y << endl;
}

int main() {

#ifdef DEV
    std::ifstream in("AtCoder/ABC162/FizzBuzz Sum.input");
    cin.rdbuf(in.rdbuf());

    int t; cin >> t;
    for (int x = 1; x <= t; ++x) {
        solve();
    }
#else
    solve();
#endif

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main() {
  int w, h;
  char c;
  cin >> w >> h >> c;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if ((i == 0 || i == h - 1) && (j == 0 || j == w - 1)) {
        cout << '+';
      } else if ((i == 0 || i == h - 1) && !(j == 0 || j == w - 1)) {
        cout << '-';
      } else if (!(i == 0 || i == h - 1) && (j == 0 || j == w - 1)) {
        cout << '|';
      } else if (i == (h - 1) / 2 && j == (w - 1) / 2) {
        cout << c;
      } else {
        cout << '.';
      }
      if (j == w - 1) {
        cout << endl;
      }
    }
  }
}



Measured memory_bytes: 3076
level, num_eat = map(int,input().split())

def get_layers(level):
    return 2**(level+2) - 3

def get_patty(level):
    return 2**(level+1) - 1

def f(level, x):
    if level == 0:
        return 1
    elif x == 1:
        return 0
    elif 1 < x <= 1 + get_layers(level-1):
        return f(level-1, x-1)
    elif x == 2 + get_layers(level-1):
        return get_patty(level - 1) + 1
    elif 2 + get_layers(level-1) < x <= 2 + 2 * get_layers(level-1):
        return get_patty(level-1) + 1 + f(level-1,x-2-get_layers(level-1))
    elif x == 3 + 2*get_layers(level-1):
        return 2*get_patty(level - 1) + 1

print(f(level, num_eat))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
            using namespace std;
             
            int main() {
              int N, A, B , sum, K, i;              
              cin >> N >> K;
              sum = 1;
              for (i = 0; i < N; i++){   
                A = sum * 2;
                B = sum + K;
                if(A < B) {
                  sum = A;
                } else {
                  sum = B;
                }
              }
               cout << sum << endl;
            }

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

namespace AtTest.Hitachi2020
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] abm = ReadInts();
            int a = abm[0];
            int b = abm[1];
            int m = abm[2];
            int[] aArray = ReadInts();
            int[] bArray = ReadInts();
            int[][] xycs = new int[m][];
            for(int i = 0; i < m; i++)
            {
                xycs[i] = ReadInts();
            }

            int res = int.MaxValue;
            for(int i = 0; i < m; i++)
            {
                int x = xycs[i][0] - 1;
                int y = xycs[i][1] - 1;
                int c = xycs[i][2];

                res = Min(res, aArray[x] + bArray[y] - c);
            }

            Array.Sort(aArray);
            Array.Sort(bArray);
            res = Min(res, aArray[0] + bArray[0]);
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 35292
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  int n;
  while(cin>>n){
    int tmp=0, x;
    vector <int> v;
    for(int i=1; i<=n; ++i){
      scanf("%d",&x);
      if(x==i){
        ++tmp;
      }
      else{
        v.push_back(tmp);
        tmp=0;
      }
    }
    v.push_back(tmp);
    int ans=0;
    for(int i=0; i<v.size(); ++i){
      ans+=(v[i]+1)/2;
    }
    cout<<ans<<endl;
  }
  return 0;
}




Measured memory_bytes: 892
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

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

        int min = 9999;
        for(int i=0; i<n; i++) {
            int cc = sc.nextInt();
            int tt = sc.nextInt();
            if(tt <= t) {
                min = Math.min(min, cc);
            }
        }

        if(min == 9999) {
            System.out.println("TLE");

        } else {
            System.out.println(min);
        }
    }

}


Measured memory_bytes: 23764
#include<iostream>
#include<stdio.h>
#include<vector>
#include<math.h>
#include<algorithm>
#include<string>
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> >
#define vb vector<bool> 
#define vvb vector<vector<bool> >
#define INF 1145141919810
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b:i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
using namespace std;

int main(){
	ll a,b,c; cin>>a>>b>>c;
	if(b-a == c-b) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
   int N;
   std::string S;
   std::cin >> N >> S;

   int ans = 1;
   for(int i=0; i<N-1; ++i){
      if(S[i]!=S[i+1]) ++ans;
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 512
import numpy as np
N, M, C = [int(x) for x in input().split()]
B = np.array([int(x) for x in input().split()])
A = np.array([[int(x) for x in input().split()] for _ in range(N)])
print(np.sum(np.sum(A*B, axis=1) > -C))


Measured memory_bytes: 12484
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod2 (long long)1000000007
#define mod (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX




void solve()
{
    int a,b;
    cin  >> a >> b;
    if((a-b)%2)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << (a+b)/2 << endl;
}



signed main()
{
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 256
O = list(input())
E = list(input())
L = len(O)+len(E)
a = list()
for i in range(L):
    if i < len(E):
        a.append(O[i])
        a.append(E[i])
        i += 1
if len(O) != len(E):
    a.append(O[-1])
b = "".join(a)
print(b)
    


Measured memory_bytes: 3060
import sys

def comb(n):
    count = 0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                for l in range(10):
                    if i+j+k+l == n:
                        count += 1
                        continue
    return count


while True:
    line = sys.stdin.readline()
    if not line: break
    n = int(line.rstrip('\r\n'))
    print(comb(n))


Measured memory_bytes: 5600
#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,j,k,count;
    scanf("%d",&n);
    char s[n];
    scanf("%s",&s);
    if(n%2!=0)
        printf("No");
    else
        {
            count=0;

        for(i=0,j=n/2;i<n/2,j<n;i++,j++)
        {
            if (s[i]==s[j])
                count++;
        }
        if (count==n/2)
        printf("Yes");
    else printf("No");


        }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int BUF = 500005;


class SegTree{
public:
  int v[BUF*4];

  SegTree(){ 
    memset(v,0,sizeof(v));
  }
  
  int init(int node, int L, int R, int a[BUF]){
    if(L==R) return v[node] = a[L];
    int s = init(node*2+1,L,(L+R)/2,a);
    int t = init(node*2+2,(L+R)/2+1,R,a);
    return v[node] = s + t;
  }

  int get(int node, int L, int R, int LQ, int RQ){
    if(R<LQ || RQ<L) return 0;
    if(LQ<=L && R<=RQ) return v[node];
    int s = get(node*2+1,L,(L+R)/2,LQ,RQ);
    int t = get(node*2+2,(L+R)/2+1,R,LQ,RQ);
    return s + t;
  }
  
  int update(int node, int L, int R, int Q, int chVal){
    if(R<Q || Q<L) return v[node];
    if(L==R) return v[node] = chVal;
    int s = update(node*2+1,L,(L+R)/2,Q,chVal);
    int t = update(node*2+2,(L+R)/2+1,R,Q,chVal);
    return v[node] = s + t;
  }
};


class Query {
public:
    int id;
    int l, r;
    Query(){}
    Query(int id, int l, int r): id(id), l(l), r(r) {}

    bool operator< (const Query &opp) const {
        return r < opp.r;
    }
};


int nVal, nQuery;
int val[BUF];
Query query[BUF];


void read() {
    cin >> nVal >> nQuery;
    for (int i = 0; i < nVal; ++i) {
        cin >> val[i];
        --val[i];
    }
    for (int i = 0; i < nQuery; ++i) {
        query[i].id = i;
        cin >> query[i].l >> query[i].r;
        --query[i].l;
        --query[i].r;
    }
}


void work() {
    sort(query, query + nQuery);

    static SegTree stree;
    memset(stree.v, 0, sizeof(stree.v));

    int queryId2ans[BUF];
    
    int v2lastIdx[BUF];
    memset(v2lastIdx, -1, sizeof(v2lastIdx));

    int queryIdx = 0;
    for (int valIdx = 0; valIdx < nVal; ++valIdx) {
        int &v = val[valIdx];

        if (v2lastIdx[v] != -1) {
            stree.update(0, 0, nVal - 1, v2lastIdx[v], 0);
        }
        stree.update(0, 0, nVal - 1, valIdx, 1);
        v2lastIdx[v] = valIdx;

        while (queryIdx < nQuery && query[queryIdx].r == valIdx) {
            int ans = stree.get(0, 0, nVal - 1, query[queryIdx].l, query[queryIdx].r);
            queryId2ans[query[queryIdx].id] = ans;
            ++queryIdx;
        }
    }

    for (int i = 0; i < nQuery; ++i) {
        cout << queryId2ans[i] << endl;
    }
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 23224
#include <stdio.h>

int main(void){
  int n, i, j, flag = 0;
  int count = 0;
  scanf("%d", &n);
  char s[n][11];
  for(i = 0; i < n; i++){
    scanf("%s", s[i]);
  }
  for(i = 0; i < n - 1; i++){
    if(s[i][strlen(s[i]) - 1] != s[i + 1][0]) flag = 1;
  }
  for(i = 0; i < n; i++){
    count = 0;
    for(j = 0; j < n; j++){
      if(strcmp(s[i], s[j]) == 0) count++;
    }
    if(count > 1) flag = 1;
  }
  if(flag) printf("No\n");
  else printf("Yes\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b;
  c = (a + b) % 2;
  if(c == 0) {
    d = (a + b) / 2;
  }
  else {
	d = (a + b) / 2 + 1;
  }
  cout << d << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

bool check(const string& s)
{
    if(s.find("AGC") != string::npos)
        return false;

    int n = s.size();
    for(int i=0; i<n-1; ++i){
        string t = s;
        swap(t[i], t[i+1]);
        if(t.find("AGC") != string::npos)
            return false;
    }

    return true;
}

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

    map<string, long long> dp;
    dp["..."] = 1;
    for(int i=0; i<n; ++i){
        map<string, long long> nextDp;
        for(const auto& p : dp){
            string s = p.first;
            for(int j=0; j<4; ++j){
                string t = s + "ACGT"[j];
                if(check(t)){
                    t = t.substr(1);
                    nextDp[t] += p.second;
                    nextDp[t] %= MOD;
                }
            }
        }
        dp = move(nextDp);
    }

    long long ans = 0;
    for(const auto& p : dp){
        ans += p.second;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
    int N;
    string s;
    string output;
    cin >> N;
    cin >> s;
    for(int i=0;i<N;i++){
        if(output.length()==0){
            output+=s[i];
        }else if(s[i] !=output[output.length()-1]){
            output +=s[i];
            
        }
        
    }
    
    cout << output.length() << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

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

	int vect[250][2];
	REP(i,250) REP(j,2) vect[i][j] = 0; //??§?¨????????´????????????????0??§?????????
	int grid[500][500];
	REP(i,500) REP(j,500) grid[i][j] = 0; //??§?¨??????¢???0??§?????????
	vect[0][0] = 250; //?????????x??§?¨?
	vect[0][1] = 250; //?????????y??§?¨?
	grid[250][250] = 1; //???????????????????????????????????????
	int nx,ny;
	int a,b;

	FOR(i,1,n){
	  cin >> a >> b;
	  if(b==0){
		nx = -1;
		ny = 0;
	  }else if(b == 1){
		nx = 0;
		ny = 1;
	  }else if(b == 2){
		nx = 1;
		ny = 0;
	  }else if(b == 3){
		nx = 0;
		ny = -1;
	  }
	  vect[i][0] = vect[a][0] + nx; //??????x??§?¨????a???????????§?¨????????????????????????????????????§??????????????????
	  vect[i][1] = vect[a][1] + ny; //y??§?¨?
	  grid[vect[i][0]][vect[i][1]] = 1; //????????§?¨????1?????????
	}

	int xmax = 0;
	int xmin = 1000;
	int ymax = 0;
	int ymin = 1000;
	int c = 0;
	//0????????§????????????????????????????????§?????????????????§??§?????????????????£?????????????????¬??????

	REP(i,500){
	  c = 0;
	  REP(j,500){
		//		cout << grid[i][j]; //?????????????????????
		c += grid[i][j];
	  }
	  if(c > 0 && i < xmin) xmin = i;
	  if(c > 0 && i > xmax) xmax = i;
	}

	REP(i,500){
	  c = 0;
	  REP(j,500){
		c += grid[j][i];
	  }
	  if(c > 0 && i < ymin) ymin = i;
	  if(c > 0 && i > ymax) ymax = i;
	}

	//	cout << xmax << " " << xmin << endl;
	//	cout << ymax << " " << ymin << endl;

	int x = 0;
	int y = 0;

	x = (xmax - xmin) + 1;
	y = (ymax - ymin) + 1;

	cout << x << ' ' << y << endl;
  }

}

Measured memory_bytes: 2136
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long ans = 1;
		long c = 1;
		long mod =1000000007;
		for(var i=str.Length-1;i>=0;i--){
			if(str.Substring(i,1)=="1"){
				ans = ans * 2 % mod;
				ans = (ans + c)% mod;
			}
			c = c * 3 % mod;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

void check(set<int> &vec)
{
	ll sum=0;
	int g=(*vec.begin());
	for(int v:vec)
	{
		assert(v>=1&&v<=300000);
		sum+=v; g=__gcd(v,g);
	}
	assert(g==1);
	for(int v:vec)
	{
		assert(__gcd(sum, ll(v))>1);
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	set<int> vec;
	if(n==3)
	{
		vec = {2,5,63};
	}
	else if(n==4)
	{
		vec = {2,5,20,63};
	}
	else if(n==5)
	{
		vec = {2,5,20,30,63};
	}
	else
	{
		ll cur = 0;
		ll sum = 0;
		for(int i = 0; i < n; i++)
		{
			if(cur%6==0) cur+=2;
			else if(cur%6==2) cur++;
			else if(cur%6==3) cur++;
			else cur+=2;
			vec.insert(cur); sum+=cur;
		}
		cur++;
		assert(sum%6==2||sum%6==0||sum%6==3||sum%6==5);
		if(sum%6==2)
		{
			assert(vec.find(8)!=vec.end());
			vec.erase(8);
			while(cur%6!=0) cur++;
			vec.insert(cur);
		}
		else if(sum%6==3)
		{
			assert(vec.find(9)!=vec.end());
			vec.erase(9);
			while(cur%6!=0) cur++;
			vec.insert(cur);
		}
		else if(sum%6==5)
		{
			assert(vec.find(9)!=vec.end());
			vec.erase(9);
			while(cur%6!=4) cur++;
			vec.insert(cur);
		}
	}
	check(vec); assert(int(vec.size())==n);
	for(auto it = vec.begin(); it != vec.end(); it++)
	{
		cout<<(*it);
		cout<<' ';
	}
	cout<<'\n';
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cstdio>
#define MOD 1000000007
int arr[105], dp[55][105][105];
int main()
{
	// freopen("AGC012-F.in", "r", stdin);
	int n;
	scanf("%d", &n);
	int m = 2 * n - 1;
	for (int i = 0; i < m; i++)
		scanf("%d", arr + i);
	std::sort(arr, arr + m);
	dp[n - 1][0][0] = 1;
	for (int i = n - 1; i; i--)
	{
		bool l = arr[i] != arr[i - 1];
		bool r = arr[m - i - 1] != arr[m - i];
		for (int j = 0; j <= m; j++)
		{
			for (int k = 0; k <= m; k++)
			{
				(dp[i - 1][j + l][k + r] += dp[i][j][k]) %= MOD;
				for (int x = 0; x < j + l; x++)
					(dp[i - 1][x][k + r + 1] += dp[i][j][k]) %= MOD;
				for (int x = 0; x < k + r; x++)
					(dp[i - 1][j + l + 1][x] += dp[i][j][k]) %= MOD;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= m; i++)
	{
		for (int j = 0; j <= m; j++)
			(ans += dp[0][i][j]) %= MOD;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    int n;

    scanf("%d", &n);

    if (n % 2 == 0) {
        printf("%d\n", n);
    } else {
        printf("%d\n", n * 2);
    }
    return 0;
}

Measured memory_bytes: 128
import sys,collections

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  l=LI()
  l=list(set(l))

  if len(l)==2:
    return 'Yes'
  return 'No'

# main()
print(main())


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	map<string,ll>m;
	string s;
	cin>>n;
	while (n--)
	{
		cin>>s;
		m[s]++;
	}
	cout<<m.size()<<"\n";
}

Measured memory_bytes: 19132
n = int(input())

all_count = 0
options = [str(i) for i in range(10)]

maeato = [[0 for i in range(10)] for j in range(10)]

for i in range(n+1):
    checking = str(i)
    maeato[int(checking[0])][int(checking[-1])]+=1
all_count = 0
for i in range(1,10):
    for j in range(1,10):
        for k in range(1,10):
            for p in range(1,10):
                if i == p and j == k:
                    all_count+=maeato[i][j]*maeato[k][p]
print(all_count)

Measured memory_bytes: 68180
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int M = 1e6+100;
    vector<bool> P(M,true);
    P[0] = false;
    P[1] = false;
    for(int i = 2; i*i < M; ++i){
        if(!P[i]) continue;
        for(int j = i; j*i < M; ++j){
            P[i*j] = false;
        }
    }
    int a, d, n;
    while(cin >> a >> d >> n, a||d||n){
        while(n > 0){
            while(!P[a]) a += d;
            --n;
            if(!n) cout << a << endl;
            else a += d;
        }
        //cout << a << endl;
    }
}



Measured memory_bytes: 3204
#include <stdio.h>


int main(void) {

	// 1_7-D Matrix Multiplication

	int i,j,k;
	int n,m,l;
	long wk;
	long ma[100][100];
	long mb[100][100];
	long mc[100][100];

	scanf("%d",&n);
	scanf("%d",&m);
	scanf("%d",&l);

	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			scanf("%ld",&ma[i][j]);
		}
	}
	for(i=0; i<m; i++){
		for(j=0; j<l; j++){
			scanf("%ld",&mb[i][j]);
		}
	}

	for(i=0; i<n; i++){
		for(j=0; j<l; j++){
			wk = 0;
			for(k=0; k<m; k++){
				wk += (ma[i][k] * mb[k][j]);
			}
			mc[i][j] = wk;
		}
	}

	for(i=0; i<n; i++){
		for(j=0; j<l; j++){
			printf("%ld",mc[i][j]);
			if(j<(l-1)){
				putchar(' ');
			}else{
				putchar('\n');
			}
		}
	}
        return 0;
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  char X, Y;
  cin >> X >> Y;

  if((ll)(X - 'A') < (ll)(Y - 'A')){
    cout << '<' << endl;
  } else if((ll)(X - 'A') > (ll)(Y - 'A')){
    cout << '>' << endl;
  } else{
    cout << '=' << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, c, k;
	int max;
	int sum = 0;

	scanf("%d %d %d", &a, &b, &c);

	scanf("%d", &k);
	

	if (a < b) {
		if (b < c) {
			max = c;
			sum = a + b;
		}
		else {
			max = b;
			sum = a + c;
		}
	}
	else if (a < c) {
		max = c;
		sum = a + b;
	}
	else {
		max = a;
		sum = b + c;
	}

	for (int i = 0; i < k; i++) {
		max = max * 2;
	}
	sum = sum + max;

	printf("%d\n", sum);

//	system("PAUSE");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/




int main(void) {
  ll i, j, k;
  string L;
  ll K;
  cin >> L >> K;
  ll N=L.size();
  
  ll dp[111][5][2]={};
  
  dp[0][0][1]=1;
  for(i=0; i<N; i++) {
    for(j=0; j<=K; j++) {
      
      for(k=0; k<10; k++) {
        dp[i+1][j+(k!=0)][0]+=dp[i][j][0];
      }
      
      ll MX=L[i]-'0';
      for(k=0; k<MX; k++) {
        dp[i+1][j+(k!=0)][0]+=dp[i][j][1];
      }
      
      dp[i+1][j+(MX!=0)][1]+=dp[i][j][1];
    }
  }
  
  pt(dp[N][K][0]+dp[N][K][1]);
  
}



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




using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;

#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

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

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


class UnionFind{
    public:
    vector<int> par;
    vector<int> val;
    int root(int input){
        if(par[input]==input) return input;
        return par[input] = root(par[input]);
    }
    void unite(int val1, int val2){
        par[val1] = root(par[val2]);
    }
    bool same(int val1, int val2){
        return root(par[val1]) == root(par[val2]);
    }
    UnionFind(){
        return;
    }
};

const ll N_MAX = 10*100000+100;
ll N,M;
ll A[N_MAX];
vector<ll> Alist;

int main() {
    
    cin >> N;
    ll res = 0;
    rep(i,N){
        ll a;
        cin >> a;
        if(i+a < N_MAX){
            A[i+a] ++;
        }
        if(i-a >= 0){
            res += A[i-a];
        }
    }



    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6720
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;

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

  int n;
  cin >> n;
  int a;
  vector<int> cnt(9);
  for(int i = 0; i < n; i++){
    cin >> a;
    if(a < 400){
      cnt[0]++;
    }else if(a < 800){
      cnt[1]++;
    }else if(a < 1200){
      cnt[2]++;
    }else if(a < 1600){
      cnt[3]++;
    }else if(a < 2000){
      cnt[4]++;
    }else if(a < 2400){
      cnt[5]++;
    }else if(a < 2800){
      cnt[6]++;
    }else if(a < 3200){
      cnt[7]++;
    }else{
      cnt[8]++;
    }
  }
  int ans = 0;
  for(int i = 0; i < 8; i++){
    if(cnt[i] > 0) ans++;
  }
  if(ans > 0){
    cout << ans << " ";
  }else{
    cout << 1 << " ";
  }
  cout << ans + cnt[8] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

ll binpow(ll a,ll p){
    ll res = 1;
    while (p>0){
        if (p & 1)res = (res*a)%hell;
        a = (a*a)%hell;
        p = p>>1;
    }
    return res;
}

void solve(){
	//write here
    ll fact[5001];
    ll invfact[5001];
    fact[0] = 1;
    for (ll i = 1 ; i<5001 ; i++){
        fact[i] = fact[i-1]*i;
        fact[i]%=hell;
    }
    invfact[5000] = binpow(fact[5000],hell-2);
    for (ll i = 4999 ; i>=0 ; i--){
        invfact[i] = (i+1)*invfact[i+1];
        invfact[i]%=hell;
    }
    ll S;
    cin>>S;
    ll count = 0;
    for (int i = 1 ; i<S/3 + 1 ; i++){
        ll n = S - 3*i;
        count = (count + (fact[n+i-1]%hell * invfact[i-1]%hell * invfact[n]%hell)%hell)%hell;
    }
    cout<<count<<endl;
	return;
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	
		solve();
	return 0;
}

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

class P
{
    static void Main()
    {
        /*
         */
        Console.ReadLine();
        int[] rates = Console.ReadLine().Split().Select(int.Parse).ToArray();

        int[] rateColor = new int[8];
        int over3200 = 0;
        foreach (var rate in rates)
        {
            if (rate >= 3200)
            {
                over3200++;
            }
            else
            {
                rateColor[rate / 400] = 1;
            }
        }
        int colorVal = rateColor.Sum();
        Console.WriteLine($"{Math.Max(colorVal, 1)} {colorVal + over3200}");
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll int n, m;
    cin >> n >> m;
    P a[m];
    int min_1, max_1;
    min_1 = 0;
    max_1 = 200000;
    rep(i, m) {
        cin >> a[i].first >> a[i].second;
        if(a[i].first > min_1) min_1 = a[i].first;
        if(a[i].second < max_1) max_1 = a[i].second;
    }
    if(max_1 < min_1) cout << 0 << endl;
    else cout << max_1 - min_1 + 1 << endl;


}

Measured memory_bytes: 1024