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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  bool hyphenIsOnce = false;
  int hyphenIndex = -1;
  rep(i, s.size()) {
    if (s[i] == '-') {
      if (hyphenIsOnce) {
        hyphenIsOnce = false;
        break;
      } else {
        hyphenIsOnce = true;
        hyphenIndex = i;
      };
    }
  }
  bool isOk = false;
  if (hyphenIsOnce) {
    if (hyphenIndex == a) {
      isOk = true;
    }
  } else {
    isOk = false;
  }

  cout << (isOk ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 998244353;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  vector<int> dp(sum + 1);
  dp[0] = 1;
  int m = 0;
  for (int i = 0; i < n; ++i) {
    m += a[i];
    for (int j = m; j >= 0; --j) {
      dp[j] = (dp[j] * 2LL + (j >= a[i] ? dp[j - a[i]] : 0)) % MOD;
    }
  }
  // trace(m);
  // for (int i = 0; i <= m; ++i) {
  //   trace(i, dp[i]);
  // }
  vector<int> e(sum + 1);
  int ret = 1;
  for (int i = 0; i < n; ++i) ret = ret * 3LL % MOD;
  for (int i = (sum + 1) / 2; i <= sum; ++i) {
    ret = (ret + MOD - dp[i] * 3LL % MOD) % MOD;
  }
  if (sum % 2 == 0) {
    e[0] = 1;
    m = 0;
    for (int i = 0; i < n; ++i) {
      m += a[i];
      for (int j = m; j >= a[i]; --j) {
        e[j] = (e[j] + e[j - a[i]]) % MOD;
      }
    }
    ret = (ret + e[sum / 2] * 3LL) % MOD;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 896
import itertools
S = input()

sumAns = 0
for bit in itertools.product([0, 1], repeat=len(S) - 1):
    ans = 0
    start = 0
    for fin in range(len(bit)):
        if bit[fin] == 1:
            ans += int(S[start: (fin + 1)])
            start = fin + 1
    ans += int(S[start:])

    sumAns += ans

print(sumAns)

Measured memory_bytes: 3060
#include<iostream>
#include <algorithm>
#include<vector>
#include<map>
#include <set>
#include<string>
#include <queue>
#include <stack>
#include <random>
#define INF 10000001

int main()
{    

    int H, W;
    std::cin >> H >> W ;
    int d[1001][1001];
    int dx[4] = {1,-1,0,0};
    int dy[4] = {0,0,1,-1};

    std::queue<std::pair<int,int> > q;

    for(int  i = 0; i < H; ++i){
        std::string s;
        std::cin >> s ;
        for(int j = 0; j < W; ++j){
            if(s[j]=='#'){
                d[i][j] = 0;
                q.push({i,j});
            }
            else {
                d[i][j] = INF;
            }
         }
    }

    int max_count = 0;

    while(!q.empty()){
        const auto cur = q.front();
        q.pop();
        max_count = d[cur.first][cur.second] < max_count ? max_count : d[cur.first][cur.second]; 
        for(int k = 0; k < 4; ++k){
            const int ix = cur.first + dx[k];
            const int iy = cur.second + dy[k];
            if(ix < 0 || ix >= H || iy < 0 || iy >= W) continue;
            if(d[ix][iy] > d[cur.first][cur.second] + 1){
                d[ix][iy] = d[cur.first][cur.second] + 1;
                q.push({ix,iy});
            } 
        }
    }


    std::cout <<  max_count << std::endl; 

    return 0;
}


Measured memory_bytes: 12304
#include <iostream>

using namespace std;

int main()
{
	int len, count = 0;
	string s;
	
	cin >> s;
	
	len = s.length();
	
	for (int i = 0; i < len / 2; i++) {
		if (s[i] != s[(len - 1) - i]) {
			count++;
		}
	}
	
	cout << count << endl;
}


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

void solve(int x){
	bool C[x];
	
	C[0]=false; C[1]=false;
	for(int i=2; i<=x; i++){
		C[i]=true;
	}
	
	for(int i=2;i<(int)sqrt(x)+1; i++){
		if(C[i]){
			for(int y=i*2; y<=x; y+=i) C[y]=false;
		}
	}
	
	int count=0;
	for(int i=0; i<=x; i++){
		if(C[i]){
			count++;
		}
	}
	
	cout << count << endl;  
}

int main(){
	int n;
	
	while(cin >> n){
		solve(n);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define DBG 1
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;

vector<int> c;
vector< vector<int> > s;

struct State {
  vector<int> t;
  int d, score;

  State() {  }

  void set(int _d, vector<int>& _t) {
    d = _d;
    //t = _t;
    t.resize(d);
    forr(i,0,d-1) t[i] = _t[i];
    compscore0();
  }

  void compscore0() {
    vector<int> last(26,-1);
    int sc = 0;
    forr(i,0,d-1) {
      int tt = t[i];
      last[tt] = i;
      forr(j,0,25) sc -= c[j]*(i-last[j]);
      sc += s[i][tt];
    }
    score = sc;
  }

  void add(int day, int con) {
    int bef = day-1;
    while (bef>=0 && t[bef]!=con) bef--;
    int aft = day+1;
    while (aft<d && t[aft]!=con) aft++;
    int inc = s[day][con] + c[con]*(day-bef)*(aft-day);
    //cerr << "add inc " << inc << " s " << s[day][con] << " c " << c[con] << " dy-bf " << day-bef << " af-dy " << aft-day << " sc " << score << endl;
    score += inc;
    t[day] = con;
  }

  void sub(int day) {
    int con = t[day];
    int bef = day-1;
    while (bef>=0 && t[bef]!=con) bef--;
    int aft = day+1;
    while (aft<d && t[aft]!=con) aft++;
    int inc = s[day][con] + c[con]*(day-bef)*(aft-day);
    //cerr << "sub inc " << inc << " s " << s[day][con] << " c " << c[con] << " dy-bf " << day-bef << " af-dy " << aft-day << " sc " << score << endl;
    score -= inc;
    t[day] = -1;
  }

  void chg(int day, int con) {
    //cerr << "chg day " << day << " con " << con << endl;
    sub(day);
    //cerr << "sub done" << endl;
    add(day,con);
    //cerr << "add done score " << score << endl;
  }
};

int main() {
  int d;
  cin >> d;
  //c = vector<int>(26);
  c.resize(26);
  //s = vector< vector<int> >(d, vector<int>(26));
  s.resize(d);
  forr(i,0,d-1) s[i].resize(26);

  forr(i,0,25)
    cin >> c[i];
  forr(i,0,d-1)
    forr(j,0,25)
      cin >> s[i][j];
  vector<int> t(d);
  forr(i,0,d-1) {
    cin >> t[i];
    t[i]--;
  }

  //cerr << "before st" << endl;
  State st;
  st.set(d,t);
  //cerr << "after st" << endl;

  int m;
  cin >> m;
  forr(i,0,m-1) { int dd,qq;
    cin >> dd >> qq;
    st.chg(dd-1,qq-1);
    cout << st.score << endl;
  }
}


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

int main() {
	int a,b,c,x;
	cin >> a >> b >> c;
	if(a > b) {
		x = a;
		a = b;
		b = x;
	}
	if(b > c) {
		x = b;
		b = c;
		c = x;
	}
	if(a > b) {
		x = a;
		a = b;
		b = x;
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}

int main(){
    ll n,m; cin >> n >> m;
    vvl G(n);
    vl vec(n,0);
    rep(i,n+m-1){
        ll a,b; cin >> a >> b; a--; b--;
        G[a].push_back(b);
        vec[b]++;
    }
    ll root;
    rep(i,n) if(vec[i]==0) root = i;
    vl par(n,0);
    queue<ll> q;
    q.push(root);
    vl d(n,0);
    while(!q.empty()){
        ll u = q.front(); q.pop();
        for(auto v : G[u]){
            if(vec[v]>1){
                vec[v]--;
                continue;
            }
            par[v] = u+1;
            q.push(v);
        }
    }
    rep(i,n) cout << par[i] << endl;
}

Measured memory_bytes: 8704
import numpy as np
N, T = map(int, input().split())

menu = []
for _ in range(N):
    m = tuple(map(int, input().split()))
    menu.append(m)
menu = sorted(menu, key=lambda m: m[0])

# 料理i-1をj-1分までに完食するときの満足度最大値
dp = np.zeros((N, T), dtype='int64')
anss = []

for i in range(1, N):
    # 一つまえのメニューについて
    ai, bi = menu[i-1]
    dp[i][:ai] = dp[i-1][:ai]  # 時間が足りないので注文しない
    dp[i][ai:] = np.fmax(
        dp[i-1][ai:], # 何も注文しない
        dp[i-1][:-ai] + bi # 注文した場合, ai分かかっても大丈夫な範囲から取得
    )
    # 加えて自身を最後に食べた場合を記録
    anss.append(dp[i][-1] + menu[i][1])

print(max(anss))

Measured memory_bytes: 82912
import java.util.Scanner;

class Main {
	
	static int[][] multi;
	static int[] line;
	static int[] col;
	
	static int rec (int m, int n) {
		if(m ==n)
            return 0;
        if(multi[m][n] == 0){
            int min = Integer.MAX_VALUE;
            for(int i = m; i < n; i++){
                int r = rec(m, i) + rec (i + 1, n) + (line[m] * col[i] * col[n]);
                if(r < min)
                    min = r;
            }
            multi[m][n] = min;
        }
        return multi[m][n];
	}

	public static void main (String[] args) {
		Scanner scan = new Scanner (System.in);
		int n = scan.nextInt();
		multi = new int[n][n];
		line = new int[n];
		col = new int[n];
		
		
		for (int i = 0; i < n; i++) {
			line[i] = scan.nextInt();
			col[i] = scan.nextInt();
		}
		scan.close();
		System.out.println(rec(0, n - 1));
	}
}



Measured memory_bytes: 27140
from operator import itemgetter
n = int(input())
ranking = []
for i in range(n):
    si, pi = input().split()
    ranking.append([si,int(pi),i])
ranking = sorted(ranking, key = itemgetter(1))[::-1]
ranking = sorted(ranking, key = itemgetter(0))
for item in ranking:
    print(item[2]+1)

Measured memory_bytes: 3064
import math
n, d = map(int, input().split(" "))

count = 0
dots = []
for _ in range(n):
    line = input().split(" ")
    dots.append([int(m) for m in line])

for i in range(n-1):
    for j in range(i+1, n):
        val = [(dots[i][k] - dots[j][k])**2 for k in range(d)]
        
        if math.sqrt(sum(val)).is_integer():
            count += 1
            
print(count)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int a,b,x;
	scanf("%d %d",&a,&b);
	if(a>b) swap(a,b);
	while(1){
		x=a%b;
		if(x==0) break;
		a=b;
		b=x;
	}
	printf("%d\n",b);
	return 0;
}

Measured memory_bytes: 1024
#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 sz(x) (int)(x.size())
#define mod 1000000007
#define endl "\n"
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;

int power(int a, int b){
    if(b==0){
        return 1LL;
    }
    else{
        int ans=power(a,b/2);
        ans=(ans*ans)%mod;
        if(b%2==1){
            ans=(a*ans)%mod;
        }
        return ans;
    }
}

int32_t main(){
    ios::sync_with_stdio(false);
    int n, k;
    cin>>n>>k;
    int ans=0;
    vector<int>v(k+1);
    for(int i=k;i>=1;i--){
        v[i]=power((k/i),n);
        for(int j=2*i;j<=k;j+=i){
            v[i]=(2*mod-v[j]+v[i])%mod;
        }
    }
    for(int i=1;i<=k;i++){
        ans=(ans+(i*v[i])%mod )%mod;
    }
    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 4024
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,t,a[100010],mx=0,ans=0;
bool yes[100010];
priority_queue <int> q;
vector <int> v;

int main()
{
	cin>>n>>t;
	rep(i,n) scanf("%d",&a[i]);
	for(int i=n-2;i>=0;i--)
	{
		q.push(a[i+1]);
		mx=max(mx,q.top()-a[i]);
		v.pb(q.top()-a[i]);
	}
	rep(i,v.size()) if(v[i]==mx) ans++;
	cout<<ans<<endl;
	rt0;
}

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

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

    int cnt = 0;
    for (int i = 0 ; i < n ; i++){
        if(h[i] >= k){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
using namespace std;

int ss; char chr;
inline int read(){
	ss=0; chr=getchar();
	while(chr<'0'||chr>'9') chr=getchar();
	while('0'<=chr&&chr<='9') ss=ss*10+chr-'0',chr=getchar();
	return ss;
}

const int N=1e5+7;
int n,m,pren[N],num,hhh;
int tot=-1,last[N],pre[2*N],to[2*N];
int idx,dfn[N],low[N],vis_p[N];
bool vis_e[N],bridge[N];

inline void add(int xx,int yy){
	++tot;
	pre[tot]=last[xx];
	to[tot]=yy;
	last[xx]=tot;
}

void tarjan(int u){
	vis_p[u]=1;
	dfn[u]=low[u]=++idx;
	for(int c=last[u],v;c!=-1;c=pre[c])
		if(!vis_e[c])
		{
			vis_e[c]=vis_e[c^1]=true;
			v=to[c];
			if(!vis_p[v])
			{
				pren[v]=u;
				tarjan(v);
				if(low[v]<low[u]) low[u]=low[v];
				if(dfn[u]<low[v])
				{
					++num;
					bridge[v]=true;
				}
			}
			else
				if(vis_p[v]==1&&dfn[v]<low[u])
					low[u]=dfn[v];
		}
	vis_p[u]=2;
}

int main(){
	n=read(); m=read();
	memset(last,-1,sizeof(last));
	int i,u,v;
	for(i=1;i<=m;++i)
	{
		u=read(); v=read();
		add(u,v); add(v,u);
	}
	pren[1]=1;
	tarjan(1);
	for(i=1;i<=n;++i)
		if(bridge[i])
			hhh++;
			printf("%d",hhh);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1,-1, 0, 0};
int dy[4] = {0, 0, 1,-1};
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    vector<int>cnt(4);
    for(int i = 0; i < N; i++) {
        if(i == 0) {
            cnt[2]++;
        }
        else if(i+1 == N) {
            if(i%2 == 0) {
                cnt[2]++;
            }
            else {
                cnt[1]++;
            }
        }
        else {
            if(i%2 == 0) {
                cnt[3]++;
            }
            else {
                cnt[0]++;
            }
        }
    }
    int ans = 0,now = 0;
    for(int i = 0; i < cnt[0]; i++) {
        ans-=A[now]*2;
        now++;
    }
    for(int i = 0; i < cnt[1]; i++) {
        ans-=A[now];
        now++;
    }
    for(int i = 0; i < cnt[2]; i++) {
        ans+=A[now];
        now++;
    }
    for(int i = 0; i < cnt[3]; i++) {
        ans+=A[now]*2;
        now++;
    }
    vector<int>cnt2(4);
    for(int i = 0; i < N; i++) {
        if(i == 0) {
            cnt2[1]++;
        }
        else if(i+1 == N) {
            if(i%2 == 0) {
                cnt2[1]++;
            }
            else {
                cnt2[2]++;
            }
        }
        else {
            if(i%2 == 0) {
                cnt2[0]++;
            }
            else {
                cnt2[3]++;
            }
        }
    }
    now = 0;int res = 0;
    for(int i = 0; i < cnt2[0]; i++) {
        res-=A[now]*2;
        now++;
    }
    for(int i = 0; i < cnt2[1]; i++) {
        res-=A[now];
        now++;
    }
    for(int i = 0; i < cnt2[2]; i++) {
        res+=A[now];
        now++;
    }
    for(int i = 0; i < cnt2[3]; i++) {
        res+=A[now]*2;
        now++;
    }
    cout << max(ans,res) << endl;
}


Measured memory_bytes: 4048
n, c = list(map(int, input().split()))
sushi = [list(map(int, input().split())) for i in range(n)]
s = sorted(sushi, key=lambda x: x[0])

r = [0]
r_return = [0]
cal_r = 0

l = [0]
l_return = [0]
cal_l = 0

for i in range(n):
    cal_r += s[i][1]
    eff_cal_r = cal_r - s[i][0]
    eff_cal_r_return = cal_r - 2*s[i][0]
    r += [max(r[i], eff_cal_r)]
    r_return += [max(r_return[i], eff_cal_r_return)]

    cal_l += s[-i-1][1]
    eff_cal_l = cal_l - (c-s[-i-1][0])
    eff_cal_l_return = cal_l - 2*(c-s[-i-1][0])
    l += [max(l[i], eff_cal_l)]
    l_return += [max(l_return[i], eff_cal_l_return)]

cal = 0

for i in range(n+1):
    cal = max(
            cal,
            r_return[i] + l[n-i],
            l_return[i] + r[n-i]
            )

print(cal)

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        Set<String> set = new HashSet<>();

        for (int i = 0; i < N; i++) {
            set.add(sc.next());
        }

        System.out.println(set.size());
    }
}


Measured memory_bytes: 76652
def get_medians(nums):
    s = sorted(nums)
    mid = len(s) // 2
    return (s[mid - 1], s[mid])

input()
nums = [int(tok) for tok in input().split()]

medians = get_medians(nums)
for num in nums:
    if num <= medians[0]:
        print(medians[1])
    else:
        print(medians[0])


Measured memory_bytes: 25556
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp1, tmp2;
    string S;
    bool flag=true;
    
    cin >> A >> B ;

    if(A-B>0)
    	cout << A-B<<endl;
    else
	cout << 0<<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a;
	cin >> a;
	string s;
	cin >> s;
	cout << (a < 3200 ? "red" : s) << endl;

	return 0;
}

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

using namespace std;

int main()
{
  int L,t,t2;
  
  cin >> L;
  t=L/3;
  t2=L%3;
  
  int ans1 = t*t*t;
  long double t3,ans2;
  t3 = (long double)t2/3;
  ans2 = (3*t*t + 3*t*t3 + t3*t3)*t3;
  
  cout<<fixed<<setprecision(12);
  cout << ans1+ans2 << endl;
  
  return 0;
}

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

using namespace std;
string s;
int main()
{
    int n,ans,S=0;
    cin >> s;
    n=s.size();
    ans=n;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='S')
        {
            S++;
        }
        else if(s[i]=='T' && S>0)
        {
            S--;
            ans-=2;
        }
    }
    cout << ans << endl;
    return 0;
}


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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            for (int i = 1; i < 50000; i++)
            {
                if (i * 108 / 100 == N)
                {
                    Console.WriteLine(i);
                    return; ;
                }
            }

            Console.WriteLine(":(");
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 11092
N, M = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(M)]
lst.sort(key = lambda x: x[1])
div = 0
cnt = 0
for a, b in lst:
  if a > div:
    div = b-1
    cnt += 1
print(cnt)

Measured memory_bytes: 29084
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  Long a, b, n;
  cin >> a >> b >> n;
  Long q = min(b - 1, n);
  cout << q * a / b << '\n';

  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstring>

const int MOD = 998244353;

const int ms = 2020;

int memo[ms + ms][ms + ms];
std::string str;

int dp(int round, int red, int blue) {
	if(round < (int) str.size()) {
		if(str[round] == '0') red += 2;
		else if(str[round] == '1') { red++; blue++; }
		else blue += 2;
	}
	int &ans = memo[round][red];
	if(ans != -1) return ans;
	ans = 0;
	if(red + blue == 0) return ans = 1;
	if(red) {
		ans += dp(round+1, red-1, blue);
	}
	if(blue) {
		ans += dp(round+1, red, blue-1);
	}
	if(ans >= MOD) ans -= MOD;
	return ans;
}

int main() {
	memset(memo, -1, sizeof memo);
	std::cin >> str;
	std::cout << dp(0, 0, 0) << '\n';
}

Measured memory_bytes: 64384
N = int(input())
A = list(map(int, input().split()))
Y = list(map(int, input().split()))
A_sum_1 = sum(A)
for i in range(N):
  if A[i] < Y[i]:
    Y[i] = Y[i] - A[i]
    A[i] = 0
    if A[i + 1] < Y[i]:
      A[i + 1] = 0
    else:
      A[i + 1] = A[i + 1] - Y[i]

  else:
    A[i] = A[i] - Y[i]
    Y[i] = 0

print(A_sum_1 - sum(A))


Measured memory_bytes: 19156
# -*- coding: utf-8 -*-

import sys
from collections import deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H,W=MAP()

que = deque()
# 右左上下  
directions = [(0,1),(0,-1),(1,0),(-1,0)]
# 四方に一回り大きいグリッドを作る
grid = list2d(H+2, W+2, '*')
for i in range(1,H+1):
    row = list(input())
    for j in range(1, W+1):
        grid[i][j] = row[j-1]
        if grid[i][j] == '#':
            que.append((i, j, 0))

# 移動距離メモ
memo=[[-1]*(W+2) for i in range(H+2)]
while len(que):
    cur=que.popleft()
    if memo[cur[0]][cur[1]]!=-1:
        continue
    memo[cur[0]][cur[1]]=cur[2]
    # 4方向見る
    for direction in directions:
        x=cur[0]+direction[0]
        y=cur[1]+direction[1]
        # 壁と黒はスキップ
        if grid[x][y]=='*' or grid[x][y]=='#':
            continue
        # 白を埋める
        if grid[x][y]=='.':
            grid[x][y]='#'
            que.append((x, y, cur[2]+1))
ans=0
for i in range(1, H+1):
        ans=max(ans, max(memo[i]))
print(ans)


Measured memory_bytes: 166748
class UnionFind
  attr_accessor :parent, :size
  
  def initialize(n)
    @parent = []
    @size = []
    n.times do |i|
      @parent[i] = i
      @size[i] = 1
    end
  end

  def find(x)
    if @parent[x] == x
      return x
    else
      return @parent[x] = find(@parent[x])
    end
  end

  def unite(x,y)
    x,y = find(x),find(y)
    return if x==y

    x,y = y,x if @size[x] < @size[y]
    @size[x] += @size[y]
    @parent[y] = x
  end
  
  def same(x,y)
    return find(x) == find(y)
  end
end

N,K,L = gets.split.map(&:to_i)
road = UnionFind.new(N+1)
rail = UnionFind.new(N+1)
par = Hash.new(0)

K.times do
  a,b = gets.split.map(&:to_i)
  road.unite(a,b)
end
L.times do
  a,b = gets.split.map(&:to_i)
  rail.unite(a,b)
end

N.times do |i|
  par[[road.find(i+1),rail.find(i+1)]] += 1
end
N.times do |i|
  print "#{par[[road.find(i+1),rail.find(i+1)]]}"
  print i < N-1 ? " " : "\n"
end


Measured memory_bytes: 32764
#include <iostream>
#include <string>
#include <algorithm>
#define N 90
using namespace std;

typedef long long ll;

int main()
{
	int n;
	cin >> n;
	int *arr = new int[4];
	for (int i = 3; i >= 0; i--)
	{
		arr[i] = n % 10;
		n /= 10;
	}
	if (arr[0] + arr[1] + arr[2] + arr[3] == 7)
	{
		cout << arr[0] << "+" << arr[1] << "+" << arr[2] << "+" << arr[3] << "=7";
		return 0;
	}
	if (arr[0] + arr[1] + arr[2] - arr[3] == 7)
	{
		cout << arr[0] << "+" << arr[1] << "+" << arr[2] << "-" << arr[3] << "=7";
		return 0;
	}
	if (arr[0] + arr[1] - arr[2] + arr[3] == 7)
	{
		cout << arr[0] << "+" << arr[1] << "-" << arr[2] << "+" << arr[3] << "=7";
		return 0;
	}
	if (arr[0] + arr[1] - arr[2] - arr[3] == 7)
	{
		cout << arr[0] << "+" << arr[1] << "-" << arr[2] << "-" << arr[3] << "=7";
		return 0;
	}

	if (arr[0] - arr[1] + arr[2] + arr[3] == 7)
	{
		cout << arr[0] << "-" << arr[1] << "+" << arr[2] << "+" << arr[3] << "=7";
		return 0;
	}
	if (arr[0] - arr[1] + arr[2] - arr[3] == 7)
	{
		cout << arr[0] << "-" << arr[1] << "+" << arr[2] << "-" << arr[3] << "=7";
		return 0;
	}
	if (arr[0] - arr[1] - arr[2] + arr[3] == 7)
	{
		cout << arr[0] << "-" << arr[1] << "-" << arr[2] << "+" << arr[3] << "=7";
		return 0;
	}
	if (arr[0] - arr[1] - arr[2] - arr[3] == 7)
	{
		cout << arr[0] << "-" << arr[1] << "-" << arr[2] << "-" << arr[3] << "=7";
		return 0;
	}
	return 0;
}

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

int main()
{
    using UInt = std::uint32_t;

    auto gcd = [] (UInt x, UInt y) -> UInt {
        if (x < y) {
            UInt tmp = x;
            x = y;
            y = tmp;
        }
        while (y > 0) {
            UInt tmp = x % y;
            x = y;
            y = tmp;
        }
        return x;
    };

    /*
    UInt x, y;
    std::cin >> x >> y;
    std::cout << gcd(x, y) << std::endl;
    return 0;
    */

    int N;
    std::cin >> N;
    std::vector<UInt> A(N);
    for (int i = 0; i < N; ++i) std::cin >> A.at(i);
    std::vector<UInt> L(N);
    std::vector<UInt> R(N);
    L.at(0) = 0;
    R.at(N - 1) = 0;
    for (int i = 1; i < N; ++i) L.at(i) = gcd(L.at(i - 1), A.at(i - 1));
    for (int i = N; i > 1; --i) R.at(i - 2) = gcd(R.at(i - 1), A.at(i - 1));
    UInt best_gcd = 0;
    for (int i = 0; i < N; ++i) {
        best_gcd = std::max(best_gcd, gcd(L.at(i), R.at(i)));
    }

    std::cout << best_gcd << std::endl;

    return 0;
}


Measured memory_bytes: 1408
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

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

    int height[n];
    for (int i = 0; i < n; i++) cin >> height[i];

    long long dp[n];

    fill(dp, dp + n, 1000000007);

    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < min(i + k + 1, n); j++) {
            dp[j] = min(dp[j], dp[i] + abs(height[j] - height[i]));
        }
    }

    cout << dp[n - 1] << endl;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    ll A[N]; rep(i, N) cin >> A[i]; sort(A, A+N);
    priority_queue<pair<ll, ll>> pq;
    rep(i, M){
        ll b, cost; cin >> b >> cost;
        pq.push(make_pair(cost, b));
    }
    int argmin = 0;
    rep(i, M){
        ll cost = pq.top().first;
        ll b = pq.top().second;
        pq.pop();
        int j = 0;
        while(j < b && argmin < N && A[argmin] < cost){
            A[argmin] = cost;
            argmin++;
            j++;
        }
    }
    ll ans = 0; rep(i, N) ans += A[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000LL
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
#define FILEIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);

using namespace std;

ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
vii adj[upperlimit+1];
bool visited[upperlimit+1];
ll dp[2][upperlimit+1];
int n,m,s,t,u,v,a,b;
void dijkstra(int node,int ind){
	for(int i=1;i<=2*n;i++){
		visited[i]=false;
		dp[ind][i]=INFL;
	}
	priority_queue<pll> pq;
	pq.push(mp(0,node));
	while(!pq.empty()){
		pll temp=pq.top();
		pq.pop();
		if(visited[temp.S])continue;
		visited[temp.S]=true;
		dp[ind][temp.S]=-temp.F;
		for(int i=0;i<adj[temp.S].size();i++){
			pll temp2;
			temp2.S=adj[temp.S][i].F;
			temp2.F=temp.F-adj[temp.S][i].S;
			pq.push(temp2);
		}
	}
}
ll answer[upperlimit+1];
int main()
{
	int i,j,k;
	sd(n);sd(m);sd(s);sd(t);
	for(i=1;i<=m;i++){
		sd(u);sd(v);
		sd(a);sd(b);
		adj[u].pb(mp(v,a));
		adj[v].pb(mp(u,a));
		adj[u+n].pb(mp(v+n,b));
		adj[v+n].pb(mp(u+n,b));
	}
	for(i=1;i<=n;i++){
		adj[i].pb(mp(i+n,0));
	}
	dijkstra(s,0);
	for(i=1;i<=n;i++){
		adj[i].pop_back();
		adj[i+n].pb(mp(i,0));
	}
	dijkstra(t+n,1);
	answer[n]=INFL;
	for(i=n-1;i>=0;i--){
		answer[i]=min(answer[i+1],dp[0][i+1]+dp[1][i+1+n]);
	}
	for(i=0;i<n;i++){
		plldn(INFL-answer[i]);
	}
	return 0;
}

Measured memory_bytes: 49976
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        String s = sc.next();
        String date[] = s.split("/");
        if (Integer.valueOf(date[1]) > 4) {
            System.out.println("TBD");
        } else {
            System.out.println("Heisei");
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define MOD 1e9 + 7
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265359

template <typename T>
void printVector(string name, vector<T> vec)
{
    cout << name << ": ";
    rep(i, vec.size())
    {
        cout << vec[i] << " ";
    }
    cout << endl;
}

void Main()
{
    ll n, k;
    cin >> n >> k;
    ll m = n % k;

    cout << ((m < k - m) ? m : k - m) << endl;
    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  int n;
  ll o = 0, c = 1;
  cin >> n;
  vector<string> s(n);
  string t;
  for(int i = 0; i < n; i++) {
    cin >> t;
    sort(t.begin(), t.end());
    s.at(i) = t;
  }
  sort(s.begin(), s.end());
  t = s.at(0);
  for(int i = 1; i < n; i++) {
    if(s.at(i) == t)
      c++;
    if(s.at(i) != t || i == n - 1) {
      if(c >= 2)
        o += c * (c - 1) / 2;
      c = 1;
      t = s.at(i);
    }
  }
  cout << o << endl;
}

Measured memory_bytes: 5760
import java.util.*;

class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    long x = scan.nextLong();
    long[][] dp = new long[n][n];
    for(int j = 0; j < n; j++) {
      dp[0][j] = scan.nextLong();
    }
    for(int i = 1; i < n; i++) {
      for(int j = 0; j < n; j++) {
        dp[i][j] = Math.min(dp[i-1][j], dp[0][(j-i+n)%n]);
      }
    }
    long result = 1L<<60;
    for(int i = 0; i < n; i++) {
      long dummyResult = i*x;
      for(int j = 0; j < n; j++) {
        dummyResult += (long)dp[i][j];
      }
      result = Math.min(result,dummyResult);
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 45160
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, int> LP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int sz = 80*160+5;
int a[81][81];
bitset<sz*2> dp[81][81];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	rep(i,h)rep(j,w) cin >> a[i][j];
	rep(i,h)rep(j,w){
		int b;
		cin >> b;
		a[i][j] = abs(b - a[i][j]);
	}
	dp[0][0][sz-a[0][0]] = 1;
	dp[0][0][sz+a[0][0]] = 1;
	rep(i,h)rep(j,w){
		if(i > 0){
			dp[i][j] |= dp[i-1][j] << a[i][j];
			dp[i][j] |= dp[i-1][j] >> a[i][j];
		}
		if(j > 0){
			dp[i][j] |= dp[i][j-1] << a[i][j];
			dp[i][j] |= dp[i][j-1] >> a[i][j];
		}
	}
	int ans = INF;
	rep(i,sz*2){
		if(dp[h-1][w-1][i]) chmin(ans, abs(i-sz));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23960
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  
  int N;
  cin >> N;
  
  vector<double> V(N, 0);
  for(int i = 0; i < N; i++){
    cin >> V[i];
  }
  
  //sort
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N - i - 1; j++){
        if(V[j] >= V[j + 1]){
            int Temp = V[j];
            V[j] = V[j + 1];
            V[j + 1] = Temp;  
        }
    }
  }
  
  double sum = (V[0] + V[1])/2;
  
  for(int i = 2; i < N; i++){
    sum = (sum + V[i])/2;
  }
  
  cout << sum;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";

#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 1000005

template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

//FILE* outFile;

inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
inline int gcd(int a, int b){if(b == 0)return a; return gcd(b, a%b);}
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

int dp[N];
int main(){
    int j,k,i,T,ca=0, m = 0, K = 0, n;
    int H, D;
    scanf("%d%d%d", &n, &H, &D);
    K = 1;
    ll sum = 0;
    rep(i, 1, n+1){
        K = 1LL * K * i % mod;
        sum = (sum + K) % mod;
    }
    ll q = K;
    dp[1] = q;
    rep(i, 2, H+1){
        K = dp[i-1];
        if(i-1 > D){
            K = (K - dp[i-1-D] + mod) % mod;
        }
        K = K * sum % mod;
        if(i <= D){
            K = (K + q) % mod;
        }
        dp[i] = (dp[i-1] + K) % mod;
    } 
    printf("%d\n", K);
}



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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

ll Inv(ll n){
	ll res=1,b=mod-2;
	while(b){
		if(b&1) (res*=n)%=mod;
		(n*=n)%=mod;
		b>>=1;
	}
	return res;
}

int main(){
	IOS;
	int n,s;
	cin>>n>>s;
	int i,a[n],p2[n+1];
	p2[0]=1;
	REP(i,1,n) (p2[i]=1ll*2*p2[i-1])%=mod;
	ll inv=Inv(2);
	REP(i,0,n-1) cin>>a[i];
	ll dp[s+1],j;
	memset(dp,0,sizeof(dp));
	dp[0]=p2[n];
	ll ans=0;
	sort(a,a+n);
	REP(i,0,n-1){
		RAP(j,s,a[i]) {
			(dp[j]+=((dp[j-a[i]])*inv)%mod)%=mod;
			dbg(dp[j],j);
		}
	}
	cout<<dp[s];
	return 0; 	
}




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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<pair<int, int>> m(100000);

  for (int i = 0; i < n; i++) {
    cin >> v[i];
    m[v[i]].first++;
    m[v[i]].second = i;
  }
  sort(m.begin(), m.end(), greater<pair<int, int>>());
  int index = 0;
  int s1    = 0;
  int s2    = 0;

  for (auto p : m) {
    if (index == 0)
      s1 = p.second;
    else if (index == 1)
      s2 = p.second;
    else
      break;
    index++;
  }

  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i += 2) {
    a[i]     = v[s1];
    a[i + 1] = v[s2] == v[s1] ? -1 : v[s2];
    b[i]     = v[s2] == v[s1] ? -1 : v[s2];
    b[i + 1] = v[s1];
  }

  int cnt = 0, cnt2 = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] != a[i]) cnt++;
    if (v[i] != b[i]) cnt2++;
  }
  cout << min(cnt, cnt2) << endl;
}

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

using namespace std;
typedef long long ll;

int p[100001];
ll Q;
ll l[100001];
ll r[100001];
int ans[100001];

int main(){
    ll Q;
    cin >> Q;
    ll N = 100000;
    for(int i=0;i<Q;i++) cin >> l[i] >> r[i];
    for(int i=1;i<=N;i++) p[i] = 1;
    for(int i=2;i*i<=N;i++){
        if(p[i] != 1) continue;
        for(int j=2;i*j<=N;j++) p[i*j]++;
    }
    p[1] = 0;
    for(int i=0;i<=N;i++){
        if(i%2 == 0){
            ans[i] = 0;
            continue;
        }
        if(p[i] == 1 && p[(i+1)/2] == 1) ans[i] = 1;
        else ans[i] = 0;
    }
    for(int i=2;i<=N;i++) ans[i] += ans[i-1];
    for(int i=0;i<Q;i++){
        cout << ans[r[i]] - ans[l[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

int main(void){
  fast_io

  int n;
  cin>>n;
  ll ans = 0;
  vector<string> S;
  vector<ll> T;
  rep(i,n){
    string s;
    ll t;
    cin>>s>>t;
    S.push_back(s);
    T.push_back(t);
  }
  string s;
  cin>>s;
  bool ok = false;
  rep(i,n){
    if(ok){
      ans += T[i];
    }
    if(s==S[i]){
      ok = true;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
	string s;
	cin >> s;
	string t;
	cin >> t;
	int c = 0;
	c = t.size();
	t.erase(c-1);

	if (s == t) {
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3572
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[400001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size), j = i >> 1;
	data tmp;
	h->obj[i] = x;
	while (j > 0) {
		if (h->obj[i].key < h->obj[j].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j <<= 1;
		} else break;
	}
	return output;
}

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, H, W, A, B;
	scanf("%d %d", &H, &W);
	
	int j, k, s[200002], left[200002], right[200002], BIT[200001] = {}, L, R, M, tmp;
	data d;
	min_heap h;
	h.size = 0;
	for (i = 0; i <= W + 1; i++) {
		s[i] = i;
		left[i] = i - 1;
		right[i] = i + 1;
	}
	for (i = 1, d.key = 0; i <= W; i++) {
		d.id = i;
		push(d, &h);
		add_BIT(W, BIT, i, 1);
	}
	for (i = 1; i <= H; i++) {
		scanf("%d %d", &A, &B);
		tmp = sum_BIT(BIT, A - 1);
		if (sum_BIT(BIT, B) == tmp) {
			printf("%d\n", h.obj[1].key + i);
			continue;
		}
		
		L = A;
		R = B++;
		while (L < R) {
			M = (L + R) / 2;
			if (sum_BIT(BIT, M) > tmp) R = M;
			else L = M + 1;
		}
		
		left[B] = left[L];
		right[left[L]] = B;
		if (s[B] < 0) add_BIT(W, BIT, B, 1);
		for (j = L; j < B; j = right[j]) {
			if (s[j] > s[B]) s[B] = s[j];
			s[j] = -1;
			add_BIT(W, BIT, j, -1);
		}
		if (j != B) {
			left[j] = B;
			right[B] = j;
		}
		if (B <= W) {
			d.key = B - s[B];
			d.id = B;
			push(d, &h);
		}
		
		while (h.size > 0 && s[h.obj[1].id] < h.obj[1].id - h.obj[1].key) pop(&h);
		if (h.size > 0) printf("%d\n", h.obj[1].key + i);
		else break;
	}
	for (; i <= H; i++) printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 6676
#include <iostream>
using namespace std;
typedef long long ll;
//vector<pair<bool, ll>> v(4001);
unsigned long long int a[4001];

int main(){
	int n, num, p, q;
	while(cin >> n, n){
		//fill(a, a+4001, 0);
		int f = 1;
		for(int i = 0;i < 4001;i++)a[i] = 0;
		for(int i = 0;i < n;i++){
			cin >> num >> p >> q;
			a[num] += p * q;
			if(a[num]>999999){
                cout << num << endl;
                f = 0;
            }
		}
		if(f)cout << "NA" <<endl;
		/*int f = 1;
		for(int i = 1;i <= 4000;i++)if(a[i] >= 1000000)cout << i << endl, f = 0;
		if(f)cout << "NA" << endl;*/
	}
	return 0;
}

/*
4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
*/

Measured memory_bytes: 3104