akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

unsigned long xor128(){
    static unsigned long x=123456789,y=362436069,z=521288629,w=88675123;
    unsigned long t;
    t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}

int a[][4] = {{0, 1, 2, 3},
              {4, 5, 6, 7},
              {0, 1, 5, 4},
              {3, 2, 6, 7},
              {0, 4, 7, 3},
              {1, 5, 6, 2}};

int main()
{
    for(;;){
        vector<string> color(8);
        map<string, char> index;
        for(int i=0; i<8; ++i){
            if(!(cin >> color[i]))
                return 0;
            if(index.find(color[i]) == index.end()){
                int k = index.size();
                index[color[i]] = k + 'a';
            }
        }

       string s(8, ' ');
        for(int i=0; i<8; ++i)
            s[i] = index[color[i]];
        sort(s.begin(), s.end());

        set<string> x;
        do{
            string t = s;
            bool ok = true;

            for(int i=0; i<500; ++i){
                int b = xor128() % 3;
                for(int j=0; j<3; ++j){
                    swap(t[a[b*2][j]], t[a[b*2][j+1]]);
                    swap(t[a[b*2+1][j]], t[a[b*2+1][j+1]]);
                }
                if(x.find(t) != x.end()){
                    ok = false;
                    break;
                }
            }

            if(ok)
                x.insert(s);
        }while(next_permutation(s.begin(), s.end()));

        cout << x.size() << endl;
    }
}

Measured memory_bytes: 1356
# AtCoder Beginner Contest 074
# B - Collecting Balls (Easy Version)
# https://atcoder.jp/contests/abc074/tasks/abc074_b

N = int(input())
K = int(input())
*X, = map(int, input().split())

ans = 0
for x in X:
    ans += min(abs(0-x), abs(K-x))

print(ans*2)

Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,K;
int x[100002];

int main(){
    cin>>N>>K;
    repn(i,N) cin>>x[i];

    int ans=1001001001;
    repn(i,N-K+1){
        ans=min(ans,min(abs(x[i])+abs(x[i+K-1]-x[i]),abs(x[i+K-1])+abs(x[i+K-1]-x[i])));
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include    <iostream>
#include    <string>
#include    <map>

using namespace std;

int main() {
    map<char,int> roman;

    // ローマ数字とアラビア数字の紐づけ
    roman['I'] = 1;
    roman['V'] = 5;
    roman['X'] = 10;
    roman['L'] = 50;
    roman['C'] = 100;
    roman['D'] = 500;
    roman['M'] = 1000;

    // ローマ数字のゼロに相当する文字を'_'と仮定する
    // (本来は存在しない)
    roman['_'] = 0;

    // 入力
    while(1) {
        string input;

        cin >> input;
        if(cin.eof()) break;

        char prev = '_';
        int sum = 0;
        for(auto c : input) {
            // 入力された数字はとりあえず合計に加算する
            sum += roman[c];

            // 0でない今の数字が前の数字よりも大きい場合(例えばIX)は、今の数字から前の数字を引いてあげる。
            // ここで前の数字を２つ分多く足している状態なので、この分を引き算で取り除くと都合がよい事になる。
            // (引き算は前の1文字分のみ考えればよい。即ち、IIXは10-2=8ではなく、1+10-1=10となる点に注意)
            if(roman[prev] == 0 || roman[c] <= roman[prev])
                prev = c;
            else {
                sum -= roman[prev] * 2;
                prev = '_';
            }
        }

        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,i;
	string str;
	cin>>k>>str;
	if(str.length()<=k)
	cout<<str<<endl;
	else
	{
		for(i=0;i<k;i++)
		cout<<str[i];
		cout<<"..."<<endl;
	}
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 3568
double a,b,c,d,x,y;z;main(s){for(;~scanf("%*d%lf%lf%lf%lf"+z,&a,&b,&c,&d);z=3)s++%2?y=b-d,x=a-c:puts((b-d)*x-y*(a-c)?"NO":"YES");}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int H,W,K;
	string SS[10];
	cin >> H >> W >> K;
	for(int i = 0; i < H; i++){
		cin >> SS[i];
	}
	
	int black = 0;
	for(int h = 0; h < H; h++){
		for(int w = 0; w < W; w++){
			if(SS[h][w] == '#'){
				black++;
			}
		}
	}
	
	int ans = 0;
	for(int bit = 0; bit < (1<<(H+W)); bit++){
		int count = 0;
		string S[10];
		for(int i =0; i < H; i++){
			S[i] = SS[i];
		}
		for(int h = 0; h < H; h++){
			if(bit & (1 << h)){
				for(int ww = 0; ww < W; ww++){
					if(S[h][ww] == '#'){
						count++;
						S[h][ww] = 'r';
					}
				}
			}
		}
		for(int w = 0; w < W; w++){
			if(bit & (1 << (H+w))){
				for(int hh = 0; hh < H; hh++){
					if(S[hh][w] == '#'){
						count++;
						S[hh][w] = 'r';
					}
				}
			}
		}
		if(black - count == K){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

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



int main(){

    fast;
    int x;
    cin>>x;
    if(x)
    cout<<0;
    else
    cout<<1;
    

}

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

using namespace std;

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

    int count = 0;
    stack<int> st;
    for( char x: s) {
        if( x == 'T' && !st.empty()) {
            st.pop();
            count ++;
        }
        if( x == 'S') {
            st.push('S');
        }
    }
    cout << (s.size() - 2 * count) << endl;
}

Measured memory_bytes: 900
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int a[maxn];

int main()
{
    int c;
    scanf("%d",&c);
    for(int i=0; i<c; i++)
        scanf("%d",&a[i]);
    sort(a,a+c);
    int m=-1,n=-1;
    for(int i=c-1; i>=0; i--)
    {
        if(a[i]==a[i-1]&&i>=1)
        {
            m=a[i];
            a[i]=0;
            a[i-1]=0;
            break;
        }
    }
    sort(a,a+c);
    for(int i=c-1; i>=0; i--)
    {
        if(a[i]==a[i-1]&&i>=1)
        {
            n=a[i];
            break;
        }
    }
    // cout<<m<<" "<<n<<endl;
    if(n!=-1&&m!=-1)
        cout<<(ll)n*m<<endl;
    else
        cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int N;
	cin >> N;
	string S[N];
	int P[N];
	int n[N];
	for(int i=0;i < N;i++){
		n[i]=i+1;
	}
	for(int i = 0;i < N; i++){
		cin >> S[i] >> P[i];
	}
	string buf;
	int b;
	for(int t=0;t<N;t++){
	for(int i = 0;i <N-1;i++){
		if(S[i]>S[i+1]){
			buf = S[i];
			S[i] = S[i+1];
			S[i+1] = buf;
			b = n[i];
			n[i]=n[i+1];
			n[i+1]=b;
			b=P[i];
			P[i]=P[i+1];
			P[i+1]=b;
		}
	}
	}	
	for(int t=0;t<N;t++){
	for(int i = 0;i <N-1;i++){
		if(S[i]==S[i+1] && P[i]<P[i+1]){
			buf = S[i];
			S[i] = S[i+1];
			S[i+1] = buf;
			b = n[i];
			n[i]=n[i+1];
			n[i+1]=b;
			b=P[i];
			P[i]=P[i+1];
			P[i+1]=b;
		}
	}
	}
	

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
map<ll,ll> ma;
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  ll n; cin >> n;
  if(n==0){
    cout << 0 << endl;
    return 0;
  }
  string s="";
  while(n!=0){
    int k = n%2;
    if(k<0) k+=2;
    s += (char)('0' + k);
    n = (n-k)/(-2);
  }
  reverse(all(s));
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N=int(input())
As=list(map(int, input().split()))

k=0
k1=As[0]
g=0
for i in range(2,N+1):
    if i%2==1:
        k=max(k+As[i-1],g)
        k1=k1+As[i-1]
    if i%2==0:
        g=max(k1,g+As[i-1])
    #print(k,k1,g)

ans=g if N%2==0 else k
print(ans)

Measured memory_bytes: 31512
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };

    let n_string = {
        let mut ws = s.split_whitespace();
        let n_string: String = ws.next().unwrap().parse().unwrap();
        n_string
    };

    let mut sum: i32 = 0;

    for i in n_string.as_str().chars() {
        let num : i32 = i as i32 - 48;
        sum += num;
    }

    if sum % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main(void){
  int n,a[100000],Min = 1000000000,Max = 0,count = 0,result = 1;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(Min > a[i])Min = a[i];
    if(Max < a[i])Max = a[i];
    if(i >= 1 && a[i] == a[i - 1])count++;
  }
  if(count == n - 1)cout << a[0] << endl;
  else{

  for(int i = 2; i <= min(Min,Max / 2); i++){
    for(int j = 0; j < n; j++){
      if(a[j] % i != 0)break;
      if(j == n - 1)result = i;
    }
  }
  cout << result << endl;
  
  }
  return 0;
}

Measured memory_bytes: 640
STDIN.gets.to_i
numbers = STDIN.gets.split(' ').map(&:to_i)

odds = 0
evens = 0

numbers.each do |num|
  if (num % 2 == 0)
    evens += 1
  else
    odds += 1
  end
end

if (evens == 1 && odds == 0)
  puts 'Yes'
elsif (evens == 0 && odds == 1)
  puts 'Yes'
else
  evens += odds / 2

  odds = odds % 2
  evens = evens % 2
  if (odds == 0)
    puts 'YES'
  else
    puts 'NO'
  end
end

Measured memory_bytes: 8452
#include<iostream>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int a, b;
int x, y;
int main() {
	cin >> a >> b;
	rep(i, 10000) {
		x = i * 0.08;
		y = i * 0.1;
		if (x == a && y == b) {
			cout << i << endl;

			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    n = A[-1]
    import bisect
    idx = bisect.bisect_left(A, n//2)
    candidates = []
    if idx < N:
        candidates.append(A[idx])
    if idx > 0:
        candidates.append(A[idx-1])

    if abs(n/2 - candidates[0]) < abs(n/2 - candidates[1]):
        print(n, candidates[0])
    else:
        print(n, candidates[1])       

    
if '__main__' == __name__:
    resolve()

Measured memory_bytes: 14428
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
L = []
ans = 0
for i in range(n):
    a, b = LIST()
    ans += b - a + 1
print(ans)




Measured memory_bytes: 6068
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int n, k, a[234567], f[234567], sum;
signed main() {
	cin >> n >> k;
	for0(i, n)cin >> a[i]; sort(a, a + n);
	for0(i, n)cin >> f[i]; sort(f, f + n);
	for0(i, n)sum += a[i];
	if (sum <= k) { cout << "0\n"; return 0; }
	int l = 0, r = 1000000000009;
	while (r - l > 1) {
		int mid = (l + r) / 2;
		int k1 = k;
		for0(i, n)
			k1 -= max((int)0, a[i] - mid / f[n - i - 1]);
		if (k1 >= 0)r = mid;
		else l = mid;
	}
	cout << r << endl;
}

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

int main()
{
    ll A,B;
    cin>>A>>B;
    ll a,s,m;
    a=A+B;
    s=A-B;
    m=A*B;
   ll  MM=max(a,s);
    cout<<max(MM,m)<<endl;


  return 0;
}


Measured memory_bytes: 256
N, T = map(int, input().split())
A = [0] * T
B = [0] * T
for _ in range(N):
    a, b = map(int, input().split())
    for i in range(T)[::-1]:
        if i + a < T:
            A[i+a] = max(A[i+a], A[i] + b)
            B[i+a] = max(B[i+a], B[i] + b)
        B[i] = max(B[i], A[i] + b)
print(max(B))

Measured memory_bytes: 48856
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    to = [[None]*n for _ in range(60)]
    to[0] = a
    for i in range(1, 60):
        for j in range(n):
            to[i][j] = to[i-1][to[i-1][j]-1]
    p = 1
    for i in range(59, -1, -1):
        num = 1 << i
        if k >= num:
            k -= num
            p = to[i][p-1]
    print(p)
            

if __name__ == "__main__":
    main()

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

int main(void){
  int N, M;
  vector<int> w, h;
  vector<int> wsum, hsum;
  while(cin >> N >> M, N | M){
    map<int, int> hm, wm;
    h.resize(N);  hsum.resize(N+1);
    w.resize(M);  wsum.resize(M+1);
    hsum[0] = wsum[0] = 0;
    for(int i=0; i < N; i++){
      cin >> h[i];
      if(i != 0){
        hsum[i+1] = hsum[i] + h[i];
      }else{
        hsum[i+1] = h[i];
      }
    }
    for(int i=0; i < M; i++){
      cin >> w[i];
      if(i != 0){
        wsum[i+1] = wsum[i] + w[i];
      }else{
        wsum[i+1] = w[i];
      }
    }


    for(int i=0; i < M+1; i++){
      for(int j=i+1; j < M+1; j++){
        int a = wsum[j] - wsum[i];
        if(wm.find(a) == wm.end()){
          wm[a] = 1;
        }else{
          wm[a]++;
        }
      }
    }
    int ans = 0;
    for(int i=0; i < N+1; i++){
      for(int j=i+1; j < N+1; j++){
        int a = hsum[j] - hsum[i];
        if(wm.find(a) != wm.end()){
          ans += wm[a];
        }
      }
    }
  cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 14596
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
 
#define ll long long
 
 
int main() {
	int N;
  	cin >> N;
  	
  	int out;
	out = 1000 -(N%1000);
  	
  	if(out == 1000){
      out =0;
    }
  
  	cout << out <<endl;


}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
using namespace std;

int main() {
    int a = 0, b = 0, c = 0, n, x;
    cin >> n;
    rep(i, 0, n) {
        cin >> x;
        if (x % 4 == 0) a++;
        else if (x % 2 == 0) b++;
        else c++;
    }
    a -= c;
    if (a == -1 && b == 0) {
        cout << "Yes" << endl;
    } else if (a >= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		new Main().mainrun();
	}

	Scanner scan;
	int N,W;
	List<Integer>v,w;

	private void mainrun() {

		scan = new Scanner(System.in);

		N = scan.nextInt();
		W = scan.nextInt();

		v = new ArrayList<Integer>();
		w = new ArrayList<Integer>();

		for(int i = 0;i < N ;i++){
			v.add(scan.nextInt());
			w.add(scan.nextInt());
		}

		int[][] dp = new int[N + 1][W + 1];
		Arrays.fill(dp[0], 0);

		for(int i = 0;i < N;i++) {
			for(int j = 0; j <= W;j++) {
				if(j >= w.get(i)) {
					dp[i + 1][j] = Math.max(dp[i][j - w.get(i)] + v.get(i),dp[i][j]);
				}else {
					dp[i + 1][j] = dp[i][j];
				}
			}
		}


		System.out.println(dp[N][W]);

		scan.close();
	}
}


Measured memory_bytes: 31216
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &e : A) cin >> e;

    vector<int> s(N+1), rs(N+1);
    s[0] = 0;
    rs[N] = 0;
    for (int i = 0; i < N; i++) {
        s[i+1] = gcd(s[i], A[i]);
        rs[N-i-1] = gcd(rs[N-i], A[N-i-1]);
    }

    int ans = -INF;
    for(int i = 0; i < N; i++) {
        ans = max(ans, gcd(s[i], rs[i+1]));
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> C(N-1),S(N-1),F(N-1),ans(N);
  for (int i = 0; i < N; i++) cin >> C[i] >> S[i] >> F[i];
  
  for (int i = 0; i < N-1; i++) {
    int t = 0;
    for (int j = i; j < N-1; j++) {
      if (t <= S[j]) t = S[j] + C[j];
      else t = (t + F[j] - 1) / F[j] * F[j] + C[j];
    }
    ans[i] = t;
  }
  ans[N-1] = 0;
  
  for (int i = 0; i < N; i++) cout << ans[i] << endl;  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a,b;
	cin >> a >> b;
	
	if((a*b) % 2 == 0)
	{
		cout << "Even" << endl;
	}
	else
	{
		cout << "Odd" << endl;
	}
	return 0;
}

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

#define ll long long

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2;
    } else {
        cout << min(a - 1, n - b) + (b - a + 1) / 2;
    }

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B,C,D; cin>>A>>B>>C>>D;
    ll ans = A*C;
    chmax(ans,A*D);
    chmax(ans,B*C);
    chmax(ans,B*D);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3648
X, N = map(int, input().split())
p = list(map(int, input().split()))
a = [i for i in range(-1, 103)]
for P in p:
    a.remove(P)

ans = 101
d = 10000
for A in a:
    if d > abs(A-X):
        ans = A
        d = abs(A-X)


print(ans)


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

using namespace std;

int max(int m,int n ){
 if(m > n){
    return m;
  }
 else{
  return n;
 }
}


int main(){

 int n,m;
 scanf("%d",&n);
 m=n;
 vector<int> answer(3),answer1(3);
 while(n > 0){
  vector<int> values(3);
  for(int i = 0;i < 3;++i){
     scanf("%d",&values[i]);
  }
 if(m!=n){
   for(int i = 0;i < 3; ++i){
    int val = -99999;
    for(int j = 0; j < 3;++j){	
	if(i!=j){
        val = max(val,answer[j]);
         }
     }
     // printf("%d\n",val);
     answer1[i] = values[i] + val;
    }
   answer = answer1;
  }
else{
   for(int i=0;i<3;++i){
      answer[i] = values[i]; 
   }
}
 n--;
 }
int c = -999999;
for(int i=0;i < 3; ++i){
//        printf("%d ",answer[i]);
        c = max(c,answer[i]);
}
printf("%d",c);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
using namespace std;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                
    #ifndef _LOCAL          
    #endif // _LOCAL

    long long a, b, c, d;

    cin >> a >> b >> c >> d;

    if (b <= 0 && d <= 0) {
        cout << a * c << "\n";
        return 0;
    }

    if (a >= 0 && c >= 0) {
        cout << b * d << "\n";
        return 0;
    }

    cout << max(max(b * d, a * c), max(a * d, c * b)) << "\n";

    return 0;
}

Measured memory_bytes: 3648
h,w=map(int,input().split())

#縦をずらしながら全探索
#  |
#  |==>
#  |

ans=(10**5)*(10**5)
for x in range(1,w):
    tmp=[x*h,(w-x)*(h//2),(w-x)*(h-(h//2))]
    ans=min(ans,max(tmp)-min(tmp))
    #print("x>>",x,ans,tmp)
    if w-x>=2:
        tmp=[x*h,((w-x)//2)*h,((w-x)-(w-x)//2)*h]
        ans=min(ans,max(tmp)-min(tmp))
    #print("x>>",x,ans)

#横をずらしながら全探索
#  ---------
#     ||  
#     \/


for y in range(1,h):
    tmp=[y*w,(h-y)*(w//2),(h-y)*(w-w//2)]
    ans=min(ans,max(tmp)-min(tmp))

    if h-y>=2:
        tmp=[y*w,((h-y)//2)*w,((h-y)-(h-y)//2)*w]
        ans=min(ans,max(tmp)-min(tmp))
    #print("y>>",y,ans)

print(ans)

Measured memory_bytes: 68436
// E - Almost Everywhere Zero
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
string N;
int K;
int lt = 0, eq = 1;//lt: <, eq: =
int dp[101][2][4];// digit DP, [|N|+1: 1 origin][lt|eq][k:0~3]

int main(){
	cin>>N>>K;
	N = "0" + N;
	int dn = N.size();
	int di = N[0] - '0';
	dp[0][eq][0] = 1;
	rp(i,1,dn){
		di = N[i] - '0';
		rp(k,0,4){
			// lt
			dp[i][lt][k] = dp[i-1][lt][k] * 1 + dp[i-1][eq][k] * (di?1:0);
			if(k) dp[i][lt][k] += dp[i-1][lt][k-1] * 9 + dp[i-1][eq][k-1] * max(0,di-1);
			// eq
			if(dp[i-1][eq][k]) dp[i][eq][k+(di>0)] = 1;
		}
	}
	cout<< dp[dn-1][lt][K] + dp[dn-1][eq][K] <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	if(s=="AAA"||s=="BBB"){
		cout << "No";
	}
	else{
		cout <<"Yes";
	}
	// your code goes here
	return 0;
}

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

vector<vector<int>> g;
vector<int> prenum;
vector<int> parent;
vector<int> lowest;
vector<int> visited;
int timer = 1;

void dfs( int u, int p )
{
	prenum[u] = lowest[u] = timer;
	timer++;
	visited[u] = 1;
	for( int v : g[u] ) {
		if( visited[v] == 0 ) {
			parent[v] = u;
			dfs( v, u );
			lowest[u] = min( lowest[u], lowest[v] );
		}
		else if( v != p ) {
			lowest[u] = min( lowest[u], prenum[v] );
		}
	}
}

int main()
{
	int V, E;
	cin >> V >> E;
	g = vector<vector<int>>( V );
	prenum = vector<int>( V );
	parent = vector<int>( V );
	lowest = vector<int>( V );
	visited = vector<int>( V );
	for( int i = 0; i < E; i++ ) {
		int s, t;
		cin >> s >> t;
		g[s].push_back( t );
		g[t].push_back( s );
	}

	dfs( 0, -1 );
	set<int> ap;
	int np = 0;
	for( int i = 1; i < V; i++ ) {
		int p = parent[i];
		if( p == 0 ) np++;
		else if( prenum[p] <= lowest[i] ) ap.insert( p );
	}
	if( np > 1 ) ap.insert( 0 );

	for( auto x : ap ) {
		cout << x << endl;
	}
}



Measured memory_bytes: 4600
n = int(input())
c = [[0 for i in range(10)] for j in range(10)]
for i in range(1, n+1):
    c[int(str(i)[0])][int(str(i)[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j]*c[j][i]

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
typedef pair<int, int> P;
typedef pair<P, P> PP;
vector<PP> ans;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    int a[510][510];
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
        }
    }

    rep(i, h) {
        rep(j, w - 1) {
            if(a[i][j] % 2 == 1) {
                a[i][j]--;
                a[i][j + 1]++;
                ans.push_back({{i , j}, {i, j + 1}});
            }
        }
    }
    rep(i, h - 1) {
        if(a[i][w - 1] % 2 == 1) {
            a[i][w - 1]--;
            a[i + 1][w - 1]++;
            ans.push_back({{i , w - 1}, {i + 1, w - 1}});
        }
    }
    cout << ans.size() << endl;
    for(auto e: ans) {
        cout << e.first.first  + 1 << " " << e.first.second + 1 << " " << e.second.first + 1 << " " << e.second.second + 1 << endl;
        
    }


    return 0;
}


Measured memory_bytes: 5232
#include <stdio.h>

void insertionSort(int* a, int n) {
	int i, v, j, k;
	for (i = 1; i <= n; i++) {
		for (k = 0; k < n; k++) {
			printf("%d", a[k]);
			if (k != n - 1) {
				printf(" ");
			} else {
				printf("\n");
			}
		}
		v = a[i];
		j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
	}
}

int main(int argc, char const *argv[]) {
	int i, n;
	int a[100];
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	insertionSort(a, n);
	return 0;
}

Measured memory_bytes: 1820
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

const int MOD = 1000000007;

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

    ll N, K;
    cin >> N >> K;
    vector<vector<ll>> g(N, vector<ll>());
    Rep (i, N-1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ll ans = K;
    queue<ll> q;
    vector<bool> visited(N, false);
    q.push(0);
    visited[0] = true;
    while (!q.empty()) {
        ll now = q.front();
        q.pop();
        ll color = K-2;
        if (now == 0) color = K-1;
        for (ll v : g[now]) {
            if (visited[v]) continue;
            ans *= color;
            ans %= MOD;
            q.push(v);
            visited[v] = true;
            color--;
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 7412
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <cmath>      // sqrt
#include <cstdlib>    // exit
#include <algorithm>  // min,max
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define R 1000000007
#define DBG 1

#define MAXN 602
int b[MAXN][MAXN];
int accz[MAXN][MAXN];
int accu[MAXN][MAXN];

int main() {
  int h,w;
  cin >> h >> w;
  forr(i,0,MAXN-1)
  forr(j,0,MAXN-1)
    b[i][j] = accz[i][j] = accu[i][j] = 0;
  forr(i,0,h-1) {
    string s;
    cin >> s;
    forr(j,0,w-1) {
      b[i-j+w][i+j] = (s[j]=='#' ? 1 : 0);
    }
  }
  forr(z,-w,h-1)
  forr(u,0,w+h-2) {
    accz[z+w][u] = accz[z-1+w][u] + b[z+w][u];
    accu[z+w][u] = accu[z+w][u-1] + b[z+w][u];
  }
  int sum = 0;

  forr(u,0,w+h-1) {
    int lft = (u<w ? -u : u-2*w+2);
    int rgt = (u<h ?  u : 2*h-u-2);
    forr(z,lft,rgt) {
      if (b[z+w][u]==0) continue;
      forr(zz,z+1,rgt) {
        if (b[zz+w][u]==0) continue;
        int uu = u - (zz-z);
        if (uu >= 0) {
          int lft2 = (uu<w ? -uu : uu-2*w+2);
          int rgt2 = (uu<h ?  uu : 2*h-uu-2);
          int z3 = min(zz,rgt2);
          int z4 = max(z,lft2) - 1;
          sum += accz[z3+w][uu] - accz[z4+w][uu];
        }
        uu = u + (zz-z);
        if (uu <= w+h) {
          int lft2 = (uu<w ? -uu : uu-2*w+2);
          int rgt2 = (uu<h ?  uu : 2*h-uu-2);
          int z3 = min(zz,rgt2);
          int z4 = max(z,lft2) - 1;
          sum += accz[z3+w][uu] - accz[z4+w][uu];
        }
      }
    }
  }

    forr(z,-w+1,h-1) {
      int lo = abs(z);
      int hi = (z<h-w ? 2*w+z-2 : 2*h-z-2);
      forr(u,lo,hi) {
        if (b[z+w][u]==0) continue;
        forr(uu,u+2,hi) {
          if (b[z+w][uu]==0) continue;
          int zz = z - (uu-u);
          if (zz >= 1-w) {
            int lo2 = abs(zz);
            int hi2 = (zz<h-w ? 2*w+zz-2 : 2*h-zz-2);
            int u3 = min(uu-1,hi2);
            int u4 = max(u+1,lo2) - 1;
            sum += accu[zz+w][u3] - accu[zz+w][u4];
          }
          zz = z + (uu-u);
          if (zz <= h-1) {
            int lo2 = abs(zz);
            int hi2 = (zz<h-w ? 2*w+zz-2 : 2*h-zz-2);
            int u3 = min(uu-1,hi2);
            int u4 = max(u+1,lo2) - 1;
            sum += accu[zz+w][u3] - accu[zz+w][u4];
          }
        }
      }
    }

    cout << sum << endl;
}


Measured memory_bytes: 4480
import sys
input = sys.stdin.readline
N, Z, W = map(int, input().split())
a = list(map(int, input().split()))
dp = [[float("inf"), 0] for _ in range(N)]
dp[-1][0] = abs(a[-1] - W)
dp[-1][1] = 0
for i in range(N - 1):
  dp[-1][1] = max(dp[-1][1], abs(a[i] - a[-1]))
#print(dp)
for i in range(N - 2, -1, -1):
  for j in range(N - 1, i, -1):
    dp[i][0] = min(dp[i][0], dp[j][1], abs(a[i] - a[j]))
    dp[i][1] = max(dp[i][1], dp[j][0], abs(a[i] - a[j]))
#print(dp)
res = 0
for i in range(N): res = max(res, dp[i][0])
print(res)

Measured memory_bytes: 46572
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm> // sort
#include <map>       // pair
#include <vector>
using namespace std;

#define REP(a,b) for(int i =(a);i < (b);i++)
#define FOR(n) for(int i = 0; i<(n); i++)
#define COUT(c)  cout<<(c)<<endl


const int INF = 100100100;
const int MOD = (int)1e9 +7;
const double EPS = 1e-9; 

typedef long long int ll;

//char in[120];
//ex. pair
//pair<pair<string,int>,int> p[110];

int main(){
    int a,b,hole=1,ans=0;cin>>a>>b;
    while(hole < b){
        hole += a-1;
        ans++;
    }
    cout<<ans<<endl;
    return 0;    
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

int N;
LL P[250000];

LL ans = 0;

void solve(){
	//番号iの観客の位置をpos_h[i],pos_w[i]で表す
	vector<LL> pos_h(N*N+1);
	vector<LL> pos_w(N*N+1);
	//位置(h,w)に座っている人が退席するコストをcost[h][w]とおく
	vector<vector<LL>> cost(N,vector<LL>(N));
	for(int h=0;h<N;h++){
		for(int w=0;w<N;w++){
			cost[h][w] = min(min(h,N-h-1),min(w,N-w-1));
			pos_h[N*h+w+1] = h;
			pos_w[N*h+w+1] = w;
		}
	}

	vector<vector<LL>> seat(N,vector<LL>(N,1));

	for(int i=0;i<N*N;i++){
		LL leaving_h = pos_h[P[i]];
		LL leaving_w = pos_w[P[i]];

		queue<pair<LL,LL>> q;
		q.push(pair<LL,LL>(leaving_h,leaving_w));

		auto spread = [&](LL h,LL w){
			int dh[4] = {-1,1,0,0};
			int dw[4] = {0,0,-1,1};
			for(int j=0;j<4;j++){
				if(h+dh[j]>=0 && h+dh[j]<=N-1 && w+dw[j]>=0 && w+dw[j]<=N-1){
					if(seat[h][w]==0){
						if(cost[h+dh[j]][w+dw[j]]>cost[h][w]){
							cost[h+dh[j]][w+dw[j]] = cost[h][w];
							q.push(pair<LL,LL>(h+dh[j],w+dw[j]));
						}
					}
					if(seat[h][w]==1){
						if(cost[h+dh[j]][w+dw[j]]>cost[h][w]+1){
							cost[h+dh[j]][w+dw[j]] = cost[h][w]+1;
							q.push(pair<LL,LL>(h+dh[j],w+dw[j]));
						}
					}
				}
			}
		};
		auto show_cost = [&](){
			for(int h=0;h<N;h++){
				for(int w=0;w<N;w++){
					cout << cost[h][w] << " ";
				}
				cout << endl;
			}
			cout << endl;
		};

		spread(leaving_h,leaving_w);
		ans += cost[leaving_h][leaving_w];
		seat[leaving_h][leaving_w] = 0;
		//printf("P[%d]=%lld\n",i,P[i]);
		//show_cost();
		while(!q.empty()){
			LL now_h = q.front().first;
			LL now_w = q.front().second;
			q.pop();
			//cout << "+=" << cost[now_h][now_w] << endl;
			spread(now_h,now_w);
			//show_cost();
		}
	}
}

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

    solve();

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

Measured memory_bytes: 12712
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N){
    cout<<ceil(double(N)/2.0)<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
import bisect
n = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))

A.sort()
B.sort()
C.sort()
ans = 0
for j in range(n):
    i = bisect.bisect_left(A, B[j])
    k = n - bisect.bisect_right(C, B[j])
    ans += int(i*k)
print(ans)

Measured memory_bytes: 29380
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

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

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

    sort(c.begin(), c.end());

    cout << c[n - 1].first + c[n - 1].second << endl;
}


Measured memory_bytes: 3948
n,q=map(int,input().split())
s=input()
a=[0]*n

for i in range(n-1):
  a[i+1]=a[i]+(1 if s[i:i+2]=='AC' else 0)

for _ in range(q):
  l,r=map(int,input().split())
  print(a[r-1]-a[l-1])


Measured memory_bytes: 9668
kuziNum=int(input())
nyuuryokuNum=0
prizeDictionary={}

while kuziNum > nyuuryokuNum:
  nextPrize =input()
  if nextPrize not in prizeDictionary :
    prizeDictionary[nextPrize]=nextPrize
  nyuuryokuNum+=1

print(str(len(prizeDictionary.keys()))) 

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

int main(){
    int n, m;
    int count = 0;
    cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    cin >> l[0] >> r[0];
    int max = l[0];
    int min = r[0];
    for(int i = 1; i < m; i++){
        cin >> l[i] >> r[i];
        if(l[i] > max) max = l[i];
        if(r[i] < min) min = r[i];
    }
    int ans = min - max + 1;
    if(ans < 0) cout << 0 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
k = int(input())
a,b = map(int, input().split())
c,d,e,f,g = a%k,b%k,a//k,b//k,0
if c!=0 and d!=0:
    if e == f:
        if d >= c:
            g = 1

if g == 0:
    print('OK')
else:
    print('NG')

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

int main()
{
    int n; cin>>n;
    vector<int> a(3*n);
    for(auto& e: a) cin>>e;

    vector<long> sa(n+1);
    priority_queue<int, vector<int>, greater<int>> qa;
    for(int i=0; i<n; ++i) {
        qa.push(a[i]);
        sa[0]+=a[i];
    }
    for(int k=1; k<=n; ++k) {
        sa[k]=sa[k-1];
        if (qa.top()<=a[n+k-1]) {
            sa[k]+=a[n+k-1]-qa.top();
            qa.pop();
            qa.push(a[n+k-1]);
        }
    }

    vector<long> sb(n+1);
    priority_queue<int> qb;
    for(int i=3*n-1; i>=2*n; --i) {
        qb.push(a[i]);
        sb[0]+=a[i];
    }
    for(int k=1; k<=n; ++k) {
        sb[k]=sb[k-1];
        if (qb.top()>=a[2*n-k]) {
            sb[k]+=a[2*n-k]-qb.top();
            qb.pop();
            qb.push(a[2*n-k]);
        }
    }

    long res=LONG_MIN;
    for(int i=0; i<=n; ++i) res=max(res, sa[i]-sb[n-i]);
    cout<<res<<endl;
}


Measured memory_bytes: 4088
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;


int n;
string s;
int c1, c2, c3;
int ans;

int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        string s;
        cin >> s;
        for (int j = 1; j < (int)s.size(); ++j)
            if (s[j - 1] == 'A' && s[j] == 'B') ++ans;
        char c;
        c = s[(int)s.size() - 1];
        if (s[0] == 'B' && c == 'A') ++c1;
        else if (s[0] == 'B') ++c2;
        else if (c == 'A') ++c3;
    }
    int res = ans;
    int xx, yy, z, x, y, zz;
    int cur;
    for (int i = 0; i <= c2 && i <= c1; ++i) {
        for (int j = 0; j <= c3 && j <= c1 - i; ++j) {
            cur = ans + i + j;
            x = c1 - i - j;
            y = c2 - i;
            z = c3 - j;
            xx = min({x, y, z});
            zz = xx;
            cur += xx + xx;
            x -= xx;
            y -= xx;
            z -= xx;
            if (x == 0) cur += min(y, z);
            else if (y == 0) {
                yy = min(x, z);
                cur += yy;
                x -= yy;
                z -= yy;
                if (z == 0 && x) {
                    if (i + j + zz + yy) cur += x;
                    else cur += x - 1;
                }
            } else {
                z = y;
                yy = min(x, z);
                cur += yy;
                x -= yy;
                z -= yy;
                if (z == 0 && x) {
                    if (i + j + zz + yy) cur += x;
                    else cur += x - 1;
                }
            }
            if (cur > res) res = cur;
        }
    }
    cout << res << '\n';
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool v[4][14];
int main() {
	int n; cin >> n; char q; int m;
	for (int i = 0; i < n; i++) {
		cin >> q;
		cin >> m;
		if (q == 'S')
			v[0][m] = true;
		if (q == 'C')
			v[1][m] = true;
		if (q == 'H')
			v[2][m] = true;
		if (q == 'D')
			v[3][m] = true;
	}
	for (int k = 1; k < 14; k++) {
		if (!v[0][k]) {
			cout << "S " << k << endl;
		}
	}
	for (int k = 1; k < 14; k++) {
		if (!v[2][k]) {
			cout << "H " << k << endl;
		}
	}
	for (int k = 1; k < 14; k++) {
		if (!v[1][k]) {
			cout << "C " << k << endl;
		}
	}
	for (int k = 1; k < 14; k++) {
		if (!v[3][k]) {
			cout << "D " << k << endl;
		}
	}
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
int main()
{
	ll Sl,Tl,x;
	string S;
	std::string T;
	fast;
	getline(cin,S);
	getline(cin,T);
	Sl=S.length();
	Tl=T.length();
	if(Tl==Sl+1)
	{
		if (!T.empty()) {
		T.resize(T.size() - 1);
	}

		    int x = S.compare(T); 
		    if(x==0)
		    {
		    	cout<<"Yes";
		    }
		    else
		    {
		    	cout<<"No";
		    }

	}
	return 0;
}

Measured memory_bytes: 3656
import sys

read = sys.stdin.read
readline = sys.stdin.readline


class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1] * (n + 1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0] * (n + 1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if self.root[x] < 0:
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]

    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if x == y:
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1

    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


N, M, K, *ABCD = map(int, read().split())
AB = ABCD[:M * 2]
CD = ABCD[M * 2:]
F = UnionFind(N)
friend = [[] for _ in range(N + 1)]
for A, B in zip(*[iter(AB)] * 2):
    F.Unite(A, B)
    friend[A].append(B)
    friend[B].append(A)

block = [[] for _ in range(N + 1)]
for C, D in zip(*[iter(CD)] * 2):
    block[C].append(D)
    block[D].append(C)

answer = []
for i, n in enumerate(map(len, friend[1:]), 1):
    cnt = F.Count(i) - 1 - n
    for j in block[i]:
        if F.isSameGroup(i, j):
            cnt -= 1
    answer.append(cnt)

print(' '.join(map(str, answer)))


Measured memory_bytes: 58504
import java.util.*;
import java.io.*;

class Main {

	void solve() {
		
		char[] a = {' ', 'a', 'c', 'a', 'b', 'a', 'b', 'a', 'a', 'b', 'a', 'b', 'a'};
		int b = inint(), c = inint();
		
		out.println(a[b] == a[c] ? "Yes" : "No");
		
	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

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

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

	public char[][] incharmap(int h, int w) {
		char[][] a = new char[h][w];
		for (int i=0; i<h; i++) {
			String temp = in.next();
			for (int j=0; j<w; j++) {
				a[i][j] = temp.charAt(j);
			}
		}
		return a;
	}

}

Measured memory_bytes: 22868
#include<cstdio>

int main(){
    int A, B;
    scanf("%d %d", &A, &B);
    if (A < 14 && B < 14 && A > 0 && B > 0){
        if(A == 1 && B!= 1){
        printf("Alice");
    } else if (A != 1 && B == 1){
        printf("Bob");
    } else if (A != 1 && B != 1 && A > B){
        printf("Alice");
    } else if (A != 1 && B != 1 && A < B){
        printf("Bob");
     }else if (A == B){
         printf("Draw");
     }
     } 
    }


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

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

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}


int main(){
    long double a,b; cin >> a >> b;
    cout << (ll)floor(a*b+0.001) << endl;
}



Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
void solve() {
	double r;
	cin >> r;
	cout << acos(-1) * r * 2 << endl;
}
int32_t main() {
	BOLT;
	int t;
	t = 1;
	int counter = 0;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 3788