akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int n, x, t = 0, c = 0;
	int a[110];
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int i = 0;
	while(t<=x){
		t += a[i];
		c++; i++;
	}
	cout << c << endl;
}

Measured memory_bytes: 384
n = int(input())
t = list(map(int, input().split()))
m = int(input())
px = []
for i in range(m):
    px.append(list(map(int, input().split())))
for i in range(m):
    ans = 0
    for j in range(n):
        if px[i][0] == j+1:
            ans += px[i][1]
        else:
            ans += t[j]
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    int N;
    cin >> N;
    vector<int> v;
    
    int n;
    REP(i,N) {
        cin >> n;
        v.pb(n);
    }

    VSORT(v);

    int prev = 0;

    int kind = 0;

    REP(i,N) {
        if (prev != v[i]) {
            kind++;
            prev = v[i];
        }
    }
    if ((N-kind) % 2 == 1) {
        cout << kind - 1 << endl;
    } else {
        cout << kind << endl;
    }

    return 0;
}


Measured memory_bytes: 892
#include <iostream>
using namespace std;
int main(){
long long int a; long long int b;
long long int tou[1000];
cin >> a>> b;
long long int c=b-a;
long long int cnt=0;
for(int i=1;i<=999;i++){
  cnt+=i;
  tou[i-1]=cnt;
}
long long int ans;
ans=tou[c-1]-b;
cout << ans<<endl;
}


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

#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long

int main(void)
{
    int a,b,c; cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}

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

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

vector<int> to[200005];

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> ans(n + 1, 0);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	queue<int> que;
	que.push(1);
	while (!que.empty()) {
		int v = que.front();
		que.pop();
		for (auto next : to[v]) {
			if (ans[next] != 0) continue;
			ans[next] = v;
			que.push(next);
		}
	}
	cout << "Yes" << endl;
	for (int i = 2; i <= n; ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 12516
import java.util.*;

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();
        
        if(a < b && b < c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)

//変数
int N,A,B;

//解法
void solve() {

	if (N == 1) {
		cout << "Hello World";
	}
	if (N == 2) {
		cin >> A >> B;
		cout << A + B;
	}


	return;
}

int main() {
	//入力
	cin >> N;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define MAX 100
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef pair<int,int> P;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
int imap[MAX][MAX];
int h,w,ans;
P gp;

void Display(string s,P p){
  cout << s << " = P(" << p.first << "," << p.second << ")" << endl;
}

/*
void dmap(){
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout << imap[i][j] << " ";
    }
    cout << endl;
  }
}
*/

P dir(P now,P dir){
  while(true){
    now.first += dir.first;
    now.second += dir.second;
 
    if(!(0<=now.first && now.first<w && 0<=now.second && now.second<h) && now != gp){
      return P(-1,-1);
    }
    else if(imap[now.second][now.first] == 1){
      imap[now.second][now.first] = 0;
      return P(now.first-dir.first,now.second-dir.second);
    }
    else if(now == gp){
      return P(999,999);
    }
  }
}


bool solve(P xy,int counter){
  if(counter > 10){
    return false;
  }
  if(xy == gp){
    ans = min(ans,counter);
    return true;
  }
  int cpymap[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)cpymap[i][j] = imap[i][j];
  }


  for(int i=0;i<4;i++){
    if(imap[xy.second + dy[i]][xy.first + dx[i]] == 1){
      continue;
    }
    P nowP = dir(xy,P(dx[i],dy[i]));
    //Display("xy",xy);
    //cout << "dir = P(" << dx[i] << "," << dy[i] << ")" << endl;
    //Display("nowP",nowP);
    if(nowP == P(999,999)){
      ans = min(ans,counter);
    }
    else if(nowP != P(-1,-1)){
      solve(nowP,counter+1);
      for(int i=0;i<h;i++){
	for(int j=0;j<w;j++)imap[i][j] = cpymap[i][j];
      }
    }   
  }

  return false;
}


int main(){
  P sp;
  while(cin >> w >> h && h && w){
    ans = 1<<30;
    rep(i,h){
      rep(j,w){
	cin >> imap[i][j];
	if(imap[i][j] == 2){
	  sp.first = j;
	  sp.second = i;
	  imap[i][j] = 0;
	}
	else if(imap[i][j] == 3){
	  gp.first = j;
	  gp.second = i;
	  imap[i][j] = 0;
	}
      }
    }

    solve(sp,1);
    //dmap();
    ans==(1<<30)?cout <<"-1"<<endl:cout <<ans<<endl;

  }

  return 0;
}

Measured memory_bytes: 896
using System;
using System.Collections;
using System.Linq;
class Program
{
    public static int Main()
    {
        int a = int.Parse(Console.ReadLine());
        //string[] s = Console.ReadLine().Split(' ');
        int b = int.Parse(Console.ReadLine());
        int c = int.Parse(Console.ReadLine());
        int d = int.Parse(Console.ReadLine());

        Console.WriteLine(Math.Min(a, b) + Math.Min(c, d));
        return 0;
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
int n;
ll a[maxx], b[maxx];
map <ll, int> mp;
map <ll, bool> vis;
ll ans;

int main() {
	while(cin >> n && n > 3) {
		mp.clear();
		vis.clear();
		for(int i = 1; i <= n; i++) cin >> a[i];
		for(int i = 1; i <= n; i++) mp[a[i]]++;
		int t = 0;
		for(int i = 1; i <= n; i++) {
			if(mp[a[i]] > 1 && !vis[a[i]]) {
				vis[a[i]] = 1;
				b[++t] = a[i];
			}
		}
		if(t == 0) ans = 0;
		else if(t == 1) {
			if(mp[b[1]] <= 3) ans = 0;
			else ans = b[1] * b[1];
		}
		else {
			sort(b + 1, b + t + 1);
			if(mp[b[t]] >= 4) ans = b[t] * b[t];
			else ans = b[t] * b[t - 1];
		}
		cout << ans << endl;
	}
}

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

int N;

int main() {
  cin >> N;
  int answer;
  for (int i = 0; i <= 10; i++) {
    if (pow(2, i) <= N) answer = pow(2, i);
    else break;
  }
  cout << answer << endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k = map(int,input().split())
data = [0] * (k+1)
for i in range(k,0,-1):
  tmp = pow(k//i,n,mod)
  for j in range(i+i,k+1,i):
    tmp -= data[j]
  data[i] = tmp % mod
ans = 0
for i,di in enumerate(data):
  ans += i * di
  ans %= mod
print(ans)
# print(data)

Measured memory_bytes: 69344
<?php
// Your code here!
fscanf(STDIN,"%d",$N);
fscanf(STDIN,"%s",$A);
fscanf(STDIN,"%s",$B);
fscanf(STDIN,"%s",$C);

$count=0;

if ($A==$B && $B==$C) echo "0\n";
else
{
for ($i=0;$i<$N;$i++)
{
 if ($A[$i]==$B[$i] && $B[$i]==$C[$i]);
 else if ($A[$i]!=$B[$i] && $B[$i]!=$C[$i] && $C[$i]!=$A[$i]) $count+=2;
 else if ($A[$i]==$B[$i] && $C[$i]!=$B[$i]&& $C[$i]!=$A[$i]) $count++;
 else if ($A[$i]==$C[$i] && $B[$i]!=$C[$i] && $B[$i]!=$A[$i]) $count++;
 else if ($B[$i]==$C[$i] && $A[$i]!=$C[$i] && $B[$i]!=$A[$i]) $count++;
}
echo $count."\n";
}

Measured memory_bytes: 3700
import Data.Bool

main :: IO ()
main = do
  { [n] <- readLineInputs
  ; putStrLn $ solve n
  }

{- |
>>> solve 432
"400"
>>> solve 1079
":("
>>> solve 1001
"927"
-}
solve :: Int -> String
solve n = bool ":(" (show n') (n == floor (fromIntegral n' * 1.08))
  where
    n' = ceiling $ fromIntegral n / 1.08

readLineInputs :: Read a => IO [a]
readLineInputs = map read . words <$> getLine


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll Inf = 1e18;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

class UnionFind {
    public:
        vector<int> rank, p, size;

        UnionFind() {}
        UnionFind(int s) {
            rank.resize(s, 0);
            p.resize(s, 0);
            size.resize(s, 0);
            rep (i, s) init(i);
        }

        void init(int x) {
            p[x] = x;
            rank[x] = 0;
            size[x] = 1;
        }

        bool isSame(int x, int y) {
            return root(x) == root(y);
        }

        void unite(int x, int y) {
            if (isSame(x, y)) return;
            link(root(x), root(y));
        }

        void link(int x, int y) {
            if (rank[x] > rank[y]) {
                p[y] = x;
                size[x] += size[y];
            } else {
                p[x] = y;
                size[y] += size[x];
                if (rank[x] == rank[y]) {
                    rank[y]++;
                }
            }
        }

        int root(int x) {
            if (x != p[x]) {
                p[x] = root(p[x]);
            }
            return p[x];
        }

        int getSize(int x) {
            return size[root(x)];
        }
};

struct edge {
    int source, target, cost;
    edge(int source = 0, int target = 0, int cost = 0): source(source), target(target), cost(cost) {}
    bool operator < (const edge &e) const {
        return cost < e.cost;
    } 
};

int kruskal(int N, vector<edge> edges) {
    int totalCost = 0;
    sort(edges.begin(), edges.end());

    UnionFind uf = UnionFind(N + 1);
    rep (i, N) uf.init(i);

    int source, target;
    rep (i, edges.size()) {
        edge e = edges[i];
        if (!uf.isSame(e.source, e.target)) {
            totalCost += e.cost;
            uf.unite(e.source, e.target);
        }
    }

    return totalCost;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<tuple<int, int, int> > s, t;
    rep (i, n) {
        int x, y;
        cin >> x >> y;
        s.emplace_back(x, y, i);
        t.emplace_back(y, x, i);
    }
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    vector<edge> v;
    FOR (i, 1, n) {
        int x1, x2, y1, y2;
        x1 = get<0>(s[i - 1]), y1 = get<1>(s[i - 1]);
        x2 = get<0>(s[i]), y2 = get<1>(s[i]);
        edge e;
        e.source = get<2>(s[i - 1]), e.target = get<2>(s[i]);
        e.cost = min(abs(x1 - x2), abs(y1 - y2));
        v.push_back(e);
    }
    FOR (i, 1, n) {
        int x1, x2, y1, y2;
        x1 = get<0>(t[i - 1]), y1 = get<1>(t[i - 1]);
        x2 = get<0>(t[i]), y2 = get<1>(t[i]);
        edge e;
        e.source = get<2>(t[i - 1]), e.target = get<2>(t[i]);
        e.cost = min(abs(x1 - x2), abs(y1 - y2));
        v.push_back(e);
    }
    cout << kruskal(v.size(), v) << endl;

    return 0;
}



Measured memory_bytes: 10280
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int MOD = 998244353;
const int MX = (int)1e6 + 10;

void add_self(int &x, int y, int md = MOD){x += y; if(x >= md) x -= md;}
void sub_self(int &x, int y, int md = MOD){x -= y; if(x < 0) x += md;}
void mul_self(int &x, int y, int md = MOD){x = x * 1LL * y % md;}
inline int mul(int x, int y, int md = MOD){return x * 1LL * y % md;}
inline int add(int x, int y, int md = MOD){x += y; if(x >= md) x -= md; return x;}
inline int sub(int x, int y, int md = MOD){x -= y; if(x < 0) x += md; return x;}

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

vector<int> read(int n, int k){
	vector<int> vec(n);
	for(int i = 0; i < k; ++i) cin >> vec[i];
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for(int i = k; i < n; ++i)
		vec[i] = (a * 1ll * vec[i - 2] + b * 1ll * vec[i - 1] + c) % d;
	return vec;
}

void solve(){
	int k;
	cin >> k;
	string res;
	while(k--){
		res += "ACL";
	}
	cout << res << "\n";
	return;
}

int main(){

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

	// freopen("input.in", "r", stdin);
	// freopen("output.out", "w", stdout);

	int t;
	t = 1;
	// cin >> t;
	// pre();
	for(int i = 1; i <= t; ++i){
		// cout << "Case #" << i << ": ";
		solve();
		// cout << '\n';
		// cout << endl;
	}

	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int value = 700;
    for (size_t i=0; i<S.size(); ++i) {
        if (S[i] == 'o') value += 100;
    }
    cout << value << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[0].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    string S; cin >> S;
    int cnt[3] = {0, 0, 0};
    REP(i, S.size()) cnt[S[i] - 'a']++;
    int M = max(max(cnt[0], cnt[1]), cnt[2]);
    int m = min(min(cnt[0], cnt[1]), cnt[2]);
    ANS(M - m <= 1);
    
    return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val P = readLine()!!.split(" ").map(String::toInt)

    var sum = 0
    for (i in 1 until N - 1) {
        val array = intArrayOf(P[i], P[i - 1], P[i + 1]).sortedArray()
        if (array[1] == P[i]) {
            sum++
        }
    }

    println(sum)

}

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

main(){
	while(true){
		int maxI=0, maxV=0;
		
		for(int i=0; i<5; ++i){
			int a,b,v;
			cin >> a >> b;
			if(a==0 &&b==0){
				return 0;
			}
			v = a+b;
			if( maxV < v ){
				maxI = i;
				maxV = v;
			}
		}
		
		printf("%c %d\n",'A'+maxI,maxV);
	}
}


Measured memory_bytes: 3136
def aaa(a, b):
    l = []
    for i in range(1, max(a,b)+1):
        if(a%i == 0 and b%i == 0):
            l.append(i)
    return l

a,b,k = (int(i) for i in input().split())

l = aaa(a,b)
print(l[-k])

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 234567;
vector<int> A, F;

bool check(LL ans, LL N, LL K) {
     for (int i = 0; i < N; i++) {
         LL quo = ans / F[i];
         LL need = A[i] - quo;
         if (need < 0) need = 0;
         if (need > K) return false;
         K -= need;
     }
     return true;
}

int main() {
    LL N, K;
    scanf("%lld %lld", &N, &K);
    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        A.push_back(tmp);
    }
    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        F.push_back(tmp);
    }
    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());
    LL l = 0, r = (LL)1e13;
    while (l < r) {
          LL mid = (l + r) / 2;
          if (check(mid, N, K)) r = mid;
          else l = mid + 1;
    }
    printf("%lld\n", l);
    return 0;
}


Measured memory_bytes: 2548
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {

		Solve s= new Solve();
		s.solve();

	}
}


class Solve{


	 public void solve() {
		 Scanner sc = new Scanner(System.in) ;
		 int A = sc.nextInt();
		 int P = sc.nextInt();
		 int res = 0;
		 res=(A*3+P)/2;
		 System.out.println(res);
		 
		 
		 }
}

Measured memory_bytes: 21844
import java.util.Scanner;
import java.util.Random;
import java.io.PrintWriter;

public class Main{
    public static Random rand = new Random();
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        long start = System.currentTimeMillis();
        int D = Integer.parseInt(sc.next());
        int[] C = new int[26];
        int[] L = new int[26];
        for (int i = 0; i < 26; i++){
            C[i] = Integer.parseInt(sc.next());
            L[i] = 0;
        }
        int[][] S = new int[D][26];
        int[] Ans = new int[D];
        for (int i = 0; i < D; i++){
            int maxS = 0;
            for (int j = 0; j < 26; j++){
                S[i][j] = Integer.parseInt(sc.next());
                if (S[i][j] > maxS){
                    maxS = S[i][j];
                    Ans[i] = j + 1;
                }
            }
        }
        int maxPoint = calcPoint(Ans, S, C, L, D);
        

        while (System.currentTimeMillis() - start < 1850){
            maxPoint = change(Ans, S, C, L, D, maxPoint, 1600 - (System.currentTimeMillis() - start));
        }

        for (int i = 0; i < D; i++){
            out.print(Ans[i]);
            out.print("\n");
        }
        //out.println(maxPoint);
        //template
        sc.close();
        out.flush();
    }

    public static int calcPoint(int[] Ans, int[][] S, int[] C, int[] L, int D){
        int point = 0;
        for (int i = 0; i < 26; i++){
            L[i] = 0;
        }
        for (int i = 0; i < D; i++){
            point += S[i][Ans[i] - 1];
            L[Ans[i] - 1] = i + 1;
            for (int j = 0; j < 26; j++){
                point -= C[j] * (i + 1 - L[j]);
            }
        }
        return point;
    }

    public static int change(int[] Ans, int[][] S, int[] C, int[] L, int D, int maxPoint, long t){
        int ci = rand.nextInt(D);
        int before = Ans[ci];
        Ans[ci] = rand.nextInt(26) + 1;
        int newPoint = calcPoint(Ans, S, C, L, D);
        if (newPoint < maxPoint){
            if (rand.nextInt(1900) < t){
                return newPoint;
            }
            else{
                Ans[ci] = before;
            return maxPoint;
            }    
        }
        else{
            return newPoint;
        }
    }
}


Measured memory_bytes: 42092
use proconio::{fastout, input};
use proconio::marker::*;

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      ab: [(Usize1, Usize1); m]
   }

   let mut to = vec![vec![]; n];
   for (a, b) in ab {
      to[a].push(b);
      to[b].push(a);
   }

   let mut q = std::collections::VecDeque::new();
   let mut d = vec![n; n];
   q.push_back((0, 0));
   d[0] = 0;
   while let Some((c, v)) = q.pop_front() {
      for &u in to[v].iter() {
         if d[u] == n {
            d[u] = c + 1;
            q.push_back((c+1, u));
         }
      }
   }
   println!("Yes");
   for v in 1..n {
      for &u in to[v].iter() {
         if d[v] == d[u] + 1 {
            println!("{}", u + 1);
            break;
         }
      }
   }
}


Measured memory_bytes: 15988
i = int(input())
i = i % 10
if i == 0:
    print('pon')
elif i == 1:
    print('pon')
elif i == 2:
    print('hon')
elif i == 3:
    print('bon')
elif i == 4:
    print('hon')
elif i == 5:
    print('hon')
elif i == 6:
    print('pon')
elif i == 7:
    print('hon')
elif i == 8:
    print('pon')
elif i == 9:
    print('hon')


Measured memory_bytes: 9124
#include <stdio.h>
#define LL long long
int main(){
	LL a,b,c,d;
	scanf("%lld%lld%lld",&a,&b,&c);
	d=c-(a+b);
	if(d<=0)printf("No\n");
	else{
		if(4*a*b<d*d)printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
n=int(input())
c=input()
wlist=[]
rlist=[]
cntw=0
cntr=0
for i in range(n):
  if c[i]=='R':
    rlist.append(i)
    cntr+=1
  else:
    wlist.append(i)
    cntw+=1
rlist.sort(reverse=True)
cnt=0
for j in range(min(cntw,cntr)):
  if rlist==[] or wlist==[]:
    break
  elif rlist[j]>wlist[j]:
    cnt+=1
print(cnt)

Measured memory_bytes: 17396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long LL;
#define rep(i ,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define all(v) (v).begin(),(v).end()
#define arycpy(ary1,ary2,N) memcpy(ary2,ary1,sizeof(int)*N) //ary1:???????????? ary2:????????????
typedef vector<int> vi;


int main(){
	int n, p;
	while (cin >> n >> p){
		if (n == 0&&p == 0) break;
		vi num(n, 0);
		int i = 0;
		int pp = p;
		while (1){

			if (p > 0){
				p--;
				num[i]++;
				if (p == 0 && num[i] == pp) break;
			} else{
				if (num[i] > 0){
					p += num[i];
					num[i] = 0;
				}
			}
			i++;
			i = i%n;
		}
		

		for (int j = 0; j < n; j++){
			if (num[j]==p){
				cout << i  << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

int main(){
    int N, x=0, i, max=0;
    char S[101];

    scanf("%d", &N);
    scanf("%s", S);

    for(i=0; i<N; i++){
        if(S[i] == 'I')
            x++;
        else
            x--;

        if(max < x)
            max = x;
    }

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

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

int main(){

    int A, B;
    cin >> A >> B;

    cout << (long long)A * B / gcd(A, B) << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def calc(a, b):
    if b == 0: return a
    if a == R: return b + R
    if b == C: return R + C + (R - a)
    if a == 0: return R + C + R + (C - b)

R, C, N = map(int, input().split())
A = []
for i in range(N):
    x1, y1, x2, y2 = map(int, input().split())
    if (x1 == 0 or x1 == R or y1 == 0 or y1 == C) and (x2 == 0 or x2 == R or y2 == 0 or y2 == C):
        A.append((calc(x1, y1), i))
        A.append((calc(x2, y2), i))

A = [l[1] for l in sorted(A, key = lambda x: x[0])]
B = []

while A:
    while len(B) and A[-1] == B[-1]:
        A.pop()
        B.pop()
    if A:
        B.append(A.pop())

print("NO" if len(B) else "YES")

Measured memory_bytes: 88280
a, b, c = map(int,input().split())

total = 0
mod_roop_list = []

def roop_checker(candidate):
    a_str = ''
    candidate_str = ''.join(candidate)
    for can in candidate:
        a_str = a_str + str(can)
        if a_str*5 in candidate_str:
            return True
    else:
        return False

while True:
    total += a
    if total%b == c:
        print('YES')
        break

    mod_roop_list.append(str(total%b))
    if roop_checker(mod_roop_list):
        print('NO')
        break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;

int main()
{
  int A[3],bb[101]={0},res=0;
  cin >> A[0] >> A[1] >> A[2];
  sort(A,A+3);
  REP(i,3)bb[A[i]]++;
  REP(i,101)if(bb[i])res++;
  cout << res << endl;  
  return 0;
}



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

int main(void) {
  ios::sync_with_stdio(false);
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  rep(i, N) { cin >> A[i]; }
  int max_len = K + A[0] - A[N - 1];
  for (int i = 1; i < N; ++i) {
    max_len = max(max_len, A[i] - A[i - 1]);
  }
  int answer = K - max_len;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a[100010];
int main()
{
	int n,i;
	long long ans=1;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		if(!a[i])
		{
			cout<<0;
			return 0;
		}
	}
	for(i=0;i<n;i++)
	{
		if(1000000000000000000ll/ans<a[i])
		{
			cout<<-1;
			return 0;
		}
		ans*=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4364
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    COMinit();

    srep(i,1,k+1){
        if(i==1){
            cout << n-k+1 << endl;
        }else if(n-k+1<i){
            cout << '0' << endl;
        }else{
            ll blue = COM(k-1,i-1)%MOD;
            ll red = 0;
            srep(j,-1,2){
                if(n-k-1<i+j-1)continue;
                red += COM(n-k-1,i+j-1);
                if(j==0)red += COM(n-k-1,i+j-1);
                red %= MOD;
            }
            ll ans = (red*blue) % MOD;
            cout << ans << endl;
        }
    }

    return 0;
}
 
 


Measured memory_bytes: 12160
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define pb(b) push_back(b) 
#define all(a) a.begin(),a.end()
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
const int mod=1e9+7;
/* 
UnionFind：素集合系管理の構造体(union by size)
isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
treeSize(x): x を含む集合の要素数。
*/
struct UnionFind{
 vector<int>size,parents;
 UnionFind(){}
 UnionFind(int n){//make n trees.
  size.resize(n,0);
  parents.resize(n,0);
  for(int i=0;i<n;i++)makeTree(i);
 }
 void makeTree(int x){
   parents[x]=x;//the parent of x is x
   size[x]=1;
  }
 bool isSame(int x,int y){return findRoot(x)==findRoot(y);}
 bool unite(int x,int y){
  x = findRoot(x);
  y = findRoot(y);
  if(x==y)return false;
  if(size[x]>size[y]){
   parents[y]=x;
   size[x]+=size[y];
  } 
  else{
   parents[x]=y;
   size[y]+=size[x];
  }
  return true;
 }
 int findRoot(int x){//木の根を探す,計算量削減のため低く
  if(x!=parents[x])parents[x]=findRoot(parents[x]);
  return parents[x];
 }
 int treeSize(int x){return size[findRoot(x)];}
};
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*迷路移動*/const int dx[4]={1,0,-1,0};const int dy[4]={0,1,0,-1};
llfor;////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 ll a;
 ll cnt[100010]={0};
 rep(i,0,n){
  cin>>a;
  cnt[a]++;
 }
  
 ll ans=0;
 rep(i,1,1e5+1){
  ans=max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
 }
 pr(ans);
return 0;}

Measured memory_bytes: 4416
import math
N=1000000007;
def ncr(n, r, p): 
    # initialize numerator 
    # and denominator 
    num = den = 1 
    for i in range(r): 
        num = (num * (n - i)) % p 
        den = (den * (i + 1)) % p 
    return (num * pow(den,  
            p - 2, p)+p) % p 



	
def power(base,e):
	if e==0:
		return 1
	ans=int(base)
	e=int(e)
	base=int(base)
	e=e-1
	while(e>0):
		if(e&1==1):
		    ans=(ans*base)%N
		base=(base*base)%N
		e=int(e/2)
	return ans%N



n,a,b=(map(int,input().split()));
ans=(power(2,n)-1-ncr(n,a,N)-ncr(n,b,N)+N)%N



print(ans)
print()

Measured memory_bytes: 3064
def gcd(a,b):
	return a if b==0 else gcd(b,a%b)

def lcm(a,b):
	return a*b/gcd(a,b)
	
while 1:
	a1,m1,a2,m2,a3,m3=map(int,raw_input().split())
	if a1==0:break
	x,y,z=a1%m1,a2%m2,a3%m3
	cx=cy=cz=1
	while x!=1:
		x=a1*x%m1
		cx+=1
	while y!=1:
		y=a2*y%m2
		cy+=1
	while z!=1:
		z=a3*z%m3
		cz+=1
	print reduce(lcm,[cx,cy,cz])

Measured memory_bytes: 4320
from statistics import median

N = int(input())
As = [0] * N
Bs = [0] * N

for i in range(N):
    As[i], Bs[i] = map(int, input().split())

med_A = median(As)
med_B = median(Bs)

if N%2:
    print(med_B-med_A+1)
else:
    print(int((med_B-med_A)*2)+1)


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

bool solve(int x, int y, int t){
  int check = x+y-t;
  if (check <= 0 && abs(check) % 2 == 0 ){
    return true;
  }
  else{
    return false;
  }
}

int main(){
  int x0=0;
  int y0= 0;
  int t0=0;
  int n, x, y, t;
  int x1=0;
  int y1=0;
  int t1=0;
  cin >> n;
  int c = 0;
  for(int i=0; i<n; i++){
    cin >> t >> x >> y;
    t1 = t;
    x1 = x;
    y1 = y;
    t = abs(t-t0);
    x = abs(x-x0);
    y = abs(y-y0);
    t0 = t1;
    x0 = x1;
    y0 = y1;
    if(solve(x, y, t)==true){
      c+= 1;
      continue;
    }
    else {
      break;
    }
  }
  if(c == n) {
    cout << "Yes";
  }
  else {
    cout <<"No";
  }
}


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

using namespace std;

int main(int argc, char *argv[]){
    string s1,s2="CODEFESTIVAL2016";
    cin>>s1;
    int a=0;
    for(int i=0;i<s1.length();i++){
        if(s1[i]!=s2[i])a++;
    }
    cout<<a<<endl;
    return 0;
}


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

int main() {
  int n,k;cin>>n>>k;
  int an[n];rep(i,n)cin>>an[i];
  sort(an,an+n);
  reverse(an,an+n);
  int sn=0;
  rep(i,k) sn+= an[i];
  cout<<sn;
}


Measured memory_bytes: 256
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
total = 0
for i in range(n+1):
  total += abs(a[i] - a[i+1])
for i in range(1,n+1):
  ans = total - abs(a[i+1] - a[i]) - abs(a[i] - a[i-1]) + abs(a[i+1] - a[i-1])
  print(ans)


Measured memory_bytes: 14040
from collections import defaultdict
MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))

d = defaultdict(int)
for ai in a:
    d[ai] += 1

if n % 2 == 0:
    ans = 1
    for i in range(n//2):
        j = 2*i + 1
        ans *= 2 if d[j] == 2 else 0
        ans %= MOD
else:
    ans = 1 if d[0] == 1 else 0
    for i in range(n//2):
        j = 2 * (i+1)
        ans *= 2 if d[j] == 2 else 0
        ans %= MOD

print(ans)


Measured memory_bytes: 14820
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

#include <stdio.h>

using ll = long long;
using namespace std;

vector<vector<bool>> v;

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;

    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   function<bool(const pair<int, int>, const pair<int, int>)>>
        q([](const pair<int, int>& l, const pair<int, int> r) {
            return l.second > r.second;
        });

    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        q.emplace(a, b);
    }

    pair<int, int> p = q.top();
    q.pop();
    int last = p.second;
    int ans = 1;
    while (!q.empty()) {
        p = q.top();
        q.pop();
        if (p.first < last) {
            continue;
        } else {
            ans++;
            last = p.second;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3868
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String[] s = new String[n];

    for(int i = 0; i < n; i++){
      String city = sc.next();
      double point = 1 / sc.nextDouble();
      int num = i + 1;
      s[i] = city + " " + point + " " + num;
    }

    Arrays.sort(s);

    for(int i = 0; i < n; i++){
      String ans = s[i].split(" ")[2];
      System.out.println(ans);
    }
  }
}


Measured memory_bytes: 23252
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n; cin>>n; 
    vi a(n),b(n);
    for (int &i: a) cin >> i ; 
    for (int &i: b) cin >> i ; 
    int ok = 0,s=0;
    for (int i=0;i<n;i++){
        s += max(0LL,(a[i]-b[i])*2);
        ok += max(0LL,(b[i]-a[i])/2); 
    }
    if ((ok >= s/2) or (s==0) ) printf("Yes\n");
    else printf("No\n");
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3780
#include<stdio.h>
int main()
{

    int a, b, k;
    scanf("%d %d %d", &a, &b, &k);
    int i;
    for (i = a; i <= b; i++)
        if (i - a < k || b - i < k)
            printf("%d\n", i);
    return 0;
}

Measured memory_bytes: 128
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    auto S = sread();
    long Q = lread();
    auto reverse = false;
    DList!char ans;
    foreach (c; S)
        ans.insertBack(c);
    foreach (_; 0 .. Q)
    {
        auto q = readln.split();
        if (q[0] == "1")
        {
            reverse = reverse == false;
            continue;
        }
        long f = q[1] == "2";
        auto c = q[2][0];
        if (f == reverse)
        {
            ans.insertFront(c);
        }
        else
        {
            ans.insertBack(c);
        }
    }
    if (reverse)
    {
        foreach_reverse (c; ans)
            write(c);
    }
    else
    {
        foreach (c; ans)
            write(c);
    }
    writeln();

}


Measured memory_bytes: 25944
from itertools import permutations
n=int(input())
l=[]
for i in range(n):
    x,y=map(int,input().split())
    l.append((x,y))
dist=[]
for ll in list(permutations(l)):
    d=0.0
    for i in range(len(ll)-1):
        d+=((ll[i][0]-ll[i+1][0])**2+(ll[i][1]-ll[i+1][1])**2)**0.5
    dist.append(d)
print(sum(dist)/len(dist))
        

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

int main(){
    long long n;
    long long h[110000];
    cin >> n;
    for(long long i = 0; i < n; i++) cin >> h[i];

   
    long long storedCount = 0;
    long long eachCount = 0;
    for(long long i = 0; i < n; i++){
        // cout << storedCount << eachCount << endl;
        if(storedCount < eachCount) storedCount = eachCount;
        //計算量てきにこれがないとTLE
        if(storedCount >= n - 1) break;
        eachCount = 0;
        for(long long j = i; j < n - 1; j++){
            if(h[j] >= h[j+1]) eachCount++;
            else {
                i += eachCount;
                break;

            }
        }
    }

    cout << storedCount << endl;

}

Measured memory_bytes: 1024
#include <stdio.h>
#include<map>
#include<vector>
using namespace std;

map<pair<int, int>, int> seen, dist;

int dfs(map<pair<int, int>, vector<pair<int, int>>> &edge, pair<int, int> now)
{
	if (seen[now] == 2)
		return dist[now];
	seen[now] = 1;
	for (pair<int,int> &e : edge[now])
	{
		if (seen[e] == 1)
		{
			printf("-1\n");
			exit(0);
		}
		dist[now] = max(dist[now], dfs(edge, e) + 1);
	}
	seen[now] = 2;
	return dist[now];
}

int main()
{
	int N;
	scanf("%d", &N);
	
	map<pair<int, int>, vector<pair<int, int>>> edge;
	for (int i = 0; i < N; i++)
	{
		pair<int, int> now = {0, 0};
		for (int j = 0; j < N - 1; j++)
		{
			int tmp;
			scanf("%d", &tmp);
			tmp--;
			int gr = max(i, tmp);
			int sm = min(i, tmp);

			pair<int, int> next = make_pair(sm, gr);
			edge[now].push_back(next);
			now = next;
		}
	}

	printf("%d\n", dfs(edge, make_pair(0, 0)));
}

Measured memory_bytes: 117504
#include<stdio.h>
void CountingSort(int A[],int B[],int k){
  int x,y;
  int C[20000];

  
  for(x=0;x<20000;x++) C[x]=0;
  for(x=0;x<k;x++) C[A[x]+1]++;
  for(x=1;x<20000;x++){
    C[x]=C[x]+C[x-1];
  }

  for(x=1,k=0;x<=10001;x++){
    for(y=C[x-1];y<C[x];y++){
      B[k]=x-1;
      k++;
    }
  }
}


int A[2000000+1];
int B[2000000+1];
int main(void){
  int x,n;
  
  scanf("%d\n",&n);
  for(x=0;x<n;x++){
    scanf("%d",&A[x]);
  }
  
  CountingSort(A,B,n);
  
  for(x=0;x<n;x++){
    printf("%d",B[x]);
    if(x<n-1){
      printf(" ");
    } else{
      printf("\n");
    }
  }
  
  return 0;
}



Measured memory_bytes: 17428
#include <bits/stdc++.h> 
using namespace std;
void solution(string s)
{
	int i=0;
	while(i<s.size())
	{
		if(s[i]=='B')
		{
			if(i>0)
			{
				for(int j=i-1; j<s.size()-2; j++)
				{
					s[j]=s[j+2];
				}
				s=s.substr(0,s.size()-2);
				i=i-1;
			}
			else
			{
				for(int j=0; j<s.size()-1; j++)
				{
					s[j]=s[j+1];
				}
				s=s.substr(0,s.size()-1);
			}
		}
		else
			i++;
	}
	cout<<s<< endl;
}
int main()
{
	string s;
	cin>>s;
	solution(s);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0;
std::cin >> x;
std::cout << 180*(x-2) << '\n';
}


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

int main() {
	int N, X;
	std::cin >> N >> X;

	int donutNum = 0;

	std::vector<int> m(N);
	for(int i = 0; i < N; i++) {
		std::cin >> m[i];
	}

	for(auto mi : m) {
		X -= mi;
	}
	donutNum += N;

	int min = 1000000;
	for(auto mi : m) {
		if(min > mi) {
			min = mi;
		}
	}
	donutNum += X / min;

	std::cout << donutNum << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e8
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;



int main() {
	int n; cin >> n;
	set<int> all;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		all.insert(a);
	}

	int m = all.size();
	if (m % 2 == 1) {
		cout << m << endl;
	}
	else {
		cout << m - 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
int main()
{
	int a, b, ans;
	char op;
	while (1)
	{
		scanf("%d %c %d", &a, &op, &b);
		if (op == '+')
			ans = a + b;
		if (op == '-')
			ans = a - b;
		if (op == '*')
			ans = a * b;
		if (op == '/')
			ans = a / b;
		if (op == '?')
			break;
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2696
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int  a, b;
	cin >> a >> b;

	string sa = "",sb = "";

	rep(i, a) {
		sb += '0' + b;
	}
	rep(i, b) sa += '0' + a;

	cout << min(sa, sb) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007


int main(){
  long long n,m;
  cin >> n >> m;
  long prime_size = sqrt(m);
  vector<bool> prime(prime_size+1,true);
  long long d = m;
  long long ans = 1;
  for(long i=2;i<prime_size+1;i++){
    if(!prime.at(i)) continue;
    for(long j=2;i*j<prime_size+1;j++){
      prime.at(i*j) = false;
    }
    long count = 0;
    while(d % i == 0){
      count++;
      d /= i;
    }
    long mul = n-1+count;
    long div = count;
    rep(k,count){
      ans *= mul;
      mul--;
      ans %= MOD;
      while(ans % div != 0){
        ans += MOD;
        //cout << ans << " " << div << endl;
      }
      ans /= div;
      div--;
    }
    if(d == 1) break;
  }
  if(d > prime_size) ans *= n;
  cout << ans % MOD << endl;
}

Measured memory_bytes: 384