akhauriyash/Code-Regression huggingface dataset:
// ※※※ 解答不能 ※※※
// ztzshiwo氏.
// https://atcoder.jp/contests/code-festival-2017-quala/submissions/1779879
#include <bits/stdc++.h>
using namespace std;
#define B2(x) (63 - __builtin_clzll(x))
const int N = 100007;
int n, ans, l[N], r[N], dp[N][2];
int main(){
    int x;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d", &x);
        l[i] = B2(x);
        r[i] = l[i] + ((1 << l[i]) != x);
        ans += r[i];
        dp[i][0] = max(dp[i - 1][0] + min(r[i - 1], l[i]), dp[i - 1][1] + min(l[i - 1], l[i]));
        dp[i][1] = max(dp[i - 1][0] + min(r[i - 1], r[i]), dp[i - 1][1] + min(l[i - 1], r[i]));
    }
    printf("%d\n", ans - max(dp[n][0], dp[n][1]));
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

struct Edge
{
    int to, cost;
};
struct Node
{
    int from, to, cost;
};

bool comp(const Node& n1, const Node& n2){
    return n1.cost < n2.cost;
}

struct UnionFind {
	vector<int> par, rank, cnt;
	UnionFind(int n) : par(n), rank(n, 0), cnt(n, 1){
		for(int i = 0; i < n; ++i) par[i] = i;
	}
 
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
 
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
 
		if (rank[x] < rank[y]) swap(x, y);
 
		par[y] = x;
		cnt[x] += cnt[y];
		if (rank[x] == rank[y]) rank[x]++;
	}
 
	bool same(int x, int y) {
		return find(x) == find(y);
	}
 
	int size(int x) {
		return cnt[find(x)];
	}
};



int main(){
    ll N, K, L; cin >> N >> K >> L;
    vector<ll> p(K), q(K), r(L), s(L);
    UnionFind road(N), rail(N);
    for (int i = 0; i < K; i++){
        cin >> p[i] >> q[i];
        p[i]--; q[i]--;
        road.unite(p[i], q[i]);
    }
    for (int i = 0; i < L; i++){
        cin >> r[i] >> s[i];
        r[i]--; s[i]--;
        rail.unite(r[i], s[i]);
    }
    pair<int,int> now;
    map<pair<int,int>, int> mp;
    for (int i = 0; i < N; i++){
        now.first = road.find(i);
        now.second = rail.find(i);
        mp[now]++;
    } 
    for (int i = 0; i < N; i++){
        now.first = road.find(i);
        now.second = rail.find(i);
        cout << mp[now] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 19584
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

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

const int MAX = 2018;
const int INF = 1e9+7;

int N, K, Q;
int A[MAX];

int main() {

  cin >> N >> K >> Q;
  REP (i, N) cin >> A[i];

  vi B(A, A+N);
  sort(B.begin(), B.end());

  vvi lst;
  int ans = INF;

  REP (k, N) {
    int mn = B[k];
    lst = vvi(0);

    int last = -1;
    REP (j, N) {
      if (A[j] < mn) {
        lst.push_back(vi(A+last+1, A+j));
        last = j;
      }
    }
    lst.push_back(vi(A+last+1, A+N));

    vi mxs;
    REP (j, lst.size()) {
      vi v = lst[j];
      sort(v.begin(), v.end());
      REP (i, (int)v.size()-K+1) {
        mxs.push_back(v[i]);
      }
    }

    sort(mxs.begin(), mxs.end());
    if (mxs.size() >= Q) {
      ans = min(ans, mxs[Q-1]-mn);
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<bitset>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int A[200200];
int A2[200200];
int L[200200];
int R[200200];

template<typename... Args>
void debug(Args... args) {
    for (auto arg:{args...})cerr << arg << " ";
    cerr << endl;
}

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> A[i];
        A2[--A[i]] = i;
    }
    set<int> block;
    block.insert(-1);
    block.insert(N);
    rep(i, N) {
        int pos = A2[i];
        auto it = block.lower_bound(pos);
        int right = *it;
        --it;
        int left = *it;
        L[pos] = pos - left;
        R[pos] = right - pos;
        block.insert(pos);
    }
    int ans = 0;
    rep(i, N) {
        ans += ++A[i] * L[i] * R[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
 
using namespace std;

vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
#define MOD 1000000007
#define A first
#define B second
#define all(x) (x).begin(), (x).end

typedef long long ll;
 
inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}
 
inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}
 
inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}
 
inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}
 
inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}
 
inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}
 
const int N = 1e5 + 5;

int arr[N];
char c[] = {'z', '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'};

void solve(){
  ll n;
  cin >> n;
  string ans = "";
  while(n > 0){
    ans += c[(n % 26)];
    if(n % 26 == 0) n /= 26, n--;
    else n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans;

}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

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

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

string s;

int main(){
	cin >> s;
	int A = 0;
	int B = 0;
	for(auto x : s){
		if(x == 'A') A += 1;
		else B += 1;
	}
	puts(A and B? "Yes":"No");
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict

def DD(arg): return defaultdict(arg)
INF = float('inf')

N,M = list(map(int,input().split()))
graph = {i:[] for i in range(N)}
for _ in range(M):
  a,b = list(map(int,input().split()))
  graph[a-1].append(b-1)
p = [None for i in range(N)]
def detect_cycle(graph):
  N = len(graph)
  Q = [i for i in range(N)]
  cycle = []
  while Q:
    state = [-1 for i in range(N)]
    s = Q.pop()
    if p[s] != None: continue
    p[s] = -1
    q = [s]
    while q:
      x = q.pop()
      if x < 0:
        state[~x] = 0
        continue
      q.append(~x)
      for y in graph[x]:
        state[x] = 1
        if state[y] == 0: continue
        elif state[y] == -1:
          p[y] = x
          q.append(y)
        else:
          p[y] = x
          now = x
          while now != y:
            cycle.append(now)
            now = p[now]
          cycle.append(y)
          return cycle
  return cycle

def squeeze(l):
  check = [0 for i in range(N)]
  for i in l:
    check[i] = 1
  global graph
  edges = []
  subgraph = {k:[] for k in l}
  data = DD(lambda:DD(int))
  i = 0
  for k in l:
    for y in graph[k]:
      if check[y]:
        subgraph[k].append(y)
        edges.append([0,k,y])
        data[k][y] = i
        i += 1
  graph = subgraph
  s = l[0]
  i = data[p[s]][s]
  edges[i][0] = 1
  now = p[s]
  heiro = [s]
  while now != s:
    heiro.append(now)
    i = data[p[now]][now]
    edges[i][0] = 1
    now = p[now]
  if len(heiro)==len(edges):
    print(len(heiro))
    for x in heiro:
      print(x+1)
    exit()
  else:
    for b,k,y in edges:
      if not b:
        p[y] = k
        now = p[y]
        heiro = [y]
        while now != y:
          heiro.append(now)
          now = p[now]
        squeeze(heiro)

c = detect_cycle(graph)
if not c:
  print(-1)
else:
  squeeze(c)


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Buffet
            int N = int.Parse(Console.ReadLine());
            var A = ReadLine();
            var B = ReadLine();
            var C = ReadLine();

            int ans = 0;
            int before = -99;

            foreach(var a in A)
            {
                ans += B[a - 1];

                if (a - 1 == before)
                {
                    ans += C[a - 2];
                }

                before = a;
            }

            Console.WriteLine(ans);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
from collections import Counter
n=int(input())
def soin(n):
  soin_ans=[]
  while n%2==0:
    n//=2
    soin_ans.append(2)
  f=3
  while f<=n**0.5:
    if n%f==0:
      n//=f
      soin_ans.append(f)
    else:
      f+=2
  if n!=1:
    soin_ans.append(n)
  return soin_ans
s_list=soin(n)
s_set=set(s_list)
sc=Counter(s_list)
count=0
for i in s_set:
  for j in range(1,sc[i]+1):
    if n%i**j==0:
      n//=i**j
      count+=1
print(count)

Measured memory_bytes: 9712
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextLine()
    val L = N.length
    val K = sc.nextInt()

    println(bitDp(N, K, L))
  }

  def bitDp(S: String, K: Int, L: Int): Long = {
    val dp = Array.fill(L+1, 2, 5)(0L)

    dp(0)(0)(0) = 1
    for {
      i <- 0 until L
      d = S.charAt(i) - '0'
      f <- 0 until 2 // N未満が確定している => 1
      n <- 0 to (if (f == 1) 9 else d)
    } if (f == 1 || n < d) {
      if (n != 0) {
        for (j <- 1 until 5)
          dp(i+1)(1)(j) += dp(i)(f)(j-1)
      } else {
        for (j <- 0 until 5)
          dp(i+1)(1)(j) += dp(i)(f)(j)
      }
    } else {
      if (n != 0) {
        for (j <- 1 until 5)
          dp(i+1)(0)(j) += dp(i)(f)(j-1)
      } else {
        for (j <- 0 until 5)
          dp(i+1)(0)(j) += dp(i)(f)(j)
      }
    }

    dp(L)(0)(K) + dp(L)(1)(K)
  }

}

Measured memory_bytes: 27452
def solve(string):
    n, a, b = map(int, string.split())

    def check(i):
        return a <= sum([int(_i) for _i in str(i)]) <= b

    return str(sum([i for i in range(n + 1) if check(i)]))


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 3296
N = int(input())
A = list(map(int, input().split()))
dp = [[0] * (N + 1) for _ in range(N+ 1)]

accum = [0] * (N + 1)
for i in range(N):
    accum[i + 1] = accum[i] + A[i]

for m in range(1, N+1):
    for l in range(N):
        if m == 1:
            dp[l][l + m] = 0
        else:
            if l + m < N + 1:
                r = l + m
                dp[l][r] = min([dp[l][l+k] + dp[l+k][r] for k in range(1, m)]) + accum[r] - accum[l]

print(dp[0][N])

Measured memory_bytes: 77660
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n,m ,sum = 0;
    cin >> n >> m;
    if (n > 1){
        sum += (n * (n-1) / 2);
    }
    if(m > 1){
        sum += (m * (m-1) / 2);
    }
    cout << sum;
}

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

int main(){
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    int x[N],y[M];

    for (int i=0; i<N; i++) { cin >> x[i]; }
    sort(x,x+N);

    for (int i=0; i<M; i++) { cin >> y[i]; }
    sort(y,y+M);

    if (x[N-1] < y[0] && x[N-1] < Y && y[0] > X) {
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// finish date: 2018/01/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int main() {
    int N;
    cin >> N;
    map<int, int> mp;
    int A;
    rep(i, N) {
        cin >> A;
        mp[A]++;
    }
    for (auto itr:mp) {
        if (itr.first == 0) {
            if (N % 2 == 1 && itr.second == 1) continue;
            else {
                cout << 0 << endl;
                return 0;
            }
        }
        if (itr.second != 2) {
            cout << 0 << endl;
            return 0;
        }
    }
    int ans = 1;
    rep(i, N / 2) {
        ans = mul(ans, 2);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int N;

int main() {
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}

	int ans = 0;
	sort(L.begin(), L.end());
	//for (int i = 0; i < N; i++) {
	//	cout << L[i] << ", " << flush;
	//}
	//cout << endl;
	for (int i = 0; i < N - 2; i++) {
		for (int j = i + 1; j < N - 1; j++) {
			/*if (j > i + 1 && L[j] == L[j - 1]) {
				continue;
			}
			if (j > 1 && L[j] == L[j - 2]) {
				continue;
			}*/
			int ab = L[i] + L[j];
			int mab = -L[i] + L[j];
			int amb = L[i] - L[j];
			for (int k = j + 1; k < N; k++) {
				if (0 >= ab - L[k]) { break; }
				else if (0 < mab + L[k] && 0 < amb + L[k]) {
					//if (L[k] == L[k - 1] && k > j + 1) {
					//	continue;
					//}
					//cout << i << ", " << j << ", " << k << endl;
					//cout << L[i] << ", " << L[j] << ", " << L[k] << endl;
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

bool graph[55][55], visited[55];
int N;

void dfs(int v){
    visited[v] = true;

    for(int i=1; i<=N; i++){
        if(graph[v][i] == true && visited[i] == false) dfs(i);
    }
}

int main(){
    int M; cin >> N >> M;
    vector<int> a(M), b(M);

    for(int i=0; i<M; i++){
        cin >> a[i] >> b[i];
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;
    for(int i=0; i<M; i++){

        for(int j=1; j<=N; j++) visited[j] = false;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        dfs(1);

        bool bridge = false;
        for(int j=1; j<=N; j++) if(visited[j] == false) bridge = true;
        if(bridge) ans++;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << ans << endl;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;

int d[5];

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

	int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;

	int Xmax = a*e;
	int XXmax = b*e;
	int XXXmax =(a+b)*e;

	int Xsugar =0;
	int XXsugar =0;
	int XXXsugar =0;


	for(int i=0; i<=Xmax/c; i++){
		for(int j=0; j<=Xmax/d; j++){
			if(i*c+j*d <=Xmax){
				if(a*100+i*c+j*d<=f){
				Xsugar =max(Xsugar,i*c+j*d);
				}
			}
		}
	}

	for(int i=0; i<=XXmax/c; i++){
		for(int j=0; j<=XXmax/d; j++){
			if(i*c+j*d <=XXmax){
				if(b*100+i*c+j*d<=f){
				XXsugar =max(XXsugar,i*c+j*d);
				}
			}
		}
	}
	for(int i=0; i<=XXXsugar/c; i++){
	for(int j=0; j<=XXXmax/d; j++){
		if(i*c+j*d <=XXXmax){
			if((a+b)*100+i*c+j*d<=f){
				XXXsugar =max(XXXsugar,i*c+j*d);
			}
		}
	}

}

/*	cout<<a*100+Xsugar<<" "<<Xsugar<<endl;
	cout<<b*100+XXsugar<<" "<<XXsugar<<endl;
	cout<<(a+b)*100+XXXsugar<<" "<<XXXsugar<<endl;*/

	if((double)Xsugar/(double)(a*100+Xsugar) >=(double)XXsugar/(double)(b*100+XXsugar)){

		if((double)Xsugar/(double)(a*100+Xsugar) >=(double)XXXsugar/(double)((a+b)*100+XXXsugar)){
		cout<<a*100+Xsugar<<" "<<Xsugar<<endl;
		}else {
			cout<<(a+b)*100+XXXsugar<<" "<<XXXsugar<<endl;
		}
	}else {

		if((double)XXsugar/(double)(b*100+XXsugar) >=(double)XXXsugar/(double)((a+b)*100+XXXsugar)){
		cout<<b*100+XXsugar<<" "<<XXsugar<<endl;
		}else {
			cout<<(a+b)*100+XXXsugar<<" "<<XXXsugar<<endl;
		}
	}


}


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

long long INF = 1'000'000'000'000'000;
typedef pair<long long, long long> P;

int main(){
    int n;
    cin >> n;
    
    //xとyそれぞれについてsort
    vector<P> x_node(n);
    vector<P> y_node(n);
    long long x, y;
    for (int i = 0; i < n; i++){
        cin >> x >> y;
        x_node[i] = {x, i};
        y_node[i] = {y, i};
    }
    sort(x_node.begin(), x_node.end());
    sort(y_node.begin(), y_node.end());
    
    //辺を貼る
    vector<vector<P>> node(n);
    for (int i = 1; i < n; i++){
        node[x_node[i - 1].second].push_back({abs(x_node[i - 1].first - x_node[i].first), x_node[i].second});
        node[x_node[i].second].push_back({abs(x_node[i - 1].first - x_node[i].first), x_node[i - 1].second});
        node[y_node[i - 1].second].push_back({abs(y_node[i - 1].first - y_node[i].first), y_node[i].second});
        node[y_node[i].second].push_back({abs(y_node[i - 1].first - y_node[i].first), y_node[i - 1].second});
    }

    //プリム法
    vector<bool> used(n, false);
    long long res = 0;

    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0, 0});

    while(pq.size() > 0){
        x = pq.top().first; y = pq.top().second; pq.pop();
        if (used[y]) continue;

        used[y] = true;
        res += x;

        int k = (int)node[y].size();
        for (int i = 0; i < k; i++){
            if (used[node[y][i].second] == false){
                pq.push({node[y][i].first, node[y][i].second});
            }
        }
    }
    cout << res << endl;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[10000];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	int ans = 0;
	inc(i, n) {
		while(a[i] % 2 == 0) { a[i] /= 2; ans++; }
	}
	
	cout << ans << endl;
	
	return 0;
}


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

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

  int t, x, y;
  t = 0;
  x = 0;
  y = 0;

  bool flg = true;
  for(int i = 0; i < n; i++){
    int t2, x2, y2;
    cin >> t2 >> x2 >> y2;
    int time = t2 - t;
    int d = abs(x - x2) + abs(y - y2);
    if(time < d || time % 2 != d % 2) flg = false;
    t = t2, x = x2, y = y2;
  }

  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}


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

typedef long long ll;
#define loop(i,a,b) for(ll i=(a); i<ll(b); i++)
#define rep(i,b) loop(i,0,b)

int f(double V){
    rep(i,100000000){
        double y = 5 * i - 5;
        double t = sqrt(y / 4.9);
        double v = 9.8*t;
        if (v >= V) return i;
    }
    return -1;
}

int main(){
    double v;
    while (cin >> v){
        cout << f(v) << endl;
    }
}

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

int main() {
	long N, A, B;
	cin >> N >> A >> B;
	long a = N / (A + B);
	long b = A * a;
	long c = N % (A + B);
	long d = min(A, c);
	cout << b + d;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool vis[300005];
int a[300005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1,j=0,lst=0;i<=n;i++){
		vis[a[i]]=1;
		while(vis[j+1])j++;
		if(j==i){
			bool ok[2]={1,1};
			for(int k=lst+1;k<=j;k++)if(a[k]!=k)ok[k&1]=0;
			if(!ok[0]&&!ok[1]){puts("No"); return 0;}
			int c=ok[0];
			// printf("%d\n",c);
			int p=-1;
			for(int k=lst+1;k<=j;k++)if((k&1)==c&&a[k]<=k){
				if(p>0&&a[p]>a[k]){puts("No"); return 0;}
				p=k;
			}
			p=-1;
			for(int k=j;k>lst;k--)if((k&1)==c&&a[k]>=k){
				if(p>0&&a[p]<a[k]){puts("No"); return 0;}
				p=k;
			}
			lst=j;
		}
	}	
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    map<int,int> g;
    map<int,int> k;
    rep(i,n){
        if(i%2==0){
            g[v[i]]++;
        }
        else{
            k[v[i]]++;
        }
    }
    //g[3]=2みたいな感じ
    //3は2回現れる
    int maxg =0; //何回現れるか
    int max_valueg=0;//最頻値は何か
    int maxk = 0;
    int max_valuek=0;
    int maxk2=0;
    int maxg2=0;
    //int max_valuek2=0;
    for(auto c:g){
        int va = c.first;
        int count = c.second;
        if(maxg2 <= count && maxg>count){
            maxg2 = count;
        }
        if(maxg <= count){
            maxg2 = maxg;
            maxg = count;
            max_valueg = va;

        }
    }
    for(auto c:k){
        int va = c.first;
        int count = c.second;
        if(maxk2 <= count && maxk>count){
            maxk2 = count;
        }
        if(maxk <= count){
            maxk2 = maxk;
            maxk = count;
            max_valuek = va;
        }
    }
    //n/2から最頻値の数分を引いた分変えればいい
    //最頻値のvalueが同じだと/\/にならない
   // cout << max_valuek<<" " <<max_valueg<<endl;
    //cout << maxk<<" " <<maxg<<endl;
    //cout <<maxk2 <<" " << maxg2 <<endl;
    if(max_valuek == max_valueg){
        cout << min(n-maxk-maxg2,n-maxk2-maxg) <<endl;
    }
    else{
        cout << n - maxk - maxg <<endl;
    }
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<i64> a(n);
    i64 x = 0;
    for (auto &e : a) {
        std::cin >> e;
        x ^= e;
    }

    for (auto &e : a) e &= ~x;

    for (int i = 60, index = 0; i >= 0; i--) {
        int mi = index;
        i64 me = -1;
        for (int j = index; j < n; j++) {
            if ((a[j] & (1ll << i)) && a[j] > me) {
                me = a[j];
                mi = j;
            }
        }

        if (me == -1) continue;

        std::swap(a[index], a[mi]);

        mi = index++;

        for (int j = 0; j < n; j++) {
            if (j != mi && (a[j] & (1ll << i))) a[j] ^= a[mi];
        }
    }

    i64 m = 0;
    for (int i = 0; i < n; i++) m ^= a[i];

    std::cout << x + m * 2 << std::endl;

    return 0;
}


Measured memory_bytes: 1024
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    idx = S.find('C')
    if idx == -1:
        print('No')
    else:
        i = S[idx:].find('F')
        if i == -1:
            print('No')
        else:
            print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 8996
#include <stdio.h>

int main(void) {
    int H, W;

    while (1) {
        scanf("%d %d", &H, &W);

        if (H == 0 && W == 0) break;

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i % 2 == 0) {
                    if(j % 2 == 0) printf("#");
                    else printf(".");
                } else {
                    if (j % 2 == 0) printf(".");
                    else printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2072
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            var i = new int[32] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

            var n = int.Parse(Console.ReadLine());
            
            Console.WriteLine(i[n - 1]);
        }

        public int Gcd(int a, int b)
        {
            for (var i = b; i > 1; i -= 1)
            {
                if (a % i == 0 && b % i == 0)
                {
                    return i;
                }
            }
            return 1;
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ConvertIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }

        public List<double> ConvertDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ConvertLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#define lp(i, l, r) for (int i = l; i <= r; ++i)
#define rp(i, r, l) for (int i = r; i >= l; --i)
#define ls(i, s) for (int i = 0; s[i]; ++i)
#define rs(i, s) for (int i = strlen(s) - 1; i >= 0; --i)
#define lv(i, a) for (int i = 0; i < int(a.size()); ++i)
#define rv(i, a) for (int i = (int)a.size() - 1; i >= 0; --i)
#define fast ios::sync_with_stdio(0), cin.tie(0)
#define prec(a) cout << setprecision(a) << fixed
#define appl(f, a) for (auto i = begin(a); i != end(a); f, ++i)
#define many for (int T = -1; T < 0 && cin >> T, T--;)
#define rang(a) begin(a), end(a)
#define gene template <class T>
#define endl '\n'
#define asse assert
using namespace std;
using namespace __gnu_pbds;
gene T inf() { return numeric_limits<T>::max(); }
gene int tmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
gene int tmax(T &a, T b) { return b > a ? a = b, 1 : 0; }
gene auto min(const T &a) { return *min_element(rang(a)); }
gene auto max(const T &a) { return *max_element(rang(a)); }
gene auto sum(const T &a) { return accumulate(rang(a), 0); }
gene auto gath(const T &a, const vector<int> &b) {
    vector<typename T::value_type> r;
    for (auto i : b)
        r.push_back(a[i]);
    return r;
}
gene void sort(T &a) { sort(rang(a)); }
gene void reve(T &a) { reverse(rang(a)); }
gene void uniq(T &a) { sort(a), a.erase(unique(rang(a)), end(a)); }
gene void shuf(T &a) { random_shuffle(rang(a)); }
gene void merg(T l, T m, T r) { inplace_merge(l, m, r); }
// template <typename... T> void in(T &... a) { ((cin >> a), ...); }
// template <typename... T> void ou(T... a) { ((cout << a << ' '), ...); }
template <class F, class S> auto &operator>>(istream &s, pair<F, S> &a) {
    return s >> a.first >> a.second;
}
template <class F, class S> auto &operator<<(ostream &s, const pair<F, S> &a) {
    return s << '(' << a.first << ", " << a.second << ')';
}
gene auto &operator>>(istream &s, vector<T> &a) {
    for (int i = -1; i < 0 && (!a.size() && (cin >> i, a.resize(i), 0), i = 0),
             i < int(a.size());)
        s >> a[i++];
    return s;
}
gene auto &operator<<(ostream &s, const vector<T> &a) {
    lv(i, a) cout << a[i] << (i + 1 == int(a.size()) ? "" : " ");
    return s;
}
gene using bbst =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
gene using heap = __gnu_pbds::priority_queue<T, greater<T>, pairing_heap_tag>;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
int main() {
    fast, prec(12);
    int a, b;
    cin >> a >> b;
    if (a > b)
        swap(a, b);
    lp(i, 1, b) cout << a;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
char s[105][105];
int vis[105],cnt[105];
int main()
{
    int n,m;scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i)
        scanf("%s",s[i]);
    for(int i=0;i<n;++i)
    {
        int f=0;
        for(int j=0;j<m;++j)
            f+=s[i][j]=='#';
        if(!f)vis[i]=1;
    }
    for(int j=0;j<m;++j)
    {
        int f=0;
        for(int i=0;i<n;++i)
            f+=s[i][j]=='#';
        if(!f)cnt[j]=1;
    }
    for(int i=0;i<n;++i)
        if(!vis[i])
        {
            for(int j=0;j<m;++j)
                if(!cnt[j])
                    putchar(s[i][j]);
            puts("");
        }
    return 0;
}

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

using namespace std;
typedef long long ll;


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




    int res[n] = {0};

    for(int i=0;i<n-1;i++){
        int tmp = 0;
        cin >> tmp;
        res[tmp-1]++;
    }

    for(int i=0;i<n;i++){
        cout << res[i] << endl;
    }

}

Measured memory_bytes: 4364
#!/usr/bin/env python3

def main():
    n = int(input())
    a = list(map(int, input().split()))
    absmaxindex = 0
    for i in range(1, n):
        if abs(a[i]) > abs(a[absmaxindex]):
            absmaxindex = i

    print(2 * n - 2)
    for i in range(n):
        if i == absmaxindex:
            continue
        print(absmaxindex + 1, i + 1)
    if a[absmaxindex] >= 0:
        for i in range(n - 1):
            print(i + 1, i + 2)
    else:
        for i in reversed(range(n - 1)):
            print(i + 2, i + 1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            Dictionary<int,int> input = new Dictionary<int, int>();
            for (int i = 0; i < N; i++)
            {
                input.Add(i + 1,int.Parse(Console.ReadLine()));
            }

            int buttonPos = 1;
            for (int i = 0; i < N; i++)
            {
                buttonPos = input[buttonPos];
                if (buttonPos == 2)
                {
                     Console.WriteLine(i + 1);
                     return;
                }
            }
            Console.WriteLine("-1");
        }
    }
}

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

SUM = 0
for n in range(N):
    #print("{}".format(n))
    i = n+1
    if i%3 == 0 or i%5 == 0 or (i%3 == 0 and i%5 == 0):
        continue
    else:
        SUM += i
print("{}".format(SUM))

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

using namespace std;

int main()
{
    int N;
    int a[200];
    cin >> N; N *= 2;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a, a + N);
    int ans = 0;
    for (int i = 0; i < N; i += 2) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;
char s[110];
int l,ans1,ans2;
bool f1,f2;
int main()
{
	cin >> s;
	l = strlen(s);
	ans1 = 0x7fffff;
	ans2 = -1;
	for(int i = 0;i < l; i++)
	{
		if(s[i] == 'C') f1 = 1,ans1 = min(ans1,i);
		if(s[i] == 'F') f2 = 1,ans2 = max(ans2,i);
	}
	if(f1 && f2 && ans1 < ans2)
		printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
#define debug(X) cout << #X << " = " << (X) << endl;
#define say(X) cout << (X) << endl;
#else
#define debug(X)
#define say(X)
#endif

using namespace std;

typedef long long ll;
#define int long long

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;
typedef vector<int> vecint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000L * 1000L * 1000L + 7L)

template<typename T>
vector<T> readArray(int N) {
    vector<T> vec(N);

    for (auto& v: vec) {
        cin >> v;
    }

    return vec;
}

template<typename T>
T read() {
    T a; cin >> a; return a;
}

int readInt() {
    int a; cin >> a; return a;
}
double readDouble() {
    double a; cin >> a; return a;
}
string readStr() {
    string a; cin >> a; return a;
}

void Main()
{
    string s = readStr();

    string m = s.substr(5, 2);
    string d = s.substr(8, 2);
    int mm = atoi(m.c_str());

    cout << (mm <= 4 ? "Heisei" : "TBD") << endl;
}

signed main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli x,n;
    cin>>x>>n;
    lli i,a[n], b[105]={0};
    
    for(i=0;i<n;i++) cin>>a[i],b[a[i]]++;
    
    if(b[x]==0) return cout<<x, 0;
    for(i=1;i<105;i++) 
    {
        if(b[x-i]==0) return cout<<x-i, 0;
        if(b[x+i]==0) return cout<<x+i, 0;
    }
    return 0;
}

Measured memory_bytes: 3644
n, x, y = map(int, input().split())
ans = [0] * (n-1)

for i in range(1, n):
    for j in range(i+1, n+1):
        k = min(abs(i-j),
                abs(i-x)+1+abs(j-y)
                )
        ans[k-1] += 1

for i in ans:
    print(i)

Measured memory_bytes: 3444
#include <cstdio>
#include <cctype>
#include <array>
#include <set>
#include <queue>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int n = 0, c = gcu();
	// bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	return n; }
	// return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
//template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
//svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

struct board {
	enum {size = 3};
	struct pos {int r, c;};
	typedef array<array<int, size>, size> arr;
	arr b;
	pos p;
	int max;
	int cnt = 0;

	int f(arr &a) {
		int l = 0;
		for (int i = 0; i < size; i++)
			for (int j = 0; j < size; j++) {
				int c = a[i][j];
				if (c == 0)
					c = size * size - 1;
				else
					c--;
				l += abs(i - c / 3) + abs(j - c % 3);
			}
		return l;
	}

	void read() {
		for (int i = 0; i < size; i++)
			for (int j = 0; j < size; j++) {
				b[i][j] = in();
				if (!b[i][j])
					p.r = i, p.c = j;
			}
		max = f(b);
	}
	void print() {
		for (auto &r: b) {
			for (int &c: r)
				out(&c == &r[0]?"":" ", c);
			out('\n');
		}
		out('\n');
	}


	int solver() {
		set<arr> m;
		queue<board> q;
		q.push(*this);
		while (!q.empty()) {
			board a = q.front();
			q.pop();
//			a.print();
			int dis = f(a.b);
			if (dis > max * 2.1 - a.cnt)
				continue;
//			out(dis, "\n");
			auto it = m.find(a.b);
			if (it != m.end())
				continue;
			m.insert(a.b);
			if (!dis)
				return a.cnt;
			pos to[] = {
				a.p.r + 1, a.p.c,
				a.p.r, a.p.c + 1,
				a.p.r - 1, a.p.c,
				a.p.r, a.p.c - 1
			};
			for (pos o: to) {
				if (0 <= o.r && o.r < size && 0 <= o.c && o.c < size) {
					board c = a;
					swap(c.b[a.p.r][a.p.c], c.b[o.r][o.c]);
					c.p = o;
					c.cnt = a.cnt + 1;
					q.push(c);
				}
			}
		}
		return -1;
	}
};

int main() {
	board b;
	b.read();
	out(b.solver(), '\n');
}


Measured memory_bytes: 17600
#include<cstdio>
#include<algorithm>
#define maxn 100005
using namespace std;
int n,ans,f[maxn][30];
struct node { int v; node *nxt; } edge[maxn*2],*head[maxn],*ncnt;
void addedge(int u,int v)
{
	ncnt++;
	ncnt->v=v,ncnt->nxt=head[u];
	head[u]=ncnt;
}
void dfs(int u,int fa)
{
	for(node *p=head[u];p;p=p->nxt)
	{
		int v=p->v;
		if(v==fa) continue;
		dfs(v,u); 
		for(int i=0;i<=20;i++) f[u][i]+=f[v][i];
	}
	int p=0;
	for(int i=20;i>=0;i--)
		if(f[u][i]>1) { p=i+1; break; }
	while(f[u][p]) p++;
	f[u][p]++;
	for(int i=0;i<p;i++) f[u][i]=0;
	ans=max(ans,p);
}
int main()
{
	ncnt=&edge[0];
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v); addedge(v,u);
	}
	dfs(1,0);
	printf("%d\n",ans);
}

Measured memory_bytes: 21504
Kin = int(input())

i = 0
now = 0

if (0 == (Kin % 2)) or (0 == (Kin % 5)):
    print(-1)
else:
    while 1:
        now = (now * 10 + 7) % Kin
        i+=1

        if now == 0:
            break
    print(i)

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

int main(){
  string S,T;
  cin >> S >> T;
  
  const char* Schr = S.c_str();
  const char* Tchr = T.c_str();
   
  int count = 0;
  
  for(int i = 0; i < 3; i++){
    if(Schr[i] == Tchr[i]){
      count++;
    } 
  }
  cout << count;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int x;
	cin>>x;
	cout<<!x<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys


def solve(n: int, p: "List[int]"):

    count = 0
    for i in range(n - 2):
        partial = p[i : i + 2 + 1]
        if min(partial) != partial[1] and max(partial) != partial[1]:
            count += 1
        else:
            pass

    print(count)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(n)]  # type: "List[int]"
    solve(n, p)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

signed main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];

  int f = 0;
  vector<int> v;
  for (int i = 0; i < N; i++) {
    if (a[i] < 3200)
      v.push_back(a[i] / 400);
    else
      f++;
  }

  sort(ALL(v));
  UNIQUE(v);

  if (v.size() == 0) {
    if (f > 0) {
      cout << 1 << " " << f << endl;
    }
  } else {
    cout << v.size() << " " << v.size() + f << endl;
  }
  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split();
        long[] A = new long[N];
        long[] ans = new long[N];
        long sum = 0;
        long halfsum = 0;
        for (int i = 0;i < N; i++)
        {
            A[i] = long.Parse(input[i]);
            sum += A[i];
            if (i % 2 == 1) { halfsum += 2*A[i]; }
        }
        ans[0] = sum - halfsum;
        for(int i = 0; i < N-1; i++)
        {
            ans[i + 1] = 2 * A[i] - ans[i];
        }
        Console.WriteLine(string.Join(" ", ans));
    }
}


Measured memory_bytes: 33992