akhauriyash/Code-Regression huggingface dataset:
/*================================================
# ~  file:C.cpp
# ~~ date:2020-03-09
# ~~~author: SoMnus_L
#        |everybody finds love,in the end|
#   人の運命か,人の希望は悲しみにつづられているね
=================================================*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N=1e6+10;
using namespace std;
typedef pair<int,int>PII;

int n,m,a[10],s,c;
map<int,int>mp;
int main(){
 ios::sync_with_stdio(false);
  cin>>n>>m;
  memset(a,-1,sizeof(a));bool flag=1;
   while(m--){ 
     cin>>s>>c;
     if(a[s]==-1){
	a[s]=c;
	mp[s]=c;
     }
     else if(mp[s]!=c) flag=0;
   }
   if(a[1]==0 && n>1) flag=0;
   if(flag==0)  cout<<-1;
   else{
       if(n>1){
	 for(int i=1;i<=n;i++){
           if(a[i]==-1 && i==1) cout<<1;
	   else if(a[i]==-1 && i!=1) cout<<0;
	   else cout<<a[i];
	}
       }
	else{
          if(a[1]==-1) cout<<0;
	  else cout<<a[1];
	}
       }
  return 0;
}


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

int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  long long int N,t=1,n=1,e=1,O;
  cin >> N;
  for(int i=0;i<N;i++){
    t=t*10;
    t=t%1000000007;
    n=n*9;
    n=n%1000000007;
    e=e*8;
    e=e%1000000007;
  }
  O=t-2*n+e;
  while(O<0){
    O=O+1000000007;
  }
  cout << O <<endl;
}


int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int, int> p;

string zero(int ken, int ban){
  int kens = int(log10(ken));
  int bans = int(log10(ban));
  string s = "";
  for (int i = 0; i < 5 - kens; i++)
  {
    s += "0";
  }
  s += to_string(ken);
  for (int i = 0; i < 5 - bans; i++)
  {
    s += "0";
  }
  s += to_string(ban);
  return s;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(n, vector<int>());
  vector<vector<int>> tmp(n, vector<int>());
  map<int, string> mp;
  vector<int> zyunban(m, 0);
  for (int i = 0; i < m; i++)
  {
    int place;
    cin >> place;
    int gomi;
    cin >> gomi;
    zyunban[i] = gomi;
    v[place-1].push_back(gomi);
    tmp[place-1].push_back(gomi);
  }

  for (int i = 0; i < n; i++) {
    sort(all(tmp[i]));
  }

  for(int i = 0; i < n; i++){
    for(auto b : v[i]){
      auto it = lower_bound(tmp[i].begin(), tmp[i].end(), b);
      // zero(i+1, it-tmp[i].begin()+1);
      mp[b] = zero(i+1, it-tmp[i].begin()+1);
      // cout << setfill('0') << right  << setw(6) << i;
      // cout << setfill('0') << right  << setw(6) << it-tmp[i].begin() << endl;
    }
  }

  for(auto a : zyunban) cout << mp[a] << endl;


}


Measured memory_bytes: 23808
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {
	
	public static long gcd(long a, long b){
		return b == 0 ? a : gcd(b, a % b);
	}
	public static long lcm(long a, long b){
		return a / gcd(a, b) * b;
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){	
			final long A = sc.nextLong();
			final long B = sc.nextLong();
			
			System.out.println(lcm(A, B));
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21204
// C - Minimization
// with operation
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define ote(x) cout<<(x)<<endl
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)

void prn(vi & v){
	rp(i,1,v.size()){
		printf("%d ",v[i]);
	}puts("");
}

int main(){
	int N,K; cin>>N>>K;
	int p = 0;
	vi A(N+1);// 1 origin
	vi G(N+1);// 1 origin
	A[0] = INT_MAX;
	G[0] = -1;
	rp(i,1,N+1){
		cin>>A[i];
		if(A[p]>A[i]) p = i;
		G[i] = (i-1)/(K-1);
	}

	// prn(A);//
	// prn(G);//
	// printf("N%K %d\n",N%K);//
	// printf("a %d b %d\n",G[N],G[N-(K-1)+1]);//
	// ote(G[N]+(G[N]==G[N-(K-1)+1]));
	// ote(G[N]+(N%K!=0));
	ote(G[N]+((N-1)%(K-1)!=0));
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (((ll)1<<31)-1)
#define eps LDBL_EPSILON
#define moder (1000000007)
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0;
using namespace std;
int n,c[200010],a[200010],b[200010];
int dp[200010];
map<int,int> mp;
signed main(){
	cin>>n;
	rep(i,n)cin>>c[i];
	memset(b,-1,sizeof(b));
	rep(i,n){
		if(b[c[i]]!=-1){
			a[b[c[i]]]=i;
		}
		b[c[i]]=i;
	}
	dp[0]=1;
	rep(i,n){
		if(i)dp[i]+=dp[i-1];
		dp[i]%=moder;
		if(a[i]&&a[i]!=i+1)dp[a[i]]+=dp[i];
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 6528
#coding:utf-8

from collections import defaultdict

if __name__ == "__main__":
    n = int(raw_input())
    str_list = []
    for i in range(n):
        str_list.append(raw_input())

    min_counts = [1 << 20] * 26

    for string in str_list:
        counts = [0] * 26
        for char in string:
            counts[ord(char) - ord('a')] += 1

        for i, count in enumerate(counts):
            if count < min_counts[i]:
                min_counts[i] = count

    answer = ""
    for i in range(26):
        answer += chr(ord('a') + i) * min_counts[i]

    print answer


Measured memory_bytes: 2812
from itertools import permutations
def warshallFloyd():
    for i in range(N):
        for j in range(N):
            for k in range(N):
                dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k])
    return

INF = 10 ** 18
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
dp = [[INF for _ in range(N)] for _ in range(N)]
ansF = False
for i in range(N):
    for j in range(N):
        if i == j:
            dp[i][j] = 0

for i in range(M):
    a, b, c = map(int, input().split())
    dp[a - 1][b - 1] = c
    dp[b - 1][a - 1] = c

warshallFloyd()
ans = INF
for i in permutations(r):
    tmp = 0
    for j in range(1, len(i)):
        tmp += dp[i[j - 1] - 1][i[j] - 1]
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 47448
#include <iostream>

using namespace std;

int coin[4] = {10, 50, 100, 500};
const int inf = 1000000;

int main()
{
  int n, a[4], b[4], c[4], s, t, u, v;
  bool f = false;

  while(cin>>n && n){
    if(f){
      cout << endl;
    }
    v = 0;
    for(int i = 0; i < 4; i++){
      cin >> a[i];
      b[i] = c[i] = 0;
      v += a[i];
    }
    s = t = inf;

    for(int i = 0; i <= a[3]; i++){
      for(int j = 0; j <= a[2]; j++){
	for(int k = 0; k <= a[1]; k++){
	  for(int l = 0; l <= a[0]; l++){
	    s = l*coin[0] + k*coin[1] + j*coin[2] + i*coin[3];
	    if(s >= n){
	      s -= n;
	      u = v-(l+k+j+i);
	      for(int m = 3; m >= 0; m--){
		c[m] = (s/coin[m]);
		u += c[m];
		s %= coin[m];
	      }
	      if(u < t){
		t = u;
		b[0] = l;
		b[1] = k;
		b[2] = j;
		b[3] = i;
	      }
	    }
	  }
	}
      }
    }

    for(int i = 0; i < 4; i++){
      if(b[i] > 0){
	cout << coin[i] << " " << b[i] << endl;
      }
    }
    f = true;
  }

  return 0;
}

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

int e[202][202];
vector<int>E[202];
set<int>st[202];
int used[202];
int N;

void err() {
	puts(-1);
	exit(0);
}

int bfs(int st){
	int res = 1;
	queue<pair<int,int>>q;
	vector<int>check(N);
	for (int i = 0; i < N; i++)check[i] = -1;
	q.push({st,1});
	check[st] = 0;
	while (q.size()) {
		auto tp = q.front();
		q.pop();
		int v = tp.first;
		int num = tp.second;
		res = max(res, num);
		for (int i = 0; i < N; i++) {
			if (e[v][i] == 1) {
				if (check[i] == -1) {
					check[i] = !check[v];
					q.push({i,num+1});
				}
				else if (check[i] == check[v])err();
			}
		}
	}
	return res;
}

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


	cin >> N;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		for (int j = 0; j < N; j++) {
			e[i][j] = S[j] - '0';
		}
	}

	int ans = -1;
	for (int i = 0; i < N; i++) {
		ans = max(bfs(i), ans);
	}
	puts(ans);

	return 0;
}

Measured memory_bytes: 384
use std::io::{stdin, Read};
const MOD: usize = 1000000007;

fn gcd(a: usize, b: usize) -> usize {
    match b {
        0 => a,
        _ => gcd(b, a % b),
    }
}

fn powmod(base: usize, exp: usize, m: usize) -> usize {
    let b: Vec<bool> = format!("{:b}", exp)
        .chars()
        .map(|x| x.to_digit(10).unwrap() != 0)
        .collect();
    let mut v = 1;
    for bi in b {
        v *= v;
        v %= m;
        if bi {
            v *= base;
            v %= m
        }
    }
    return v % m;
}

fn invmod(x: usize, m: usize) -> usize {
    powmod(x, m - 2, m)
}

fn prime_factors(x: usize) -> Vec<usize> {
    let mut res = vec![];
    let mut y = x;
    let mut p = 2;
    let upper = (y as f64).sqrt() as usize;
    while y > 1 && p <= upper {
        match y % p {
            0 => {
                res.push(p);
                y /= p;
            }
            _ => {
                p += 1;
            }
        }
    }
    if y > 1 {
        res.push(y)
    }
    return res;
}

fn get_factorials(n: usize, m: usize) -> Vec<usize> {
    let mut res = vec![0; n as usize];
    res[0] = 1;
    for i in 1..(n as usize) {
        res[i] = (res[i - 1] * (i as usize)) % m;
    }
    res
}

fn get_facinvs(n: usize, m: usize, facts: &Vec<usize>) -> Vec<usize> {
    let mut res = vec![0; n];
    res[n - 1] = invmod(facts[n - 1], m);
    for i in (0..(n - 1)).rev() {
        res[i] = (res[i + 1] * (i + 1)) % m;
    }
    res
}

fn combmod(a: usize, b: usize, m: usize, facts: &Vec<usize>, invs: &Vec<usize>) -> usize {
    if a < b {
        0
    } else {
        (((facts[a as usize] * invs[b as usize]) % m) * invs[(a - b) as usize]) % m
    }
}

macro_rules! parse {
    ($iter: ident) => {
        $iter.next().unwrap().parse().unwrap()
    };
    ($iter: ident,2) => {
        (parse!($iter), parse!($iter))
    };
    ($iter: ident,3) => {
        (parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident,4) => {
        (parse!($iter), parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident, $n: ident) => {
        (&mut $iter).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let (r1, c1, r2, c2): (usize, usize, usize, usize) = parse!(it, 4);
    let facts = get_factorials(2000010, MOD);
    let invs = get_facinvs(2000010, MOD, &facts);
    let f = |i, j| combmod(i + j, i, MOD, &facts, &invs);
    let g = |i, j| -> usize { (0..(i + 1)).map(|x| f(x + 1, j)).sum() };
    let ret = ((g(r2, c2) + g(r1 - 1, c1 - 1)) as i64) - ((g(r2, c1 - 1) + g(r1 - 1, c2)) as i64);
    let ret = ret % (MOD as i64);
    let ret = if ret < 0 { ret + (MOD as i64) } else { ret };
    println!("{}", ret);
}


Measured memory_bytes: 37116
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int a= 0, b = 0;
    string s;
    cin>>s;
    int i;
    FOR0(i, 3) 
    {
        if(s[i] == 'A') a++;
        else b++;
    }
    if(a && b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

int main(){
  int N,A,B,C;
  cin>>N>>A>>B>>C;
  vector<int> l(N);
  for(int i=0;i<N;i++){
    cin>>l[i];
  }
  vector<int> p((1<<N),167167167);
  vector<int> q((1<<N),167167167);
  vector<int> r((1<<N),167167167);
  for(int i=1;i<(1<<N);i++){
    int L=0,X=0;
    vector<int> a;
    for(int j=0;j<N;j++){
      if(i&(1<<j)){
        L+=l[j];
      }
      else{
        a.push_back(j);
        X++;
      }
    }
    for(int j=0;j<(1<<X);j++){
      int Y=i;
      for(int k=0;k<X;k++){
        if(j&(1<<k)){
          Y+=(1<<a[k]);
        }
      }
      p[Y]=min(p[Y],abs(L-A)+10*(N-X-1));
    q[Y]=min(q[Y],abs(L-B)+10*(N-X-1));
    r[Y]=min(r[Y],abs(L-C)+10*(N-X-1));
    }
  }
  int Z=167167167;
  for(int i=1;i<(1<<N);i++){
    for(int j=1;j<(1<<N);j++){
      if(i&j){
        continue;
      }
      int k=((1<<N)-1)^(i|j);
      Z=min(Z,p[i]+q[j]+r[k]);
    }
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
using namespace std;

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

	int a,b,c,i,j;
	vector<int> v;
	cin>>a>>b;
	for(i=0;i<b;i++){
		cin>>c;
		a-=c;
	}
	if(a>0){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}

	

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define il inline
using namespace std;
const int N=2e5+5,M=2e6;

int n,m,e,S,T,h,t,q[N],lev[N],ax[N],ay[N],o[N];
int to[M],nx[M],cap[M],hd[N],it[N],sze=1;
std::vector<int> g[N];

il void add(int u,int v,int c){to[++sze]=v,nx[sze]=hd[u],cap[sze]=c,hd[u]=sze;}

il void ins(int u,int v,int c){add(u,v,c),add(v,u,0);}

il int bfs()
{
	memset(lev,0,4*T+4); int i,u,v; q[h=t=lev[S]=1]=S;
	while (h<=t) for (i=hd[u=q[h++]]; i; i=nx[i])
        if (cap[i]&&!lev[v=to[i]]) lev[v]=lev[u]+1,q[++t]=v;
	return lev[T];
}

il int dfs(int u,int f)
{
	if (u==T) return f; int z,v,res=0;
	for (int &i=it[u]; i; i=nx[i])
		if (lev[v=to[i]]==lev[u]+1&&cap[i]&&(z=dfs(v,min(f-res,cap[i]))))
		{
			cap[i]-=z,cap[i^1]+=z,res+=z;
			if (res==f) break;
		}
	return res;
}

il int dinic()
{
	int i,f,res=0;
	while (bfs())
    {
        for (i=1; i<=T; i++) it[i]=hd[i];
        while (f=dfs(S,1e9)) res+=f;
    }
	return res;
}

il int work()
{
    int i,u,v,s=0;
    for (u=1; u<n; u++) for (i=hd[u]; i; i=nx[i])
        if ((v=to[i])!=S&&!cap[i]) o[u]=v-n+1;
    for (q[++t]=n; h<=t; )
    {
        u=q[h++],s++;
        for (int v:g[u]) if (o[v])
            ax[v]=u,ay[v]=o[v],q[++t]=o[v],o[v]=0; 
    }
    return s==n;
}

int main()
{
	scanf("%d",&n),S=n+n-1,T=n+n; int i,c,x;
    for (i=1; i<n; i++) ins(i+n-1,T,1);
    for (i=1; i<n; i++)
    {
        scanf("%d",&c),ins(S,i,1);
        while (c--)
        {
            scanf("%d",&x);
            if (x!=n) ins(i,x+n-1,1);
            g[x].push_back(i);
        }
    }

    if (dinic()<n-1) return puts("-1"),0;
    if (!work()) return puts("-1"),0;
	for (i=1; i<n; i++) printf("%d %d\n",ax[i],ay[i]);
	
	return 0;
}

Measured memory_bytes: 26092
import itertools

operators = ("+", "-", "*")
forms = ( "(({3}{0}{4}){1}{5}){2}{6}", "({3}{0}{4}){1}({5}{2}{6})", "({3}{0}({4}{1}{5})){2}{6}", "{3}{0}(({4}{1}{5}){2}{6})", "{3}{0}({4}{1}({5}{2}{6}))", )

def calc(n):
    for op in itertools.product(operators, repeat=3):
        for form in forms:
            formula = form.format(op[0], op[1], op[2], n[0], n[1], n[2], n[3])
            if eval(formula) == 10:
                print(formula)
                return True
    return False

while True:
    num = list(map(int, input().split()))
    if num[0] == 0:
        break
    for n in itertools.permutations(num):
        if calc(n):
            break
    else:
        print(0)



Measured memory_bytes: 5644
use std::io::stdin;

fn main() {
    let mut string = String::new();
    stdin().read_line(&mut string);
    let N: usize = string.trim().parse().unwrap();
    string = String::new();
    stdin().read_line(&mut string);
    let S = string.trim();
    let mut sum = 0;

    let R = S.matches("R").count();
    let G = S.matches("G").count();
    let B = S.matches("B").count();

    let S: Vec<char> = S.chars().collect();

    sum = R * G * B;

    for i in 0..N - 2 {
        for j in i + 1..N - 1 {
            let k = j * 2 - i;
            if k >= N {
                break;
            }
            // println!("i = {}, j = {}, k = {}", i, j, k);


            let ichar = S[i];
            let jchar = S[j];
            let kchar = S[k];
            if  ichar != jchar {
                if jchar != kchar {
                    if ichar != kchar {
                        sum -= 1;
                    }
                }
            }
        }
    }

    println!("{}", sum)
}

Measured memory_bytes: 2172
fn read<T: std::str::FromStr>() -> Vec<T>
where
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).unwrap();
    b.split_whitespace()
        .map(|x| x.trim().parse::<T>().unwrap())
        .collect()
}

fn main() {
    let iv = read::<u64>();
    let (a, b, t) = (iv[0], iv[1], iv[2]);
    println!("{}", t / a * b);
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    rep(i, N) {
        cin >> A[i];
        B[i]=A[i];
    }
//ソートして1,2番目に大きい数を求める
sort(B.begin(),B.end(),greater<int>());
    int max1=B[0];
    int max2=B[1];

    rep(i, N) {
        if (A[i] != max1) cout << max1 << endl;
        else {
            cout<<max2<<endl;
        }
    }
}

Measured memory_bytes: 3200
A[20000];z(int*a,int*b){return*b-*a;}
main(n,i,j){for(;scanf("%d",&n),n;puts(i>n?"No":"Yes")){
for(i=0;i<n*2;i++)scanf("%d",A+i);
for(i=qsort(A,n,4,z);i<n;i=A[i]?n+1:i+1)for(j=0;j<n;j++)if(A[j+n])A[i]--,A[j+n]--;
}exit(0);}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D) {
        cout << "Left" << endl;
    }
    else if (A + B < C + D) {
        cout << "Right" << endl;
    }
    else {
        cout << "Balanced" << endl;
    }
    return 0;
}

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

if(  Math.abs(c-a) <= d ) {
 System.out.println("Yes");

}else if(Math.abs(b-a) <= d && Math.abs(c-b) <= d) {
	System.out.println("Yes");

} else {
	System.out.println("No");
}

}
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int A[3100], B[3100];

int dp[3100][3100] = {0};
int prev_A[3100][3100];

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

  int N, T;
  cin >> N >> T;

  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }

  for(int i = 0; i < N; i++){
    for(int t = 0; t <= T-1; t++){

      if(t >= A[i]){
        if(dp[i+1][t] < dp[i][t-A[i]] + B[i]){
          dp[i+1][t] = dp[i][t-A[i]] + B[i];
          prev_A[i+1][t] = t - A[i];
        }
      }

      if(dp[i+1][t] < dp[i][t]){
        dp[i+1][t] = dp[i][t];
        prev_A[i+1][t] = t;
      }
    }
  }

  vector<int> selected_ind(N);

  int cur_T = T-1;

  for(int i = N-1; i >= 0; i--){
    if(prev_A[i+1][cur_T] == cur_T - A[i]){
      selected_ind[i] = 1;
    }
    cur_T = prev_A[i+1][cur_T];
  }

  int MAX_B = 0;
  for(int i = 0; i < N; i++){
    if(selected_ind[i] == 0){
      chmax(MAX_B, B[i]);
    }
  }

  cout << dp[N][T-1] + MAX_B << endl;

  return 0;
}


Measured memory_bytes: 74112
#include <bits/stdc++.h>
using namespace std;
int main(){
int D;
cin>>D;
if(D==25){
cout<<"Christmas"<<endl;
}
else if(D==24){
cout<<"Christmas Eve"<<endl;
}
else if(D==23){
cout<<"Christmas Eve Eve"<<endl;
}
else if(D==22){
cout<<"Christmas Eve Eve Eve"<<endl;
}
}


Measured memory_bytes: 3488
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int b[10] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

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

  sort(a, a + m);

  int dp[m + 1][n + 1];
  for(int i = 0; i <= m; i++){
    fill(dp[i], dp[i] + n + 1, -1);
  }

  dp[0][0] = 0;
  for(int i = 1; i <= m; i++){
    for(int j = 0; j <= n; j++){
      int tmp = -1;
      for(int k = 0; j - k * b[a[i - 1]] >= 0; k++){
        if(dp[i - 1][j - k * b[a[i - 1]]] >= 0)
          tmp = max(tmp, dp[i - 1][j - k * b[a[i - 1]]] + k);
      }
      if(tmp >= 0) dp[i][j] = tmp;
    }
  }

  string ans;
  int r = n;
  for(int i = m - 1; r >= 0 && i >= 0; i--){
    int k = r / b[a[i]];
    while(k >= 0){
      if(dp[i + 1][r] == dp[i][r - b[a[i]] * k] + k) break;
      --k;
    }
    r -= b[a[i]] * k;
    for(int j = 0; j < k; j++){
      ans += to_string(a[i]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(){

    char a[200001];
    char b[200001];

    int d = 0;
    int x;


    scanf("%s",a);
    scanf("%s",b);

    x = strlen(a);

    for(int i = 0;i < x; ++i){
        if(a[i] != b[i])
            ++d;
    }
    printf("%d\n",d);

    return 0;
}

Measured memory_bytes: 2092
#include<iostream>
using namespace std;
int main() {
	char arr[6];
	for (int i = 0; i < 6; i++) {
		cin >> arr[i];
	}
	if (arr[2] == arr[3] && arr[4] == arr[5])
		cout << "Yes";
	else
		cout << "No";
}


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

double sum = 0;

double measure_dist(double x1, double y1, double x2, double y2){
  return pow( pow(x1-x2,2.0)+pow(y1-y2,2.0) ,0.5);
}

int main(){
  cout << fixed << setprecision(10);
  int N; cin >> N;

  vector<double> x(N);
  vector<double> y(N);
  
  for(int i=0; i<N; i++){
    cin >> x.at(i) >> y.at(i);
  }

  double dist = 0;
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      dist += measure_dist( x.at(i), y.at(i), x.at(j), y.at(j) );
    }
  }
  cout << dist/(N/2.0) << endl;
}

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

string s;

int main() {
  cin >> s;
  if(s[0]==s[1] && s[1]==s[2]){
    cout << "No" << endl;
  } else if(s[0]==s[1] | s[1]==s[2] | s[2]==s[0]) {
    cout << "Yes" << endl;
  }
}

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> G;
    G.assign(N, vector<int>());
    rep(i, N - 1) {
        int a;
        cin >> a;
        a--;
        G[a].push_back(i);
    }

    for (auto v : G) {
        cout << v.size() << endl;
    }
}

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

int main(){
  int N,Q;
  string S;
  cin>>N>>Q>>S;
  vector<int> l(Q),r(Q);
  for(int i=0;i<Q;i++){
    cin>>l.at(i)>>r.at(i);
  }
  vector<int> count(N,0);
  for(int i=0;i<N-1;i++){
    if(S.at(i)=='A'&&S.at(i+1)=='C'){
      count.at(i+1)++;
    }
    count.at(i+1)+=count.at(i);
  }
  for(int i=0;i<Q;i++){
    cout<<count.at(r.at(i)-1)-count.at(l.at(i)-1)<<endl;
  }
}


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

int main() {
    string N;
    cin >> N;
    
    string rev;
    if (N == "Sunny") rev = "Cloudy";
    if (N == "Cloudy") rev = "Rainy";
    if (N == "Rainy") rev = "Sunny";

    cout << rev << endl;
}

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

int N, W;
long long dp[100001];

long long to(long long *x, long long y) {
    if (*x < y) *x = y;
}

int main() {
    scanf("%d %d", &N, &W);
    for (int i = 0; i <= W; i++) {
        dp[i] = -2e18;
    }
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        int w, v;
        scanf("%d %d", &w, &v);
        for (int j = W - w; j >= 0; j--) {
            to(&dp[j + w], dp[j] + v);
        }
    }
    long long ans = 0;
    for (int i = 0; i <= W; i++) {
        to(&ans, dp[i]);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

static const int MAX = 10000;
static const int INFTY =(1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int,int> >adj[MAX];

void dijkstra()
{
    priority_queue<pair<int,int> >PQ;

    int color[MAX];
    int d[MAX];
    int i,j;

    for(i = 0; i < n; i++)
    {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    PQ.push(make_pair(0,0));
    color[0] = GRAY;

    while(!PQ.empty())
    {
        pair<int,int> f = PQ.top();PQ.pop();

        int u = f.second;

        color[u] = BLACK;

        if(d[u] < f.first * (-1)) continue;

        for(j = 0; j < adj[u].size(); j++)
        {
            int v = adj[u][j].first;

            if(color[v] == BLACK) continue;
            if(d[v] > d[u] + adj[u][j].second)
            {
                d[v] = d[u] + adj[u][j].second;

                PQ.push(make_pair(d[v] * (-1),v));

                color[v] = GRAY;
            }
        }
    }

     for(i = 0; i < n; i++)
    {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main()
{
    int k,u,v,c;
    int i,j;

    cin >> n;

    for(i = 0; i < n; i++)
    {
        cin >> u >> k;
        for(j = 0; j < k; j++)
        {
            cin >> v >> c;
            adj[u].push_back(make_pair(v,c));
        }
    }

    dijkstra();

    return 0;

}


Measured memory_bytes: 7984
n = int(input())
txy = []
for i in range(n):
    txy.append(list(map(int, input().split())))

for i in range(n):
    t = txy[i][0]
    t -= txy[i][1]
    t -= txy[i][2]
    if t < 0:
        print("No")
        break
    if t % 2 != 0:
        print("No")
        break
    if i == n-1:
        print("Yes")
        break
    else:
        txy[i+1][0] -= txy[i][0]
        txy[i+1][1] = abs(txy[i+1][1] - txy[i][1])
        txy[i+1][2] = abs(txy[i+1][2] - txy[i][2])

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int itr = lower_bound(v.begin(), v.end(), v.at(i)+v.at(j)) - v.begin();
            ans += max(itr - (j+1), 0);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
const int MAXN = 10000;
int n;
int vs[MAXN];
int d[MAXN];
void bfs(int s,vector<vector<int> > &g){
  queue<int> q;
  q.push(s);
  fill(d,d+MAXN,-1);
  d[s] = 0;
  while(!q.empty()){
    int current = q.front();q.pop();
    for(int next:g[current]){
      if(d[next] < 0){
        q.push(next);
        d[next] = d[current] + 1;
      }
    }
  }
}
int main(){
  cin >> n;
  vector<vector<int> > g(n+1);
  for(int i = 1;i <= n;i++){
    int u,k;
    cin >> u >> k;
    for(int j = 0; j < k;j++){
      int v;
      cin >> v;
      g[u].push_back(v);
    }
  }
  bfs(1,g);
  for(int i = 1;i <= n;i++){
    cout << i << ' ' << d[i] << endl;
  }
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
ll MOD = 1e9 + 7;

using vc = vector<char>;
using vi = vector<int>;
using vll = vector<ll>;

vector<vll> dp;

vi NS;
vi MS;

ll recurse(int n, int m) {
    if (n == -1 || m == -1) return 1;

    if (dp[n][m] != -1) return dp[n][m];

    ll total = 0;
    if (NS[n] == MS[m]) 
        total += 2 * recurse(n-1, m-1);
    else 
        total += recurse(n-1, m-1);
    total %= MOD;
    total += recurse(n-1, m) - recurse(n-1, m-1);   total %= MOD;
    total += recurse(n, m-1) - recurse(n-1, m-1);   total %= MOD;
    dp[n][m] = total;
    return total;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N, M; cin >> N >> M;

    NS = vi (N);
    F0R(i, N) cin >> NS[i];

    MS = vi (M);
    F0R(i, M) cin >> MS[i];

    dp = vector<vll> (N, vll (M, -1));

    cout << (MOD + recurse(N-1, M-1)) % MOD << endl;
}

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

int dp[1<<12][13];

int main(){
	int M,W;
	while(scanf("%d%d",&M,&W),M!=0){
		int bm[12],bw[12];
		for(int i=0;i<M;i++) scanf("%d",&bm[i]);
		for(int i=0;i<W;i++) scanf("%d",&bw[i]);
		for(int i=0;i<(1<<12);i++) for(int j=0;j<13;j++) dp[i][j]=-1;
		dp[0][0]=0;
		for(int j=0;j<W;j++) for(int i=0;i<(1<<M);i++){
			if(dp[i][j]<0) continue;
			dp[i][j+1]=max(dp[i][j],dp[i][j+1]);
			for(int k=0;k<M;k++){
				int x=1<<k;
				if(i&x) continue;
				int y=abs(bm[k]-bw[j]);
				dp[i+x][j+1]=max(dp[i][j]+y*(y-30)*(y-30),dp[i+x][j+1]);
			}
		}
		int res=0;
		for(int i=0;i<(1<<M);i++) res=max(res,dp[i][W]);
		printf("%d\n",res);
	}
}

Measured memory_bytes: 1396
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=3e5+10,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int a,b;
    cin>>a>>b;
    cout<<max({a+b,a*b,a-b});
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}

// #define MULTIPLE_TEST_CASE
void solution() {
  int n;
  cin >> n;
  int ans = 0;
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    ans += x;
    cnt[x]++;
  }
  int q;
  cin >> q;
  while (q--) {
    int x, y;
    cin >> x >> y;
    int bef = cnt[x];
    ans -= bef * x;
    ans += bef * y;
    cnt[y] += bef;
    cnt[x] -= bef;
    cout << ans << endl;
  }
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 9564
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		double[][] dp=new double[n+1][n+2];
		dp[0][0]=1;
		for(int i=0; i<n; i++){
			double p=sc.nextDouble();
			for(int j=0; j<=n; j++){
				dp[i+1][j+1]+=dp[i][j]*p;
				dp[i+1][j]+=dp[i][j]*(1-p);
			}
		}
		double ans=0;
		for(int i=n; i>=(n+2)/2; i--){
			ans+=dp[n][i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 133416
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    string s,t;
    cin >> s >> t;
    int S=s.size(),T=t.size();
    int dp[3020][3020][2];
    //0はニュートラル、1はS、2はT
    
  	REP(i,S+1){REP(j,T+1){dp[i][j][0]=0;}}
    for(int i=1;i<=S;i++){
        for(int j=1;j<=T;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j][0]=dp[i-1][j-1][0]+1;
                dp[i][j][1]=0;
            }else{
                if(dp[i-1][j][0]>=dp[i][j-1][0]){
                    dp[i][j][0]=dp[i-1][j][0];
                    dp[i][j][1]=1;
                }else{
                    dp[i][j][0]=dp[i][j-1][0];
                    dp[i][j][1]=2;
                }
            }
        }
    }
    //cout << dp[S][T][0] << endl;
    
  	string A;
    int p=S,q=T;
  	while(p>0&&q>0){
      if(dp[p][q][1]==0){
		A.push_back(s[p-1]);
        p--;q--;
      }else if(dp[p][q][1]==1){
        p--;
      }else{
        q--;
      }
    }
  
  	RREP(i,A.size()){
		cout << A[i]; 
    }
  	/*REP(i,S+1){
		REP(j,T+1){
          cerr << dp[i][j][0] << " ";
        }cerr << endl;
    } cerr << endl;
  	REP(i,S+1){
		REP(j,T+1){
          cerr << dp[i][j][1] << " ";
        }cerr << endl;
    }*/
    return 0;
}   


Measured memory_bytes: 142592
#距離を計算する関数
def distance(k,j,zen,d):
    a = zen[k]
    b = zen[j]
    r = 0
    for i in range(d):
        r = r + (int(a[i]) - int(b[i])) ** 2
    return r ** 0.5

#2次元配列を用意
zen = []
#N、Dを得る
n, d = map(int, input().split())

for i in range(n):
    #xを得る
    x = input()
    #リストにする
    xi =x.split()
    #2次元配列に追加
    zen.append(xi)

#2次元配列を表示
#print(zen)
#print(zen[1])
count = 0
good=[]
for k in range(n-1):
    for j in range(k+1, n):
        #good.append(distance(k, j, zen, d))
        if distance(k, j, zen, d).is_integer():
            count = count + 1

#print(good)
print(count)


Measured memory_bytes: 3064
# https://atcoder.jp/contests/abc058/tasks/arc071_a
from collections import Counter
n = int(input())

ans = []
strings = []
for _ in range(n):
    strings.append(input())

for i in range(26):
    w = chr(ord('a') + i)
    t = float('inf')
    for s in strings:
        c = s.count(w)
        t = min(t, c)
    for _ in range(t):
        ans.append(w)
print(''.join(ans))

Measured memory_bytes: 67992
#include <iostream>

int main(int argc, char *argv[]) {
  int a, b;
  std::cin >> a >> b;
  if (a >= 13)
    std::cout << b << std::endl;
  else if (a >= 6)
    std::cout << b / 2 << std::endl;
  else
    std::cout << 0 << std::endl;
}


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

void insertionSort(int A[], const int n, const int g, int *cnt)
{
    for( int i = g; i < n; ++i ){
	int tmp = A[i];
	int j = i - g;
	while( -1 < j && tmp < A[j] ){
	    //cout << A[j+g] << "<-->" << A[j] << endl;
	    A[j+g] = A[j];
	    j = j - g;
	    ++*cnt;
	}
	A[j+g] = tmp;
    }
}

void shellSort(int A[], const int n)
{
    int cnt = 0;
    int m;
    int G[100];
    for( int i = 0; i < 100; ++i ){
	if( i == 0 ) G[i] = n / 2 + 1;
	else G[i] = G[i-1] / 2 - 1;
	if( G[i] < 0 ){
	    G[i-1] = 1;
	    G[i] = 0;
	    m = i;
	    break;
	}
    }

    for( int i = 0; i < m; ++i )
	insertionSort(A, n, G[i], &cnt);

    //出力
    printf("%d\n", m);
    for( int i = 0; i < m; ++i ){
	if( i ) printf(" ");
	printf("%d", G[i]);
    }
    printf("\n%d\n", cnt);
    for( int i = 0; i < n; ++i )
	printf("%d\n", A[i]);
}

int main()
{
    //入力
    int n;
    scanf("%d", &n);
    int A[n];
    for( int i = 0; i < n; ++i )
	scanf("%d", &A[i]);

    //シェルソート
    shellSort(A, n);

    return 0;
}

Measured memory_bytes: 5100
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
string s;
using MIte = multimap<int, int>::iterator;

int main() {

	string s, t;
	cin >> s >> t;

	vector<vector<int>> ind(26, vector<int>(0));

	for (int i = 0; i < s.size(); i++) {
		ind[s[i] - 'a'].push_back(i);
	}

	long long now = 0;
	long long ans = 0;
	for (int i = 0; i < t.size(); i++) {
		int c = (int)t[i] - 'a';
		if (ind[c].size() == 0) {
			cout << -1 << endl;
			return 0;
		}
	A:
		auto it = lower_bound(ind[c].begin(), ind[c].end(), now);
		if (it == ind[c].end()) {
			ans++;
			now = 0;
			goto A;
		}
		now = (*it) + 1;


	}

	cout << (long long)ans * s.size() + (long long)now << endl;

	return 0;
}

Measured memory_bytes: 1216
import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
time = [a,b,c,d,e]
test = list(itertools.permutations(time))
mnm = 100000
for i in range(len(test)):
    temp = 0
    for k in range(5):
        if temp%10 == 0:
            temp += test[i][k]
        else:
            temp += (10-temp%10)+test[i][k]
    if temp < mnm:
        mnm = temp
print(mnm)

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

using ll = long long;


int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; ++i) {
        auto s = to_string(i);
        auto t = s;
        reverse(begin(t), end(t));
        ans += s == t;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import math

n = int(input())
x = list(map(int,input().split()))

num = math.ceil(sum(x)/len(x))
num2 = int(sum(x)/len(x))
res = 0
res2 = 0

for i in x:
    res += (i - num)**2

for i in x:
    res2 += (i - num2)**2

if res < res2:
    print(res)
else:
    print(res2)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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(){
V<V<int>> a(3,V<int>(3));
for(int i=0;i<3;i++)for(int j=0;j<3;j++)cin>>a[i][j];
int n;
cin>>n;
V<V<bool>> used(3,V<bool>(3,false));
for(int i=0;i<n;i++){
    int m;cin>>m;
    bool ok=false;
    for(int j=0;j<3;j++){
        for(int k=0;k<3;k++){
            if(a[j][k]==m){
                used[j][k]=true;
                break;
            }
        }
        if(ok)break;
    }
}
bool ok=false;
for(int i=0;i<3;i++){
    bool c=true;
    for(int j=0;j<3;j++){
       if(!used[i][j])c=false;
    }
    if(c)ok=true;
}
for(int i=0;i<3;i++){
    bool c=true;
    for(int j=0;j<3;j++){
       if(!used[j][i])c=false;
    }
    if(c)ok=true;
}
bool t=true;
for(int i=0;i<3;i++){
    if(!used[i][i])t=false;
}
if(t)ok=true;
t=true;
for(int i=0;i<3;i++){
    if(!used[i][2-i])t=false;
}
if(t)ok=true;
if(ok)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
    

Measured memory_bytes: 256