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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  string a, b;
  cin >> a >> b;
  int aa, bb;
  cin >> aa >> bb;
  string u;
  cin >> u;
  if (u == a) {
    cout << aa-1 << " " << bb << endl;
  }else {
    cout << aa << " " << bb-1 << endl; 
  }
}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  vector<char> S(N);
  bool ans = false;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  for(int i = 0; i < N; i++) {
    if(S.at(i) == 'Y') {
      ans = true;
      break;
    }
  }
  if(ans) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }

  return 0;
}

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

int main(){
  int n; cin>>n;
  string s; cin>>s;
  vector<int> b(n+1,0),w(n+1,0);
  for(int i=1;i<=n;i++){
    if(s[i-1]=='#') b[i]=b[i-1]+1;
    else b[i]=b[i-1];
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]=='.') w[i]=w[i+1]+1;
    else w[i]=w[i+1];
  }int ans=b[0]+w[0];
  for(int i=0;i<=n;i++){
    ans=min(ans,b[i]+w[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2180
#include <iostream>
#include <random>
#include <cmath>
#include <cstring>
using namespace std;

int c[27], s[366][27], t[366], last[27], bestT[366];
int main()
{
    int D; cin>>D;
    for(int i=1; i<=26; ++i) cin>>c[i];
    for(int i=1; i<=D; ++i)
        for(int j=1; j<=26; ++j)
            cin>>s[i][j];

    auto calc_score=[&](){
        long score=0;
        for(int i=1; i<=26; ++i) last[i]=0;
        for(int d=1; d<=D; ++d) {
            score+=s[d][t[d]];
            last[t[d]]=d;
            for(int i=1; i<=26; ++i) score-=c[i]*(d-last[i]);
        }
        return score;
    };

    for(int i=1; i<=D; ++i) {
        long bestscore=-(1L<<60), typ=1;
        for(int j=1; j<=26; ++j) {
            t[i]=j;
            auto score=calc_score();
            t[i]=0;
            if (bestscore<score) {
                bestscore=score;
                typ=j;
            }
        }
        t[i]=typ;
    }

    mt19937 engine;
    uniform_int_distribution<> rndT(1, 26), rndD(1, 365);
    uniform_real_distribution<> rndS(0.0, 1.0);
    auto bestscore=calc_score();
    memcpy(bestT, t, sizeof(t));

    const double cool=0.99;
    double temp=1.0;
    for(int A=100000; A--; ) {
        int d=rndD(engine);
        int q=rndT(engine);
        int x=t[d];
        t[d]=q;
        auto score=calc_score();
        auto sa=exp((score-bestscore)/temp)<rndS(engine);
        if (sa or bestscore<score) {
            if (bestscore<score) {
                bestscore=score;
                memcpy(bestT, t, sizeof(t));
            }
        }
        else {
            t[d]=x;
        }
        temp*=cool;
    }
    for(int i=1; i<=D; ++i) cout<<bestT[i]<<endl;
//    cout<<bestscore<<endl;
}


Measured memory_bytes: 3876
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
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;
}
using namespace std;
int main(){ 
   int n;
   cin>>n;
   int ans=1;
   for(int ans=1;ans<=n;ans*=2){
      if(ans*2>n) cout<<ans;
      
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) (a).begin(),(a).end()
#define ms(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10) 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge{ int from, to, cost; };

string s;

int main()
{
	cin >> s;
	bool f = true;
	if (s[0] == 'm') s.erase(0, 1);
	else f = false;
	if (s[s.size() - 1] == 'w') s.erase(s.size() - 1, 1);
	else f = false;

	while (1)
	{
		if (s == "e") break;
		else
		{
			if (s.find("mew") != -1)
			{
				int i = s.find("mew");
				s.erase(i, 3);
			}
			else
			{
				f = false;
				break;
			}
		}
	}
	if (f) cout << "Cat" << endl;
	else cout << "Rabbit" << endl;
	return 0;
}

Measured memory_bytes: 1212
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Collectors;

public class Main {

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

        int N = sc.nextInt(), K = sc.nextInt();
        ArrayList<Integer> arr = new ArrayList<>();
        for(int i = 0; i < N; i++) arr.add(sc.nextInt());

        int ret = 0;
        for(int a : arr) {
            if(a >= K)
                ret += 1;
        }

        System.out.println(ret);
    }
}
//[B@25618e91
//[B@326de728
//

Measured memory_bytes: 60556
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vector<T>>;

constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
    if (b <= 0) { return 1; } if (b == 1) { return a % mod; } if (b == 2) { return (a * a) % mod; }
    return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
}
constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
    return (a * mpow(b, mod - 2, mod)) % mod;
}

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

    int a = 0, b = 0, c = 0;
    while (n--) {
        int d; cin >> d;
        a += d % 4 == 0;
        b += d % 2 == 0 && d % 4 != 0;
        c += d & 1;
    }

    if (a + 1 < c || ((c - a) == 1 && b != 0)) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}



Measured memory_bytes: 3664
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,l = map(int,readline().split())
lst1 = list(map(int,readline().split()))

res = -1

for i in range(n-1):
    if lst1[i]+lst1[i+1] >= l:
        res = i

if res == -1:
    print("Impossible")
    exit()
else:
    print("Possible")

ans = []
for i in range(res):
    ans.append(i)
for j in range(n-2,res,-1):
    ans.append(j)
ans.append(res)

for i in ans:
    print(i+1)


Measured memory_bytes: 92128
#include<iostream>
using namespace std;
char s[1000001];
int main()
{
	int i, j;
	int cnt_j, cnt_o, cnt_i;
	int max=0;
	cin >> s;
	for (i = 0;s[i] != '\0';i++)
	{
		if (s[i] == 'J')
		{
			cnt_j = 0;
			while (s[i] == 'J')
			{
				cnt_j++;
				i++;
			}
			if (max >= cnt_j)
			{
				i--;
				continue;
			}
			cnt_o = 0;
			while (s[i] == 'O')
			{
				cnt_o++;
				i++;
			}
			if (cnt_j < cnt_o)
			{
				i--;
				continue;
			}
			if (max >= cnt_o)
			{
				i--;
				continue;
			}
			cnt_i = 0;
			while (s[i] == 'I')
			{
				cnt_i++;
				i++;
			}
			if (cnt_i < cnt_o)
			{
				i--;
				continue;
			}
			max = cnt_o;
			i--;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 4068
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<vector<int> > ball(2, vector<int>(n + 1, -1));
  FOR(i, 1, n * 2 + 1) {
    char c; int a; cin >> c >> a;
    ball[c == 'W'][a] = i;
  }
  // FOR(j, 1, n + 1) cout << ball[0][j] << " \n"[j == n];
  // FOR(j, 1, n + 1) cout << ball[1][j] << " \n"[j == n];
  vector<vector<int> > black(n + 1, vector<int>(n * 2 + 1, 0));
  FOR(j, 1, n + 1) FOR(i, j, n + 1) ++black[i][ball[0][j]];
  FOR(i, 1, n + 1) FOR(j, 1, n * 2 + 1) black[i][j] += black[i][j - 1];
  // REP(i, n + 1) REP(j, n + 1) cout << black[i][j] << " \n"[j == n];
  vector<vector<int> > white(n + 1, vector<int>(n * 2 + 1, 0));
  FOR(j, 1, n + 1) FOR(i, j, n + 1) ++white[i][ball[1][j]];
  FOR(i, 1, n + 1) FOR(j, 1, n * 2 + 1) white[i][j] += white[i][j - 1];
  vector<vector<int> > dp(n * 2 + 1, vector<int>(n + 1, INF));
  dp[0][0] = 0;
  REP(i, n * 2) REP(j, n + 1) {
    if (j > i) continue;
    int w = i - j;
    if (w > n) continue;
    if (j + 1 <= n) {
      int pos = ball[0][j + 1];
      chmin(dp[i + 1][j + 1], dp[i][j] + black[j][n * 2] - black[j][pos] + white[w][n * 2] - white[w][pos]);
    }
    if (w + 1 <= n) {
      int pos = ball[1][w + 1];
      chmin(dp[i + 1][j], dp[i][j] + black[j][n * 2] - black[j][pos] + white[w][n * 2] - white[w][pos]);
    }
  }
  cout << dp[n * 2][n] << '\n';
  return 0;
}


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

int main(){
    int a,b,c,k; cin >> a >> b >> c >> k;
    int maxa = a,maxb = b,maxc = c;
    for(int i=0;i<k;i++){
        maxa *= 2;
        maxb *= 2;
        maxc *= 2;
    }
    maxa += b+c; maxb += c+a; maxc += a+b;
    cout << max(max(maxa,maxb),maxc) << endl;
}


Measured memory_bytes: 256
n, y = map(int, input().split())

a, b, c = -1 ,-1, -1
for i in range(n + 1):
    for j in range(n +1 - i):
        k = n - i - j
        total = 10000 * i + 5000 * j + 1000 * k
        if total == y:
            a = i
            b = j 
            c = k
print('{} {} {}'.format(a, b, c))


Measured memory_bytes: 3060
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    int64_t n;
    cin >> n;
    vector<int64_t> p(n);
    vector<int64_t> d(n);
    vector<int64_t> v(n);
    int64_t max = 0;
    for (int64_t i = 0; i < n; ++i) {
        v[i] = 0;
    }
    for (int64_t i = 0; i < n; ++i) {
        cin >> d[i];
        v[d[i]]++;
        if (d[i] > max) {
            max = d[i];
        }
    }
    if (d[0] != 0 || v[0] != 1) {
        std::cout << 0 << endl;
        return 0;
    }
    int64_t cur = 1;
    for (int64_t i = 1; i <= max; ++i) {
        int64_t tmp = 0;
        if (v[i] == 0) {
            cur = 0;
            break;
        }
        for (int64_t j = 0; j < v[i]; ++j) {
            cur = (cur * v[i-1]) % 998244353;
        }
    }
    cout << cur << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int c[3][3];
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			cin >> c[i][j];
		}
	}
	bool yes = true;
	for(int d=0; d<2; d++){
		for(int i=0; i<2; i++){
			int diff = c[0][i]-c[0][i+1];
			if(diff != c[1][i]-c[1][i+1] || diff != c[2][i]-c[2][i+1]){
				yes = false;
			}
		}
		swap(c[1][0], c[0][1]);
		swap(c[0][2], c[2][0]);
		swap(c[1][2], c[2][1]);
	}
	if(yes){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a_n = list(map(int, input().split()))
cnt = 0

for i in range(n):
    if (sum(a_n) / (4 * m)) <= a_n[i]:
        cnt += 1

if m <= cnt:
    print('Yes')
else:
    print('No')


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

const long long MOD=1000000007;

int main(void){
  int N;
  long A[200001];
  cin >> N;
  for (int i=0; i<N; i++){
    cin >> A[i];
  }
  
  long long sum=0;
  long long dsum=0;
  for (int i=0; i<N; i++){
    sum += A[i];
    dsum += A[i] * A[i];
    sum = sum % MOD;
    dsum = dsum % MOD;
  }
  
  long long all = sum*sum-dsum;
  long long ans;
  
  if (all % 2 == 0){
    ans = all / 2;
  }
  else{
    ans = (all + MOD)/2;
  }
  ans = ans % MOD;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4748
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] ary = new int[n];

        int count = 0;
        for(int i=0; i<n; i++){
            int temp = sc.nextInt();
            if(temp%2==1 && i%2==0){
                count++;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 35972
k, n = map(int, input().split())
l = list(map(int, input().split()))
d = [0] * n
for i in range(n):
    if i == n - 1:
        d[i] = k - l[-1] + l[0]
    else:
        d[i] = l[i + 1] - l[i]
print(k - max(d))

Measured memory_bytes: 32380
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int A[101];
    A[0]=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A,A+N);
    cout<<A[N-1]-A[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def lcm(a, b):
    return a * b // gcd(a, b)


num = T[0]
for i in range(1, N):
    num = lcm(num, T[i])

print(num)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        ll k;cin>>k;
        ll ans=1;
        priority_queue<ll,vector<ll>,greater<ll> > q;
        map<ll,ll> m;
        for(ll i=1;i<=9;i++)q.push(i),m[i]=1;
        while(k--){
            ll n=q.top();q.pop();
            ans=n;
            q.push(n*10+n%10);
            if(n%10!=9)
            q.push(n*10+n%10+1);
            if(n%10!=0)
            q.push(n*10+n%10-1);
        }

        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 2420
/**********************************

Sometimes the people whom no one ever imagines anything of,
do the things that no one can ever imagine.

***********************************/
#include <bits/stdc++.h>
using namespace std;

#define EPS (1e-12)
#define ll long long int
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pi 3.141592653589
#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define precise(n) cout << fixed << setprecision(n)
#define pcase cout<<"Case "<<++cs<<": "
const int mod=1e9+7;
ll gcd(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}



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

      cout << b+b-1 << endl;

      }



      return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n=s.size();
  int p=0;
  for(int i=0;i<n;i++){
    if(s[i]=='p'){
      p++;
    }
  }
  cout << n/2-p << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;

//typedef long long int;
int N, W;
map<pair<int, int> , int> dp; //<i番目まで見たときの重さに対する価値の最大値>
vector<int> w, v;

int func(int, int);
int main(){
  cin >> N >> W;
  int wt, vt;
  w.push_back(0); v.push_back(0);
  for(int i=1; i<=N; i++) {
    cin >> wt >> vt;
    w.push_back(wt);
    v.push_back(vt);
  }

  int ans=func(N, W);

  cout << ans << endl;

  return 0;
}

int func(int i, int j){
  pair<int, int> tmp = make_pair(i, j);
  if(dp.find(tmp)==dp.end()){
    if(i==0 || j==0){
      return dp[tmp]=0;
    }
    else if(j<w[i]){
      return dp[tmp]=func(i-1, j);
    }
    else{
      return dp[tmp]=max(func(i-1, j), func(i-1, j-w[i])+v[i]);
    }
  }
  else{
    return dp[tmp];
  }
}


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

const int maxn = 5005;

int n, k;

int a[maxn];

bool pre[maxn][maxn];
long long suf[maxn][maxn];

int main(int argc, const char * argv[]) {
	cin >> n >> k;
	long long sum = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
		sum += a[i];
	}
	memset(pre, false, sizeof(pre));
	memset(suf, false, sizeof(suf));
	pre[0][0] = true;
	suf[n + 1][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = k; j >= 0; j--) {
			pre[i][j] |= pre[i - 1][j];
			if (j >= a[i])pre[i][j] |= pre[i - 1][j - a[i]];
		}
	}
	for (int i = n; i >= 1; i--) {
		for (int j = k; j >= 0; j--) {
			suf[i][j] = suf[i + 1][j];
			if (j >= a[i]) suf[i][j] |= suf[i + 1][j - a[i]];
		}
	}
	for (int i = n + 1; i >= 1; i--) {
		for (int j = 0; j <= k; j++) {
			if (j == 0) continue;
			suf[i][j] += suf[i][j - 1];
		}
	}
	int ans = n;
	for (int i = 1; i <= n; i++) {
		bool flag = false;
		for (int j = 0; j <= k - 1; j++) {
			if (pre[i - 1][j] && ((suf[i + 1][k - 1 - j] - ((k - 1 - a[i] - j) >= 0 ? suf[i + 1][k - 1 - a[i] - j] : 0)) > 0)) { flag = true; }
		}
		if (flag) ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 220416
#include<stdio.h>
#include<string.h>
int main(){
  int i,j,n;
  char str[21],tmp[21];
  scanf("%s",str);
  n=strlen(str);
  for(i=n-1 ; i>=0 ; i--){
    printf("%c",str[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 524
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::{max, min};
use std::collections::HashMap;
fn main(){
    input!{
        n:usize,
        an:[i64;n],
    }
    let ans = an.iter().fold(0,|y,x| y+x-1);
    println!("{}",ans);
}
// fn gcd(a:i64,b:i64) -> i64{
//     if b == 0 { return a; }
//     gcd(b, a%b)
// }
// fn lcm(a:i64,b:i64) -> i64{
//     (a*b) / gcd(a, b)
// }

Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    if(A==B){
        cout << "Draw" << endl;
    }
    else if(A==1 && B!=1){
        cout << "Alice" << endl;
    }
    else if(A!=1 && B==1){
        cout << "Bob" << endl;
    }
    else if(A>B){
        cout << "Alice" << endl;
    }
    else if(A<B){
        cout << "Bob" << endl;
    }
}

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

int main(){
  long long A,B,K;
  cin >> A >> B >> K;
  long long taka,aoki;
  taka=A-K;
  aoki=B;
  if(taka<0){
    aoki+=taka;
    if(aoki<0){
      aoki=0;
    }
    taka=0;
  }
  cout << taka << " " << aoki << endl;
}

Measured memory_bytes: 256
h,w,d=map(int,input().split())
grid=[None]*(h*w)
for i in range(h):
    *a,=map(int,input().split())
    for j in range(w):
        grid[a[j]-1]=(i,j)

mp=[[0] for i in range(d)]

for i in range(d):
    tmp=i
    while tmp+d<h*w:
        x=abs(grid[tmp+d][0]-grid[tmp][0])+abs(grid[tmp+d][1]-grid[tmp][1])
        mp[i].append(x+mp[i][-1])
        tmp+=d
q=int(input())
for _ in range(q):
    l,r=map(int,input().split())
    l,r=l-1,r-1
    tmp=mp[r%d][(r-(r%d))//d]-mp[l%d][(l-(l%d))//d]
    print(tmp)

Measured memory_bytes: 90984
#include <stdio.h>
#include <iostream>
using namespace std;
int main(void)
{
  int x,t,a;
  cin>>x>>t;
  a=x-t;
  if (a>0)
  {
    cout<<a;
  }
  else
  {
    cout<<0;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
#define int long long
int a[54];
int pasc[54][54];
void cal() {
	pasc[0][0] = 1;
	for (int i = 0; i <= 50; i++) {
		for (int j = 0; j <= i; j++) {
			pasc[i + 1][j] += pasc[i][j];
			pasc[i + 1][j + 1] += pasc[i][j];
		}
	}
	return;
}

signed main() {
	int n, p;
	cin >> n >> p;
	for (int i = 0; i < n; i++)cin >> a[i];
	int e = 0, o = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] & 1)e++;
		else o++;
	}
	cal();
	int ans = 0;
	for (int i = p; i <= e; i += 2) {
		for (int j = 0; j <= o; j += 1) {
			ans += pasc[e][i] * pasc[o][j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

vector<bool> add(vector<bool>& a, vector<bool>& b) {
	vector<bool> c(256);
	for (int i = 0; i < 256; i++)
		for (int j = 0; j < 256; j++)
			if (a[i] && b[j])
				c[(i + j) % 256] = true;
	return c;
}

vector<bool> sub(vector<bool>& a, vector<bool>& b) {
	vector<bool> c(256);
	for (int i = 0; i < 256; i++)
		for (int j = 0; j < 256; j++)
			if (a[i] && b[j])
				c[(i - j + 256) % 256] = true;
	return c;
}

vector<bool> mul(vector<bool>& a, vector<bool>& b) {
	vector<bool> c(256);
	for (int i = 0; i < 256; i++)
		for (int j = 0; j < 256; j++)
			if (a[i] && b[j])
				c[(i * j) % 256] = true;
	return c;
}

vector<bool> div(vector<bool>& a, vector<bool>& b) {
	vector<bool> c(256);
	for (int i = 0; i < 256; i++)
		for (int j = 0; j < 256; j++)
			if (a[i] && b[j])
				c[(i / j) % 256] = true;
	return c;
}

int main() {
	int m; cin >> m;
	vector<string> name(m);
	vector<int> lb(m), ub(m);
	for (int j = 0; j < m; j++)
		cin >> name[j] >> lb[j] >> ub[j];
	stack< vector<bool> > s;
	int n; cin >> n;
	while (n--) {
		string e; cin >> e;
		if (e == "+") {
			vector<bool> b = s.top(); s.pop();
			vector<bool> a = s.top(); s.pop();
			s.push(add(a, b));
		}
		else if (e == "-") {
			vector<bool> b = s.top(); s.pop();
			vector<bool> a = s.top(); s.pop();
			s.push(sub(a, b));
		}
		else if (e == "*") {
			vector<bool> b = s.top(); s.pop();
			vector<bool> a = s.top(); s.pop();
			s.push(mul(a, b));
		}
		else if (e == "/") {
			vector<bool> b = s.top(); s.pop();
			vector<bool> a = s.top(); s.pop();
			if (b[0]) {
				cout << "error" << endl;
				return 0;
			}
			s.push(div(a, b));
		}
		else {
			vector<bool> a(256);
			int _j = -1;
			for (int j = 0; j < m; j++)
				if (name[j] == e) _j = j;
			if (_j == -1) {
				int i = stoi(e);
				a[i] = true;
			}
			else {
				for (int i = lb[_j]; i <= ub[_j]; i++)
					a[i] = true;
			}
			s.push(a);
		}
	}
	cout << "correct" << endl;
}

Measured memory_bytes: 1248
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int GCD(int a,int b)
{
  int r, tmp;
   /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


long long int Svec(vector<long long int> v){
  long long int n=0;
  for(long long int i=0;i<v.size();i++) n+=v[i];
  return n;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  long long int n,left=0,right=0,ans=2000000001;
  cin>>n;
  vector<long long int> v(n);
  rep(i,n) cin>>v[i];
  
  right=Svec(v)-v[0];
  left=v[0];
  rep(i,n-1){
    ans=min(ans,abs(right-left));
    right-=v[i+1];
    left+=v[i+1];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define fi first
#define se second
typedef pair<pair<int,int>, pair<int,int> > Rect;

vector<string> img;
map<char, Rect> item;
int t, H, W;

bool ok(Rect r, char c) {
	for (int i=r.se.fi; i<=r.se.se; ++i) {
		for (int j=r.fi.fi; j<=r.fi.se; ++j) {
			if (img[i][j] != c && img[i][j] != '#') {
				return false;
			}
		}
	}
	return true;
}

void fill(Rect r, char c) {
	for (int i=r.se.fi; i<=r.se.se; ++i) {
		for (int j=r.fi.fi; j<=r.fi.se; ++j) {
			img[i][j] = c;
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin >> t;
	while (t--) {
		cin >> H >> W;
		img.resize(H);
		for (int i=0; i<H; ++i) {
			cin >> img[i];
		}
		for (int i=0; i<H; ++i) {
			for (int j=0; j<W; ++j) {
				char c = img[i][j];
				if (c != '.') {
					if (item.count(c) == 0) {
						item[c] = make_pair(make_pair(j, j), make_pair(i, i));
					} else {
						item[c].fi.fi = min(item[c].fi.fi, j);
						item[c].fi.se = max(item[c].fi.se, j);
						item[c].se.fi = min(item[c].se.fi, i);
						item[c].se.se = max(item[c].se.se, i);
					}
				}
			}
		}
		map<char, Rect>::iterator it = item.begin();
		while (it != item.end()) {
			char c = (*it).fi;
			Rect r = (*it).se;
			if (ok(r, c)) {
				fill(r, '#');
				item.erase(c);
				it = item.begin();
				continue;
			}
			++ it;
		}
		bool safe = item.empty();
		cout << (safe ? "SAFE" : "SUSPICIOUS") << endl;
		item.clear();
	}
	return 0;
}

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

int main()
{
	long long A[128][128], B[128][128], C[128][128];
	int N, M, L;
	cin >> N >> M >> L;
	
	for(int i = 0; i < N; ++i)
	{
		for(int j = 0; j < M; ++j)
		{
			cin >> A[i][j];
		}
	}
	
	for(int i = 0; i < M; ++i)
	{
		for(int j = 0; j < L; ++j)
		{
			cin >> B[i][j];
		}
	}
	
	for(int i = 0; i < N; ++i)
	{
		for(int j = 0; j < L; ++j)
		{
			C[i][j] = 0;
			for(int k = 0; k < M; ++k)
			{
				C[i][j] += A[i][k] * B[k][j];
			}
			
			if(j != 0)
			{
				cout << " ";
			}
			cout << C[i][j];
		}
		cout << endl;
	}

    return 0;
}



Measured memory_bytes: 3272
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

int main(void){
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  rep(i, N)
    cin >> H[i];

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

  long int count = 0;
  rep(i, N-K)
    count += H[i];

  cout << count << endl;
  
  return 0;
}


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

int main(){
  int n; cin >> n;
  vector<int> L(n);
  
  for(int i = 0; i < n; i++){
    cin >> L.at(i);
  }
  
  sort(L.begin(), L.end());
  int64_t cnt = 0;
  int a, b, c;
  for(int i = 0; i < n - 2; i++){
    a = L.at(i);
    for(int j = i + 1; j < n - 1; j++){
      b = L.at(j);
      for(int k = n - 1; k > j; k--){
        c = L.at(k);
        if(a < b + c && b < c + a && c < a + b){
          cnt++;
        }else if(a >= b + c || b >= c + a){
          break;
        }
      }
    }
  }
  
  cout << cnt << endl;
  
  
}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    cin >>n;
    vector<ll> x(n);
    rep(i,0,n) cin >> x[i];

    ll ans(LL_MAX);

    rep(i,1,101)
    { 
        ll cur(0);
        rep(j,0,n)
        {
            cur += (ll)pow(x[j]-i, 2);
        }
        ans = min(ans, cur);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read() for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
S = input()
K = read_a_int()

target = S[K-1]

ans = []
for i in range(N):
    if S[i] != target:
        ans.append('*')
    else:
        ans.append(target)

print(*ans, sep="")


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<stack>
using namespace std;
int main() {
    
    stack<int> num;
    while (1) {
        string in;
        cin >> in;
        if (in == "+" || in == "-" || in == "*") {
            int a, b;
            b = num.top();
            num.pop();
            a = num.top();
            num.pop();
            if (in == "+")num.push(a + b);
            if (in == "-")num.push(a - b);
            if (in == "*")num.push(a * b);
        }
        else if (cin.eof())break;
        else num.push(stoi(in));
    }
    cout << num.top() << endl;
    return 0;
}


Measured memory_bytes: 3136
#include<stdio.h>
#include<string.h>

int main(){
  int i,j,k=0;
  char A[256];
  scanf("%s",A);
  
  for(i=0;i<strlen(A);i++){
    k += A[i] - '0';
  }
  
  if(atoi(A)%k == 0){
    puts("Yes");
    return 0;
  }
  
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    int n;
    int key, p=0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    int min;
    for(int i=0;i<n;i++) {
        min = i;
        for(int j=i;j<n;j++) {
            if(a[j] < a[min]) min = j;
        }
        if(i != min) {
            key = a[min];
            a[min] = a[i];
            a[i] = key;
            p++;
        }
    }
    for(int i=0;i<n;i++) {
        cout << a[i];
        if(i == n-1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
    cout << p << endl;
}

Measured memory_bytes: 3080
li = input().split()
n = int(li[0])
m = int(li[1])
# IDカードn枚，　ゲートm個
# i番目のゲートはl~rのIDカードを持っていれば通過できる
l_r = [input().split() for i in range(m)]
l_r.sort(key=lambda x:int(x[0]))
l_max = int(l_r[-1][0])
l_r.sort(key=lambda x:int(x[1]))
r_min = int(l_r[0][1])
answer = 0
# for i in range(n):
#     if l_max <= i + 1 and i + 1 <= r_min:
#         answer += 1
diff = r_min - l_max + 1
if diff > 0:
    print(diff)
else:
    print(0)

Measured memory_bytes: 36992
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s>>k;
    rep(i,Size(s)){
        if(s[i]=='1')cnt++;
        else break;
    }
    if(cnt>=k)Cout(1);
    else{
        rep(i,Size(s)){
            if(s[i]!='1'){
                Cout(s[i]);
                return 0;
            }
        }
    }
    return 0;
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 11111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
    set < int > s;
    int n  , x;
    cin >> n ;
    while(n--) {
        cin >> x ;
        s.insert(x) ;
    }
    cout <<(int)s.size() << endl ;
    return 0 ;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
digit = [list(map(int, input().split())) for _ in range(m)]

for i in range(10**n):
  tmp = str(i)
  if len(tmp) == n:
    flag = True
    for s, c in digit:
      if tmp[s-1] != str(c):
        flag = False
        break
    if flag:
      print(i)
      exit()
print(-1)
  


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define pi 3.14159265359
int INF = 1000000000;

int main() {
  string S; cin >> S;
  if (S == "Sunny") cout << "Cloudy" << endl;
  else if (S == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	int n, a[110], i, j, Alice=0, Bob=0, tmp;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", a + i);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < n - i - 1; j++) {
			
			if (a[j] < a[j + 1]) {
				tmp = a[j];
				a[j] = a[j + 1];
				a[j + 1] = tmp;
			}
		}
	}

	for (i = 0; i < n; i++) {
		if (i % 2 == 0) {
			Alice += a[i];
		}
		else {
			Bob += a[i];
		}
	}

	printf("%d", Alice - Bob);
	
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main()
{
  long long int N,x,ans=0;
  cin>>N>>x;
  vector <long long int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(i==0){
      if(A[i]>x){
	ans+=A[i]-x;
	A[i]=x;
      }
    }
    if(i!=0){
      if(A[i]+A[i-1]>x){
       ans+=A[i]+A[i-1]-x;
       A[i]=x-A[i-1];
      }
    }
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int number(char c){
	if(c>='0'&&c<='9')
	return (c-'0');
	else
		return 0;
}
int main(){
	int n;
	cin>>n;
	
	while(n>0){
		string a;
		string b;
	int k=0;
	int c=0;
	string s="";
	
		cin>>a;
		cin>>b;
		
	
	for(int i=a.length()-1,j=b.length()-1;i>=0||j>=0;i--,j--){
		int d;
		int n1=0,n2=0;
		if(i>=0)
			n1=number(a[i]);
		if(j>=0)
			n2=number(b[j]);
		d=n1+n2+k;
		k=d/10;
		d=d%10;
		s=to_string(d)+s;
	}
		if(k>0)
		s=to_string(k)+s;
	
	if(s.length()>80)
		cout<<"overflow"<<endl;
	else
		cout<<s<<endl;
		n--;
	}
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e18;
const int mod = 1e9 + 7;

signed main() {
    int N;
    cin >> N;
    vector<int> a(N), idx(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        --a[i];
        idx[a[i]] = i;
    }
    int ans = 0;
    set<int> S;
    for (int i = N - 1; i >= 0; i--) {
        int inidx = idx[i];
        S.insert(inidx);
        auto itr = S.find(inidx);
        vector<int> left(2, -1), right(2, N);
        for (int j = 0; j < 2; j++) {
            if (itr == S.begin()) break;
            --itr;
            left[j] = *itr;
        }
        itr = S.find(inidx);
        for (int j = 0; j < 2; j++) {
            ++itr;
            if (itr == S.end()) break;
            right[j] = *itr;
        }
        left[1] = left[0] - left[1];
        left[0] = inidx - left[0];
        right[1] = right[1] - right[0];
        right[0] = right[0] - inidx;
        int c = left[0] * right[1] + left[1] * right[0];
        ans += c * (i + 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6528
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

LL N;
vector<LL>a;
//x回でできるか？
bool cond(LL x, vector<LL>A)
{
	for (LL&elm : A)elm += x;
	LL cnt = 0;
	for (LL elm : A)
	{
		elm -= (N - 1);
		if (elm <= 0)continue;
		cnt += (elm - 1) / (N + 1) + 1;
	}
	return cnt <= x;
}

int main(void)
{
	cin >> N;
	LL sum = 0;
	for (int i = 0; i < N; ++i)
	{
		LL aa; cin >> aa;
		a.push_back(aa);
		sum += (aa - (N - 1));
	}
	if (cond(0, a))
	{
		cout << 0 << endl;
		return 0;
	}
	LL small = sum;
	small = max(small, 0LL);
	for (LL x = small; true; ++x)
	{
		if (cond(x, a))
		{
			cout << x << endl;
			return 0;
		}
	}
	return 0;
}


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

double x,y;

void treasure(void){
  double tmp;
  tmp = acos( x/sqrt(x*x+y*y) );
  if(y<0.0)tmp *= -1.0;;
  x += cos(tmp + M_PI/2);
  y += sin(tmp + M_PI/2);
}

int main(void){
  int i;
  int n;

  while(1){
    scanf("%d",&n);
    if(n<0)break;

    x = 1.0;
    y = 0.0;
    for(i=0;i<n-1;i++)treasure();

    printf("%lf\n%lf\n",x,y);
  }

  return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int[] arg =new int[100];
        int i=0,sum=0,tate=0,yoko=0;
        int[] atari=null;
        boolean first=true;

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	String[] str=line.split(" ");
            	if(first){
            		tate=Integer.parseInt(str[0]);
            		yoko=Integer.parseInt(str[1]);
            		first=false;
            	}else{
            		String[] cloud=new String[yoko];
            		i++;
            		int time=-1;
            		boolean cl=false;
            		for(int k=0;k<cloud.length;k++){
            			if(line.substring(k,k+1).equals("c")){
            				cloud[k]="0";
            				time=0;
            				cl=true;
            			}else if(cl){
            				time++;
            				cloud[k]=String.valueOf(time);
            			}else{
            				cloud[k]=String.valueOf(time);
            			}
            		}
            		System.out.println(String.join(" ", cloud));
            		if(tate==i){
            			break;
            		}
            	}
            }
        }
	}

}

Measured memory_bytes: 27884
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int h = sc.nextInt();
        int w = sc.nextInt();
        int m = sc.nextInt();
        int[][] arr = new int[m][2];
        int[] cntH = new int[h];
        int[] cntW = new int[w];
        for (int i=0; i<m; i++) {
            arr[i][0] = sc.nextInt() - 1;
            arr[i][1] = sc.nextInt() - 1;
            cntH[arr[i][0]]++;
            cntW[arr[i][1]]++;
        }

        Pair[] pairH = new Pair[h];
        Pair[] pairW = new Pair[w];

        int maxhCnt = 0;
        for (int i=0; i<h; i++) {
            maxhCnt = Math.max(maxhCnt, cntH[i]);
        }
        int maxWCnt = 0;
        for (int i=0; i<w; i++) {
            maxWCnt = Math.max(maxWCnt, cntW[i]);
        }


        for (int i=0; i<h; i++) {
            pairH[i] = new Pair(cntH[i], i);
        }
        for (int i=0; i<w; i++) {
            pairW[i] = new Pair(cntW[i], i);
        }


        Set<Integer> setH = new HashSet<>();
        for (int i=0; i<h; i++) {
            if (pairH[i].cnt == maxhCnt) setH.add(pairH[i].idx);
        }
        Set<Integer> setW = new HashSet<>();
        for (int i=0; i<w; i++) {
            if (pairW[i].cnt == maxWCnt) setW.add(pairW[i].idx);
        }

//        System.out.print(setH);
//        System.out.print(setW);

        for (int i=0; i<m; i++) {
            if (!setH.contains(arr[i][0])) {

            }
        }


        long cnt = 0;
        for (int i=0; i<m; i++) {
            if (setH.contains(arr[i][0]) && setW.contains(arr[i][1])) cnt++;
        }

        if ((long)setH.size() * (long)setW.size() == cnt) {
            System.out.print(maxhCnt + maxWCnt - 1);
        } else {
            System.out.print(maxhCnt + maxWCnt);
        }



    }

    class Pair {
        int cnt;
        int idx;
        public Pair(int c, int i) {
            this.cnt = c;
            this.idx = i;
        }
    }



}



Measured memory_bytes: 114624
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if((a*b)%2==0) cout<<"Even"<<endl;
	else cout<<"Odd"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;

class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        Map<Integer, List<String>> map = new HashMap<>();
        
        for(int i=0; i<m; i++){
            int key = scanner.nextInt();
            if(map.containsKey(key)){
                map.get(key).add(scanner.next());
            }else{
                List<String> list = new ArrayList<>();
                list.add(scanner.next());
                map.put(key, list);
            }
        }

        scanner.close();
        int ac = 0;
        int wa = 0;

        for(int key : map.keySet()){
            if(!map.get(key).contains("AC")){
                continue;
            }
            for(String val : map.get(key)){
                if(val.equals("AC")){
                    ac += 1;
                    break;
                }
                wa += 1;
            }

        }
        System.out.print(ac + " " + wa);
    }
}

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

signed main(void)
{
	int n, x;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	x = a[0];
	for (int i = 1; i < n; i++)
		x ^= a[i];
	rep(i, n) printf("%d%c", x ^ a[i], i == n - 1?'\n':' ');
	return 0;
}


Measured memory_bytes: 4028