akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int dx[]{ 1,0,-1,0 }, dy[]{ 0,1,0,-1 };
char f[2][50][51];
bool used[50][50][50][50];
struct st {
	int rx, ry, lx, ly;
};
int main() {
	int w, h;
	while (scanf("%d%d", &w, &h), w) {
		memset(used, 0, sizeof(used));
		st in;
		rep(i, h * 2) {
			scanf("%s", f[i % 2][i / 2]);
			rep(j, w) {
				if (f[i % 2][i / 2][j] == 'R')in.rx = i / 2, in.ry = j, f[i % 2][i / 2][j] = '.';
				if (f[i % 2][i / 2][j] == 'L')in.lx = i / 2, in.ly = j, f[i % 2][i / 2][j] = '.';
			}
		}
		queue<st>que;
		que.push(in);
		used[in.rx][in.ry][in.lx][in.ly] = true;
		while (!que.empty()) {
			st s = que.front(); que.pop();
			if (f[1][s.rx][s.ry] == '%'&&f[0][s.lx][s.ly] == '%') {
				puts("Yes"); goto g;
			}
			if (f[1][s.rx][s.ry] == '%' || f[0][s.lx][s.ly] == '%')continue;
			rep(i, 4) {
				int nrx = s.rx + dx[i], nry = s.ry + dy[i], nlx = s.lx + dx[i], nly = s.ly + dy[(i + 2) % 4];
				if (nrx < 0 || nrx >= h || nry < 0 || nry >= w || f[1][nrx][nry] == '#')nrx = s.rx, nry = s.ry;
				if (nlx < 0 || nlx >= h || nly < 0 || nly >= w || f[0][nlx][nly] == '#')nlx = s.lx, nly = s.ly;
				if (!used[nrx][nry][nlx][nly]) {
					used[nrx][nry][nlx][nly] = true;
					que.push({ nrx,nry,nlx,nly });
				}
			}
		}
		puts("No");
	g:;
	}
}

Measured memory_bytes: 10048
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()) {
            double a = scan.nextDouble();
            double b = scan.nextDouble();
            double c = scan.nextDouble();
            double d = scan.nextDouble();
            double e = scan.nextDouble();
            double f = scan.nextDouble();
            double db;
            double ae;
            double x;
            double y;
            double j;
            double g;
            db = d * b;
            ae = a * e;

            j = db - ae;
            y = ((d * c) - (a * f)) / j;

            g = y * b;

            x = (-1 * (g) + c) / a;

            System.out.printf("%.3f %.3f\n", x, y);

        }
    }
}



Measured memory_bytes: 28564
N, A, B = map(int, input().split())
S = list(input())

A_sum = 0
B_sum = 0

for i in S:
        if i == 'a':
                if A_sum + B_sum < A + B:
                        A_sum += 1
                        print('Yes')
                else:
                        print('No')
        elif i == 'b':
                if A_sum + B_sum < A + B and B_sum < B:
                        B_sum += 1
                        print('Yes')
                else:
                        print('No')
        else:
                print('No')

Measured memory_bytes: 4708
#include<stdio.h>

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

  int cnt = 0;
  long t = x;
  while(1) {
    cnt++;
    //printf("t = %ld, y = %ld\n", t, y);
    t *= 2;
    if (t > y) break;
  }

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


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

int main(){
    ll t;
    cin >> t;
    ll n;
    vector <vector <ll>> rr,lll,fr;
    ll qq;
    ll wa=0;
    ll k,l,r;
    ll sa=0;
    priority_queue <ll> q1,q2,q3;
    ll qqq;
    int no;
    vector <ll> ans(t);

    rep(i,t){
    cin >> n;
    lll=fr;
    rr=fr;
    sa=0;
    
    wa=0;
    rep(j,n){
        cin >> k >> l >> r;
        if(l>r){
            wa+=l;
        }
        else{
            wa+=r;
        }
        //wa+=max(l,r);
        if(l>=r){
            lll.push_back({k,l-r});
            ++sa;
        }
        else{
            rr.push_back({n-k,r-l});
        }
    }

// cout << sa << endl;

        sort(lll.begin(),lll.end());
        q1=q3;
        qq=sa;
        rep(i2,sa){
            if(qq>=1){
            while(lll[qq-1][0]>=sa-i2){

                q1.push(lll[qq-1][1]);
                --qq;
                if(qq==0){
                    break;
                }
               //cout << qq << endl;
            }
            }
            //cout << 5 << endl;
            if(q1.size()!=0){
                //qqq=q1.top();
                q1.pop();
            }
        }
//cout << sa << endl;
       
        
        no=q1.size();
        rep(i3,no){
            qqq=q1.top();
            q1.pop();
            wa-=qqq;
        }


        sort(rr.begin(),rr.end());
        q1=q3;
        qq=n-sa;
        rep(i2,n-sa){
            if(rr[i2][0]==0){
                wa-=rr[i2][1];
            }
            if(qq>=1){
            while(rr[qq-1][0]>=(n-sa-i2) and qq>=1){
                
                q1.push(rr[qq-1][1]);
                --qq;
                if(qq==0){
                    break;
                }
            }
            }
            if(q1.size()!=0){
                qqq=q1.top();
                q1.pop();
            }
        }
        //int no;
        no=q1.size();
        rep(i3,no){
            qqq=q1.top();
            q1.pop();
            wa-=qqq;
        }


        ans[i]=wa;








    





    }

    rep(i,t){
        cout << ans[i] << endl;
    }


    

    return 0;
}

Measured memory_bytes: 15940
n=int(input())
cityLst=[]
for i in range(n):
	s,p=map(str,input().split(" "))
	cityLst.append(["{:<10}".format(s),p])
sCityLst=sorted(cityLst,key=lambda x:x[0]+"a"+chr(-1*(int(x[1])-100)+97))
for o in sCityLst:
	print(cityLst.index(o)+1)

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

int main() {
    long long x,k,d;
    cin>>x>>k>>d;
    long long absx=abs(x);
    long long w=absx/d;
    if(k<=w)
        cout<<absx-k*d;
    else{
        if(x>0){
            long long l=x-w*d;
            long long r=l-d;
            k-=w;
            if(k%2){
                cout<<abs(r)<<endl;
            }
            else
                cout<<abs(l)<<endl;
        }
        else if(x==0){
            if(k%2)
                cout<<d<<endl;
            else
                cout<<x<<endl;
        }
        else{
            long long l=x+w*d;
            long long r=l+d;
            k-=w;
            if(k%2){
                cout<<abs(r)<<endl;
            }
            else
                cout<<abs(l)<<endl;
        }
    }
}


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

int main() {
    std::vector<double> a;
    int n;
    std::cin>>n;
    for(int i=0;i<n;i++){
        double t;
        std::cin>>t;
        a.push_back(1.0/t);
    }
    double s=0;
    for(int i=0;i<n;i++){
        s= s+a[i];
    }
    std::cout<<1.0/s<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
ll n;
void add(ll& a, ll b)
{
	a=((a%mod)+(b%mod))%mod;
}
ll mul(ll a, ll b)
{
	return ((a%mod)*(b%mod))%mod;
}
struct M{
	vector<vector<ll>> t;
	M(){
		t.resize(n,vector<ll>(n));
	}
	M operator*(M& b){
		M c=M();
		for(ll i=0;i<n;i++)
		{
			for(ll j=0;j<n;j++)
			{
				for(ll k=0;k<n;k++)
					add(c.t[i][k],mul(t[i][j],b.t[j][k]));
			}
		}
		return c;
	}
};
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("test.txt","r",stdin);
	ll k;
	cin>>n>>k;
	vector<vector<ll>> arr(n,vector<ll>(n));
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
			cin>>arr[i][j];
	}
	M ans=M();
	for(ll i=0;i<n;i++)
		ans.t[i][i]=1;
	M m=M();
	m.t=arr;
	while(k){
		if(k%2)
			ans=ans*m;
		m=m*m;
		k/=2;
	}
	ll total=0;
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
			add(total,ans.t[i][j]);
	}
	cout<<total<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  double sum = 0.0;
  cin >> n >> m;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }
  sum = sum / (4*m);
  sort(a.begin(), a.end(), greater<int>());
  for(int i = 0; i < m; i++) {
    if(a.at(i) < sum) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

struct edge
{
	int from;
	int to;
	ll cost;
};

bool reachable[2505];
bool Rreachable[2505];
vector<int> to[2505];
vector<int> ot[2505];

void dfs(int v)
{
	if (reachable[v])return;
	reachable[v] = true;
	for (int next : to[v])dfs(next);
}
void rdfs(int v)
{
	if (Rreachable[v])return;
	Rreachable[v] = true;
	for (int next : ot[v])rdfs(next);
}

int main()
{
	int n, m, p; cin >> n >> m >> p;
	vector<edge> edges(m);
	rep(i, m)
	{
		int a, b; cin >> a >> b;
		--a, --b;
		ll c; cin >> c;
		c -= p;
		edge e = { a,b,c };
		edges[i] = e;
		to[a].push_back(b);
		ot[b].push_back(a);
	}
	dfs(0);
	rdfs(n - 1);
	vector<bool> ok(n);
	rep(i, n)if (reachable[i] && Rreachable[i])ok[i] = true;

	ll INF = 1e18;
	vector<ll> res(n, -INF);
	res[0] = 0;
	rep(i, n)
	{
		bool changed = false;
		rep(j, m)
		{
			edge e = edges[j];
			if (res[e.from] == -INF)continue;
			if (!ok[e.from])continue;
			if (!ok[e.to])continue;
			if (res[e.to] < res[e.from] + e.cost)
			{
				res[e.to] = res[e.from] + e.cost;
				changed = true;
				if (i == n - 1)
				{
					cout << -1 << endl;
					return 0;
				}
			}
		}
		if (!changed)break;
	}
	if (res[n - 1] == -INF)cout << -1 << endl;
	else cout << max(0LL, res[n - 1]) << endl;
}

Measured memory_bytes: 640
n=int(input())
p=round(n**0.5)+1
ans=[0]*n
for x in range(1,p):
    for y in range(1,p):
        for z in range(1,p):
            k=x**2+y**2+z**2+x*y+y*z+z*x
            k-=1
            if 0<=k<=n-1:
                ans[k]+=1
for i in ans:
    print(i)

Measured memory_bytes: 9560
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end() 
#define MAXN 200005
using namespace std;

int n,m,a,b;
vector<int> adj[MAXN];
int vis[MAXN];
int dp[MAXN];

void dfs(int s)
{
    vis[s]=1;
    for(int i=0;i<adj[s].size();i++)
    {
        if(!vis[adj[s][i]]) dfs(adj[s][i]);
        dp[s] = max(dp[s], 1+dp[adj[s][i]]);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    while(m--)
    {
        cin>>a>>b;
        adj[a].pb(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i]) dfs(i);
    }
    int ans=INT_MIN;
    for(int i=1;i<=n;i++) ans = max(ans, dp[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 10880
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
P x[512121];
bool cm(P a, P b) {
	return a.second < b.second;
}

int cpair(P *a, int n) {
	if (n <= 1)return 100000000;
	int m = n / 2;
	int x = a[m].first;
	int d = min(cpair(a, m), cpair(a + m, n - m));
	inplace_merge(a, a + m, a + n, cm);

	vector<P>b;
	for (int i = 0; i < n; i++) {
		if (abs(a[i].first - x) >= d)continue;

		for (int j = 0; j < b.size(); j++) {
			int dx = a[i].first - b[b.size() - j - 1].first;
			int dy = a[i].second - b[b.size() - j - 1].second;
			if (dy >= d)break;
			d = min(d, (dx*dx + dy*dy));
		}
		b.push_back(a[i]);
	}
	return d;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		x[i] = P(a, b);
	}
	sort(x, x + n);
	cout << cpair(x, n) << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 12552
n = int(input())
s = input().strip()

d = [0]
for _s in s:
  if _s == '(':
    d.append(d[-1] + 1)
  else:
    d.append(d[-1] - 1)
x = min(d[1:])
ds = d[-1]

if x > 0:
  print('(' * (-x) + s + ')' * (ds))
else:
  print('(' * (-x) + s + ')' * (ds - x))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

vector<pair<P,int>> city;
vector<pair<int, P>> dist_pair;
int mid[200001];
bool ok[200001];
void init(int n)
{
    int i;
    for(int i = 1; i < n+1; i++)
    {
        mid[i] = i;
    }
}

int find(int x)
{
    if(x != mid[x])
        mid[x] = find(mid[x]);

    return mid[x];
}

bool join(int a, int b)
{
    int x = find(a);
    int y = find(b);
    if(x != y)
    {
        mid[x] = y;
        return true;
    }
    return false;
}
bool cmp(pair<P,int> a, pair<P,int> b)
{
    return a.first.second < b.first.second;
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int x,y;
        cin >> x >> y;
        city.push_back(make_pair(make_pair(x,y),i));
    }
    sort(city.begin(),city.end());
    int end = city.size();
    for(int i = 0; i < end-1; i++)
    {
        int dist = abs(city[i].first.first - city[i+1].first.first);

        dist_pair.push_back(make_pair(dist,make_pair(city[i].second,city[i+1].second)));
    }
    sort(city.begin(),city.end(),cmp);
    
    for(int i = 0; i < end-1; i++)
    {
        int dist = abs(city[i].first.second - city[i+1].first.second);

        dist_pair.push_back(make_pair(dist,make_pair(city[i].second,city[i+1].second)));
    }
    sort(dist_pair.begin(), dist_pair.end());
    init(n);
    int ans = 0;
    end = dist_pair.size();
    for(int i = 0; i < end-1; i++)
    {
        int a = dist_pair[i].second.first;
        int b = dist_pair[i].second.second;
        if(join(a, b)) {
            ans += dist_pair[i].first;
        }
        
    }
    cout << ans << endl;
}

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXHW = 100;

int grid[MAXHW + 2][MAXHW + 2];

int main() {
	int H, W, N;
	cin >> H >> W >> N;
	for(int i = 1, x = 0, y = 0; i <= N; i++) {
		int a;
		cin >> a;
		while(a) {
			if(x % 2 == 0) {
				while(a) {
					if(y == W) {
						x++;
						break;
					}
					grid[x][y++] = i;
					a--;
				}
			} else {
				while(a) {
					if(y == 0) {
						x++;
						break;
					}
					grid[x][--y] = i;
					a--;
				}
			}
		}
	}
	for(int x = 0; x < H; x++) {
		cout << grid[x][0];
		for(int y = 1; y < W; y++)
			cout << ' ' << grid[x][y];
		cout << '\n';
	}
}


Measured memory_bytes: 384
class RollingHash:

    def __init__(self, string, root, mod):
        self.root = root
        self.mod = mod
        self.hs = [0] * (len(string) + 1)
        self.pw = [1] * (len(string) + 1)
        for i in range(len(string)):
            self.hs[i + 1] = (self.hs[i] * self.root + ord(string[i])) % self.mod
            self.pw[i + 1] = self.pw[i] * self.root % self.mod

    def get_hash(self, l, r):
        "get the hash of s[l:r] (0 <= l <= r <= len(s))"
        return (self.hs[r] - self.hs[l] * self.pw[r - l]) % self.mod

    def __getitem__(self, index):
        if isinstance(index, slice):
            return self.get_hash(index.start, index.stop)
        else:
            return 0


RHMOD = 1 << 61 - 1
POSITIVIZER = RHMOD << 20
class RollingHashMOD61:
    """
    MOD == 2 ** 61 - 1
    参考: https://qiita.com/keymoon/items/11fac5627672a6d6a9f6
    """


    def __init__(self, string, root):
        self.root = root
        self.hs = [0] * (len(string) + 1)
        self.pw = [1] * (len(string) + 1)
        for i in range(len(string)):
            tmp = self.hs[i] * self.root + ord(string[i])
            self.hs[i + 1] = tmp >> 61 + (tmp & RHMOD)
            tmp = self.pw[i] * self.root
            self.pw[i + 1] = tmp >> 61 + (tmp & RHMOD)

    def get_hash(self, l, r):
        "get the hash of s[l:r] (0 <= l <= r <= len(s))"
        ret = (self.hs[r] - self.hs[l] * self.pw[r - l] + POSITIVIZER)
        ret = ret >> 61 + (ret & RHMOD)
        return ret

    def __getitem__(self, index):
        if isinstance(index, slice):
            return self.get_hash(index.start, index.stop)
        else:
            return 0
        
if __name__ == "__main__":
    N = int(input())
    S = input()

    MOD = 2 ** 61 - 1
    root = 10000

    rh = RollingHash(S, root, MOD)

    ok = 0
    ng = N
    while ng - ok > 1:
        mid = (ok + ng) // 2
        hashes = dict()
        flg = False
        for i in range(N - mid + 1):
            hashofsub = rh[i:i+mid]
            if hashofsub in hashes:
                if i >= hashes[hashofsub] + mid:
                    flg = True
                    break
            else:
                hashes[hashofsub] = i
        
        if flg:
            ok = mid
        else:
            ng = mid

    print(ok)


Measured memory_bytes: 71200
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        h: usize, w: usize,
        sy: usize, sx: usize,
        gy: usize, gx: usize,
        graph: [Chars; h]
    }

    let mut dist = vec![vec![-1; w]; h];
    let directions = vec![(0, 1), (1, 0), (-1, 0), (0, -1)];
    let mut pq = BinaryHeap::new();
    pq.push((0, (sx-1, sy-1)));

    while let Some((dep, (x, y))) = pq.pop() {
        let dep = -dep;
        if dist[y][x] >= 0 { continue; }

        dist[y][x] = dep;

        for &(dx, dy) in directions.iter() {
            let (cx, cy) = (x as isize + dx, y as isize + dy);
            if cx < 0 || cy < 0 || cx >= w as isize || cy >= h as isize { continue; }

            let (cxu, cyu) = (cx as usize, cy as usize);
            if dist[cyu][cxu] >= 0 { continue; }
            if graph[cyu][cxu] == '#' { continue; }
            
            pq.push((-dep , (cxu, cyu)));
        }

        let left_bound = if x < 2 { 0 } else { x - 2 };
        let right_bound = if x + 3 >= w { w } else { x + 3 };
        let up_bound = if y < 2 { 0 } else { y - 2 };
        let down_bound = if y + 3 >= h { h } else { y + 3 };

        for wx in left_bound..right_bound {
            for wy in up_bound..down_bound {
                if graph[wy][wx] == '#' { continue; }
                if dist[wy][wx] >= 0 { continue; }
                pq.push((-(dep+1), (wx, wy)))
            }
        }
    }
    
    println!("{}", dist[gy-1][gx-1]);
}


fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 12608
#include <iostream>
#include <iomanip>
#include<cstdlib>
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <string>
void call(int n);
using namespace std;
int main(){
	int n,m,l;
	cin>>n>>m>>l;
	
	int ar1[n][m];
	int ar2[m][l];
	long ans[n][l];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>ar1[i][j];
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<l;j++){
			cin>>ar2[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
			ans[i][j]=0;
		}
	}
	for(int ii=0;ii<n;ii++){
		for(int jj=0;jj<l;jj++){
			for(int k=0;k<m;k++){
				ans[ii][jj]=ans[ii][jj]+ar1[ii][k]*ar2[k][jj];
				
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
			if(j!=l-1){
				cout<<ans[i][j]<<' ';
			}else{cout<<ans[i][j];}
		}
		cout<<endl;
	}
	
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
        int n;
        cin>>n;
        int a,mxa=0;
        map<int,int>mp;
        for(int i=0;i<n;i++){
             cin>>a;mxa=max(a,mxa);
             mp[a]++;
        }
        int ans=0;
        for(auto&& i:mp){
             if(i.second==0)continue;
               if(i.second==1)ans++;
               for(int j=i.first;j<=mxa;j+=i.first){
                    mp[j]=0;
               }
        }
        cout<<ans<<endl;

     }


 


 






    





      

        


Measured memory_bytes: 66072
// https://abc043.contest.atcoder.jp/tasks/abc043_b
#include <iostream>
#include <vector>

using namespace std;

typedef vector<char> vc;

int main() {
	string s;
	cin >> s;
	vc v;
	for (auto c : s) {
		if (c == 'B') {
			if (!v.empty()) v.pop_back();
		} else v.push_back(c);
	}
	for (auto c : v) cout << c;
	cout << endl;
}


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

int main() {
  string S;
  cin >> S;

  rep(i, S.size() - 1) {
    if (S[i] == 'A' && S[i + 1] == 'C') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main() {
  int a, b, c, n = 0, m = 0;
  char d;
  while (cin >> a >> d >> b >> d >> c) {
    if (a * a + b * b == c * c) n++;
    if (a == b) m++;
  }
  cout << n << endl << m << endl;
}

Measured memory_bytes: 1160
from string import ascii_lowercase as al
cost = dict(zip(al, [0] + list(range(25, 0, -1))))

s = input()
K = int(input())
ans = ''
for si in s:
    if K - cost[si] >= 0:
        K -= cost[si]
        ans += 'a'
    else:
        ans += si
print(ans[:-1] + (al * 2)[al.index(ans[-1]) + K % 26])

Measured memory_bytes: 4344
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<sstream>
#include<queue>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#define INF 2147483647
#define lli long long int

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

class Team{

	public:
		int id = 0;
		int solve = 0;
		int time = 0;
		int rank = 0;	
		vector<int> check; 
		void set(int P,int id){
			this->id = id;
			for (int i = 0; i < P; i++){
				check.push_back(0);
			}
		}
};


bool compare(Team maxT, Team G){
	if (maxT.solve < G.solve){
		return true;
	}else if (maxT.solve > G.solve){
		return false;
	}else{
		if (maxT.time > G.time){
			return true;	
		}else if(maxT.time < G.time){
			return false;
		}else{
			if (maxT.id < G.id){
				return true;
			}else{
				return false;
			}
		}
	}
}

void result_sort(vector<Team> &Group){
	int maxj = 0;
	Team maxT;
	for (int i = 0; i < Group.size(); i++){
		maxj = i;
		maxT.id = INF;
		maxT.time = INF;
		maxT.solve = 0;
		for (int j = i; j < Group.size(); j++){
			if(compare(maxT,Group[j])){
				maxT = Group[j];
				maxj = j;
			}
		}
		Team tmp = Group[i];
		Group[i] = Group[maxj];
		Group[maxj] = tmp;
	}
	
}

void result_print(vector<Team> Group){
	cout << Group[0].id;
	int old_solve = Group[0].solve;
	int old_time = Group[0].time;
	for (int i = 1; i < Group.size(); i++){
		if (old_solve == Group[i].solve and old_time == Group[i].time){
			cout << "=" <<  Group[i].id ;	
		}else{
			cout << "," << Group[i].id; 
		}
		old_solve = Group[i].solve;
		old_time = Group[i].time;
	}
	cout << endl;
}

int main() {

	while(1){
		int M,T,P,R; cin >> M >> T >> P >> R;
		if (M + T + P + R ==0) break;
		
		vector<Team> Group(T);

		for (int i = 0; i < T; i++){
			Group[i].set(P,i+1);	
		}
		for (int i = 0 ; i < R; i++){
			int m,t,p,r;
			cin >> m >> t >> p >> r;
			if (r == 0){//correct
				Group[t-1].time += m + Group[t-1].check[p-1] * (20);
				Group[t-1].check[p-1] = 0;
				Group[t-1].solve++;
			}else{
				Group[t-1].check[p-1]++;
			}
		}
		result_sort(Group);
		result_print(Group);
	}
	return 0;
}

Measured memory_bytes: 3108
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %.10lf\n",d,r,f);
	return 0;
}

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

#ifdef SG
	#include <debug.h>
#else
	template<typename T> struct outputer;
	struct outputable {};
	#define PRINT(...)
	#define OUTPUT(...)
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
	#define fbegin(...)
	#define fend
	#define pbegin(...)
	#define pend
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb emplace_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef int64_t ll;
typedef uint64_t ull;
typedef uint32_t ui;
typedef uint16_t us;
typedef uint8_t uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 50;

struct Input {
	int n, p;
	int a[N];
	
	bool read () {
		if (!(cin >> n >> p)) {
			return 0;
		}
		forn (i, n) {
			scanf("%d", &a[i]);
		}
		return 1;
	}

	void init (const Input &input) {
		*this = input;
	}
};

struct Data: Input {
	ll ans;
	
	void write () {
		cout << ans << endl;
	}
};


namespace Main {
	
	struct Solution: Data {
		
		void solve () {
			bool has1 = 0;
			forn (i, n) {
				has1 |= (a[i] % 2 == 1);
			}
			
			if (has1) {
				ans = 1ll << (n - 1);
			} else {
				if (p) {
					ans = 0;
				} else {
					ans = 1ll << n;
				}
			}
		}
		
		void clear () {
			*this = Solution();
		}
	};
}


Main::Solution sol;

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);

	#ifdef SG
		freopen((problemname + ".in").c_str(), "r", stdin);
//		freopen((problemname + ".out").c_str(), "w", stdout);
		while (sol.read()) {
			sol.solve();
			sol.write();
			sol.clear();
		}
	#else
		sol.read();
		sol.solve();
		sol.write();
	#endif
	
	/*
	int t;
	cin >> t;
	forn (i, t) {
		sol.read();
		sol.solve();
		sol.write();
		sol.clear();
	}
	*/
	
	return 0;
}


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

int main()
{

    int n;
    cin>>n;
    if(n==1)
    cout<<"Hello World\n";
    else
    {
        int a,b;
        cin>>a>>b;
        cout<<a+b<<"\n";
    
    }







return 0;
}

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

#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;


void solve() 
{ 

ll n;
cin>>n;
ll x;
ll y;
for(ll i=1;i<=sqrt(n);i++){
	if(n%i==0){
	x=i;	
	y=n/i;
	}
}
cout<<x+y-2;
return ;


}
 

int main(){

		solve();
		cout<<endl;
					
}
		

	

		

 



Measured memory_bytes: 3572
//Author: AnandRaj uux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 998244353,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
    		}
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{
	int n;
	cin>>n;
	set<string> S;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		S.insert(s);
	}
	cout<<S.size()<<endl;
}		

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n, m;
  std::cin >> n >> m;
  if (n == 1 && m == 1)
    print(1);
  else if (n == 1 || m == 1)
    print(max(n, m) - 2);
  else
    print(n * m - (2 * n + 2 * m - 4));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll L, R;
    ll min = 1e+9;
    cin >> L >> R;
    for(ll i = L; i <= R-1; i++){
        for(ll j = i + 1; j <= R; j++){
            ll mod = (i*j) % 2019;
            if(mod == 0){
                cout << mod << endl;
                return 0;
            }
            if(min > mod) min = mod;
        }
    }
    cout << min << endl;
    return 0;
} 


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

signed main() {
#ifdef LOCAL
  assert(freopen("c.in", "r", stdin));
#endif
  int n, m;
  cin >> n >> m;
  ll t = n * 100 + m * 1800;
  cout << t * (1 << m) << '\n';
}


Measured memory_bytes: 256
from sys import stdin

input = stdin.readline

n = int(input())
a = input().rstrip()
cnt = 0

for x in range(n - 2):
    for z in range(x + 2, n, 2):
        y = (x + z) // 2
        if a[x] == a[y] or a[y] == a[z] or a[z] == a[x]:
            continue

        cnt += 1

print(a.count('R') * a.count('G') * a.count('B') - cnt)

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define eb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define output(x) cout<<x<<endl;
#define fre(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define frd(i, a, b) for (int i = (int)(a); i >= b; --i)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int,int> > vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
const ll mod=1e9+7;
const int maxn = 60;

ll dp[maxn][maxn][80],a[60][60],flag[maxn][maxn];

int main(){
	cin.tie(0);ios_base::sync_with_stdio(0);	
	int n;
	ll k;
	cin>>n>>k;
	fre(i,1,n){
		fre(j,1,n){
			cin>>a[i][j];
			dp[i][j][0]=a[i][j];
		}
	}
	fre(i,1,70){
		fre(aa,1,n){
			fre(b,1,n){
				fre(c,1,n){
					ll temp = (dp[aa][b][i-1] * dp[b][c][i-1])%mod;
					dp[aa][c][i] = (dp[aa][c][i] + temp)%mod;
				}
			}
		}
	}
	ll ans=0;
	vi v;
	for (int i = 0; i < 61; ++i)
	{
		if((k&(1ll<<i))) v.pb(i);
	}
	fre(i,1,v.size()-1){
		fre(aa,1,n){
			fre(b,1,n){
				fre(c,1,n){
					ll temp = (dp[aa][b][v[i-1]] * dp[b][c][v[i]])%mod;
					flag[aa][c] = (flag[aa][c] + temp)%mod;
					// dp[aa][c][i] = (dp[aa][c][i] + temp)%mod;
				}
			}
		}
		fre(j,1,n){
			fre(kk,1,n){
				dp[j][kk][v[i]] = flag[j][kk];
				flag[j][kk]=0;
			}
		}
	}
	fre(i,1,n){
		fre(j,1,n){
			ans=(ans+dp[i][j][v.back()])%mod;
		}
	}
	output(ans);
	return 0;
}

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

S = set()
for i in range(1,N):
    for j in range(i+1, N+1):
        S.add((i,j))

d = set()
if N % 2 == 0:
    for i in range(1,N//2+1):
        d.add((i, N-i+1))
else:
    for i in range(1,N//2+1):
        d.add((i, N-i))

r = S.difference(d)

print(len(r))
for i in r:
    print(i[0], i[1])



Measured memory_bytes: 4284
#include<stdio.h>
#define min(a,b) ((a)>(b)?(b):(a))

int main(){
  long long a,b,c;
  scanf("%lld%lld%lld",&a,&b,&c);
  printf("%lld",min((a%2)*b*c,min(a*(b%2)*c,a*b*(c%2))));
}

Measured memory_bytes: 128
N,M = gets.split.map(&:to_i) # switches, lights
L = Array.new(M + 1)
(1 .. M).map{|i| k,*c = gets.split.map(&:to_i); L[i] = [k, c] }

P = Array.new(N + 1)
gets.split.map(&:to_i).each.with_index(1){|parity,j| P[j] = parity }

ans = (1 << N).times.count do |sw|
  (1 .. M).all? do |m|
    k, c = L[m]
    c.count{|i| sw[i - 1] == 1 } % 2 == P[m]
  end
end
puts ans

Measured memory_bytes: 1788
import std.stdio,std.string,std.conv,std.algorithm;
import std.algorithm:rev=reverse;

void main(){
    auto input=readln.chomp.split.to!(ulong[]);
    auto n=input[0];
    auto a=input[1];
    auto b=input[2];
    auto ans=n/(a+b)*a;
    ans+=min(a,n%(a+b));
    ans.writeln;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
const int HMAX = 1501;
const int WMAX = 1501;
int h[HMAX], w[WMAX];

int hacc[HMAX], wacc[WMAX];

int hbetween(int m, int n) {
  return hacc[n] - hacc[m];
}

int wbetween(int m, int n) {
  return wacc[n] - wacc[m];
}

void init(int n, int m) {
  hacc[0] = wacc[0] = 0;
  REP(i, n) {
    hacc[i+1] = hacc[i] + h[i];
  }
  REP(i, m) {
    wacc[i+1] = wacc[i] + w[i];
  }
/*  REP(i, n+1) {
    cout << hacc[i] << " ";
  }
  cout << endl;
  REP(i, m+1) {
    cout << wacc[i] << " ";
  }
  cout << endl;
*/
}

bool has_key(map<int, int> m, int key) {
  return (m.find(key) != m.end());
}

int value_of(map<int, int> m, int key) {
  return ((has_key(m, key)) ? m[key] : 0);
}

int solve(int n, int m) {
  /*map<int, int> hdiffs, wdiffs;
  for (int i = 0; i < n + 1; i++) {
    for (int j = i + 1; j < n + 1; j++) {
      int hbetw = hbetween(i, j);
      if (has_key(hdiffs, hbetw)) {
        hdiffs[hbetw] = hdiffs[hbetw] + 1;
      } else {
        hdiffs[hbetw] = 1;
      }
    }
  }
  
  for (int i = 0; i < m + 1; i++) {
    for (int j = i + 1; j < m + 1; j++) {
      int wbetw = wbetween(i, j);
      if (has_key(wdiffs, wbetw)) {
        wdiffs[wbetw] = wdiffs[wbetw] + 1;
      } else {
        wdiffs[wbetw] = 1;
      }
    }
  }*/
  vector<int> hdiffs, wdiffs;
  for (int i = 0; i < n + 1; i++) {
    for (int j = i + 1; j < n + 1; j++) {
      hdiffs.push_back(hbetween(i, j));
    }
  }
  for (int i = 0; i < m + 1; i++) {
    for (int j = i + 1; j < m + 1; j++) {
      wdiffs.push_back(wbetween(i, j));
    }
  }
  sort(hdiffs.begin(), hdiffs.end());
  sort(wdiffs.begin(), wdiffs.end());

  int ans = 0;
/*
  for (pair<int, int> elm : hdiffs) {
    ans += value_of(wdiffs, elm.first) * elm.second;
  }*/
  vector<int>::iterator hit = hdiffs.begin();
  while (hit != hdiffs.end()) {
    int hval = *hit;
    auto heqr = equal_range(hdiffs.begin(), hdiffs.end(), hval);
    auto weqr = equal_range(wdiffs.begin(), wdiffs.end(), hval);
    ans += (heqr.second - heqr.first) * (weqr.second - weqr.first);
    hit = heqr.second;
  }

  return ans;
}


int main() {
  int n, m;
  while (cin >> n >> m and n != 0) {
    REP(i, n) {
      cin >> h[i];
    }
    REP(i, m) {
      cin >> w[i];
    }
    init(n, m);
    cout << solve(n, m) << endl;
  }
}

Measured memory_bytes: 20956
#!/usr/bin/env python

from itertools import combinations
import operator as op

nums = range(0, 10)
while True:
    n, s = map(int, raw_input().split())
    if (n, s) == (0, 0): break
    count = 0
    for c in combinations(nums, n):
        if sum(c) == s:
            count += 1
    print count

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

ll sum(vector<ll> dist) {
    ll ans = 0;
    for(auto x : dist) {
        ans += x;
    }
    return ans;
}

int main() {
    ll N; cin >> N;
    vector<ll> A(N+1);
    vector<ll> dist(N+1);
    A.at(0) = 0;
    for(ll i = 1; i < N+1; i++) {
        cin >> A.at(i);
    }

    for(ll i = 0; i < N+1; i++) {
        if(i != N)
            dist.at(i) = abs(A.at(i)-A.at(i+1));
        else
            dist.at(i) = abs(A.at(i)-A.at(0));
    }

    ll s = sum(dist);

    for(ll i = 1; i < N+1; i++)
        if(i != N)
            cout << s - dist.at(i-1) - dist.at(i) + abs(A.at(i-1) - A.at(i+1)) << endl;
        else
            cout << s - dist.at(i-1) - dist.at(i) + abs(A.at(i-1) - A.at(0)) << endl;
        
}

Measured memory_bytes: 2800
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    k,n = map(int,input().split())
    a = list(map(int,input().split()))
    
    for i in range(n-1):
      a[i] = a[i+1]-a[i]
    a[n-1] = k-sum(a)+a[n-1]
    ans = k-max(a)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Measured memory_bytes: 77132
#include <atcoder/all>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;
using namespace atcoder;

struct UnionFind {
    vector< int > data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};

int main(void) {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    while(M--) {
        int A, B;
        cin >> A >> B;
        --A; --B;
        if(uf.unite(A, B)) N--;
    }

    cout << N-1 << endl;
    return 0;
}


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

using namespace std;

int main() {
    int n;
    double plus;
    double kake;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a.at(i);

    if (a.size() == 1) {
        cout << a.at(0);
        return 0;
    }

    double tmp = a.at(0);
    for (int i = 1; i < n; ++i) {
        plus = tmp + a.at(i);
        kake = tmp * a.at(i);
        tmp = kake / plus;
    }

    cout << tmp;
}


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

using namespace std;

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

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

ll funkcija(ll h)
{
    if(h == 1)
    {
        return 1LL;
    }

    else
    {
        return 2 * funkcija(h / 2) + 1;
    }
}

int main()
{
    ll h;

    cin >> h;

    cout << funkcija(h) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

class UnionFind {
 public:
  vector<ll> par;
  vector<ll> siz;

  // Constructor
  UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
    for(ll i = 0; i < sz_; ++i) par[i] = i;
  }
  void init(ll sz_) {
    par.resize(sz_);
    siz.assign(sz_, 1LL);
    for(ll i = 0; i < sz_; ++i) par[i] = i;
  }

  // Member Function
  // Find
  ll root(ll x) {
    while(par[x] != x) {
      x = par[x] = par[par[x]];
    }
    return x;
  }

  // Union(Unite, Merge)
  bool merge(ll x, ll y) {
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(siz[x] < siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }

  bool issame(ll x, ll y) {  // 連結判定
    return root(x) == root(y);
  }

  ll size(ll x) {  // 素集合のサイズ
    return siz[root(x)];
  }
};
int main() {
  int N, M;
  cin >> N >> M;
  auto uf = UnionFind(N);
  REP(i, M) {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    X--;
    Y--;
    uf.merge(X, Y);
  }

  auto roots = set<int>();
  REP(i, N) { roots.insert(uf.root(i)); }

  cout << roots.size() << endl;
}


Measured memory_bytes: 6528
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).OrderBy(x => x).ToArray();
        var B = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).OrderBy(x => x).ToArray();
        var C = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).OrderBy(x => x).ToArray();
        var ans = 0L;
        for (int i = 0; i < N; ++i)
        {
            var a = LowerBound(B[i],A);
            var c = UpperBound(B[i],C);
            ans += a * (N-c);
        }
        Console.WriteLine(ans);
    }
    //lowがvalue+1になるがNから引いたときにちょうど良くなる
    static long UpperBound(long value,long[] array)
    {
        var low = 0;
        var high = array.Length;
        while (low < high)
        {
            var middle = (high + low) / 2;
            if (value < array[middle]) high = middle;
            else low = middle+1;
        }
        return low;
    }
    //より小さい
    static long LowerBound(long value, long[] array)
    {
        var low = 0;
        var high = array.Length;
        while (low < high)
        {
            var middle = (high + low) / 2;
            if (value <= array[middle]) high = middle;
            else low = middle+1;
        }
        return low;
    }
}

Measured memory_bytes: 44924
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int MOD = (int)1e9 + 7;
const int N = 5010;

int n, len, dp[N][N];
string s;

int fpow(int x, int y)
{
	if (y == 0)
		return 1;
	if (y%2 == 1)
		return (x*fpow(x, y-1))%MOD;
	int res = fpow(x, y/2);
	return (res*res)%MOD;
}

signed main()
{
    init_ios();
    cin >> n >> s;
    len = s.size();
    dp[1][0] = 1;
    dp[1][1] = 2;
    for (int i = 2; i <= n; ++i)
    	for (int j = 0; j <= n; ++j) {
    		if (j == 0)
    			dp[i][j] = (dp[i-1][0]+dp[i-1][1])%MOD;
    		else
    			dp[i][j] = (2*dp[i-1][j-1]+dp[i-1][j+1])%MOD;
    	}
    cout<<(dp[n][len]*fpow(fpow(2, MOD-2), len))%MOD<<"\n";
}

Measured memory_bytes: 195968
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

const ll v = 3001;
ll dp[v][v];

ll length(string& s,string& t,ll i,ll j)
{
   // memset(dp,-1,sizeof(dp));
    //Base case
    if(i>=s.size() || j>=t.size())
    return 0;

    //Lookup
    if(dp[i][j] != -1)
    return dp[i][j];

    //Rec case
    if(s[i] == t[j])
    return dp[i][j] = 1 + length(s,t,i+1,j+1);

    else
    return dp[i][j] = max(length(s,t,i+1,j), length(s,t,i,j+1));
}

int main()
{
    string s,t;
    cin>>s>>t;
     memset(dp,-1,sizeof(dp));

    //cout<<length(s,t,0,0)<<endl;
  ll len = length(s,t,0,0);
  ll i=0,j=0;

   string ans = " ";
   while(len)
   {
       if(s[i] == t[j])
       {
           ans.pb(s[i]);
           i++;
           j++;
           len--;
       }
       else
       {
           if(dp[i][j+1] > dp[i+1][j])
           j++;
           else
           i++;
       }
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 70912
for r in range(input()):
	snake=raw_input()
	m=(len(snake)-4)/2
	if m>0 and snake == ">'" + "="*m + "#" + "="*m + "~":
		print "A"
	elif m>0 and snake == ">^" + "Q="*m + "~~":
		print "B"
	else:
		print "NA"

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  ll N, M; scanf("%lld %lld", &N, &M);
  ll ans = 0;
  if (2 * N <= M) {
    ans = N;
    M -= 2 * N;
    ans += M / 4;
  }
  else {
    ans = M / 2;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256