akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
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 devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N){
    ll ans = 0;
    return ans;
}

int main(){
    ll N; cin >> N;
    vector<ll> A(N); rep(i,N) cin >> A[i];
    
    ll ans = 0, mn = 1e9;
    rep(i,N){
        if(mn >= A[i]) ans++;
        mn = min(mn,A[i]);
    }
    print(ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

int main() {
    ll n; cin >> n;
    ll ans; cin >> ans;
    rep(i, n-1) {
        ll t; cin >> t;
        ans = LCM(ans, t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3556
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

ll power(ll m, ll n){
    if(n == 0) return 1;
    if(n % 2 == 1) return m * power(m, n - 1) % INF;
    if(n % 2 == 0) {
        ll tmp = power(m, n/2);
        return tmp * tmp % INF;
    }
}

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N), digit(64, 0);
    rep(i, N) cin >> A[i];

    rep(i, N){
        bitset<64> s(A[i]);
        rep(j, 64){
            if(s.test(j)) digit[j]++;
        }
    }

    ll ans = 0;

    rep(i, N){
        bitset<64> s(A[i]);
        ll a = 1;
        rep(j, 64){
            if(s.test(j)){
                ans += a * (N - digit[j]);
                ans %= INF;
            } else {
                ans += a * digit[j];
                ans %= INF;
            }
            a *= 2;
            a %= INF;
        }
    }

    ans *= power(2, INF - 2);
    ans %= INF;

    cout << ans << endl;
    
}

Measured memory_bytes: 2560
N,M = map(int,input().split())
a=[]
for _ in range(M):
    a.append(int(input()))
    
kaidan = [1, 2]

for i in range(2, N):
  kaidan.append(kaidan[i-1]+ kaidan[i-2])

if M == 0:
  ans = kaidan[N - 1]
else:
  ans = 1

  if a[0] - 1 > 0:
      ans *= kaidan[a[0] - 2]

  for i in range(M-1):
    if((a[i] + 1) > (a[i+1] - 1)):
      ans *= 0
    elif((a[i] + 1) == (a[i+1] - 1)):
      ans *= 1
    else:
      ans *= (kaidan[a[i+1] - a[i] - 3])

  if N - (a[M - 1] + 1) > 0:
      ans *= kaidan[N - (a[M - 1] + 2)]
      
print(ans%1000000007)
  


Measured memory_bytes: 464040
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

bool kaibun(std::string str)
{
  for (auto i = 0; i < str.size() / 2; ++i)
  {
    if (str[i] != str[str.size() - 1 - i])
      return false;
  }
  return true;
}

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

  auto N = S.size();

  if (kaibun(S) && kaibun({S.begin(), S.begin() + (N - 1) / 2}) && kaibun({S.begin() + (N + 3) / 2 - 1, S.begin() + N}))
    std::cout << "Yes\n";
  else
    std::cout << "No\n";
}

Measured memory_bytes: 256
// Copyright 2017 wu_qing
#include <stdint.h>
#include <cstdio>
#include <vector>
#include <algorithm>
int n, l, v;
int64_t cur, ans, w, w0;
std::vector<int> h[4];
std::vector<int64_t> pre[4];
bool cmp(int a, int b) {
    return a > b;
}
int main() {
    scanf("%d%d%lld%d", &n, &l, &w0, &v);
    h[0].push_back(v);
    for (int i = 2; i <= n; i++) {
        scanf("%lld%d", &w, &v);
        h[w - w0].push_back(v);
    }
    for (int i = 0; i < 4; i++) {
        std::sort(h[i].begin(), h[i].end(), cmp);
        cur = 0;
        pre[i].push_back(cur);
        for (std::vector<int>::iterator it = h[i].begin();
                it != h[i].end(); it++) {
            cur += *it;
            pre[i].push_back(cur);
        }
    }
    for (int i = 0; i <= static_cast<int>(h[0].size()); i++)
        for (int j = 0; j <= static_cast<int>(h[1].size()); j++)
            for (int k = 0; k <= static_cast<int>(h[2].size()); k++) {
                int64_t m = l - i * w0 - j * (w0 + 1) - k * (w0 + 2);
                if (m < 0) continue;
                m /= w0 + 3;
                m = std::min(m, static_cast<int64_t>(h[3].size()));
                ans = std::max(ans, pre[0][i] + pre[1][j] + pre[2][k] +
                        pre[3][m]);
            }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
N,M,Q=map(int,input().split())
a=[0]*Q
b=[0]*Q
c=[0]*Q
d=[0]*Q

for i in range(Q):
    a[i],b[i],c[i],d[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1    #Aのa[i],b[i]番目を指定したいから-1する。

def score(A):
    一つ一つの点数=0
    for ai,bi,ci,di in zip(a,b,c,d):
        if A[bi]-A[ai]==ci:
            一つ一つの点数+=di
    return 一つ一つの点数

def dfs(A):
    if len(A)==N:
        return score(A)
    暫定の点数=0
    数列=A[-1] if len(A)>0 else 0
    for v in range(数列,M):
        A.append(v)
        暫定の点数=max(暫定の点数,dfs(A))    #再帰関数を呼び出しながら暫定1位の点数を更新。
        A.pop()
    return 暫定の点数

print(dfs([]))




Measured memory_bytes: 74504
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

ll w[MAX_N], v[MAX_N];
ll dp[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,W;
    cin >> n >> W;
    rep(i,n){
        cin >> w[i] >> v[i];
    }
    rep(i,n){
        rrep(j,W-w[i]+1){
            cmx(dp[j+w[i]], dp[j]+v[i]);
        }
    }
    cout << *max_element(dp, dp+W+1) << "\n";
    return 0;
}

Measured memory_bytes: 1024
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    a=[parseMap(split(readline())) for i in 1:2]
    l=[0 for i in 1:n]
    r=[0 for i in 1:n]
    l[1],r[1]=a[1][1],a[2][end]
    for i in 2:n
        l[i]=l[i-1]+a[1][i]
        r[i]=r[i-1]+a[2][n-i+1]
    end
    ans=0
    for i in 1:n
        ans=max(ans,l[i]+r[n-i+1])
    end
    println(ans)
end
main()

Measured memory_bytes: 173180
#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(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n/i+1; j++){
            if(i*j >= n) break;
            else ans++;
        }
    }
    cout << ans << endl;
}

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

const int N = 21;

int n, m;
int f[N][1 << N], len[1 << N];
int trans[1 << N][2];
// f[k][S|T]: 已经匹配 S，还需要添加的内容 T' 是 T 的子序列, |T| = k, |S| + '1' + |T| = N + 1, 状态数 O(n*2^n)
inline char nc()
{
	static char buf[1000000], *p1 = buf, *p2 = buf;
	return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)? EOF : *p1++;
}

inline int read()
{
	int neg = 1, res = 0;
	char ch;
	do 
	{
		ch = nc();
		if (ch == '-') neg = -1;
	} while (ch < 48 || ch > 57);
	do res = res * 10 + ch - 48, ch = nc(); while (ch >= 48 && ch <= 57);
	return res * neg;
}

inline int read_bit()
{
	char ch;
	do ch = nc(); while (ch != 48 && ch != 49);
	return ch - 48;
}

int main()
{
	n = read(), m = read();
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j < (1 << i); ++j)
		{
			f[i][1 << i | j] = read_bit();
		}
	}
	len[0] = -1;
	for (int i = 1; i <= 1 << (n + 1); ++i) len[i] = len[i >> 1] + 1;

	for (int S = 2; S <= 1 << (n + 1); ++S)
	{
		if (S >> (len[S] - 1) & 1)
		{
			trans[S][1] = S ^ (1 << len[S]); // 由于形如 1 + T，因此消掉前缀1即可
			trans[S][0] = trans[trans[S][1]][0];
		}
		else
		{
			trans[S][0] = S ^ (3 << (len[S] - 1)); // 消掉前缀 1 同时补一个前缀
			trans[S][1] = trans[trans[S][0]][1];
		}
	}

	for (int i = n; i >= 1; --i)
	{
		for (int S = 1 << i; S < (1 << (n + 1)); ++S)
		{	// S: [A|B]
			if (f[i][S])
			{
				int A = S >> i, B = (S & (1 << i) - 1) | 1 << i, T = 0;
				if (T = trans[B][0]) f[len[T]][(A << 1 | 1) << len[T] ^ T] += f[i][S];
				if (T = trans[B][1]) f[len[T]][(A << 1 | 0) << len[T] ^ T] += f[i][S];
				f[0][A] += f[i][S];
			}
		}
	}
	int ans = 1;
	for (int S = 2; S < 1 << (n + 1); ++S) if (f[0][S] >= m && len[S] > len[ans]) ans = S;
//	for (int i = 0; i <= n; ++i) for (int j = 0; j < 1 << n + 1; ++j) if (f[i][j]) printf("f[%d][%d] = %d\n", i, j, f[i][j]);
//	printf("ans = %d\n", ans);
	int j = n;
	while (~ans >> j & 1) --j;
	while (j--) printf("%d", ans >> j & 1);
	putchar('\n');
//	for (int i = 0; i <= n; ++i) for (int j = 0; j < (1 << N); ++j) if (f[i][j]) printf("state (%d, %d)\n", i, j);
	
	return 0;
}

Measured memory_bytes: 195968
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
#define endl "\n"
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()

int main()
{
    hs;
   string c;
   int ans=0,i;
   cin>>c;
   for(i=0;c[i]!='\0';i++){
    ans=(ans*10+c[i]-'0')%9;
   }

    if(ans==0)
    {
        cout<<"Yes"<<"\n";
    }
    else
        cout<<"No"<<"\n";

}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b, k; cin >> a >> b >> k;
    int cnt = 0;
    for(int i = min(a,b); i >= 1; i--){
        if(a % i == 0 && b % i == 0) cnt++;
        if(cnt == k) {
            cout << i << endl;
            return 0;
        }
    }
}

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

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


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(void){
    int d;
    cin >> d;
    
    
    
    cout << ((d == 25) ? "Christmas" : (d == 24) ? "Christmas Eve" : (d == 23) ? "Christmas Eve Eve" : "Christmas Eve Eve Eve") << "\n";
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

struct edge {
    int to;
    ll cost;
};

vector<edge> tree[100010];
ll cost_k[100010];

void dfs(int v, int par, ll dist) {
    cost_k[v] = dist;

    for(int i = 0; i < tree[v].size(); i++){
        if(tree[v][i].to == par) continue;
        dfs(tree[v][i].to, v, dist + tree[v][i].cost);
    }
}

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

    rep(i,n-1){
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        tree[a].push_back({b,c});
        tree[b].push_back({a,c});
    }

    int q, k; cin >> q >> k;
    k--;

    dfs(k,-1,0);

    rep(i,q){
        int x, y; cin >> x >> y;
        x--; y--;

        cout << cost_k[x] + cost_k[y] << endl;
    }

    return 0;
}

Measured memory_bytes: 15872
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





class bellmanford
{
private:
    struct edge {
        ll to, cost;
    };
    ll vertex;    // 頂点数
    vector<vector<edge>> list;    // 隣接リスト
    vector<ll> distance;    // 距離
public:
    bellmanford(ll n);   // nは頂点数
    void add_edge(ll v1, ll v2, ll cost);    // 頂点v1から頂点v2に辺を張る
    bool run(ll s);        // sは開始地点。返り値がfalseのとき負の閉路あり
    ll get_distance(ll v);    // 頂点vへの距離を返す
};

bellmanford::bellmanford(ll n){
    list.resize(n);
    vertex = n;
}

void bellmanford::add_edge(ll v1, ll v2, ll cost) {
    list[v1].push_back({ v2, cost });
}

bool bellmanford::run(ll s) {
    distance = vector<ll>(vertex, INF);
    distance[s] = 0;    //開始点の距離は0
    
    for (ll i = 0; i < vertex; i++) {
        for (ll v = 0; v < vertex; v++) {
            for (auto edge : list[v]) {
                if (distance[v] != INF && distance[edge.to] > distance[v] + edge.cost) {
                    distance[edge.to] = distance[v] + edge.cost;
                    if (i == vertex - 1) {
                        //return false;
                        distance[edge.to] = -INF;
                    }
                }
            }
        }
    }
    return true;
}

ll bellmanford::get_distance(ll v) {
    return distance[v];
}


int main() {
    ll n, m;
 
	cin >> n >> m;
 
	bellmanford bell(n);
 
	REP(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
 
		bell.add_edge(a, b, -c);
	}
 
	bell.run(0);
 
	if (bell.get_distance(n - 1) > -INF) {
		cout << -bell.get_distance(n - 1) << endl;
	}
	else {
		cout << "inf" << endl;
	}
}


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

const int maxn = 5e3, mod = 1e9 + 7;
int n, sz[maxn + 3], num[maxn + 3], dp[maxn + 3][maxn + 3], f[maxn + 3];
vector<int> G[maxn + 3];

void prework(int n) {
	num[0] = 1;
	for (int i = 2; i <= n; i += 2) {
		num[i] = 1ll * num[i - 2] * (i - 1) % mod;
	}
}

void add(int u, int v) {
	G[u].push_back(v);
}

int func(int x) {
	return x < mod ? x : x -= mod;
}

void dfs(int u, int pa = 0) {
	dp[u][1] = 1;
	sz[u] = 1;
	for (int i = 0, v; i < G[u].size(); i++) {
		v = G[u][i];
		if (v == pa) continue;
		dfs(v, u);
		int m = sz[u] + sz[v];
		for (int j = 1; j <= m; j++) {
			f[j] = 0;
		}
		for (int j = 1; j <= sz[u]; j++) {
			for (int k = 1; k <= sz[v]; k++) {
				f[j + k] = (f[j + k] + 1ll * dp[u][j] * dp[v][k]) % mod;
				f[j] = func(f[j] - 1ll * dp[u][j] * dp[v][k] % mod * num[k] % mod + mod);
			}
		}
		for (int j = 1; j <= m; j++) {
			dp[u][j] = f[j];
		}
		sz[u] += sz[v];
	}
}

int main() {
	scanf("%d", &n);
	prework(n);
	for (int i = 1, u, v; i < n; i++) {
		scanf("%d %d", &u, &v);
		add(u, v), add(v, u);
	}
	dfs(1);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = (ans + 1ll * dp[1][i] * num[i]) % mod;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 97408
#include<bits/stdc++.h>
#define ll long long 
#define int ll
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int32_t main(){
    int H{},W{};    cin>>H>>W;
    for(int i=0;i<H;i++){
        char A[W];
        for(int j=0;j<W;j++){
            cin>>A[j];
            cout<<A[j];
        }
        cout<<endl;
        for(int j=0;j<W;j++){
            cout<<A[j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	string s;
	cin >> s;

	string r_s = s;
	reverse(r_s.begin(), r_s.end());

	int ans = 0;
	for (int i = 0;i < s.length() / 2;i++) {
		if (s[i] != r_s[i]) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3576
//f*ck hideto!!
#include<stdio.h>
int main(void)
{
	int Q,i,y,c,a,n,t;
	scanf("%d",&Q);
	for(i=0;i!=Q;i++){
		t=0;
		scanf("%d%d%d",&c,&a,&n);
		while(1){
			if(c>0&&a>0&&n>0){
				t++;
				c-=1;
				a-=1;
				n-=1;
			}
			else if(c>1&&a>0){
				t++;
				c-=2;
				a-=1;
			}
			else if(c>2){
				t++;
				c-=3;
			}
			else{
			break;
			}
		}
	printf("%d\n",t);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin>>s;
    if(s[0]=='A'){
        int size;
        size=s.size();
        int numofs=0;
        int posofc=0;
        for(int i=2;i<(size-1);i++){
            if(s[i]=='C'){
                numofs++;
                posofc=i;
            }
        }
        if(numofs==1){
            for(int j=1;j<size;j++){
                if(j==posofc){
                    continue;
                }else if(isupper(s[j])!=0){
                    cout<<"WA"<<"\n";
                    return 0;    
                }
            }
            cout<<"AC"<<"\n";
            return 0;
        }
    }
    cout<<"WA"<<"\n";
    return 0;
}

Measured memory_bytes: 256
if __name__=='__main__':
    a,b,c,x,y = map(int,input().split())
    ans = float('inf')

    ans = min(ans,x*a+b*y)
    ans = min(ans,c*2*y+(x-y)*a) if x>y else min(ans,c*2*x+(y-x)*b)
    ans = min(ans,c*2*max(x,y))
    print(ans) 

Measured memory_bytes: 9124
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
int N,M;
int fuga[214514];
int main(){
	cin>>N;
	vector<ll> hoge(N);
	rep(i,N)cin>>hoge[i];
	bool check=true;
	ll ans=0;
	if(hoge[0]!=0)check=false;
	for(int i=0;i<N-1;i++){
		if(hoge[i+1]-hoge[i]> 1)check=false;
		if(hoge[i+1] <= hoge[i])ans+=hoge[i];
	}
	if(check){
		ans+=hoge[N-1];
			  cout<<ans<<endl;
	}else{
		cout<<-1<<endl;
	}
}

Measured memory_bytes: 1792
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 = 1001;
        for(int i = 1; i <= N; i++){
            int c = sc.nextInt();
            int t = sc.nextInt();
            if(t <= T){
                if(c < min){
                    min = c;
                }
            }
        }
        sc.close();
        if(min > 1000){
            System.out.println("TLE");
        }else{
            System.out.println(min);
        }

    }

}


Measured memory_bytes: 21716
import sys
input = sys.stdin.readline
N = int(input())
a = [0] + [int(x) for x in input().split()]

ans = [0 for _ in range(N+1)]
for i in reversed(range(1,N+1)) :
    temp = 0
    for j in range(N//i) :
        temp += ans[(j+1) * i]
    if temp%2 != a[i] :
        ans[i] = 1

print(sum(ans))
ans2 = []
for i in range(N+1) :
    if ans[i] == 1 :
        ans2.append(i)
print(*ans2)


Measured memory_bytes: 14100
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string.h>
using namespace std;
long b[200005];
long a[200005];
long c[200005];
long d[200005];
long int j = 1;
long long sum = 0;
void s()
{
	for (long k = 1; k <= j; k++)
	{
	   sum += (b[c[k]]) * (b[c[k]] - 1) / 2;
	}
}
void f()
{
	for (long i = 1; i <= j; i++)
	{
		d[c[i]] = sum-(b[c[i]]-1);
	}
	return;
}
int main()
{
	long n;
	cin >> n;
	
	for (long int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (b[a[i]] == 0)
		{
			c[j] = a[i];
			j++;
		}
			b[a[i]]++;
	}
	s();
	f();
	for (long i = 1; i <= n; i++)
	{
		cout << d[a[i]] << endl;
	}
		
}

Measured memory_bytes: 7808
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void* x, const void* y) { return *(int*)x - *(int*)y; }
int main() {
	int n, a[100000], ans = 0, cnt, c;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	qsort(a, n, sizeof(int), cmpint);
	for (int i = 0; i < n;) {
		cnt = 0;
		c = a[i];
		while (i < n && a[i] == c) {
			cnt++;
			i++;
		}
		ans += cnt % 2;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 892
<?php

while(1) {
    fscanf(STDIN, "%d %d", $n, $x);
    if ($n === 0 && $x === 0) {
        return;
    }

    $count = 0;
    for ($i = 1; $i <= $n -2; ++$i) {
        for ($j = $i + 1; $j <= $n - 1; ++$j) {
            for ($k = $j + 1; $k <= $n; ++$k) {
                if ($i + $j + $k === $x) {
                    ++$count;
                }
            }
        }
    }
    echo $count, PHP_EOL;
}



Measured memory_bytes: 9204
#include<stdio.h>
int N,S,R[20005],r,i,j;

int main()
{
	for(;scanf("%d%d",&N,&S),N;)
	{
		r=0;
		for(i=0;i<N;i++)scanf("%d",&R[i]);
		for(i=0;i<N;i++)
			for(j=i+1;j<N;j++)
				if(R[i]+R[j]>S)r++;
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll N, Y;
    scanf("%lld %lld", &N, &Y);
    for(ll i=0; 10000*i<=Y; i++){
        for(ll j=0; 5000*j+10000*i<=Y; j++){
            ll k = (Y - 5000*j - 10000*i) / 1000;
            if(i+j+k==N){
                printf("%lld %lld %lld\n", i, j, k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


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

int main(int argc, char* argv[]) {
  queue<int> q;
  int x, y;

  cin >> x >> y;
  while(!(x == 0 && y == 0)){
    q.push(x);
    q.push(y);
    cin >> x >> y;
  }

  while(!q.empty()){
    int a = q.front();
    q.pop();
    int b = q.front();
    q.pop();
    cout << min(a, b) << " " << max(a, b) << endl;
  }

  return 0;
}

Measured memory_bytes: 1236
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll H, W;
  cin >> H >> W;
  ll cost[10][10];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> cost[i][j];
    }
  }
  vector<vector<ll>> A(H);
  ll a;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a;
      A[i].push_back(a);
    }
  }
  vector<ll> min_cost(10);
  min_cost[1] = 0;
  for (int i = 0; i < 10; i++) {
    if (i == 1) continue;
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q;
    vector<vector<bool>> memo(10, vector<bool>(10, false));
    q.push({0, i});
    ll min_c = INF;
    while (!q.empty()) {
      ll cur_pos = q.top().second;
      ll cur_cost = q.top().first;
      q.pop();
      if (cur_pos == 1) {
        min_c = min(min_c, cur_cost);
        continue;
      }
      for (int j = 0; j < 10; j++) {
        if (!memo[cur_pos][j] && j != cur_pos) {
          memo[cur_pos][j] = true;
          q.push({cur_cost + cost[cur_pos][j], j});
        }
      }
    }
    min_cost[i] = min_c;
  }
  ll ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (0 <= A[i][j]) ans += min_cost[A[i][j]];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3944
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N,M,C; scanf("%d %d %d", &N, &M, &C);

	int B[M];
	REP(i,M) scanf("%d", &B[i]);

	int ans = 0;
	REP(i,N){
		int point = C;
		int A;
		REP(j,M){ 
			scanf("%d", &A);
			point += A * B[j];
		}
		if(point > 0) ans++;

	}

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

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    string str="";
    while(n!=0){
        int r=n%2;
        if(r<0) r+=2;

        n=(n-r)/(-2);

        str+=(char)('0'+r);
    }
    reverse(all(str));
    if(str=="") str="0";
    cout<<str<<endl;
}


 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int n;
	cin >> n;

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

	bool flag=false;
	int cnt=0;
	while(true){
		for(int i=0;i<n;i++){
			if(a[i] % 2 == 0) a[i]/=2;
			else flag=true;
		}
		if(flag) break;
		cnt++;
	}
	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define long long long

const long N = 400 + 10;
const long INF = 1e16;

int n;
long f[N][N], s[N];

int main()
{
//    freopen("tam.inp", "r", stdin);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n;
    for (int i = 0; i < N; ++i) fill(f[i], f[i] + N, INF);
    for (int i = 1, x; i <= n; ++i) cin >> x, f[i][i] = 0, s[i] = s[i - 1] + x;

    for (int l = n - 1; l; --l)
        for (int r = l + 1; r <= n; ++r)
            for (int mid = l; mid < r; ++mid)
                f[l][r] = min(f[l][r], f[l][mid] + f[mid + 1][r] + s[r] - s[l - 1]);
    cout << f[1][n];
    return 0;
}


Measured memory_bytes: 1536
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long a = cin.Long();
			long b = cin.Long();

			var ap = GetPrimeFactor(a);
			var bp = GetPrimeFactor(b);

			var set = new HashSet<long>();
			foreach (long app in ap) {
				if (bp.Contains(app)) {
					set.Add(app);
				}
			}

			Console.WriteLine(set.Count() + 1);
		}

		public static HashSet<long> GetPrimeFactor(long value)
		{
			var factors = new HashSet<long>();
			for (long i = 2; i * i <= value; ++i) {
				if (value % i == 0) {
					factors.Add(i);
					while (value % i == 0) {
						value /= i;
					}
				}
			}

			if (value != 1) {
				factors.Add(value);
			}

			return factors;
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

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

int main() {
  int N,K,sum=0;
  cin >> N >> K;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin >> P.at(i);
  }
  sort(P.begin(),P.end());
  for(int i=0;i<K;i++){
    sum+=P.at(i);
  }
  cout << sum << endl;
}
  

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<pair<ll, ll>> vab(n);
  for (int i = 0; i < n; ++i) {
    cin >> vab[i].first >> vab[i].second;
  }

  sort(vab.begin(), vab.end(), [](auto &a, auto &b) {
    return a.first + a.second > b.first + b.second;
  });

  ll a_sum = 0, b_sum = 0;
  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      a_sum += vab[i].first;
    } else {
      b_sum += vab[i].second;
    }
  }

  cout << a_sum - b_sum << '\n';
}

Measured memory_bytes: 4800
N,X=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
  A[i]=abs(X-A[i])
for i in range(N-1):
  while(A[i]>0):
    A[i+1]%=A[i]
    A[i],A[i+1]=A[i+1],A[i]
print(A[N-1])

Measured memory_bytes: 14224
import bisect
n = int(input())
L = sorted([int(i) for i in input().split()])
ans = 0
for b in range(n):
    for a in range(b):
        ab = L[a] + L[b]
        r = bisect.bisect_left(L,ab)
        l = b+1
        ans += max(0,r-l)
print(ans)

Measured memory_bytes: 3316
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

map<ll, ll> m;

ll solve(ll h) {
    if(h==1) return 1;
    if(m[h] != 0) return m[h];
    ll res = 1 + solve(floor(h/2)) + solve(floor(h/2));
    m[h] = res;    
    return res;
}

int main(void){
    ll h;
    cin >> h;
    cout << solve(h) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()

{
    int A,B;
    char op;

    scanf("%d %c %d",&A,&op,&B);

    if(op =='+')
        {
      //  printf("%d op %d",A,B);
        printf("%d",A+B);
        }
    else 
      //  printf("%d op %d",A,B);
        printf("%d",A-B);


}


Measured memory_bytes: 1696
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (1)
    {
       C = C - B;
       if (C <= 0){
           cout << "Yes" << endl;
           break;
       }
       A = A - D;
       if (A <= 0)
       {
           cout << "No" << endl;
           break;
       }

    }
    
    return 0;
}

Measured memory_bytes: 3104
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
struct point{
    double x, y;
};
double get_dist(point a, point b){
    double x = a.x - b.x;
    double y = a.y - b.y;
    return sqrtl(x * x + y * y);
}
void tc(){
    int n, d;
    cin >> n >> d;
    int ans = 0;
    for(int i = 0; i < n; i++){
        point p;
        cin >> p.x >> p.y;
        if(get_dist(p, point{0, 0}) <= d){
            ans++;
        }
    }
    cout << ans;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) tc();
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 3864
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

li table[9][1001][101];

li minsum(li n, li from){
	li res=0;
	repp(i,from,n+from)res+=i;
	return res;
}

li maxsum(li n){
	li res=0;
	for(li i=100; i>100-n; i--)res+=i;
	return res;
}

li solve(li n, li s, li from){
	//p3(n,s,from);
	if(n==1){
		if(s>=from && s<=100)return 1;
		else return 0;
	}
	li res=0;
	repp(i,from,101){
		if(minsum(n-1, i+1)>s-i)res+=0;
		else if(maxsum(n-1)<s-i)res+=0;
		else if(i<100 && table[n-2][s-i][i+1]>0) res+=table[n-2][s-i][i+1];
		else res+=solve(n-1,s-i,i+1);
	}
	table[n-1][s][from]=res;
	return res;
}

int main(){
	li n,s;
	while(1){
		cin>>n>>s;
		if(n==s && n==0)break;
		
		rep(i,n){
			rep(j,s+1){
				rep(k,101)table[i][j][k]=-1;
			}
		}
		
		li res=solve(n,s,0);
		cout<<res<<endl;
	}
	
	return 0;
}

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

int64_t solve(vector<int> v, int n, int k, int sum){
  if(n == v.size() - 1){
    return sum + v.at(0) * pow(10, k);
  }

  return solve(v, n + 1, k + 1, sum + v.at(v.size() - n - 1) * pow(10, k)) +
         solve(v, n + 1, 0, sum + v.at(v.size() - n - 1) * pow(10, k));
}

int main(){
  string S;
  vector<int> V;

  cin >> S;

  for(int i = 0; i < S.size(); i++){
    // 配列の末尾に追加するメソッド
    V.push_back(S.at(i) - '0');
  }

  cout << solve(V, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
struct Card{
  char suit;
  int value;
};

  struct Card L[MAX/2+2],R[MAX/2+2];
void merge(struct Card*,int,int,int,int);

void mergeSort(struct Card*,int,int,int);

int partition(struct Card*,int,int,int);
void quickSort(struct Card*,int,int,int);

int main(){
  int n,i,v;
    struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      scanf("%s%d",S,&v);
      A[i].suit=B[i].suit=S[0];
      A[i].value=B[i].value=v;}
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++)
    {
      if(A[i].suit!=B[i].suit)
	stable=0;}

  if(stable==1)
    printf("Stable\n");
  else
    printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);}
  return 0;}
void merge(struct Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++)
    L[i]=A[left+i];
  for(i=0;i<n2;i++)
    R[i]=A[mid+i];
  L[n1].value=R[n2].value=SENTINEL;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
    }}}

void mergeSort(struct Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);}}

int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }}
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}


void quickSort(struct Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);}}



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

int main()
{
  int z = 0, n, l;
  cin >> n; 
  cin >> l;
  string name[101];
  for(z = 0;z<n;z++)
  {
    cin >> name[z];
  }
  sort(name,name + n);

  for(int y = 0; y < z; y++)
  {
    cout << name[y];
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(n):
    if i == 0:
        s = sum([a[i] if i % 2 == 0 else -a[i] for i in range(n)])
        tmp = s
    else:
        tmp = 2 * a[i-1] - tmp
    ans.append(tmp)
print(*ans)


Measured memory_bytes: 70884
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
int gcd(int a, int b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
int ans = 0;
int s[10][10];
int k[10];
int p[10];
void bit(int m, int n,int d) {
	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			bool w = true;
			rep(i, 0,d ) {
				int x = 0;
				rep(j, 0, k[i])if (now[s[i][j] - 1] == '1')x++;
				if (x%2 != p[i])w = false;
			}
			if(w)ans += 1;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}
;
int main() {
	int n, q;
	cin >> n >> q;
	hei(int) l(n), r(n), a(n,0);
	string s;
	cin >> s;
	rep(i, 0, q) {
		cin >> l[i] >> r[i];
	}
	rep(i, 1, n) {
		if (s[i - 1] == 'A' && s[i] == 'C')a[i]++;
		a[i] += a[i - 1];
	}
	rep(i, 0, q) {
		int ans = a[r[i] - 1] - a[l[i] - 1];
		cout << ans << endl;
	}
	 return 0;

}

Measured memory_bytes: 2176
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<ll>;


ll MOD = 1000000007;


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

	vec A(N);
	int total=0;

	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		total += A[i];
	}

	for (int G = total; G > 0; --G)
	{
		if (total%G != 0) { continue; }
		//cout << G << endl;
		vec M(N);
		bool flag = true;
		for (int i = 0; i < N; ++i)
		{
			M[i] = A[i] % G;
			if (M[i] != 0)flag = false;
		}
		if(flag)
		{
			cout << G << endl;
			return 0;
		}

		sort(M.begin(), M.end());

		vec sum1(N), sumR(N);

		sum1[0] = M[0];
		sumR[N - 1] = G-M[N - 1];
		for (int i = 1; i < N; ++i)
		{
			sum1[i] = M[i] + sum1[i - 1];
			int r = N - i - 1;
			sumR[r] = G-M[r] + sumR[r + 1];

		}
		/*
		for(ll i=0;i<N;++i)
		{
			cout << sum1[i] << " ";
		}cout << endl;
		for (ll i = 0; i<N; ++i)
		{
			cout << sumR[i] << " ";
		}cout << endl;
		*/
		for (int i = 0; i < N-1; ++i)
		{
			if (sum1[i] == sumR[i+1])
			{
				//cout << sum1[i] << " ";
				if (sum1[i] <= K)
				{
					cout << G << endl;
					return 0;
				}
				
			}
		}
		//cout << endl;
	}

	cout << 1 << endl;

	return 0;
}

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

namespace atpra101A
{
    class Class1{
        static void Main()
        {
            string x = Console.ReadLine();
            int sum = 0;
            for (int i = 0; i < x.Length; i++)
            {
                if (x[i] == '+') sum++;
                else sum--;
            }
            Console.Write(sum);
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    string s;
    int k;
    int cnt=1;
    string ans;
    map<string,int> sub;
    cin >> s >> k;
    rep(i,s.size()){
        if(i>5) break;
        for(int j=i; j<s.size(); j++){
            string S = s.substr(j-i,i+1);
            sub[S]++;
        }
    }
    for(auto c:sub){
        if(cnt == k) ans=c.first;
        cnt++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5172
#include <iostream>

using namespace std;

int
main()
{
  int b, m, sum;
  int N;
  sum = 0;
  m = 0;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> b;
    if (b > m) {
      sum += m;
      m = b;
    } else {
      sum += b;
    }
  }
  if (sum > m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256