akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
#define dump(x) cerr << #x " = " << x << endl
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }
template <typename X, typename T> auto make_vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_vectors(X x, Y y, Z z, Zs... zs) { auto cont = make_vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, (int)xs.size() - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }

bool solve(int n, const vector<int> & a) {
    int acc = 0;
    REP (i, n) {
        acc ^= a[i];
    }
    return not acc;
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    REP (i, n) {
        cin >> a[i];
    }
    cout << (solve(n, a) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

typedef long long ll;

int A,B;

int main(){
    cin >> A >> B;
    int count = 0;
    cout << "100 100" << endl;
    for(int i=0;i<50;i++){
        for(int j=0;j<100;j++){
            if((i+j)%2 == 0 || i % 2 == 0) cout << '#';
            else{
                count++;
                if(count < A) cout << '.';
                else cout << '#';
            }
        }
        cout << endl;
    }
    count = 0;
    for(int i=0;i<50;i++){
        for(int j=0;j<100;j++){
            if((i+j)%2 == 0 || i % 2 == 0) cout << '.';
            else{
                count++;
                if(count < B) cout << '#';
                else cout << '.';
            }
        }
        cout << endl;
    }
    return 0;
}

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


int main()
{
  int a,b;
  cin >> a >> b;
  int dif,sum;
  dif = b - a;
  sum = 0;
  for(int i = 1;i <=dif;i++){
    sum += i;
  }
  cout << (sum-b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef pair<int, int> P;
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

string str;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(cin >> str){
		char a[3][3];
		bool ok = false;
		rep(u,3) rep(k,3) a[u][k] = str[u*3+k];
		if(a[0][0]==a[1][1]&&a[1][1]==a[2][2]&&a[0][0]!='s'){
			if(a[0][0]=='o') cout << "o" << endl;
			else cout << "x" << endl;
			continue;
		}
		if(a[2][0]==a[1][1]&&a[1][1]==a[0][2]&&a[2][0]!='s'){
			if(a[2][0]=='o') cout << "o" << endl;
			else cout << "x" << endl;
			continue;
		}
		rep(j,3){
			if(a[j][0]==a[j][1]&&a[j][1]==a[j][2]&&a[j][0]!='s'){
				ok = true;
				if(a[j][0] == 'o') cout << "o" << endl;
				else cout << "x" << endl;
				break;
			}
			if(a[0][j]==a[1][j]&&a[1][j]==a[2][j]&&a[0][j]!='s'){
				ok = true;
				if(a[0][j] == 'o') cout << "o" << endl;
				else cout << "x" << endl;
				break;
			}
		}
		if(!ok) cout << "d" << endl;
	}
}

Measured memory_bytes: 1180
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int leftcount = 0;
		int rightcount = 0;
		for(int i=0; i<S.length(); i++) {
			char ch = S.charAt(i);
			if(ch == '(') {
				rightcount++;
			} else {
				if(rightcount>0) {
					rightcount--;
				} else {
					leftcount++;
				}
			}
		}
		String leftp = "";
		String rightp = "";
		for(int i=0; i<leftcount; i++) {
			rightp += "(";
		}
		for(int i=0; i<rightcount; i++) {
			leftp += ")";
		}
		System.out.println(rightp + S + leftp);
	}
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
}


Measured memory_bytes: 23636
# リスト内包表記
a = [[0 for i in range(10)] for k in range(3 * 4)]
for i in range(int(input())):
    b, f, r, v = map(int, input().split())
    a[(b-1)*3 + (f-1)][r-1] += v
for idx, i in enumerate(a):
    if idx % 3 == 0 and idx != 0:
        for k in range(20):
            print("#", end = "")
        print("")
    print(" ", end = "")
    print(" ".join(map(str, i)))


Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <map>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9

int dp[128][128]; //[node][kane]
int node[128][128]; //distance
int enemy[128][128];

int main(){
	int n,m,l;
	while(scanf("%d%d%d",&n,&m,&l),n|m|l){
		rep(i,128)rep(j,128){
			dp[i][j]=INT_MAX; node[i][j]=enemy[i][j]=INT_MAX;
		}
		rep(i,m){
			int a,b,c,d;
			scanf("%d%d%d%d",&a,&b,&c,&d);
			node[a][b] = node[b][a] = c;
			enemy[a][b] = enemy[b][a] = d;
		}
		dp[1][l] = 0;
		for(;;){
			bool flag = false;
			REP(i,1,n){
				rep(j,l+1)if( dp[i][j]!=INT_MAX ){
					REP(k,1,n+1)if( node[i][k]!=INT_MAX ){
						if( j>=node[i][k] && dp[k][j-node[i][k]]>dp[i][j] ){
							dp[k][j-node[i][k]] = dp[i][j];
							//printf("%d->%d ye_kane:%d  e:%d\n",i,k,j-node[i][k],dp[i][j]);
							flag = true;
						}
						if( dp[k][j]>dp[i][j]+enemy[i][k] ){
							dp[k][j] = dp[i][j]+enemy[i][k];
							//printf("%d->%d no_kane:%d  e:%d\n",i,k,j,dp[k][j]);
							flag = true;
						}
					}
				}
			}
			if( !flag )break;
		}
		int ans = INT_MAX;
		rep(i,l+1){
			//printf("%d,%d  : %d\n",n,i,dp[n][i]);
			ans=min(ans,dp[n][i]);
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

int main(){
  vector<vector<int>> v(3,vector<int>(3));
  rep(i,3){
    rep(j,3){
      cin>>v.at(i).at(j);
    }
  }
  
  int N;
  cin>>N;
  int ans;
  rep(l,N){
    cin>>ans;
  
  rep(i,3){
    rep(j,3){
      if(v.at(i).at(j)==ans){
        v.at(i).at(j)=0;
      }
    }
  }
  }
  string st="No";
  if(v.at(0).at(0)==0 && v.at(0).at(1)==0 && v.at(0).at(2)==0){
    st="Yes";
  }
  if(v.at(1).at(0)==0 && v.at(1).at(1)==0 && v.at(1).at(2)==0){
    st="Yes";
  }
  if(v.at(2).at(0)==0 && v.at(2).at(1)==0 && v.at(2).at(2)==0){
    st="Yes";
  }
  if(v.at(0).at(0)==0 && v.at(1).at(0)==0 && v.at(2).at(0)==0){
    st="Yes";
  }
  if(v.at(0).at(1)==0 && v.at(1).at(1)==0 && v.at(2).at(1)==0){
    st="Yes";
  }
  if(v.at(0).at(2)==0 && v.at(1).at(2)==0 && v.at(2).at(2)==0){
    st="Yes";
  }
  if(v.at(0).at(0)==0 && v.at(1).at(1)==0 && v.at(2).at(2)==0){
    st="Yes";
  }
  if(v.at(0).at(2)==0 && v.at(1).at(1)==0 && v.at(2).at(0)==0){
    st="Yes";
  }
  
  cout<<st<<endl;
}
     

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

int calc(int x,int y, int s){
  double a = (double)s/(x+100)*100;
  int b = ceil(a);
  if((int)floor((double)b*(x+100)/100) != s)return -100000;
  double c = (double)b*(y+100)/100;
  return (int)floor(c);
}

int main(){
  int x, y, S;

  while(cin >> x >> y >> S, x){
    int ans = 0;
    for(int s=1;s<S;s++){
      int tmp1 = calc(x,y,s), tmp2 = calc(x,y,S-s);
      if(ans < tmp1+tmp2){
	ans = tmp1 + tmp2;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
    int n;
    cin >> n;
    int ans, pmax=0, sum=0;
    for (int i=0; i<n; i++) {
        int tmp;
        cin >> tmp;
        pmax = max(tmp, pmax);
        sum += tmp;
    }
    ans = sum - pmax / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def main():
    LIST=[]

    while True:
        try:
            val=input().split()
            LIST=[]
            
            
            for v in val:
                flag=True
                for item in LIST:
                    if item[0]==v:
                        index=LIST.index(item)
                        flag=False

                if flag:
                    LIST.append([v,1])
                else:
                    LIST[index][1]+=1

            longest=""
            LIST=sorted(LIST,key=lambda x:x[1],reverse=True)
            for i in LIST:
                longest=i[0] if max(len(longest),len(i[0]))==len(i[0]) else longest

                
            ans=LIST[0][0]
            print("{0} {1}".format(ans,longest))

        except:
            break

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 7384
while p=gets
 a=p.chomp.to_i
 b=gets.chomp.to_i
 c=gets.chomp.to_i
 d=gets.chomp.to_i
 e=gets.chomp.to_i
 if b%d==0
  f=b/d
 else
  f=b/d+1
 end
 if c%e==0
  g=c/e
 else
  g=c/e+1
 end
 if f>=g
  h=f
 else
  h=g
 end
 i=a-h
 puts i.to_s
end

Measured memory_bytes: 6096
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)

// 素集合データ構造
struct UnionFind {
  // par[i]：データiが属する木の親の番号。i ==
  // par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i, n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) { return find(x) == find(y); }

  // データxが含まれる木の大きさを返す
  int size(int x) { return sizes[find(x)]; }
};

// 頂点a, bをつなぐコストcostの（無向）辺
struct Edge {
  int a, b, cost;

  // コストの大小で順序定義
  bool operator<(const Edge& o) const { return cost < o.cost; }
};

// 頂点数と辺集合の組として定義したグラフ
struct Graph {
  int n;            // 頂点数
  vector<Edge> es;  // 辺集合

  // クラスカル法で無向最小全域木のコストの和を計算する
  // グラフが非連結のときは最小全域森のコストの和となる
  int kruskal() {
    // コストが小さい順にソート
    sort(es.begin(), es.end());

    UnionFind uf(n);
    int min_cost = 0;

    rep(ei, es.size()) {
      Edge& e = es[ei];
      if (!uf.same(e.a, e.b)) {
        // 辺を追加しても閉路ができないなら、その辺を採用する
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }

    return min_cost;
  }
};

// 標準入力からグラフを読み込む
Graph input_graph() {
  Graph g;
  int m;
  cin >> g.n >> m;
  rep(i, m) {
    Edge e;
    cin >> e.a >> e.b >> e.cost;
    g.es.push_back(e);
  }
  return g;
}

int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > xpts(n);  // x,id
  vector<pair<int, int> > ypts(n);  // y,id

  for (int i = 0; i < n; i++) {
    int xtmp, ytmp;
    cin >> xtmp >> ytmp;
    xpts[i].first = xtmp;
    ypts[i].first = ytmp;
    xpts[i].second = i;
    ypts[i].second = i;
  }
  sort(xpts.begin(), xpts.end());
  sort(ypts.begin(), ypts.end());

  Graph g;

  int m = 2 * n - 2;
  g.n = n;

  for (int i = 0; i < n - 1; i++) {
    Edge e;
    int dist_x = xpts[i + 1].first - xpts[i].first;
    //cerr << xpts[i + 1].second << " " << xpts[i].second << " " << dist_x << endl;
    e.a = xpts[i + 1].second;
    e.b = xpts[i].second;
    e.cost = dist_x;
    g.es.push_back(e);
  }

  for (int i = 0; i < n - 1; i++) {
    Edge e;
    int dist_y = ypts[i + 1].first - ypts[i].first;
    //cerr << ypts[i + 1].second << " " << ypts[i].second << " " << dist_y << endl;
    e.a = ypts[i + 1].second;
    e.b = ypts[i].second;
    e.cost = dist_y;
    g.es.push_back(e);
  }

  cout << "" << g.kruskal() << endl;
  return 0;
}

Measured memory_bytes: 6388
n=int(input())

a=n
count=0
for i in range(11):
    if a-26**(i+1)>0:
        a-=26**(i+1)
        count+=1
    else:
        break

a-=1
#print(a)
#print(count)

ans=[]
for j in range(count):
#for j in range(i+1):
    ans.append(a//26**(count-j))
    a%=26**(count-j)
ans.append(a%26)

#print(ans)
m=len(ans)
#print(m)
letter=[]
for i in range(m):
    #print(ans[i])
    if i==m-1:
        letter.append(chr(97+ans[i]))
    else:
        letter.append(chr(97+ans[i]))

print(''.join(letter))


Measured memory_bytes: 9124
import collections

mittsu = input()
mittsulist = mittsu.split()

kawaisou_ck = str(collections.Counter(mittsulist).values())
result = "No"
if kawaisou_ck == "dict_values([1, 2])" or kawaisou_ck == "dict_values([2, 1])":
  result = "Yes"
  
print(result)

Measured memory_bytes: 3316
initial = list(map(int, input().split(" ")))
move_list=[]
for i in range(initial[1]):
    move_list.append(list(map(int,input().split(" "))))

#[ball_num, red_ball_exist]
contents_list = [[1, False] for i in range(initial[0]-1)]
contents_list.insert(0,[1,True])

for move in move_list:
    x_ball_num,x_red_ball_exist = contents_list[move[0]-1]
    if x_red_ball_exist:
        contents_list[move[1]-1][1] = True
        if x_ball_num == 1:
            contents_list[move[0]-1][1] = False


    contents_list[move[0]-1][0] -= 1
    contents_list[move[1]-1][0] += 1

cnt = 0
for content in contents_list:
    if content[1] == True:
        cnt += 1

print(cnt)


Measured memory_bytes: 34632
#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    int a[N], color[9];
    for(int i=0; i<9; i++){
        color[i] = 0;
    }
    for(int i=0; i<N; i++){
        scanf("%d", &a[i]);
        int k = a[i] / 400;
        if(k>8){ k = 8; }
        color[k]++;
    }

    int min = 0;
    for(int i=0; i<8; i++){
        if(color[i] != 0){
            min++;
        }
    }

    int max = min + color[8];

    if(min==0){
        min = 1;
    }
    printf("%d %d\n", min, max);

    return 0;
}


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

int main(){
  int N;
  int B = 0;
  string A;
  cin >> N;
   for(int i = 0 ; i < N ; i++){
   cin >> A;
   if(A == "Y"){
     cout << "Four" ;
     B=1;
     break;
   }
   i ++;
   }
   if(B != 1){
     cout << "Three" ;
   }
  
}

Measured memory_bytes: 256
char*p[]={"Wednes","Thurs","Fri","Satur","Sun","Mon","Tues"};
a[12]={3,1,3,2,3,2,3,3,2,3,2,3},m,d;
main(i){
    for(;~scanf("%d%d",&m,&d);){
        if(!m)return 0;
        for(i=0;i<m-1;d+=a[i++]);
        printf("%sday\n",p[d%7]);
    }
}

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


int main() 
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int value;

    if (A < C && B < D)
        value = B - C;
    if (A >= C && B < D)
        value = B - A;
    if (A >= C && B >= D)
        value = D - A;
    if (A < C && B >= D)
        value = D - C;
    if (B < C || D < A)
        value = 0;
    cout << value;

    return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::HashMap;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<usize> = read_as_vec();
    let (n, m) = (line[0], line[1]);
    let m: u64 = m as u64;
    let a: Vec<u64> = read_as_vec();


    let mut b: Vec<u64> = vec![0];
    let mut sum = 0;
    for elem in a{
        sum = (elem + sum) % m;
        b.push(sum);
    }
    /*
    let mut mod_hash = HashMap::new();
    let mut ans = 0;
    for elem in b{
        let x = mod_hash.entry(elem%m).or_insert(0);
        ans += *x;
        *x += 1;
    }
    println!("{}", ans);
     */

    /*
    let mut b = vec![0; n + 1];
    for i in 0..n {
        b[i + 1] = (b[i] + a[i]) % m;
    }
    */
    let mut map = std::collections::HashMap::new();
    let mut ans: u64 = 0;
    for i in 0..n + 1 {
        let x = map.entry(b[i]).or_insert(0);
        ans += *x;
        *x += 1;
    }
    println!("{}", ans);
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl

int32_t main() {

    int a, b; cin >> a >> b;

    if(a <= 5) b = 0;
    else if(a <= 12) b /= 2;

    cout << b << endl;
    
    return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
ans = 0
if x == 1 :
    ans += 300000
elif x == 2:
    ans += 200000
elif x == 3:
    ans += 100000
if y == 1 :
    ans += 300000
elif y == 2:
    ans += 200000
elif y == 3:
    ans += 100000
if x == 1 and y == 1:
    ans += 400000
print(ans)

    

Measured memory_bytes: 38384
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

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

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var s, c string
var q, t, f int

func main() {
	sc.Split(bufio.ScanWords)
	s = nextStr()
	q = nextInt()

	head := make([]byte, 0, pow(10, 6))
	tail := make([]byte, 0, pow(10, 6))

	//反転する回数
	//奇数なら逆順になっている
	r := 0
	for i := 0; i < q; i++ {
		t = nextInt()
		if t == 1 {
			r++
		} else {
			f, c = nextInt(), nextStr()
			if f == 1 {
				if r%2 == 0 {
					head = append(head, c[0])
				} else {
					tail = append(tail, c[0])
				}
			} else {
				if r%2 == 0 {
					tail = append(tail, c[0])
				} else {
					head = append(head, c[0])
				}
			}
		}
	}

	if r%2 == 1 {
		s = reverse(s)
		s = reverse(string(tail)) + s + string(head)
	} else {
		s = reverse(string(head)) + s + string(tail)
	}

	fmt.Println(s)
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
void calc_comb(vector<vector<long long>> &v){
    rep(i,v.size()){
        v[i][0]=1;
        v[i][i]=1;
    }
    for(int i=1; i<v.size(); i++){
        for(int j=1; j<i; j++){
            v[i][j]=(v[i-1][j-1]+v[i-1][j]);
            v[i][j]%=(ll)1e9+7;
        }
    }
}
int main(){
    string S;
    cin>>S;
    bool ok=true;
    int cnt=0;
    for(int i=0; i<S.size()/2; i++){
        if(S[i]!=S[S.size()-i-1]){
            if(S[i]!='x' && S[S.size()-i-1]!='x') ok=false; 
            if(S[i]=='x'){ S.insert(S.end()-i,'x'); cnt++; }
            else{ S.insert(S.begin()+i,'x'); cnt++; }
        }
    }
    if(ok) cout<<cnt<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,m,x,nw[22],c[22],a[22][22],ans=1e9,ct;
int main()
{
	cin>>n>>m>>x;
	for(int i=0;i<n;i++)
	{
		cin>>c[i];
		for(int j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<(1<<n);i++)
	{
		ct=0;
		for(int j=0;j<m;j++)
		{
			nw[j]=0;
		}
		for(int j=0;j<n;j++)
		{
			if((i>>j)&1==1)
			{
				ct+=c[j];
				for(int k=0;k<m;k++)
				{
					nw[k]+=a[j][k];
				}
			}
		}
		bool ok=true;
		for(int j=0;j<m;j++)
		{
			if(nw[j]<x)
			{
				ok=false;
				break;
			}
		}
		if(ok)
		{
			ans=min(ans,ct);
		}
	}
	if(ans==1e9)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3636
N = int(input())
lineA = input().split()
lineB = input().split()
lineC = input().split()
A = [0] * N
B = [0] * N
C = [0] * (N-1)
for i in range(N):
    if i<N-1:
        A[i] = int(lineA[i])
        B[i] = int(lineB[i])
        C[i] = int(lineC[i])
    else:
        A[i] = int(lineA[i])
        B[i] = int(lineB[i])

ans = sum(B)
for i in range(0, N-1):
    if A[i+1] == A[i] + 1:
        ans += C[A[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define dump(x) cerr << #x << " = " << (x) << endl
using namespace std;

int x, a, b;

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

    cin >> x >> a >> b;

    if (abs(x - a) > abs(x - b))
    {
        cout << "B" << endl;
    }
    else
    {
        cout << "A" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        double l=0;
  		int[] x=new int[n];
  		int[] y=new int[n];
  		for(int c=0;c<n;c++){
    		x[c]=sc.nextInt();
          	y[c]=sc.nextInt();
    	}
    	
  		for(int c=0;c<n;c++){
          for(int d=c+1;d<n;d++){
            l+=Math.sqrt(Math.pow(x[c]-x[d],2)+Math.pow(y[c]-y[d],2));
          }
        }
 	   double ans=l*2/n;

    	System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
#define MOD 1e9 + 7
#define N 1e5 + 10
struct res
{
	string name;
	ll score;
	ll index;
};
bool cmp(res a,res b)
{
	if(a.name<b.name)
		return true;
	else if(a.name>b.name)
		return false;
	else
	{
		if(a.score>b.score)
			return true;
		else
			return false;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	res r[n];
	ll i=0;
	for(i=0;i<n;i++)
	{
		cin>>r[i].name>>r[i].score;
		r[i].index=i+1;
	}
	sort(r,r+n,cmp);
	for(i=0;i<n;i++)
	{
		cout<<r[i].index<<"\n";
	}
}	

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

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;

bool ok(int n);

int main()
{
    int n;
    cin >> n;
    vector<int> num(n);
    rep(i, n) {
        cin >> num[i];
    }
    int ret = -1;
    rep(i, n) {
        for (int j = i + 1; j < n; j++) {
            int tmp = num[i] * num[j];
            if (ok(tmp)) {
                ret = max(ret, tmp);
            }
        }
    }
    cout << ret << endl;
    return 0;
}

bool ok(int n)
{
    string a = to_string(n);
    for (int i = 1; i < a.length(); i++) {
        if (a[i-1] + 1 != a[i]) {
            return false;
        }
    }
    return true;
}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a[3];
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
if(a[0]==5&&a[1]==5&&a[2]==7)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>

struct edge
{
	int idx;
	int dst;
	int clr;
};

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

	std::vector<std::vector<edge>> graph(n);

	for(int i=0; i<n-1; i++){
		int tmp1, tmp2;
		std::cin>>tmp1>>tmp2;

		graph[tmp1-1].push_back({i, tmp2-1, -1});
		graph[tmp2-1].push_back({i, tmp1-1, -1});
	}

	int color=0;
	for(int i=0; i<n; i++)
		color= std::max(color, (int)graph[i].size());

	std::vector<int> prev(n, -1);

	std::queue<int> q;

	q.push(0);

	std::vector<edge> ansList;

	while(!q.empty()){
		int cur= q.front();
		q.pop();
		int curColor=(prev[cur]+1)%color;;

		prev[0]= 9999999;

		for(int i=0; i<graph[cur].size(); i++){			
			if(prev[graph[cur][i].dst]==-1){
				q.push(graph[cur][i].dst);
				graph[cur][i].clr= curColor;				
				prev[graph[cur][i].dst]= curColor;
				ansList.push_back({graph[cur][i].idx, graph[cur][i].dst, graph[cur][i].clr});
				curColor= (curColor+1)%color;
			}			
		}

	}


	std::sort(ansList.begin(), ansList.end(), [](edge &x, edge &y){return x.idx < y.idx;});

	std::cout<<color<<std::endl;
	for(int i=0; i< ansList.size(); i++)
		std::cout<<ansList[i].clr+1<<std::endl;


	return 0;
}

Measured memory_bytes: 8844
n, m = gets.chomp.split(" ").map(&:to_i)
res = Array.new(m, 0)
n.times do
    inputs = gets.chomp.split(" ").map(&:to_i)
    k = inputs.shift
    inputs.each do |a|
        res[a-1] += 1
    end
end
puts res.select{|x| x == n}.size

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

#define NMAX 2000001

void CountingSort (int *,int *,int);
int n;

int main (void)
{
  int *a,*b,i,k,result;
  
  //input
  scanf ("%d",&n);

  //ヒープメモリ確保
  a = malloc(sizeof(int) * NMAX);
  b = malloc(sizeof(int) * NMAX);

  //input
  for (i = 1 ; i <= n ; i++){
    scanf ("%d",&a[i]);
  }

  //CountingSort関数で用いるC[i]の要素数の決定
  k = 0;
  for (i = 1 ; i <= n ; i++){
    if (k < a[i])
      k = a[i];
    }

  //CountingSort関数へ移動
    CountingSort (a,b,k);

  //output
  for (i = 1 ; i <= n ; i++){
    printf ("%d",b[i]);
    if (i < n)
      printf (" ");
    else
      printf ("\n");
  }

  //ヒープメモリ解放
  free(a);
  free(b);

  return 0;
}

void CountingSort (int *a,int *b,int k)
{
  int i,j,*c;

  //ヒープメモリ確保
  c = malloc(sizeof(int) * k);

  for (i = 0 ; i <= k ; i++){
    c[i] = 0;
  }

  //C[i] に i の出現数を記録する
  for (j = 1 ; j <= n ; j++){
    c[a[j]]++;
  }

  //C[i] に i 以下の数の出現数を記録する
  for (i = 1 ; i <= k ; i++){
    c[i] = c[i] + c[i-1];
  }

  for (j = n ; j >= 1 ; j--){
    b[c[a[j]]] = a[j];
    c[a[j]]--;
  }

  //ヒープメモリ解放
  free(c);

  return;
}

Measured memory_bytes: 16124
#include<bits/stdc++.h>
using namespace std;
int a[11];
bool isvalid(int x){
    while(x>0){
    int dig=x%10;
    if(a[dig])
        return false;
    x/=10;
  }
  return true;
}
int main()
{
    //freopen("i.txt","r",stdin);
    int b,n,k;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>b;
        a[b]++;
    }
    int j=n,f=0;
    while(1){
        if(isvalid(j)){
            break;
        }
        j++;
    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 3580
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        // 引数を取得
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        sc.close();

        // DP 配列全体を「DP の種類に応じた初期値」で初期化
        int[] dp = new int[n];
        for (int i = 0; i < n; i++) {
            dp[i] = Integer.MAX_VALUE;
        }

        // 初期条件を入力
        dp[0] = 0;

        // ループを回す
        for (int i = 1; i < n; i++) {
            int a = dp[i - 1] + Math.abs(h[i] - h[i - 1]);
            if (dp[i] > a) {
                dp[i] = a;
            }

            if (i > 1) {
                int b = dp[i - 2] + Math.abs(h[i] - h[i - 2]);
                if (dp[i] > b) {
                    dp[i] = b;
                }
            }
        }

        // テーブルから解を得て出力
        System.out.println(dp[n - 1]);
    }
}


Measured memory_bytes: 52120
N,x = map(int,input().split())
A = [0] + [int(a) for a in input().split()]

ans = 0
for i in range(N):  
    if A[i] + A[i+1] >= x:
        ans += A[i] + A[i+1] - x
        A[i+1] -= A[i] + A[i+1] -x
print(ans)


Measured memory_bytes: 14052
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,k;cin>>n>>k;
    ll r,s,p;cin>>r>>s>>p;
    string t;cin>>t;
    ll d[3]={p,r,s};
    char g[3]={'r','s','p'};
    ll res=0;
    vector<char> l;
    rep(i,n){
        char c=t[i];
        rep(j,3){
            if(c==g[j]){
                if(i<k||l[i-k]!=g[j]){
                    res+=d[j];
                    l.push_back(c);
                }else{
                    l.push_back('n');
                }
            }
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,n,h) for(int i = n; i < h; ++i)
#define rep3(l,n,h) for(int l = n; l <= h; ++l)
typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main(void) {
    int x,ans = 0,res;
    cin >> x;
    for(int i = 1; i <= x; ++i) {
        for(int j = 2; j <= x+1; ++j) {
             res = pow(i,j);
            if (res <= x) ans = max(ans, res);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <assert.h>
#include <algorithm>

int main(){
    int32_t N;
    std::cin >> N;
    assert(1 <= N);
    
    std::vector<int32_t> H(N);
    for(auto& i : H){
        std::cin >> i;
    }

    int32_t cnt = 0;
    int32_t max_cnt = 0;
    for(int32_t i = 1; i < N; i++){
        if(H[i-1] >= H[i]){
            cnt++;
        }
        else{
            max_cnt = std::max(max_cnt, cnt);
            cnt = 0;
        }
    }
    max_cnt = std::max(max_cnt, cnt);
    std::cout << max_cnt;

    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int search(int beg, int end, int value, vector<int> seq)
{

  int mid = -1;
  while (end - beg > 1) {
    mid = (beg + end) / 2;
    if (seq[mid] == value) { return mid; }
    else if (value < seq[mid]) {
      end = mid;
    }
    else {
      beg = mid;
    }
  }
  if (value <= seq[beg]) { return beg; }
  else { return end; }
}

int solve(vector<int> a)
{
  int n = a.size();
  vector<int> seq;
  seq.push_back(a[0]);
  for (int i = 1; i < n; ++i) {
    if (a[i] > seq.back()) {
      seq.push_back(a[i]);
    }
    else {
      int pos = search(0, seq.size() - 1, a[i], seq);
      seq[pos] = a[i];
    }
  }
  return seq.size();
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%d", &a[i]);
  }
  int ans = solve(a);
  fprintf(stdout, "%d", ans);
  fprintf(stdout, "\n");
  return 0;
}

Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 998244353
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi > 
const int N=200010;

int main()
{
	ll a,b;
	cin>>a>>b;
	int res=0,x=1;
  	while(x<b)
    {
      res++;
      x+=a-1;
    }
  cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    string L;
    cin >> L;
    int N = L.length();
    vector<int> B(N);
    for (int i = 0; i < N; ++i)
    {
        B[i] = L[i] - '0';
    }

    vector<vector<LLONG>> dp(N, vector<LLONG>(2));
    int F = 0, S = 1;
    dp[0][F] = 1, dp[0][S] = 2;
    const LLONG M = 1000000007;
    for (int i = 1; i < N; ++i)
    {
        if (L[i] == '1')
        {
            dp[i][S] = (dp[i - 1][S] * 2) % M;
            dp[i][F] = (dp[i - 1][S] * 1 + dp[i - 1][F] * 3) % M;
        }
        else if (L[i] == '0')
        {
            dp[i][S] = (dp[i - 1][S] *1 ) % M;
            dp[i][F] = (dp[i - 1][F] * 3) % M;
        }
    }
    cout << (dp[N - 1][S] + dp[N - 1][F]) % M << endl;
}


Measured memory_bytes: 6272
//https://atcoder.jp/contests/abc070/tasks/abc070_c
//C - Maltiple Clocks
//最小公倍数
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int N;
vector<ll> times;

ll gcd(ll a, ll b) {
    ll maxnum = a > b ? a : b;
    ll minnum = a > b ? b : a;
    if (!(maxnum%minnum)) return minnum;
    else return gcd(minnum, maxnum%minnum);
}

ll lcm(ll a, ll b) {
    ll g = gcd(a,b);
    return a/g*b;          //a*b先にするとオーバーフローする
}

int main() {
    cin >> N;
    times.resize(N);
    for (int i = 0; i < N; i++) scanf("%Ld", &times[i]);
    for (int i = 1; i < N; i++) {
        times[0] = lcm(times[0], times[i]);
    }
    cout << times[0] << endl;
    return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int i,n,c=0,j,c1=0;
    cin>>n;
    for(i=0;i<n;++i)
    {
        cin>>j;
        if(j%2==0)
        {
            ++c;
            if(j%3==0 || j%5==0)
                ++c1;
        }
    }
    if(c==c1)
        cout<<"APPROVED";
    else
        cout<<"DENIED";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;

vector <pii> F[330];
int D[2][310][310][310];
const int MOD = 1e9 + 7;

void solve(){
	int n, m; scanf("%d%d", &n, &m);
	rep(i, m){
		int l, r, v; scanf("%d%d%d", &l, &r, &v);
		F[r].pb(pii(v, l));
	}
	D[0][0][0][0] = 1;
	int ans = 0;
	for(int i=1;i<=n;i++) {
		int t = i & 1;
		for(int a=0;a<=i;a++) for(int b=0;b<=i;b++) {
			int lc = 0;
			if(a != i && b != i) lc = i;
			for(int c=lc;c<=i;c++) D[t][a][b][c] = 0;
		}
		for(int a=0;a<i;a++) for(int b=0;b<i;b++) {
			int lc = 0;
			if(a != i-1 && b != i-1) lc = i-1;
			for(int c=lc;c<i;c++){
				D[t][i][b][c] = (D[t][i][b][c] + D[!t][a][b][c]) % MOD;
				D[t][a][i][c] = (D[t][a][i][c] + D[!t][a][b][c]) % MOD;
				D[t][a][b][i] = (D[t][a][b][i] + D[!t][a][b][c]) % MOD;
			}
		}
		for(int a=0;a<=i;a++) for(int b=0;b<=i;b++) {
			int lc = 0;
			if(a != i && b != i) lc = i;
			for(int c=lc;c<=i;c++) {
				for(pii e : F[i]) {
					int cnt = (a >= e.Se) + (b >= e.Se) + (c >= e.Se);
					if(cnt != e.Fi) D[t][a][b][c] = 0;
				}
				if(i == n) ans = (ans + D[t][a][b][c]) % MOD;
			}
		}
	}
	printf("%d\n", ans);
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
};


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  cin>>N;
  int data[200][3];
  REP(i, N)REP(j, 3) cin>>data[i][j];
  int ans[200] = {};
  REP(j, 3){
    int cnt[101] = {};
    REP(i, N) cnt[data[i][j]]++;
    REP(i, N) if(cnt[data[i][j]] <= 1) ans[i] += data[i][j];
  }
  REP(i, N) cout<<ans[i]<<endl;
  return 0;
}

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

int main(){
    int n; cin >> n;
    vector<int> x(n),y(n);
    for(int i=0;i<n;++i) cin >> x[i] >> y[i];
    double sum = 0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            sum += sqrt(pow(x[j]-x[i],2) + pow(y[j] - y[i],2));          
        }
    }
    double ans = 2*sum/n;
    cout << fixed << setprecision(30) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <sstream>
#include <complex>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
#define ll long long
#define ull unsigned long long

const int MAXN = 100005;
const int INF = 0x3f3f3f3f;
const ll INFLL = 9223372036854775807;
const int MOD = 1e9 + 7;
const double PI=2.0*asin(1.0);

int X, A, B;

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	while(~scanf("%d %d %d", &X, &A, &B)){
		if(B-X>A) puts("dangerous");
		else if(B>A) puts("safe");
		else puts("delicious");
	}

	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n; cin>>n;
  vector<ll> xs(n);
  vector<ll> ys(n);
  vector<ll> hs(n);
  rep(i,n) {
    cin>>xs[i]>>ys[i]>>hs[i];
  }
  bool f = true;
  rep(i,n) {
    f = f && (hs[i]==0);
  }
  if(f) {
    rep(cx,101) {
      rep(cy,101) {
        rep(i,n) {
          if(cx!=xs[i]||cy!=ys[i]) {
            cout << cx << " " << cy << " " << 1 << endl;;
            return 0;
          }
        }
      }
    }
  }
  rep(cx,101) {
    rep(cy,101) {
      ll H;
      rep(i,n) {
        if(hs[i]>0) {
          H = hs[i]+abs(xs[i]-cx)+abs(ys[i]-cy);
          break;
        }
      }
      rep(i,n) {
        if(hs[i]!=max(H-abs(xs[i]-cx)-abs(ys[i]-cy),0LL)) {
          goto FAIL;
        }
      }
      cout << cx << " " << cy << " " << H << endl;
      return 0;
      FAIL:
      ;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        System.out.println(s.next().charAt(0)+""+s.next().charAt(0)+""+s.next().charAt(0));


    }



}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25384
while True:
  a,op,b = input().split()
  a = int(a)
  b = int(b)
  if op == "+":
   print(a+b)
  elif op == "-":
   print(a-b)
  elif op == "*":
   print(a*b)
  elif op == "/":
   print(int(a/b))
  else :
    break


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

#define REP(i, s, e) for(int i = (int)(s); i < (int)(e); ++i)
#define rep(i, n) REP(i, 0, n)

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> used(n+1);
  vector<int> ans;
  ans.reserve(n+1);
  vector<int> a(m);
  rep(i, m) cin >> a[i];
  rep(i, m) {
    int b = a[m-1-i];
    if(used[b] == 0) {
      ans.push_back(b);
      used[b]++;
    }
  }
  rep(i, n) {
    if(used[i+1] == 0) ans.push_back(i+1);
  }
  rep(i, ans.size()) {
    cout << ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 4620
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

int main()
{
	int m,d;
	ll ans=0;
	cin>>m>>d;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=d;j++)
		{
			int d1=j%10;int d10=j/10;
			if(d1>=2 && d10>=2 && d1*d10==i)
				ans++;
		}
	}
	cout<<ans<<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 n=sc.nextInt();
		int m=sc.nextInt();
		
		ArrayList<Integer>[] list=new ArrayList[n+1];
		for(int i=0;i<n+1;i++){
			list[i]=new ArrayList();
		}
		
		for(int i=0;i<m;i++){
			int a=sc.nextInt()-1;
			int b=sc.nextInt()-1;
			list[a].add(b);
			list[b].add(a);
		}
		

		int[] dist=new int[n];
		int[] ans=new int[n];
		
		Arrays.fill(dist,-1);
		
		Deque<Integer> q = new ArrayDeque<>();
		q.add(0);
		dist[0]=0;
		
		while(!q.isEmpty()){
			int i=q.poll();
			for (int j = 0; j < list[i].size(); j++) {
                int v = list[i].get(j);
                if(dist[v]<0){
                	dist[v]=dist[i]+1;
                	ans[v]=i;
                	q.add(v);
        		}
			}
		}
		
		System.out.println("Yes");
		
		
		for(int i=1;i<n;i++){
			System.out.println(ans[i]+1);
		}
	}
}

Measured memory_bytes: 75176
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define INF 1e9 + 1
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PF pop_front
#define PP pop_back
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	LL c;
	while (a != 0) {
		c = a;
		a = b % a;
		b = c;
	}
	return b;
}
int LCM(int a, int b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		printf("%d ", 2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			printf("%d ", i);
			n /= i;
		}
	}
	if (n > 2)printf("%d ", n);
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	string s;
	cin >> s;
	int n = (int)s.size();
	int val = 753;
	int ans = INF;
	for (int i = 0; i < n - 2; i++)
	{
		string temp = "";
		for (int j = i; j < 3+i; j++)
		{
			temp += s[j];
		}
		int v = stoi(temp, NULL, 10);
		ans = min(ans, abs(val - v));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main (String[] args){
		int H;
	    int W;
	    ArrayList<String> strList = new ArrayList<String>();
	    Scanner scan = new Scanner(System.in);
	    H = Integer.parseInt(scan.next());
	    W = Integer.parseInt(scan.next());
	    scan.nextLine();

	    for(int i = 0; i < H; i++ ){
	    	strList.add(scan.nextLine());
	    }

	    for(int i = 0; i < W+2; i++){
	    	System.out.print("#");
	    }
	    System.out.println("");

	    for(String str : strList){
	    	System.out.println("#" + str + "#");
	    }

	    for(int i = 0; i < W+2; i++){
	    	System.out.print("#");
	    }
	    System.out.println("");

	}
}

Measured memory_bytes: 22996