akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        List<Integer> s = new ArrayList<>();
        List<Integer> c = new ArrayList<>();

        for(int i=0; i<M; i++){
            s.add(scanner.nextInt());
            c.add(scanner.nextInt());
        }
        int min = pow(10,N-1);
        int max = pow(10,N) - 1;
        if(N==1){
            min = 0;
            max = 9;
        }

        boolean noanswer = true;
        for(int i=min; i<=max; i++){
            boolean found = true;
            for(int j=0; j<M; j++){
                if(bketa(i,N-s.get(j)) != c.get(j)){
                    found = false;
                }
            }
            if(found){
                noanswer=false;
                System.out.println(i);
                break;
            }
        }
        if(noanswer){
            System.out.println(-1);
        }
    }
    public static int bketa(int a, int b){
        int red = a / pow(10,b);
        return red % 10;
    }
    public static int pow(int a, int b){
        int res = 1;
        for(int i=0; i<b; i++){
            res = res * a;
        }
        return res;
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  int N; string S; cin >> N >> S;
  
  int cnt = 0;
  
  for(int i = 0; i < N-2; i++){ 
    string t = "";
    t = S[i];
    t += S[i+1];
    t += S[i+2];
    
    if( t == "ABC"){ cnt++;}
  }

  cout << cnt << endl;
  
  return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

ll powerMod(ll a, ll x) {
    ll ans = 1;
    while(x--) {
        ans *= a;
        ans %= MOD;
    }
    return ans;
}

int main(){
	ios::sync_with_stdio(0);
    int N, M;
    cin >> N >> M;
    vector<vector<int>> a(N, vector<int>(M));
    rep(i,0,N)
        rep(j,0,M) {
            cin >> a[i][j];
        }
    int pos = 0;
    rep(j,0,M) {
        bool ok = 0;
        rep(i,pos,N) {
            if (a[i][j]) {
                swap(a[i], a[pos]);
                ok = 1;
                break;
            }
        }
        if (ok) {
            rep(i,pos+1,N) {
                if (!a[i][j])
                    continue;
                rep(j2,0,M) {
                    a[i][j2] ^= a[pos][j2];
                }
            }
            ++pos;
        }
    }
    int rank = pos;
    ll ans = powerMod(2, N+M-1);
    ans -= powerMod(2, N+M-1-rank);
    ans %= MOD;
    if (ans < 0)
        ans += MOD;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
   ll n,k;cin >> n >> k;
   vector<ll>a(n);
   for(int i = 0;i<n;i++) cin >> a[i];
   vector<ll>kk(60);
   vector<ll>b(60);
   ll temp = k;int cnt = 0;
   while(temp){if(temp%2)kk[cnt]++;cnt++;temp /= 2;}
   for(int i = 0;i<n;i++){
      temp = a[i];cnt = 0;
      while(temp){
        if(temp%2) b[cnt]++;
        cnt++;
        temp /= 2;
      }
   }
   ll ans = 0;bool go = 0;
   for(int i = 59;i>=0;i--){
   if(kk[i]==0&&go==0) ans += modpow(2,i,1e18)*b[i];
   else if(kk[i]==1&&go==0){
    if((n-b[i])<=b[i]) go = 1;
    b[i] = max(b[i],n-b[i]);ans += modpow(2,i,1e18)*b[i];}
   else {b[i] = max(b[i],n-b[i]);ans += modpow(2,i,1e18)*b[i];}
   }
   cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3892
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int ans=1;
		for(int i=0;i!=a+1;i++) {
			for(int j=2;j<=Math.sqrt(i);j++) {
				for(int k=j;k<=i;k*=j) {
					if(k==i) {
						ans=i;
					}
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21204
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
int main() {
	cin >> x >> y;
	a = max(0LL, (4 - x) * 100000);
	b = max(0LL, (4 - y) * 100000);
	c = max(0LL, (3 - x - y) * 400000);
	cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>

#define int long long 

using namespace std;

int a[20],n;

int f(int l,int r,int xl,int xr)
{
	int i,j;
	if(r-l<=1) return 0;
	int ans=0x3f3f3f3f3f3f3f3f;
	for(i=l+1;i<r;i++)
	{
		ans=min(ans,f(l,i,xl,xl+xr)+f(i,r,xl+xr,xr)+a[i]*(xl+xr));
	}
	return ans;
}

signed main()
{
	ios::sync_with_stdio(false);
	register int i,j;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>a[i];
	cout<<a[1]+a[n]+f(1,n,1,1);
}


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

int main(){
  int N,K;
  cin >>N >>K;
  int l=0;
  for(int i=0; i<N;i++){
    int x;
    cin >>x;
    if(x<=(K-x))
      l+=x*2;
    else
      l+=(K-x)*2;
  }
  cout <<l <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;using vll = vector<ll>;
int main(){
  ll n;
  cin >> n;
  vll a(n+1), b(n);
  for (ll i = 0; i <= n; i++) cin >> a[i];
  
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    cin >> b[i];
    if (a[i] >= b[i]) ans += b[i];
    else {
      ans += a[i];
      b[i] -= a[i];
      if (a[i+1] >= b[i]) {
        ans += b[i];
        a[i+1] -= b[i];
      }
      else {
        ans += a[i+1];
        a[i+1] = 0;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include <bits/stdc++.h>

using namespace std;
#define int long long

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];
    vector<bool> dp(k + 1);
    for (int i = 0; i <= k; ++i) {
        for (int x:a) {
            if (x <= i && !dp[i - x])dp[i] = true;
        }
    }
    cout << (dp[k] ? "First" : "Second") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <algorithm>
#include <string>

std::string lcs(const std::string& s, const std::string& t) {
  size_t m = s.length();
  size_t n = t.length();

  std::vector<std::vector<size_t>> dp(m+1, std::vector<size_t>(n+1));
  // for (size_t i = 1; i <= m; ++i)
  //   dp[i][0] = i;
  // for (size_t j = 1; j <= n; ++j)
  //   dp[0][j] = j;

  std::vector<std::vector<size_t>> prev(m+1, std::vector<size_t>(n+1));
  for (size_t i = 1; i <= m; ++i)
    for (size_t j = 1; j <= n; ++j) {
      size_t a = dp[i-1][j];
      size_t b = dp[i][j-1];
      size_t c = dp[i-1][j-1] + (s[i-1] == t[j-1]);
      size_t max = std::max({a, b, c});
      dp[i][j] = max;
      if (a == max) {
        prev[i][j] = 1;
      } else if (b == max) {
        prev[i][j] = 2;
      } else if (c == max) {
        prev[i][j] = 3;
      }
    }

  // for (size_t i = 0; i <= m; ++i)
  //   for (size_t j = 0; j <= n; ++j)
  //     fprintf(stderr, "%zu%c", dp[i][j], j<n? ' ':'\n');

  fprintf(stderr, "%zu\n", dp[m][n]);
  if (dp[m][n] == 0) return "";

  std::string res;
  size_t len = dp[m][n];
  size_t i = m;
  size_t j = n;
  while (dp[i][j]) {
    if (prev[i][j] == 3) {
      assert(s[i-1] == t[j-1]);
      res += s[i-1];
      --i;
      --j;
    } else if (prev[i][j] == 2) {
      --j;
    } else if (prev[i][j] == 1) {
      --i;
    }
  }

  std::reverse(res.begin(), res.end());
  assert(res.length() == len);
  return res;
}

int main() {
  char buf[4096];
  scanf("%s", buf);
  std::string s = buf;
  scanf("%s", buf);
  std::string t = buf;

  printf("%s\n", lcs(s, t).c_str());
}


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

using namespace std;

int main() {
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    int ans = n;
    for(int i = 0; i + m - 1< n; ++i){
        int count = 0;
        for(int j = 0; j < m; ++j){
            if(s[j+i] != t[j])count ++;
        }
        ans = min(ans,count);
    }
    cout << ans <<"\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define x first
#define y second
#define pb push_back
#define ll long long
#define int ll
#define ld long double
#define ii pair<int, int>
#define iii pair<int, ii>
#define vi vector<int>
#define vii vector<ii>
#define pq priority_queue
using namespace std;
const int ms = 2e5+100;
const int mod = 1e9+7;
const int inf = 1e9 + 100;
const int sigma = 30;
int n, m, k, t = 1;

int dp[ms];
bool valid[ms];

int w[ms];
int v[ms];

void solve(){
  cin>>n>>m;
  int tot = 0;
  for(int i=0; i<n; i++){
    cin>>w[i]>>v[i];
    tot+=v[i];
  }
  valid[0] = 1;
  for(int i =0; i<=tot; i++){
    dp[i] = inf;
  }
  dp[0] = 0;
  for(int i = 0; i<n; i++){
    for(int j = tot; j>=0 && (j - v[i]>=0); j--){
      int pos = j - v[i];
      if(valid[pos]){
        valid[j] = 1;
        dp[j] = min(dp[j], dp[pos] + w[i]);
      }
    }
  }
  int ans = 0;
  for(int i = tot; i>=0; i--){
    if(dp[i]<=m){
      ans = i;
      break;
    }
  }
  cout<<ans<<endl;
  
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  while(t--){
    solve();
  }
}

Measured memory_bytes: 2304
#!/usr/bin/env python
# coding: utf-8
#


def main(x):
    s = int(x % 60)
    m = int((x - s) / 60 % 60)
    h = int((x - m * 60 - s) / 60 / 60)
    print('{}:{}:{}'.format(h, m, s))
    
    
if '__main__' == __name__:
    try:
        while True:
            main(int(input().strip()))
    except EOFError:
        pass



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
string s;
int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(), cout.tie(0);
    int num[3];
    while(cin >> s) {
        num[0] = num[1] = num[2] = 0;
        int l = s.length();
        for(int i = 0; i < l; ++i)
            ++num[s[i] - 'a'];
        sort(num, num + 3);
        int a = 0;
        for(int i = 0; i < 3; ++i) a += num[i] != 0;
        if(a == 1) {
            if(num[2] == 1) cout << "YES" << endl;
            else cout << "NO" << endl;
        } else if(a == 2) {
            if(num[2] == 1 && num[1] == 1) cout << "YES" << endl;
            else cout << "NO" << endl;
        } else if(a == 3) {
            if(num[1] == num[0] + 1 && num[2] == num[1] + 1) cout << "NO" << endl;
            else if(num[1] <= num[0] + 1 && num[2] <= num[1] + 1) cout << "YES" << endl;
            else cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  long long A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);
  long long ans = A[N - 1];
  for (int i = 0, j = N - 2; i < N - 2; i++) {
    ans += A[j];
    if (i & 1) j--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5208
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,x[100];
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n)
	cin>>x[i];
	sort(x,x+n);
	int ans=1e9;
	forn(i,x[0],x[n-1]+1){
		int ans1=0;
		rep(j,n){
			ans1+=(x[j]-i)*(x[j]-i);
		}
		ans=min(ans,ans1);
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)

void solve(){
  int n;cin >> n;
  vector<int> a(n,98765432); 
  int ans = 0;
  FOR(i,0,n-1){
    int b; cin >> b;
    a[i] = min(a[i], b);
    a[i+1] = min(a[i+1], b);
    ans += a[i];
  }
  ans += a[n-1];
  cout << ans;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n, l; cin >> n >> l;
    int near = -400;
    vector<int> nums;
    for(int i = 1; i <= n; ++i){
        int x = l + i - 1;
        if(abs(near) > abs(x)) near = x;
        nums.push_back(x);
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        ans += nums[i];
    }
    ans -= near;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
//https://atcoder.jp/contests/abc176/tasks/abc176_e
vector<pair<int,int>> row, col;
set<pair<int,int>> bombs;

int main() {
    int r, c, m, a, b; scanf("%d %d %d", &r, &c, &m);
    row.resize(r + 1);   col.resize(c + 1);
    for(int i=0; i<=r; i++) row[i].f = 0, row[i].s = i;
    for(int i=0; i<=c; i++) col[i].f = 0, col[i].s = i;

    for(int i=0; i<m; i++) {
        scanf("%d %d", &a, &b);
        
        row[a].f++; col[b].f++;
        bombs.insert({a, b});
    }

    sort(row.begin(), row.end());   // {#bombs in that row, row index}
    sort(col.begin(), col.end());   // {#bombs in that col, col index}

    //printf("ROW: "); for(auto x: row) printf("[%d, idx:%d], ", x.f, x.s);
    //printf("\nCOL: "); for(auto x: col) printf("[%d, idx:%d], ", x.f, x.s);

    int ans = 0;

    if(bombs.find({row[r].s, col[c].s}) == bombs.end()) ans = row[r].f + col[c].f;   // no bomb here at this cell
    else if(r == 1) ans = row[1].f;   // no other choice, in next line as well
    else if(c == 1) ans = col[1].f;
    else {
        ans = row[r].f + col[c].f - 1;  // this cell added twice

        int idx = r - 1;
        while(bombs.find({row[idx].s, col[c].s}) != bombs.end()) idx--;  // where there is empty cell in that col
        ans = max(ans, row[idx].f + col[c].f);

        idx = c - 1;
        while(bombs.find({row[r].s, col[idx].s}) != bombs.end()) idx--; // where there is empty cell in that row
        ans = max(ans, row[r].f + col[idx].f);        
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 21948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
struct unionfind{
    public:
    vector<ll>par;
    vector<ll>siz;
    unionfind(ll n) :par(n),siz(n,1LL){
        rep(0,i,n)par[i]=i;
    }
    ll root(ll x){
        if(par[x]==x)return x;
        return par[x]=root(par[x]);
    }
    bool merge(ll x,ll y){
        x=root(x);
        y=root(y);
        if(x==y)return false;
        if(siz[x]<siz[y])swap(x,y);
        siz[x]+=siz[y];
        par[y]=x;
        return true;
    }
    bool same(ll x,ll y){
        ll rx=root(x);
        ll ry=root(y);
        return rx==ry;
    }
    ll size(ll x){
        return siz[root(x)];
    }
};
int main(void){
    ll n,m;
    cin>>n>>m;
    unionfind tree(n);
    rep(0,i,m){
        ll a,b;
        cin>>a>>b;
        --a,--b;
        tree.merge(a,b);
    }
    ll M=0;
    rep(0,i,n){
        M=max(M,tree.size(i));
    }
    cout<<M;
}

Measured memory_bytes: 6424
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
char z;
cin >> z;
z++;
cout << z << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {

int a,b,c[110],d[110],e;
   cin >> a>>b;
   
  
   for(int i =1;i<=a;i++){
       c[i] = b+i-1;
     
   }
  
  if(c[1] >=0){
    cout <<(c[1]+c[a])*a/2-c[1]<<endl;
  }
  else if(c[a] <=0){
    cout << (c[1]+c[a])*a/2-c[a] << endl;
  }
  else{
    cout <<(c[1]+c[a])*a/2 << endl;
  }
}
  


Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))
even_list = []
n = 0
for i in range(N):
    if A_list[i] % 2 == 0:
        even_list.append(A_list[i])
        n += 1
m = 0
for j in range(n):
    if even_list[j] % 3 == 0 or even_list[j] % 5 == 0:
        m += 1
if n == m:
    print('APPROVED')
else:
    print('DENIED')


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

int main(void){
    int a;
    cin >> a;
    cout << "Christmas";
    switch(a){
        case 24:cout << " Eve" << endl;
                break;
        case 23:cout << " Eve Eve" << endl;
                break;
        case 22:cout << " Eve Eve Eve" << endl;
                break;
    }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int A=sc.nextInt();
		String op=sc.next();
		int B=sc.nextInt();
		pw.println(op.equals("+")?(A+B):(A-B));
		pw.close();
	}

	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

Measured memory_bytes: 21332
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;

#define MOD          (1000000007)
#define N_MAX     (100000)
#define EX                (5)
#define MAX_FACT_NUM (32)

QWORD N, M;
unordered_map<QWORD, QWORD> mFact;
QWORD combDp[N_MAX + EX][MAX_FACT_NUM] = {};

//素因数計算　素因数keyがvalue個あるmapを求める
void Factoring(QWORD n)
{
	QWORD num = n;
	for (QWORD i = 2; i * i < n; i++) {
		while ((num % i) == 0) {
			mFact[i]++;
			num /= i;
		}
	}
	if (num != 1) {
		mFact[num] = 1;
	}
}

void calcCombDP()
{
	//i番目の箱までにボールをj個選ぶ場合の数
	REP (i, 0, (N_MAX + EX)) {
		//初期条件 ボールが0個なら場合の数は１
		combDp[i][0] = 1;
	}
	
	REP (i, 0, (N_MAX + 1)) {
		REP (j, 1, MAX_FACT_NUM) {
				combDp[i + 1][j] = (combDp[i + 1][j - 1] + combDp[i][j]) % MOD;
		}
	}
}

void solve_main()
{
	QWORD ans = 1;

	cin >> N >> M;	

	//Nを素因数分解
	Factoring(M);

	//重複組み合わせを計算
	calcCombDP();

	//各keyに対して、重複組み合わせDPを出して掛け算
	for(auto it = mFact.begin(); it != mFact.end(); it++) {
		ans = (ans * combDp[N][it->second]) % 1000000007;
	}

	cout << ans << endl;
}

int main()		
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}

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

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << x2 + y1 - y2 << " " << y2 + x2 - x1 << " " << x1 + y1 - y2 << " " << y1 + x2 - x1;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、正方形であるからx2-x1=y2-y3、x2-x3=y2-y1となる
更に、x1+x3=x2+x4、y1+y3=y2+y4であることも分かる
ここから、y2-y3=y1-y4よりy4=y1+x2-x1であることが分かるので、y3=y2+x2-x1であると分かる
後は同様に解いてx3=x2-y2+y1, x3=x1-y2+y1となる
*/

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n; cin >> n;
  int A[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
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)
 
int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
 
typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
 
const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
 
// --------------------------------------
int n;
vector<string> s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  cin >> n;
  REP(i, n) {
    string ss;
    cin >> ss;
    sort(ss.begin(), ss.end());
    s.push_back(ss);
  }
 
  string ss = s[0];
 
  FOR(i, 1, n) {
    int sl = ss.length();
    string sss = "";
    vector<bool> f(sl, true);
    REP(j, sl) {
      REP(k, s[i].length()) {
        if(ss[j] == s[i][k] && f[k]) {
          sss.push_back(ss[j]);
          f[k] = false;
          break;
        }
      }
    }
    ss = sss;
  }
 
  cout << ss << endl;
}

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

int main(){
  //N, Aの入力・Aの並び変え
  int64_t N;
  cin >> N;
  vector<int64_t> A(N), C(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
    C.at(A.at(i) - 1)++;
  }

  //kを取らない時の組み合わせの個数
  int64_t all = 0LL;
  for (int i = 0; i < N; i++) {
    if (C.at(i) > 1){
      all += C.at(i) * (C.at(i) - 1) / 2;
    }
  }
  
  //kを取る場合の組み合わせ
  int64_t answer = all; 
  for (int k = 0; k < N; k++){
    answer = all;
    if (C.at(A.at(k) - 1) > 1){
      answer -= C.at(A.at(k) - 1) - 1;
    }
    cout << answer << endl;
  }
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  printf("%d %d %d\n", z, x, y);
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_SANDCLOCK	(100)

int main( void )
{
	int bestTime;								//best time, 茹で上がるのに最もよい時間	T
	int numOfSandClock;							//number of sandclock,砂時計の数	N
	int canMeaTime[ MAX_SANDCLOCK + 1 ];		//CanMeasuring Time,測れる時間	x
	int errorTime;								//許される誤差	E
	
	int i;
	
	scanf( "%d%d%d", &numOfSandClock, &bestTime, &errorTime );
	
	for( i = 0; i < numOfSandClock; i++ )
	{
		scanf( "%d", &canMeaTime[i] );
	}
	
	for( i = 0; i < numOfSandClock; i++ )
	{
		if( bestTime % canMeaTime[i] <= errorTime )
		{
			printf( "%d\n", i + 1 );
			return (0);
		}
		if( bestTime % canMeaTime[i] >= canMeaTime[i] - errorTime )
		{
			printf( "%d\n", i + 1 );
			return (0);
		}
	}
	printf( "-1\n" );
	
	return (0);
}

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

int main() {
  int x, y;
  cin >> x >> y;
  int group[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  if (group[x] == group[y])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
template<typename T>inline void rd(T&x){int fl=0,ch;while(ch=getchar(),ch<48||57<ch)fl^=!(ch^45);x=(ch&15);while(ch=getchar(),47<ch&&ch<58)x=x*10+(ch&15);if(fl)x=-x;}
template<typename T>inline void pt(T x){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);}
template<typename T>inline void pt(T x,int ch){pt(x),putchar(ch);}
template<typename T>inline T max(const T&x,const T&y){return x<y?y:x;}
template<typename T>inline T min(const T&x,const T&y){return x<y?x:y;}
const int N=100005;
int n,m,len,d[N],dep[N],q[N],fa[N],ans[N][2],uu[N],vv[N],vis[N],cf[N],f[N];std::vector<int>g[N];
int get(int u){return fa[u]==u?u:fa[u]=get(fa[u]);}
void pre(int u){
	for(int i=0;i<g[u].size();++i){
		int v=g[u][i];
		if(v==f[u])continue;
		f[v]=u;
		++d[u];
		pre(v);
	}
}
void dfs(int u){
	for(int i=0;i<g[u].size();++i){
		int v=g[u][i];
		if(v==f[u])continue;
		dfs(v);
		cf[u]^=cf[v];
	}
}
signed main(){
	rd(n),rd(m);
	rep(i,1,n)fa[i]=i;
	rep(i,1,m){
		int u,v;rd(u),rd(v);
		if(get(u)!=get(v)){
			fa[get(u)]=get(v);
			g[u].push_back(v),g[v].push_back(u);
		}else{
			ans[++len][0]=u,ans[len][1]=v;
			++d[u];
		}
	}
	pre(1);
	rep(i,1,n)if(d[i]&1){
		q[++*q]=i;
	}
	if((*q)&1){puts("-1");return 0;}
	for(int i=1;i<=*q;++i){
		cf[q[i]]^=1;
	}
	dfs(1);
	for(int i=1;i<=n;++i)if(i!=1)ans[++len][0]=cf[i]?i:f[i],ans[len][1]=cf[i]?f[i]:i;
	for(int i=1;i<=len;++i)pt(ans[i][0],' '),pt(ans[i][1],'\n');
	return 0;
}

Measured memory_bytes: 17408
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
 
using namespace std ;
 
typedef long long ll ;
 
#define fr(i) f[i].first
#define sc(i) f[i].second
#define pint pair<int, int>
 
const int N = 300010 ;
 
ll ans ;
int m, n ;
pint f[N] ;
ll base[N] ;
 
bool comp(int x, int y){
    return base[x] > base[y] ;
}
int main(){
    cin >> m ; n = (1 << m) - 1 ;
    for (int i = 0 ; i <= n ; ++ i){
        cin >> base[i] ;
        f[i] = make_pair(i, n + 1) ;
    }
    base[n + 1] = -1 ;
    for (int i = 0 ; i <= n ; ++ i)
        for (int j = 0 ; j < m ; ++ j)
            if (!((1 << j) & i)){
                int k = (1 << j) | i ;
                int t[4] = {fr(i), sc(i), fr(k), sc(k)} ;
                sort(t, t + 4, comp) ; unique(t, t + 4) ;
                f[k] = make_pair(t[0], t[1]) ;
            }
    for (int i = 1 ; i <= n ; ++ i){
        ans = max(ans, base[fr(i)] + base[sc(i)]) ;
        cout << ans << endl ;
    }
}

Measured memory_bytes: 7808
#include<iostream>
#include<map>

using namespace std;
typedef pair<int, int> pii;
const int _K=200000+5;
struct UnionFind{

    int par[_K];
    int size[_K];
    void init(int n){
        for(int i=0; i<n; i++) par[i]=i;
        for(int i=0; i<n; i++) size[i]=1;
    }
    int find(int x){
        if(par[x]==x) return x;
        else return par[x]=find(par[x]);
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    void uni(int x, int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(size[x]<size[y]) swap(x, y);
        par[y]=x;
        size[x]+=size[y];
    }
    int getsize(int x){
        return size[find(x)];
    }
};

int main(){

    int N, K, L;
    cin>> N>> K>> L;

    UnionFind ufoo;
    ufoo.init(N);
    for(int i=0; i<K; i++){
        int p, q;
        cin>> p>> q;
        p--; q--;
        ufoo.uni(p, q);
    }
    UnionFind ubar;
    ubar.init(N);
    for(int i=0; i<L; i++){
        int r, s;
        cin>> r>> s;
        r--; s--;
        ubar.uni(r, s);
    }

    map<pii, int> hoge;
    for(int i=0; i<N; i++){
        hoge[pii(ufoo.find(i), ubar.find(i))]++;
    }

    for(int i=0; i<N; i++){
        cout<< hoge[pii(ufoo.find(i), ubar.find(i))]<< endl;
    }
    return 0;
}

Measured memory_bytes: 15232
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;
int main(){
  long long n, m;
  cin >> n >> m;
  long long a[n + 1], b[n + 1];
  map<long long, long long> mod;

  b[0] = 0;
  for (int i = 1; i <= n; i++){
    cin >> a[i];
    b[i] = (b[i - 1] + a[i]) % m;
    mod[b[i] % m]++;
  }
  long long count = 0;
  for (auto iter = mod.begin(); iter != mod.end(); ++iter){
    count += iter->second * (iter->second - 1) / 2;
    if (iter->first == 0)
      count += iter->second;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
typedef long long ll;
struct pr{
	int i,v;
	pr(int a=0,int b=0){i=a;v=b;}
}p[100010];
bool operator<(pr a,pr b){return a.v<b.v;}
int a[100010],val[100010],n,m;
int s[100010],sum[200010];
int lowbit(int x){return x&-x;}
void modify(int x,int v){
	while(x<=2*n){
		sum[x]+=v;
		x+=lowbit(x);
	}
}
int query(int x){
	int res=0;
	while(x){
		res+=sum[x];
		x-=lowbit(x);
	}
	return res;
}
ll check(int k){
	int i;
	ll ans;
	for(i=1;i<=n;i++)s[i]=(a[i]>=k?1:-1)+s[i-1];
	ans=0;
	memset(sum,0,sizeof(sum));
	modify(n+1,1);
	for(i=1;i<=n;i++){
		ans+=query(s[i]+n+1);
		modify(s[i]+n+1,1);
	}
	return ans;
}
int main(){
	int i,l,r,mid,ans;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",a+i);
		p[i]=pr(i,a[i]);
	}
	sort(p+1,p+n+1);
	for(i=1;i<=n;i++){
		if(p[i].v!=p[i-1].v)val[++m]=p[i].v;
		a[p[i].i]=m;
	}
	l=1;
	r=m;
	ans=1;
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid)>=((ll)n*(n+1)/2+1)/2){
			ans=mid;
			l=mid+1;
		}else
			r=mid-1;
	}
	printf("%d",val[ans]);
}

Measured memory_bytes: 2944
n=int(input())
l=[]
for i in range(n):
    temps,tempp=input().split()
    temp=[temps,int(tempp),i+1]
    l.append(temp)

l.sort(key=lambda x:x[1],reverse=True)
l.sort(key=lambda x:x[0])
for i in range(n):
    print(l[i][2])


Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}

int main()
{
   int n;
   cin>>n;
   vector<int>t(n);
   for(int i=0;i<n;i++)
   	cin>>t[i];
   int sum=0;
   for(int i=0;i<n-1;i++)
   	for(int j=i+1;j<n;j++)
   		sum+=t[i]*t[j];
   		cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args){
 
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		
		Integer[] lengthArray = new Integer[N];
		for(int i = 0; i < N; i++) {
			lengthArray[i] = sc.nextInt();
		}
		Arrays.sort(lengthArray);
		
		for(int i = 0; i < N; i++) {
			for(int j = i+1; j < N; j++) {
				for(int k = j+1; k < N; k++) {
					int a = lengthArray[i];
					int b = lengthArray[j];
					int c = lengthArray[k];
					if(b<c+a && c<a+b) {
						ans++;
					}
				}
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 27152
#include <stdio.h>

int main()
{
  int n, k, i, a = 1;
  int b[100001];
  scanf("%d %d",  &n, &k);

  for(i=0; i<n; i++){
    scanf("%d", &b[i]);
  }

  n = n - k;
  while(1){
    if(n==0)break;
    a++;
    if(n<k)break;
    n = n - (k-1);
  }
  printf("%d", a);
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef pair<int,int> P;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define lowbit(x) (x&-x)
const ll INF=0x3f3f3f3f;
const double EPS=1e-6;
const int N=2e5+10;
const ll mod=1e9+7;
inline ll read()
{  ll f=1,x=0;char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar()) x=x*10+ch-'0';
   return x*f;
}
ll n,k;
double a[N];
bool check(double mid)
{  ll cnt=0;
   for(ll i=1;i<=n;i++)
   {  if(a[i]<=mid)continue;
      cnt=cnt+ceil((a[i]/mid));
      cnt--;
      if(cnt>k)return 0;
   }
   if(cnt>k)return 0;
   else return 1;
}
int main()
{  cin>>n>>k;
   for(int i=1;i<=n;i++)cin>>a[i];
   double l=0.0001,r=1e9+5,ans;
   while(r-l>=EPS)
   {  double mid=(l+r)/2;
      if(check(mid))
      {  r=mid;
      }
      else
      {  l=mid;
      }
   }
   printf("%.0f\n",max(1.0,ceil(r-0.000001)));
}

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

vector<int> g[1<<17];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N, M; cin >> N >> M;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int A, B; cin >> A >> B;
    if (M >= A) g[M - A].push_back(B);
  }
  priority_queue<int> pq;
  for (int i = M - 1; i >= 0; --i) {
    for (auto c : g[i]) pq.push(c);
    if (pq.size()) ans += pq.top(), pq.pop();
  }
  cout << ans << '\n';
}


Measured memory_bytes: 6400
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 1000000007
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
vector<complex<double>>  DFT(vector<complex<double>> a) {
	int n = a.size();
	if (n == 1) return a;
	vector<complex<double>> a0(n / 2), a1(n / 2);
	REP(i, n) {
		if (i % 2 == 0) {
			a0[i / 2] = a[i];
		}
		else {
			a1[i / 2] = a[i];
		}
	}
	vector<complex<double>> inversed_a0 = DFT(a0), inversed_a1 = DFT(a1);
	vector<complex<double>> inversed_a(n);
	for (int i = 0; i < n; ++i) {
		complex<double> zeta = complex<double>(cos(2 * Ma_PI * i / n), sin(2 * Ma_PI * i / n));
		inversed_a[i] = inversed_a0[i % (n / 2)] + zeta * inversed_a1[i % (n / 2)];
	}
	return inversed_a;
}
vector<complex<double>> IDFT(vector<complex<double>> inversed_a) {
	int n = inversed_a.size();
	vector<complex<double>> now = DFT(inversed_a);
	reverse(now.begin(), now.end());
	for (int q = now.size() - 1; q >= 1; --q) {
		swap(now[q], now[q - 1]);
	}
	REP(i, n) {
		now[i] /= complex<double>(n, 0);
	}
	return now;
}
vector<complex<double>> conv(vector<complex<double>> a, vector<complex<double>> b) {
	int deg = a.size() + b.size() - 1;
	int n = 1;
	while (n < deg) n <<= 1;
	a.resize(n);
	b.resize(n);
	vector<complex<double>> inversed_a = DFT(a), inversed_b = DFT(b);
	vector<complex<double>> inversed_c(n);
	REP(i, n) {
		inversed_c[i] = inversed_a[i] * inversed_b[i];
	}
	return IDFT(inversed_c);
}
long long powing(long long now, long long hoge) {
	long long ans = 1;
	while (hoge != 0) {
		if (hoge % 2 == 1) {
			ans *= now;
			ans %= MOD;
		}
		hoge /= 2;
		now *= now;
		now %= MOD;
	}
	return ans;
}
long long inv(long long now) {
	return powing(now, MAX_MOD - 2LL);
}
unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x^(x << 11));
	x = y; y = z; z = w;
	return (w = (w^(w >> 19))^(t^(t >> 8)));
}
int main() {
	int n;
	cin >> n;
	vector<long long> A;
	REP(i, n+1) {
		long long b;
		cin >> b;
		A.push_back(b);
	}
	long long ans = 0;
	REP(i, n) {
		long long b;
		cin >> b;
		if (A[i] <= b) {
			b -= A[i];
			ans += A[i];
			A[i] = 0;
		}
		else {
			A[i] -= b;
			ans += b;
			b = 0;
		}
		if (A[i + 1] <= b) {
			b -= A[i + 1];
			ans += A[i + 1];
			A[i + 1] = 0;
		}
		else {
			A[i + 1] -= b;
			ans += b;
			b = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main(void){
	int A;
    int B;
    int max=0;
 	scanf("%d %d",&A,&B);
    
    max = A-B;
    if((A+B)>max)
      max = A+B;
    if(max<=(A*B))
      max = A*B;
  
    printf("%d\n",max);

	return 0;
}

Measured memory_bytes: 128
s = dict()
s["a"] = list(input())
s["b"] = list(input())
s["c"] = list(input())

nexts = "a"
while True:
    cur = nexts
    if len(s[cur]) == 0:
        print(cur.capitalize())
        break
    nexts, s[cur] = s[cur][0], s[cur][1:]
#     print(cur, s[cur], "->", nexts)
    


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

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


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        ArrayList<Dish> li = new ArrayList<>();
        int[][] dpi = new int[n+1][t+1];
        int[][] dpj = new int[n+1][t+1];
        for(int i = 0; i < n; i++){
            int ai = sc.nextInt();
            int bi = sc.nextInt();
            for(int j = 0; j < t; j++){
                dpi[i+1][j] = dpi[i][j];
                if(j >= ai){
                    dpi[i+1][j] = Math.max(dpi[i+1][j],dpi[i][j-ai]+bi);
                }
            }
            li.add(new Dish(ai,bi));
        }
        for(int i = n-1; i >= 0; i--){
            int ai = li.get(i).a;
            int bi = li.get(i).b;
            for(int j = 0; j < t; j++){
                dpj[i][j] = dpj[i+1][j];
                if(j >= ai){
                    dpj[i][j] = Math.max(dpj[i][j],dpj[i+1][j-ai]+bi);
                }
            }
        }
        int max = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < t; j++){
                //System.out.println(i +" " + j + " " + dpi[i][j] + " " + dpj[i+1][t-1-j]);
                max = Math.max(max,dpi[i][j] + dpj[i+1][t-1-j] + li.get(i).b);
            }
        }
        System.out.println(max);
    }
}

class Dish{
    int a,b;
    public Dish(int a, int b){
        this.a = a;
        this.b = b;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 102068
n = int(input())
R = [int(input()) for i in range(n)]
minv = R[0]
maxv = R[1]-R[0]
for j in range(1,n):
    if maxv < (R[j]-minv):
        maxv = R[j]-minv
    if minv > R[j]:
        minv = R[j]
print(maxv)


Measured memory_bytes: 13592
N = int(input())
A = list(map(int, input().split()))
ans = 1
dekai = False
for a in A:
    ans *= a
    if ans > (10 ** 18):
        dekai = True
        break

if 0 in A:
    print(0)
elif dekai:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 21468
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    int x[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};

    cout << ((x[a] == x[b]) ? "Yes" : "No") << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl

const ll INF=1e11+7;
const ll N = 100001;
ll n,ans=0,c;
ll v[N],x[N];
ll c1[N],c2[N],u1[N],u2[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>c;
	if(n==1){
		ll a,b;
		cin>>a>>b;
		cout<<TO(a>b,0,b-a)<<endl;
		return 0;
	}


	ll w=0;
	FOR(i,0,n){
		cin>>x[i]>>v[i];
		w+=v[i];
		if(i==0){
			c1[i]=max(w-x[i],0ll);
			c2[i]=max(w-x[i]*2,0ll);
		}else{
			c1[i]=max(c1[i-1],w-x[i]);
			c2[i]=max(c2[i-1],w-x[i]*2);
		}
	}
	ans=w-c+max(x[0],c-x[n-1]);
	w=0;
	FOR(i,0,n){
		ll j=n-1-i;
		w+=v[j];
		if(i==0){
			u1[j]=max(w+x[j]-c,0ll);
			u2[j]=max(w+x[j]*2-c*2,0ll);
		}else{
			u1[j]=max(w+x[j]-c,u1[j+1]);
			u2[j]=max(w+x[j]*2-c*2,u2[j+1]);
		}
	}

	FOR(i,0,n-1){
		ans=max(ans,c1[i]+u2[i+1]);
		ans=max(ans,c2[i]+u1[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
char a[1005],s[1005];string s1; 
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>s1;
	for(int i=0;i<s1.size();i++)s[i+1]=s1[i];
	int now=0;
	for(int i=1;i<=1000;i++)a[i]='q';
	for(int i=1;i<=s1.size();i++){
		if(s[i]=='1')a[++now]='1';
		if(s[i]=='0')a[++now]='0';
		if(s[i]=='B'){
			if(now==0)continue;
			a[now--]='q';
		} 
	}
	for(int i=1;i<=now;i++)
	printf("%c",a[i]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0;
  cin >> n;
  long long a[n],b[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
    if(a[i]>b[i]){
      ans+=a[i]-b[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define ll long long

int main (){

    ll a,b,i;

    cin>>a>>b;

    for(i=1; i<=b; i++){

        if((a*i)%b==0){

            cout<<a*i<<endl;
            break;

        }

    }

    return 0;

}


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

using namespace std;

int main(){
	int x, y, z;
	cin >> x >> y >> z;
	int w = x - (2*z);
	int now = 0; 
	int cnt = 0;
	for(;;){
		now += y;
		if(now > w){
			break;
		}else{
			now += z;
			cnt++;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256