akhauriyash/Code-Regression huggingface dataset:
// Sea the world.

#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// SELF TEMPLATE CODE BGEIN

#define SZ(x) ((int)((x).size()))
#define OUT(x) printf(#x" %d\n", x)
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repf(i,a,b) for (int i = (a); i <= (b); ++i)
#define repd(i,a,b) for (int i = (a); i >= (b); --i)
#define repcase int t, Case = 1; for (scanf ("%d", &t); t; --t)

typedef long long int64;
typedef pair<int, int> pii;

int sgn(double x) { return (x > 1e-8) - (x < -1e-8); }
int count_bit(int x) { return x == 0? 0 : count_bit(x >> 1) + (x & 1); }

template<class T> inline void to_min(T &a, const T b) { if (b < a) a = b; }
template<class T> inline void to_max(T &a, const T b) { if (b > a) a = b; }

// SELF TEMPLATE CODE END

const int maxn = 100000 + 10;

int a[maxn], b[maxn];

void solve(int n) {
  long long ret = 0;
  int cmax = 0;
  rep (i, n) {
    // cin >> a[i];
    scanf("%d", &a[i]);
    // try reduce a[i] to cmax
    if (cmax == 0) {
      cmax = 1;
      ret += a[i] - 1;
      // printf("%d %d\n", cmax, a[i] - 1);
    } else {
      if (a[i] == cmax + 1) {
        ++cmax;
        // printf("%d %d\n", cmax, 0);
      } else {
        int num = max(0, (a[i] - 1) / (cmax + 1));
        ret += num;
        // printf("%d %d\n", cmax, num);
      }
    }
  }
  cout << ret << endl;
}

int main() {
  // ios::sync_with_stdio(false);

  int n, m;
  // string s;
  // while (cin >> n) {
  while (scanf("%d", &n) != EOF) {
    solve(n);
  }
  return 0;
}


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


int main(){
    int n, m, s=0;

    cin >> n;
    m = n;
	while(n != 0){
        s += n % 10;
        n /= 10;
    }
    if(m % s == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%s", $S);

$ans = 0;
$x = 0;
for ($i = 0; $i < strlen($S); $i++) {
    if ($S[$i] === 'I') {
        $x++;
        $ans = max($ans, $x);
    } else {
        $x--;
    }
}

print "$ans\n";

?>

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    int k;
    long long ans = 0;

    cin >> k;

    for(int i = 1; i <= k; i++)
        for(int j = 1; j <= k; j++)
            for(int p = 1; p <= k; p++)
                ans += __gcd(i, __gcd(p, j));

    cout << ans << "\n";

    return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int r, d, x;
    cin >> r >> d >> x;
    for(int i = 0; i < 10; ++i){
        x = r * x - d;
        cout << x << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace  std;

using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<int , int > pairs;
typedef complex<ll> G;
const int N=1e4+5;

const int INF = 1e9+5;


void done() {
    vector<int>frq(N, 0);
    int n;
    cin >> n;
    int a[n*4];
    for(int i=0;i < 4 * n;i++) {
        cin >> a[i];
        //++frq[a[i]];
    }
    ll sum = 0;
    int l = 0;
    int r = 4*n-1;
    sort(a, a+4*n);
    ll q = 0;
    int st = 0;
    while(l < r) {
        if(a[l]!=a[l+1] || a[r]!=a[r-1]) {
            cout << "NO\n";
            return;
        }

        sum = a[l]*a[r];
        if(st == 0) {
            q = sum;
            st = 1;
        }
        if(st==1 ) {
            if(sum!=q) {
                cout << "NO\n";
                return;
            }
        }
        l += 2;
        r -= 2;
    }
    cout << "YES\n";





}
void solve() {

    int n;
    cin >> n;
    cout << pow(n, 2) + pow(n, 3) + n;
}

void another() {
    int n, k;
    cin >> n >> k;
    vector<int>a(n);
    int cnt = 0;
    for(int i = 0 ;i < n;i++) {
        cin >> a[i];
        if(a[i]%2==1) {
            cnt++;
        }
    }

    if(cnt < k) {
        cout << "NO\n";
        return;
    }
    if(k%2!=cnt%2) {
        cout << "NO\n";
        return;
    }
    set<int>ans;
    cout << "YES\n";
    for(int i=0; i< n;i++) {
        if(k > 1) {
            if((a[i] & 1)) {
                ans.insert(i+1);
                k--;
            }
        }
    }
    ans.insert(n);
    for(auto c : ans) {
        cout << c << " ";
    }
    cout << '\n';



}
void test_case() {
    int t;
    cin >> t;
    while(t--)solve();
}
int main() {

    fast;
    solve();
}


Measured memory_bytes: 4272
use proconio::{input, fastout};
// use std::collections::BinaryHeap;
use std::cmp::max;

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}

#[fastout]
fn main() {
  input!{
    k: i32,
    t: usize,
    aa: [i32; t]
  };
  let m = aa.iter().max().unwrap();
  let ans = max(m - 1 - (k-m), 0);
  echo!(ans);

  // let mut que = BinaryHeap::new();
  // 
  // for (i, a) in aa.iter().enumerate() {
  //   que.push((*a, i));
  // }
  // 
  // let mut pre = que.peek().unwrap().1 + 1;
  // let mut ans = 0;
  // while que.len() > 0 {
  //   let top = que.pop().unwrap();
  //   if pre != top.1 {
  //     pre = top.1;
  //     let a = top.0;
  //     if a > 1 {
  //       que.push((a - 1, pre));
  //     }
  //   } else if que.len() > 0 {
  //     let sec = que.pop().unwrap();
  //     pre = sec.1;
  //     let a = sec.0;
  //     if a > 1 {
  //       que.push((a - 1, pre));
  //     }
  //     que.push(top);
  //   } else {
  //     ans += 1;
  //     let a = top.0;
  //     if a > 1 {
  //       que.push((a - 1, pre));
  //     }
  //   }
  // }
  // echo!(ans);
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n;
  int a[n][3];
  for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  vector<vector<int>>dp(n,vector<int>(3,0));
  dp[0][1]=a[0][1];
  dp[0][2]=a[0][2];
  dp[0][0]=a[0][0];

  for(int i=1;i<n;i++)
    {
    	dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];	
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
	}
	
  	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 9812
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
#include <assert.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp

//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int INF=0x3f3f3f3f;
//const ll INFF=0x3f3f3f3f3f3f3f3fll;
const int MAX=3e5+5;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
//const ll MOD=1e15+37;
//const long double pi=acos(-1.0);
//const double eps=0.00000001;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
//    freopen("1009.in","r",stdin);
    freopen("out.txt","w",stdout);
}

int n,k,cnt;
vector<int>an;
int main()
{
    scanf("%d%d",&k,&n);
    if(k%2==0)
    {
        an=vector<int>(n,k);
        an[0]=k/2;
    }
    else
    {
        an=vector<int>(n,(k+1)/2);
        cnt=n/2;
        while(cnt--)
        {
            if(an.back()==1)an.pop_back();
            else
            {
                an.back()--;
                while(an.size()<n)
                    an.pb(k);
            }
        }
    }
    for(int i:an)
        printf("%d ",i);

}
/*
3 2
10 5
20 10
10 3
1 2 22
2 3 200

*/


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

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

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

//////////////////////////////////////////////

const int N = 5e5;

int tree[26][N+1];
int n;
int cur[N + 5];

int LSOne(int a) {
	return (a & -a);
}

void update(int bit, int a, int b, int v) {
	REPP(i,a,n,LSOne(i)) {
		tree[bit][i] += v;
//		printf("%d add %d -> %d\n",bit,i,tree[bit][i]); 
	}
}

int query(int l, int r) {
	int ret = 0;
	FOR(i,26) {
		int v = 0;
		REVV(j,r,1,LSOne(j)) v += tree[i][j];
		REVV(j,l-1,1,LSOne(j)) v -= tree[i][j];
//		printf("     %d -> %d\n",i,v);
		if(v > 0) ret++;
	}
	return ret;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	string str; cin >> str;
	FOR(i,n) {
		int c = str[i] - 'a';
		update(c,i+1,i+1,1);
		cur[i+1] = c;
	}
	int q; cin >> q;
	while(q--) {
		int ins; cin >> ins;
		if(ins == 1) {
			string x;
			int l; cin >> l >> x;
			int c = x[0] - 'a';
			update(cur[l],l,l,-1);
//			printf("remove %d\n",cur[l]);
			update(c,l,l,1);
//			printf("add %d\n",c);
			cur[l] = c;
		}
		else {
			int l,r; cin >> l >> r;
			cout << query(l,r) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 53660
#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

#define SOUR (N+N)
#define SINK (N+N+1)
#define INF (1<<29)

class Node
{
public:
	vector<int> to;
};

int flow[205][205], capa[205][205],N,M,L;

void Connect(vector<Node>& node, int u, int v, int w)
{
	flow[v][u]+=w;
	capa[v][u]+=w;
	capa[u][v]+=w;
	
	node[u].to.push_back(v);
	node[v].to.push_back(u);
}
int dfs(int p, int T, int mf, vector<Node>& graph, vector<int>& level, vector<bool>& finished)
{
	if(p==T) return mf;
	if(finished[p]) return 0;
	
	finished[p]=true;
	
	for(int i=0; i<graph[p].to.size(); i++)
	{
		int next=graph[p].to[i], fw=capa[p][next]-flow[p][next];
		if(level[p] >= level[next]) continue;
		if(fw <=0 ) continue;
	
		int f=dfs(next, T, min(mf, fw), graph, level, finished);
		if(f>0)
		{
			finished[p]=false;
			flow[p][next]+=f;
			flow[next][p]-=f;
			return f;
		}
	}
	
	return 0;
}

int dinic(int S, int T, vector<Node>& graph)
{
	bool end=false;
	int total=0;
	while(!end)
	{
		end=true;
		vector<int> level(graph.size(), -1);
		level[S]=0;
		
		queue<int> q;
		q.push(S);
		while(!q.empty())
		{
			int n=q.front(); q.pop();
			for(int i=0; i<graph[n].to.size(); i++)
			{
				int next=graph[n].to[i];
				if(level[next]!=-1) continue;
				if(capa[n][next]-flow[n][next] <= 0) continue;
				level[next]=level[n]+1;
				q.push(next);
			}
		}
		
		if(level[T]==-1) break;
		
		vector<bool> finished(graph.size());
		while(1)
		{
			int fw=dfs(S, T, INF, graph, level, finished);
			if(fw<=0) break;
			
			total+=fw;
			end=false;
		}
	}
	
	return total;
}

int main()
{
	while(cin >> N >> M >> L)
	{
		int d[100][100];
		for(int i=0; i<N; i++)
		for(int j=0; j<N; j++)
		{
			d[i][j]=INF;
			d[i][i]=d[j][j]=0;
		}
		
		for(int i=0; i<M; i++)
		{
			int u,v,w;
			cin >> u >> v >> w;
			u--; v--;
			d[u][v]=w;
			d[v][u]=w;
		}
		
		for(int k=0; k<N; k++)
		for(int y=0; y<N; y++)
		for(int x=0; x<N; x++)
			d[x][y]=min(d[x][y], d[x][k]+d[k][y]);
		
		memset(flow,0,sizeof(flow));
		memset(capa,0,sizeof(capa));
		
		vector<Node> node(SINK+1);
		
		int in, out;
		for(int i=0; i<N; i++)
		{
			cin >> in;
			Connect(node, SOUR, i, in);
		}
			
		for(int i=0; i<N; i++)
		{
			cin >> out;
			Connect(node, N+i, SINK, out);
		}
		
		for(int i=0; i<N; i++)
		for(int j=0; j<N; j++)
		{
			if(d[i][j] < L) Connect(node, i, N+j, INF);
		}
		
		cout << dinic(SOUR,SINK,node) << endl;
	}
}

Measured memory_bytes: 1384
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        Integer[] num = {a,b,c};
        Arrays.sort(num, Collections.reverseOrder());

        int sum = 0;

        sum = num[0]*10+(num[1]+num[2]);
        System.out.println(sum);
        
  
    }

}


Measured memory_bytes: 23252
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//https://drken1215.hatenablog.com/entry/2019/03/23/175300
fn main() {
    let N: u64 = read();
    let M: u64 = read();

    let once_time = 1900 * M + 100 * (N - M);
    let e = 2u64.pow(M as u32);
    println!("{}", once_time * e);
}


Measured memory_bytes: 2116
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
#define Length 80000
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

bool used[110];

bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
	return a.first * a.first + a.second * a.second > b.first*b.first + b.second * b.second;
}

void solve(int n) {
	vector<pair<int, int>>p(n), q(n);
	for (int i = 0;i < n;i++) {
		cin >> p[i].first >> p[i].second;
	}
	for (int i = 0;i < n;i++) {
		cin >> q[i].first >> q[i].second;
	}
	int dist = Length, flag = 0;
	int ans = 0;
	sort(p.begin(), p.end());
	for (int i = 0;i < n;i++) {
		dist = Length;
		flag = 0;
		for (int j = 0;j < n;j++) {
			if (!used[j]) {
				int x = q[j].first - p[i].first;
				int y = q[j].second - p[i].second;
				if ((x > 0) && (y > 0) && y < dist) {
					dist = y;
					flag = j;
				}
			}
		}
		if (dist < Length) {
			ans++;
			used[flag] = true;
		}
	}
	cout << ans << endl;
}

char board[110][110];
	
int main(void){
	int n, ans = 0;
	cin >> n;
	vector<int>l(2 * n);
	for (int i = 0;i < 2 * n;i++)cin >> l[i];
	sort(l.begin(), l.end());
	for (int i = 0;i < 2 * n - 1;i += 2) {
		ans += l[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
l=[int(x) for x in input().split()]
dp=[False]*(k+1)
for i in range(k+1):
	for j in range(n):
		if i>=l[j] and not dp[i-l[j]]:
			dp[i]=True
if dp[k]:
	print('First')
else:
	print('Second')

Measured memory_bytes: 41836
N = gets.to_i
a = gets.split.map(&:to_i)
Q = gets.to_i

hash = a.sort.group_by(&:itself).map { |key, value| [key, value.count]}.to_h

sum = 0
hash.each do |key, value|
    sum += key * value
end

Q.times do
    line = gets.split.map(&:to_i)
    if hash.has_key?(line[0]) then
        count = hash[line[0]]
        sum += - line[0] * count + line[1] * count
        hash.store(line[0], hash[line[0]].to_i - count)
        hash.store(line[1], hash[line[1]].to_i + count)
    end
    puts sum
end


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  VLL p(n);
  VLL q(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  VLL a(n);
  rep(i, n) a[i] = i + 1;
  ll cnt = 0;
  ll aa, bb;
  do {
    bool pflag = true;
    bool qflag = true;
    
    rep(i, n) {
      if (a[i] != p[i]) pflag = false;
      if (a[i] != q[i]) qflag = false;
      // cout << a[i] << " ";
    }
    // cout << endl;
    if (pflag) aa = cnt;
    if (qflag) bb = cnt;
    cnt++;
  } while (next_permutation(all(a)));
  cout << abs(aa - bb) << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int sum = 0, tmp = n;
  while (tmp > 0) {
    sum += tmp % 10;
    tmp /= 10;
  }

  if (n % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
int main(){
  std::string s;
  int a[100];
  int i=0;
  while (std::cin>>s){
    if (s=="+"){
      i--;
      a[i]+=a[i+1];
    }
    else if (s=="-"){
      i--;
      a[i]-=a[i+1];
    }
    else if (s=="*"){
      i--;
      a[i]*=a[i+1];
    }
    else {
      i++;
      a[i]=atoi(s.c_str());
    }
  }
  std::cout << a[i] << '\n';

}



Measured memory_bytes: 3168
import math
import collections
def f(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n = n//f
        else:f += 2
    if n != 1:
        a.append(n)
    return a

a,b = map(int,input().split())
a = set(collections.Counter(f(a)).keys())
b = set(collections.Counter(f(b)).keys())
print(len(a&b)+1)


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

int main()
{
  lint L, R;
  cin >> L >> R;

  lint m = 2019;
  for (lint i = L; i < R and 0 < m; ++i)
  {
    for (lint j = i + 1; j <= R and 0 < m; ++j)
    {
      m = min((i * j) % 2019, m);
    }
  }
  cout << m << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int x,y,i,j;
   
   scanf("%d%d",&x,&y);
  
   for(i=0;i<=100;i++){
     for(j=0;j<=100;j++){
       if(2*i+4*j == y && i+j==x){  
         printf("Yes");
         return 0;
       }
     }
   }
  
  if(i==101)
    printf("No");
  
   return 0;
  
}


Measured memory_bytes: 1724
/*  -*- coding: utf-8 -*-
 *
 * a.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_H = 8;
const int MAX_W = 8;

/* typedef */

/* global variables */

string as[MAX_H];
bool bs[MAX_H][MAX_W];

/* subroutines */

void impossible() {
  puts("Impossible");
  exit(0);
}

/* main */

int main() {
  int h, w;
  cin >> h >> w;
  for (int y = 0; y < h; y++) cin >> as[y];

  if (as[0][0] != '#') impossible();
  bs[0][0] = true;

  int x = 0, y = 0;
  while (x != w - 1 || y != h - 1) {
    if (x < w - 1 && as[y][x + 1] == '#')
      bs[y][++x] = true;
    else if (y < h - 1 && as[y + 1][x] == '#')
      bs[++y][x] = true;
    else
      impossible();
  }

  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++)
      if ((bs[y][x] && as[y][x] == '.') || (! bs[y][x] && as[y][x] == '#'))
	impossible();

  puts("Possible");
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                9000000000000000000
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= mod;} b >>= 1; x *= x; x %= mod;} return p % mod;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (const pair<db,ll>  p1, const pair<db,ll> p2){
        return (p1.first ==  p2.first) ? p1.ss < p2.ss : p1.first > p2.first;
    }
};

int main(){
    FIO;
    ll n; cin >> n;
    map<ll,ll> m;
    ll sum = 0;
    forn(i,0,n){
        ll a;cin >> a;
        m[a]++;
        sum += a;
    }
    ll q; cin >> q;
    while(q--){
        ll b,c; cin>> b >> c;
        ll countb = m[b];
        m[c] += m[b];
        m[b] = 0;
        sum += ((c-b)*countb);
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 9408
#include <bits/stdc++.h>
using namespace std;
int main(){
    int ans = 0;
    int cnt = 1;

    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) {
        cin >> a.at(i);
        if(a.at(i)==cnt){
            ans++;
            cnt++;
        }
    }

    if(!ans) ans = -1;
    else ans = N - ans;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  cin >> s;

  string t = "CODEFESTIVAL2016";
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) ans++;
  }

  // 解答
  cout << ans << endl;

  return 0;
}


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

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<=b) printf("%d",a);
	else printf("%d",a-1);
}

Measured memory_bytes: 256
def main():
    N, X = map(int, input().split())

    a, p = [1], [1]

    for i in range(N):
        a.append(a[i] * 2 + 3)
        p.append(p[i] * 2 + 1)

    def func(N, X):
        if N == 0:
            return 0 if X <= 0 else 1
        elif X <= 1 + a[N-1]:
            return func(N-1, X-1)
        else:
            return p[N-1] + 1 + func(N-1, X-2-a[N-1])

    print(func(N,X))

main()

Measured memory_bytes: 38256
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int x,a;
    scanf("%d%d",&x,&a);
    if(x<a)printf("0\n");
    else printf("10\n");
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    main.solve();
  }
  public void solve() {
    Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    String s = scan.next();
    char[] d = s.toCharArray();
    int ans = 0;
    for (int i = 0; i < d.length; i++) {
      ans += d[i] == '1' ? 1 : 0;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23764
n = gets.chomp.to_i
m = gets.chomp.split("")

w = m.select{|t| t == "W"}.count
e = m.select{|t| t == "E"}.count

cw = 0
ce = 0
min_or = w + e
m.each do |t|
  if t == "W"
    cw += 1
    w -= 1
    min_or = cw + e - 1 if min_or > cw + e
  else
    ce += 1
    e -= 1
    min_or = cw + e if min_or > cw + e
  end
end

puts min_or

Measured memory_bytes: 30860
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const LL MOD = 1000000007LL;
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b + c || b == a + c || c == a + b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

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

    ll n;
    cin >> n;

    string a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;

    ll ans = 0;

    rep(i,n)
    {
    	char aa = a[i];
    	char bb = b[i];
    	char cc = c[i];

    	ll x = 1;
    	if(aa==bb && aa==cc)
    		x = 3;
    	else if(aa==bb || aa==cc || bb==cc)
    		x = 2;

    	ans = ans + (3-x);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  string s,t; cin >> s >> t;
  reverse(s.begin(), s.end());
  if(s == t) cout << "YES" << "\n";
  else cout << "NO" << "\n";
  return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();

		int count = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				
				int z = S - x - y;
				if(z >= 0 && z <= K) count++;
			}
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector <ii> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z].first >> arr[z].second;
	}
	vector <ll> k(n);
	for (int z=0;z<n;z++){
		k[z] = z;
	}
	ld ans = 0;
	ll f = 0;
	do{
		ld t = 0;
		for (int z=0;z<k.size()-1;z++){
			t += sqrtl((arr[k[z]].first-arr[k[z+1]].first)*(arr[k[z]].first-arr[k[z+1]].first)+
				(arr[k[z]].second-arr[k[z+1]].second)*(arr[k[z]].second-arr[k[z+1]].second));
		}
		ans += t;
		f++;
	}
	while (next_permutation(k.begin(),k.end()));
	cout << setprecision(60) << ans/f << endl;
}

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

int W,H;
int dx[4] = {-1,1,0,0},dy[4] = {0,0,1,-1};
int visited[70][20] = {},field[70][20] = {};
vector<double> G(200,0),L(200,0),R(200,0);
vector<vector<pair<int,int>>> list(200);
char P[70][20];
double eps = 1e-9;

bool in(int x,int y){
    return 0<=x && x<H && 0<=y && y<W;
}

void dfs(int x,int y,int ti,char c){
    visited[x][y] = 1;
    field[x][y] = ti;
    list[ti].push_back({x,y});
    G[ti] += y+0.5;
    if(x==0 || (x!=0 && P[x-1][y]!='.' && P[x-1][y]!=c)) L[ti] = min((double) y,L[ti]);
    if(x==0 || (x!=0 && P[x-1][y]!='.' && P[x-1][y]!=c)) R[ti] = max((double) y+1,R[ti]);
    for(int i=0;i<4;i++){
        int nx = x+dx[i],ny = y+dy[i];
        if(in(nx,ny) && visited[nx][ny]==0 && P[nx][ny]==c) dfs(nx,ny,ti,c);
    }
}

void dfs2(int x,int y,int ti,set<int>& s){
    visited[x][y] = 1;
    s.insert(field[x][y]);
    for(int i=1;i<4;i++){
        int nx = x+dx[i],ny = y+dy[i];
        if(i==1 && in(nx,ny) && visited[nx][ny]==0 && field[nx][ny]!=0 && field[nx][ny]!=ti) dfs2(nx,ny,ti,s);
        if((i==2 || i==3) && in(nx,ny) && visited[nx][ny]==0 && field[nx][ny]!=0 && field[nx][ny]!=ti && field[nx][ny]==field[x][y]) dfs2(nx,ny,ti,s);;
    }
}

int main(){
    while(cin >> W >> H && H>0){
        for(int i=H-1;i>=0;i--) for(int j=0;j<W;j++) cin >> P[i][j];
        int cnt = 1;
        for(int i=1;i<200;i++){
            G[i] = 0;
            L[i] = 100;
            R[i] = -1;
            list[i].clear();
        }
        for(int i=0;i<H;i++) for(int j=0;j<W;j++) visited[i][j] = 0;
        for(int i=0;i<H;i++) for(int j=0;j<W;j++) field[i][j] = 0;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(P[i][j]!='.' && visited[i][j]==0){
                    dfs(i,j,cnt,P[i][j]);
                    G[cnt] /= 4;
                    cnt++;
                }
            }
        }
        bool stable = true;
        for(int t=1;t<cnt;t++){
            double g = 0,l = L[t],r = R[t];
            for(int i=0;i<H;i++) for(int j=0;j<W;j++) visited[i][j] = 0;
            set<int> s;
            s.insert(t);
            for(auto x:list[t]){
                if(in(x.first+1,x.second) && field[x.first+1][x.second]!=0 && field[x.first+1][x.second]!=t) dfs2(x.first+1,x.second,t,s);
            }
            for(auto x:s){
                g += G[x];
            }
            g /= (double) s.size();
 //           cerr << s.size() << " " << t << " l:" << l << " r:" << r << " g:" << g << endl;
            if(!(l+eps<g && g<r-eps)) stable = false;
        }
        cout << (stable? "STABLE":"UNSTABLE") << endl;
    }
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    ll n; cin >> n;
    ll ans = to_string(n).size();
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            ll x = to_string(n / i).size();
            ll y = to_string(i).size();
            ans = min(ans, max(x, y));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import itertools

N, K = map(int, input().split())
ans = []
for i in range(2, N + 1):
    ans.append([1, i])

"""
全ての組み合わせは N_C_2
1を中心にスターグラフを作る
2,3,...,Nの中での組み合わせは N-1_C_2、これらの距離は2
2,3,...,Nの中で、(N-1_C_2 - K) 個の辺を張れば、
距離2の組み合わせがK個残る

N-1_C_2 - K < 0 となる時、構築不可
"""

if (N - 1) * (N - 2) // 2 - K < 0:
    print(-1)
    exit()
else:
    comb = list(itertools.combinations(range(2, N + 1), 2))
    for i in range((N - 1) * (N - 2) // 2 - K):
        u = comb[i][0]
        v = comb[i][1]
        ans.append([u, v])
    print(len(ans))
    for i in ans:
        print(*i)


Measured memory_bytes: 74936
#include <iostream>
using namespace std;
int main(){
	int n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	int ac[n+1]={0};
	for(int i=0;i<s.size()-1;i++){
		if(s[i]=='A'&&s[i+1]=='C')ac[i+1]=1;
	}
	for(int i=1;i<=n;i++)ac[i]+=ac[i-1];
	int l,r;
	for(int i=0;i<q;i++){
		cin>>l>>r;
		cout<<ac[r-1]-ac[l-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
package main

import "fmt"

func larger(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func commonDivisor(a, b int) []int {
	x := larger(a, b)
	s := make([]int, 0, x)
	for i := 1; i <= x; i++ {
		if a%i == 0 && b%i == 0 {
			s = append(s, i)
		}
	}
	return s
}

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	s := commonDivisor(a, b)
	fmt.Println(s[len(s)-k])
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int a, b, h;

int solve() {
    return (a + b) * h / 2;
}       

void input() {
    cin >> a >> b >> h;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>

using namespace std;

int euclidean_algorithm(int a, int b){
    int r;
    int answer = 1e9;
    if (b == 0){
        return a;
    }
    if (a >= b){
        r = a%b;
        answer = euclidean_algorithm(b, r);
    }
    return answer;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int answer = 1e9;
    int hp = 1e9;
    for(int i=0; i<n-1; i++){
        hp = euclidean_algorithm(a[i+1], a[i]);
        if (answer > hp){
            answer = hp;
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
      
      if(n.charAt(1) == n.charAt(2) && (n.charAt(1) == n.charAt(0) || n.charAt(1) == n.charAt(3))){
        System.out.print("Yes");
      }else{
        System.out.print("No");
      }
      
      
    }
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		// Scanner scan = new Scanner(System.in);
		String[] ana = new String[2];
		ana = line.split("");
		
		if(ana[0].equals("9"))
			System.out.println("Yes");
		else if(ana[1].equals("9"))
			System.out.println("Yes");
		else
			System.out.println("No");

}
}

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

int main(){
    int a;
    for(int i=1;i<=10000;++i){
        cin >> a;
        if(a==0){
            break;
        }else{
            cout << "Case " << i << ": " << a << endl; 
        }
    }
    return 0;
}


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

int main()
{
    int x=0; string s; int max=0;int n;
    cin>>n>>s;
    for(int i=0; i<n;i++)
    {
        if(s.at(i)=='I')
            x++;
        if(s.at(i)=='D')
            x--;
        if(x>=max)
            max=x;

    }
    cout<<max<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <iomanip>

int main(int argc, char *argv[])
{
    int a,b;
    std::string op;

    while(1){
        std::cin >> a >> op >> b;
        if(op == "+"){
            std::cout << a+b << std::endl;
        }
        else if(op == "-"){
            std::cout << a-b << std::endl;
        }
        else if(op == "*"){
            std::cout << a*b << std::endl;
        }
        else if(op == "/"){
            std::cout << a/b << std::endl;
        }
        else break;
    }

    return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N=1e5+5;
const int mod=1e9+7;
int pow(int,int,int);
int prime[N],tag[N],phi[N],tot;

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n,k;cin>>n>>k;
    int ans=0;
    for(int i=1;i<=k;i++){
        ans=(ans+1LL*pow(k/i,n,mod)*phi[i])%mod;
    }   
    cout<<ans;
}
int pow(int a,int p,int m){
    int re=1;
    for(;p;p>>=1){
        if(p&1) re=1LL*re*a%m;
        a=1LL*a*a%m;
    }
    return re;
}
void init(){
    phi[1]=1;
    for(int i=2;i<N;i++){
        if(!tag[i]) prime[++tot]=i,phi[i]=i-1;
        for(int j=1;j<=tot&&i*prime[j]<N;j++){
            tag[i*prime[j]]=1;
            if(i%prime[j]==0){
                phi[i*prime[j]]=phi[i]*prime[j];
                break;
            }
            phi[i*prime[j]]=phi[i]*(prime[j]-1);
        }
    }
}


Measured memory_bytes: 4508
#include<iostream>
using namespace std;
int n;
char s[100];
int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> s[i];
  bool f=false;
  for(int i=0;i<n;i++){
    if(s[i]=='Y'){
      f=true;
      break;
    }
  }
  if(f) cout << "Four\n";
  else cout << "Three\n";
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
struct node{ node* l; node* r; node* p; int key; }; 
node L; 
node* nil=&L; 
node* t=nil; 
void insert(node* a){ 
node* y=nil; node* x=t; 
while(x!=nil){ 
y=x;
if(a->key<x->key)x=x->l; 
else x=x->r; 
} 
a->p=y; 
if(y==nil)t=a; 
else if(a->key<(y->key))y->l=a; 
else y->r=a; 
} void pri(node* b,int a){ 
if(b==nil)return; 
if(!a)cout<<" "<<b->key; pri(b->l,a); if(a)cout<<" "<<b->key; pri(b->r,a); } int main(){ int n,a; string s; cin>>n; for(int i=0;i<n;i++){ cin>>s; if(s[0]=='i'){ cin>>a; node* b=(node *)malloc(sizeof(node)); b->l=nil; b->r=nil; b->key=a; insert(b); } else{ pri(t,1); cout<<endl; pri(t,0); cout<<endl; } } return 0; } 







Measured memory_bytes: 26556
#include<iostream>
using namespace std;
int minn=0;
int n,m,x,c[15],a[15][15],u[15]={0};
bool flag=false;
bool check()
{
	for (int i=1;i<=m;i++)
		if(u[i]<x) return false;
	return true;
}
void search(int k,int sum)
{
	if(k==n+1)
	{
		if(check())
		{
			flag=true;
			if(sum<minn) minn=sum;
		}
		return;
	}
	for (int j=1;j<=m;j++)
		u[j]+=a[k][j];
	search(k+1,sum+c[k]);
	for (int j=1;j<=m;j++)
		u[j]-=a[k][j];
	search(k+1,sum);
}
int main()
{
	cin>>n>>m>>x;
	for (int i=1;i<=n;i++)
	{
		cin>>c[i];
		minn+=c[i];
		for (int j=1;j<=m;j++)
			cin>>a[i][j];
	}
	search(1,0);
	if (flag) cout<<minn; else cout<<-1;
}

Measured memory_bytes: 3636
#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;
    string t=s;

    reverse(t.begin(), t.end());

    int ans=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans/2 << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse
// struct Edge {
//   int to, id;
//   Edge(int a, int b): to(a), id(b) {}
// };

P key[1010];

int n;

int main(int argc, char const *argv[])
{
	int m;cin>>n>>m;

	rep(i,m) {
		int a,b;cin>>a>>b;
		int bit=0;
		rep(j,b) {
			int c;cin>>c;c--;
			bit |= 1<<c;
		}
		key[i]=P(bit,a);
		// cout<<key[i].first<<" "<<key[i].second<<endl;
	}

	vector<int> dp(1<<(n+1));

	rep(s,1<<n) dp[s]=1000000010;

	dp[0]=0;

	// cout<<dp[2]<<endl;

	rep(s,1<<n) {
		rep(j,m) {
			// cout<<dp[s|key[j].first]<<endl;
			dp[s|key[j].first]=min(dp[s|key[j].first],dp[s]+key[j].second);
			// cout<<s<<" "<<int(s|key[j].first)<<" "<<dp[s|key[j].first]<<" ";
			// if (j==m-1) cout<<endl;
		}
	}

	if (dp[(1<<n)-1]==1000000010) {
		cout<<-1<<endl;
	} else {
		cout<<dp[(1<<n)-1]<<endl;
	}

	// cout<<dp[(1<<n)-1]<<endl;

	// rep(i,1<<n) {
	// 	cout<<i<<" "<<dp[i]<<endl;
	// }

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
  
int main(void){
  char s1[100], s2[100], ans[2*100];
 
  scanf("%s %s", s1, s2);
  strcpy(ans, s1);
  strcat(ans, s1);
  if(strstr(ans, s2) == NULL){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}


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

void lcs( string X, string Y, int m, int n )
{
int L[m+1][n+1];

for (int i=0; i<=m; i++)
{
	for (int j=0; j<=n; j++)
	{
	if (i == 0 || j == 0)
		L[i][j] = 0;
	else if (X[i-1] == Y[j-1])
		L[i][j] = L[i-1][j-1] + 1;
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]);
	}
}

int index = L[m][n];

char lcs[index+1];
lcs[index] = '\0';
int i = m, j = n;
while (i > 0 && j > 0)
{
	if (X[i-1] == Y[j-1])
	{
		lcs[index-1] = X[i-1];
		i--; j--; index--;
	}

	else if (L[i-1][j] > L[i][j-1])
		i--;
	else
		j--;
}
cout << lcs;
}

int main()
{
  string s1,s2;
  cin>>s1>>s2;
lcs(s1, s2, s1.length(),s2.length());
return 0;
}


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

int linear(int *, int*, int, int);
int same(int *, int*, int, int);

int main() {
  int *s, *t;
  int n, q, i;

  scanf("%d", &n);
  s = (int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    if(scanf("%d", &s[i])==EOF)break;
  }

  scanf("%d", &q);
  t = (int *)malloc(q*sizeof(int));
  for(i=0;i<q;i++){
    if(scanf("%d", &t[i])==EOF)break;
  }

  printf("%d\n", linear(s, t, n, q));

  free(s);
  free(t);
  
  return 0;
}

int linear(int *s, int *t, int n, int q){
  int i, j;
  int count = 0;
  for(i=0;i<n;i++){
    for(j=0;j<q;j++){
      if(s[i]==t[j] && same(s, t, i, j)==0) count++;
    }
  }

  return count;
}

int same(int *s, int *t, int k, int l){
  int i;

  for(i=0;i<k;i++){
    if(s[i]==s[k]) return 1;
  }
  for(i=0;i<l;i++){
    if(t[i]==t[l]) return 1;
  }

  return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<numeric>
#include<math.h>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string n;
    cin >> n;
    char tmp_num;
    int cnt = 0;
    rep(i, n.length()) {
        if ( i == 0 ) {
            tmp_num = n[i];
            ++cnt;
        }
        else if ( i == 1 ) {
            if ( tmp_num == n[i] ) {
                ++cnt;
                continue;
            }
            else {
                tmp_num = n[i];
                cnt = 1;
            }
        }
        else if ( i == 2 ) {
            if ( tmp_num == n[i] ) {
                ++cnt;
                continue;
            }
            else {
                break;
            }
        }
        else if ( i == 3 ) {
            if ( tmp_num == n[i] ) {
                ++cnt;
            }
            else {
                break;
            }
        }
    }
    if ( cnt >= 3 ) cout << "Yes" << endl;
    else            cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;

void solve() {
    int n, k;
    cin >> n >> k;
    cout << (n > k ? "safe" : "unsafe");
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 3632
n = int(input())
lst = [0] * n
for i in range(n):
    lst[i] = input()

flag = True
for i in range(n-1):
    if lst[i][-1] != lst[i + 1][0]:
        flag = False

print('Yes' if flag == True and len(set(lst)) == n else 'No')

Measured memory_bytes: 3060