akhauriyash/Code-Regression huggingface dataset:
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long ll; typedef long double ld ;using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define ALL(name) (name).begin(),(name).end()
#define REP(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){ios::sync_with_stdio(0);cin.tie(nullptr); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  string s;
  cin >> s;
  ll N = s.length();
  ll cnt = 0;
  ll ans = 0;
  for (ll i = N-1; i >= 0; i--) {
    if (s[i] == 'B') {
      ans += N-i-1-cnt;
      cnt++;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 720
#include <iostream>

using namespace std;

#define MAX 10100
 
int prime[MAX];
 
void is_prime(){
    for(int i = 0 ; i < MAX ; i++) prime[i] = 0;
    prime[0] = prime[1] = 1;
 
    for(int i = 2 ; i*i < MAX ; i++)
	if(!prime[i])
	    for(int j = 2*i ; j < MAX ; j += i)
		prime[j] = 1;
}
 
int main(){
    int n;
 
    is_prime();
    while(cin >> n){
	int cnt = 0;
	for(int i = 1, j = n ; i <= n && j >= 1 ; i++,j--)
	    if(!prime[i]&&!prime[j]) cnt++;
 
	cout << cnt << endl;
    } 
    return 0;
}

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

int main() {
   while (1) {
      string s;
      getline(cin, s);
      if (s == ".") break;

      stack<char> stk;
      bool ok = true;
      int n = s.size();
      for (int i = 0; i < n; i++) {
         if (s[i] == '(') stk.push(s[i]);
         if (s[i] == '[') stk.push(s[i]);
         if (s[i] == ')') {
            if (stk.empty() || stk.top() != '(') {
               ok = false;
               break;
            } else {
               stk.pop();
            }
         }
         if (s[i] == ']') {
            if (stk.empty() || stk.top() != '[') {
               ok = false;
               break;
            } else {
               stk.pop();
            }
         }
      }
      if (ok && stk.empty()) {
         puts("yes");
      } else {
         puts("no");
      }
   }
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(M);
  vector<int> B(M);
  for (int i = 0; i < M; i++) {
    int a,b;
    cin >> a >> b;
    A.at(i) = a;
    B.at(i) = b;
  }
  for (int i = 0; i < N; i++) {
    int sum = 0;
    for (int j = 0; j < M; j++) {
      if (A.at(j) == i + 1 || B.at(j) == i + 1) {
        sum += 1;
      }
    }
    cout << sum << endl;
  }
}

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

int main() {
	int h,w; cin>>h>>w;
	vector<vector<int>> a(h,vector<int>(w));
	for (int i=0; i<h; i++)
		for (int j=0; j<w; j++)
			cin>>a[i][j];

	vector<int> x1,y1,x2,y2;
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			if (a[i][j]%2==1) {
				a[i][j]--;
				if (i==h-1 and j==w-1) continue;
				if (j<w-1 or i==h-1) {
					a[i][j+1]++;
					x1.push_back(i+1);
					y1.push_back(j+1);
					x2.push_back(i+1);
					y2.push_back(j+2);
				}
				else {
					a[i+1][j]++;
					x1.push_back(i+1);
					y1.push_back(j+1);
					x2.push_back(i+2);
					y2.push_back(j+1);
				}
			}
		}
	}

	cout << x1.size() << endl;
	for (int i=0; i<x1.size(); i++)
		cout << x1[i] << ' ' << y1[i] << ' ' << x2[i] << ' ' << y2[i] << endl;

	return 0;
}


Measured memory_bytes: 5224
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		boolean[] isZero = new boolean[N];
		for (int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
			if (h[i] == 0) {
				isZero[i] = true;
			}
		}
		sc.close();

		int cnt = 0;
		for (int i = 0; i < N; i++) {
			while (h[i] > 0) {
				for (int j = i; j < N; j++) {
					if (isZero[j]) {
						break;
					}

					h[j]--;
					if (h[j] == 0 && !isZero[j]) {
						isZero[j] = true;
					}
				}
				cnt++;
			}

		}

		System.out.println(cnt);
	}
}


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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main(){
	int n;
	cin>>n;
	ll b,x=0,y=0;
	for(int i=0;i<n;i++){
		cin>>b;
		if(b%4==0){
			x++;
		}
		else if(b%2==0){
			y++;
		}
	}
	if(y==1){
		y--;
	}
	if(x*2+1>=n||y==n||x*2+y>=n){
		cout << "Yes"<<endl;
	}
	else{
		cout <<"No"<<endl;
	}
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }

string s;
int w;

int main() {
	cin >> s >> w;
	
	inc(i, ce(s.size(), w)) { cout << s[i * w]; }
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
a = int(raw_input()) #500
b = int(raw_input()) #100
c = int(raw_input()) #50
x = int(raw_input())

xcount=0

q=min(x/500,a)
for i in range(q+1):
   y=x-500*i
   r=min(y/100,b)
   for j in range(r+1):
      z=y-100*j
      if (z%50==0 and (z/50)<=c) :xcount=xcount+1

print xcount




Measured memory_bytes: 2568
program main
	implicit none
	integer :: a(1:5),i, temp, ans = 0
	do i = 1, 5
		read(*, *) a(i)
	end do

	temp = 1
	do i = 2, 5
		if(mod(a(temp),10) > mod(a(i),10) .AND. mod(a(i),10) > 0) then
			temp = i
		end if
	end do
	do i = 1, temp-1
		if(mod(a(i),10) /= 0) then
			ans = ans + (a(i) + (10 - mod(a(i),10))) 
		else
			ans = ans + a(i)
		end if
	end do
	
	do i = temp+1, 5
		if(mod(a(i),10) /= 0) then
			ans = ans + (a(i) + (10 - mod(a(i),10))) 
		else
			ans = ans + a(i)
		end if
	end do

	write(*, *) ans + a(temp)

end program main

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
i = 1
TF = "F"
for j in range(N):
    if A[j] == i:
        i += 1
        TF = "T"
i -= 1
if TF == "T":
    print(N-i)
else:
    print(-1)


Measured memory_bytes: 25768
a, b = input().split()
s,t = "", ""
i, j = 0, 0
while(i<int(b)):
  s += a
  i += 1

while (j<int(a)):
  t += b
  j += 1

if (int(a)<int(b)):
  print(s)
elif(int(a) == int(b)):
  print(s)
else:
  print(t)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		int n = sc.nextInt();
		int t = sc.nextInt();
		int min = 1001;
		for(int i = 0; i < n; i++) {
			int c = sc.nextInt();
			if(sc.nextInt() <= t) {
				if(min > c) min = c;
			}
		}
		if(min <= 1000)System.out.println(min);
		else System.out.println("TLE");
	}
	Main(){doIt();}
	public static void main(String[] args) {
		new Main();
	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#include<cstdio>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<map>
#include<set>
#include<queue>
#include<set>
#define READ                freopen("in.txt", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)
#define INF9                1000000010
#define INF18               1000000000000000010
#define dist(ax,ay,bx,by)   sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define gcd(a,b)            __gcd(a,b)
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define m_p(a,b)            make_pair(a,b)
#define sqr(a)              ((a)*(a))
#define pb                  push_back
#define bpll(a)             __builtin_popcountll(a)
#define MX                  1000000
#define PI                  acos(-1)
#define mod                  1000000007
#define cnt_bin(n)          __builtin_clzll(0ll) - __builtin_clzll(n)

typedef long long lli;
using namespace std;

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

    if(n>=400 && n<600) cout<<8<<endl;
    if(n>=600 && n<800) cout<<7<<endl;
    if(n>=800 && n<1000) cout<<6<<endl;
    if(n>=1000 && n<1200) cout<<5<<endl;
    if(n>=1200 && n<1400) cout<<4<<endl;
    if(n>=1400 && n<1600) cout<<3<<endl;
    if(n>=1600 && n<1800) cout<<2<<endl;
    if(n>=1800 && n<2000) cout<<1<<endl;

    return 0;
}


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

int main()
{
    int n, l;
    cin>>n>>l;
    string str[n];
    for(int i=0; i<n; i++) cin>>str[i];
    sort(str, str+n);
    string ans = "";
    for(int i=0; i<n; i++) ans += str[i];
    cout<<ans<<endl;
}


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

int dp[1010][1010];
const int INF = 500010;

int main() {
    string s, t; cin >> s >> t;
    int N = s.length(), M = t.length();

    for(int i=0; i<=N; i++) dp[i][0] = i;
    for(int j=0; j<=M; j++) dp[0][j] = j;

    for(int i=0; i<N; i++) {
        for(int j=0; j<M; j++) {
            int cost = (s[i] != t[j]);
            dp[i+1][j+1] = min({dp[i][j+1]+1, dp[i+1][j]+1, dp[i][j]+cost});
        }
    }
    cout << dp[N][M] << endl;
    return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;
const ll rmod[2] = {2147483647,2147483629};
const ll B[2] = {2147483624, 2147483627};

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

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

int main() {
  ll N,M,K;
  cin>>N>>M>>K;
  ll ans = (M*(M-1)*(M+1)/6%mod*N%mod*N + N*(N-1)*(N+1)/6%mod*M%mod*M)%mod;
  ll c = 1;
  rep(i,K-2){
    c = (c * (N*M-i-2))%mod;
    c = (c*pow((ll)i+1,mod-2,mod))%mod;
  }
  ans = (ans*c)%mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 3612
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

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 long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int m = fs.nextInt();
        System.out.println(24 + 24 - m);
    }
}


Measured memory_bytes: 81748
import java.util.*;

public class Main {

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

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		int[] c = new int[N - 1];
		int[] S = new int[N - 1];
		int[] F = new int[N - 1];

		for (int i = 0; i < N - 1; i++) {
			c[i] = sc.nextInt();
			S[i] = sc.nextInt();
			F[i] = sc.nextInt();
		}

		for (int i = 0; i < N; i++) {
			int[] at = new int[N];
			int[] dt = new int[N];
			if (i == N - 1) {
				dt[i] = 0;
			} else {
				dt[i] = S[i];
			}
			for (int j = i + 1; j < N; j++) {
				at[j] = dt[j - 1] + c[j - 1];
				if (j < N - 1) {
					dt[j] = (at[j] < S[j]) ? S[j] : S[j] + F[j] * roundUp(at[j] - S[j], F[j]);
				}
			}
			System.out.println(at[N - 1]);
		}

		sc.close();
	}

	private int roundUp(int a, int b) {
		int res = a / b;
		if (a % b == 0) {
			return res;
		} else {
			return res + 1;
		}
	}

}

Measured memory_bytes: 28320
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int n,d,sum,ans,i,j,k;
double l;
int main(){
    cin>>n>>d;
    int x[n][d]={};
    for(i=0;i<n;i++)for(j=0;j<d;j++)cin>>x[i][j];
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            sum=0;
            for(k=0;k<d;k++)sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            l=sqrt(sum);
            if(l-floor(l)<0.000001)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

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

    int n;
    cin >> n;

    string s, t;
    cin >> s >> t;

    string x;
    for(int i=0; i<n; i++){
        x+=s[i];
        x+=t[i];
    }
    cout << x << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int x,y,a,b,c,d,ans;
int solve(int x,int y)
{
	if(x<=y)
		return y-x;
	return 2+x-y;
}
int main()
{
	scanf("%d%d",&x,&y);
	a=solve(x,y);
	b=solve(-x,y)+1;
	c=solve(-x,-y)+2;
	d=solve(x,-y)+1;
	ans=min(a,min(b,min(c,d)));
	printf("%d\n",ans);
	return 0;  
}


Measured memory_bytes: 256
N = int(input())

def solve(n):
    if 1 <= n <= 26:
        return chr(ord('a') + (n-1) % 26)
    else:
        q, r = divmod(n, 26)
        if r == 0:
            q -= 1
            r += 26
        return solve(q) + chr(ord('a') + (r-1) % 26)

print(solve(N))

Measured memory_bytes: 9176
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<int, int> > VPII;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	string S, S2 = "CODEFESTIVAL2016";
	int ans = 0;
	cin >> S;
	FOR(i, 0, S.length()) {
		if (S[i] != S2[i]) {
			ans++;
		}
	}
	O(ans);


	return 0;
}


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

int main () {
  string s;
  int ans = 0;
  cin >> s;
  for(char c: s) {
    if(c == '+') {
      ans++;
    } else {
      ans--;
    }
  }
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SEKAI_NO_OWARI return 0;
#define INIT cin.tie(0); ios::sync_with_stdio(false);
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

void solve() {
	long long n; cin >> n;
	cout << (n*(n - 1)) / 2 << "\n";
}

int main(void) {
	INIT
	solve();
	SEKAI_NO_OWARI
}

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

int main() {
    string s;
    cin >> s;
    int digit = s.size();
    int k = s.front() - '0';

    // n 以下の整数の特徴
    // 1. digit 桁目は k 以下
    // 2. それ以外の桁は 9 以下
    // よって答えの上限は k + 9(digit - 1)
    //
    // 答えの元となる整数は次の2通り
    // a. k999...999
    // b. (k-1)999...999

    bool is_a = true;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] != '9') {
            is_a = false;
            break;
        }
    }

    int ans;
    if (is_a)
        ans = k + 9 * (digit - 1);
    else
        ans = k + 9 * (digit - 1) - 1;

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

Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 310;

char a[N][N];
int rsum[N][N], csum[N][N], ans[N][N];
int nxt = 1;

void solve(int r1, int r2, int c1, int c2);

int main() {
	fast_cin();
	int h, w, k;
	cin >> h >> w >> k;
	for (int i = 1; i <= h; ++i) {
		cin >> (a[i] + 1);
	}
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			rsum[i][j] = rsum[i][j - 1] + (a[i][j] == '#');
		}
		// cout << i << ' ' << rsum[i][w] << endl;
	}
	for (int j = 1; j <= w; ++j) {
		for (int i = 1; i <= h; ++i) {
			csum[j][i] = csum[j][i - 1] + (a[i][j] == '#');
		}
	}
	solve(1, h, 1, w);
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cout << ans[i][j] << ' ';
		}
		cout << '\n';
	}
}

void solve(int r1, int r2, int c1, int c2) {
	int cnt = 0;
	for (int r = r1; r <= r2; ++r) {
		cnt += (rsum[r][c2] - rsum[r][c1 - 1]);
	}
	// cout << r1 << ' ' << r2 << ' ' << c1 << ' ' << c2 << ' ' << cnt << endl;
	if (cnt == 1) {
		for (int r = r1; r <= r2; ++r) {
			for (int c = c1; c <= c2; ++c) {
				ans[r][c] = nxt;
			}
		}
		++nxt;
	} else {
		int temp = 0;
		for (int r = r1; r < r2; ++r) {
			temp += (rsum[r][c2] - rsum[r][c1 - 1]);
			if (temp and temp < cnt) {
				solve(r1, r, c1, c2);
				solve(r + 1, r2, c1, c2);
				return;
			}
		}
		temp = 0;
		for (int c = c1; c < c2; ++c) {
			temp += (csum[c][r2] - csum[c][r1 - 1]);
			if (temp and temp < cnt) {
				solve(r1, r2, c1, c);
				solve(r1, r2, c + 1, c2);
				return;
			}
		}
		assert(0);
	}
}

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

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
 
int main() {
    int h,w;
    while(cin>>w>>h,h || w){
        bool board[40][40][4];
        rep(i,h){
            rep(j,w){
                rep(k,4){
                    board[i][j][k]=true;
                }
            }
        }
        rep(i,h) board[i][0][3]=false;
        rep(i,h) board[i][w-1][2]=false;
        rep(i,w) board[0][i][1]=false;
        rep(i,w) board[h-1][i][0]=false;

        int inp;
        rep(i,2*h-1){
            int l;
            if(i%2==0) l=w-1;
            else l=w;
            rep(j,l){
                cin>>inp;
                if(inp==1){
                    if(i%2==0){
                        board[i/2][j][2]=false;
                        board[i/2][j+1][3]=false;
                    }
                    else{
                        board[i/2][j][0]=false;
                        board[i/2+1][j][1]=false;
                    }
                }
            }
        }

        int dist[40][40];
        rep(i,h){
            rep(j,w){
                dist[i][j]=-1;
            }
        }
        dist[0][0]=1;
        queue<pair<int,int>> q;
        q.push({0,0});

        while(!q.empty()){
            pair<int,int> t=q.front(); q.pop();
            int x=t.first;
            int y=t.second;
            rep(i,4){
                if(!board[x][y][i]) continue;
                int nx=x+dx[i];
                int ny=y+dy[i];
                if(dist[nx][ny]!=-1) continue;
                dist[nx][ny]=dist[x][y]+1;
                q.push({nx,ny});
            }
        }

        if(dist[h-1][w-1]==-1) cout<<0<<endl;
        else cout<<dist[h-1][w-1]<<endl;
    }
}


Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
  ll N,AE=0,AW=0,TE=0,TW=0,sum=MOD,dsum=0;
  string S;
  cin >> N >> S;
  rep(i,S.size()){
    if(S[i]=='E'){
      AE++;
    }
    else{
      AW++;
    }
  }
  rep(i,N){
    dsum=0;
    dsum+=TW;
    if(S[i]=='E'){
      TE++;
    }
    else{
      TW++;
    }
    dsum+=AE-TE;
    if(dsum<sum){
      sum=dsum;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 832
from bisect import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
data=[0]*n
for i in range(n):
    l=bisect(c,b[i])
    data[i]=n-l
data+=[0]
for i in range(n):
    data[n-i-1]+=data[n-i]
ans=0
for i in range(n):
    l=bisect(b,a[i])
    ans+=data[l]
print(ans)

Measured memory_bytes: 105444
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#ABC146-B
n=ii()
s=list(ss())
for i in range(len(s)):
    p=ord(s[i])
    if p+n >=91:

        s[i]=chr(p+n-26)

    else:

        s[i]=chr(p+n)
print("".join(s))



Measured memory_bytes: 66028
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int[] arr = new int[5];
		for (int i = 0; i < 5; i++) {
			arr[i] = scn.nextInt();
		}
		for (int i = 0; i < 5; i++) {
			int a = arr[i];
			if (a == 0) {
				System.out.println(i + 1);
			}
		}
	}
}

Measured memory_bytes: 27000
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int x;set<int> s;
  for(int i=0;i<n;i++){cin>>x;s.insert(x);}
  int k=s.size();
  if(k&1)cout<<k;
  else cout<<k-1;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long N = long.Parse(Console.ReadLine());
		long mod = 1000000007;
		long[]M = new long[N];
		long[]P = new long[N];
		M[0] = 1;
		P[0] = 1;
		for(var i=1;i<N;i++){
			M[i] = (M[i-1] + Mpow(i+1,mod-2,mod)) % mod;
			P[i] = P[i-1] *(i+1) % mod;
		}
		string[] str = Console.ReadLine().Split();
		long[]A = new long[N];
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str[i]);
		}
		long ans = 0;
		for(var i=0;i<N;i++){
			//ans = (ans + P[N-1] * A[i] % mod * M[i] % mod + P[N-1] * A[i] % mod * M[N-i-1] % mod - P[N-1] * A[i] % mod * M[0] % mod) % mod;
			ans = (ans + P[N-1] * A[i] % mod * (M[i] + M[N-i-1] - 1) % mod) % mod;
		}
		Console.WriteLine(ans);
	}
	
	public static long Mpow(long x,long n,long m)
	{
		long ans = 1;
		while(n > 0){
			if(n % 2 == 1){
				ans = ans * x % m;
				n -= 1;
			}
			x = x * x % m;
			n /= 2;
		}
		return ans;
	}
}

Measured memory_bytes: 20576
fun main() {
    val builder = StringBuilder()

    val x = readInputLine().toLong()

    val gcd = gcd(x, 360L)

    builder.appendln(x * 360L / gcd / x)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}

tailrec fun gcd(a: Long, b: Long): Long =
    when {
        b > a -> gcd(b, a)
        b == 0L -> a
        else -> gcd(b, a % b)
    }


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

int main() {
  int N, n, nn;
  int i;
  cin >> N;
  int s[N+1];
  for (i=1; i<=N; i++) cin >> s[i];
  i=0;
  n=1;
  while (s[n] !=0) {
    nn=s[n];
    s[n]=0;
    n=nn;
    i++;
    if ( n==2 ) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;  
}


Measured memory_bytes: 640
#include<iostream>
#include<climits>

int count;

void merge(int*, int, int, int);
void mergeSort(int*, int, int);

using namespace std;

int main(){
  int i, n, s_in;
  int l, m, r;
  int S[500000];
  cin >> n;
  for(i=0;i<n;++i) cin >> S[i];
  mergeSort(&S[0], 0, n);

  for(i=0;i<n;++i){
    cout << S[i];
    if(i != n-1) cout << " ";
  }
  cout << "\n" << count << "\n";
  
  return 0;
}

void merge(int* A, int left, int mid, int right){
  int i, j;
  int n1 = mid - left, n2 = right - mid;
  int L[n1], R[n2];
  for(i=0;i < n1;++i) L[i] = A[left+i];
  for(i=0;i < n2;++i) R[i] = A[mid+i];
  L[n1] = INT_MAX, R[n2] = INT_MAX;
  
  i=0, j=0;
  for(int k=left;k < right;++k){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
    count++;
  }
}

void mergeSort(int* A, int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left+right)/2;
    mergeSort(&A[0], left, mid);
    mergeSort(&A[0], mid, right);
    merge(&A[0], left, mid, right);
  }
}



Measured memory_bytes: 6888
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    }else if(n == 2){
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

void solve() {
    int N;
    cin >> N;
    vector<pair<ll, ll>> v;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        a += 1e9 + 7;
        b += 1e9 + 7;
        v.emplace_back(a, b);
    }
    sort(v.begin(), v.end());
    pair<ll,ll> mini = make_pair(v[0].first, v[0].second), maxi = make_pair(v[0].first, v[0].second);
    ll ans = 0;
    rep(i, N) {
        ans = max(ans, v[i].first + v[i].second - mini.first - mini.second);
        ans = max(ans, v[i].first - maxi.first + maxi.second - v[i].second);
        if (v[i].first + v[i].second < mini.first + mini.second) {
            mini = v[i];
        }
        if (v[i].first - v[i].second < maxi.first - maxi.second) {
            maxi = v[i];
        }
    }
    cout << ans;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();

    return 0;
}


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

int main() {
    string a,b;
    cin>>a>>b;
    ll n=atoi((a+b).c_str());
    if((ll)sqrt(n)==sqrt(n)){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

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

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

    int n;
    cin >> n;

    const int N = 100004;
    vector<bool> F(N, true);
    for(int i = 2; i <= (int)(sqrt(N)); i++){
        if(!F[i]) continue;
        for(int j = i + i; j <= N; j += i){
            F[j] = false;
        }
    }

    for(int i = n; i <= N; i++){
        if(F[i]){
            cout << i << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 256
N = int(input())
ABC = []
for _ in range(N):
    line = list(map(int,input().split()))
    ABC.append(line)
DP = [ABC[0]]
for i in range(1,N):
    a = ABC[i][0] + max(DP[i-1][1],DP[i-1][2])
    b = ABC[i][1] + max(DP[i-1][2],DP[i-1][0])
    c = ABC[i][2] + max(DP[i-1][0],DP[i-1][1])
    DP.append([a,b,c])
print(max(DP[-1]))

Measured memory_bytes: 50168
#include <iostream>

int main()
{
    while (true)
    {
        int x, y;
        std::cin >> x >> y;
        
        if (x == 0 && y == 0)
            break;
        else
        {
            if (x < y)
                std::cout << x << " " << y << std::endl;
            else
                std::cout << y << " " << x << std::endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3008
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>
#include <iomanip>

using namespace std;

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

	if (x == 1)cout << 0 << endl;

	if (x == 0)cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n, temp, cnt = 0;
		ArrayList<Integer> A = new ArrayList<Integer>();
		
		n = sc.nextInt();
		for(int i = 0; i < n; i++){
			A.add(sc.nextInt());
		}
		
		for(int i = 0; i < n - 1; i++){
			for(int j = n - 1; j > i; j--){
				if(A.get(j - 1) > A.get(j)){
					temp = A.get(j - 1);
					A.set(j - 1, A.get(j));
					A.set(j, temp);
					cnt ++;
				}
			}
		}
		
		for(int i = 0; i < n - 1; i++){
			System.out.print(A.get(i) + " ");
		}
		System.out.println(A.get(n-1));
		System.out.println(cnt);
	}
}

Measured memory_bytes: 26400
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

vector<ll> v;

ll f(ll a){
	vector<ll> v1 = v;
	v1[0]-=a;
	rep(i,1,v1.sz){
		v1[i]-=v1[i-1];
	}
	v1[v1.sz-1]-=a;
	return abs(v1[v1.sz-1]);
}

int main() {
	ll n;
	cin>>n;
	rep(i,0,n){
		ll a;
		cin>>a;
		v.pb(a);
	}
	long long left = 0;
	long long right = v[0];

	while (left != right) {
		long long d = (right - left) / 3;
		long long l = f(left + d);
		long long r = f(right - d);
		if (d == 0) {
			if (l > r)left++;
			else right--;
		}
		else {
			if (l > r)left = left + d;
			else right = right - d;
		}
	}
	vector<ll> ans;
	ans.pb(left*2);
	v[0]-=left;
	v[v.sz-1]-=left;
	rep(i,0,v.sz-1){
		ll a = v[i];
		ans.pb(v[i]*2);
		v[i]-=a;
		v[i+1]-=a;
	}
	rep(i,0,ans.sz){
		cout << ans[i];
		if(i!=ans.sz-1)cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3940
N = int(input())
A = list(map(int,input().split()))
odds = len(list(filter(lambda x: x%2 == 1,A)))
baisu4 = len(list(filter(lambda x: x%4 == 0,A)))
evens = N-odds
if odds == 0:print('Yes')
elif evens == baisu4 and baisu4+1 >= odds:
    print('Yes')
elif evens != baisu4 and baisu4 >= odds:
    print('Yes')
else:
    print("No")



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

long stackData[200];
int stackPointer = -1;

long pop(){	
	long result = stackData[stackPointer];
	stackPointer--;
	return result;
}

void push(long n){
	stackPointer++;
	stackData[stackPointer] = n;
}

void clear(){
	stackPointer = -1;
}

int main(){
	string str;
	string tmp;
	getline(cin, str);

	long a, b;

	istringstream s(str);
	for(int i = 0; i < 200; i++){
		s >> tmp;
		switch(tmp[0]){
			case '+':
				a = pop();
				b = pop();
				push(b + a);
				break;
			case '-':
				a = pop();
				b = pop();
				push(b - a);
				break;
			case '*':
				a = pop();
				b = pop();
				push(b * a);
				break;
			case '/':
				a = pop();
				b = pop();
				push(b / a);
				break;
			default:
				push(stoi(tmp));
				break;
		}
		if(s.tellg() == -1){
			break;
		}

	}
	cout << pop() << endl;
	return 0;
}


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

typedef long long ll;

const int inf = 1 << 30;

int main() {
    ios_base::sync_with_stdio(false);

    int n, d, a;
    cin >> n >> d >> a;

    vector<pair<int, int> > P;

    for(int i = 0; i < n; i++) {
        int x, h;
        cin >> x >> h;

        P.push_back({x, h});
    }

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

    vector<int> prefix(n + 1);
    prefix[0] = (P[0].second + a - 1) / a;

    ll ans = prefix[0];

    for(int i = 1; i < n; i++) {
        auto it = lower_bound(P.begin(), P.end(), make_pair(P[i].first - 2 * d, -inf));
        int l = it - P.begin();

//        cout << "l " << l << endl;
//        cout << "x " << (*it).first << endl;

        ll sum = prefix[i - 1] - (l > 0 ? prefix[l - 1] : 0);

//        cout << "sum " << sum << endl;

        P[i].second = max(0LL, P[i].second - sum * a);

        ll t = (P[i].second + a - 1) / a;

//        cout << "t " << t << endl;

        prefix[i] = prefix[i - 1] + t;

        ans += t;

//        cout << t << " ";
//        cout << endl;
    }

    cout << ans << endl;
}

/**
* [x - d, x + d]
*/


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

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

    if(s.size() <= k){
        cout << s << endl;
    }
    else{
        rep(i,k){
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3552
A1, A2, B1, B2 = map(int, input().split())
if A1 <= B1 <= A2 <= B2:
    print(A2 - B1)
elif B1 <= A1 <= B2 <= A2:
    print(B2 - A1)
elif A1 <= B1 <= B2 <= A2:
    print(B2 - B1)
elif B1 <= A1 <= A2 <= B2:
    print(A2 - A1)
else:
    print(0)


Measured memory_bytes: 2940
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/21/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr ll MOD = 998244353;
constexpr ll MAX_GRANDY = 512;

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

  int N; cin>>N;
  vector<int> graph[3][N+1];
  for (int i = 0; i < 3; i++) {
    int M; cin>>M;
    for (int m = 0; m < M; m++) {
      int a,b; cin>>a>>b;
      if (a > b) swap(a,b);
      graph[i][a].push_back(b);
    }
  }

  vector<ll> pw(N+1);
  pw[0] = 1;
  constexpr ll p = ll(1e18)%MOD;
  for (int i = 1; i <= N; i++) {
    pw[i] = pw[i-1]*p%MOD;
  }

  array<array<ll, MAX_GRANDY>, 3> cnt={};
  for (int i = 0; i < 3; i++) {
    vector<int> gr(N+1, 0);
    for (int v = N; v >= 1; v--) {
      set<int> ps;
      for (auto t : graph[i][v])
        ps.insert(gr[t]);
      while (ps.count(gr[v]) > 0)
        ++gr[v];
      cnt[i][gr[v]] += pw[v];
      cnt[i][gr[v]] %= MOD;
    }
  }

  ll ans = 0;
  for (int i = 0; i < MAX_GRANDY; i++) for (int j = 0; j < MAX_GRANDY; j++) {
    ans += cnt[0][i] * cnt[1][j] % MOD * cnt[2][i^j] % MOD;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13824
#include <cstdio>
#include <algorithm>
using std::sort;
using std::lower_bound;
using std::upper_bound;

const int MAXN=200003;
long long a[MAXN],L[MAXN],R[MAXN];

int main(void)
{
    int i,N;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%lld",a+i);
        L[i] = i+1+a[i];
        R[i] = (i+1)-a[i];
    }
    sort(R,R+N);
    long long ret = 0,lwbd,upbd;
    for(i=0;i<N;i++)
    {
        lwbd = lower_bound(R,R+N,L[i]) - &R[0];
        upbd = upper_bound(R,R+N,L[i]) - &R[0];
        ret+=upbd-lwbd;

    }
    printf("%lld\n",ret);
    return 0;
}



Measured memory_bytes: 6416
#include <iostream>
#include <vector>

using namespace std;


int main()
{
  int n, m;
  int ans = 0;
  int sum = 0;

  cin >> n >> m;
  vector <int>v(m);

  for (int i = 0; i < m; i++) {
    cin >> v[i];
    sum += v[i];
  }

  ans = n - sum;
  if (ans < 0) {
    cout << -1;
  } else {
    cout << ans;
  }
  return 0;
}

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

int main() {
    long long N;
    cin >> N;
    vector <long long> A(N);
    for (long long i=0; i<N; i++) cin >> A.at(i);
    vector <long long> s(N+1, 0);
    map<long long, long long> m;
    m[0]++;
    for (long long i=0; i<N; i++) {
        s.at(i+1) = s.at(i) + A.at(i);
        m[s.at(i+1)]++;
    }
    long long res = 0;
    for (auto it : m) {
        res += it.second * (it.second-1) / 2;
    }
    cout << res << endl;
}

Measured memory_bytes: 18664
import math
import sys
sys.setrecursionlimit(1000000)
dp = [[0]*(1000+1) for x in range(1000+1)]
tab = []
def main():
    global n,m
    n,m = map(int,input().split())
    
    for x in range(n):
        tab.append(input())
    x = 0
    while x < n and tab[x][0] != "#":
        dp[x][0] = 1
        x += 1
    x = 0
    while x < m and tab[0][x] != "#":
        dp[0][x] = 1
        x += 1
    for x in range(1,n):
        for y in range(1,m):
            if tab[x][y]!="#":
                dp[x][y] = dp[x][y-1] + dp[x-1][y]
    
    print(dp[n-1][m-1]%(10**9+7))
main()

Measured memory_bytes: 208988
x, y = map(int, input().split())
a = int(2*x - 0.5*y)
b = int(-x + 0.5*y)

if y % 2 == 1:
    print('No')
    exit()

if a < 0 or b < 0:
    print('No')
    exit()

print('Yes')


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  int count = 1;
  int Max = vec.at(0);
  for(int j = 1;j < N;j++) {
    if(Max == vec.at(j)) {
      count++;
    }
    else if(Max < vec.at(j)) {
      Max = vec.at(j);
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	int A,S,M;
	A = a+b;
	S = a-b;
	M = a*b;
	if(A>=S && A>=M) printf("%d\n",A);
	else if(S>=A && S>=M) printf("%d\n",S);
	else if(M>=A && M>=S) printf("%d\n",M);
	return 0;
}



Measured memory_bytes: 128
'use strict'
const Main = (arg) => {
  let input = arg.trim().split('\n');
  let C = input[0];
  let code = C.charCodeAt(0) + 1;
  let Ans = String.fromCharCode(code);
  console.log(Ans);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21192
#include <bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define rep(n) for(int i=0; i<n; i++)
#define v(n) vector<n>
using namespace std;
signed main(){
    int ans=-1;
    int n; cin>>n;
    v(int) a(n); bool no2=true;
    rep(n){
        cin>>a.at(i);
        if(a.at(i)==2) no2=false;
    }
    if(no2){cout<<ans<<endl; return 0;}
    int d=a.at(0); ans=1;
    while (d!=2) {
        ans++;
        d=a.at(d-1);
        if(ans>n){
            cout<<-1<<endl; return 0;
        }
    }
    cout<<ans<<endl;
}

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

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

Measured memory_bytes: 5112