akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#define max_n 999999
#define INF 1000000
int prime[max_n];
bool is_prime[max_n+1];
int main(){
    for(int i=0; i<max_n; i++){
        prime[i] = INF;
        is_prime[i]=true;
    }
    int p = 0;
    is_prime[1]=false;
    is_prime[0]=false;
    for(int i=2;i<max_n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<max_n;j+=i)is_prime[j]=false;
        }
    }
    int n;
    while(scanf("%d",&n)!=EOF){
        //printf("%d\n",n);
        int ans = 0;
        for(int i =0; i<max_n; i++){
            if(prime[i]>n){
                ans = i;
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 7460
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P	  = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++) {
		s[i] = mod(s[i] - 'A' + n, 26) + 'A';
	}
	dump(s);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int yama,top1=0,top2=0,top3=0;
    for(int i=0;i<10;i++){
        cin >> yama;
        if(top1<yama){
            top3 = top2;
            top2 = top1;
            top1 = yama;
        }
        else if(top2<yama){
            top3 = top2;
            top2 = yama;
        }
        else if(top3<yama){
            top3 = yama;
        }
    }
    cout << top1 << "\n" << top2 << "\n" << top3 << "\n";
}

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

pub 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")
}

use std::cmp::{max, min};

fn main() {
  let n = read::<i32>();
  let d = read::<i32>();
  let mut x: Vec<Vec<i32>> = vec![];
  let mut count = 0;

  for _ in 0..n {
    let mut xi = vec![];
    for _ in 0..d {
      let xs = read::<i32>();
      xi.push(xs);
    }
    x.push(xi);
  }

  let mut ok_list = [false; 500000];

  for i in 1..401 {
    ok_list[i * i as usize] = true;
  }

  // println!("{:?}", ok_list);

  for i in 0..n {
    for j in i + 1..n {
      let a = &x[i as usize];
      let b = &x[j as usize];

      // println!("a: {:?} b:{:?}", a, b);

      let dist: i64 = a
        .iter()
        .enumerate()
        .map(|(i, v)| ((v - b[i]) * (v - b[i])) as i64)
        .sum();

      if ok_list[dist as usize] {
        count += 1;
      }

    }
  }
  println!("{}", count);
}



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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> hei(N);
  
  int num=0;
  for (int i=0; i<N; i++){
    cin >> hei.at(i);
    if (hei.at(i)>=K){
      num++;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

 /* Coding Space*/
class segtree{
public:
  int Node;
  vector<ll> table;
  segtree(int);
  ll ope(const ll,const ll);
  void update(int index,const ll value){ // index is 0-indexed.
    index += Node; // query function
    table[index] += value; // Check!!
    while(index > 0){
      index /= 2;
      table[index] = ope(table[2*index],table[2*index+1]);
    }
  }
  ll find(int l, int r);
};
ll segtree::find(int l,int r){ // l,r is 0-indexed.
    if(l == r) return table[r+Node];
    l += Node; r += Node;
    ll ans = 0; // Check!!
    for(; l <= r;l >>=1, r >>=1){
      if(r == l){ans=ope(ans,table[l]); return ans;}
      if(r%2 == 0) ans=ope(ans,table[r]),--r;
      if(l%2) ans=ope(ans,table[l]),++l;
    }
    return ans;
}
segtree::segtree(int Max_Node){  // initialize
  Node = 2;
  while(Node < Max_Node)
    Node *= 2;
  table.resize(2*Node);
  for(int i = Node;i < Node*2; i++)
    table[i] = 0; // initialize
  for(int i= Node-1; i > 0; i--)
    table[i] = ope(table[i*2],table[i*2+1]);
}
ll segtree::ope(const ll a,const ll b){
  return a+b;
}

int main(){
  segtree sg1(100010);
  segtree sg2(100010);
  int n,k; cin >> n >> k;
  rep(i,n){
    int in; cin >> in;
    sg1.update(i,in);
    if(in > 0)
      sg2.update(i,in);
  }
  ll ans = 0;
  rep(i,n-k+1){
    ans = max(ans,sg2.find(0,i-1) + sg1.find(i,i+k-1) + sg2.find(i+k,n-1));
    ans = max(ans,sg2.find(0,i-1) + sg2.find(i+k,n-1));
  }
  cout << ans <<endl;
}

Measured memory_bytes: 4480
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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 MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

class BIT {
private:
	ll N;
	vector<ll> node;
public:
	BIT(ll M) {
		node = vector<ll>(M + 1, 0);
		N = M;
	}

	ll sum(ll i) {
		ll s = 0;
		while (i > 0) {
			s += node[i];
			i -= i & -i;
		}
		return s;
	}

	ll sum(ll i, ll j) {
		ll l = sum(i - 1);
		ll r = sum(j);
		return r - l;
	}

	void add(ll i, ll x) {
		while (i <= N) {
			node[i] += x;
			i += i & -i;
		}
	}
};


int main()
{
    ll N; scanf("%lld", &N);
	vector<vector<ll>> g(100050);
	BIT bit(105000);
    for (ll i = 0; i < N; i++) {
        ll a, b; scanf("%lld %lld", &a, &b);
		a--;
		b--;
		g[a].push_back(b);
    }
	ll res = 0;
	for (ll i = 1; i <= N; i++) {
		for (auto e : g[i]) {
			bit.add(e, 1);
		}
		ll sm = bit.sum(i, 100030);
		//cout << sm << endl;
		if (sm >= i) chmax(res, i);
	}
    cout << res << endl;

    return 0;

}


Measured memory_bytes: 8152
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main() {
	while (1) {
		char str[1200];
		cin >> str;

		if (strcmp(str, "0") == 0) {
			break;
		}

		int total = 0;
		for (int i = 0; str[i] != NULL; i++) {
			total += (int)(str[i] - '0');
		}
		printf("%d\n", total);
	}
	return 0;
}

Measured memory_bytes: 1124
n,q=map(int,input().split())
s=input()
c1=[1 if (s[i]=="A" and s[i+1]=="C") else 0 for i in range(n-1) ]
#print(c1)
d=[list(map(int,input().split())) for i in range(q)]
c2=[0]*n
for i in range(1,n):
    #print(i)
    c2[i]=c2[i-1]+c1[i-1]
#print(c2)
for i in range(q):
    print(c2[d[i][1]-1]-c2[d[i][0]-1])



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

namespace ACBC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            if ((x == 3 )|| (x == 5) ||( x == 7 ))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
            Console.ReadKey();

            }
    }
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll r,d,x;cin>>r>>d>>x;
  for(int i=0;i<10;i++){
    x = r * x - d;
    cout<<x<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

const int inf = 2147483647;
const int MAX = 2e5 + 10;

//RMQ
struct SegTree {
    int N, dat[2*MAX];
    SegTree() {}
    SegTree(int n) {
        N = 1;
        while(N < n) N *= 2;
        for(int i = 0; i < 2*N-1; i++)
            dat[i] = inf;
    }
    // update k th element
    void update(int k, int a) {
        k += N-1; // leaf
        dat[k] = a; 
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    // min [a, b)
    int query(int a, int b) { return query(a, b, 0, 0, N); }
    int query(int a, int b, int k, int l, int r) {
        if(r <= a or b <= l) return inf;
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        return min(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};

signed main(){
    int n, q;
    cin >> n >> q;
    SegTree sg(n);
    rep(i, 0, q){
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0){
            sg.update(x, y);
        }else{
            cout << sg.query(x, y + 1) << endl;
        }
    }
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long[] candi = new long[]{
			A * X + B * Y,
			C * 2 * X + Math.Max(0, Y - X) * B,
			C * 2 * Y + Math.Max(0, X - Y) * A,
		};
		
		Console.WriteLine(candi.Min());
		
		
	}
	long A,B,C,X,Y;
	public Sol(){
		var d = ria();
		A = d[0]; B = d[1]; C = d[2]; X = d[3]; Y = d[4];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    int n,k;
    ll sum=0;
    cin >> n >> k;
    vector<int> x(n);
    rep(i,n)
        cin >> x[i];
    rep(i,n){
        if(abs(k-x[i])<x[i]){
            sum+=2*abs(k-x[i]);
        }else
            sum+=2*x[i];
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

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

int main() {
    int n, k, i;
    string s;
    cin >> n >> k;
    cin >> s;
    char t = s[0];
    int cnt = 1, a[100001] = {0, }, gc = 0;
    for (i = 1; i < n; i++) {
        if (t != s[i]) {
            a[gc++] = t == '0' ? -1 * cnt : cnt;
            cnt = 0;
            t = s[i];
        }
        cnt++;
    }
    a[gc++] = t == '0' ? -1 * cnt : cnt;
    cnt = 0;
    int sum = 0, lo = 0, hi = 0, ans = -1,now=0;
    // for(i=0;i<gc;i++){
    //     cout<<a[i] << " ";
    // }
    // cout<<endl;
    while (lo <= hi) {
        // cout<<"now = " << now << " sum = " << sum << endl;
        if(hi==gc)break;
        if (a[hi]<0){
            if(now==k){
                now-=a[lo]<0;
                sum-=abs(a[lo++]);
                continue;
            }
        }
        now+=a[hi]<0;
        sum+=abs(a[hi++]);
        ans=max(ans,sum);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,m,i,j,a,b,ans=0;
  	cin>>n>>m;
  	vector<ll> c(n);
  	for(i=0;i<n;i++){
		cin>>a>>b;
      	c[i]=100001*a+b;
    }
  	sort(c.begin(),c.end());
  	for(i=0;m>0;i++){
		if(c[i]%100001<m){
          ans+=(c[i]/100001)*(c[i]%100001);
          m-=c[i]%100001;
        }else{
          ans+=(c[i]/100001)*m;
		  cout<<ans<<endl;
		  return 0;
        }
    }
}

          

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int a[4],b[4],hit=0,blow=0;
int main(){while(cin>>a[1]>>a[2]>>a[3]>>a[0]>>b[1]>>b[2]>>b[3]>>b[0]){for(int i=0;i<4;i++){for(int ii=0;ii<4;ii++){if(a[i]==b[ii]){if(i==ii){hit++;}else{blow++;}}}}cout<<hit<<" "<<blow<<endl;hit=0;blow=0;}return 0;}


Measured memory_bytes: 1160
#include<stdio.h>

int main(){
  
 	char N[4];
	
  	scanf("%s",N);
  
  	for(int i=0;i<3;i++){
      if(N[i] =='7'){
      	printf("Yes");
        return 0;
      }
      
    }
  printf("No");
  
  return 0;
  
}

Measured memory_bytes: 1732
#include<stdio.h>
int main (){
	int a,b,c,d;
	
	scanf("%d %d %d",&a,&b,&c,&d);
	
	d=a+b+c;
	
	if(d<=21){
		printf("win");
	}
	
	else{
		printf("bust");
	}
	
	return 0;
	
}

Measured memory_bytes: 3232
#include<iostream>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cassert>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX 300001
 
using namespace std;
typedef unsigned long long ull;
int n,m,L,R;
char s[MAX],o[5];
set<ull> ans;
const ull B = 9973ULL;
const ull inv = 9063375710536127837ULL;
ull H,Bmax;
 
int main()
{
 
  Bmax = 1;
  L = R = 0;
  scanf("%d %d",&n,&m);
  scanf("%s",&s[0]);
  H = s[0];
 
  rep(_,m)
    {
      scanf("%s",&o[0]);
 
      if(o[0] == 'R')
	{
	  if(o[1] == '+')
	    {
	      R++;
	      Bmax *= B;
	      H = H + s[R]*Bmax; 
	    }
	  else
	    {
	      H = H - s[R]*Bmax;
	      Bmax = Bmax*inv;
	      R--;
	    }
	}
      else
	{
	  if(o[1] == '+')
	    {
	      H = (H-s[L])*inv;
	      Bmax *= inv;
	      L++;
	    }
	  else
	    {
	      L--;
	      H = H * B + s[L];
	      Bmax *= B;
	    }
	}
      /*
	cout << "Bmax = " << Bmax << endl;
	cout << "[" << L << "," << R << "]" << endl;
	cout << "s : ";
	REP(i,L,R+1)cout << s[i];
	cout << endl;
	cout << "hash : " << H << endl;
      */
      ans.insert(H);
    } 
 
  cout << ans.size() << endl;
 
  return 0;
}

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

int main() {
  long long N,K;
  cin >> N >> K;
  vector<long long> A(N);
  vector<long long> firs(N,-1);
  
  long long loop,l_1,l_2,now;
  
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  
  
  now = 1;
  for (int i=0; i<N+1200; i++) {
    if (i == K) {
      cout << now << endl;
      return 0;
    }
    if (firs[now-1] == -1) {
      firs[now-1] = i;
      now = A[now-1];
    }
    else {
      l_1 = firs[now-1];
      l_2 = i;
      loop = l_2 - l_1;
      break;
    }
  }
  
  long long ans = K % loop;
  for (;;) {
    if (ans < l_1) {
      ans += loop;
    }
    else {
      break;
    }
  }
  
  for (int i=0; i<N; i++) {
    if (firs[i] == ans) {
      cout << i+1 << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 6428
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
cd=[list(map(int,input().split())) for i in range(m)]
basyo=0
for i in range(n):
  saisyo=10**9+1
  for j in range(m):
    if saisyo>abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]):
      saisyo=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
      basyo=j
  print(basyo+1)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		if (n == 1)
			System.out.println("Hello World");
		else{
			int a = in.nextInt();
			int b = in.nextInt();
			System.out.println(a + b);
		}

	}

}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n, p; cin >> n;
    map<int, int> a;
    rep(i,n) {
        cin >> p;
        ++a[p];
    }
    if(a.size() == 1 && a.begin()->first == 0 && a.begin()->second == n) {
        cout << "Yes" << '\n';
        return 0;
    }
//  Debug
//    for(auto p : a) {
//        debug(p.first);
//        debug(p.second);
//    }
//    debug(a.size());
//    debug(a.begin()->second);
//    debug((++a.begin())->second);
//    debug(a.end()->second);

    if (n%3==0 && a.size() == 2 &&
        a.begin()->first == 0 &&
        a.begin()->second == n/3 &&
        (++a.begin())->second == 2*n/3) {
        cout << "Yes" << '\n';
    }
    else if (n%3 == 0 &&
            a.size() == 3 &&
            a.begin()->second == n/3 &&
            (++a.begin())->second == n/3 &&
            (--a.end())->second == n/3 &&
            (a.begin()->first ^ (++a.begin())->first ^ (--a.end())->first) == 0) {
        cout << "Yes" << '\n';
    }
    else cout << "No" << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var tree = new List<List<Tree>>();
            for (var i = 0; i < N; i++) tree.Add(new List<Tree>());

            for (var i = 0; i < N - 1; i++)
            {
                var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
                l[0]--;
                l[1]--;
                var model1 = new Tree();
                model1.To = l[1];
                model1.Cost = l[2];
                tree[l[0]].Add(model1);
                var model2 = new Tree();
                model2.To = l[0];
                model2.Cost = l[2];
                tree[l[1]].Add(model2);
            }

            var ans = Enumerable.Repeat(-1, N).ToArray();
            ans[0] = 0;
            var queue = new Queue<int>();
            queue.Enqueue(0);
            while (queue.Count > 0)
            {
                var v = queue.Dequeue();
                foreach (var t in tree[v])
                {
                    var u = t.To;
                    var w = t.Cost;
                    if (ans[u] != -1) continue;
                    ans[u] = (ans[v] + w) % 2;
                    queue.Enqueue(u);
                }
            }
            
            Console.WriteLine(string.Join("\n", ans));
        }
    }

    class Tree
    {
        public int To { get; set; }
        public int Cost { get; set; }
    }
}


Measured memory_bytes: 36364
#include<bits/stdc++.h>
using namespace std;
int n, c[300005], minn=1e9;
char s[300005];
int main(){
	scanf("%d%s", &n, (s+1));
	for(int i=1;i<=n;i++){
		if(s[i]=='W') c[i+1]++;
		else c[1]++, c[i]--;
	}
	for(int i=1;i<=n;i++) {
		c[i]+=c[i-1];
		minn=min(minn, c[i]);
	}
	cout<<minn;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
#define N 400005
using namespace std;
int n;
char s[N];
int a[N];
int cnt[N];
ll ans;
int main() {
  scanf ("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'B') a[i] = 1;
    else a[i] = 0;
  }
  for (int i = n; i >= 1; i--) {
    if (a[i] == 0) cnt[i]++;
    cnt[i] += cnt[i + 1];
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1) ans += cnt[i];
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int n,k,w;
int main(){
	scanf("%d%d",&n,&k);
	w=n*(n-1)/2;
	if(w-k<n-1){
		puts("-1");
		return 0;
	}
	printf("%d\n",w-k);
	int l=1,r=2;
	for(int i=1;i<=w-k;i++,r++){
		if(r>n){
			l++,r=l+1;
		}
		printf("%d %d\n",l,r);
	}
	return 0;
}

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

int main()
{
	char table[30];
	
	for(int i=0;i<26;i++)
	{
		table[i]='a'+i;
	}
	table[26]='.';
	table[27]='?';
	table[28]='!';
	table[29]=' ';
	
	std::string input,output;
	
	while(1)
	{
		std::cin>>input;
		if(std::cin.eof())break;
		output.erase();
		
		if(input.size()%2==0)
		{
			for(int i=0;i<input.size()-1;i+=2)
			{
				int c=input[i]-'0',r=input[i+1]-'0';
				if(r>5||r<=0||c>6||c<=0)
				{
					output="NA";
					break;
				}
				output+=table[(c-1)*5+r-1];
			}
		}
		else
		{
			output="NA";
		}
		std::cout<<output<<std::endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
#define x first
#define y second
#define mp make_pair

int x, y, a, b, c, cnt[3];
vector <pii> v;

bool cmp(pii x, pii y){
	return x.x > y.x;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> x >> y >> a >> b >> c;
for(int i = 0 ; i < a ; ++i){
	int val;
	cin >> val;
	v.push_back(mp(val, 1));
}
for(int i = 0 ; i < b ; ++i){
	int val;
	cin >> val;
	v.push_back(mp(val, 2));
}
for(int i = 0 ; i < c ; ++i){
	int val;
	cin >> val;
	v.push_back(mp(val, 0));
}
sort(v.begin(), v.end(), cmp);
int br = 0;
int i = 0;
ll sol = 0;
while(i < a + b + c && br < x + y){
	if(v[i].y == 1){
		if(cnt[0] < x){
			cnt[0]++;
			sol += (ll)v[i].x;
			br++;
		}
	}
	else if(v[i].y == 2){
		if(cnt[1] < y){
			cnt[1]++;
			sol += (ll)v[i].x;
			br++;
		}
	}
	else{
		sol += (ll)v[i].x;
		br++;
	}
	i++;
}
cout << sol << endl;

return 0;
}



Measured memory_bytes: 6512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = getInt(sc);

		if (n % 2 == 0) {
			System.out.println(0.5);
		} else {
			System.out.println((double) (n / 2 + 1) / n);
		}

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
      ll n,i;
      cin>>n;
      ll x[n+1][4],y[n+1][4];
      for(i=0;i<n;i++)
      {
            cin>>x[i][1]>>x[i][2]>>x[i][3];
      }
      vector<int>v;
      for(i=0;i<n;i++)
      {
            if(i==0)
            {
                  y[i][1]=x[i][1];
                  y[i][2]=x[i][2];
                  y[i][3]=x[i][3];
                  v.push_back(max(y[i][1],max(y[i][2],y[i][3])));
            }
            else{
                  y[i][1]=x[i][1]+max(y[i-1][2],y[i-1][3]);
                  y[i][2]=x[i][2]+max(y[i-1][1],y[i-1][3]);
                  y[i][3]=x[i][3]+max(y[i-1][2],y[i-1][1]);
                  v.push_back(max(y[i][1],max(y[i][2],y[i][3])));
            }
      }
      cout<<v[n-1]<<"\n";
     // for(i=0;i<v.size();i++){cout<<v[i]<<" ";}
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, n) for (auto i : (n))
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

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

  map<string, int> m;
  int maximum = 0;
  REP(i, N) {
    string s;
    cin >> s;
    m[s]++;
    maximum = max(maximum, m[s]);
  }

  for (const auto p : m) {
    if (p.second == maximum) cout << p.first << endl;
  }
}


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

int main()
{
	int N,M;
	int A[1000],B[1000];
	int vote[1000];
	int best;
	int i,j;
	
	scanf("%d %d",&N,&M);
	
	for(i=0;i<N;i++)scanf("%d",&A[i]);
	for(i=0;i<M;i++)scanf("%d",&B[i]);
	for(i=0;i<N;i++)vote[i]=0;
	
	for(i=0;i<M;i++)
	{
		for(j=0;j<N;j++)
		{
			if(B[i]>=A[j])
			{
				vote[j]++;
				break;
			}
		}
	}
	
	best=0;
	for(i=0;i<N;i++)
	{
		if(vote[best]<vote[i])best=i;
	}
	
	printf("%d\n",best+1);
	return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10;
const int inf = 0x3f3f3f3f;


int main()
{
    int n, t;
    cin >> n >> t;
    int a, minn = inf, maxn = 0;
    int diff[N];
    for (int i = 1; i <= n; i++)
    {
        cin >> a;
        diff[i] = max(a - minn, 0);
        minn = min(a, minn);
        maxn = max(diff[i], maxn);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        if (diff[i] == maxn)
            ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;



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

    if(a - b >= 0) cout << "delicious" << endl;
    else if(b - a <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    int[][] x = new int[n][d];

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < d; j++) {
        x[i][j] = sc.nextInt();
      }
    }

    int count = 0;

    for (int i = 0; i < n; i++) {
      for (int j = i+1; j < n; j++) {

        int k = 0;

        for (int h = 0; h < d; h++) {
          k += Math.pow(x[i][h]-x[j][h],2);
        }

        int s = (int)Math.sqrt(k);
        if (s*s == k) count++;

      }
    }


    System.out.println(count);

  }

}


Measured memory_bytes: 21204
import java.util.*;import java.util.stream.*;public class Main{public static void main(String[] g){Scanner c=new Scanner(System.in);int n=c.nextInt();int[] a=IntStream.range(0,n).map(i->c.nextInt()).toArray();int s=Arrays.stream(a).sum();BitSet b=new BitSet();b.set(s);IntStream.range(0,n).forEach(i->b.or(b.get(a[i],s+1)));System.out.println(b.nextSetBit((s+1)/2));}}



Measured memory_bytes: 273536
N = int(input().strip())
array = list(map(int, input().strip().split()))
x=1
l=len(array)
a=array.count(0)
if a>=1:
    print(0)
else:
    for i in range (l):
        x*=array[i]
        if x>1000000000000000000:
            x=-1
            break
    print(x)

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

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

  int cnt=0;
  for(int i=0;i<S.size();i++) if(S.at(i)=='o')  cnt++;
  if(cnt+15-S.size()>=8)  cout << "YES" << endl;
  else  cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
L=list(map(int,input().split()))
N=L[0]
K=L[1]
Q=L[2]
point=[K-Q]*N
for i in range(Q):
  ans=int(input())
  point[ans-1]+=1
for i in range(N):
  if point[i]>0 :
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 6596
import java.util.*;
import java.io.*;
import java.lang.*;

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

        if (a == b)
            System.out.println(c);
        else if (a == c)
            System.out.println(b);
        else if (c == b)
            System.out.println(a);
    }
}


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

int lcs(string x, string y) {
	static int c[1001][1001];
	int m = x.size();
	int n = y.size();
	int max1 = 0;
	x = ' ' + x;
	y = ' ' + y;
	for (int i = 0; i <= m; i++)c[i][0] = 0;
	for (int j = 1; j <= n; j++)c[0][j] = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (x[i] == y[j])c[i][j] = c[i - 1][j - 1] + 1;
			else c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			max1 = max(max1, c[i][j]);

		}
	}
	return max1;
}

int main() {
	string s1, s2;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}
	return 0;
}

Measured memory_bytes: 5128
N = int(input())
A = input()
B = input()
C = input()
Change = 0
for i in range(N):
    if A[i] == B[i] == C[i]:
        continue
    elif A[i] == B[i] or B[i] == C[i] or C[i] == A[i]:
        Change += 1
    else:
        Change += 2
print(Change)


Measured memory_bytes: 3060
N, We = map(int, input().split())

items = [list(map(int, input().split()))for _ in range(N)]
V = []
W = []
for item in items:
    key = 1
    v, w, m = item
    while m > 0:
        V.append(v*key)
        W.append(w*key)
        m -= key
        key = min(key*2,m)
        
num = len(V)
dp = [0 for w in range(We+1)]

for i in range(num):
    w = W[i]
    v = V[i]
    for j in reversed(range(w,We+1)):
        if dp[j] < dp[j-w] + v:
            dp[j] = dp[j-w]+v
            
print(dp[-1])


Measured memory_bytes: 6080
from collections import Counter
N = int(input())
S = Counter()
for i in range(N):
  s_i = input()
  S[s_i] += 1

M = int(input())
T = Counter()
for i in range(M):
  t_i = input()
  T[t_i] += 1

ans = 0
for k in S.keys():
  ans = max(ans, S[k]-T[k])
print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
int main(void){
    int n,i,j,g=0;
    scanf("%d\n",&n);
    int t[n];
    for(i=0;i<n;i++) scanf("%d",&t[i]);
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++)
            g+=t[i]*t[j];
    }
    printf("%d\n",g);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl

ll pow(int a){
    ll ans=1;
    REP(i,a){
        ans*=2;
        ans%=MOD;
    }
    return ans;
}

int main(){
    int n;
    cin>>n;
    unordered_map<int,int> cnt;
    REP(i,n){
        int a;
        cin>>a;
        if(n%2 == a%2 || cnt[a]==(a==0?1:2)){
            cout<<0<<endl;
            return 0;
        }
        cnt[a]++;
    }

    cout<<pow(n/2)<<endl;

    return 0;
}


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

struct list{
    int key;
    int prev;
    int next;
};

int main() {
    int n, num, pnt = 1, top_ad = 0, bot_ad = 1, j, count=0;
    string command;
    cin >> n;
    list lst[2000001]={};
    lst[0].key = 0;
    lst[0].prev = 0;
    lst[0].next = 1;
    for (int i=0; i<n; i++) {
        cin >> command;
        if (command == "insert") {
            cin >> num;
            lst[pnt].key = num;
            lst[pnt].next = pnt+1;
            lst[pnt].prev = top_ad;
            top_ad = pnt;
            pnt ++;
            count ++;
        } else if (command == "delete") {
            cin >> num;
            j = top_ad;
            while (j >= bot_ad && lst[j].key != num && j!=0) {
                j = lst[j].prev;
            }
            if(lst[j].key == num) {
                if (j == bot_ad) {
                    bot_ad = lst[bot_ad].next;
                } else if (j == top_ad) {
                    lst[lst[j].prev].next = lst[j].next;
                    lst[lst[j].next].prev = lst[j].prev;
                    top_ad = lst[top_ad].prev;
                } else {
                    lst[lst[j].prev].next = lst[j].next;
                    lst[lst[j].next].prev = lst[j].prev;
                }
                count--;
                if (count == 0) {
                    lst[2000001]={};
                    lst[0].next=1;
                    top_ad = 0;
                    bot_ad = 1;
                    pnt = 1;
                }
            }
        } else if (command == "deleteLast") {
            bot_ad = lst[bot_ad].next;
            count--;
            if (count == 0) {
                lst[2000001]={};
                lst[0].next=1;
                top_ad = 0;
                bot_ad = 1;
                pnt = 1;
            }
        } else if (command == "deleteFirst") {
            lst[lst[top_ad].prev].next = lst[top_ad].next;
            lst[lst[top_ad].next].prev = lst[top_ad].prev;
            top_ad = lst[top_ad].prev;
            count--;
            if (count == 0) {
                lst[2000001]={};
                lst[0].next=1;
                top_ad = 0;
                bot_ad =1;
                pnt = 1;
            }
        }
    }
    int b = top_ad;
    while (b > bot_ad) {
        cout << lst[b].key << " ";
        b = lst[b].prev;
    }
    cout << lst[bot_ad].key << endl;
    return 0;
}


Measured memory_bytes: 26644
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {

static long[] list=new long[87];

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

  // String nyuA=sc.nextLine();
 //  String nyuB=sc.nextLine();
 
   String[] s=sc.nextLine().split("");
     String[] t=sc.nextLine().split("");
Arrays.sort(s);
Arrays.sort(t);

String S="";
String T="";
for(String temp:s)S+=temp;
for(String temp:t)T=temp+T;

String[] so={S,T};
Arrays.sort(so);

//int N=Integer.parseInt(nyuA);

//int Y=Integer.parseInt(e[1]);
//int Z=Integer.parseInt(e[2]);

if(S.equals(T))
System.out.println("No");
else if(S.equals(so[0]))
System.out.println("Yes");
else
System.out.println("No");



}

}



Measured memory_bytes: 22228
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3
0.0 0.0
2.0 0.0
1.0 1.0

output:
1.41421356237
"""

import sys
from operator import attrgetter


class ClosestPair(object):
    def __init__(self, ):
        """
        Init closest pairs points set.
        """
        _input = sys.stdin.readlines()
        p_num = int(_input[0])
        points = map(lambda x: x.split(), _input[1:])
        p_list = [complex(float(x), float(y)) for x, y in points]
        # pre_sort by axis_X
        p_list.sort(key=attrgetter('real'))

        ans = self.closest_pair(array=p_list, array_length=p_num)
        print(('{:.6f}'.format(ans)))

    def closest_pair(self, array, array_length):
        if array_length <= 1:
            return float('inf')
        mid = array_length // 2
        mid_real = array[mid].real
        d = min(self.closest_pair(array[:mid], mid),
                self.closest_pair(array[mid:], array_length - mid))

        # sort by axis_Y while recursively solve d
        array.sort(key=attrgetter('imag'))

        min_stack = list()
        for ele in array:
            size = len(min_stack)

            if abs(ele.real - mid_real) >= d:
                continue

            for j in range(size):
                alt = ele - min_stack[size - j - 1]
                if alt.imag >= d:
                    break
                d = min(d, abs(alt))

            min_stack.append(ele)

        return d


if __name__ == '__main__':
    case = ClosestPair()

Measured memory_bytes: 23480
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N;
ll A[201010];

map<ll, ll> memo;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    for (int j = 0; j < N; ++j) cin >> A[j];

   memo[0] = 1;
    ll ans = 0, acc = 0;
    for (int j = 0; j < N; ++j) {
        acc += A[j];
        ans += memo[acc];
        memo[acc]++;
    }
    cout << ans << endl;
    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 057 A / Link: http://abc057.contest.atcoder.jp/tasks/abc057_a  ----- */


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

	LL A, B; cin >> A >> B;
	A += B;
	
	LL ans = A%24;
	
	
	cout << (ans) << "\n";

	return 0;
}


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

int main()
{
	int x, n;
	cin >> x >> n;
	auto a = vector<bool>(102);
	for(int i = 0; i < n; ++i){
		int p;
		cin >> p;
		a[p] = true;
	}
	int ans = -1;
	for(int i = 0; ; ++i){
		int l = x - i, r = x + i;
		if(!a[l]){
			ans = l;
			break;
		}
		if(!a[r]){
			ans = r;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
#define endl '\n'

using namespace std;

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

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
//	#ifndef ONLINE_JUDGE
////	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
//	#endif
	int n;
	cin>>n;
	vi v(n);
	for(int i=0;i<n;++i){
		cin>>v[i];
	}
	sort(all(v));
	reverse(all(v));
	ll a=0,b=0;
	for(int i=0;i<n;++i){
		if(i&1)
			b+=v[i];
		else
			a+=v[i];
	}
	cout<<a-b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
	int n, k;
	cin >> n >> k;
	vector<ll> a;
	REP(i, n){
		ll tmp;
		cin >> tmp;
		a.pb(tmp);
	}
	SORT(a);
	int head = -1, tail = n;
	while(tail - head > 1){
		bool dp[5010][5010];
		REP(i, 5010) REP(j, 5010) dp[i][j] = false;
		int mid = (head + tail) / 2;
		REP(i, n){
			REP(j, k){
				if(i == 0){
					if(a[0] < k && mid != 0) dp[1][a[0]] = true;
					dp[1][0] = true;
					break;
				}
				if(i == mid) dp[i + 1][j] |= dp[i][j];
				else{
					if(j + a[i] < k) dp[i + 1][j + a[i]] = dp[i][j];
					dp[i + 1][j] |= dp[i][j];
				}
			}
		}
		bool flag = false;
		if(a[mid] >= k){
			tail = mid;
		}else{
			FOR(i, k - a[mid], k){
				flag = dp[n][i] || flag;
			}
			if(flag){
				tail = mid;
			}else{
				head = mid;
			}
		}
	}
	cout << (head + tail + 1) / 2 << endl;
	/*
	n ^ 2 * k = 10 ^ 2 * (10^3) * 3 = 10^11
	600点解法を考える
	・ai >= kが成り立つときは自明に必要
	・ai < kについて以下の条件
	・とりあえずaiを含むいい集合Siがあるとして
		Si - ai < k ⇒ aiは必要
		Si>=kを満たす最小のSiを求めればいいのでは
			→?これなんだっけ→蟻本をみる
			ん　これ小さい方から足しておくだけでは にぶたんでN + NlogN
			N * N これ嘘じゃん
			ai以外のaで k - ai <= S < k を作れるか
		N * 
	*/
 /* 解説を見ます*/
}


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

int main()
{
  int K ;
  cin>>K ;
  int count=0 ;
  for(int i=1;i<=K-1;i++){
    for(int j=i+1;j<=K;j++) if((i%2==1&&j%2==0)||(i%2==0&&j%2==1)) count++ ; 
  }
  cout<<count<<endl ;
             
  return 0 ;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int x,y,p;
  
  cin >> x >> y;
  
  p=0;
  if (x<=3) p+=(4-x)*100000;
  if (y<=3) p+=(4-y)*100000;
  
  if (x==1 && y==1) p+=400000;
  
  cout << p << endl;
  
  return 0;
}

Measured memory_bytes: 256
# ABC122 B - ATCoder
s = input()
n = len(s)

acgt = 'A','C','G','T'
ans = 0

for i in range(n):
    for j in range(n-i):
        S = s
        S = S[j:j+i+1]
        t = 0
        for k in range(len(S)):
            if S[k:k+1] not in acgt:
                break
            if k+1 == len(S):
                t = len(S)
                ans = max(ans,t)
print(ans)


Measured memory_bytes: 3060
/**
 *    author:  FromDihPout
 *    created: 2020-06-20
**/

#include <bits/stdc++.h>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = (int) s.length(), p_cnt = 0;
    for (char c : s) {
        if (c == 'p') p_cnt++;
    }
    cout << n / 2 - p_cnt << endl;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, t;
    cin >> k >> t;
    priority_queue<pair<int, int>> pq;
    int b = -1;
    int ans = 0;
    rep(i, t) {
        int a;
        cin >> a;
        pq.push(make_pair(a, i));
    }
    rep(i, k) {
        pair<int, int> fa = pq.top(); pq.pop();
        if (!sz(pq)) {
            if (b == fa.second) ans++;
            fa.first--;
            b = fa.second;
            if (fa.first) pq.push(fa);
            continue;
        }
        pair<int, int> sa = pq.top(); pq.pop();
        if (b == fa.second) {
            sa.first--;
            b = sa.second;
        }
        else {
            fa.first--;
            b = fa.second;
        }
        if (fa.first) pq.push(fa);
        if (sa.first) pq.push(sa);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def gcd(x, y):
  while(x % y != 0 and y % x != 0):
    if(x > y):
      x = x % y
    else:
      y = y % x
  if(x > y):
    return y
  else:
    return x

K = int(input())
ans = 0
for i in range(1, K+1):
  for j in range(i, K+1):
    for k in range(j, K+1):
      if(i == j and j == k):
        ans += i
      elif(i == j or j == k):
        ans += gcd(i, k) * 3
      else:
        ans += gcd(i, gcd(j, k)) * 6
print(ans)

Measured memory_bytes: 9220