akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("-O3","unroll-loops")
#pragma GCC target("avx")
#include<bits/stdc++.h>
 
using namespace std;
 
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
 
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;

bool isPrime(int x){
    for(int i=2;i*i<=x;i++){
        if(x%i==0)return false;
    }
    return true;
}
void solve() {
    vector<int>v;
    int N;cin>>N;
    for(int i=6;i<=55555;i+=5){
        if(isPrime(i))v.push_back(i);
    }
    REP(i,N){
        pe(v[i]);
    }cout<<endl;
}

int main() {
	solve();
}

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

template<class T>
struct fenwick_tree{
  int n;
  std::vector<T> data;
  fenwick_tree(){}
  fenwick_tree(int _n):n(_n){
    data.resize(n+1);
  }
  template<class U>
  fenwick_tree(std::vector<U>const& a):n(a.size()){
    data.resize(n+1);
    for(int i=1;i<=n;++i){
      data[i] += a[i-1];
      if(i+(i&-i)<=n)data[i+(i&-i)] += data[i];
    }
  }
  T prefix_sum(int x){
    T res{0};
    for(int i=x;i>0;i-=i&-i)res+=data[i];
    return res;
  }
  T fold(int l,int r){
    return prefix_sum(r)-prefix_sum(l);
  }
  void add(int x,T v){
    for(int i=x+1;i<=n;i+=i&-i)data[i]+=v;
  }
  int lower_bound(T w){
    int k = 0;
    int sz=1;while(sz<n)sz<<=1;
    for(int i=sz;i>0;i>>=1){
      if(k+i<=n&&data[k+i]<w){
        w -= data[k+i];
        k += i;
      }
    }
    return k;
  }
};

int main(){
  using namespace std;
  using ll = int64_t;
  cin.tie(0);
  ios::sync_with_stdio(false);
  constexpr char newl = '\n';

  int n,q;
  cin>>n>>q;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  fenwick_tree<ll> fen(a);
  while(q--){
    int t;cin>>t;
    if(t==0){
      int p,x;cin>>p>>x;
      fen.add(p,x);
    }
    if(t==1){
      int l,r;cin>>l>>r;
      cout<<fen.fold(l,r)<<newl;
    }
  }
}

Measured memory_bytes: 10148
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var d = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Array.Sort(d);
        Console.WriteLine(d[n / 2] - d[n / 2 - 1]);
    }
}


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


// int N = 3;
// int M = 1;

// map<string, int> mp_red = {{"apple", 2}, {"orange", 1}};
// map<string, int> mp_blue = {{"grape", 0}};

int N, M;
map<string, int> mp_red, mp_blue;

int main() {
    // input
    cin >> N;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        mp_red[s]++;
    }

    cin >> M;
    for (int i = 0; i < M; i++) {
        string s2;
        cin >> s2;
        mp_blue[s2]++;
    }

    // cout << mp_blue["grape"] << endl;
    map<string, int>::iterator ite;
    int ans = 0;
    for (ite = mp_red.begin(); ite != mp_red.end(); ite++) {
        // cout << ite->first << endl;
        int plus = ite->second;
        int minus = 0;
        if (mp_blue.count(ite->first) > 0) {
            minus = mp_blue[ite->first];
        }
        // printf("%d %d\n", plus, minus);
        if (ans < plus - minus) {
            ans = plus - minus;
        }       
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int main(void){
  int n;
  cin>>n;
  /*vi a(n+1);
  rep(i,n+1){cin>>a[i];a[i]--;}
  vi pos(n,-1);
  int expos;
  int exnum;
  rep(i,n+1){
    if(pos[a[i]]!=-1){
      exnum=a[i];
      expos=i;
      continue;
    }
    pos[a[i]]=i;
  }*/
  vl a(n);
  ll mmin=llMAX-10;
  rep(i,n){
    cin>>a[i];
    mmin=min(mmin,a[i]);
  }
  set<ll> rec;
  rep(i,n){
    rec.insert(a[i]);
  }
  ll tmpmin;
  while(rec.size()>1){
    //cout<<rec.size()<<endl;
    set<ll> tmp={};
    tmpmin =mmin;
    for(auto i=rec.begin();i!=rec.end();++i){
      if((*i)%mmin!=0){
        tmp.insert((*i)%mmin);
        tmpmin=min(tmpmin,(*i)%mmin);
      }
    }
    tmp.insert(mmin);
    rec=tmp;
    mmin=tmpmin;
  }
  cout<<mmin;
  return 0;
}

Measured memory_bytes: 6016
#include<stdio.h>
int color[105],k[105],d[105],f[105],G[105][105];
int u,time,v;
void DFS_Visit(int u){
  int i;
  color[u]=2;
  d[u]=++time;
  for(i=0;i<k[u];i++)
    if(color[G[u][i]]==1)
      DFS_Visit(G[u][i]);
  color[u]=0;
  f[u]=++time;
}
void DFS(int n){
  int i;
  for(i=1;i<=n;i++){
    color[i]=1;
    time=0;
  }
  for(i=1;i<=n;i++){
    if(color[i]==1){
      DFS_Visit(i);
    }
  }
}
int main(void){
  int n,i,j,k1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k1);
    k[u]=k1;
    for(j=0;j<k[u];j++){
      scanf("%d",&v);
      G[u][j]=v;
    }  
  } 

  DFS(n);
  for(i=1;i<=n;i++)
    printf("%d %d %d\n",i,d[i],f[i]);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

int main()
{
    int n, m, cnt = 0, cnt2;
    cin>>n>>m;
    VI a(n);
    REP(i,n) {
        cin>>a[i];
        cnt += a[i];
    }
    REP(i,n) {
        cnt2 += ((double)a[i] >= cnt / 4.0 / m);
    }

    Yes(cnt2 >= m);

    return 0;
}


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


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    ans = 1000 - N
    while ans < 0:
        ans += 1000
    print(ans)


# oj t -c "pypy3 main.py"
# acc s main.py -- --guess-python-interpreter pypy
main()


Measured memory_bytes: 61872
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){

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

	string s;
	cin >> s;
	int n=s.size();
	int x=0,y=0,z=0,u=0;
	REP(i,n){
		if(s[i]=='N') x++;
		if(s[i]=='S') y++;
		if(s[i]=='W') z++;
	    if(s[i]=='E') u++;
	}

	if((x!=0 && y==0) || (x==0 && y!=0) || (z!=0 && u==0) || (z==0 && u!=0)) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  if (S.at(0) == S.at(1) && S.at(0) == S.at(2) && S.at(1) == S.at(2)){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	string s;  cin >> s;

	int right = 0, left = 0; //right : (, left : )
	bool flag = false;
	while(!flag){
			flag = true;
			REP(i, s.length()){
					if(s[i] == '(')
							right += 1;
					else{
							left += 1;
							if(right - left < 0){
									s = "(" + s;
									flag = false;
									right = 0, left = 0;
									break;
							}
					}
			}
	}

	right = 0, left = 0;
	flag = false;
	while(!flag){
			flag = true;
			REPR(i, s.length() - 1){
					if(s[i] == ')')
							left += 1;
					else{
							right += 1;
							if(left - right < 0){
									s = s + ")";
									flag = false;
									right = 0, left = 0;
									break;
							}
					}
			}
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;


int main()
{
    int n;
    cin >> n;
    int total = 0;
    int squaretotal = 0;
    for (int q = 0; q < n; q++)
    {
        int a;
        cin >> a;
        total+=a;
        squaretotal += (a*a);
    }
    cout << (total*total-squaretotal)/2;
    return 0;
}


Measured memory_bytes: 256
#coding:utf-8
a =[list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
#print(b)
check = [[0, 0, 0] for _ in range(3)]
#print(check)


for i in range(n):
    for j in range(0, 3):
        for k in range(0, 3):
            if int(b[i]) == int(a[j][k]):
                check[j][k] = 1



#print(sum(check[0]))

if sum(check[0]) == 3 or sum(check[1]) == 3 or sum(check[2]) == 3:
    print('Yes')
    exit()
elif check[0][0]+check[1][0]+check[2][0] == 3 or check[0][1]+check[1][1]+check[2][1]== 3 or check[0][2]+check[1][2]+check[2][2] == 3:
    print('Yes')
    exit()
elif check[0][0]+check[1][1]+check[2][2] == 3 or check[0][2]+check[1][1]+check[2][0] == 3:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 3064
N, M = map(int, input().split())
A, B = zip(*(map(int, input().split()) for _ in range(N)))
C = sorted(zip(A, B))
ans = 0
m = M
for a, b in C:
    if m >= b:
        ans += a * b
        m -= b
    else:
        ans += a * m
        break
print(ans)

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

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(upper: str, lower: str):

    if upper == lower[::-1] and lower == upper[::-1]:
        print(YES)
    else:
        print(NO)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    upper = str(next(tokens))  # type: str
    lower = str(next(tokens))  # type: str
    solve(upper, lower)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;

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

    sort(L, L+n);

    int ans = 0;
    for (int i = 0; i < n-2; i++) {
        for (int j = i+1; j < n-1; j++) {
            for (int k = j+1; k < n; k++) {
                if (L[i] != L[j] && L[j] != L[k]
                    && L[i] + L[j] > L[k])
                    ans++;
            }
        }
    }

    cout << ans;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
template <class T1, class T2>
void vadd(vector<T1> &v, T2 x);

void solve(long long N, long long K, std::vector<long long> A,
           std::vector<long long> F)
{
  lli up = 1e18, low = -1;
  sort(A.rbegin(), A.rend());
  sort(F.begin(), F.end());
  while (up - low > 1)
  {
    lli mid = (up + low) / 2;
    lli ret = 0;
    rep(i, N)
    {
      // F[i] * (A[i]-k_i) <= mid
      // にするのに必要なk_i
      // A[i] - (mid+F[i]-1)/F[i] <= k_i
      ret += max(0ll, A[i] - mid / F[i]);
    }
    (ret <= K ? up : low) = mid;
  }
  cout << up << endl;
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }
  std::vector<long long> F(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &F[i]);
  }
  solve(N, K, std::move(A), std::move(F));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2>
void vadd(vector<T1> &v, T2 x)
{
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }

    return 0;
}

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

A=[]
n=N

for i in range(32):
    if n % 2 != 0:
        A.append(1)
        n -= 1
    else:
        A.append(0)
        
    n /= -2
    
ret=""
flg=0
for i in range(len(A)-1,-1,-1):
    if A[i] != 0:
        flg = 1
    if flg != 0:
        ret += str(A[i])
    
if ret=="":
    ret = "0"
print (ret)

Measured memory_bytes: 3064
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.rmi.server.UnicastRemoteObject;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n = sc.nextInt();
        int m[]=sc.nextIntArray(n+1);
        int h[]=sc.nextIntArray(n);
        long ans=0;
        for (int i = 0; i < h.length; i++) {
			if(h[i]>=m[i]) {h[i]-=m[i];ans+=m[i]; m[i]=0;}
			else {m[i]-=h[i]; ans+=h[i]; h[i]=0;}
			if(h[i]>=m[i+1]) {h[i]-=m[i+1];ans+=m[i+1]; m[i+1]=0;}
			else {m[i+1]-=h[i]; ans+=h[i]; h[i]=0;}
        }
        
        out.println(ans);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

class P {
	int x, y;
	P(int  x, int y) {
	  this.x=x;
	  this.y=y;
	}
}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//        return b-p.b;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

using namespace std;



int main(int argc, char *argv[]) {
	string S, T;
	cin >> S >> T;

	for (int i = S.size() - T.size(); i >= 0; i--) {
		bool matched = true;
		for (int j = 0; matched && j < T.size(); j++) {
			if (S[i + j] != '?' && S[i + j] != T[j]) matched = false;
		}

		if (matched) {
			for (int j = 0; j < S.size(); j++) {
				if (S[j] == '?') S[j] = 'a';
			}
			for (int j = 0; j < T.size(); j++) {
				S[i + j] = T[j];
			}

			cout << S << endl;
			return 0;
		}
	}

	cout << "UNRESTORABLE" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}


#include <iostream>

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if (A + B > C + D) { cout << "Left" << endl; }
    else if (A + B == C + D) { cout << "Balanced" << endl; }
    else { cout << "Right" << endl; }

}


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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<cd> vcd;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef unordered_map<int, int> umpii;
typedef unordered_map<ll, ll> umpll;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int inf = 1e9;
const int MX = 100001; //check the limits, dummy

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

    int n; cin >> n;
    umpii mp;
    F0R(i, n) {
        int tmp; cin >> tmp;
        mp[tmp] = i + 1;
    }

    F0R(i, n) {
        cout << mp[i + 1] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4900
N = int(input())
if N == 0:
    print(0)
    exit()
L = []
M = []

def bit_range(bit_length,maximum=0,minimal=0):
    for i in range(bit_length-1,-1,-1):
        if i % 2 == 0:
            maximum += pow(2,i)
        else:
            minimal += pow(-2,i)
    L.append(minimal)
    M.append(maximum)

for i in range(1,41):
    bit_range(i)

identify = []
for i in range(40):
    if i == 0:
        ap_list = [L[0],M[0]]
    elif i % 2 == 1:
        ap_list = [L[i],L[i-1]]
    elif i % 2 == 0:
        ap_list = [M[i-1],M[i]]
    identify.append(ap_list)

bit = [0]*40
for i in range(39,-1,-1):
    left = identify[i][0]
    right = identify[i][1]
    if i % 2 == 0 and left < N <= right:
        bit[39-i] = 1
        N -= pow(-2,i)
    elif i % 2 == 1 and left <= N < right:
        bit[39-i] = 1
        N -= pow(-2,i)

ans = "".join(str(e) for e in bit).lstrip("0")
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long

const int N=(int)1e5+5;

int dp[101][N];

int n,we;
int w[N],v[N];

int solve(int i,int wt)
{
    
    if(i==n+1)return 0;
    
    int &ans=dp[i][wt];
    if(ans!=-1)return ans;
    
    int op1=0,op2=0;
    if(wt-w[i]>=0)
    {
        op1=v[i]+solve(i+1,wt-w[i]);
    }
    op2=solve(i+1,wt);
    
    return ans=max(op1,op2);
    
    
}
	
void solve()
{
   
    memset(dp,-1,sizeof dp);
   
    cin>>n>>we;
    for(int i=1;i<=n;i++)cin>>w[i]>>v[i];
    
    
    int ans=solve(1,we);
    cout<<ans;
}

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

Measured memory_bytes: 82536
def main(argv)
  (a, b) = gets.chomp.split(' ').map(&:to_i)
  
  if a <= 5 then
    puts 0.to_s
  elsif a <= 12 then
    puts (b / 2).to_s
  else
    puts b.to_s
  end
end

if self.to_s === 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, m = Is()
AB = TIR(m)
C = [set() for _ in range(n)]
for a, b in AB:
    a -= 1
    b -= 1
    C[a].add(b)
    C[b].add(a)

ANS = [INF]*n
visited = [False]*n
def bfs():
    que = deque()
    que.append(0)
    while que:
        x = que.popleft()
        visited[x] = True
        for y in C[x]:
            if not visited[y]:
                ANS[y] = x
                que.append(y)
                visited[y] = True

bfs()
print("Yes")
for ans in ANS[1:]:
    print(ans+1)


Measured memory_bytes: 140844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            long ans = Digit(N);

            for (long i = 1; i * i <= N ; i++)
            {
                if(N % i == 0)
                {
                    ans = Math.Min(Math.Max(Digit(i), Digit(N / i)), ans);
                }
            }

            Console.WriteLine(ans);
        }

        public static long Digit(long num)
        {
            //// Mathf.Log10(0)はNegativeInfinityを返すため、別途処理する。
            return (num == 0) ? 1 : ((long)Math.Log10(num) + 1);
        }
    }
}

Measured memory_bytes: 27468
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
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; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N,K;cin >> N >> K;
    vector<int> p(N);
    rep(i,N)cin >> p[i];
    sort(all(p));
    LL ans = 0;
    rep(i,K)ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";
#define MOD 998244353

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

void halt(int x) {
  cout << x << endl;
  exit(0);
}

int main()
{
  int N; cin >> N;
  vector<int> D(N); REP(i, N) cin >> D[i];
  if (D[0] > 0) halt(0);

  const int M = *max_element(ALL(D));
  vector<ll> hist(M + 1, 0);
  for (auto&& e : D) hist[e]++;

  ll ans = 1;
  for (int i = 1; i < N; i++) {
    if (D[i] <= 0) halt(0);
    (ans *= hist[D[i]-1]) %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a;
  if(a%2==1)
  {
    b=(a+1)/2;
  }
  if(a%2==0)
  {
    b=a/2;
  }
  
  cout<<(double)b/a<<endl;
    return 0;
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;

int n, m, a[15][15], sum[15], x, c[15], ans = 1e9;

int main(){
    scan(n, m, x);
    for(int i = 0; i < n; i++){
        scan(c[i]);
        for(int j = 0; j < m; j++)
            scan(a[i][j]);
    }
    
    for(int i = 0; i < (1<<n); i++){
        memset(sum, 0, sizeof sum);
        int cost = 0;
        for(int j = 0; j < n; j++){
            if(i&(1<<j)){
                cost += c[j];
                for(int k = 0; k < m; k++){
                    sum[k] += a[j][k];
                }
            }
        }
        if(*min_element(sum, sum+m) >= x){
            ans = min(ans, cost);
        }
    }
    
    print(ans == 1e9? -1: ans);
    
    return 0;
}

Measured memory_bytes: 3636
open Printf open Scanf
open Array

let divisors n = (* O(sqrt n) *)
  let tbl = Hashtbl.create ~random:true 30000 in
  let rec f0 i =
    if i*i > n then ()
    else if i*i = n && n mod i = 0 then Hashtbl.add tbl i i
    else if n mod i = 0 then (
      Hashtbl.add tbl i i;
      Hashtbl.add tbl (n/i) (n/i);
      f0 (i+1)
    ) else f0 (i+1)
  in f0 1;
  let res = make (Hashtbl.length tbl) 0 in
  ignore @@ Hashtbl.fold (fun _ v idx -> res.(idx) <- v; idx+1) tbl 0;
  res

let () = scanf " %d" @@ fun n ->
  let a = divisors n in
  print_int @@
    fold_left (fun sum v ->
      let m = v - 1 in
      if m > 0 && n / m = n mod m then (
        sum + m
      ) else sum
    ) 0 a




Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
    int n, m, x;
    cin >> n >> m >> x;

    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    int res = -1;
    for (int i = 0; i < (1 << n); i++) {
        int ir = 0;
        vector<int> ia(m, 0);
        for (int j = 0; j < n; j++) {
            if ((i & (1 << j)) > 0) {
                ir += c[j];
                for (int k = 0; k < m; k++) {
                    ia[k] += a[j][k];
                }
            }
        }

        if (*min_element(ia.begin(), ia.end()) >= x) {
            res = (res == -1 ? ir : min(res, ir));
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 3652
var lines: string[] = [];
var reader: any = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on("line", function (line: string) {
  lines.push(line);
});
reader.on("close", function () {
  var numN = Number(lines[0]);
  if (numN % 3 == 0) {
    console.log(numN / 3);
  } else {
    console.log(Math.floor(numN / 3));
  }
});


Measured memory_bytes: 7628
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e6+5;

int32_t main()
{
	IOS;
	string s;
	cin>>s;
	int ans=0, b=0;
	for(auto &it:s)
	{
		if(it=='B')
			b++;
		else
			ans+=b;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1356
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

LL a,b,bin[65];

int main()
{
	scanf("%lld%lld",&b,&a);
	if (a==b) {puts("1");return 0;}
	bin[0]=1;
	for (int i=1;i<=60;i++) bin[i]=bin[i-1]*2;
	int d=60;
	while ((a&bin[d])==(b&bin[d])) d--;
	a&=bin[d+1]-1;b&=bin[d+1]-1;
	int k=d-1;
	while (k>=0&&!(a&bin[k])) k--;
	LL l1=b,r1=bin[d]+bin[k+1]-1,l2=bin[d]+b,r2=bin[d+1]-1;
	l2=max(l2,r1+1);
	printf("%lld",r1-l1+1+max((LL)0,r2-l2+1));
	return 0;
}

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

int main(void) {
    long long int a,b;
    cin>>a>>b;
    long long int A=a;
    long long int B=b;
    if (a<b) {
        long long int tmp=a;
        a=b;
        b=tmp;
    }
    while (a%b!=0) {
        long long int hoge=b;
        b=a%b;
        a=hoge;
    }
    cout<<(A*B)/b;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

constexpr long long inf = (1ll << 60);

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (int &x: A) {
    std::cin >> x;
  }
  std::vector<int> order(N);
  std::iota(order.begin(), order.end(), 0);
  std::sort(order.begin(), order.end(), [&](int i, int j) {
    return A[i] > A[j];
  });
  std::vector<std::vector<long long>> dp(N + 1, std::vector<long long>(N + 1, -inf));
  dp[0][0] = 0;
  for (int i: range(0, N)) {
    int t = order[i];
    for (int j: range(0, N + 1)) {
      if (j + 1 <= N) {
        int pos = j;
        chmax(dp[i + 1][j + 1], dp[i][j] + (long long) A[t] * (t - pos));
      }
      {
        int pos = N - (i - j) - 1;
        chmax(dp[i + 1][j], dp[i][j] + (long long) A[t] * (pos - t));
      }
    }
  }
  long long ans = 0;
  for (int i: range(0, N + 1)) {
    chmax(ans, dp[N][i]);
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] = abs(A[i]);
  }
  sort(A.begin(), A.end());
  cout << A[N - 1] - A[0] << endl;
  return 0;
}

Measured memory_bytes: 256
s = str(input())
t = str(input())

S = []
T = []

for i in s:
    S.append(i)
for j in t:
    T.append(j)

ans = 'No'

for n in range(len(S)):
    last = S[-1]
    del S[-1]
    S.insert(0, last)
    if S == T:
        ans = 'Yes'
        break

print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

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

    int odd = 0;

    for(int i = 0; i < n; i++){
        int c;
        cin >> c;
        if(c % 2 == 1){
            odd++;
        }
    }

    if(odd % 2 == 0){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vi V(n);
    for (int i = 0; i < n; ++i) {
        cin >> V[i];
    }
    ll mini = 1e9;
    for (int i = -100; i <= 100; ++i) {
        ll aux = 0;
        for (int j = 0; j < n; ++j) {
            aux += (i-V[j])*(i-V[j]);
        }
        mini = min(mini, aux);
    }
    cout << mini << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long double ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int a1, a2;
    cin >> a1 >> a2;
    ll atotal = a1, btotal = a2;
    for (int i = 1; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        ll low = 0, high = 1e18, cnt = 100;
        while (cnt--) {
            ll mid = floor((low+high)/2);
            ll a1 = a*mid, b1 = b*mid;
            if (a1 >= atotal && b1 >= btotal) high = mid;
            else low = mid+1;
        }
        atotal = a*high, btotal = b*high;
    }
    cout << fixed << setprecision(0);
    cout << atotal+btotal << "\n";
    return 0;
}

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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll result = 1;
    for(int i=0;i<N;i++) {
        cin >> A.at(i);
    }

    if(find(A.begin(),A.end(),0) != A.end()) {
        cout << "0" << endl;
        exit(0);
    }
    for(int i=0;i<N;i++) {
        if (result > (ll)pow(10,18)/A.at(i)) {
            cout << "-1" << endl;
            exit(0);
        }
        result = result * A.at(i);
    }
    cout << result << endl;
}

Measured memory_bytes: 4400
#pragma GCC target ("avx2")
#pragma GCC target ("sse2")
#pragma GCC optimize ("Ofast")
#pragma GCC push_options
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef int _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	doin();
	int n,m = 0, t;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> t, m = __gcd(m, t);
	cout << m;
}


Measured memory_bytes: 256
#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
using namespace std;
int main()
{
	int n,x;
	cin>>n>>x;
	int ans=n;
	vector <int> a(n);
	rep(i,n) 
	{
		cin>>a[i];
		x-=a[i];
	}
	sort(a.begin(),a.end());
	ans+=x/a[0];
	cout<<ans;
    rt0;
}

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

using namespace std;

int main()
{
    string s;
    int i;
    cin >> s;
    for (i=0; i<3; i++)
    {
        if (s[i]== s[i+1])
        {
            cout << "Bad";
            i=5;
            break;
        }

    }
    if (i != 5)
        cout << "Good";
}

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

int main()
{
	int n, v;
	int R[200000] = {0};
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		cin >> v;
		R[i] = v;
	}
	
	int minv = R[0];
	int maxv = R[1]-R[0];
	for (int j = 1; j < n; j++)
	{
		if (maxv < (R[j] - minv))
			maxv = (R[j] - minv);
		if (minv > R[j])
			minv = R[j];
		
		//cout << "DEBUG:" << "minv=" << minv << ",maxv=" << maxv << endl;
	}
	
	cout << maxv << endl;
	
	return 0;
}

Measured memory_bytes: 1948
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;

signed main()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,k;
    cin>>n>>k;
    vector<int> a(n),b(n);
    for (int i=0;i<n;++i)
        cin>>a[i]>>b[i];

    int dp[n+1][k+1];

    for (int i=0;i<=n;++i)
    {
        for (int w=0;w<=k;++w)
        {
            if (i==0 || w==0)
                dp[i][w]=0;
            else if (a[i-1]<=w)
                dp[i][w]=max(b[i-1]+dp[i-1][w-a[i-1]],dp[i-1][w]);
            else
                dp[i][w]=dp[i-1][w];
        }
    }

    cout<<dp[n][k]<<endl;
}


Measured memory_bytes: 82332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,A,B;
  
  cin >> N;
  cin >> A;
  
  B = N*N ;
  N <= 100 | N >= 1;
  A <= B | A >= 0;
 
  cout << B - A << endl;
  
}

Measured memory_bytes: 3596
#include<stdio.h>
 
int main(void){
  int n;
  int i = 0;
  float x1,y1,x2,y2,x3,y3,x4,y4;
  double a,b;
 
  scanf("%d",&n);
 
  while(scanf("%f %f %f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4) != EOF){
 
    if( i >= n )break;
 
    a = (y2 - y1) / (x2 - x1);
    b = (y4 - y3) / (x4 - x3);
 
    if( a == b ){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
 
    i++;
 
  }
 
  return 0;
}

Measured memory_bytes: 616
#個数
items = int(input())
#価格
price_array = []

#個数の数だけforを回す
for _ in range(items):
    price = int(input())
    price_array.append(price)

price_sum = sum(price_array)
half_price = max(price_array)//2

result = price_sum - half_price
print(result)


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

int main(){
  int64_t N,K;
  cin >> N >> K;
  vector<int64_t> v(1e5+1,0);
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    v.at(a)+=b;
  }
  v.at(0)=1;
  for(int i=1;i<v.size();i++){
    v.at(i)+=v.at(i-1);
    if(v.at(i)>K){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
A, B, C, D = map(int,input().strip().split(' '))

Alice_time = set(range(A,B+1))
Bob_time = set(range(C, D+1))

seki_set = Alice_time.intersection(Bob_time)
seki_list = list(seki_set)

if  seki_list == []:
    print(0)
else:
    print(max(seki_list) - min(seki_list))


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int a,b,n[4],m[4];
int main(){
	int i,j,h,l;
	while(cin >> a >> b && (a != 0 && b != 0)){
		h = 0;
		l = 0;
		for(i=0;i<4;i++){
			n[i] = a % 10;
			m[i] = b % 10;
			a /= 10;
			b /= 10;
		}
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(n[i] == m[j]){
					if(i==j) h++;
					else l++;
				}
			}
		}
		cout << h << " " << l << endl;
	}
}

Measured memory_bytes: 864
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // qsort()
#include <stdbool.h>

int
cmp_func(const void *l_, const void *r_)
{
	const int* l = (const int*) l_;
	const int* r = (const int*) r_;

	if (*l < *r)
		return -1;

	if (*l > *r)
		return 1;

	return 0;
}

int
main(int argc, char** argv)
{
	int n[5];
	int nn[6];
	int i, j, k;

	while (true)
	{
		if (scanf("%d,%d,%d,%d,%d", &n[0], &n[1], &n[2], &n[3], &n[4]) == EOF)
			break;

		qsort(n, 5, sizeof(int), cmp_func);

		j = n[0] + 1;
		for (i = 1; i < 5; ++i, ++j)
		{
			if (i == 1 && n[i] == 10 && n[0] == 1)
				j = 10;

			if (n[i] != j)
				break;
		}

		if (i >= 5)
		{
			printf("straight\n");
			continue;
		}

		int bn = n[0];
		j = 1;
		k = 0;
		for (i = 1; i < 5; ++i)
		{
			if (n[i] != bn)
			{
				nn[k++] = j;
				bn = n[i];
				j = 1;
				continue;
			}

			j++;
		}

		nn[k++] = j;
		qsort(nn, k, sizeof(int), cmp_func);
		switch (k)
		{
		case 2:
			if (nn[k - 1] == 4)
				printf("four card\n");
			else
				printf("full house\n");
			break;

		case 3:
			if (nn[k - 1] == 3)
				printf("three card\n");
			else
				printf("two pair\n");
			break;

		case 4:
			printf("one pair\n");
			break;

		case 5:
		default:
			printf("null\n");
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <fstream>

const long long infinity=1000000001;
const long long nmax = 100000;
using namespace std;

int n;
long v[nmax];
long long wmax, w[nmax],f[nmax];


int main()
{
    //freopen()
    //freopen("test.inp","r",stdin);
    cin >> n >> wmax;
    long long t = 0, ans = -infinity;\
    for (int i = 1; i <= n; i++)
    {
        cin >> w[i] >> v[i];
        t += v[i];
    }
    for (int i = 1; i <= t; i++)
        f[i] = infinity;
    for (int i = 1; i <= n; i++)
        for (long j = t; j >= v[i]; j--)
            f[j] = min(f[j],f[j - v[i]] + w[i]);

    for (long i = 1; i <= t; i++)
        if (f[i] <= wmax)
            if (ans < i) ans = i;
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024