akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  sort(s,s+N);

  int sum = 0;
  for(int i=0;i<N;i++){
    sum += s[i];
  }

  //全部10の倍数
  bool isok = true;
  for(int i=0;i<N;i++){
    if(s[i]%10 != 0){
      isok = false;
      break;
    }
  }
  if(isok){
    cout << 0 << endl;
    return 0;
  }


  if(sum%10 != 0){
    cout << sum << endl;
    return 0;
  }

  for(int i=0;i<N;i++){
    if((sum-s[i])%10 != 0){
      sum -= s[i];
      break;
    }
  }

  cout << sum << endl;
  return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int a,b,c[1001],d[1001],i,j,e[1001][1001],f[1001][1001],x,m;
int main(void)
{
	scanf("%d %d",&a,&b);
	for(i=0;i<=1000;i++){
		c[i]=0;
		d[i]=0;
	}
	for(i=0;i<=1000;i++){
		for(j=0;j<=1000;j++){
			f[i][j]=0;
		}
	}
	for(i=1;i<=a;i++){
		scanf("%d",&c[i]);
	}
	for(i=1;i<=b;i++){
		scanf("%d",&d[i]);
	}
	for(i=0;i<=b;i++){
		for(j=0;j<=a;j++){
			if(c[i+1]*d[j+1]+f[i][j]<f[i+1][j+1] || f[i+1][j+1]==0){
				if(j<=i && b>=i+1 && a>=j+1){
					f[i+1][j+1]=f[i][j]+c[j+1]*d[i+1];
				}
			}
			if(f[i][j]+c[j+1]*d[i+1]>f[i][j+1] || f[i+1][j+1]==0){
				if(j<=i && b>=i+1 && a>=j+1&& f[i][j+1]!=0){
					f[i+1][j+1]=f[i][j+1];
				}
			}
		}
	}
	printf("%d\n",f[b][a]);
	return 0;
}

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

int main()
{
    int N, M;
    cin >> N >> M;

    int a, b;
    vector<int> vec(N, 0);

    for (int i = 0; i < M; i++)
    {
        cin >> a >> b;
        vec.at(a - 1)++;
        vec.at(b - 1)++;
    }

    for (int i = 0; i < N; i++)
        cout << vec.at(i) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long mypow(long long x, int n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res *= x;
        x *= x;
        n >>= 1;
    }
    return res;
}
int main(){
	long long x;
	cin >> x;
	for(long long a=-118; a<=119; ++a){
		for(long long b=-119; b<=118; ++b){
			if(x==mypow(a,5)-mypow(b,5)){
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod

vec calcans(int N, int A, int B){
    if(N == 1) return vec({A, B});
    int i0;
    REP(i, N) if(((A ^ B) >> i) & 1){
        i0 = i;
        break;
    }
    int a = (A & (bit(i0) - 1)) + ((A >> (i0 + 1)) << i0);
    int b = (B & (bit(i0) - 1)) + ((B >> (i0 + 1)) << i0);
    int c = a ^ 1;
    vec v1 = calcans(N - 1, a, c), v2 = calcans(N - 1, c, b);
    vec ans;
    int p = (A >> i0) & 1;
    for(int x: v1){
        ans.pb((x & (bit(i0) - 1)) + ((x >> i0) << (i0 + 1)) + (p << i0));
    }
    p ^= 1;
    for(int x: v2){
        ans.pb((x & (bit(i0) - 1)) + ((x >> i0) << (i0 + 1)) + (p << i0));
    }
    return ans;
}

signed main(){

    int N, A, B; cin >> N >> A >> B;
    if(__builtin_popcountll(A ^ B) % 2 == 0){
        cout << "NO" << endl;
        return 0;
    }
    vec ans = calcans(N, A, B);
    cout << "YES" << endl;
    REP(i, bit(N)) cout << ans[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 2392
def base_convert(nl, ibase, obase):
    o = []
    while any(nl):
        c = 0
        for i in range(len(nl)):
            c = c * ibase + nl[i]
            nl[i], c = divmod(c, obase)
        o.append(c)
    o.reverse()
    return o


N = list(str(int(input())))
N = list(map(int, N))
p = base_convert(N, 10, 26)

ans = []
for _ in range(len(p)):
    for i in range(len(p)):
        if p[i] == 0 and i != 0:
            p[i - 1] -= 1
            p[i] = 26


pp = []
for i in range(len(p)):
    if p[i] != 0:
        pp.append(p[i])

ans = [chr(ord("a") + i - 1) for i in pp]
print("".join(ans))


Measured memory_bytes: 9200
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

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

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

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

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  string a,b,c; cin >> a >> b >> c;
  if (a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){
    cout << "YES";
  } else {
    cout << "NO";
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    int b[n];
    int c[n-1];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    for(int i=0;i<n-1;i++) cin>>c[i];
    
    int s=0;
    for(int i=0;i<n;i++) s+=b[i];
    for(int i=0;i<n-1;i++){
        if(a[i+1]-a[i]==1){
            s+=c[a[i]-1];
        }
    }
    cout<<s;
}


Measured memory_bytes: 256
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  S=pin()[:-1]
  ans=0
  T="CODEFESTIVAL2016"
  for i in range(16):
    if S[i]==T[i]:
      continue
    ans+=1
  print(ans)
  return 

main()

Measured memory_bytes: 9116
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n; map<char,ll> v;
  cin >> n >> v['A'] >> v['B'] >> v['C'];
  vector<string> s(n);
  rep(i,n) cin >> s[i];

  vector<char> ans;
  rep(i,n){
    auto f = [&](char l,char r){
      ll vl = v[l], vr = v[r];
      if(vl==0 && vr==0) return false;
      if(vl==0 || vr==0) {
        if(vr==0) swap(l,r);
        v[l]++; v[r]--; ans.push_back(l);
        return true;
      }
      if(vl>1 || vr>1 || i==n-1 || s[i]==s[i+1]){
        if(vl>vr) swap(l,r);
        v[l]++; v[r]--; ans.push_back(l);
        return true;
      }
      map<char,int> m;
      rep(ni,2)rep(si,2) m[s[i+ni][si]]++;
      char c;
      for(auto mi:m) if(mi.second==2) c = mi.first;
      if(c==r) swap(l,r);
      v[l]++; v[r]--; ans.push_back(l);
      return true;
    };
    bool ok = false;
    if(s[i] == "AB") ok = f('A','B');
    if(s[i] == "AC") ok = f('A','C');
    if(s[i] == "BC") ok = f('B','C');
    if(!ok){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  rep(i,n){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 6744
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var k = cin.ReadInt;

            Console.WriteLine(n - (k - 1));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int a[N][3];
    int b[3][101]{};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
            b[j][a[i][j]]++;
        }
    }
    int p[N]{};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            if (b[j][a[i][j]] == 1) {
                p[i] += a[i][j];
            }
        }
    }
    for (int i : p) {
        cout << i << "\n";
    }
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

int main()
{
  string a;
  cin >> a;
  string ans = a;

  
  
  cout << fixed << (a == "ABC" ? "ARC" : "ABC") << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
using std::cin;
using std::cout;
using std::endl;
using std::ios;


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

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

    if(A + B <= 16 && A <= 8 && B <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;

}

Measured memory_bytes: 256
n = int(raw_input())

jpy = 0.0
btc_to_jpy = 380000.0

for i in range(0, n):
  v, c = raw_input().split()
  c = c.upper()
  v = float(v)
  if 'JPY' == c:
    jpy += v
  elif 'BTC' == c:
    jpy += v*btc_to_jpy

print jpy
    

Measured memory_bytes: 2568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String N = in.next();
			if(N.charAt(0) == N.charAt(2)) {
				out.println("Yes");
			} else {
				out.println("No");
			}
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int main(){

    string s;cin>>s;
    int K;cin>>K;

    for(int i=0;i<s.size();i++){
        int d = ('z'- s[i] +1)%26;
        if(d<=K){
            s[i]='a';
            K-=d;
        }
    }

    K%=26;

    s[s.size()-1] = (char)(s[s.size()-1] + K);
    cout<<s<<endl;

    return 0;
}

Measured memory_bytes: 640
n = int(input())
if n == 0:
    print(0)
else:
    ans = ""
    while n != 1:
        if n % -2:
            ans += str(n % 2)
            n = n // -2 + 1
        else:
            ans += "0"
            n //= -2
    ans += "1"
    print("".join(reversed(ans)))

Measured memory_bytes: 3060
"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""


import sys
from collections import Counter as C
def data(): return sys.stdin.readline().strip()
def out(var): sys.stdout.write(str(var))
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)


d = C()
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            d[i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i] += 1
n = int(data())
for i in range(1, n+1):
    out(str(d[i])+"\n")


Measured memory_bytes: 72252
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
  int n,flg = 0;
  cin >> n;
  
  for(int i=1; i<=9; i++){
    for(int j=1; j<=9; j++){
      if(n == i * j) flg = 1;
    }
  }

  if(flg == 0) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut sum: f64 = 0.0;
    for _i in 0..n {
        let a = read::<f64>();
        sum += 1.0 / a;
    }
    println!("{:.8}", 1.0 / sum);
}


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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans1 = (N / (A + B)) * A;
    ll ans2 = (N % (A + B));
    if (ans2 > A)
    {
        cout << ans1 + A;
    }
    else
    {
        cout << ans1 + ans2 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s;
    cin >> s;

    ll l, r;
    ll flag = 0;
    rep(i, s.size()) {
        if(!flag && s[i] == 'A') {
            l = i;
            flag = 1;
        }
        if(s[i] == 'Z') {
            r = i+1;
        }
    }
    out(r - l);
    re0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,s;
int a[200200];
int t[200200];
bool check(int x)
{
	for(int i=1;i<=s;++i)
		if(a[i]<=x)t[i]=0;
		else t[i]=1;
	int fl=0;
	int d0=s,d1=s;
	for(int i=1;i<=s;++i)
	{
		int c=0,dis=abs(n-i);
		for(;t[i+c+1]==t[i]&&i+c+1<=s;c++)dis=min(dis,abs(n-(i+c+1)));
		if(c>=1)
		{
			fl=1;
			if(t[i]==0)d0=min(d0,dis);
			else d1=min(d1,dis);
		}
		i=i+c;
	}
	if(!fl)return t[1];
	if(d0<d1)return 0;
	else return 1;
}
int main()
{
	scanf("%d",&n),s=n*2-1;
	int l=0,r=0,mid;
	for(int i=1;i<=s;++i)scanf("%d",&a[i]),r=max(r,a[i]);
	while(l<=r)
	{
		mid=(l+r)/2;
		if(check(mid))l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",l);
	return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define U1 unsigned char
#define S1 char
#define	S4 int
#define S8 long

#define TRUE					(1)
#define FALSE					(0)

#define NUM_LINE                (3) /* 計算に使う辺の数 */

#define FIRST_LINE_IDX			(0) /* 1番小さな辺の添え字 */
#define SECOND_LINE_IDX         (1) /* 2番目に大きな辺の添え字 */

#define RADIUS_TO_DIAMETER		(2) /* 半径を直径に変換する定数 */

/* qsort用比較関数 */
int comp(const void* vd_ap_var1, const void* vd_ap_var2)
{
	return *(S4*)vd_ap_var1 - *(S4*)vd_ap_var2;
}

S4 main(void)
{
	U1 u1_t_isCompleteCalc;		/* 計算完了フラグ */
	S4 s4_t_sumLineLength;		/* 計算完了確認用の変数（辺がすべて0なら計算終了) */

	/* チーズの高さ・幅・奥行と操作用の添え字 */
	S4 s4_t_lines[NUM_LINE];
	S4 s4_t_lineIdx;

	S4 s4_t_cnt;			/* 入口の数カウント用の変数 */
	S4 s4_t_numEnterance;	/* 入口の数 */
	U1 u1_t_delimiter;		/* scanfで改行を捨てるための変数 */
	S4 s4_t_radius;			/* 入口の半径 */
	S4 s4_t_CheeseHypotenuse;/* チーズの斜辺 */
	S4 s4_t_diameter;		/* 入口の直径 */

	u1_t_isCompleteCalc = (U1)FALSE;

	while (u1_t_isCompleteCalc != (U1)TRUE)
	{
		/* チーズの高さ・幅・奥行を入力 */
		s4_t_sumLineLength = (S4)0;
		for (s4_t_lineIdx = (S4)0; s4_t_lineIdx < (S4)NUM_LINE; s4_t_lineIdx++)
		{
			(void)scanf("%d", &s4_t_lines[s4_t_lineIdx]);
			s4_t_sumLineLength += s4_t_lines[s4_t_lineIdx];
		}

		/* 辺がすべて０なら計算完了 */
		if (s4_t_sumLineLength <= (S4)0)
		{
			u1_t_isCompleteCalc = (U1)TRUE;
		}
		else
		{
			/* チーズの高さ・幅・奥行のうち、小さな２辺が分かれば、チーズを入口に通せるか判定できる */
			qsort(s4_t_lines, (size_t)NUM_LINE, sizeof(S4), comp);

			s4_t_CheeseHypotenuse = sqrt((double)(s4_t_lines[FIRST_LINE_IDX] * s4_t_lines[FIRST_LINE_IDX] + s4_t_lines[SECOND_LINE_IDX] * s4_t_lines[SECOND_LINE_IDX]));

			/* 入口の数を入力 */
			(void)scanf("%d%c", &s4_t_numEnterance, &u1_t_delimiter);

			for (s4_t_cnt = (S4)0; s4_t_cnt < s4_t_numEnterance; s4_t_cnt++)
			{
				/* 円に接する正方形の辺の長さは半径の√2倍 */
				(void)scanf("%d%c", &s4_t_radius, &u1_t_delimiter);
				s4_t_diameter = s4_t_radius * (S4)RADIUS_TO_DIAMETER;
				if (s4_t_CheeseHypotenuse < s4_t_diameter)
				{
					printf("OK\n");
				}
				else
				{
					printf("NA\n");
				}
			}
		}
	}
	return((S4)0);
}
 


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int64_t A, B;
    cin >> A >> B;

    uint64_t ans = A%2?A:0;
    if((A+B) % 2){
        if(A % 2) ans ^= ((B-A-1)/2)%2;
        else      ans ^= ((B-A+1)/2)%2;
    }else{
        ans ^= ((B-A)/2)%2;
    }
    if(B % 2 == 0) ans ^= B;
    cout << ans << endl;
    
    return 0;
}

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

main() {
	string s;
	getline(cin, s);
	for (int i = 0; i < s.size(); i++) {
		if ('a' <= s[i] && s[i] <= 'z') cout << (char)toupper(s[i]);
		else if ('A' <= s[i] && s[i] <= 'Z') cout << (char)tolower(s[i]);
		else cout << (char)s[i];
	}
	cout << endl;
}


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

using namespace std;

#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  double n,t,a,h,huga=10000,hoge,shake=10000;
  int ans=0;
  cin>>n>>t>>a;
  //$BI89b$,(B x $B%a!<%H%k$NCOE@$G$NJ?6Q5$29$O(B 
  //T $B!](B x $B!_(B 0.006 $BEY$G$9(B
  //joisino$B$*I1MM$O!"$3$l$i$NCf$+$iJ?6Q5$29$,(BA$BEY$K(B
  //$B:G$b6a$$COE@$rA*$s$G5\EB$r7z@_$9$k$h$&$K(B
  //$B$"$J$?$KL?$8$^$7$?!#(B
  //$B5\EB$r7z@_$9$Y$-COE@$NHV9f$r=PNO$7$F$/$@$5$$!#(B
  rep(i,n){
    cin>>h;
    hoge=t-h*0.006;
    if(hoge>=0){
      if(abs(a-hoge)<shake)shake=abs(a-hoge);
    }else{
      if(abs(hoge-a)<shake)shake=abs(hoge-a);
    }
    if(shake<huga){
      huga=shake;
      ans=i+1;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = 4.0 * atan(1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    int K; cin >> K;
    string S; cin >> S;

    int size = S.size();

    if (size <= K) cout << S << endl;
    else cout << S.substr(0, K) + "..." << endl;
    
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  string s; cin >> s;
  int w = 0, r = 0;
  rep(i,n){
    if(s[i] == 'W') w++;
    if(s[i] == 'R') r++;
  }
  int cnt = 0;
  rep(i,r) if(s[i] == 'R') cnt++;
  cout << min(r,r-cnt);
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <random>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
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; }
typedef long long ll;
ll rand26() {
  random_device rnd;
  mt19937 mt(rnd());
  uniform_real_distribution<> rand(0, 25);
  return (ll)rand(mt);
}
int main()
{
  ll D; cin >> D;
  vector<ll> c(26);
  rep(i,26) cin >> c[i];
  vector<vector<ll>> s(D, vector<ll>(26));
  vector<ll> t(D);  
  rep(i,D) {
    ll smax = -1;
    rep(j,26) {
      cin >> s[i][j];
      if(smax <= s[i][j]) {
	smax = s[i][j];
	t[i] = j;
      }
    }
  }

  
  ll m = 26*365*2;
  vector<ll> d(m), q(m);
  rep(k,2) {
    rep(i,26) {
      rep(j,365) {
	d[k*26*365 + i*365 + j] = j;
	q[k*26*365 + i*365 + j] = i;
      }
    }
  }
  
  vector<set<ll>> st(26);
  rep(i,26) {
    st[i].insert(-1);
    st[i].insert(D);    
  }
  rep(i,D) {
    st[t[i]].insert(i);
  }

  ll res = 0;
  // ペナルティ
  vector<ll> pen(26, 0);
  rep(i,26) {
    auto it = st[i].begin();
    it++;
    while(it != st[i].end()) {
      auto it2 = it;
      it2--;
      ll x = *it - *it2 - 1;
      res -= x * (x + 1) / 2 * c[i];
      pen[i] += x * (x + 1) / 2 * c[i];
      it++;
    }
  }
  rep(i,D) {
    res += s[i][t[i]];
  }

  rep(i,m) {
    ll oldres = res;
    ll old = t[d[i]];
    ll neww = q[i];
    set<ll> oldst1 = st[old];
    set<ll> oldst2 = st[neww];    
    ll oldpen1 = pen[old];
    ll oldpen2 = pen[neww];
    
    res += s[d[i]][neww] - s[d[i]][old];
    st[old].erase(d[i]);
    st[neww].insert(d[i]);    
    // old
    res += pen[old];
    pen[old] = 0;
    auto it = st[old].begin();
    it++;
    while(it != st[old].end()) {
      auto it2 = it;
      it2--;
      ll x = *it - *it2 - 1;
      res -= x * (x + 1) / 2 * c[old];
      pen[old] += x * (x + 1) / 2 * c[old];
      it++;
    }
    // new
    res += pen[neww];
    pen[neww] = 0;
    it = st[neww].begin();
    it++;
    while(it != st[neww].end()) {
      auto it2 = it;
      it2--;
      ll x = *it - *it2 - 1;
      res -= x * (x + 1) / 2 * c[neww];
      pen[neww] += x * (x + 1) / 2 * c[neww];
      it++;
    }

    if(oldres < res) {
      t[d[i]] = neww;
    }
    else {
      t[d[i]] = old;
      st[old] = oldst1;
      st[neww] = oldst2;
      pen[old] = oldpen1;
      pen[neww] = oldpen2;      
    }
  }

  rep(i,D) cout << t[i]+1 << "\n";
  
  return 0;
}


Measured memory_bytes: 3732
open Batteries
module EnumL = Enum.Labels
open Tuple

let dbg x = Printf.eprintf "[debug]%s\n" @@ dump x; x

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_lines n fmt f =
  List.Labels.map
    (List.range 1 `To n)
    ~f:(fun _ -> scan fmt f)
  |> List.enum

let scan_list cnv =
  let l = read_line ()
          |> String.split_on_char ' '
          |> List.map cnv in
  List.enum l

let scan_lists n cnv =
  let ll = List.Labels.map (List.range 1 `To n)
      ~f:(fun _ -> scan_list cnv) in
  List.enum ll

let scan_array n m e conv =
  let arr = Array.make_matrix n m e in
  EnumL.iter (0 --^ n)
    ~f:(fun i -> arr.(i) <- Array.of_enum @@ scan_list conv);
  arr

let (n, m) = scan "%d %d" Tuple2.make
let lights = scan_lists m Int.of_string
let onoff = scan_list Int.of_string

let rec superset e =
  match Enum.get e with
  | None -> List.enum [Enum.empty ()]
  | Some v ->
    let f = superset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun f -> let h = Enum.clone f in push h v; h)
    |>  Enum.append g

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let () =
  let sets = superset (1 -- n) in
  EnumL.map sets ~f:(fun set ->
      (* EnumL.map (Enum.combine (Enum.clone onoff) (Enum.clone lights)) *)
      EnumL.map (Enum.combine (Enum.clone onoff, Enum.clone lights))
        ~f:(fun (b, l) ->
            let n = Enum.count @@
              intersection set @@ Enum.skip 1 @@ Enum.clone l
            in n mod 2 = b)
      |> EnumL.for_all ~f:((=) true))
  |> EnumL.filter ~f:((=) true)
  |> Enum.count
  |> Printf.printf "%d\n"


Measured memory_bytes: 5632
n=int(input())
p=[]
for i in range(n):
    s,t=input().split()
    p.append([s,int(t)])
p.append(["eol", 0])
x=input()
su=0
for i in p:
    su+=i[1]
sud=0
c=0
for i in p:
    sud+=p[c][1]
    if p[c][0]==x:
        break
    c+=1
print(su-sud)

Measured memory_bytes: 3064
#include<stdio.h>

int s,memo[31];

int func(int);

int main(void)
{

  int n,S,i;

  for(i=0;i<31;i++)
    memo[i]=-1;

  while(1)
    {
      scanf("%d",&n);
      if(n==0)break;
      s=0;
      s=func(n);
      S=s/3650+1;
      printf("%d\n",S);
}

  return 0;
}

int func(int n)
{

  if(n==0 || n==1)return 1;
  if(n==2)return 2;
  if(n==3)return 4;
  if(n<0)return 0;
  if(memo[n]==-1)
    {
      int result=0;
      result+=func(n-3);
      result+=func(n-2);
      result+=func(n-1);
      memo[n]=result;
    }
  
  return memo[n];
}

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

int main() {
  int N;
  cin >> N;
  vector<int> D1(N);
  vector<int> D2(N);
  for(int i=0; i<N; i++){
    cin >> D1.at(i) >> D2.at(i);
  }
  bool ans=false;
  int count=0;
   for(int i=0; i<N-2; i++){
   if(D1.at(i)==D2.at(i) && D1.at(i+1)==D2.at(i+1) && D1.at(i+2)==D2.at(i+2)){
     ans=true;
   }
  }
 
 
if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define tiii tuple<int,int,int>
#define tiiii tuple<int,int,int,int>
#define mii map<int,int>
#define popcount __builtin_popcountll

const int INF = 1LL<<60;
const int MOD = 998244353;

template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
string to_string(string s) {return s;}
template <typename A, typename B>
string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) { return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";}
template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

string bin_string(int x) {
    const int d = 32;
    string result(d, ' ');
    RREP(i, d-1, -1) result[d-1-i] = '0'+((x&1LL<<i)!=0);
    return result;
}

int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int n,a,b;
    cin >> n >> a >> b;
    if ((b-a)%2==0) cout << (b-a)/2;
    else {
        int res = a + abs(b-a-1)/2;
        int res2 = n-b+1 + abs(n-(n-b+1+a))/2;
        cout << min(res, res2);
    }
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 251

int parent(int i);
int left(int i);
int right(int i);

int main(){
  int tree[MAX],n;
  int i;

  scanf("%d",&n);

  for (i = 1;i <= n;i++)
    scanf("%d",&tree[i]);

  for (i = 1;i <= n;i++){
    printf("node %d: ",i);
    printf("key = %d, ",tree[i]);
    
    if (parent(i) >= 1)
      printf("parent key = %d, ",tree[parent(i)]);

    if (left(i) <= n)
      printf("left key = %d, ",tree[left(i)]);

    if (right(i) <= n)
      printf("right key = %d, ",tree[right(i)]);

    printf("\n");
  }
  
  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return i*2;
}

int right(int i){
  return i*2 + 1;
}



Measured memory_bytes: 2052
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

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

    std::cout<<(x < 1200 ? "ABC" : "ARC")<<std::endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i

arr = []
while n > 0
  arr << (n % 26 == 0 ? 26 : n % 26)
  n = (n - 1) / 26
end
arr.reverse!

ans = ("a".."z").to_a
puts arr.map { |s| s == 0 ? "a" : ans[s - 1] }.join


Measured memory_bytes: 14240
a = $<.map{|l| i, t = l.split.map(&:to_f); [i.to_i, t] }
rest = []
a.each_slice(8){|g|
    g.sort_by!(&:last)
    g[0..1].each{|x| printf("%d %.2f\n", *x)}
    rest += g[2..7]
}
rest.sort_by!(&:last)
rest[0..1].each{|x| printf("%d %.2f\n", *x)}

Measured memory_bytes: 8740
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

void solve()
{
	ll a,b;
	cin>>a>>b;
	if(b==1)
		{
			cout<<0;
			return;
		}
	ll r=1e8,l=1,mid,ans=1e8;
	while(l<=r)
	{
		mid=l+r>>1;
		if(mid*a-mid+1>=b)
			ans=mid,r=mid-1;
		else
			l=mid+1;
	}
	cout<<ans;

}
int main()
{


	int t;
	// cin>>t;
	t = 1;
	while (t--) solve();


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M,K=1,C;
ll A,B,W;
ll T,a,b;
double v[55],D[55];
ll ans=0;
int l;
bool h;
//bool D[100005];
ll S[50][50]={};
char str1[100005],str2[4][100005];
map<string,int> m;

int main(){
	cin>>N;
	str2[0][0]='S';
	str2[0][1]='S';
	str2[1][0]='S';
	str2[1][1]='W';
	str2[2][0]='W';
	str2[2][1]='S';
	str2[3][0]='W';
	str2[3][1]='W';
	for(int i=0;i<N;++i){
		cin>>str1[i];
	}
	for(int i=0;i<4;++i){
		l=0;
		for(int j=1;j<N-1;++j){
			if(str2[i][j]=='S'){
				if(str1[j]=='o')str2[i][j+1]=str2[i][j-1];
				if(str1[j]=='x'&&str2[i][j-1]=='S')str2[i][j+1]='W';
				if(str1[j]=='x'&&str2[i][j-1]=='W')str2[i][j+1]='S';
			}
			if(str2[i][j]=='W'){
				if(str1[j]=='x')str2[i][j+1]=str2[i][j-1];
				if(str1[j]=='o'&&str2[i][j-1]=='S')str2[i][j+1]='W';
				if(str1[j]=='o'&&str2[i][j-1]=='W')str2[i][j+1]='S';
			}

		}
		if(str2[i][N-1]=='S'){
			if(str1[N-1]=='o'&&str2[i][0]==str2[i][N-2])l++;
			if(str1[N-1]=='x'&&str2[i][N-2]!=str2[i][0])l++;
		}
		if(str2[i][N-1]=='W'){
			if(str1[N-1]=='x'&&str2[i][0]==str2[i][N-2])l++;
			if(str1[N-1]=='o'&&str2[i][N-2]!=str2[i][0])l++;
		}
		if(str2[i][0]=='S'){
			if(str1[0]=='o'&&str2[i][N-1]==str2[i][1])l++;
			if(str1[0]=='x'&&str2[i][N-1]!=str2[i][1])l++;
		}
		if(str2[i][0]=='W'){
			if(str1[0]=='x'&&str2[i][N-1]==str2[i][1])l++;
			if(str1[0]=='o'&&str2[i][N-1]!=str2[i][1])l++;
		}
		if(l==2){
			for(int j=0;j<N;++j)cout<<str2[i][j];
			cout<<endl;
			h=true;
			break;
		}
	}
	if(!h)cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 896
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum
import sys

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)


def 関数(x, n, p_liste):
    if n == 0:
        return x
    
    if x not in p_liste:
        return x
    chikai = x-1
    plus = x + 1

    for _ in range(0,101):
        #print(p_liste)
        if chikai not in p_liste:
            return chikai
        elif plus not in p_liste:
            return plus
        else: 
            plus += 1
            chikai -= 1
    return "問題"

def çözmek():
    X,N = map(int,sys.stdin.readline().split())
    P_liste = list(map(int, sys.stdin.readline().split()))

   
    res = []
    res.append(関数(X,N,P_liste))
    print(*res, sep="\n")

if __name__ == "__main__":
    çözmek()


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

using namespace std;

int main(){
  int k, n;
  cin >> k >> n;
  vector <int> a(n);
  for (int i = 0; i < n; i++)
   cin >> a[i];
  int minp = 1<<29;
  for (int i = 0; i < n - 1; i++){
    minp = min(minp, k - (a[i+1]-a[i]));
  }
  minp = min(minp,  a[n-1] - a[0]);
  cout << minp;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<algorithm>
class kuohao{
    public:
    int must_have=0;
    int this_num=0;
    int countl=0;
    bool operator<(const kuohao& a){
        if(this->must_have>0&&a.must_have>0){
            if(this->this_num<0&&a.this_num<0){
                return this->countl>a.countl;
            }
            return this->this_num>a.this_num;
        }
        return (this->must_have)<(a.must_have);
    }
};
int main(){
    int n;
    std::cin>>n;
    std::string strs[n];
    kuohao k[n];
    for(int i=0;i<n;++i){
        std::cin>>strs[i];
    }
    for(int i=0;i<n;++i){
        int temp=strs[i].size(); 
        int count=0;
        int countl=0;
        int countMH=0;
        for(int j=0;j<temp;++j){
            if(strs[i][j]=='('){
                ++count;
                ++countl;
            }
            if(strs[i][j]==')'){
                --count;
                --countl;
            }
            if(count<countMH){
                ++(k[i].must_have);
                countMH=count;
                countl=0;
            }
        }
        k[i].this_num=count;
        k[i].countl=countl;
    }
    std::sort(k,k+n);
    int count=0;
    for(int i=0;i<n;++i){
        if(count>=k[i].must_have){
            count+=(k[i].this_num);
        }
        else{
            int j;
            for(j=i+1;j<n;++j){
                if(count>=k[j].must_have&&k[j].must_have!=-1){
                    if(k[j].this_num<0){
                        std::cout<<"No"<<std::endl;
                        return 0;
                    }
                    count+=(k[j].this_num);
                    k[j].must_have=-1;
                    k[j].this_num=0;
                    --i;
                    break;
                }
            }
            if(j>=n){
                std::cout<<"No"<<std::endl;
                return 0;
            }
        }
    }
    if(count==0){
        std::cout<<"Yes"<<std::endl;
    }
    else{
        std::cout<<"No"<<std::endl;
    }
    return 0;
}


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

int main(){
  int k,a,b;
  string ans = "NG";
  cin >> k >> a >> b;
  for(int i=a; i<=b;i++){
    if(i%k==0){
      ans = "OK";
      break;
    }
  }
  cout << ans << endl;
}

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

const int DIGIT = 8;

int main(){
	int n, input;

	cin >> n;
	for ( int i = 0; i < n; ++i ){
		int max = 0, min = 0, multi = 1;
		int list[ DIGIT ] = { 0 };
		cin >> input;

		for ( int j = 0; j < DIGIT; ++j ){
			++list[ j ] = input % 10;
			input /= 10;
		}

		for ( int j = 0; j < DIGIT - 1; ++j ){
			for ( int k = 0; k < DIGIT - 1 - j; ++k ){
				if ( list[ k ] > list[ k + 1 ] ){
					int t = list[ k ];
					list[ k ] = list[ k + 1 ];
					list[ k + 1 ] = t;
				}
			}
		}

		for ( int j = 0; j < DIGIT; ++j ){
			max += list[ j ] * multi;
			min += list[ DIGIT - 1 - j ] * multi;
			multi *= 10;
		}

		cout << max - min << endl;

	}
	return 0;
}

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

int main()
{
	string S;
	int result = 0;
	cin >> S;
	int s_len = S.length();

	for (int i = 1; i < s_len - 1; i++) {
		if ((s_len - i) % 2 != 0) { continue; }
		int length = (s_len - i)/2;
		string str1 = S.substr(0, length);
		string str2 = S.substr(length, length);
		if (str1 == str2) {
			result = length*2;
			break; 
		}
	}
	cout << result << flush;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<ll,ll> P;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // not prime num
            return false;
        }
    }
    // prime num
    return true;
}

struct edge{
    int cost, to;

    edge(int in_cost, int in_to){
        cost=in_cost;
        to=in_to;
    }
    bool operator<(const edge &a) const
    {
        return cost > a.cost;
    }
};

int N=0;
bool isJudge(int monster, vector<int>a){
    ll moster_size=a[monster];

    for(int i=0; i<N; i++){
        if(i==monster)continue;

        if(2*moster_size>=a[i]){
            moster_size+=a[i];
        }else{
            // 吸収不可能なモンスターが見つかった場合
            // これ以上吸収不可能
            return false;
        }
    }

    return true;
}


int main() {
    string S;
    int ans=0;
    cin >> S;

    int l=0, r=S.size()-1;
    while(l<=r){
        if(S[l]==S[r]){
            l++;
            r--;
        }else if(S[l]=='x' && S[r]!='x'){
            l++;
            ans++;
        }else if(S[l]!='x' && S[r]=='x'){
            r--;
            ans++;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;
    return 0;
}


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

int sumofdigits(int n){
  int sum = 0;
  
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
    

int main(){
  int N , a, b;
  cin>>N>>a>>b;
  
  int total = 0;
  
  for(int i=1; i <= N; i++){
    int sum = sumofdigits(i);
    if(sum >= a && sum <= b)
      total += i;
  }
  cout<<total<<endl;
}

    
    
  

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  string s;
  cin >> s;

  if (s[0] == '0') {

    int cnt = 0;
    for (int i = 1; i < s.length(); ++i) {
      if (i % 2 != 0 && s[i] == '0') ++cnt;
      else if (i % 2 == 0 && s[i] == '1') ++cnt;
    }

    cout << cnt << "\n";
  }

  else {

    int cnt = 0;
    for (int i = 1; i < s.length(); ++i) {
      if (i % 2 != 0 && s[i] == '1') ++cnt;
      else if (i % 2 == 0 && s[i] == '0') ++cnt;
    }

    cout << cnt << "\n";
  }

  return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll N = 1e6 + 10;


int main(){
	ll n;
	cin >> n;
	pll Now = {0, 0};
	ll time = 0;
	for (int i = 0; i < n; i++){
		ll t, x, y;
		cin >> t >> x >> y;
		if (t - time < abs(x - Now.F) + abs(y - Now.S)){
			return cout << "No", 0;
		}
		if ((t - time - (abs(x - Now.F) + abs(y - Now.S))) % 2 == 1){
			return cout << "No", 0;
		}
		Now = {x, y};
		time = t;
	}
	cout << "Yes";


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, H, W;
    cin >> N >> H >> W;
    vector<vector<int>> V(N, vector<int>(2));
    rep(i, N) cin >> V.at(i).at(0) >> V.at(i).at(1);

    int cnt = 0;
    rep(i, N) {
        if(V.at(i).at(0) >= H && V.at(i).at(1) >= W) cnt++;
    }
    cout << cnt << endl;
}

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

long long d=1;

int S(long long x){
	if(!x) return 0;
	return x%10+S(x/10);
}

long long f(long long n){
	if(S(n+d*10)*(n+d) > (n+d*10)*S(n+d)) d*=10;
	return n+d;
}

int main(){
	int K;
	cin  >> K;
	int cur=1;
	long long n=1;
	for(int i=0;i<K;i++){
		if(i!=0) n=f(n);
		cout << n << endl;
	}
}


Measured memory_bytes: 256
let sl = Str.split (Str.regexp " ") @@ read_line ()
let il = List.map int_of_string sl

let calc l =
  let rec func five seven = function
    | [] -> if five = 2 && seven = 1 then print_endline "YES"
      else print_endline "NO"
    | x :: l' ->
      match x with
        5 -> func (five+1) seven l'
      | 7 -> func five (seven+1) l'
      | _ -> print_endline "NO"
  in func 0 0 l

let () = calc il

Measured memory_bytes: 384