akhauriyash/Code-Regression huggingface dataset:
using System;
class Practice
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        int c = int.Parse(str[2]);
        Console.WriteLine(a < b && b < c ? "Yes" : "No");
    }
}


Measured memory_bytes: 17912
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, k ] <- readInts
	points <- replicateM n $ do
		[ x, y ] :: [ Integer ] <- map read . words <$> getLine
		return ( x, y )
	let
		xs = map fst points
		ys = map snd points
	print $ minimum $ [ ( x2 - x1 ) * ( y2 - y1 ) | x1 <- xs, x2 <- xs, y1 <- ys, y2 <- ys, x1 <= x2, y1 <= y2, k <= solve x1 y1 x2 y2 points ]

solve x1 y1 x2 y2 = length . filter ( \( x, y ) -> x1 <= x && x <= x2 && y1 <= y && y <= y2 )


Measured memory_bytes: 2428
#include<bits/stdc++.h>                       
const int N=400005;
using namespace std;
int k,n,c,ans,l[N],r[N];
string s;
int main(){
    cin>>n>>k>>c>>s;
    int i=1,kk=0;
    while(kk<k)
    {
    	if(s[i-1]=='o') kk++,l[kk]=i,i+=c;
		i++;
	}
	i=n,kk=k;
	while(kk>0)
    {
    	if(s[i-1]=='o') r[kk]=i,kk--,i-=c;
    	i--;
	}
	for(int j=1;j<=k;j++)
		if(r[j]==l[j]&&r[j]!=0) cout<<l[j]<<endl;
	return 0;
}
//68871358
//76140264
//25446011
//200841159
//914174775

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

#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
typedef long long ll;
typedef unsigned long ul;

const int MOD = 1000000007;  // 1 000 000 007

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    string S;
    cin >> S;
    
    // calculation
    ll ans = 0, cnt = 0;
    ll len = (ll)S.length();
    REP(i, len) {
        if (S[i] == 'B') {
            cnt++;
        } else {
            ans += cnt;
        }
    }
  
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ok = N;
    int ng = 0;
    
    cout << 0 << endl;
    string S; cin >> S;
    if(S == "Vacant") return 0;
    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        cout << mid << endl;
        string T; cin >> T;
        if(T == "Vacant") return 0;
        if(mid % 2 == 0 && S == T) ng = mid;
        else if(mid % 2 == 0 && S != T) ok = mid;
        else if(mid % 2 == 1 && S != T) ng = mid;
        else ok = mid;
    }

    return 0;
}


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

int main() {

	string s; int w; cin >> s >> w;
	string ans = "";
	for (int i = 0; i < s.size(); i+=w) {
		ans += s[i];
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define oo 2000000000
#define inf 1000000000000000LL
#define M 1000000007
typedef long long ll;
using namespace std;
const int N = 105001;

int n , a[N],ans[N];

signed main(){
    cin >> n ;
    for(int i = 1 ; i <= n ; i++){
        cin >> a[i];
        ans[a[i]]=i;
    }
    for(int i = 1 ; i <= n ; i++)cout << ans[i] <<' ';


    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll dp[101][100001];
int main()
{
    int n, W;
    cin >> n >> W;
    int w[100], v[100];
    for (int i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            if (j < w[i])
            {
                dp[i + 1][j] = dp[i][j];
            }
            else
            {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[n][W] << endl;
}

Measured memory_bytes: 78336
// at coder contest 044
// link to the problem 
// https://atcoder.jp/contests/abc044/tasks/abc044_b

#include <iostream>
#include <string>
using namespace std;
int main() {
  string w;
  int a[200] = {0};
  int flag=0;
  cin>>w;
  for(int i=0; i<w.size();i++)
  {
      a[w[i]]++;
  }
  for(int i=97;i<=122;i++){
      if(a[i]%2!=0)
      {
          flag=1;
          break;
      }
  }
  if(flag==0)
    cout<<"Yes";
  else
  {
        cout<< "No";
  }
  
  
  return 0;
}

Measured memory_bytes: 256
def solve():
    N = int(raw_input())
    v = [int(_) for _ in raw_input().split()]
    v.sort()
    new_mat = v[0]
    for i in range(1, N):
        new_mat = (new_mat + v[i]) / 2.0
    print new_mat

if __name__ == '__main__':
    solve()


Measured memory_bytes: 28012
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	r1,c1,r2,c2=MI()
	m=10**9+7

	ff=[1]

	for i in range(1,2*10**6+5):
		ff.append(ff[-1]*i%m)


	def f(r,c):
		return (ff[r+c]*pow(ff[r],m-2,m)*pow(ff[c],m-2,m))%m

	ans=0
	ans+=f(r2+1,c2+1)
	ans+=f(r1,c1)
	ans-=f(r2+1,c1)
	ans-=f(r1,c2+1)

	print(ans%m)



if __name__ == "__main__":
	main()


Measured memory_bytes: 205068
/*      Chill raho be kuch nhi rakha sadness me. 
               Author: Maskman_lucifer                   */
               
#include <bits/stdc++.h>   
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define lc '\n'
using namespace std;
ll n,wt;
ll w[200000],v[200000];
ll dp[200000][110];
ll vis[200000][110];
ll solve(ll ind,ll val)
{
    if(val<=0)
    {
        return 0;
    }
    if(ind==n)
    {
        return M;
    }
    if(dp[val][ind]!=-1)
    {
        return dp[val][ind];
    }
    
    dp[val][ind]=min(solve(ind+1,val),w[ind]+solve(ind+1,val-v[ind]));
    return dp[val][ind];
}
int main()
{
    IO
    cin>>n>>wt;
    memset(dp,-1,sizeof(dp));
    ll s=0;
    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
        s+=v[i];
    }
    for(ll j=s;j>=0;j--)
    {
        ll val=solve(0,j);
        if(val<=wt)
        {
            cout<<j<<lc;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 175568
#include<iostream>
#include<cstdio>
using namespace std;
long long x, i, j;
long long a[505];
int flag = 0;
int main() {
	for (i = 0; i < 501; i++) {
		a[i] = i * i * i * i * i;
	}
	scanf("%lld", &x);
	for ( i = 0; i < 501; i++) {
		for (j = 0; j < 501; j++) {
			if (i == j)continue;
			if (a[i] + a[j] == x) {
				printf("%lld -%lld", i, j);
				flag = 1;
				break;
			}
			if (i>j && a[i] - a[j] == x) {
				printf("%lld %lld", i, j);
				flag = 1;
				break;
			}
		}
		if (flag)break;
	}
}

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

int main(){
  string S;
  cin >> S;
  int N=S.size();

  bool flag=true;
  for(int i=0;i<N/2;i++){
    if(S.at(i)!=S.at(N-1-i))  flag=false;
    //cout << S.at(i) << S.at(N-1-i) << ",";
  }
  //cout << endl;
  for(int i=0;i<(N-1)/2;i++){
    if(S.at(i)!=S.at((N-1)/2-1-i))  flag=false;
    //cout << S.at(i) << S.at(N-1-i) << ",";
  }
  //cout << endl;
  for(int i=(N+3)/2-1;i<N;i++){
    if(S.at(i)!=S.at(N-1-i))  flag=false;
    //cout << S.at(i) << S.at(N-1-i) << ",";
  }
  //cout << endl;
  if(flag)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;
#define  point complex<ld>
#define Cp(a,b) ((conj(a)*b).imag())
#define Dp(a,b) ((conj(a)*b).real())
#define dist(a,b) (abs(line(a,b)))
#define angel(a) (atan2(a.Y,a.X)*360/pi)

#define X real()
#define Y imag()

#define line(a,b) (b-a)

#define endl "\n"

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
const int N=1e5+5;
ll mod=1e9+9;
ll inf=1e18;
ld eps=1e-12;
ld pi=2*2*acos(0);
ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}

int arr[305];
int co[4];
ld n;
bool vist[305][305][305];
ld dp[305][305][305];

ld solve(int co1,int co2,int co3)
{
    int total=co1+co2+co3;
    if(!total)
        return 1;

    if(vist[co1][co2][co3])
        return dp[co1][co2][co3];
    vist[co1][co2][co3]=1;

    ld co0=n-total,inf=1/(1-(co0/n));
    ld ans=1;
    if(co1)
        ans+=(ld)co1/n*solve(co1-1,co2,co3);

    if(co2)
        ans+=(ld)co2/n*solve(co1+1,co2-1,co3);
    if(co3)
        ans+=(ld)co3/n*solve(co1,co2+1,co3-1);

    return dp[co1][co2][co3]=ans*inf;

}

int main()
{
    FIO
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        co[arr[i]]++;
    }
    cout<<fixed<<setprecision(12)<<solve(co[1],co[2],co[3])-1;


    return 0;
}


Measured memory_bytes: 230296
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    string s, p;
    cin >> s >> p;
    int n = s.size();
    int m = p.size();
    
    int dp[n+1][m+1] = {};
    forn(i, 1, n+1) {
        forn(j, 1, m+1) {
            if (s[i-1] == p[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    
    string ans = "";
    int i = n, j = m;
    while (i && j) {
        if (s[i-1] == p[j-1]) {
            ans.pb(s[i-1]);
            i--, j--;
        } else {
            if (dp[i][j] == dp[i-1][j]) i--;
            else j--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 38852
n = int(input())
s = list(input())
alphabet = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
s_position = []
ans = []
for i in range(len(s)):
    s_position.append(alphabet.index(s[i]))

#
for j in range(len(s)):
    if (s_position[j] + n) >= 26:
        ans.append(alphabet[s_position[j] + n - 26])
    else:
        ans.append(alphabet[s_position[j] + n])
print(''.join(ans))


Measured memory_bytes: 3316
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        int n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
        Scanner sc= new Scanner(System.in);
        n=sc.nextInt();
        m=sc.nextInt();
        if(n>9 || m>9)
        {
            System.out.println(-1);
        }
        else
        {
            System.out.println(n*m);
        }
 
    }
}

Measured memory_bytes: 36096
a = input()
b = input()
c = input()
x = input()

cache = {}

def d(a, b, c, r):
    if r == 0: return 1
    if r < 0: return 0
    if cache.has_key((a, b, c, r)): return cache[(a, b, c, r)]
    s = 0
    if a > 0: s += d(a - 1, b, c, r - 500)
    if b > 0: s += d(0, b - 1, c, r - 100)
    if c > 0: s += d(0, 0, c - 1, r - 50)
    cache[(a, b, c, r)] = s
    return s

print d(a, b, c, x)


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

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

	bool ans = true;
	int pre_t = 0;
	int pre_x = 0;
	int pre_y = 0;
	for (int i = 0; i < N; i++) {
		int t, x, y;
		cin >> t >> x >> y;
		int dist = abs(x-pre_x) + abs(y-pre_y);
		int e_time = t-pre_t;
		if ((dist > e_time) || (((dist - e_time) & 1) == 1)) {
			ans = false;
		}
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
// Ivan Carvalho
// Problem W - Educational Dynamic Programming Contest - AtCoder
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXN = 2*1e5 + 10;

vector<int> adiciona[MAXN],retira[MAXN];
ll seg[4*MAXN],lazy[4*MAXN],dp[MAXN],valor[MAXN];
int N,M,ini[MAXN],fim[MAXN];

void propagate(int pos,int left,int right){

	if(lazy[pos] == 0) return;

	if(left != right){
		lazy[2*pos] += lazy[pos];
		lazy[2*pos+1] += lazy[pos];
	}

	seg[pos] += lazy[pos];
	lazy[pos] = 0;

}

void update(int pos,int left, int right,int i,int j,ll delta){

	propagate(pos,left,right);
	if(left > right || left > j || right < i) return;

	if(left >= i && right <= j){
		lazy[pos] += delta;
		propagate(pos,left,right);
		return;
	}

	int mid = (left+right)/2;
	update(2*pos,left,mid,i,j,delta);
	update(2*pos+1,mid+1,right,i,j,delta);

	seg[pos] = max(seg[2*pos],seg[2*pos+1]);

}

ll query(int pos,int left,int right,int i,int j){

	propagate(pos,left,right);

	if(left >= i && right <= j) return seg[pos];

	int mid = (left+right)/2;
	if(j <= mid) return query(2*pos,left,mid,i,j);
	else if(i >= mid + 1) return query(2*pos+1,mid+1,right,i,j);
	else return max(query(2*pos,left,mid,i,j), query(2*pos+1,mid+1,right,i,j));

}

int main(){

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

	for(int i = 1;i<=M;i++){
		scanf("%d %d %lld",&ini[i],&fim[i],&valor[i]);
		adiciona[ini[i]].push_back(i);
		retira[fim[i]].push_back(i);
	}

	for(int i = 1;i<=N;i++){
		for(int j : adiciona[i]){
			update(1,0,N,0,ini[j] - 1,valor[j]);
		}
		dp[i] = query(1,0,N,0,i-1);
		update(1,0,N,i,i,dp[i]);
		for(int j : retira[i]){
			update(1,0,N,0,ini[j] - 1,-valor[j]);
		}
	}

	ll best = 0;
	for(int i = 1;i<=N;i++) best = max(best,dp[i]);
	printf("%lld\n",best);

	return 0;

}

Measured memory_bytes: 39296
import sys
import collections

n = int(input())
xy = []
for _ in range(n):
    xy.append([int(i) for i in input().split()])
xy.sort()

if len(xy) == 1:
    print(1)
    sys.exit()

cost_list = []
for i in range(n):
    for j in range(i,n):
        if i == j:
            continue
        x_sub = xy[j][0] - xy[i][0]
        y_sub = xy[j][1] - xy[i][1]
        cost_list.append('{},{}'.format(x_sub, y_sub))

cost_dic = collections.Counter(cost_list)
#print(cost_dic)
zero_cost_num = max(cost_dic.values())
#print(zero_cost_num)
ans = n - zero_cost_num

print(ans)


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

int main() {
int x;
cin >> x;
int first = (x/500)*1000;
int second = ((x%500)/5)*5;
int ans = first + second;
cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
const int MAX_V = 15;
const int INF = 1e9;
  
int V,E;
int d[MAX_V][MAX_V];
int dp[1<<MAX_V][MAX_V];
 
//bitDP
//????????????v?????????????????????????????????????????????£???v?????????£??????????????????????????????
// = ??????0??????????????????????????????£????????????????????????0?????????£?????????
 
int dfs(int mask,int v){
    if(mask==(1<<V)-1) return d[v][0];
    if(dp[mask][v]!=-1) return dp[mask][v];
    int res = INF;
    rep(u,V){
        if(d[v][u]==INF || (mask&(1<<u))) continue;
        res = min(res, dfs(mask|(1<<u),u)+d[v][u]);
    }
    return dp[mask][v] = res;
}
 
int main() {
    cin>>V>>E;
    rep(i,V)rep(j,V) d[i][j]=INF;
    rep(i,V) d[i][i]=0;
    rep(i,E){
        int s,t;
        cin>>s>>t;
        cin>>d[s][t];
    }
    memset(dp, -1, sizeof(dp));
    int res=dfs(1,0);
    cout<<(res==INF ? -1 : res)<<endl;
    return 0;
}

Measured memory_bytes: 5052
s = input()
t = input()
q =int(input())
info = [list(map(int,input().split())) for i in range(q)]
MOD = 3
memo = {"A":1,"B":2}

s_ruiseki = [0]*(len(s)+1)
for i in range(1,len(s)+1):
  s_ruiseki[i] = (s_ruiseki[i-1]+memo[s[i-1]]) % MOD

t_ruiseki = [0]*(len(t)+1)
for i in range(1,len(t)+1):
  t_ruiseki[i] = (t_ruiseki[i-1]+memo[t[i-1]]) % MOD

for i in range(q):
  ans1 =  (2*s_ruiseki[info[i][0]-1] + s_ruiseki[info[i][1]])%MOD
  ans2 =  (2*t_ruiseki[info[i][2]-1] + t_ruiseki[info[i][3]])%MOD
  print("YES" if ans1 == ans2 else "NO")

Measured memory_bytes: 36376
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	string s;
	cin>>s;
	rep(i,s.length())if(s.at(i)==(i%2?'R':'L')){cout<<"No"<<endl;return 0;}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;

int low[52], num[52], k = 1, ans = 0;
vector<int> G[52];

int dfs(int u, int pre){
	if(low[u])return low[u];
	int res = k, t;
	low[u] = k;
	num[u] = k++;
	for(int i = 0;i < G[u].size();i++){
		if(G[u][i] != pre){
			t = dfs(G[u][i], u);
			res = min(res, t);
		}
	}
	if(res == num[u])ans++;
	return low[u] = res;
}

int main(){
	int n, m, t1, t2;
	scanf("%d%d", &n, &m);
	for(int i = 0;i < m;i++){
		scanf("%d%d", &t1, &t2);
		G[t1].push_back(t2);
		G[t2].push_back(t1);
	}
	dfs(1, -1);
	printf("%d\n", ans-1);
	return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back

#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto item : (x))
#define output_s(a) printf("%s\n",(a).c_str())

//library----------------------------------------------


int main(){
    int h,a;cin>>h>>a;
    printf("%d\n",(h+a-1)/a);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
const ll INF = 1LL << 60;
ll M = 1000000000 + 7;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod = M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod = M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod = M) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod = M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int main(void) {
  int n; cin >> n;
  int action[101000][3];
  rep(i,n) cin >> action[i][0] >> action[i][1] >> action[i][2];
  ll dp[101000][3];
  rep(j,3){
    dp[1][j] = action[0][j];
  }
  
  for (int i = 1; i < n; i++){
    dp[i+1][0]=-1*INF; dp[i+1][1]=-1*INF; dp[i+1][2]=-1*INF;
    rep(j,3){
      rep(k,3){
        if (j != k){
          chmax(dp[i+1][k],dp[i][j]+action[i][k]);
        }
      }
    }
  }
  ll res=0;
  rep(j,3) chmax(res,dp[n][j]);
  cout << res << "\n";
  return 0;
}

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

int main() {
	int N, A, B;
	string S;
	cin >> N >> A >> B >> S;

	int pass = 0, inter = 0;

	rep(i, N) {
		if(S.at(i) == 'a') {
			if(pass < A + B) {
				cout << "Yes" << endl;
				pass++;
			} else {
				cout << "No" << endl;
			}
		} else if (S.at(i) == 'b') {
			if(pass < A + B && inter < B) {
				cout << "Yes" << endl;
				pass++;
				inter++;
			} else {
				cout << "No" << endl;
			}
		} else {
			cout << "No" << endl;
		}
	}
}

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



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

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>

int main()
{
	char c[16];
	scanf("%s", c);

	int max = 0;
	int count = 0;
	for(int i=0; c[i]!='\0'; i++){
		if(c[i] == 'A' || c[i] == 'C' || c[i] == 'G' || c[i] == 'T'){
			count ++;
		} else {
			count = 0;
		}
		if(count > max){
			max = count;
		}
	}

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


Measured memory_bytes: 128
ans=0
from collections import Counter,deque
this=list(map(int,input().split()))
n=this[0]
m=this[1]
arr=[]
for _ in range(n+1):
    arr.append([])
for _ in range(m):
    x=list(map(int,input().split()))
    arr[x[0]].append(x[1])
    arr[x[1]].append(x[0])
net=Counter([])
for i in range(1,n+1):
    if net[i]==0:
        visited=Counter([])
        q=deque()
        visited[i]=1
        now=1
        q.append(i)
        while q:
            k=q.popleft()
            for item in arr[k]:
                if visited[item]==0:
                    q.append(item)
                    net[item]=1
                    now+=1
                    visited[item]=1
        ans=max(ans,now)
print (ans)

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

int main(){
    int N;
    cin >> N;
    int tmp = 0;
    if(N % 2 == 1){
        tmp = (N / 2 + 1);
    }else{
        tmp = (N / 2);
    }
    cout << (double)tmp / N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll GCD(ll a, ll b) {
  if (b == 0) return a;
  else return GCD(b, a%b);
}

void Main(){

  int N;
  ll T;
  cin>>N>>T;

  ll t[N];
  rep(i,N){
    cin>>t[i];
  }

  ll ct=N*T;

  rep(i,N-1){
    ct-=max((ll)0, T-(t[i+1]-t[i]));
  }

  cout<< ct<<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 10;
int sum1[N], sum2[N];

int main()
{
    ios::sync_with_stdio(false);
    int n, t;
    cin >> n;
    for (int i = 1;i <= n;i++)
    {
        cin >> t;
        sum1[i] = sum1[i - 1] + t;
    }
    for (int i = 1;i <= n;i++)
    {
        cin >> sum2[i];
    }    
    for (int i = n - 1;i > 0;i--)
        sum2[i] += sum2[i + 1];
    int maxn = 0;
    for (int i = 1;i <= n;i++)
        maxn = max(sum1[i] + sum2[i], maxn);
    cout << maxn;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int i,h, tmp, d[10];
	
	for(i = 0; i < 10; i++) scanf("%d", &d[i]);
	
	
	for(h = 10; h > 0; ){
		h /= 1.3;
		
		for(i = 0; i + h < 10; i++){
			if(d[i + h] > d[i]){
				tmp = d[i];
				d[i] = d[i + h];
				d[i + h] = tmp;
			}
		}
	}
	for(i = 0; i < 3; i++) printf("%d\n", d[i]);
		
	return 0;
}

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

int main(){
    string a,b;
    cin>>a>>b;
    int a_b=0;

    // aの末尾にbを追加
    a.append(b);
    a_b=stoi(a);

    int sqrt_ab_i=sqrt(a_b);
    double sqrt_ab_d=sqrt(a_b);

    if(sqrt_ab_i==sqrt_ab_d){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = [int(x) for x in input().split()]
d = {}
for a in A:
	if a in d:
		d[a] += 1
	else:
		d[a] = 1

d = sorted(d.values())

if len(d)>K:
	ans = 0
	for i in range(len(d)-K):
		ans += d[i]
	print(ans)
else:
	print(0)

Measured memory_bytes: 32288
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

int a[200005], b[200005];

void Main() {
  int n, k; cin >> n >> k;
  for(int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = b[i - 1] + a[i];
  }
  int res = 0;
  for(int i = k; i <= n; i++) {
    res = max(res, b[i] - b[i - k]);
  }
  cout << fixed << setprecision(10) << ((res + k) * 0.5) << "\n";
}


Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc145/tasks/abc145_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

const int MOD = 1000000007;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) {
    int x = a.n + b.n;
    return x - (x >= MOD) * MOD;
}
mint operator-(mint a, mint b) {
    int x = a.n - b.n;
    return x + (x < 0) * MOD;
}
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
    for (int i = I_.size(); i <= n; i++) {
        I_.push_back(I_[MOD % i] * (MOD - MOD / i));
        F_.push_back(F_[i - 1] * i);
        R_.push_back(R_[i - 1] * I_[i]);
    }
}

mint I(int n) {
    check_fact(abs(n));
    return n >= 0 ? I_[n] : -I_[n];
}
mint F(int n) {
    check_fact(n);
    return n < 0 ? 0 : F_[n];
}
mint R(int n) {
    check_fact(n);
    return n < 0 ? 0 : R_[n];
}
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, Y;
    cin >> X >> Y;
    if ((X + Y) % 3 != 0) {
        cout << "0\n";
        return 0;
    }
    int m = (2 * X - Y) / 3;
    int n = (2 * Y - X) / 3;
    cout << C(n + m, n) << endl;

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    map<ll, ll> wa, sa;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        wa[i + 1 + A]++;
        sa[i + 1 - A]++;
    }
    ll ans = 0;
    for (auto itr = wa.begin(); itr != wa.end(); ++itr) {
        ans += itr->second * sa[itr->first];
    }
    cout << ans << endl;
}

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

#define fc first
#define sc second
#define all(x) x.begin(), x.end()
#define bit(x) __builtin_popcount(x)
#define pb push_back
#define popb pop_back
#define ll long long

using namespace std;

int main() {
    srand('M' + 'R' + '.' + 'D' + 'U' + 'D' + 'E' + 'C');
    #ifdef ONPC
        freopen("a.in", "r", stdin);
        //freopen("a.out", "w", stdout);
    #else
        //freopen("a.in", "r", stdin);
        //freopen("a.out", "w", stdout);
    #endif
    int n, m;
    cin >> n >> m;
    char c[n][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> c[i][j];
        }
    }
    int x = 0, y = -1;
    while (x < n) {
        while (y + 1 < m && c[x][y + 1] == '#') {
            c[x][y + 1] = '.', y++;
        }
        x++;
        y--;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (c[i][j] == '#') {
                cout << "Impossible\n";
                return 0;
            }
        }
    }
    cout << "Possible\n";
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    int n = a.length();
    int m = b.length();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
        dp[i][0] = 0;
    
    for(int i=0;i<=m;i++)
        dp[0][i] = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i-1]==b[j-1])
                dp[i][j]  = dp[i-1][j-1]+1;
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string s;
    int i = n,j = m;
    while(i>0 and j>0){
        if(a[i-1]==b[j-1]){
            s.push_back(a[i-1]);
            i--;
            j--;
        }else{
            if(dp[i-1][j]>dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
    // cout<<dp[n][m];
}

Measured memory_bytes: 38772
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,N,a;
  cin>> K>>N;
  vector <int>A(N);
  for (int i=0; i<N;i++){
    cin >>A.at(i);
  }
  a= K+A.at(0)-A.at(N-1);
  for(int i=0;i<N-1;i++){
    if(A.at(i+1)-A.at(i)>a){
      a=A.at(i+1)-A.at(i);
    }
  }
  cout <<K-a<<endl;
  
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 10000000

typedef long long ll;

int n, m, t, k = -1;
vector<int> vi;

int main(){
	while (cin >> n >> m){
		if (n + m == 0)break;
		vi.push_back(0);
		REP(i, n + m){
			cin >> t;
			vi.push_back(t);
		}
		sort(ALL(vi));
		REP(i, vi.size() - 1){
			k = max(k, vi[i + 1] - vi[i]);
		}
		cout << k << endl;
		k = -1;
		vi.clear();
	}
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
#define pb push_back
#define tam 3100
#define offset 100000
#define se second
#define fi first
#define forr(i,p,n) for(int i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<int,int> ii;
ll   H,W,N;
set<ii> existe;
set<ii> cuad[100];
bool valid(int posy,int posx)
{
    if (posy<=0|| posx<=0||posy>H|| posx>W)
        return 0;
    return 1;
}
int works(int posy,int posx)
{
    int auxsum=0;
    forr(i,0,3){
        forr(j,0,3){
            if (valid(posy+i,posx+j)==0)
                return 0;
            else{
                if (existe.find(ii(posy+i,posx+j))!=existe.end())
                    auxsum++;
                //cout<<posy+i<<" "<<posx+j<<" "<<mapa[posy+i][posx+j]<<endl;
            }
        }
    }
    return auxsum;
}
int main()
{
    cin>>H>>W>>N;
    vector<ii> lst;
    int Y,X;
    forr(i,0,N)
    {
        cin>>Y>>X;
        existe.insert(ii(Y,X));
        lst.pb(ii(Y,X));
    }
    
    int xx,yy;
    forr(i,0,lst.size())
    {
        X=lst[i].se;
        Y=lst[i].fi;
        //cout<<X<<" "<<Y<<endl;
        forr(delX,-2,1)
        {
            forr(delY,-2,3)
            {
                xx=X+delX;
                yy=Y+delY;
                int auxval=works(yy,xx);
                if (auxval==0)continue;
                cuad[auxval].insert(ii(yy,xx));
            }
        }
        //cout<<endl;
    }
    ll resp=0;
    resp=(W-2)*(H-2);
    forr(i,1,10)
        resp-=cuad[i].size();
    cout<<resp<<endl;
    forr(i,1,10)
    cout<<cuad[i].size()<<endl;

}

Measured memory_bytes: 47860
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REPI(i, S, N) for(int i=int(S); i<int(N); i++)
#define REP(i, N) REPI(i, 0, N)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<string> N;
  ll r = 0;
  
  for(auto i : N) {
    r = (r + (i - '0')) % 9;
  }


  return (r == 0 ? "Yes" : "No");
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



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

const LL mod = 1e9 + 7 ;
const LL mx = 2e5 + 7 ;

LL fact[mx], inv_fact[mx] ;

LL powmod(LL base, LL exp, LL modulus = mod){
	base %= modulus;
	long long result = 1;
	while (exp > 0) {
		if (exp & 1LL) result = (result * base) % modulus;
		base = (base * base) % modulus;
		exp >>= 1;
	}
	return result;
}

void preprocess(){
	fact[0] = inv_fact[0] = 1LL ;
	for(LL i = 1 ; i < mx ; i++){
		fact[i] = (fact[i-1] * i) % mod ;
		inv_fact[i] = powmod(fact[i], mod-2LL) ;
	}
}

LL nCr(LL n, LL r){
	return (((fact[n] * inv_fact[r]) % mod) * inv_fact[n-r]) % mod ; 
}

int main(){

	preprocess() ;

	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	LL H, W, N ;
	cin >> H >> W >> N ;

	vector<pair<int, int> > walls(N) ;
	for(auto &i : walls)
		cin >> i.first >> i.second ;
	walls.push_back(make_pair(H, W)) ;

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

	vector<LL> dp(N+1) ;

	for(int i = 0 ; i <= N ; i++){
		dp[i] = nCr(walls[i].first + walls[i].second - 2LL, walls[i].first - 1LL) ;
	}

	for(int i = 0 ; i <= N ; i++){
		for(int j = i + 1 ; j <= N ; j++){
			LL x = walls[j].first - walls[i].first ;
			LL y = walls[j].second - walls[i].second ;

			if(x < 0 || y < 0)
				continue ;
			
			dp[j] -= dp[i] * nCr(x + y, x) ;
			dp[j] = (dp[j] + mod) % mod ;
		}
	}

	dp[N] = (dp[N] + mod) % mod ;
	cout << dp[N] << endl ;

	return 0;
}

Measured memory_bytes: 3456
//距離「奇数」にしても必ず存在するやんけ～。燃やす～（冗談です）
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
vector<int> et[200000];
int depth[200000];
int ans[200000];

void dfs(int p, int v, int dep) {
	depth[v] = dep;
	int i;
	rep(i, et[v].size()) {
		int nv = et[v][i];
		if (nv == p) continue;
		dfs(v, nv, dep + 1);
	}
}

int main() {
	int i;
	
	cin >> n;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		et[a].push_back(b);
		et[b].push_back(a);
	}
	
	dfs(0, 0, 0);
	
	int cnt[2] = {0};
	rep(i, n) {	cnt[depth[i] % 2]++; }
	
	int kosuu[3] = {0};
	rep(i, n) { kosuu[(i + 1) % 3]++; }
	
	if (kosuu[1] + kosuu[2] <= cnt[0]) {
		rep(i, n) {
			if (depth[i] % 2 == 0) {
				if (kosuu[1] > 0) { ans[i] = 1; kosuu[1]--; }
				else if (kosuu[2] > 0) { ans[i] = 2; kosuu[2]--; }
				else { ans[i] = 0; kosuu[0]--; }
			}
			else {
				ans[i] = 0; kosuu[0]--;
			}
		}
	}
	else if (kosuu[1] + kosuu[2] <= cnt[1]) {
		rep(i, n) {
			if (depth[i] % 2 == 1) {
				if (kosuu[1] > 0) { ans[i] = 1; kosuu[1]--; }
				else if (kosuu[2] > 0) { ans[i] = 2; kosuu[2]--; }
				else { ans[i] = 0; kosuu[0]--; }
			}
			else {
				ans[i] = 0; kosuu[0]--;
			}
		}
	}
	else if (kosuu[1] <= cnt[0] && kosuu[2] <= cnt[1]) {
		//cout << "hoge" << endl;
		rep(i, n) {
			if (depth[i] % 2 == 0) {
				if (kosuu[1] > 0) { ans[i] = 1; kosuu[1]--; }
				else { ans[i] = 0; kosuu[0]--; }
			}
			else {
				if (kosuu[2] > 0) { ans[i] = 2; kosuu[2]--; }
				else { ans[i] = 0; kosuu[0]--; }
			}
		}
		//cout << kosuu[0] << ", " << kosuu[1] << ", " << kosuu[2] << endl;
	}
	else {
		assert(0);
	}
	
	int hoge[3] = {3, 1, 2};
	rep(i, n) {
		cout << hoge[ans[i]] << " ";
		hoge[ans[i]] += 3;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 21504
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var p, q, r int
	fmt.Scan(&p, &q, &r)
	ans := min(p+q, min(r+q, p+r))
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int N, c[300000][2];

int main() {
    string S;
    cin >> N >> S;
    FOR(i, 1, N) {
        c[i][0] = c[i - 1][0];
        c[N - i - 1][1] = c[N - i][1];
        if (S[i - 1] == 'W') c[i][0]++;
        if (S[N - i] == 'E') c[N - i - 1][1]++;
    }
    int ans = 300000;
    REP(i, N) ans = min(ans, c[i][0] + c[i][1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

  string s;
  cin >> s;
  vector<string> v;
  for (auto c: s) {
    if (c == '0') v.pb("0");
    if (c == '1') v.pb("1");
    if (c == 'B' && !v.empty()) v.pop_back();
  }
  for (auto e: v) {
    cout << e;
  }
  cout << endl;
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;

  int d = b - a;

  int west_tower = 0;
  for(int i = 1; i < d; ++i) {
    west_tower += i;
  }

  cout << west_tower - a << endl;
}


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

int main(){
  string S;
  int Q;
  cin >> S >> Q;
  bool flag=false;
  vector<int> T(Q);
  for(int i=0;i<Q;i++){
    cin >> T.at(i);
    if(T.at(i)==1){
      if(flag){
        flag=false;
      }else{
        flag=true;
      }
    }else{
      int f;
      char c;
      cin >> f >> c;
      if(f==1){
        if(flag){
          S.insert(S.end(),c);
        }else{
          S.insert(S.begin(),c);
        }
      }else{
        if(flag){
          S.insert(S.begin(),c);
        }else{
          S.insert(S.end(),c);
        }
      }
    }
  }
  if(flag){
    reverse(S.begin(),S.end());
  }
  cout << S << endl;
}


Measured memory_bytes: 1796
import java.util.Scanner;
public class Main{
	public static void main(String[]args) {
		Scanner input=new Scanner(System.in);
		int a=input.nextInt();
		String op=input.next();
		int b=input.nextInt();
		int calc=0;
		if(op.contentEquals("+")) {
			calc=a+b;
		}else if(op.contentEquals("-")) {
			calc=a-b;
		}
		System.out.println(calc);
	}
}

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

int main(){
  int i = 1;
  while(1){
     int value;
     cin >> value;
     if ( value == 0 ) {
        break;
     }
     cout << "Case " << i << ": " << value << endl;
     ++i;
  }
  return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define M 205
int Ans=-1e9,n,L,A[M],Sum,w=1e9;
int main() {
	scanf("%d%d",&n,&L);
	for(int i=1; i<=n; i++)Sum+=i-1+L;
	for(int i=1; i<=n; i++)
		if(w>abs(i-1+L))w=abs(i-1+L),Ans=Sum-i+1-L;
	printf("%d",Ans);
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    swap(a,b);
    swap(a,c);
    cout << " " << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
// B.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int s = 0;
	for (int x = n; x; x /= 10) {
		s += x % 10;
	}
	string ans = (n % s) ? "No" : "Yes";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

vector<int>E[101010];
int N;

int dfs(int now,int p) {
	vector<int>v;
	int ccnt = 0;
	fore(x, E[now]) {
		if (x != p) {
			ccnt++;
			int tmp = dfs(x, now);
			if (tmp != 0)v.pb(tmp);
		}
	}
	int ret = accumulate(all(v), 0);
	if (ccnt != v.size())ret += (ccnt - 1) - (int)v.size();
	return ret;
}


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

	
	cin >> N;
	vector<int>ccnt(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		E[a].pb(b);
		E[b].pb(a);
		ccnt[a]++;
		ccnt[b]++;
	}

	int root = max_element(all(ccnt)) - ccnt.begin();
	if (ccnt[root] <= 2) { puts(1); return 0; }
	puts(dfs(root, -1));
	
	return 0;
}

Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 87;
int h[N], a[N];
ll f[N];
void upd(int i, ll v)
{
    for (; i < N; i += i & -i)
        f[i] = max(f[i], v);
}
ll qry(int i)
{
    ll r = 0;
    for (; i > 0; i -= i & -i)
        r = max(f[i], r);
    return r;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> h[i];
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 1; i <= n; ++i)
        upd(h[i], qry(h[i] - 1) + a[i]);
    cout << qry(n) << endl;
}


Measured memory_bytes: 3328
n,k = map(int,input().split())
a = list(map(int,input().split()))
dp = [0] * (k+1)
dp[0] = 1
for i in range(1,k+1):
  for j in a:
    if i-j >= 0 and dp[i-j] ==1:
      dp[i] = 0
      break
  else:
    dp[i] = 1
print("Second" if dp[k] else "First")

Measured memory_bytes: 43244
N, M, Q = map(int, input().split())
check = list()
for i in range(Q):
  check.append(list(map(int, input().split())))
ans = 0

for i1 in range(1, M+1):
  for i2 in range(i1, M+1):
    for i3 in range(i2, M+1):
      for i4 in range(i3, M+1):
        for i5 in range(i4, M+1):
          for i6 in range(i5, M+1):
            for i7 in range(i6, M+1):
              for i8 in range(i7, M+1):
                for i9 in range(i8, M+1):
                  L = [1, i1, i2, i3, i4, i5, i6, i7, i8, i9]
                  A = list()
                  for i in range(N):
                    A.append(L[i])
                  tmp = 0
                  for i in range(Q):
                    a = check[i][0]
                    b = check[i][1]
                    c = check[i][2]
                    d = check[i][3]
                    if(A[b-1]-A[a-1] == c):
                      tmp += d
                  ans = max(ans, tmp)

print(ans)

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for(auto& e : x) cin >> e;
    sort(begin(x), end(x));
    vector<int> d(m-1);
    for(int i = 0;i < m-1;i++) d[i] = x[i+1] - x[i];
    sort(begin(d),end(d));
    cout << (n >= m ? 0 : accumulate(begin(d), begin(d) + m-n, 0)) << endl;
    return 0;
}

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

int main(){
    int n,ans=0;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    if(n<=2){}
    else{
        for(int i=0;i<n-2;i++){
            for(int j=i+1;j<n-1;j++){
                for(int k=j+1;k<n;k++){
                    if(a.at(i)==a.at(j)||a.at(i)==a.at(k)||a.at(j)==a.at(k))continue;
                    int dekai=max(a.at(i),max(a.at(j),a.at(k)));
                    if(a.at(i)+a.at(j)+a.at(k)-2*dekai>0)ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#!/bin/bash

read n
read s
read t

i=1

if [ $s = $t ]; then
  echo ${n}
else
  while true
  do
    cnt_s=$((i+1))
    cnt_t=$((n-i))
    tmp_s=$(echo ${s} | cut -b${cnt_s}-)
    tmp_t=$(echo ${t} | cut -b1-${cnt_t})

    if [ $tmp_s = $tmp_t ]; then
      echo  "$(( $n + $n - $(($(echo ${tmp_s} | wc -c) -1 )) ))"
      exit
    fi

    i=$((i+1))
  done
fi

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

unsigned long long _gcd(unsigned long long m, unsigned long long n) {
    if (m == 0) return n;
    return _gcd(n % m, m);
}

unsigned long long gcd(unsigned long long m, unsigned long long n) {
    if (m < n) return _gcd(m, n);
    else return _gcd(n, m);
}

unsigned long long lcm(unsigned long long m, unsigned long long n) {
    if (m > n)
        return m * n / _gcd(n, m);
    return m * n / _gcd(m, n);
}


int main() {
    int n, i;

    while (cin >> n, n) {
        unsigned long long d[n], v[n];
        unsigned long long dm, vd;
        dm = 1;
        for (i = 0; i < n; i++) {
            cin >> d[i] >> v[i];
            dm = lcm(dm, d[i]);
        }
        for (i = 0; i < n; i++) {
            v[i] = v[i] * dm / d[i];
            // cout << "v/d: " << v[i] << "/" << dm << endl;
        }
        vd = v[0];
        for (i = 1; i < n; i++) {
            vd = gcd(vd, v[i]);
        }
        for (i = 0; i < n; i++) {
            cout << v[i] / vd << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160