akhauriyash/Code-Regression huggingface dataset:
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N, M; cin >> N >> M;

    int ans = (1900 * M + 100 * (N - M))*(0x01 << M);
    cout << ans << endl;

    return 0;
}

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

int main() {
    string s;
    cin>>s;
    //a diff sol i came up with
    int n=s.length();
    int a[n]={0};
    for(int i=0;i<n;i++){
        if(s[i]=='A')a[i]=1;
        else if(s[i]=='Z')a[i]=2;
    }
    int l=0,r=0;
    for(int i=0;i<n;i++){
        if(a[i]==1){
            l=i;
            break;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(a[i]==2){
            r=i;
            break;
        }
    }
    cout<<(r-l)+1<<endl;
	return 0;
}

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

#define M 1000000007
#define ll long long int
#define endl "\n"
#define pb push_back
vector<bool> dp(100005);

void stone(int n, vector<ll> v, int k){
    for(int i=1; i<=k; i++){
        bool flag = 0;
        for(int j=0; j<n; j++){
            if(i-v[j]<0) { dp[i]=0; break; }
            else if(!dp[i-v[j]]) { dp[i]=1; flag=1; break; }
        }
        if(flag==0) dp[i]=0;
    }
    if(dp[k]==1) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    for(int i=0; i<n; i++) cin>>v[i];
    sort(v.begin(), v.end());
    stone(n,v, k);
    return 0;
}


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

constexpr int max_n = 2e5, no_of_dims = 2;

bool operator<(const array< int, no_of_dims >& less, const array< int, no_of_dims >& more)
{
    for (int i = 0; i < no_of_dims; ++i)
        if (less[i] != more[i])
            return less[i] < more[i];
    return false;
}

int n, len[no_of_dims];
vector< int > graph[no_of_dims][max_n + 1];
array< int, no_of_dims > components[max_n + 1];
map< array< int, no_of_dims >, int > counter;

void dfs(const int dimension_id, const int vertex_id, const int colour)
{
    components[vertex_id][dimension_id] = colour;
    for (int s : graph[dimension_id][vertex_id])
        if (not components[s][dimension_id])
            dfs(dimension_id, s, colour);
}

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

    cin >> n;

    for (int i = 0; i < no_of_dims; ++i)
        cin >> len[i];

    for (int i = 0; i < no_of_dims; ++i)
        for (int j = 0; j < len[i]; ++j)
        {
            int p, q; cin >> p >> q;
            graph[i][p].push_back(q);
            graph[i][q].push_back(p);
        }

    for (int i = 0; i < no_of_dims; ++i)
        for (int j = 1; j <= n; ++j)
            if (not components[j][i])
                dfs(i, j, j);

    for (int i = 1; i <= n; ++i)
        ++counter[components[i]];

    for (int i = 1; i <= n; ++i)
        cout << counter[components[i]] << ' ';
    cout << '\n';
}


Measured memory_bytes: 30740
H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7

# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, H + W + 2):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))


# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD


ans = 0
for w in range(B, W):
    ans += nCr(H - A - 1 + w, w) * nCr(A - 1 + W - w - 1, A - 1) % MOD
    ans %= MOD
print(ans % MOD)


Measured memory_bytes: 66672
#include <cstdio>

using namespace std;

int main(){
	for(int i=0;i<3;i++){
		int a,b,c,d,e,f;
		scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
		int ans = (d * 3600 + e * 60 + f) - (a * 3600 + b * 60 + c);
		int h = ans / 60 / 60;
		int m = ans / 60 - ans / 60 / 60 * 60;
		int s = ans % 60;
		printf("%d %d %d\n" ,h,m,s);
	}
}

Measured memory_bytes: 0
# AOJ 0120 Patisserie
# Python3 2018.6.23 bal4u

INF = 0x7fffffff
R = 100000
d = [[0 for j in range(13)] for i in range(13)]  # ロールケーキ円心間の水平距離
for i in range(3, 11):
	ii = i*i
	for j in range(i, 11):
		d[i][j] = d[j][i] = int(2*R * ii**0.5)
		ii += i

while 1:
	try: r = list(map(int, input().split()))
	except: break
	W = r.pop(0)
	if 2*sum(r) <= W:
		print("OK")
		continue
	n = len(r)
	W *= R
	dp = [[INF for j in range(1<<n)] for i in range(n)]
	for i in range(n): dp[i][1<<i] = r[i]*R
	lim = 1<<n
	for k in range(lim):
		for i in range(n):
			if k & (1<<i): continue
			for j in range(n):
				dp[i][k|(1<<i)] = min(dp[i][k|(1<<i)], dp[j][k] + d[r[i]][r[j]])
	w = 240*R
	for i in range(n):
		dp[i][lim-1] += r[i]*R
		if dp[i][lim-1] < w: w = dp[i][lim-1];
	print("OK" if w <= W else "NA")


Measured memory_bytes: 7248
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b;return true;} return false;}

int main(){
    int n,k; cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    ll dp[100105];
    rep(i,100105) dp[i] = INF;
    dp[0] = 0;

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

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

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

int nai[200];

int main()
{
    int n,i,j,k;
    cin >> n;
    int half = n/2;

    for(i=half,j=half+1;i>=1;i--,j++)
        nai[i]=j;
    cout << n*(n-1)/2 - half << endl;
    for(i=1;i<n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            if(nai[i]!=j) cout << i << ' ' << j << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
char str[10];
int main()
{
    cin>>str;
    for(int i=0;i<2;i++)
    {
        if(str[i]!=str[i+1]){
            cout<<"Yes"<<endl;
            return 0;
        }else{
        }
    }
    cout<<"No"<<endl;
}

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

int main(){
	int a,b,c,d;
	while( cin >> a >> b ){
		d = 0;
		c = a + b;
		while( c != 0 ){
			c/=10;
			d++;
		}
		cout << d << endl;
	}
	
	return 0; 
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t=1;
   // cin>>t;
   while(t--){
	   ll x,k,d,ans;
      cin>>x>>k>>d;
      if(k<=(abs(x))/d){
         if(x<0){
            x=x+k*d;
         }else{
            x=x-k*d;
         }
         k=0;
      }else{
          k=k-(abs(x))/d;
         if(x<0){
            x=x+((abs(x))/d)*d;
         }else{
            x=x-((abs(x))/d)*d;
         }
      }
      if(k&1){
         if(x<0){
            ans=x+d;
         }else{
            ans=x-d;
         }
      }else{
         ans=x;
      }
      cout<<abs(ans);
}
   return 0;
}



Measured memory_bytes: 3596
s = input()
if 1 <= int(s[:2]) <= 12:
    if 1 <= int(s[2:]) <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= int(s[2:]) <= 12:
        print('YYMM')
    else:
        print("NA")

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

using namespace std;

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

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

  long long ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    ans += ((a[i] + ans + b[i] - 1) / b[i] * b[i] - (a[i] + ans));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
int main()
{
long long int i,j=0,n,d;
double p,x,y;
scanf("%lld%lld",&n,&d);
for(i=0;i<n;i++)
{
scanf("%lf%lf",&x,&y);
p=sqrt(x*x+y*y);
if(p<=d)
j++;
}
printf("%lld",j);
return 0;
}





Measured memory_bytes: 2188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k; cin >> k;
    string s; cin >> s;
    if (s.size() <= k) cout << s << "\n";
    else cout << s.substr(0, k) << "...\n";
    return 0;
}

Measured memory_bytes: 3672
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	fx := 0
	t := n
	for t > 0 {
		fx += t % 10
		t /= 10
	}

	if n%fx == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans;
    ans = max(a*c,a*d);
    ans = max(ans,b*c);
    ans = max(ans,b*d);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
n=int(input())
x=[]
y=[]
for i in range(n):
    nx,ny=map(int,input().split())
    x.append(nx)
    y.append(ny)
from itertools import permutations
import math
per=list(permutations(range(n)))
def d(j):
    d=0
    for i in range(n-1):
        dx=abs(x[per[j][i]]-x[per[j][i+1]])
        dy=abs(y[per[j][i]]-y[per[j][i+1]])
        d+=math.sqrt(dx**2+dy**2)
    return d
s=0
for j in range(len(per)):
    s += d(j)
print(s/len(per))

Measured memory_bytes: 7996
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        if (a + b > 0) {
            System.out.println("1");
        } else if (a + b < 0) {
            System.out.println("-1");
        } else {
            System.out.println("0");
        }
    }
}



Measured memory_bytes: 26200
n,q=map(int,input().split())
s=input()
cnt=[0]*n
icnt=0
for i in range(n-1):
#    print(s[i:i+2])
    if s[i:i+2]=="AC":
      icnt=icnt+1
      cnt[i+1]=cnt[i]+1
    else:
      cnt[i+1]=cnt[i]
#print(cnt,s)
for i in range(q):
    li,ri=map(int,input().split())
#    print(s[li-1:ri].count("AC"))
#    print(sum(cnt[li-1:ri-1]))
    print(cnt[ri-1]-cnt[li-1])


Measured memory_bytes: 6060
x,y = map(int, input().split())

def nCk(n, k, mod=10**9+7):
  
  ans = 1
  for i in range(1, k+1):
    ans = ans*(n-i+1)*pow(i, mod-2, mod)%mod
    
  return ans

ans = 0

if (2*x-y)%3==0 and (2*y-x)%3==0 and 2*y-x>=0 and 2*x-y>=0:
  k = (2*x-y)//3
  l = (2*y-x)//3
  
  ans = nCk(k+l, min(k, l))

print(ans)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main() {
    while(1) {
        int x, y, s;

        cin >> x >> y >> s;

        if (x == 0 && y == 0 && s == 0) break;

        int ans = 0;
        for (int i = 1; i < s; ++i) {
            for (int j = 1; j < s; ++j) {
                if (i * (100 + x) / 100 + j * (100 + x) / 100 != s) continue;
                int price = i * (100 + y) / 100 + j * (100 + y) / 100;
                if (ans < price) ans = price;
            }
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

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

	int n, k;
	cin >> n >> k;
	map<int,int> m;

	vi a(n);
	vi c;
	vi d;
	rep(i, n) {
		int t;
		cin >> t;
		a[i] = t;
		m[t]++;
	}

	sort(all(a));

	//*
	int tmp = a[0];
	c.push_back(1);
	//d.push_back(a[0]);

	
	repr(i, 1, n) {
		if (a[i] != tmp) {
			tmp = a[i];
			c.push_back(1);
			//d.push_back(tmp);
		}
		else
		{
			c[c.size() - 1]++;
		}
	}
	sort(all(c));
	/*
	rep(i, d.size()) {
		c.push_back(m.count(d[i]));
	}
	*/
	//*
	int tp = c.size();
	if (tp <= k) {
		cout << '0' << endl;
		return 0;
	}

	int ans = 0;
	rep(i, c.size()) {
		tp--;
		ans += c[i];
		if (tp <= k)break;
	}
	//*/
	cout << ans << endl;


	return 0;
}


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

S = str(input())
f_half = int(S[0:2])
s_half = int(S[2:4])



if 0 < f_half and f_half <= 12 :
  if 0 < s_half and s_half <= 12 :
    print("AMBIGUOUS")
  else :
    print("MMYY")

else:
  if 0 < s_half and s_half <= 12 :
    print("YYMM")
  else :
    print("NA")

Measured memory_bytes: 3060
N=int(input())
B=list(map(int,input().split()))

A=[ ]
A0=B[0]
A.append(A0)
for i in range(N-2):
    Ai=min(B[i],B[i+1])
    A.append(Ai)
A.append(B[-1])    
print(sum(A))

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

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fore(i,a,b) for(int i = a; i < b; i++)
#define rfor(i, a, b) for(int i = a - 1; i >= b; i--)

ll n,h[2*100010],b[2*100010];
const int MAXN = 2e5;
ll tree[4*MAXN], NEUT = 0;

ll op(ll a, ll b){
  return max(a,b);
}

void update(int pos, ll value, int node = 1, int start = 1, int end = MAXN){
  int mid = (start+end)/2;
  if(start == end) tree[node] = value;
  else{
    if(start <= pos && pos <= mid) update(pos, value, 2*node, start, mid);
    else update(pos, value, 2*node+1, mid+1, end);
    tree[node] = op(tree[2*node], tree[2*node+1]);
  }
}

ll query(int l, int r, int node = 1, int start = 1, int end = MAXN){
  if(start > r || end  < l) return NEUT;
  if(l <= start && end <= r) return tree[node];
  int mid = (start+end)/2;
  return op(query(l, r, 2*node, start, mid), query(l, r, 2*node+1, mid+1, end));
}

int main() { 
    FIN;
    cin>>n;
    fore(i,0,n)cin>>h[i];
    fore(i,0,n)cin>>b[i];

    fore(i,0,n){
        ll q = query(1,h[i]-1);
        // cout<<q<<endl;
        update(h[i],q+b[i]);
    }

    cout<<query(1,2*100010)<<endl;

    return 0; 
} 

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
int main() {
	long long int N,a = 0,max = 0;
	cin >> N;
	vector<long long int> A(N);
	for (int i = 0; i < N;i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	for (int i = N - 1; i >= 0;i--) {
		if (a == A[i] && max == 0) {
			max = a;
			a = 0;
		}
		else if(a == A[i]){
			cout << a*max << endl;
			return 0;
		}
		else {
			a = A[i];
		}
	}
	cout << 0 << endl;
	return 0;
}



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

int main(){
    int n;
    string s;
    cin >> n >> s;
    ll r = 0,g = 0,b = 0;
    rep(i,n){
        if(s[i] == 'R')r++;
        if(s[i] == 'G')g++;
        if(s[i] == 'B')b++;
    }
    ll ans = r*g*b;
    rep(j,n)rep(i,j){
        int k = j + (j-i);
      	if(k < n) {
            if(s[i] == s[j])continue;
            if(s[i] == s[k])continue;
            if(s[j] == s[k])continue;
            ans--;
        }
    }
  	cout << ans << endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define REP(i,N) for (int i=0;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main(){
    int N;
    cin >>N;
    vector<double>A(N);
    REP(i,N) cin >>A[i];
    double inv1=0,inv2=0;
    REP(i,N) inv1=inv1+1/A[i];
    inv2=1/inv1;
    cout <<inv2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  ll n;
  cin >> n;
  ll dp[1000000][3];
  rep(i, n) {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    rep(j, 3) {
      rep(k, 3) {
        if(j != k) {
          dp[i+1][j] = max(dp[i][k]+a[j], dp[i+1][j]);
        }
      }
    }
  }
  cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}


Measured memory_bytes: 4480
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
using namespace std;
int main() {
	long long n,k=0;
	cin >> n;
	vector<int>vec(n);
	for (int i = 0; i < n; i++) {
		cin >> vec[i];
		if (i + 1 == vec[i]) {
			k++;
		}
	}
	if (n - 2 <= k) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	



}

Measured memory_bytes: 256
from itertools import combinations

n = int(input())
statements = []

for p in range(n):
    statement = []
    for s in range(int(input())):
        statement.append(list(map(int, input().split())))
    statements.append(statement)
    

def check_statements(honesty, statements):
    for h in range(len(honesty)):
        if honesty[h] == 1:
            for s in statements[h]:
                a, b = s
                if honesty[a-1] != b:
                    return False
    return True


def main():
    for h in range(n, 0, -1):
        for i in list(combinations(range(n), h)):
            p = [0 for _ in range(n)]
            for j in i:
                p[j] = 1
            if check_statements(p, statements):
                return h
    return 0

print(main())


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B;
	cout<<(6-A-B)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int x;
    scanf("%d", &x);
    int ans = 0, i = 1;
    while(x > 0){
        x -= i;
        ans++;
        i++;
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
import math        # factorical（階乗) # hypot(距離)
# import heapq
# from fractions import gcd # Python3.5以前 # lcm（最小公倍数） = (a*b)//gcd(a,b)
# from fractions import Fraction
# from math import gcd # Python3.6以降
# --------------------------------------------------------------

# 素因数,個数 の組リストを出力
def fctr1(n): 
    f = []
    c = 0
    r = int(n**0.5)
    for i in range(2,r+2):
        while n%i == 0:
            c += 1 
            n = n//i
        if c != 0:
            f.append([i,c])
            c = 0
    if n != 1:
        f.append([n,1])
    return f

a,b = map(int,input().split())

print(len(fctr1(math.gcd(a,b)))+1)

Measured memory_bytes: 9360
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    a, b, c = LI()
    print("No" if 4 * a * b >= (c - a - b) ** 2 or c - a - b < 0 else "Yes")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38640
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

h, w, m = na()
rs = [0] * h
cs = [0] * w

se = set()
for i in range(m):
    r, c = na()
    rs[r-1] += 1
    cs[c-1] += 1
    se.add((r-1)*w+c-1)

rmax = max(rs)
cmax = max(cs)

remax = rs.count(rmax)
cemax = cs.count(cmax)
if remax * cemax > m:
    print(rmax + cmax)
    sys.exit(0)

rmaxs = [i for i, _ in enumerate(rs) if _ == rmax]
cmaxs = [i for i, _ in enumerate(cs) if _ == cmax]
for r in rmaxs:
    for c in cmaxs:
        if r*w+c not in se:
            print(rmax + cmax)
            sys.exit(0)
print(rmax + cmax - 1)


Measured memory_bytes: 139060
a, op, b = map(str, input().split())
while not op == '?':
    a = int(a)
    b = int(b)
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    else:
        print(int(a/b))
        
    a, op, b = map(str, input().split())


Measured memory_bytes: 5596
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

N = ni()
ans = 0
for i in range(1,N+1):
    if (i % 3 !=0) and (i % 5 !=0):
        ans += i
print(ans)


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define maxn 1000005

int main()
{
    int x , y ;

    int res = 0 ;

    scanf("%d %d",&x,&y) ;

    res += max( 0 , 3-x+1 ) ;
    res += max( 0 , 3-y+1 ) ;

    if( x==1 && y==1 ) res += 4 ;

    printf("%d\n",res*100000) ;

    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=1e9+7;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>a(m);
    vector<ll>dp(n+1);
    rep(i,m)cin>>a[i];
   dp[0]=1;
   int j=0;
   
   
   if(j<m&&a[0]==1){
       dp[1]=0;
       j++;
   }
   else dp[1]=1;
   arep(i,2,n+1){
       if(j<m&&a[j]==i){
           dp[i]=0;
           j++;
       }  
       else{
           dp[i]=dp[i-1]+dp[i-2];
           dp[i]%=mod;
       }
       
   }
   cout<<dp[n]<<endl;
    return 0;
}

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

int main() {
	long long  n,a,b;
	cin>>n>>a>>b;
	long long num,numa,ans=0;
	
	num=n/(a+b);
	numa=n%(a+b);
	ans=num*a;
	numa=min(a,numa);
	ans=numa+ans;
	cout<<ans<<endl;
	// your code goes here
	return 0;
}

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

int n, W;
int weight[110], value[110];

int dp[110][10010];

int main() {
    cin >> n >> W;
    for (int i = 0; i < n; i++) {
        cin >> value[i] >> weight[i];
    }

    for (int w = 0; w <= W; w++) {
        dp[0][w] = 0;
    }

    for (int i = 0; i < n; i++) {
        for (int w = 0; w <= W; w++) {
            if (w >= weight[i]) {
                dp[i+1][w] = max(dp[i][w], dp[i][w-weight[i]]+value[i]);
            } else {
                dp[i+1][w] = dp[i][w];
            }
        }
    }

    cout << dp[n][W] <<endl;
}


Measured memory_bytes: 7068
#include<cstdio>

const int go[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};

int n, m;
char s[111][111];

bool chk(int x, int y) {
	for(int i=0;i<4;i++) {
		int _x = x+go[i][0], _y = y+go[i][1];
		if (_x<0 || _x>=n || _y<0 || _y>=m) continue;
		if (s[_x][_y]=='#') return true;
	}
	return false;
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i=0;i<n;i++) scanf("%s", s[i]);
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if (s[i][j]=='#' && !chk(i, j)) {
				puts("No");
				return 0;
			}
	puts("Yes");
	
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            if (N % 2 != 0)
            {
                WriteLine(0);
                return;
            }
            var dev = 5L;
            var ans = 0L;
            while (0 != N / (dev * 2))
            {
                ans += N / (dev * 2);
                dev *= 5;
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        graff graph = new graff(n);
        for(int i=0;i<m;i++)    {
            int x = in.nextInt();
            int y = in.nextInt();
            graph.adj[x].add(y);
        }
        int max = 0;
        for(int i=1;i<=n;i++)   {
            max = Math.max(max, graph.solve(i));
        }
        System.out.println(max);
        in.close();
    }
}

class graff {
    int n;
    int[] dp;
    boolean[] visited;
    List<Integer>[] adj;

    @SuppressWarnings("unchecked")
    graff(int size) {
        n = size;
        dp = new int[n+1];
        visited = new boolean[size+1];
        adj = new ArrayList[size+1];
        for (int i=1;i<=size;i++)    {
            adj[i] = new ArrayList<Integer>();
        }
    }

    int solve(int i)    {
        if(visited[i])  return dp[i];
        visited[i] = true;
        int best = 0;
        for(int u:adj[i])   {
            best = Math.max(best, solve(u)+1);
        }
        return dp[i] = best;
    }
}

Measured memory_bytes: 104896
#include<stdio.h>
double  dp[3000][3000];
double p[3000];
double prob(int i,int j)
{
//	printf("%d %d\n",i,j);
/*	if(i==0&&j==0)
	{
		return  ;
	}
	*/
	if(i<j)
	{
//		printf("0\n");
		dp[i][j]=0;
	
		return 0;
	}
	if(dp[i][j]!=-1)
	{
//		printf("%lf\n",dp[i][j]);
		return dp[i][j];
	}
	else
	{
		//if(j==0)
		//	dp[i][j]=prob(i-1,j)*(1-p[i]);
		//if(i==1)
		//	dp[i][j]=
	//	else
	//	{
		dp[i][j]=(prob(i-1,j-1)*p[i])+(prob(i-1,j)*(1-p[i]));
//		printf("%lf\n",dp[i][j]);
	//	}
		return dp[i][j];
	}
}
int main()
{
	int n,i,j;
	double x=0;
	scanf("%d",&n);
	for(i=0;i<3000;i++)
	{
		for(j=0;j<3000;j++)
			dp[i][j]=-1;
	}
	dp[0][0]=0;
	
	//for(i=2;i<=n;i++)
	//	dp[i][0]=(dp[i-1][0]*(1-p[i]));
	for(i=1;i<=n;i++)
	{
		scanf("%lf",&p[i]);
		
	}
	dp[1][0]=1-p[1];
	dp[1][1]=p[1];
	for(i=2;i<=n;i++)
		dp[i][0]=(dp[i-1][0])*(1-p[i]);
//	prob(n,n);
	for(i=(n/2)+1;i<=n;i++)
	{
		//printf("%d",i);
		//printf("*%lf\n",x);
		//prob(n,i);
		x=x+prob(n,i);
	}
//	printf("\nf\n");
/*	for(i=0;i<=n;i++)
	{
		for(int j=0;j<=3;j++)
			printf("%lf ",dp[i][j]);
		printf("\n");
	}*/
	printf("%0.10lf\n",x);
	return 0;
}






Measured memory_bytes: 70656
#include<iostream>
#define MAX 100
#define MAXNUM 2001
using namespace std;

int n, M[MAX][MAX];
int u, minv, total = 0;
int w[MAX], p[MAX], color[MAX] = {};

void prim() {
	for (int i = 0; i < n; i++) {
		w[i] = MAXNUM;
		p[i] = -1;
	}
	w[0] = 0;

	while (1) {
		minv = MAXNUM;
		u = -1;
		for (int i = 0; i < n; i++) {
			if (w[i] < minv && color[i] != 2) {
				u = i;
				minv = w[i];
			}
		}
		if (u == -1) break;
		color[u] = 2;
		for (int i = 0; i < n; i++) {
			if (color[i] != 2 && M[u][i] != MAXNUM) {
				if (M[u][i] < w[i]) {
					w[i] = M[u][i];
					p[i] = u;
					color[i] = 1;
				}
			}
		}
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> M[i][j];
			if (M[i][j] == -1) {
				M[i][j] = MAXNUM;
			}
		}
	}
	prim();
	for (int i = 0; i < n; i++) {
		if (p[i] != -1) total += M[i][p[i]];
	}
	cout << total << endl;
}



Measured memory_bytes: 3088
S = input()
keyence = "keyence"
k_n = len(keyence)
ans = "YES"
for i in range(k_n):
    if S[i] != keyence[i]:
        for j in range(1,k_n-i+1):
            if S[-j] != keyence[-j]:
                ans = "NO"
print(ans)

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int N, L;
int a[112345];

int main() {
	cin >> N >> L;
	REP(i, N) scanf("%d", a + i);
	
	int p = -1;
	REP(i, N - 1) if (a[i] + a[i + 1] >= L) p = i;
	
	vector<int> ans;
	
	if (p != -1) {
		REP(i, p) ans.push_back(i + 1);
		for (int i = N - 2; i > p; i--) ans.push_back(i + 1);
		ans.push_back(p + 1);
	}
	
	puts(ans.empty() ? "Impossible" : "Possible");
	REP(i, ans.size()) printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,m,a[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	if(n%2==1){
		puts("0");return 0;
	}
	int x=n/2;
	if(a[x]==a[x+1]){
		puts("0"); return 0;
	}
	printf("%d\n",a[x+1]-a[x]);
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int isInside(int,int,int,int,int);
int main(void)
{
  int w,h,x,y,r;
  scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
  if(isInside(w,h,x,y,r)) printf("Yes\n");
  else printf("No\n");
  return 0;
}
int isInside(int w,int h,int x,int y,int r)
{
  if(x-r>=0&&x+r<=w&&y-r>=0&&y+r<=h) return 1;
  else return 0;
}



Measured memory_bytes: 2124
#include<stdio.h>

int Euclid();

int main(void)
{
    int x, y;
    scanf("%d %d",&x, &y);

    printf("%d\n", Euclid(x, y));

    return 0;
}

int Euclid(int x, int y)
{
    int ans;
    ans = x % y;
    if(ans == 0) {
        return y;
    } else {
        return Euclid(y, ans);
    }
}


Measured memory_bytes: 2104
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


const LL MOD = 1000000007;
// 剰余演算クラス
struct ModInt{
    static const LL MOD = 1e+9 + 7;
    LL v;
    ModInt():v(0){}
    ModInt(LL op):v(op){}
    ModInt operator+(ModInt op) const{ return (v + op) % MOD; }
    ModInt operator-(ModInt op) const{ return (v - op + MOD) % MOD; }
    ModInt operator*(ModInt op) const{ return (v * op) % MOD; }
    ModInt operator/(ModInt op) const{ return (v * op.inverse()) % MOD; }
    ModInt operator%(LL op) = delete;
    ModInt operator+=(ModInt op){ return v = (v + op) % MOD; }
    ModInt operator-=(ModInt op){ return v = (v - op + MOD) % MOD; }
    ModInt operator*=(ModInt op){ return v = (v * op) % MOD; }
    ModInt operator/=(ModInt op){ return v = (v * op.inverse()) % MOD; }
    ModInt operator-() const{ return MOD - v; }
    bool operator==(ModInt op) const{ return v == op.v; }
    bool operator!=(ModInt op) const{ return v != op.v; }
    ModInt inverse() const{ return pow(MOD-2); }
    ModInt pow(LL n) const{
        if(n < 0) return pow(MOD-1 + n);
        if(n == 0) return 1;
        ModInt res = pow(n/2);
        return res * res * ((n&1)?ModInt(v): ModInt(1));
    }
    LL get() const{ return v; }
private:
    operator LL() const{ return v; }
};
istream& operator>>(istream& st, ModInt& m){ st>>m.v; return st; }
ostream& operator<<(ostream& st, const ModInt& m){ st<<m.v; return st; }


vector<ModInt> factorial(LL n){
    vector<ModInt> res(n, 1);
    for(LL i = 2; i < n; ++i) res[i] = res[i-1] * ModInt(i);
    return res;
}

ModInt permutation(LL n, LL m, vector<ModInt>& factorial){
    if(m < 0 || n < m) return 0;
    if(m == 0) return 1;
    return factorial.at(n) / factorial.at(n-m);
}

ModInt combination(LL n, LL m, vector<ModInt>& factorial){
    if(m < 0 || n < m) return 0;
    if(m == 0) return 1;
    return factorial.at(n) / factorial.at(n-m) / factorial.at(m);
}

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
    }
    vector<ModInt> f = factorial(n+1);
    ModInt base = f[n];
    vector<ModInt> b(n+1);
    for(int i = 1; i <= n; ++i){
        b[i] = base / ModInt(i+1);
    }
    vector<ModInt> c(n+1);
    for(int i = 1; i <= n; ++i){
        c[i] = c[i-1] + b[i];
    }

    ModInt ans(0);
    for(int i = 0; i < n; ++i){
        ans = ans + ModInt(a[i]) * (base + c[i] + c[n-1-i]);
    }
    cout << ans.get() << endl;
    return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[123];

int main(){
	scanf("%s", s); 
	int n = strlen(s);
	int ans = 0;
	REP(i, n/2){
		if(s[i] != s[n-1-i]){
			ans++;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int[] arr = new int[3];

    for (int i = 0; i < arr.length; i++) {
      arr[i] = sc.nextInt();
    }

    Arrays.sort(arr);

    System.out.println(arr[2] - arr[0]);

  }
}

Measured memory_bytes: 22612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> list = new ArrayList<String>();
		int ans = 0;
		while (true){
			String str = br.readLine();
			if (str.indexOf("?") != -1) break;
			list.add(str);
		}
		for (int i = 0 ;i < list.size() ; i++){
			String[] stra = list.get(i).split(" ");
			int a = Integer.parseInt(stra[0]);
			String op = stra[1];
			int b = Integer.parseInt(stra[2]);
			if("+".equals(op)){
				ans = a+b;
			}else if("-".equals(op)){
				ans = a-b;
			}else if("*".equals(op)){
				ans = a*b;
			}else if ("/".equals(op)){
				ans = a/b;
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 17060
import math
import queue

def readInt():
	return int(input())

def readInts():
	return list(map(int, input().split()))

def readChars():
	return input().split()


x = readInt()

a = readInts()

r = [0]*x

for i in a:
	r[i-1]+=1

for i in range(len(a)+1):
	print(r[i])

Measured memory_bytes: 33360
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  int ans = 100;
  for(char k = 'a'; k <= 'z'; k++) {
	  int cnt = 0,res = 0;
	  string d;
	  rep(i, s.size()) {
		  if(i == s.size() - 1) {
			  cnt ++; res = max(res, cnt);
		  }
		  if(s[i] == k) {
			  res = max(res, cnt); cnt = 0;
		  } else {
			  cnt ++;
		  }
		  d += k;
	  }
	  if(s == d) res = 0;
	  ans = min(ans, res);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;



int main()
{
  int N,x;    
  cin >> N >> x;
  int *a = new int[N];
  int ans=0;
  
  for(int i=0;i<N;i++)
  {
      cin >> a[i];
  }
  sort(a,a+N);
  for(int i=0;i<N;i++)
  {
      x=x-a[i];
      if(x<0)
      {
          ans=i;
          break;
      }
      ans+=1;
  }
  if(x>0) ans-=1;
  
 
  cout << ans << endl;
  
   
   
   delete[] a;
   
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define M 300000

int dat[M];


void sieve(){
    fill_n(dat,M,1);
    dat[0]=dat[1]=0;
    for(int i=2;i<1000;i++){
        if(dat[i]==0)continue;
        for(int j=2*i;j<M;j+=i){
            dat[j]=0;
        }
    }
}

int main(void){
    int n;
    sieve();
    while(cin>>n&&n){
        int cnt=0;
        for(int i=n+1;i<=2*n;i++){
            if(dat[i])cnt++;
        }
        cout<<cnt<<endl;
    }
}

Measured memory_bytes: 2332
def resolve():
    N = int(input())
    S = [input() for _ in range(N)]
    ans = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
    for s in S:
        ans[s] += 1
    for key in ans:
        print(key + " x " + str(ans[key]))


resolve()


Measured memory_bytes: 16320
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n,k,q; cin >> n >> k >> q;
    vl a(n,k-q);
    rep(i,q){
        ll t; cin >> t; t--;
        a[t]++;
    }
    rep(i,n){
        if(a[i]>0) puts("Yes");
        else puts("No");
    }
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define MOD 3000000000000000000
#define inf -100000000
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds; 
ll int power(ll int x,ll int y) 
{ 
    ll int res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
}
int main()
{
    fast;
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif
    long double x;
    cin>>x;
    long double k=(long double)((long double)(101)/(long double)(100));
    long double p=x;
    long double q=100;ll int i;
    for(i=1;i<=100000;i++)
    {
    	q=(q*k);
    	//long double z=floor(q*100);
    	//cout<<z<<endl;
    	//cout<<q<<endl;	
    	q=floor(q);

    	if(q>=p)
    	{
    		cout<<i;
    		break;
    	}
    }  
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(int x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(){
    int k;
    string s;
    cin >> k >> s;
    if(k>=s.size()){
        put(s);
    }
    else{
        rep(i,k)    cout << s[i];
        cout << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

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

	int n;
	double ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		double a;
		cin >> a;
		ans += 1 / a;
	}
	cout << std::setprecision(16) << 1 / ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int w = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();
      for(int i = 0;i < h-b;i++){
        StringBuilder sb = new StringBuilder();
      	for(int j = 0;j < w-a;j++)sb.append(1);
        for(int j = w-a;j < w;j++)sb.append(0);
        System.out.println(new String(sb));
      }
      for(int i = h-b;i < h;i++){
      	StringBuilder sb = new StringBuilder();
        for(int j = 0;j < w-a;j++)sb.append(0);
        for(int j = w-a;j < w;j++)sb.append(1);
        System.out.println(new String(sb));
      }
    }
}


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

#define maxn 30005
int n;
char s[maxn];
bool dp[maxn][1335];

int main()
{
	cin >> n;
	scanf("%s", s + 1);
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		int now = s[i] - '0';
		now++;
		for (int j = 0; j < 1335; j++)
			dp[i][j] = dp[i - 1][j];
		for (int j = 0; j < 1335; j++)
		{
			if (dp[i - 1][j])
			{
				int jj = j;
				int x = jj % 11;
				jj /= 11;
				int y = jj % 11;
				jj /= 11;
				int nn = 11 * y + x;
				nn = nn * 11 + now;
				dp[i][nn] = 1;
				nn = 11 * jj + x;
				nn = nn * 11 + now;
				dp[i][nn] = 1;
				nn = 11 * jj + y;
				nn = nn * 11 + now;
				dp[i][nn] = 1;
			}
		}
	}
	int ans = 0;
	for (int j = 0; j < 1335; j++)
	{
		int jj = j;
		int x = jj % 11;
		jj /= 11;
		int y = jj % 11;
		jj /= 11;
		if (x > 0 && y > 0 && jj > 0 && dp[n][j])
		{
			//cout << x - 1 << " " << y - 1 << " " << jj - 1 << endl;
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 39424