akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0; i<(lli)(n); i++)
#define repf(i, n) for(lli i=1; i<(lli)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n, m;
    cin >> n >> m;
    vi h(n);
    vvi adj(n);
    rep(i, n) cin >> h[i];

    rep(i, m){
        lli a, b;
        cin >> a >> b;
        a--; b--; // 0-origin
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    lli cnt = 0;
    rep(i, n){
        bool chk = true;
        for(auto p: adj[i]) if(h[i] <= h[p]) chk = false;
        if(chk) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 9792
#include <stdio.h>
#include <string.h>

int main (void){
  int N,c,i,l,j,m = 0;
  char t[102][12];

  scanf("%d", &N);

  for(i = 0 ; i < N ; i++){
  scanf("%s",t[i]);
  }


  for(j = 0;j < N-1 ; j++ ){
    int f = strlen(t[j])-1;
    if(t[j][f] != t[j + 1][0]){
      puts("No");
      return 0;
    }
  }

  for (c = 0;c < N;c++ ){
    for(l = c+1;l <N ;l++ ){
      if (strcmp(t[c],t[l])==0){
        puts("No");
        return 0;
      }
    }
  }


  puts("Yes");
  return 0;
}

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

#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define log(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)

using vi = vector<int>;


int main() {

    int n, k, x;
    cin >> n >> k;
    map<int,int> cnt;

    rep (i, n) {
        cin >> x;
        cnt[x]++;
    }

    vi a;
    for (auto p: cnt)
        a.eb(p.second);
    sort(all(a));

    int m = 0, l=len(a);
    rep (i, l-k) {
        m += a[i];
    }

    log(m);

    return 0;
}


Measured memory_bytes: 10748
import kotlin.math.abs

fun main() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }

    val b = bestB(a)
    var sum = 0L
    for (i in 1..n) sum += abs(a[i - 1].toLong() - b - i)
    println(sum)
}

private fun bestB(a: List<Int>): Int {
    val n = a.size
    var high = (1..n).map { a[it - 1] - it }.max()!! + 1
    var low = (1..n).map { a[it - 1] - it }.min()!!

    while (high - low > 1) {
        val mid = (high + low) / 2

        val big = (1..n).count { a[it - 1] < mid + it }
        val small = (1..n).count { a[it - 1] > mid + it }

        if (big > small) high = mid
        else low = mid
    }
    return low
}

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

int main() {
  ll n;
  cin >> n;
  ll limit=1000000007;
  ll pow10=1;
  ll pow9=1;
  ll pow8=1;
  ll ans=0;
  for (ll i=0;i<n;i++) {
    pow10 = (pow10*10)%limit;
    pow9 = (pow9*9)%limit;
    pow8 = (pow8*8)%limit;
  }
  ans = (pow10+limit*2-pow9*2+pow8)%limit;
  cout << ans;
  return 0;
}


Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  ld n,m,x,y;
  cin>>n>>m>>x>>y;
  
  cout << (n/2)*m << " ";
  
  cout << (2*x==n && 2*y==m?"1":"0") << endl;
  
}


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

using namespace std;

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

    int x = max(max(a, b), c);
    int ans = 0;

    if (x * 3 % 2 != (a + b + c) % 2) ++x;

    cout << ((x * 3 - (a + b + c)) / 2) << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
v = gets.chomp.split(" ").map(&:to_i)
c = gets.chomp.split(" ").map(&:to_i)
ans = 0

n.times do |i|
    tmp = v[i] - c[i]
    if tmp > 0 then
        ans += tmp
    end
end
puts ans

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

int main() {
  long long n, t, a, xt, xa;
  std::cin >> n;
  for (long long ni = 0; ni < n; ++ni) {
    std::cin >> t >> a;
    if (ni == 0) {
      xt = t;
      xa = a;
    } else {
      long long k = std::max((xt + t - 1) / t, (xa + a - 1) / a);
      xt = k * t;
      xa = k * a;
    }
  }
  std::cout << xt + xa << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
    // Your code here!
    //サイコロを作る
    //データセットをつくって方向ごとに入れ替える
    int dice[6]{};
    for(int i=0;i<6;i++)cin>>dice[i];
    string str;
    cin>>str;
    for(int i=0;i<str.size();i++)
    {
        int newdice[6]{};
        if(str[i]=='E')
        {
            newdice[0]=dice[3];
            newdice[1]=dice[1];
            newdice[2]=dice[0];
            newdice[3]=dice[5];
            newdice[4]=dice[4];
            newdice[5]=dice[2];
        }
        if(str[i]=='S')
        {
            newdice[0]=dice[4];
            newdice[1]=dice[0];
            newdice[2]=dice[2];
            newdice[3]=dice[3];
            newdice[4]=dice[5];
            newdice[5]=dice[1];
        }
        if(str[i]=='W')
        {
            newdice[0]=dice[2];
            newdice[1]=dice[1];
            newdice[2]=dice[5];
            newdice[3]=dice[0];
            newdice[4]=dice[4];
            newdice[5]=dice[3];
        }
        if(str[i]=='N')
        {
            newdice[0]=dice[1];
            newdice[1]=dice[5];
            newdice[2]=dice[2];
            newdice[3]=dice[3];
            newdice[4]=dice[0];
            newdice[5]=dice[4];
        }
        dice[0]=newdice[0];
        dice[1]=newdice[1];
        dice[2]=newdice[2];
        dice[3]=newdice[3];
        dice[4]=newdice[4];
        dice[5]=newdice[5];
    }
    cout<<dice[0]<<endl;
    return 0;
}


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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int lb = 0, rw = 0;
	for(int i=0;i<s.size();i++) {
		if(s[i] == '.') rw++;
	}
	int min = rw;
	for(int i=0;i<s.size();i++) {
		if(s[i] == '.') {
			rw--;
		} else {
			lb++;
		}
		if(lb + rw < min) min = lb + rw;
	}
	cout << min << endl;
	return 0;
}



Measured memory_bytes: 640
A, B, X = map(int, input().split())

# 解けなかった
# ans = 0
# temp_A = 0
# temp_B = 0
# for i in range(B, A-1, -1):
#     if i % X == 0:
#         temp_B = i
#         break

# for i in range(A-1, 0, -1):
#     if i % X == 0:
#         temp_A = i
#         break

# if temp_A != 0:
#     ans_a = temp_A / X
# else:
#     ans_a = 0

# if temp_B != 0:
#     ans_b = temp_B / X
# else:
#     ans_b = 0

# ans = ans_b - ans_a

# if X == 1:
#     ans = B+1

# 切り捨て除算を使えば上手くいく
# 割り算をして、小数点以下を捨てる方法
print((B//X) - ((A-1)//X))

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
// end of Template

ll n,a[300000],m1,m2;
priority_queue <ll> q;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        q.push(a[i]);
    }
    m1 = q.top();q.pop();
    m2 = q.top();q.pop();

    for(int i=1;i<=n;i++){
        if(a[i]!=m1){cout<<m1<<newl;}
        else{cout<<m2<<newl;}
    }

}


Measured memory_bytes: 4848
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    
    reps(i,1,10){
        if(n <= 111 * i){
            cout << 111 * i << endl;
            break;
        }
    }

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  int C0 = 0, C1 = 0, C2 = 0, C3 = 0;

  for (int i = 0; i < N; i++) {
    if (s.at(i) == "AC") {
      C0++;
    }
    if (s.at(i) == "WA") {
      C1++;
    }
    if (s.at(i) == "TLE") {
      C2++;
    }
    if (s.at(i) == "RE") {
      C3++;
    }
  }
    
  cout << "AC x " << C0 << endl << "WA x " << C1 << endl
       << "TLE x " << C2 << endl << "RE x " << C3 << endl;
}

Measured memory_bytes: 6420
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

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

bool prime(int n) {
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) { return false; }
  }
  return n != 1;
}

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

const ll INF = 1e9;
const ll MOD = 998244353;

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

const int COM_MAX = 1000100;
ll fac[COM_MAX], facinv[COM_MAX], inv[COM_MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  facinv[0] = facinv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < COM_MAX; ++i) {
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    facinv[i] = facinv[i-1] * inv[i] % MOD;
  }
}

ll COM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD) * facinv[n-k] % MOD;
}

ll PERM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD);
}

#define MAX_A 1000100

int main(int argc, char** argv) {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  COMinit();

  // sigma_d/i w[d] = 1/i
  vector<ll> w(MAX_A);
  for (ll i = 1; i < MAX_A; ++i) {
    w[i] += inv[i];
    if (w[i] < 0) {
      w[i] = w[i] % MOD + MOD; // w[i] >= 0
    }
    for (ll j = 2; i * j < MAX_A; ++j) {
      w[i*j] -= w[i];
    }
  }

  vector<ll> freq(MAX_A); // frequency of each A[i].
  rep(i, N) {
    ++freq[A[i]];
  }

  vector<ll> sumA(MAX_A);  // sumA[d] has the summension of A[i] (A[i] is the multiple of d).
  vector<ll> sumA2(MAX_A); // sumA2[d] has the summension of A[i] ** 2 (A[i] is the multiple of d).

  ll res = 0;
  for (ll i = 1; i < MAX_A; ++i) {
    for (ll j = 1; i * j < MAX_A; ++j) {
      ll a = i * j;
      sumA[i] += a * freq[a] % MOD;
      sumA[i] %= MOD;
      sumA2[i] += (a * a % MOD) * freq[a] % MOD;
      sumA2[i] %= MOD;
    }

    // For Debug
    // cout << sumA[i] << " -* " << sumA2[i] << "*" << w[i] << endl;
    // cout << (((sumA[i] * sumA[i] - sumA2[i]) % MOD) * w[i] % MOD) * inv[2] % MOD << endl;

    // (sumA[d] ** 2 - sumA2[d]) / 2 = summension of A[i]*A[j] (A[i], A[j] is the multiple of d, i < j)
    res += (((sumA[i] * sumA[i] - sumA2[i]) % MOD) * w[i] % MOD) * inv[2] % MOD;
    res %= MOD;
    if (res < 0) {
      res = res % MOD + MOD; // res >= 0
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 56576
d[1001],c;
main(w,n,i,C,W,b){
  for(;scanf("%d",&w),w;printf("Case %d:\n%d\n%d\n",++c,d[w],b),bzero(d,4004))
      for(scanf("%d",&n);n--;)
          for(i=w,scanf("%d,%d",&C,&W);i>=W;i--)
              d[i]=fmax(d[i],d[i-W]+C),b=d[i]-d[w]?b:i;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 2e9+7,MAX = 1e6+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vector<int> MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

int main()
{
	ll N;
	cin>>N;
	Sieve();
	map<int,int> PF;
	ll x = N;
	for(ll i=2;i*i<=N;i++)
	{
		if(!is_prime[i]) continue;
		int how=0;
		while(x%i==0)
		{
			x/=i;
			how++;
		}
		//cout<<i<<" "<<how<<endl;
		if(how)
		{
			PF[i]=how;
		}
	}

	if(x>1) PF[x] = 1;

	int ans=0;
	for(auto m:PF)
	{
		int y = m.second;

		int how = sqrt(2*y);
		if(how*(how+1)/2>y) how--;
		ans+=how;
	}
	cout<<ans<<endl;

}		

Measured memory_bytes: 7052
#include <stdio.h>
#define buf 400

int main(){
	
	int month[12]={0,31,29,31,30,31,30,31,31,30,31,30};
	int x,y,i,j,n;
	int year[buf];
	char str[buf];
  
	for( ; ; ){
		n=0;   
		fgets(str,sizeof(str),stdin);
		sscanf(str,"%d %d",&x,&y);
		if(x==0 && y==0)
			break;
		for(i=0;i<=400;i+=7){
			for(j=1;j<=7;j++){
				year[j+i]=j;
			}
		}
		for(i=0;i<x;i++)
			n += month[i];
		n = year[n+y];
		switch(n){
			case 1:
				printf("Thursday\n");
				break;
			case 2:
				printf("Friday\n");
				break;
			case 3:
				printf("Saturday\n");
				break;
			case 4:
				printf("Sunday\n");
				break;
			case 5:
				printf("Monday\n");
				break;
			case 6:
				printf("Tuesday\n");
				break;
			case 7:
				printf("Wednesday\n");
				break;
		}			
	}	
	return 0;	
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

using namespace std;
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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int A,B; cin >> A >> B;
    if (A >= 13) {
        cout << B << endl;
    } else if (A >= 6) {
        cout << B / 2 << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
import numpy as np

H,W = map(int, input().split())
res = []
for i in range(H):
    res.append(list(map(list,input().split())))

initial_map = []
for i in res:
    row = [f for f in i]
    initial_map.append(row[0])

remove_list = []
for i in range(H):
    if '#' not in initial_map[i]:
        remove_list.append(i)

count = 0
for i in remove_list:
    initial_map.pop(i-count)
    count += 1

remove_list = []

initial_map_t = np.array(initial_map).T.tolist()

for i in range(W):
    if '#' not in initial_map_t[i]:
        remove_list.append(i)

count = 0
for i in remove_list:
    initial_map_t.pop(i-count)
    count += 1

res = np.array(initial_map_t).T.tolist()

for i in res:
    for j in i:
        print(j,end='')
    print()

Measured memory_bytes: 14068
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }


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

  ll n;
  cin >> n;
  map <string, ll> ans;
  rep(i, 0, n){
    string s;
    cin >> s;
    ans[s]++;
  }
  cout << "AC x " << ans["AC"] << endl;
  cout << "WA x " << ans["WA"] << endl;
  cout << "TLE x " << ans["TLE"] << endl;
  cout << "RE x " << ans["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3676
import std.stdio,std.conv,std.string,std.algorithm,std.array,std.math;
void main(){
    auto sa=readln().split();
    auto sb=readln().split();
    auto sc=readln().split();
    auto sd=readln().split();
    int a,b,c,d,ans=0;
    a=to!int(sa[0]);
    b=to!int(sb[0]);
    c=to!int(sc[0]);
    d=to!int(sd[0]);
    
    if(a<b)
        ans+=a;
    else
        ans+=b;
    if(c<d)
        ans+=c;
    else
        ans+=d;
    writeln(ans);
}

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

int main() {
	int n,m,t[100000],p,x;
	cin>>n;
	for(int i=0;i<n;i++) cin>>t[i];
	cin>>m;
	
	for(int i=0;i<m;i++){
		cin>>p>>x;
		int sum=0;
		for(int j=0;j<n;j++){
			if(j==p-1) sum+=x;
			else sum+=t[j];
		}
		cout<<sum<<endl;
	}
	return 0;
}

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


void solve(long long N, long long K){
    long long r = N % K;
    cout << min(r, K-r) << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int n;
    cin>>n;
    vector<int> as(n);
    rep(i, n) cin>>as[i];

    int q;
    cin>>q;
    rep(i, q) {
        int k;
        cin>>k;
        cout<<distance(as.begin(), lower_bound(as.begin(), as.end(), k))<<' ';
        cout<<distance(as.begin(), upper_bound(as.begin(), as.end(), k))<<endl;;
    }
}


Measured memory_bytes: 3376
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
syurui = len(set(a))
#print(syurui)
c = Counter(a)
ans = 0
c_sort = c.most_common()
#print(c_sort)
for i in range(1, syurui-k + 1):
    ans += c_sort[-i][1]
print(ans)

Measured memory_bytes: 160856
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    int N;
    cin >> N;
    int A,yon=0,ni=0;
    for(int i=0;i<N;i++){
        cin >> A;
        if(A%4==0){
            yon++;
        }else if(A%2==0){
            ni++;
        }
    }
    int other = N-yon-ni;
    if((ni==0&&yon+1>=other)||yon>=other){
        cout << "Yes" << endl; 
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int a[MAXN],b[MAXN],N,val[MAXN],tot,st,ed,deg[MAXN],cnt;
int fa[MAXN];
map<int,int> zz;
int getfa(int u) {
	return fa[u] == u ? u : fa[u] = getfa(fa[u]);
}
void Init() {
	read(N);
	for(int i = 1 ; i <= N ; ++i) {read(a[i]);a[N + 1] ^= a[i];}
	for(int i = 1 ; i <= N ; ++i) read(b[i]);
	for(int i = 1 ; i <= N + 1 ; ++i) {
		zz[a[i]]++;
	}
}
void Solve() {
	for(int i = 1 ; i <= N ; ++i) {
		if(zz[b[i]] == 0) {
			puts("-1");return;
		}
		zz[b[i]] -= 1;
	}
	st = a[N + 1];
	for(int i = 1 ; i <= N + 1; ++i) {
		val[++tot] = a[i];
		if(zz[a[i]]) ed = a[i];
	}
	sort(val + 1,val + tot + 1);
	tot = unique(val + 1,val + tot + 1) - val - 1;
	st = lower_bound(val + 1,val + tot + 1,st) - val;
	ed = lower_bound(val + 1,val + tot + 1,ed) - val;
	for(int i = 1 ; i <= tot ; ++i) {
		fa[i] = i;
	}
	for(int i = 1 ; i <= N ; ++i) {
		if(a[i] != b[i]) {
			int p = lower_bound(val + 1,val + tot + 1,a[i]) - val;
			int q = lower_bound(val + 1,val + tot + 1,b[i]) - val;
			++deg[p];++deg[q];
			fa[getfa(p)] = getfa(q);
			++cnt;
		}
	}
	++deg[st];++deg[ed];
	int p = 0;
	for(int i = 1 ; i <= tot ; ++i) {
		if(deg[i] & 1) ++p;
	}
	cnt += p / 2;
	for(int i = 1 ; i <= tot ; ++i) {
		if(deg[i]) {
			if(getfa(i) != getfa(st)) {
				fa[getfa(i)] = getfa(st);
				cnt++;
			}
		}
	}
	out(cnt);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Init();
	Solve();
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define int               long long
#define M                 1000000007
#define MM                998244353
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount

template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
template<typename T1,typename T2>std::istream& operator>>(std::istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>std::ostream& operator<<(std::ostream& out,pair<T1,T2> &a){out<<a.fr<<" "<<a.sc;return out;}

const int N=0;
int a[200],k,s;

int dp[200][4][2];

int calc(int i,int k,int f){
	if(k==0)return 1;
	if(i==s)return 0;
	int &ans=dp[i][k][f];
	if(ans!=-1)return ans;
	ans=0;
	if(f){
		ans+=calc(i+1,k,f);
		ans+=9*calc(i+1,k-1,f);
	}
	else{
		if(a[i]==0)ans=calc(i+1,k,0);
		else{
			ans+=calc(i+1,k,1);
			ans+=(a[i]-1)*calc(i+1,k-1,1);
			ans+=calc(i+1,k-1,0);
		}
	}
	return ans;
}

void solve(){
	mem1(dp);
	string n;
	cin>>n>>k;
	s=sz(n);
	rep(i,0,s){
		a[i]=n[i]-'0';
	}
	cout<<calc(0,k,0);
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	#ifdef DSU
		cleardsu(MAXDSUSIZE);
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

fn main() {
    input! {
        n:usize,
        s:[Chars;n],
    }

    let mut ans = 0;
    let mut st = 0;
    let mut ed = 0;
    let mut both = 0;
    for c in s.clone() {
        let n = c.len();
        if c[0] == 'B' && c[n - 1] == 'A' {
            both += 1;
        } else {
            if c[0] == 'B' {
                st += 1;
            }
            if c[n - 1] == 'A' {
                ed += 1;
            }
        }
        for i in 0..n - 1 {
            if c[i] == 'A' && c[i + 1] == 'B' {
                ans += 1;
            }
        }
    }
    ans += min(st, ed);
    if st == 0 && ed == 0 && both > 0 {
        ans += both - 1;
    } else {
        ans += both;
    }
    println!("{}", ans);
}


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

int main()
{
	bool cup[3] = { true, false, false };
	string p;

	while (cin >> p)
	{
		swap(cup[p[0] - 'A'], cup[p[2] - 'A']);
	}
	for (int i = 0; i < 3; i++)
	{
		if (cup[i]) cout << char(i + 'A') << endl;
	}

	return 0;
}

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

const int MAX_N = 200005;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
}c(200005);

int main() {
	int N, K;
	cin >> N >> K;
	int L = min(K, N);
	mint ans = 0;
	for (int n = 0; n <= L;++n) {
		ans += c(N, n) * c(N - 1, n);
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
	int zero=0,one=0;
	string S;
	cin >> S;
	for(int i=0;i<S.length();i++){
		if(i%2==0){
			if(S[i]=='1'){zero++;}
			else{one++;}
		}else{
			if(S[i]=='0'){zero++;}
			else{one++;}
		}
	}
	cout << min(zero,one) << endl;
	return 0;
}

Measured memory_bytes: 512
def is_right(i, j):
    H = None
    for h, x, y in XYH:
        if H is None:
            if h > 0:
                H = abs(x - i) + abs(y - j) + h
        else:
            if h != max(H - abs(x - i) - abs(y - j), 0):
                return -1
    return H


N = int(input())
XYH = []
for _ in range(N):
    x, y, h = map(int, input().split())
    XYH.append([h, x, y])
XYH.sort(reverse=True)

for i in range(101):
    for j in range(101):
        res = is_right(i, j)
        if res > 0:
            print(i, j, res)
            exit()


Measured memory_bytes: 41692
import itertools

S = input()[::-1]

m = [0]*len(S)
tmp = 1
for i in range(len(S)):
    m[i] = int(S[i])*tmp%2019
    tmp = tmp*10%2019

cum = [0]+[0]*len(S)
for i in range(1,len(S)+1):
    cum[i] = (cum[i-1]+m[i-1])%2019

d = {}
ans = 0
for i in range(len(cum)):
    if cum[i] not in d:
        d[cum[i]] = 1
    else:
        ans += d[cum[i]]
        d[cum[i]] += 1
print(ans)

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

int main(){
	int a,b,c,d,n;
	
	while(cin>>n){
	int count = 0;
	for(a = 0;a <= 9;a++){
		for(b = 0;b <= 9;b++){
			for(c = 0;c <= 9;c++){
				for(d = 0;d <= 9;d++){
				
				if(a+b+c+d == n)
					count++;
				}
			}
		}
	}
	
	cout<<count<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
n, m = map(int, input().split())
s = []
t = []
for i in range(n):
    s.append(list(map(int, input().split())))
for i in range(m):
    t.append(int(input()))
# print(s)
# print(t)
for i in s:
    ans = 0
    for j in range(m):
        ans += i[j] * t[j]
    print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int> arr;
  rep(i, n) {
    int a;
    cin >> a;
    arr.push_back(a);
  }
  ll m = 1000;

  for (int i = 1; i < n; i++) {
    if (arr[i] <= arr[i - 1]) continue;

    ll s = arr[i - 1];
    ll count = m / s;
    m += (arr[i] - s) * count;
  }

  cout << m << endl;

  return 0;
}


Measured memory_bytes: 3620
def main():
    from builtins import abs
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    dp = [0] * N
    for i in range(1, N):
        dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(0, i - K), i))
    print(dp[N - 1])


main()


Measured memory_bytes: 20668
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
using namespace std;
using ll = long long;
using graph = std::vector<std::vector<long long>>;
int main(){
    int N;
    cin >> N;
    int a[N];
    ll sum = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        sum += a[i];
    }
    sum = sum / 2;
    int x[N];
    ll tmpSum = 0;
    for(int i = 1; i < N; i+=2){
        tmpSum += a[i];
    }
    x[0] = sum - tmpSum;
    for(int i = 1; i < N; i++){
        x[i] = a[i - 1] - x[i - 1];
    }
    for(int i = 0; i < N; i++){
        cout << x[i] * 2 << endl;
    }
}

Measured memory_bytes: 2048
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int H, W, N;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W >> N;
    int x = max(H,W);
    cout << (N+x-1) / x << endl;
}

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

using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define ve vector
#define vi vector<int>
#define vi2 vector<vi>
#define vl vector<long long>
#define vl2 vector<vl>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

vector<int> mapping(100000);

int search(int a){
    queue<int> q;
    int nexta = a;
    while(mapping[nexta] != nexta){
        q.push(nexta);
        nexta = mapping[nexta];
    }
    while(!q.empty()){
        mapping[q.front()] = nexta;
        q.pop();
    }
    return nexta;
}

int main(){
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    mapping.resize(n+1);
    rep(i, m) cin >> a[i] >> b[i];
    mapping[0] = -1;
    rep1(i, n){
        mapping[i] = i;
    }
    rep(i, m){
        int a_moto = search(a[i]), b_moto = search(b[i]);
        if(mapping[a_moto] != mapping[b_moto]) mapping[b_moto] = a_moto;
    }
    int ans = -1;
    rep1(i, n){
        if(mapping[i] == i) ans++;
    }
    cout << ans << endl;
}
/*
int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n) cin >> a[i];

}*/

Measured memory_bytes: 4412
def prod(n, A):
    if 0 in A:
        return 0
    p = 1
    for a in A:
        if p * a <= 10**18:
            p *= a
        else:
            return -1
    return p

n = int(input())
A = [int(i) for i in input().split()]
print(prod(n, A))

Measured memory_bytes: 21484
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using  namespace std;
typedef long long ll;
struct Data {
  int a, b;
  Data(int a=0, int b=0) : a(a), b(b) {}
  bool operator < (const Data &p) const {
    return b != p.b ? b < p.b : a < p.a;
  }
};

int main() {
  int n;
  cin >> n;
  int a[n], b[n];
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  Data datas[n];
  rep(i, n) datas[i] = Data (a[i],b[i]);
  sort(a, a+n);
  sort(b, b+n);
  sort(datas, datas+n);
  int rowa[n];
  rep(i, n) rowa[i] = datas[i].a;
  
  bool flag = true;
  rep(i, n) {
    if (a[i] > b[i]) flag = false;
  }

  if (flag) {
    int cnt = 1;
    int num = rowa[distance(a, lower_bound(a, a+n, rowa[0]))];
    while (num != rowa[0]) {
      ++cnt;
      num = rowa[distance(a, lower_bound(a, a+n, num))];
    }
    if (cnt == n) {
      flag = false;
      rep(i, n-1) {
        if (a[i+1] <= b[i]) flag = true;
      }
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 2176
n = int(input())
a = input().split()
a = [int(i) for i in a]

odds = len([i for i in a if i % 2 == 1])
evens = len([i for i in a if i % 2 == 0])

if odds % 2 == 1:
  print('NO')
else:
  print('YES')

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

int main() {
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
        b.at(i) = k - a.at(i);
    }
    vector<int> d(n,0);
    for(int i = 0; i < n; i++){
        if(i == 0){
            d.at(i) = a.at(n-1) - a.at(0);
        }else{
            d.at(i) = b.at(i) + a.at(i-1);
        }
    }
    int ans = d.at(0);
    for(int i = 0; i < n; i++){
        if(ans > d.at(i)){
            ans = d.at(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2688
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

unsigned euclidean_gcd(unsigned a, unsigned b) {
    while (1) {
        if (a < b) swap(a, b);
        if (!b) break;
        a %= b;
    }
    return a;
}

int main(){
    int N;
    cin >> N;
    vint A(N);
    rep(i, N)
        cin >> A[i];
    int p1 = A[0];
    {
        int pivot = A[0];
        int min_p = INF;
        int min_idx;
        REP(i, 1, N) {
            int p = euclidean_gcd(A[i], pivot);
            if (p < min_p) {
                min_idx = i;
                min_p = p;
            }
        }
        
        REP(i, 1, N) {
            if (min_idx != i)
                p1 = euclidean_gcd(p1, A[i]);
        }
    }
    int p2 = A[N - 1];
    {
        int pivot = A[N - 1];
        int min_p = INF;
        int min_idx;
        REP(i, 0, N - 1) {
            int p = euclidean_gcd(A[i], pivot);
            if (p < min_p) {
                min_idx = i;
                min_p = p;
            }
        }
        
        REP(i, 0, N - 1) {
            if(min_idx != i)
                p2 = euclidean_gcd(p2, A[i]);
        }
    }
    cout << max(p1, p2) << endl;

    return 0;
}

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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)

#define X first
#define Y second

template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int N; cin >> N;
	V v(N); input(v);
	int sum = accumulate(all(v), 0);
	int M; cin >> M;
	int sa = 0;
	rep(i, M) {
		int p, x; cin >> p >> x;
		p--;
		cout << sum - (v[p] - x) << endl;
	}
	system("pause");
}

Measured memory_bytes: 504
#include <stdio.h>

int a_num,b_num;
int a_card[100],b_card[100];

int main(void) {
	int i,j;
	int r1,r2;
	int a_sum,b_sum;
	while(1) {
		scanf("%d%d",&a_num,&b_num);
		if(a_num==0 && b_num==0)break;
		for(i=0,a_sum=0;i<a_num;i++) {
			scanf("%d",&a_card[i]);
			a_sum+=a_card[i];
		}
		for(i=0,b_sum=0;i<b_num;i++) {
			scanf("%d",&b_card[i]);
			b_sum+=b_card[i];
		}
		r1=-1;r2=1000000;
		for(i=0;i<a_num;i++) {
			for(j=0;j<b_num;j++) {
				if(a_sum-a_card[i]+b_card[j]==b_sum-b_card[j]+a_card[i]) {
					if(a_card[i]+b_card[j]<r1+r2) {
						r1=a_card[i];
						r2=b_card[j];
					}
				}
			}
		}
		if(r1<0)puts("-1"); else printf("%d %d\n",r1,r2);
	}
	return 0;
}

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

//0??????,1?????????,2??????

const long long int INF = 1000000000;

int main() {

    int n,u,d;

    string s;

    long long int table[200][200];
    //map<int,int> data[100];

    for(int i=0; i<200; i++){
        for(int j=0; j<200; j++){
            table[i][j] = INF;
        }
    }

    for(int i=0;i<200;i++){
        table[i][i] = 0;
    }

    cin >> n;

    while(n--){
        cin >> u >> s >> d;
        u--;d--;

        if(s[0] == 'l'){
            table[d+100][u] = -100;
        }
        else{
            table[u][d+100] = -10;
        }
    }

    for(int k=0;k<200;k++){
        for(int i=0;i<200;i++){
            for(int j=0;j<200;j++){
                if(table[i][k] != INF && table[k][j] != INF)
                table[i][j] = min(table[i][j],table[i][k] + table[k][j]);
            }
        }
    }

    for(int i=0;i<200;i++){
        if(table[i][i] != 0){
            cout << "1" << endl;
            return 0;
        }
    }

    cout << "0" << endl;

    return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int x = tx - sx;
  int y = ty - sy;
  rep(i,y) cout << 'U';
  rep(i,x) cout << 'R';
  rep(i,y) cout << 'D';
  rep(i,x) cout << 'L';
  cout << 'L';
  rep(i,y+1) cout << 'U';
  rep(i,x+1) cout << 'R';
  cout << "DR";
  rep(i,y+1) cout << 'D';
  rep(i,x+1) cout << 'L';
  cout << 'U' << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long cnt[100005];

int main() {
    int h, w, n, x, y;
    map<int, map<int, int> > mp;
    scanf("%d %d %d",&h, &w, &n);
    cnt[0] = 1ll*(h-2)*(w-2);

    for(int i=0;i<n;++i) {
        scanf("%d %d",&x,&y);

        for(int j=-1;j<=1;++j) {
            for(int k=-1;k<=1;++k) {
                int a = x+j, b = y+k;
                if(a>=2 && b>=2 && a<h && b<w) {
                    int p = ++mp[a][b];
                    cnt[p]++;
                    cnt[p-1]--;
                }
            }
        }
    }

    for(int i=0;i<=9;++i) {
        printf("%lld\n", cnt[i]);
    }
    return 0;
}

Measured memory_bytes: 70528
import datetime
h1,m1,h2,m2,k = map(int,input().split())
end = datetime.datetime(2020,6,6,h2,m2)
start = datetime.datetime(2020,6,6,h1,m1)
#print(start,end)
sub = end-start-datetime.timedelta(minutes=k)
print(sub.seconds//60)

Measured memory_bytes: 9408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

const int MAX_N = 100005; // 要素数の最大

int par[MAX_N]; // 親
int rk[MAX_N];  // 木の深さ(rank)

// n要素で初期化
void init(int n)
{
    for (int i = 0; i < n; i++)
    {
        par[i] = i;
        rk[i] = 0;
    }
}

// 木の根を求める
int find(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
    {
        return;
    }

    if (rk[x] < rk[y])
    {
        par[x] = y;
    }
    else
    {
        par[y] = x;
        if (rk[x] == rk[y])
        {
            rk[x]++;
        }
    }
}

bool same(int x, int y)
{
    return find(x) == find(y);
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        --a[i];
        --b[i];
    }
    int ans = 0;
    for (int i = 0; i < m; i++)
    {
        init(n);
        for (int j = 0; j < m; j++)
        {
            if (i != j)
            {
                unite(a[j], b[j]);
            }
        }
        bool flag = true;
        for (int j = 1; j < n && flag; j++)
        {
            if (!same(0, j))
            {
                flag = false;
            }
        }
        if (!flag)
        {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

int main(){
  vector<char> str(19);
  for(int i = 0; i < 19; i++){
    cin >> str.at(i);
  }
  for(int i = 0; i < 5; i++){
    cout << str.at(i);
  }
  cout << " ";
  for(int i = 6; i < 13; i++){
    cout << str.at(i);
  }
  cout << " ";
  for(int i = 14; i < 19; i++){
    cout << str.at(i);
  }
  cout << endl;
  return 0;
}


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

// Runs range sum queries only.
// Sum : O(1)
template <class Abel>
class CumulativeSum
{
	std::vector<Abel> sums_;

  public:
	CumulativeSum(const std::vector<Abel> &data) : sums_(data)
	{
		sums_.insert(sums_.begin(), Abel(0));
		for (int i = 1; i < (int)sums_.size(); ++i)
		{
			sums_[i] += sums_[i - 1];
		}
	}

	// Gets the sum of data[0, right)
	Abel Sum(int right) { return sums_[right]; }

	// Gets the sum of data[left, right)
	Abel Sum(int left, int right) { return Sum(right) - Sum(left); }
};

int main()
{
	int n, k;
	std::cin >> n >> k;
	std::string s;
	std::cin >> s;
	char pre = '1';
	std::vector<int> L(1, 0);
	L.reserve(n);
	for (int i = 0; i < (int)s.length(); ++i)
	{
		if (s[i] == pre)
		{
			L.back()++;
		}
		else
		{
			L.push_back(1);
			pre = s[i];
		}
	}
	CumulativeSum<int> L_sum(L);
	int ans = 0;
	const int L_Size = L.size();
	for (int i = 0; i < L_Size; i += 2)
	{
		ans = std::max(ans, L_sum.Sum(i, std::min(i + 2 * k + 1, L_Size)));
	}
	std::cout << ans;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

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

    int n;
    cin >> n;

    int arrayn[n];
    int a[3] = {0};
    for(int i=0; i<n; i++)
    {
        cin >> arrayn[i];
        if(arrayn[i]%2 == 1) a[0]++;
        else if(arrayn[i]%4 == 0) a[2]++;
        else a[1]++;
    }

    if(a[2] >= a[0] || (a[2] == a[0]-1 && a[1] == 0)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640