akhauriyash/Code-Regression huggingface dataset:
#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 mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int64_t> a(n);
    map<int,int> p;
    int64_t sum=0;
    rep(i,n){
        cin>>a[i];
        sum += a[i];
        p[a[i]]++;
    }
    int q;
    cin>>q;
    rep(i,q){
        int64_t b,c;
        cin>>b>>c;
        //b*p[b]減って、c*p[b]増える
        int64_t bcount = p[b];
        //cout<<bcount<<endl;
        if(bcount!=0){
            sum -= b*bcount;
            sum += c*bcount;
            p[b] = 0;
            p[c] += bcount;
        }
        cout<<sum<<endl;
    }

}

Measured memory_bytes: 8204
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N=_I()

def F(A,B):
	return max(len(str(A)),len(str(B)))

#高々10**5まで見れば良い
ans=inf
for i in range(1,min(N,10**5+3)):
	if N%i==0:
		ans=min(ans,F(i,int(N/i)))
ans=min(ans, F(1,N))
print(ans)
	


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

int main(void) {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int takahashi_endure = A / D;
  int aoki_endure = C / B;
  
  int minimum_endure;
  
  if (takahashi_endure < aoki_endure) minimum_endure = takahashi_endure-1;
  else minimum_endure = aoki_endure-1;
  
  A -= D * minimum_endure;
  C -= B * minimum_endure;
  
  while (1) {
    if (A <= 0) {
      cout << "No";
      break;
    }
    else if (C <= 0) {
      cout << "Yes";
      break;
    }
    C -= B;
    if (A <= 0) {
      cout << "No";
      break;
    }
    else if (C <= 0) {
      cout << "Yes";
      break;
    }
    A -= D;
  }
  
  return 0;
}

Measured memory_bytes: 3636
const MOD: usize = 1000000000 + 7;

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut tree = vec![vec![]; n + 1];
    for _ in 1..n {
        let v = read_vec::<usize>();
        let (a, b) = (v[0], v[1]);
        tree[a].push(b);
        tree[b].push(a);
    }
    println!("{}", k * dfs(&tree, 1, 0, k) % MOD);
}

fn dfs(tree: &Vec<Vec<usize>>, cur: usize, parent: usize, k: usize) -> usize {
    let mut ret = 1;
    let mut colors_count = if parent > 0 { k - 2 } else { k - 1 };
    if tree[cur].len() > k {
        0
    } else {
        for child in tree[cur].iter() {
            if *child != parent {
                ret *= colors_count;
                ret %= MOD;
                ret *= dfs(&tree, *child, cur, k);
                ret %= MOD;
                colors_count -= 1;
            }
        }
        ret
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 16252
import java.util.*;

public class Main{

    int cnt;

    void solve(){
        Scanner sc = new Scanner(System.in);

        String line = sc.next();
        char[] c = line.toCharArray();
        cnt = 0;
        for(int i=0; i<=c.length/2; i++){
            if(c[i]=='(' && c[c.length-i-1]!=')'){
                cnt++;
                c[c.length-i-1] = ')';
                continue;
            }
            if(c[i]==')' && c[c.length-i-1]!='('){
                cnt++;
                c[c.length-i-1] = '(';
                continue;
            }
            if(c[i]=='w' && c[c.length-i-1]!='w'){
                cnt++;
                c[c.length-i-1] = 'w';
                continue;
            }
            if(c[i]=='i' && c[c.length-i-1]!='i'){
                cnt++;
                c[c.length-i-1] = 'i';
                continue;
            }
        }
        System.out.println(cnt);
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,K,ans=0;
  cin>>N>>K;
  if(K>1)
    ans=N-K;
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
        public static void main(final String[] args){
            final Scanner sc = new Scanner(System.in);
            while(true){
                int mid = sc.nextInt();
                int fin = sc.nextInt();
                int re = sc.nextInt();
                if(mid + fin  + re == -3){
                    break;
                }
                if(mid == -1 || fin == -1){
                    System.out.println("F");
                }else if(mid + fin >= 80){
                    System.out.println("A");
                }else if(mid + fin >= 65){
                    System.out.println("B");
                }else if(mid + fin >= 50){
                    System.out.println("C");
                }else if(re >= 50){
                    System.out.println("C");
                }else if(mid + fin >= 30){
                    System.out.println("D");
                }else{
                    System.out.println("F");
                }
            }
            sc.close();
        }
         

}


Measured memory_bytes: 26144
#include<iostream>

using namespace std;

int main(){
  int N,K,Q;
  int A[111111];
  int B[111111] = {0};
  int i;
  cin >> N >> K >> Q;
  for(i=0;i<=Q-1;i++)
    cin >> A[i];
  for(i=0;i<=Q-1;i++)
    B[A[i]]++;
  for(i=1;i<=N;i++) {
    if(B[i]>Q-K) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}



Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,a;
    cin >> n >> a;
    if (n%500<=a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

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

    int ans = n;
    while(true) {
        if (ans%2 == 0 & ans%n == 0) {
            cout << ans << endl;
            return 0;
        } else {
            ans++;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=1e5+5;
const int M=1e9+7;

void solve()
{
	string s;
	cin>>s;
	if(s=="ABC")
	cout<<"ARC";
	else
	cout<<"ABC";
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


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

struct Edge{ UL u,v; UL w; UL h; };

UL N, M;
Edge J[20000];
vector<UL> E[10000];

UL DFS(UL p, UL pre = ~0u) {
	UL ans = 0;
	for (UL e : E[p]) {
		Edge& j = J[e];
		if (j.v == pre) continue;
		if (j.h == ~0u) j.h = DFS(j.v, p);
		ans = max(ans, j.h + j.w);
	}
	return ans;
}

int main() {
	scanf("%u", &N); M = N * 2 - 2;
	rep(i, N - 1) {
		UL u, v, w; scanf("%u%u%u", &u, &v, &w);
		J[i] = { u,v,w,~0u };
		J[i + N - 1] = { v,u,w,~0u };
		E[u].push_back(i);
		E[v].push_back(i + N - 1);
	}
	rep(i, N) printf("%u\n", DFS(i));

	return 0;
}



Measured memory_bytes: 4908
s=input()
ans=[1]*len(s)

for i in range(len(s)):
    if s[i]=='L':
      if s[i]==s[i-1]:
        ans[i-2]+=ans[i]
        ans[i]=0
        
    elif s[i]=='R':
      if s[i]==s[i+1]:
        ans[i+2]+=ans[i]
        ans[i]=0

for i in range(len(s)-1,-1,-1):
    if s[i]=='L':
      if s[i]==s[i-1]:
        ans[i-2]+=ans[i]
        ans[i]=0
        
    elif s[i]=='R':
      if s[i]==s[i+1]:
        ans[i+2]+=ans[i]
        ans[i]=0
        
        
ans=list(map(str,ans))

print(' '.join(ans))
        

Measured memory_bytes: 81476
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = 0;
	
	void doIt() {
		int h = sc.nextInt();
		int w = sc.nextInt();
		int dp[][] = new int[h + 1][w + 1];
		for(int i = 0; i < h; i++){
			char c[] = sc.next().toCharArray();
			for(int j = 0; j < w; j++) {
				if(c[j] == '#')dp[i][j] = -1;
			}
			dp[i][w] = -1;
		}
		Arrays.fill(dp[h], -1);
		dp[0][0] = 1;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if(dp[i][j] < 0)continue;
				if(dp[i + 1][j] >= 0) dp[i + 1][j] += dp[i][j];
				dp[i + 1][j] %= MOD;
				if(dp[i][j + 1] >= 0) dp[i][j + 1] += dp[i][j];
				dp[i][j + 1] %= MOD;

			}
			
		}
		//for(int i = 0; i <= h; i++)
		//	System.out.println(Arrays.toString(dp[i]));
		System.out.println(dp[h - 1][w - 1]);
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 35404
#include "bits/stdc++.h"
using namespace std;

int N;
long long a[3005];
long long dp[3005][3005];

// dp[i][j] = optimal values of (X-Y) for seq a = [ai...aj]

long long rec(int i, int j, int turn)
{
    if (dp[i][j] != -1)
        return dp[i][j];

    if (i == j)
    {
        if (turn == 0)
            return dp[i][j] = a[i];
        else
            return dp[i][j] = -a[i];
    }

    if (turn == 0)
        return dp[i][j] = max(rec(i + 1, j, 1) + a[i], rec(i, j - 1, 1) + a[j]);
    else
        return dp[i][j] = min(rec(i + 1, j, 0) - a[i], rec(i, j - 1, 0) - a[j]);
}

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

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            dp[i][j] = -1;

    long long ans = rec(0, N - 1, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70784
using System;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		int n = int.Parse(Console.ReadLine());
		var flag = true;

		for (int i = 1; i <= n; i++)
		{
			// スペース区切りの整数の入力
			var inputArray = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var time = inputArray[0];
			var x = inputArray[1];
			var y = inputArray[2];

			if (x + y > time)
			{
				flag = false;
				break;
			}

			if (time % 2 != (x + y) % 2)
			{
				flag = false;
				break;
			}
		}

		if (flag)
			Console.WriteLine("Yes");
		else
			Console.WriteLine("No");
	}

}

Measured memory_bytes: 15404
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
 
using namespace std;
 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
 
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
 
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
 
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
 
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

              

int main(){
  int N,K;
  cin >> N >> K;
  int ans = 0;
  rep(i,N){
    int d;
    cin >> d;
    ans += min(abs(d),abs(d-K))*2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n;
	char S[50][50];
	int num[26];
	int num2[26];
	int basenum = (int)('a');
	for(int h=0;h<26;h++){
		num[h]=99;
	}
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf(" %s",S[i]);
	}
	for(int j=0;j<n;j++){
		for(int jj=0;jj<26;jj++){
			num2[jj]=0;
		}
		for(int k=0;k<50;k++){
			if(S[j][k]==0) break;
			int alphabet;
			alphabet = (int)S[j][k];
			num2[alphabet - basenum]++;
		}
		for(int m=0;m<26;m++){
			if(num2[m]<num[m])num[m]=num2[m];
		}
	}
	for(int p=0;p<26;p++){
		char moji = (char)(int)('a'+p);
		for(int q=0;q<num[p];q++){
			printf("%c",moji);
		}
	}
	printf("\n");
}

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

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

  unordered_set<char> cand = {'A', 'C', 'G', 'T'};
  string s;
  cin >> s;
  s += '$';
  int n = s.size();
  int cnt = 0;
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (cand.find(s[i]) != cand.end()) cnt++;
    else {res = max(res, cnt); cnt = 0;}
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

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

int n, ans = 1, dp[N], yer[N], a[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		scanf("%d", a + i);
		yer[a[i]] = i;
	}
	for(int i = 1; i <= n; i++){
		if(yer[a[i] - 1] == 0 or yer[a[i] - 1] > i)
			dp[i] = 1;
		else{
			dp[i] = dp[yer[a[i] - 1]] + 1;
			// cout << i << " " << dp[i] << endl;
			ans = max(ans, dp[i]);
		}
	}
	printf("%d\n", n - ans);
	return 0;
}

Measured memory_bytes: 9216
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int n;
    cin >> n;

    int ans = inf;
    REP(i, n) {
        ll a; cin >> a;

        int c = 0;
        while(a % 2 == 0) {
            c++;
            a /= 2;
        }

        ans = min(ans, c);
    }

    print(ans);

}

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

int main(){
  int k,a;
  string s;
  cin >> k;
  cin >> s;
  a=s.size();
  if(a<=k)
    cout << s << endl;
  else{
    for(int i=0;i<k;i++)
      cout << s.at(i);
    cout << "..." << endl;
  }
}
  


Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<algorithm>
#define ll long long
#define lowbit(x) x&-x
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int ab(int x){return x>0?x:-x;}
//int MO(int x){return x>=MOD?x-MOD:x;}
//void insert(int u,int v){tot++;e[tot].v=v;e[tot].from=first[u];first[u]=tot;}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=200010;
 
int n,c[maxn],num[maxn];
bool vis[maxn];
char s[maxn];
vector<int>v[30];
void modify(int x,int k){for(int i=x;i<=n;i+=lowbit(i))c[i]+=k;}
int query(int x){int ans=0;for(int i=x;i>=1;i-=lowbit(i))ans+=c[i];return ans;}
int main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++)num[s[i]-'a']++,v[s[i]-'a'].push_back(i);
    int ok=0;
    for(int i=0;i<26;i++){
        if(num[i]%2)ok++;
    }
    if(ok>1){printf("-1");return 0;}
    for(int i=1;i<=n+1;i++)modify(i,1);
    ll ans=0;
    for(int i=1;i<=n;i++)if(!vis[i]){
        int c=s[i]-'a';
        int x=v[c].back();
        if(i==x){
            ans+=(query(n)-query(i))>>1;
        }
        else{
            ans+=query(n)-query(x);
        }
        modify(i,-1);modify(x,-1);
        vis[i]=vis[x]=1;
        v[c].pop_back();
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 2424
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();

    sc.close();

    for (int i = N; 1 <= N; i--) {
      double j = Math.sqrt(i);
      if (j % 1 == 0) {
        System.out.println(i);
        break;
      }
    }

  }

}

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

// #define int long long

signed main()
{
    int i=0, j=0, k=0, ans=0;
    int n,m,s[5]={0}, cnt=0;
    char c[5]={0};
    cin>>n>>m;
    for(i=0;i<m;i++)
        cin>>s[i]>>c[i];

    for(i=0;i<m;i++){
        if((s[i]==1)&&(c[i]=='0')&&(n>1)){
            cout<<-1<<endl;
            return 0;
        }
    }
    string answer="aaa";
    for(i=0;i<m;i++){
        if((answer[s[i]-1]!='a')&&(answer[s[i]-1]!=c[i])){
            cout<<-1<<endl;
            return 0;
        }
        else{
            answer[s[i]-1]=c[i];
            k++;
        }
    }

    if(cnt)
        answer[0]='1';
    for(j=0;j<n;j++){
        if(answer[j]=='a')
            answer[j]='0';
    }
    if((n>1)&&(answer[0]=='0')){
        answer[0]='1';
    }
    for(i=0;i<n;i++){
        cout<<answer[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define ret0 return 0;
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main() {
    ll n;
    cin >> n;
    vi p(n), q(n);
    rep(i, n) cin >> p[i], --p[i];
    rep(i, n) cin >> q[i], --q[i];

    map<vi, int> pmt;
    int index = 0;

    vi v(n);
    rep(i, n) v[i] = i;

    do {
        pmt[v] = index++;
    } while (next_permutation(all(v)));

    mes (abs(pmt[p] - pmt[q]));
}


Measured memory_bytes: 8576
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  int n;
  int values[3];
  cin>>n;
  for (int i=0; i<3; i++)
    cin>>values[i];

  vector<string> got;
  string s;
  for (int i=0; i<n; i++) {
    cin>>s;
    got.push_back(s);
  } 

  bool valid = true;
  vector<char> ans;
  for (int i=0; i<n; i++) {
    int left = got[i][0] - 'A';
    int right = got[i][1] - 'A';

    if (values[left] == 0 && values[right] == 0) {
      valid = false;
      break;
    }

    if (values[left] > values[right]) {
      ans.push_back(right + 'A');
      values[left]--;
      values[right]++;
    }
    else if (values[left] < values[right]) {
      ans.push_back(left + 'A');
      values[left]++;
      values[right]--;
    }
    else {
      map<int, bool> need;
      if (i+1<n) {
        need[got[i+1][0]-'A'] = true;
        need[got[i+1][1]-'A'] = true;

        if (need[left]) {
          ans.push_back(left + 'A');
          values[left]++;
          values[right]--;
        }
        else {
          ans.push_back(right + 'A');
          values[right]++;
          values[left]--;
        }
      }
      else {
        ans.push_back(left + 'A');
        values[left]++;
        values[right]--;
      }
    }

    //cout<<ans[ans.size()-1]<<":"<<values[0]<<","<<values[1]<<","<<values[2]<<endl;
  }

  if (valid) {
    cout<<"Yes"<<endl;
    for (auto & p : ans)
      cout<<p<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

int 
main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 7432
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define INF 1e+9
#define mp make_pair
using namespace std;

typedef pair<int,int> P;
typedef pair<P,int> PP;

class RMQ{
	int n,seg,init;
	vector<P> dat;
	public:
	void ini(int siz,int def){
		n = siz;
		init = def;
		seg = 1;
		while(seg < n) seg *= 2;
		dat.resize(seg * 2 - 1);
		for(int i = seg - 1;i < seg * 2 - 1;i++) dat[i] = P(init,i - seg + 1);
		for(int i = seg - 2;i >= 0;i--) dat[i] = min(dat[i * 2 + 1],dat[i * 2 + 2]);
	}
	void update(int i,int x){
		i += seg - 1;
		dat[i].first = x;
		while(i){
			i = (i - 1) / 2;
			dat[i] = min(dat[i * 2 + 1],dat[i * 2 + 2]);
		}
	}
	P get(int a,int b,int k = 0,int l = 0,int r = -1){
		if(r == -1) r = seg;
		if(b <= l || r <= a) return P(init,-1);
		if(a <= l && r <= b) return dat[k];
		return min(get(a,b,k * 2 + 1,l,(l + r) / 2),get(a,b,k * 2 + 2,(l + r) / 2,r));
	}
};

vector<RMQ> rmq(2);
vector<P> ans;
vector<int> G[200000];
int num = 0;

void dfs(int l,int r,int par){
	int ind = num++;
	P first = rmq[l % 2].get(l,r),second = rmq[(l + 1) % 2].get(first.second,r);
	if(par != -1) G[par].push_back(ind);
	ans.push_back(P(first.first,second.first));
	if(first.second - l) dfs(l,first.second,ind);
	if(second.second - first.second != 1) dfs(first.second + 1,second.second,ind);
	if(r - second.second != 1) dfs(second.second + 1,r,ind);
}

int main(){
	int n,a[200000];
	cin >> n;
	for(int i = 0;i < 2;i++) rmq[i].ini(n,INF);
	for(int i = 0;i < n;i++){
		cin >> a[i];
		rmq[i % 2].update(i,a[i]);
	}
	dfs(0,n,-1);
	priority_queue<PP,vector<PP>,greater<PP> > que;
	que.push(mp(ans[0],0));
	bool flag = false;
	while(!que.empty()){
		PP p = que.top();que.pop();
		P pr = p.first;
		if(!flag) {
			cout << pr.first << " " << pr.second;
			flag = true;
		}
		else cout << " " << pr.first << " " << pr.second;
		int nu = p.second;
		for(int i = 0;i < G[nu].size();i++) que.push(mp(ans[G[nu][i]],G[nu][i]));
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 40948
n=int(input())
A=[]
for i in range(n):
  a,b=map(str,input().split())
  b=int(b)
  A.append([a,b,i+1])
A=sorted(A, key=lambda x:x[1])
A=A[::-1]
A=sorted(A,key=lambda x :x[0])
for i in range(n):
  print(A[i][2])

Measured memory_bytes: 3064
from fractions import gcd
# from datetime import date, timedelta
# from heapq import *
import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def modinv(a, mod):
    return modpow(a, mod - 2, mod)


def cnk(a, b):
    MOD = 10**9+7
    ret = 1
    for i in range(b):
        ret *= (a-i)
        ret %= MOD
        ret = ret * modinv(i+1, MOD) % MOD
    return ret




def main():
    n, k, s = map(int, input().split())
    if n == 1:
        print(s)
        exit()
    # elif k == 1:
    #     ansl = [10 ** 9] * n
    #     ansl[0] = s
    #     print(*ansl)
    #     exit()
    
    
    ansl = []
    if s == 10**9:
        ansl = [10 ** 9 - 1] * n
    else:
        ansl = [10 ** 9] * n
    
    for i in range(k):
        ansl[i] = s


    # ansl[0] = 1
    # ansl[1] = s - 1
    # for i in range(k - 1):
    #     if i % 2 == 0:
    #         ansl[i+2] = 1
    #     else:
    #         ansl[i+2] = s - 1


    
    # v = n - k + 1
    # t = s // v
    # if t == 0:
    #     ansl = [0]*n


    #     ansl[0] = 1
    #     ansl[1] = s - 1
    #     for i in range(k - 1):
    #         if i % 2 == 0:
    #             ansl[i+2] = 1
    #         else:
    #             ansl[i+2] = s - 1
        
    #     for i in range(n):
    #         if ansl[i] == 0:
    #             ansl[i] = 10**9
            

    # else:
    #     t2 = s % v
    #     l = [t] * (v - 1) + [t + t2]
    #     ansl = []
    #     for i in range(n // len(l) + 1):
    #         ansl+=l
    
    
    
    print(*ansl[:n])

    


    


if __name__ == '__main__':
    main()


Measured memory_bytes: 71980
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define alpha_size 26

const int N = 4e5 + 5;
const int MOD = 998244353;

int power(int a, int b, int m) {
  int res = 1ll;
  while (b){
    if (b & 1) 
      res = res * a % m;
    a = a* a % m;
    b >>= 1;
  }
  return res;
}

int modinv(int a) {
  return power(a, MOD - 2, MOD);
}

int fact[N], invfact[N];

void pre() {
  fact[0] = fact[1] = 1;
  for (int i = 2; i < N; i++){
    fact[i] = i * fact[i - 1];
    fact[i] %= MOD;
  }
  invfact[N - 1] = modinv(fact[N - 1]);
  for (int i = N - 2; i >= 0; --i){
    invfact[i] = invfact[i + 1] * (i + 1);
    invfact[i] %= MOD;
  }
}

int nCr(int n, int r) {
  if (r > n)
    return 0;
  return fact[n] * invfact[r] % MOD * invfact[n - r] % MOD;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  
  // n1 + n2 + n3 + ..... + np = n  [ith block = same color]
  // ways = (n - 1, p - 1) => stars and bars theorem
  // every block of length x has (x - 1) pairs of same color
  // n1 - 1 + n2 - 1 + n3 - 1 + .... np - 1 <= k
  // n1 + n2 + n3 ... + np - p <= k
  // n - p <= k => n >= p >= n - k 
  // number of ways to color first block out of p blocks
  // using m colors = m
  // total ways of coloring all p blocks = m * (m - 1) ^ (p - 1)  
  // no adjacent blocks may contain the same color

  pre();
  int n, m, k;
  cin >> n >> m >> k;

  int sum = 0ll;
  for (int p = n - k; p <= n; p++){
    int ways = m * power(m - 1, p - 1, MOD);
    ways %= MOD;
    ways *= nCr(n - 1, p - 1);
    ways %= MOD;
    sum += ways;
  }
  sum %= MOD;
  cout << sum << endl;
}



Measured memory_bytes: 9900
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int main()
{
    int x, a, b; cin >> x >> a >> b;
    string ans = (abs(x - a) < abs(x - b)) ? "A" : "B";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    string S;
    cin >> S;
    vector<ll> A(S.size()+1);
    REP(i,S.size()){
        if(S[i] == '<'){
            chmax(A[i+1],A[i]+1);
        }
    }
    RREP(i,S.size()){
        if(S[i] == '>'){
            chmax(A[i],A[i+1]+1);
        }
    }
    ll ans = 0;
    REP(i,S.size()+1)ans += A[i];
    cout << ans << "\n";
}

Measured memory_bytes: 7604
#include<stdio.h>

main(){
	int h, w, i, j;
	while(1){
		scanf("%d%d",&h,&w);
		
		if(h==0&&w==0)break;
		
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(i%2==0&&j%2==0)printf("#");
				else if(i%2==1&&j%2==1)printf("#");
				else printf(".");
			}
			printf("\n");
		}
		
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
n=int(input())
p=list(map(int,input().split()))

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

print(count)

Measured memory_bytes: 38384
#include<stdio.h>
int main(){
	int a,b,c,d,y,z,x,e;
	while(scanf("%d %d",&a,&b)!=EOF){
		if(a>=b) x=a,y=b;
		else x=b,y=a;
		while(y!=0) {
			z=x%y; x=y; y=z;
		}
		c=a/x;
		d=b/x;
		e=c*d*x;
		printf("%d %d\n",x,e);
	}
	return 0;}

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

int main() {
  long n,ans=0,amax=0;
  cin >> n;
  vector<long> a(n);
  for(long i=0;i<n;i++) cin >> a[i];
  for(long i=0;i<n;i++) {
    if(amax>a[i]) ans+=amax-a[i];
    else amax=a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4824
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <limits>

#define ll long long int
int main() {
  int n, k, j;
  std::cin >> n >> k;
  double e = 0.0;
  for(int i = 1; i < n+1; i++) {
    j = 1;
    while (i*j < k) {
      j <<= 1;
    }
    e +=  (double)(1.0)/(double)(n)/(double)(j);
  }
  std::cout << std::setprecision(10) << e << std::endl;
}

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

#define ll long long

using namespace std;

const ll C = 1000000007;

ll f(ll x, int n)
{
  if (n == 1){
    return x;
  }
  ll var = f(x, n/2);
  var = var * var;
  if (var > C)
    var %= C;
  if (n % 2 == 1){
    var *= x;
    if (var > C)
      var %= C;
  }
  return var;
}

int main()
{
  ll n;
  cin >> n;
  vector<ll> kai;
  kai.push_back(1);
  kai.push_back(1);
  for(ll i = 2; i <= n+1; ++i){
    ll newvar = kai[i-1]*i;
    if (newvar > C)
      newvar %= C;
    kai.push_back(newvar);
  }
  vector<int> pos = vector<int>(n+1, -1);
  int sp;
  for(int i = 0; i < n+1; ++i){
    int tmp;
    cin >> tmp;
    if (pos[tmp] >= 0){
      sp = n+1 - (i-pos[tmp]+1);
      break;
    }
    pos[tmp] = i;
  }
  for(int i = 1; i <= n+1; ++i){
    ll var1 = kai[i] * kai[n+1-i];
    if (var1 > C)
      var1 %= C;
    var1 = f(var1, C-2);
    var1 *= kai[n+1];
    if (var1 > C)
      var1 %= C;
    if (i <= sp+1){
      ll var2 = kai[i-1] * kai[sp-i+1];
      if (var2 > C)
        var2 %= C;
      var2 = f(var2, C-2);
      var2 *= kai[sp];
      if (var2 > C)
        var2 %= C;
      if (var1 < var2)
        var1 += C;
      var1 -= var2;
    }
    cout << var1 << endl;
  }
  return 0;
}


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

struct Node {
    Node* parent;
    Node* left;
    Node* right;
    int key;
};

Node * NIL = NULL;
Node * ROOT = NIL;

void Inorder (Node* n) {
    if (n == NIL) return;
    Inorder(n->left);
    printf(" %d", n->key);
    Inorder(n->right);
}
void Preorder (Node* n) {
    if (n == NIL) return;
    printf(" %d", n->key);
    Preorder(n->left);
    Preorder(n->right);
}

void insert (Node* n) {
    Node * r = ROOT;
    Node * t;
    while (r != NIL) {
        t = r;
        if (n->key < r->key) {
            r = r->left;
        }
        else {
            r = r->right;
        }
    }
    n->parent = t;

    if (ROOT == NIL) {
        ROOT = n;
    }
    else if(n->key < t->key) {
        t->left = n;
    }
    else {
        t->right = n;
    }
}

Node* find(int key) {
    Node* t = ROOT;
    while (t != NIL) {
        if ( t->key == key) {
            break;
        }
        else if (key < t->key) {
            t = t->left;
        }
        else {
            t = t->right;
        }
    }
    return t;
}
Node* getMinimum(Node* n) {
    while (n->left != NIL) {
        n = n->left;
    }
    return n;
}

Node* getSuccessor(Node* n) {
    if (n->right != NIL) return getMinimum(n->right);

    Node* p = n->parent;
    while (p != NIL && p->right == n) {
        n = p;
        p = p->parent;
    }

    return n;
}

void deleteFromParentNode (Node * n, Node * t) {
    if (n->parent == NIL) {
        ROOT = t;
        return;
    }
    if (n->parent->left == n) {
        n->parent->left = t;
    }
    else if (n->parent->right== n) {
        n->parent->right = t;
    }
}

void deleteNode (Node * n) {
    if (n == NIL) return;

    if (n->left == NIL && n->right == NIL) {
        deleteFromParentNode(n, NIL);
    }
    else if (n->left != NIL && n->right != NIL) {
        Node* t = getSuccessor(n);
        n->key = t->key;
        return deleteNode(t);
    }
    else if (n->left != NIL) {
        deleteFromParentNode(n, n->left);
        n->left->parent = n->parent;
    }
    else if (n->right != NIL) {
        deleteFromParentNode(n, n->right);
        n->right->parent = n->parent;
    }
    free(n);
    n = NULL;
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        char s[100];
        scanf("%s", s);
        if (s[0] == 'i') {
            int key;
            scanf("%d", &key);
            Node* n = (Node *) malloc(sizeof(Node));
            n->key = key;
            n->parent = n->left = n->right = NIL;
            insert(n);
        }
        else if (s[0] == 'p') {
            Inorder(ROOT);
            printf("\n");
            Preorder(ROOT);
            printf("\n");
        }
        else if (s[0] == 'f') {
            int key;
            scanf("%d", &key);
            if (find(key) != NIL) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
        else if (s[0] == 'd') {
            int key;
            scanf("%d", &key);
            deleteNode(find(key));
        }
    }
}

Measured memory_bytes: 21484
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        
        System.out.println((a + b) * h / 2);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;
  ll N;
  cin >> N;
  ll cnt[15]={};
  
  cnt[0]++; //Takahashi-kun
  for(i=0; i<N; i++) { ll t; cin >> t; cnt[t]++;}
  
  ll f=0;
  for(i=1; i<=11; i++) if(cnt[i]>=3) f=1;
  if(cnt[0]>=2 || cnt[12]>=2) f=1;
  if(f) {pt(0); return 0;}
  
  
  ll ans=0;
  for(ll S=0; S<1<<11; S++) {
    vector<ll> l, r;
    for(i=1; i<=11; i++) {
      if(cnt[i]==1) {
        if(S>>i&1) l.push_back(i);
        else r.push_back(i);
      }else if(cnt[i]==2) {
        l.push_back(i);
        r.push_back(i);
      }
    }
    if(cnt[12]) l.push_back(12);
    
    ll t=INF;
    ll LS=l.size(), RS=r.size();
    if(LS) chmin(t, l[0]-0);
    for(i=0; i<LS-1; i++) chmin(t, l[i+1]-l[i]);
    
    if(RS) chmin(t, r[0]-0);
    for(i=0; i<RS-1; i++) chmin(t, r[i+1]-r[i]);
    
    if(LS&&RS) chmin(t, 24-(l[LS-1]+r[RS-1]));
    
    chmax(ans, t);
    
  }
  
  
  pt(ans);
  
}



Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        int i=0,Max=0, Min=0;
        long Sum = 0;
        int n = int.Parse(Console.ReadLine());
        string[] a = Console.ReadLine().Split(' ');
        do
        {
            int x = int.Parse(a[i]);
            if (i == 0)
            {
                Max = x; Min = x; Sum += (long)x;
            }
            else if (i > 0 & x > Max)
            {
                Max = x; Sum += (long)x;
            }
            else if (i > 0 & x < Min)
            {
                Min = x; Sum += (long)x;
            }
            else
                Sum += (long)x;
            i++;
        } while (i < n);
        Console.WriteLine("{0} {1} {2}",Min,Max,Sum);
    }
}

Measured memory_bytes: 9916
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

std::string S, T;

bool can_switch(int start){
  for (int i=0; i<T.length(); i++){
    if (S[start+i]!='?' && S[start+i]!=T[i]){
      return false;
    }
  }
  return true;
}

int main(){
  std::cin >> S;
  std::cin >> T;
  int last_replace = -1;
  if (S.length()<T.length()){
    printf("UNRESTORABLE\n");
    return 0;
  }

  for (int i=0; i<S.length()-T.length()+1; i++){
    if (can_switch(i)){
      last_replace = i;
    }
  }
  //printf("last_replace=%d\n",last_replace);

  if (last_replace==-1){
    printf("UNRESTORABLE\n");
    return 0;
  }

  for (int i=0; i<T.length(); i++){
    S[last_replace+i] = T[i];
  }
  for (int i=0; i<S.length(); i++){
    if(S[i]=='?'){
      S[i]='a';
    }
  }
  std::cout << S << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int a[45];

int fin(int);

int main(){
  int n,i;
  for(i = 0; i < 45; i++) a[i] = -1;

  scanf("%d",&n);
  printf("%d\n",fin(n));

  return 0;
}

int fin(int n){
  if(n == 0 || n == 1) return a[n] = 1;
  if(a[n] != -1) return a[n];
  return a[n] = fin(n-1) + fin(n-2);
}



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

const int P = 1000000007;

int n, m, f[1005][1005];
char mp[1005][1005];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++ i) scanf("%s", mp[i]);
	f[0][0] = 1;
	for (int i = 0; i < n; ++ i)
		for (int j = 0; j < m; ++ j) {
			if (mp[i][j] == '.') {
				if (i > 0) f[i][j] = (f[i][j] + f[i - 1][j]) % P;
				if (j > 0) f[i][j] = (f[i][j] + f[i][j - 1]) % P; 
			}
		}
	printf("%d\n", f[n - 1][m - 1]);
	return 0;
}


Measured memory_bytes: 5120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class AC073C
    {
#if true
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();

            Console.WriteLine(funcMain(s1,s2));
#if DEBUG
            Console.ReadKey();
#endif
        }

#else
        static void Main(string[] args)
        {
            test();
        }
#endif

        static private string funcMain(string arg1, string arg2)
        {
            string[] bufarray;
            bufarray = arg1.Split();
            int Ninzu = int.Parse(bufarray[0]);
            long OneTime = long.Parse(bufarray[1]);
            long TotalTime = 0;
            long NowTime = 0;

            foreach (long t in arg2.Split().Select(f => long.Parse(f)))
            {
                TotalTime += Math.Min(t - NowTime,OneTime);
                NowTime = t;
            }
            TotalTime += OneTime;
            return TotalTime.ToString();
        }

        static private void test()
        {
            string arg1, arg2;
            arg1 = "2 4";
            arg2 = "0 3";
            Console.WriteLine("7" == funcMain(arg1, arg2));
            arg1 = "2 4";
            arg2 = "0 5";
            Console.WriteLine("8" == funcMain(arg1, arg2));
            arg1 = "4 1000000000";
            arg2 = "0 1000 1000000 1000000000";
            Console.WriteLine("2000000000" == funcMain(arg1, arg2));
            arg1 = "1 1";
            arg2 = "0";
            Console.WriteLine("1" == funcMain(arg1, arg2));
            arg1 = "9 10";
            arg2 = "0 3 5 7 100 110 200 300 311";
            Console.WriteLine("67" == funcMain(arg1, arg2));
            Console.ReadKey();
        }

    }
}


Measured memory_bytes: 26592
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,c=0;cin>>a;
  rep(i,a){
    cin>>b;
    c+=b-1;
  }
  cout<<c;
}



Measured memory_bytes: 27076