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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define inf 1000000100

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    a %= b;
    c %= b;
    for(int n = 0; n < b-1; n++)
    {
        if((a*n)%b == c%b)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
H, W, N = [int(_) for _ in input().split()]
XY = sorted([[int(_) for _ in input().split()] for _ in range(N)],
            key=lambda xy: xy[0])
block = 0
for xy in XY:
    if xy[0] == xy[1] + block:
        block += 1
    elif xy[0] > xy[1] + block:
        print(xy[0] - 1)
        exit()
print(H)


Measured memory_bytes: 44356
import sys
from collections import deque

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

n, m = nm()
G = [list() for _ in range(n)]
for _ in range(m):
    u, v = nm()
    u -= 1; v -= 1
    G[u].append(v)
    G[v].append(u)

michi = [0]*n
dist = [n]*n
dist[0] = 0

q = deque()
q.append(0)
while q:
    v = q.popleft()
    for x in G[v]:
        if dist[x] > dist[v] + 1:
            dist[x] = dist[v] + 1
            michi[x] = v + 1
            q.append(x)
print('Yes')
prn(michi[1:])


Measured memory_bytes: 40212
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <cstring>
using namespace std;
const int N = 1e5 + 5;
#define ll long long

struct p{
    int x;
    int y;
}a[N];
bool cmp(p a,p b){
    if(a.y != b.y)
        return a.y < b.y;
    return a.x < b.x;
}
int main(){
    int n,ans,q,p;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%d %d",&q,&p);
        a[i].x = q - p;
        a[i].y = q + p;
        if(a[i].x < 0) a[i].x = 0;
    }
    sort(a,a + n,cmp);
    if(a[0].x != a[0].y) ans = 1;
    else ans = 0;
    for(int j = 0,i = 1;i < n;i++)
        if(a[i].x >= a[j].y &&
            a[i].x != a[i].y){
            ans++; j = i;
        }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    v = list(map(int, readline().split()))
    v.sort()
    cur = v[0]

    for i in range(1, N):
        cur += v[i]
        cur /= 2

    print(cur)


if __name__ == '__main__':
    main()


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;

//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int bigint;

const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


struct Bitree {
	typedef int btT;
	vector<btT> bv;
	Bitree(int n) : bv(n + 3) {}
	btT sum(int i) {
		btT res=0; for(i++; i>0; i -= i & -i) res += bv[i]; return res;
	}
	btT sum(int a, int b) {return sum(b) - (a? sum(a-1): 0);}
	void add(int i, btT x){for(i++; i<(int)bv.size(); i += i & -i) bv[i] += x; }
};

int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m,q;
	cin >>n >>m >>q;
	
	vector<int> l(m), r(m), s(q), t(q);
	
	rep(i,m) cin >>l[i] >> r[i];
	rep(i,q) cin >>s[i] >> t[i];
	
	vector<VI> tr(m+q, VI(3));
	rep(i,m) tr[i] = VI{r[i], -5, l[i]};
	rep(i,q) tr[i+m] = VI{t[i], i, s[i]};
	sort(all(tr));
	//for(auto x :tr) printf("%d:%d:%d ",x[0], x[1],x[2]); puts("");
	VI ans(q);
	Bitree bt(n+20);
	for(auto& x :tr){
		if(x[1]== -5) bt.add(x[2], 1);
		else ans[x[1]] = bt.sum(x[2], n+5);
	}
	rep(i,q) cout << ans[i] <<"\n";
	return 0;
}


Measured memory_bytes: 20096
#include <stdio.h>

int main(int argc, const char * argv[]) {

        int w,h,x,y,r;
        
        scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
        if ((0 >= r - x) && (x+r <= w) && (0 >= r - y) && (y+r <= h)) {
            printf("Yes\n");
        } else printf("No\n");
        
    
    
    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int color[100005];
vector<int> G[100005];
int deg[100005];
map<P, int> mp;

void dfs(int v,int p, int pcolor){
  int num=1;
  for(int nv: G[v]){
    if(nv==p)continue;
    if(num==pcolor)num++;
    color[mp[P(v, nv)]]=num;
    dfs(nv, v, num);
    num++;
  }
}



int main(){
  int n;
  cin >> n;
  rep(i, n-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
    mp[P(a, b)]=i;
    mp[P(b, a)]=i;
    deg[a]++;deg[b]++;
  }
  dfs(0, -1, -1);
  int maxdeg=0;
  rep(i, n-1){
    maxdeg=max(maxdeg, color[i]);
  }
  cout << maxdeg << endl;
  rep(i, n-1){
    cout << color[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 22700
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,n;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	for(a=-1000; a<=1000; a++){
		for(b=-1000; b<=1000; b++){
			if(a*a*a*a*a-b*b*b*b*b==n){
				cout<<a<<" "<<b;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3648
def main():
    n, p = map(int, input().split())
    s = input()
    mu = [None]*n
    ans = 0
    c = [0]*p
    if 10%p == 0:
        ss = map(int, s)
        ss = list(ss)
        for i in range(n):
            if ss[i]%p == 0:
                ans += i+1
        print(ans)
        return
    sr = s[::-1]
    ssr = map(int, sr)
    tens = 1
    v = 0
    for i, si in enumerate(ssr):
        v = (v + (si%p)*tens)%p
        mu[i] = v
        c[v] += 1
        tens *= 10
        tens %= p
    c[0] += 1
    for i in c:
        if i:
            ans += ((i-1)*i)//2
        
    print(ans)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 11156
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)//iをaからn
#define per(i,a,n) for (int i=a-1;i>=n;i--)//iをnからa
#define db(x) cout << #x << " = " << x << endl
#define db2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; //デバッグ用
#define all(x) (x).begin(), (x).end()
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
 
 
//sort(all(a)); ソート
//sort(all(a),greater<int>()); 逆順ソート
 
int main() {
  long long int a,b,c,d;
  cin >>a>>b>>c>>d;
  
  long long int max= -9223372036854775806;
  
  if(max<a*c){
      max=a*c;
  }
 if(max<a*d){
      max=a*d;
  }
  if(max<b*c){
      max=b*c;
  }
  if(max<b*d){
      max=b*d;
  }
  
  cout<<max<<endl;
 return 0;
}

Measured memory_bytes: 3632
a, b = map(int, input().split())
if a > 0 and b > 0:
    print("Positive")
elif a == 0 or b == 0 or (a * b < 0):
    print("Zero")
elif a < 0 and b < 1:
    if (abs(a) - abs(b)) % 2 == 0:
        print("Negative")
    else:
        print("Positive")


Measured memory_bytes: 3060
if __name__ == '__main__':
    n = int(raw_input())
    A = map(int, raw_input().split())
    cnt = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            A[minj], A[i] = A[i], A[minj]
            cnt += 1
    for x in A:
        print x,
    print
    print cnt


Measured memory_bytes: 4652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
// #define multicase
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e3 + 5;

ll x, y, ans;

void solve() {
    int T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    for(int tc = 1; tc <= T; tc++) {
        cin >> x >> y;
        while(x * 2 <= y) {
            x *= 2;
            ans++;
        }
        cout << ans + 1 << "\n";
    }
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    solve();
    
}

Measured memory_bytes: 3636
import math
import sys
import bisect

N = int(input())

A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A = sorted(A)
B = sorted(B)
C = sorted(C)

BAcnt = [0] * N


for i in range(N):
    BAcnt[i] = bisect.bisect_left(A, B[i])

BAruiseki = [0] * N
BAruiseki[0] = BAcnt[0]
for i in range(1,N):
    BAruiseki[i] = BAruiseki[i-1] + BAcnt[i]

ret = 0
for i in range(N):
    j = bisect.bisect_left(B, C[i]) - 1
    if len(BAruiseki) > j and j>=0:
        ret += BAruiseki[j]


print(ret)


Measured memory_bytes: 24480
extern crate proconio;
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        mut p: [usize; n],
        c: [i64; n],
    }
    let p = p.iter().map(|x| x - 1).collect::<Vec<_>>();
    let mut q = vec![0; n];
    for (i, &x) in p.iter().enumerate() {
        q[x] = i;
    }
    let mut ans = std::i64::MIN;
    for i in 0..n {
        let mut cur = i;
        let mut s = 0;
        let mut cycle = false;
        let mut len: usize = 0;
        for _ in 0..k {
            cur = p[cur];
            s += c[cur];
            ans = std::cmp::max(ans, s);
            len += 1;
            if cur == i {
                cycle = true;
                break;
            }
        }
        if cycle {
            let mut a = k / len;
            if a >= 2 {
                a -= 2;
            }
            s = s * a as i64;
            cur = i;
            let mut t = 0;
            for _ in 0..(k - a * len) {
                cur = p[cur];
                t += c[cur];
                ans = std::cmp::max(ans, s + t);
            }
        }
    }
    println!("{}", ans);
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int n;
int a[105];

void solve()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    int ans = 0;
    for (int i = 1; i <= n;++i)
    {
        if(i%2==1 && a[i]%2==1)
            ans++;
    }
    cout << ans << endl;
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main() {
	int n, t[100], m, p, x, sum = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &t[i]);
		sum += t[i];
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &p, &x);
		printf("%d\n", sum - t[p - 1] + x);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    // 変数宣言
    char judge[] = "No";
    char *p_judge = judge;
    int bingo[3][3];
    int value[10];
    int i, j, k, n;
    
    // ビンゴ入力
    for( i = 0; i < 3; i++ ){
        scanf( "%d %d %d", &bingo[i][0], &bingo[i][1], &bingo[i][2] );
    }

    // 選択No入力
    scanf( "%d", &n );

    for( i = 0; i < n; i++ ){
        scanf( "%d", &value[i] );
        for( j = 0; j < 3; j++){
            for( k = 0; k <3; k++ ){
                if( value[i] == bingo[j][k] ){
                    bingo[j][k] = -1;
                }
            }
        }
    }
    
    for( i = 0 ; i < 3; i++ ){
        if( bingo[i][0] == -1 && bingo[i][1] == -1  && bingo[i][2] == -1){
            p_judge = "Yes";
        }
    }

    for( i = 0 ; i < 3; i++ ){
        if( bingo[0][i] == -1 && bingo[1][i] == -1 && bingo[2][i] == -1){
            p_judge = "Yes";
        }
    }

    if( bingo[1][1] == -1 ){
        if( bingo[0][0] == -1 && bingo[2][2] == -1 ){
            p_judge = "Yes";
        }else if( bingo[0][2] == -1 && bingo[2][0] == -1 ){
            p_judge = "Yes";
        }
    }

    printf( "%s", p_judge );

    return 0;
}

Measured memory_bytes: 128
use std::io::Read;
use std::cmp::min;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let m: usize = it.next().unwrap().parse().unwrap();
    let h: Vec<i64> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let mut z = h.clone();
    z.push(0);
    z.sort();
    z.dedup();
    let inf = std::i64::MAX / 10;
    let mut dp = vec![vec![inf; z.len()]; m + 1];
    dp[0][0] = 0;
    for &a in h.iter() {
        let x = z.binary_search(&a).unwrap();
        let mut next = vec![vec![inf; z.len()]; m + 1];
        for i in 0..(m + 1) {
            let mut cost = vec![inf; z.len()];
            cost[0] = dp[i][0];
            for j in 1..z.len() {
                cost[j] = min(dp[i][j], cost[j - 1] + z[j] - z[j - 1]);
            }
            cost[z.len() - 1] = min(cost[z.len() - 1], dp[i][z.len() - 1]);
            for j in (0..(z.len() - 1)).rev() {
                cost[j] = min(cost[j], dp[i][j]);
                cost[j] = min(cost[j], cost[j + 1]);
            }
            for j in 0..z.len() {
                if j == x {
                    next[i][j] = min(next[i][j], cost[j]);
                } else if i < m {
                    next[i + 1][j] = min(next[i + 1][j], cost[j]);
                }
            }
        }
        dp = next;
    }
    let mut ans = inf;
    for i in 0..(m + 1) {
        for j in 0..z.len() {
            ans = min(ans, dp[i][j]);
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;
void solve(){
    int k;
    cin>>k;
    for(int i=0;i<k;i++){
        cout<<"ACL";
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3604
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

// fn solve(num: i64, hs: &Vec<i64>, a: i64, b: i64) -> bool {
//     let mut rem = num;
//     let damage = num * b;
//     for h in hs {
//         if h > &damage {
//             rem -= (h - damage + a - b - 1) / (a - b);
//         } else {
//             break;
//         }
//         if rem < 0 { return false; }
//     }
//     true
// }

fn main() {
    let input = readv();
    let (n, a, b) = (input[0], input[1], input[2]);
    let hs: Vec<i64> = (0..n).map(|_| { read() }).collect();
    let sol = |num: i64| {
        let mut rem = num;
        let damage = num * b;
        for h in &hs {
            if h > &damage {
                rem -= (h - damage + a - b - 1) / (a - b);
            }
            if rem < 0 { return false; }
        }
        true
    };
    let (mut l, mut r) = (0i64, 1e9 as i64);
    while l < r {
        let piv = (l + r) / 2;
        if sol(piv) {
            r = piv;
        } else {
            l = piv + 1;
        }
    }
    println!("{}", l);
}


Measured memory_bytes: 4352
#include<queue>
#include<cstdio>
#include<algorithm>
#define maxn 100005
using namespace std;
int n,m,ans;
priority_queue<int> hep;
struct chj{
	int x,val;
	bool operator <(const chj b)const{return x<b.x;}
}a[maxn];
inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}
int main(){
	n=read();m=read();
	for (int i=1;i<=n;i++) a[i]=(chj){read(),read()};
	sort(a+1,a+n+1);
	int j=1;
	for (int i=1;i<=m;i++){
		while (j<=n&&a[j].x<=i) hep.push(a[j].val),j++;
		if (hep.size()) ans+=hep.top(),hep.pop();
	}
	printf("%d\n",ans);
	return 0;
}

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

//vector <long long> v[1000001];

//stack <long long> s, s2;

//queue <long long> s;

long long int  x[2000000], y[10000], m=0, szu, wy;
//char s[10000000];

int main()
{
    long long int d, e, f, i, j, q, t, n, k, a, b, c, w, p, aa, bb, cc, dd, nn, kk;
    t=1;
 //   scanf("%lld", &t);
    for(q=1; q<=t; q++)
    {
        scanf("%lld", &n);

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



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

int main() {
    int a, b, t;
    while (cin >> a >> b) {
        while (a) {
            t = a; a = b%a; b = t;
        }
        cout << b << endl;
    }
    return 0;
}

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

int main() {
    long long int h, w, n, a, b;
    cin >> h >> w >> n;
    long long int ans[10] = {0}, sum = 0;
    map<pair<int, int>, long long int> mp;

    for(int i = 0; i < n; ++i) {
        cin >> a >> b;
        a--, b--;
        for(int dy = -1; dy <= 1; ++dy) {
            for(int dx = -1; dx <= 1; ++dx) {
                long long int x = b + dx, y = a + dy;
                if(x >= 1 && x <= w-2 && y >= 1 && y <= h-2) {
                    mp[make_pair(x, y)]++;
                }
            }
        }
    }

    auto begin = mp.begin(), end = mp.end();
    for(auto iter = begin; iter != end; iter++) {
        ans[iter->second]++;
        sum++;
    }
    ans[0] = (h-2)*(w-2) - sum;

    for(int i = 0; i < 10; ++i) cout << ans[i] << '\n';

    return 0;
}


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

struct point {
    double x, y;
};

double th = M_PI * 60 / 180;

void koch(int d, point p1, point p2) {
    if(d == 0) return;
    point s, t, u;
    s.x = (2 * p1.x + p2.x) / 3;
    s.y = (2 * p1.y + p2.y) / 3;
    t.x = (p1.x + 2 * p2.x) / 3;
    t.y = (p1.y + 2 * p2.y) / 3;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(d - 1, p1, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(d - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(d - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(d - 1, t, p2);
}

int main() {
    int n;

    point p1, p2;
    p1.x = 0;
    p1.y = 0;
    p2.x = 100;
    p2.y = 0;

    cin >> n;
    cout << p1.x << " " << p1.y << endl;
    koch(n, p1, p2);
    cout << p2.x << " " << p2.y << endl;
}


Measured memory_bytes: 3408
#include<iostream>
using namespace std;
int main(){
    int N;string S;
    cin >> N;
    cin >> S;
    int len = S.length();
    for(int i=0;i<len;i++){
        S.at(i)=(S.at(i)-'A'+N)%26 + 'A';
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <array>
#include <set>
#include <sstream>
#include <cmath>

using namespace std;

typedef long long LL;


vector<vector<LL>> creat_matrix(LL h, LL w) {
	LL _temp;
	vector<vector<LL>> mat;
	for (LL i = 0; i < h; ++i) {
		vector<LL> vec;
		for (LL j = 0; j < w; ++j) {
			cin >> _temp;
			vec.emplace_back(_temp);
		}
		mat.emplace_back(vec);
	}
	return mat;
}


vector<vector<LL>> inner_product(vector<vector<LL>> X, vector<vector<LL>> Y) {
	size_t n = X.size();
	size_t m = X[0].size();
	size_t l = Y[0].size();

	vector<vector<LL>> mat(n, vector<LL>(l, 0));
	for (LL i = 0; i < n; ++i) {
		for (LL j = 0; j < m; ++j) {
			for (LL k = 0; k < l; ++k) {
				mat[i][k] += X[i][j] * Y[j][k];
			}
		}
	}
	return mat;
}


void show_matrix(vector<vector<LL>> mat) {
	size_t len = mat[0].size();
	for (auto&& t : mat) {
		for (LL i = 0; i < len; ++i) {
			printf("%d", t[i]);
			if (i != (len - 1)) printf(" ");
		}
		printf("\n");
	}
}


vector<string> split(const string& s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;

	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}

	return elems;
}


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

	int taro_score = 0, hanako_score = 0;
	string taro_card, hanako_card;
	for (int i = 0; i < n; ++i) {
		cin >> taro_card >> hanako_card;
		
		if (taro_card > hanako_card) taro_score += 3;
		else if (taro_card < hanako_card) hanako_score += 3;
		else {
			taro_score++;
			hanako_score++;
		}
	}

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



Measured memory_bytes: 3244
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	VI ex( n );

	for ( auto &num : ex )
	{
		cin >> num;
	}

	vector< vector<ull> > dp( n - 1 );

	for ( auto &line : dp )
	{
		line.resize( 21 );
	}

	dp[0][ ex[0] ] = 1;

	REP( i, 0, dp.size() - 1 )
	{
		REP( j, 0, dp[i].size() )
		{
			if ( 0 <= j - ex[i+1] )
			{
				dp[i+1][ j-ex[i+1] ] += dp[i][j];
			}

			if ( j + ex[i+1] <= 20 )
			{
				dp[i+1][ j+ex[i+1] ] += dp[i][j];
			}
		}
	}

	cout << dp.back()[ ex.back() ] << endl;

	return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
int main(void){
    int m, f, r;
    scanf("%d %d %d", &m, &f, &r);
    do{
        if(m + f >= 80) printf("A\n");
        else if(m == -1 || f == -1) printf("F\n");
        else if(65 <= m + f && m + f <= 79) printf("B\n");
        else if(50 <= m + f && m + f <= 64) printf("C\n");
        else if(30 <= m + f && m + f <= 49){
            if(r >= 50) printf("C\n");
            else printf("D\n");
        }else if(m + f < 30) printf("F\n");
        scanf("%d %d %d", &m, &f, &r);
    }while(!(m == -1 && r == -1 && f == -1));
    return 0;
}

Measured memory_bytes: 584
import sys
input = sys.stdin.readline

def solve():
    MOD = 998244353

    N = int(input())
    XDs = [tuple(map(int, input().split())) for _ in range(N)] + [(10**12, 0)]

    XDs.sort()
    Xs = [X for X, D in XDs]

    stack = [N]
    dp = [0] * (N+1)
    dp[-1] = 1
    for i in reversed(range(N)):
        X, D = XDs[i]
        while Xs[stack[-1]] < X+D:
            stack.pop()
        dp[i] = dp[stack[-1]] + dp[i+1]
        dp[i] %= MOD
        stack.append(i)

    print(dp[0])


solve()


Measured memory_bytes: 43052
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(input())
    A = []
    for _ in range(N):
        A.append(int(input()))
    A.sort()
    ans = sum(A)
    if ans%10==0:
        for i in range(N):
            if A[i]%10!=0:
                ans -= A[i]
                break
    print(ans if ans%10!=0 else 0)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define M                    1000000007
#define pi                   3.14159265358979323846
#define cel(x,a)             (x+a-1)/a
#define ll                   long long
#define pii                  pair<int, int>
#define pll                  pair<ll, ll>
#define vi                   vector<int>
#define vl                   vector<ll>
#define vpi                  vector<pii>
#define vpl                  vector<pll>
#define pb                   push_back
#define lb                   lower_bound
#define ub                   upper_bound
#define ps(x,y)              fixed<<setprecision(y)<<x
#define pf(x,y)              setfill('x')<<setw(y)
#define mp                   make_pair
#define F                    first
#define S                    second
/*.*Ashish_akj*.*/
#define lcm(m,n)             (m/__gcd(m,n))*n
#define all(v)               v.begin(), v.end()
using namespace std;
const int N = 2e6 + 4;
/*
int ncr(int n, int r) 
{ 
    long long p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 

    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            long long m = __gcd(p, k); 
            p /= m; 
            k /= m; 

            n--; 
            r--;
        }
    } 

    else
        p = 1; 
    return p;
} */
/*vector<bool>visited;
 vector<vector<int>>adj;
void dfs(int v)
{visited[v]=true;
for(int i:adj[v])
{if(!visited){dfs(i);}
}}
*/
int main()
{ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s;cin>>s;
if(s[s.size()-1]=='s'){cout<<s<<"es";return 0;}
cout<<s<<"s";
    return 0;
}




Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, max=0, counter=0;
  
  cin >> N;
  vector<string> blue(N);
  for(int i=0; i<N; i++) cin >> blue.at(i);
  
  cin >> M;
  vector<string> red(M);
  for(int i=0; i<M; i++) cin >> red.at(i);
  
  for(int i=0; i<N; i++){
    counter=0;
    for(int j=0; j<N; j++){
      if(blue.at(i)==blue.at(j)) counter++;
    }
    for (int k=0; k<M; k++){
      if(blue.at(i)==red.at(k)) counter--;
    }
    if (counter > max) max=counter;
  }
  
  cout << max;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#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 FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


void solve() {
  int a, b;
  cin >> a >> b;
  cout << (a*3+b)/2 << endl;
}

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


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

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

    vector<vector<int>> g(n);
    vector<pair<int, int>> vp(n - 1);
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;

        g[a].push_back(b);
        g[b].push_back(a);
        vp[i] = make_pair(a, b);
    }
    
    int k = 0;
    map<pair<int, int>, int> ans;
    vector<int> parent_color(n, 0);
    vector<int> used(n, 0);
    queue<int> que;

    used[0] = 1;
    que.push(0);

    while(!que.empty()) {
        int from = que.front();
        que.pop();

        k = max(k, (int)g[from].size());
        int current_color = 1;

        for (auto &&to : g[from])
        {
            if (used[to]) continue;
            if (parent_color[from] == current_color) current_color++;

            parent_color[to] = ans[make_pair(from, to)] = ans[make_pair(to, from)] = current_color++;

            used[to] = 1;
            que.push(to);
        }
    }

    cout << k << endl;
    for (int i = 0; i < n - 1; i++)
    {
        cout << ans[vp[i]] << endl;
    }

    return 0;
}

Measured memory_bytes: 20096
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }.toList()

fun main(args: Array<String>) {
    val (N, K) = readInts()
    val x = readInts()

    var answer = -1
    for (i in 0 until N - K + 1) {
        val insertedSum = Math.abs(x[i] - x[i + K - 1]) + Math.min(Math.abs(x[i]), Math.abs(x[i + K - 1]))
        if (answer == -1 || insertedSum < answer) answer = insertedSum
    }

    println(answer)
}

Measured memory_bytes: 49960
n = gets.to_s.to_i
ps = gets.to_s.split.map{ |v| v.to_f }

dp = Array.new(n+1) { Array.new(n+1, 0)}
dp[0][0] = 1.0

n.times do |i|
  0.upto(i+1) do |j|
    dp[i+1][j] = dp[i][j-1] * ps[i] + dp[i][j] * (1 - ps[i])
  end
end

ans = 0
dp[n].each_with_index do |pi, i|
  next if i <= n / 2
  ans += pi
end

puts ans

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

int main(){
  vector< vector<int> > m;
  vector<int> v;
  int i,j;
  int a,b;
  vector<int> ans;

  cin>>a>>b;

  m.resize(a);
  for(i=0;i<a;i++){
    m[i].resize(b);
  }
  v.resize(b);
  ans.resize(a);

  for(i=0;i<a;i++){
    for(j=0;j<b;j++){
      cin>>m[i][j];
    }
  }

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

  for(i=0;i<a;i++){
    for(j=0;j<b;j++){
      ans[i]+=m[i][j]*v[j];
    }
  }

  for(i=0;i<a;i++){
    cout<<ans[i]<<endl;
  }

  return 0;
}

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

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

    vector<int> p(n);
    for (auto i = 0; i < n; i++) cin >> p[i];
    sort(p.begin(), p.end());

    int ans = 0;
    for (auto i = 0; i < k; i++) ans += p[i];

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        int x = scan.nextInt();
        String cnt;
        
        if( x < 1200 )cnt = "ABC";
        else cnt = "ARC";
        
        System.out.println(cnt);
	  }
}

Measured memory_bytes: 22100
#なんもわからんくなった
N,M=map(int,input().split())
s=[]
c=[]
ans=0
#入力
for i in range(M):
    x,y=map(int,input().split())
    s.append(x)
    c.append(y)

if M==0:
    if N==1:
        print(0)
        exit()
    elif N==2:
        print(10)
        exit()
    else:
        print(100)
        exit()
#同じ桁だけど数が違う場合
for i in range(M-1):
    for j in range(i+1,M):
        if s[i]==s[j] and c[i]!=c[j]:
            print(-1)
            exit()

#1桁目が0なのにNが2桁以上の時
for i in range(M):
    if s[i]==1 and c[i]==0 and N>1:
        print(-1)
        exit()

#処理の重複を消してる
for i in range(M-1):
    for j in range(i+1,M):
        if s[i]==s[j] and c[i]==c[j]:
            s[j]=0
            c[j]=0

#各桁ごとの最小値
if N==1:
    print(c[0])
    exit()
if N==2:
    ans=10
    for i in range(M):
        if s[i]==1:
            ans=0
    for i in range(M):
        if s[i]==1:
            ans+=10*c[i]
        if s[i]==2:
            ans+=c[i]
    print(ans)
    exit()
if N==3:
    ans=100
    for i in range(M):
        if s[i]==1:
            ans=0
    for i in range(M):
        if s[i]==1:
            ans+=100*c[i]
        if s[i]==2:
            ans+=10*c[i]
        if s[i]==3:
            ans+=c[i]
    print(ans)

Measured memory_bytes: 3192
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a = INT()
print(a+a**2+a**3)


Measured memory_bytes: 9972
# from other person's code
n = int(input())
a = list(map(int, input().split()))
ls = [0]*(n+1)
ans = []
for i in reversed(list(range(n))):
    if sum(ls[::i+1][1:]) % 2 != a[i]:
        ls[i+1] = 1
        ans.append(i+1)
print(sum(ls))
if ans: print(' '.join(map(str, ans)))

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int a[N];
	bool put[N];
	for(int i = 0; i < N; i++) {
		cin >> a[i];
		a[i]--;
		put[i] = true;
	}

	int nextPut = 0;
	int count = 0;
	while(true) {
		if(nextPut == 1) {
			break;
		}
		if(put[nextPut]) {
			put[nextPut] = false;
			nextPut = a[nextPut];
			count++;
		} else {
			cout << -1 << endl;
			return 0;
		}

	}
	cout << count << endl;
}


Measured memory_bytes: 768
#include<cstdio>
#include<algorithm>
int main(){
    char n[18];
    scanf("%s",n);
    int a=0,b=0;
    bool largest=true;
    for(int i=0;n[i]!='\0';i++){
        if(largest && n[i]!='9'){
            largest=false;
            a+=std::max(n[0]-'0'-1,n[i]-'0'-1);
        }else a+=9;
        b+=n[i]-'0';
    }
    printf("%d",std::max(a,b));
    return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[100002];
		Arrays.fill(x, 0);

		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			x[tmp]++;
			x[tmp + 1]++;
			x[tmp + 2]++;
		}

		Arrays.sort(x);

		int max = 0;
		for (int m : x) {
			max = Math.max(max, m);
		}

		System.out.println(max);

		sc.close();

	}

}

Measured memory_bytes: 59456
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
a=1
b=1
n1=1
for i in range(n):
    n1=n1*(i+1)
for i in range(n):
    t=0
    i1=1
    for j in range(i+1):
        i1=i1*(n-j)
    for j in range(n):
        if i<j and p[i]>p[j]:
            t+=1
    a+=t*n1//i1
for i in range(n):
    t=0
    i1=1
    for j in range(i+1):
        i1=i1*(n-j)
    for j in range(n):
        if i<j and q[i]>q[j]:
            t+=1
    b+=t*n1//i1
c=a-b
if c>0:
    print(c)
else:
    print(-c)

Measured memory_bytes: 38384
class Combination:
    """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う"""
    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [0] * (n + 1)
        self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
        for i in reversed(range(n)):
            self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
        self.MOD = MOD

    def inverse(self, k):
        """kの逆元を求める O(1)"""
        return (self.inv_fact[k] * self.fact[k - 1]) % self.MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD

    def combination2(self, k, r):
        """kCrを求める O(r)
        kが大きいが、r <= nを満たしているときに使用
        """
        if k < r:
            return 0
        res = 1
        for l in range(r):
            res *= (k - l)
            res %= self.MOD
        return (res * self.inv_fact[r]) % self.MOD

s = int(input())
MOD = 10 ** 9 + 7
comb = Combination(100000, MOD)


ans = 0
for i in range(1, s + 1):
    box = i
    ball = s - (3 * i)
    if 0 <= box <= s + 1 and 0 <= ball <= s + 1:
        ans += comb.combination(ball + box - 1, ball)
        ans %= MOD
print(ans)

Measured memory_bytes: 74204
import std.stdio;
import std.bigint;
import std.conv;
import std.string;
import std.array;

void main(){
    auto c = array(["Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"][]);
    while(true){
	int m,n;
	auto s = readln().split().to!(int[]);
	m = s[0];
	n = s[1];
	if(m == 0 && n == 0) break;
	BigInt num = "1";
	BigInt p = to!string(m);
	for(int i=0;i<n;i++){
	    num *= p;
	}
	string ans = "";
	BigInt t = "100000000000000000000000000000000000000000000000000000000000000000000";
	for(int i=1;i<=17;i++){
	    auto syo = num / t;
	    
	    if(syo > 0){
		ans ~= to!string(syo) ~ c[17-i];
	    }
	    num %= t;
	    t /= 10000;
	}
	if(num > 0)
	    ans ~= to!string(num/t);
	ans.writeln();
    }
}

Measured memory_bytes: 2536
#include <bits/stdc++.h>
using Int = int64_t;
const Int inf = 1LL << 53;

std::pair<Int,Int> eval2(std::string ss, Int i) {
   if( ss[i] == '0' ) {
      return std::make_pair(0, i+1);
   }
   else if( ss[i] == '1' ) {
      return std::make_pair(1, i+1);
   }
   else if( ss[i] == '-' ) {
      Int i2 = i;
      i2 += 1;
      Int t;
      std::tie(t, i2) = eval2(ss, i2);
      return std::make_pair(t ^ 1, i2);
   }
   else if( ss[i] == '(' ) {
      Int i2 = i;
      i2 += 1;
      Int left;
      std::tie(left, i2) = eval2(ss, i2);
      char op = ss[i2];
      i2 += 1;
      Int right;
      std::tie(right, i2) = eval2(ss, i2);
      assert(ss[i2] == ')');
      i2 += 1;
      if( op == '*' ) {
         return std::make_pair(left & right, i2);
      }
      else if( op == '^' ) {
         return std::make_pair(left ^ right, i2);
      }
      else {
         assert(0);
      }
   }
   else {
      std::cerr << ss[i] << std::endl;
      assert(0);
   }
   assert(0);
   return std::make_pair(-1,-1);
}

Int eval(std::string ss) {
   Int res = 0;
   for(Int i = 0; i < 1<<4; ++i) {
      std::string ts = ss;
      for(Int k = 0; k < 4; ++k) {
         for(Int j = 0; j < (Int)ts.size(); ++j) {
            if( ts[j] == 'a' + k ) {
               if( (i & (1 << k)) == 0 ) {
                  ts[j] = '0';
               }
               else {
                  ts[j] = '1';
               }
            }
         }
      }
      res |= eval2(ts, 0).first << i;
   }
   return res;
}


int main() {
   std::map<Int,Int> dp;
   dp[0x0000] = 1;
   dp[0xffff] = 1;
   dp[0xaaaa] = 1;
   dp[0xcccc] = 1;
   dp[0xf0f0] = 1;
   dp[0xff00] = 1;
   for(Int i = 0; i < 32; ++i) {
      // -
      for(auto xs1 : dp) {
         Int x1, s1;
         std::tie(x1, s1) = xs1;
         if( dp.count(x1^0xffff) == 0 ) {
            dp[x1^0xffff] = s1+1;
         }
         else {
            dp[x1^0xffff] = std::min(dp[x1^0xffff], s1+1);
         }
      }
      // *, ^
      for(auto xs1 : dp) {
         Int x1, s1;
         std::tie(x1, s1) = xs1;
         for(auto xs2 : dp) {
            Int x2, s2;
            std::tie(x2, s2) = xs2;
            if( s1 + s2 + 3 > 16 ) {
               continue;
            }
            // ^
            if( dp.count(x1^x2) == 0 ) {
               dp[x1^x2] = s1 + s2 + 3;
            }
            else {
               dp[x1^x2] = std::min(dp[x1^x2], s1 + s2 + 3);
            }
            // *
            if( dp.count(x1&x2) == 0 ) {
               dp[x1&x2] = s1 + s2 + 3;
            }
            else {
               dp[x1&x2] = std::min(dp[x1&x2], s1 + s2 + 3);
            }
         }
      }
   }
   for(;;) {
      std::string ss;
      std::cin >> ss;
      if( ss == "." ) {
         break;
      }
      // printf("%lx\n", eval(ss));
      std::cout << dp[eval(ss)] << std::endl;
   }
}



Measured memory_bytes: 3352
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;

int N;
string s, t;

signed main()
{
    cin >> N;
    cin >> s >> t;

    for (int i=0; i<=N; i++) {
        string str = s + t.substr(N - i);
        if (str.substr(0, N) == s && str.substr(str.length() - N) == t) {
            cout << str.length() << endl;
            return 0;
        }
    }
}


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

int main(void){

  int i,j,n,m,count=0;
  int s[N],t[N];

  scanf("%d",&n);

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

  scanf("%d",&m);

  for(j=0;j<m;j++){
    scanf("%d",&t[j]);
  }

  for(j=0;j<m;j++){
    for(i=0;i<n;i++){
      if(s[i] == t[j]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 648
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.DP.A
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var N = sc.Nextint();
            var h = sc.Arrayint(N);

            var cost = new int[N];
            for (int i = 0; i < N; i++)
            {
                if (i == 0)
                {
                    continue;
                }
                else if (i == 1)
                {
                    cost[i] = Math.Abs(h[1] - h[0]);
                }
                else
                {
                    cost[i] = Math.Min(cost[i - 2] + Math.Abs(h[i] - h[i - 2]), cost[i - 1] + Math.Abs(h[i] - h[i - 1]));
                }
            }
            Console.Error.WriteLine(string.Join(" ", cost));
            Console.WriteLine(cost[N - 1]);
        }
    }

    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}


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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int>x(M);

  for(int i=0;i<M;i++){
    cin>>x[i];
  }
  sort(x.begin(),x.end());
  
  if(N>=M){
    cout<<0<<endl;
    return 0;
  }

  vector<int> diff(M-1);
  for(int i=0;i<M-1;i++){
    diff[i]=x[i+1]-x[i];
  }
  sort(diff.begin(),diff.end());
  ll ans=0;
  for(int i=0;i<M-N;i++){
    ans+=(ll)diff[i];
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <string.h>

using namespace std;

int N;
int a[2000000];

int main(int argc, char** argv) {
    cin >> N;
    for(int i=1;i<=N;i++) cin >> a[i];

    int ans = 0;
    for(int i=1;i<=N;i++) {
        while ((a[i] % 2) == 0) {
            a[i] /= 2;
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<cmath>
#include<vector>
#include<string>
 
using namespace std;
 
int main() {
	int  a, b,h;
 
	cin >>a >>b>>h;
 
    cout<<((a+b)*h)/2<<endl;
    
	return 0;
}

Measured memory_bytes: 256