akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

#define int long long
#define double long double

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e17 + 9;

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

	int n;
	cin >> n;

	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		mp[a]++;
	}
		
	int ans = n;
	int cnt = 0;
	each(i, mp) {
		if (i.second >= 2 && i.second % 2 == 0) {
			cnt++;
			i.second--; ans--;
		}
	}
	if (cnt % 2) {
		ans--;
	}
	each(i, mp) {
		if (i.second >= 2 && i.second % 2 == 1) {
			ans -= (i.second - 1); i.second = 1;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n, r;
  cin >> n >> r;
  if (n >= 10) {
    cout << r << endl;
  } else {
    cout << r + 100 * (10 - n) << endl;
  }
}


Measured memory_bytes: 256
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    N, K = get_ln_int_inputs()
    l = get_ln_int_inputs()

    print(sum(sorted(l)[::-1][:K]))


main()

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

int main()
{
    ll n; cin >> n;
    ll sqr = ceil(sqrt(n));
    while(sqr > 0 && n%sqr != 0)  sqr--;
    cout << n/sqr + sqr - 2 << endl;
    return 0;
}

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

using namespace std;

int main()
{
    stack<char> out;
    long long int n;
    cin>>n;
    while(n)
    {
        --n;
        out.push('a'+n%26);
        n/=26;//number of alphabet letters i.e base
    }
    while(!out.empty()){
        cout<<out.top();
        out.pop();
    }
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	int n;
	cin>>n;
	cout<<n*n*n<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#define ll long long
using namespace std;
const int maxn=500010, inf=1e9;
struct poi{int w;};
int n, K, Q, N;
int a[maxn], b[maxn];
vector<int>pos[maxn], v;
priority_queue<poi>q1, q2;
bool operator < (poi a, poi b){return a.w>b.w;}

template<typename T>
inline void read(T &k)
{
	int f=1; k=0; char c=getchar();
	while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
	while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
	k*=f;	
}
 
int main()
{
//	freopen("1.in", "r", stdin);
	read(n); read(K); read(Q);
	for(int i=1;i<=n;i++) read(a[i]), b[i]=a[i]; N=n;
	sort(b+1, b+1+N); N=unique(b+1, b+1+N)-b-1;
	for(int i=1;i<=n;i++) a[i]=lower_bound(b+1, b+1+N, a[i])-b, pos[a[i]].push_back(i);
	v.push_back(0); v.push_back(n+1);
	int ans=inf;
	for(int i=0;i<=N;i++)
	{
		for(int j=0;j<pos[i].size();j++) v.push_back(pos[i][j]);
//		for(int j=0;j<v.size();j++) printf("%d ", v[j]); puts("v");
		sort(v.begin(), v.end());
		for(int j=0;j<v.size()-1;j++)
		{
			for(int k=v[j]+1;k<v[j+1];k++) q1.push((poi){a[k]});
			for(int k=1;k<=v[j+1]-v[j]-1-(K-1);k++) q2.push((poi){q1.top().w}), q1.pop();
			while(!q1.empty()) q1.pop();
		}
		if(q2.size()<Q) break;
		int tmp1=q2.top().w;
		for(int j=1;j<Q;j++) q2.pop();
		int tmp2=q2.top().w;
		ans=min(ans, b[tmp2]-b[tmp1]);
//		printf("%d %d\n", i, ans);
		while(!q2.empty()) q2.pop();
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 14720
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://tenka1-2017.contest.atcoder.jp/tasks/tenka1_2017_c>
問題文============================================================
 整数 N が与えられる。
 
 4⁄N=1⁄h+1⁄n+1⁄w を満たす正整数 h,n,w を求めよ。
 
 条件を満たす解が複数ある場合、どれを出力しても良い。
 
 制約
 N に対して h,n,w≤3500 となる解が存在することが保証される。

 
=================================================================

解説=============================================================

 4/N = 1/h + 1/n + 1/w
 x4hnwN
 4hnw = nwN + whN + hnN
 移行
 4hn*w - nN*w - hN*w = hnN
 wについてまとめる
 (4hn - nN - hN)*w = hnN
 よって、 h,nを決めうちした時, w を推測できる。
 
 制約より O(3500^2)
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    for(int i = 1; i <= 3500;i++){
        for(int j = 1;j<=3500; j++){
            ll X = 4*i*j - i*N - j*N;
            ll Y = i*j*N;
            if(X <= 0) continue;
            if(Y%X == 0){
                cout << i << " " << j << " " << Y/X << endl;
                return 0;
            }
        }
    }
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string x,y;
  cin>>x>>y;
  cout<<(x<y?"<":(x>y?">":"="))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <list>
#include <set>

using namespace std;

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

int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	
	list<int> lis;
	REP(i, N) lis.push_back(i);
	
	list<int>::iterator itr = lis.begin();
	
	REP(i, M) {
		int a;
		scanf("%d", &a);
		
		bool d = a & 1;
		REP(j, a) {
			if (d) {
				if (itr == lis.begin()) itr = lis.end();
				itr--;
			}
			else {
				itr++;
				if (itr == lis.end()) itr = lis.begin();
			}
		}
		
		itr = lis.erase(itr);
		if (itr == lis.end()) itr = lis.begin();
	}
	
	set<int> s;
	for (itr = lis.begin(); itr != lis.end(); itr++) {
		s.insert(*itr);
	}
	
	REP(i, Q) {
		int q;
		scanf("%d", &q);
		if (s.find(q) != s.end()) puts("1");
		else puts("0");
	}
	return 0;
}

Measured memory_bytes: 7448
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long int n,d;
	cin>>n>>d;
	int i,j,k,x[n][d],z,b=0;
	double y[n][d],s;
	for(i=0;i<n;i++)
	{
		for(j=0;j<d;j++)
		{
			cin>>x[i][j];	
		}	
	}	
	for(i=0;i<n;i++)
	{
		for(k=i+1;k<n;k++)
		{
			z=0;
			s=0;
			for(j=0;j<d;j++)
			{
				y[i][j]=x[i][j]-x[k][j];
				y[i][j]=y[i][j]*y[i][j];
				s=s+y[i][j];
			}
			z=sqrt(s);
			s=sqrt(s);
			
			if(s==z)
			{
				b++;
			}
		}		
	}
	cout<<b<<endl;
	
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long t = sc.nextLong();
    long a = sc.nextLong();
    long k = sc.nextLong();
    if (k >= t + a) {
      System.out.println("0 0");
      return;
    }
    String tRest;
    String kRest;
    if (t >= k) {
      tRest = Long.toString(t - k);
      kRest = Long.toString(a);
      System.out.println(tRest + " " + kRest);
    } else if (k - t > a) {
      System.out.println("0 0");
    } else if (a >= k - t) {
      kRest = Long.toString(a - (k - t));
      System.out.println("0 " + kRest);
    }
  }
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf=1000000007;

ll stair(ll a)
{
  if(a==1) return 1;
  else return a*stair(a-1)%inf;
}

int main()
{
  int n,m;
  cin>>n>>m;
  ll ans;

  if(n==m)
  {
    ans=2*stair(n)*stair(n)%inf;
  }
  else if(m-n==1 || n-m==1)
  {
    ans=stair(n)*stair(m)%inf;
  }
  else ans=0;

  cout<<ans<<endl;
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

manzoku = 0

for i in range(n):
    eat = a[i] - 1
    manzoku = manzoku + b[eat]
    if i >= 1:
        if a[i] - a[i - 1] == 1:
            manzoku = manzoku + c[a[i - 1] - 1]

print(manzoku)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
	int i,n,loan = 100000;
	while (1){
		scanf("%d", &n);
		if (0 <= n&&n <= 100)
			break;
	}
	for (i = 0; i < n; i++){
		loan *= 1.05;
		if (loan % 1000 != 0){
			loan -= loan % 1000;
			loan += 1000;
		}
	}
	printf("%d\n", loan);
	return 0;
}

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

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

  vector<int64_t> array(N+1);
  array.at(0) = 2;
  array.at(1) = 1;

  for(int i = 2; i < N + 1; i++){
    array.at(i) = array.at(i-1) + array.at(i-2);
  }
  
  cout << array.at(N) << endl;

}

Measured memory_bytes: 256
import java.util.*;

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

        System.out.println(Math.min(n*a, b));
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")



int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N+1);
	vector<ll> S(N + 1);
	REP(i, 1, N+1) cin >> A[i];
	S[0] = 0;
	REP(i, 0, N)S[i + 1] = S[i] + A[i+1];
	unordered_map<ll, int> mp;
	ll ans = 0;
	mp[0] = 1;
	REP(j, 1, N+1) {
		ll x = (S[j] - j) % K;
		if (j >= K) mp[(S[j - K] - (j - K)) % K]--;
		ans += (mp.count(x) > 0) ? mp[x] : 0;
		mp[x]++;
	}
	PRI(ans);
	return 0;
}




Measured memory_bytes: 14480
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <unordered_set>
using namespace std;

int main(void){
    int A[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> A[i][j];
        }
    }
    int N, b;
    cin >> N;
    for(int n = 0; n < N; n++){
        cin >> b;
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(A[i][j] == b) A[i][j] = 0;
            }
        }
    }
    string ans = "No";
    for(int i = 0; i < 3; i++){
        if(A[i][0]==0 && A[i][1]==0 && A[i][2]==0){
            ans = "Yes";
        }
        if(A[0][i]==0 && A[1][i]==0 && A[2][i]==0){
            ans = "Yes";
        }
    }
    if(A[0][0]==0 && A[1][1]==0 && A[2][2]==0){
        ans= "Yes";
    }
    if(A[0][2]==0 && A[1][1]==0 && A[2][0]==0){
        ans = "Yes";
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl

int main() {
    cout << fixed << setprecision(15);
    int s = 15;
    REP (i, 5) {
        int a; cin >> a;
        s -= a;
    }
    cout << s << endl;
}

Measured memory_bytes: 3544
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Wed Jan  9 20:56:28 2019
//
package main

import (
	"fmt"
	"sort"
)

func max(slice ...int) int {
	sort.Ints(slice)
	return slice[len(slice)-1]
}

func min(slice ...int) int {
	sort.Ints(slice)
	return slice[0]
}

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)
	fmt.Println(max(0, min(B, D)-max(A, C)))
}


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

const int N = 1e5+5;
int n, a[N], b[N];
long long ans = 0;
int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
//  freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
  cin >> n;
  for(int i = 0; i < n + 1; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) cin >> b[i];
  for(int i = 0; i < n; ++i){
    int x = min(a[i], b[i]);
    ans += x;
    a[i] -= x;
    b[i] -= x;
    x = min(a[i + 1], b[i]);
    ans += x;
    a[i + 1] -= x;
    b[i] -= x;
  }cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    vector<int> a(N);
    rep(i, N)
    {
        cin >> a[i];
    }

    sort(ALL(a));
    reverse(ALL(a));

    int sum = accumulate(ALL(a), 0);

    cout << (a[M - 1] >= sum / double(4.0 * M) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<string> vstr;
typedef long long int llint;



int main(void) {
	llint N,ocou,zcou,ans;
	ocou = 0;
	zcou = 0;
	string S;
	cin >> S;
	N = S.length();

	for (int i = 0; i < N; i++){
		if (S[i] == '0')zcou++;
		else ocou++;
	}
	ans = min(zcou, ocou);
	cout << 2 * ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 4050
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int n,m;
    cin>>n>>m;
    ll sum=0;
    REP(i,m){
        int a;
        cin>>a;
        sum+=a;
    }
    OUT(max(n-sum,(ll)-1));
    return 0;
}

Measured memory_bytes: 3624
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    sp=[]
    for i in range(n):
        s,p=STRM()
        sp.append([s,int(p),i+1])
    sorted_sp1=sorted(sp, key=lambda x:x[1], reverse=True)
    sorted_sp2=sorted(sorted_sp1, key=lambda x:x[0])
    for i in range(n):
        print(sorted_sp2[i][2])
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int f(int a,int b){
    if(b == 0) return -a;
    return a;
}
char h(int a){
    if(a == 0) return '-';
    else return '+';
} 

int main(void){
    int i,j,k,n,a[4],op[4][2] = {};
    int sum = 0,x,y,z;
    char op1,op2,op3;
    cin >> n;
    for( i=0;i<4;i++){
        a[3-i] = n % 10;
        n = n / 10;
    }
    
    for(i=1;i<4;i++){
        op[i][0] = 1;
    }
    
    for(i=0;i<2;i++){
        for(j=0;j<2;j++){
            for(k=0;k<2;k++){
                sum = 0;
                x = 0;
                y = 0;
                z = 0;
                x = f(a[1],op[1][i]);
                y = f(a[2],op[2][j]);
                z = f(a[3],op[3][k]);
                sum = a[0] + x + y + z;
                if(sum == 7) {
                    op1 =  h(op[1][i]);
                    op2 =  h(op[2][j]);
                    op3 =  h(op[3][k]);
                    break;
                }
            }if(sum == 7)break;}if(sum == 7) break;}
    
    cout << a[0] << op1 << a[1] << op2 << a[2] << op3 << a[3] << "=7" <<endl;
    
    return 0;
}
   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
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;}
 
int main(){
  ll int p,q,r;
  cin >> p >> q >> r;
  cout << min(min(p+q, p+r), q+r) << endl;
}

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

   int main() {
   double x1,y1,x2,y2;
   cin>>x1>>y1>>x2>>y2;
   cout << fixed << setprecision(5);
   cout<<sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))<<endl;;
   return 0;
   }


Measured memory_bytes: 3288
import java.util.Scanner;

public class Main {

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

        long ans = 0;
        if (n == 1) ans = 0;
        else {
            for (long i = 1; i < n; i++) {
                ans += i;
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
	int A[5][4][11], n;
	
	//三次元配列初期化
	for (int i = 1; i <= 4; i++) {
		for (int j = 1; j <= 3; j++) {
			for (int k = 1; k <= 10; k++) {
				A[i][j][k] = 0;
			}
		}
	}

	//部屋にいる人数を入力
	cin >> n;
	for (int i = 0; i < n; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		A[b][f][r] += v;
	}
	
	for (int b = 1; b <= 4; b++) {
		if ( b > 1) cout << "####################" << endl;
		for (int f = 1; f <= 3; f++) {
			for (int r = 1; r <= 10; r++) {
				cout << " " << A[b][f][r];
			}
		cout << endl;
		}
	}

	return 0;
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#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)



int main(void){

	string S; cin >> S;
	int win = 0, lose = 0;
	REP(i,S.length()){
		if(S[i] == 'o') win++;
		else lose++;
	}
	win += 15-S.length();
	
	if(win >= 8) cout << "YES" << endl;
	else cout << "NO" << endl;


	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP1(i,n) for(ll i=1;i<=(ll)(n);i++)

int main() {
	ll n;
    cin >> n;
    ll sum = 0;

    REP1(i,n){
        if( i%3 == 0 || i%5 == 0){
            
        } else{
            sum += i;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3644
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int[] h = new int[N];
        for (int i=0; i<N; i++) {
            h[i] = Integer.parseInt(scanner.next());
        }
        int[] dp = new int[N];
        dp[0] = 0;
        dp[1] = Math.abs(h[1]-h[0]);
        int a = 0;
        int b = 0;
        for (int i=2; i<N; i++) {
            dp[i] = Math.min(dp[i-2] + Math.abs(h[i]-h[i-2]), dp[i-1] + Math.abs(h[i]-h[i-1]));
        }
        System.out.println(dp[N-1]);
    } 
}

Measured memory_bytes: 48860
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

class DisjointSet {
   private:
    vector<int> rank, parent;

   public:
    DisjointSet() {}
    DisjointSet(int size) {
        rank.resize(size, 0);
        parent.resize(size, 0);
        rep(i, size) { makeSet(i); }
    }

    void makeSet(int x) {
        parent[x] = x;
        rank[x] = 0;
    }

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

    void unite(int x, int y) { link(findSet(x), findSet(y)); }

    void link(int x, int y) {
        if (x == y) {
            return;
        }
        if (rank[x] > rank[y]) {
            parent[y] = x;
        } else {
            parent[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }
    int findSet(int x) {
        if (x != parent[x]) {
            parent[x] = findSet(parent[x]);
        }
        return parent[x];
    }
};
int n;

int main() {
    cin >> n;
    DisjointSet ds(n);
    vector<pair<int, int>> vx, vy;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        vx.push_back(make_pair(x, i));
        vy.push_back(make_pair(y, i));
    }
    sort(all(vx));
    sort(all(vy));
    vector<pair<int, pair<int, int>>> edge;
    rep(i, n) {
        rep2(j, i + 1, min(i + 10, n)) {
            edge.push_back(make_pair(vx[j].first - vx[i].first, make_pair(vx[i].second, vx[j].second)));
            edge.push_back(make_pair(vy[j].first - vy[i].first, make_pair(vy[i].second, vy[j].second)));
        }
    }
    ll ans = 0;
    int cnt = 0;
    sort(all(edge));
    for (auto &e : edge) {
        if (!ds.same(e.second.first, e.second.second)) {
            ds.unite(e.second.first, e.second.second);
            ans += e.first;
            cnt++;
            if (cnt == n - 1)
                break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 30896
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
    double r;
    cin >> r;
    double pi = M_PI; 
    //cout << fixed << setprecision(6) << 1.0*r*r*pi << " " << fixed << setprecision(6) << 2.0*r*pi << endl; //coutで書くならこっち
    //cout << 1.0*r*r*pi << " " << 2.0*r*pi << endl; //これだとエラー
    printf("%5f %5f", 1.0*r*r*pi,  2.0*r*pi);
    return 0;
}



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

typedef double lf;
const lf pai = 3.141592653589793238462643383279;
class point{
public:
  lf x, y;
  point(){}
  point(lf X, lf Y){x = X; y = Y;}
};

point operator + (point x, point y){return point(x.x + y.x, x.y + y.y);}
point operator - (point x, point y){return point(x.x - y.x, x.y - y.y);}
point operator * (point x, lf y){return point(x.x * y, x.y * y);}
point operator * (lf x, point y){return point(x * y.x, x * y.y);}

lf dot(point a, point b){return a.x * b.x + a.y * b.y;}
lf det(point a, point b){return a.x * b.y - a.y * b.x;}
lf len2(point a){return a.x * a.x + a.y * a.y;}
lf len(point a){return sqrt(a.x * a.x + a.y * a.y);}
lf sqr(lf x){return x * x;}

class circle{
public:
  point a; lf r;
  circle(){}
  circle(point A, lf R){a = A; r = R;}
};

void MOD(lf &x){while (x > pai) x -= (pai + pai); while (x < -pai) x += (pai + pai);}
int cross(circle a, circle b, lf &r1, lf &r2){
  lf D = len2(a.a - b.a);
  if (D > sqr(a.r + b.r)) return 0;
  else if (D < sqr(a.r - b.r)) return 0;
  lf t1 = atan2(b.a.y - a.a.y, b.a.x - a.a.x);
  lf t2 = acos((D + sqr(a.r) - sqr(b.r)) / (2 * sqrt(D) * a.r));
  r1 = t1 - t2; r2 = t1 + t2; MOD(r1); MOD(r2);
  return 1;
}

point P[2333];
int n, M;

pair <lf, int> d[2333];
int l;
void add(lf L, lf R){d[++l] = make_pair(L, 1); d[++l] = make_pair(R, -1);}
bool check(int p, lf r){
  int i, j; lf _l, _r;
  circle cb(P[p], r);
  l = 0;
  for (i = 1; i <= n; i++)
    if (i != p){
      circle cr(P[i], r);
      if (cross(cb, cr, _l, _r)){
    if (_l > _r) add(_l, pai), add(-pai, _r);
    else add(_l, _r);
      }
    }
  sort(d + 1, d + l + 1);
  j = 0;
  for (i = 1; i <= l; i++){
    j += d[i].second; if (j >= M - 1) return 1;
  }
  return 0;
}

#define m (l + r) / 2
int p[2333];
int main(){
  int i, j;
  lf ans = 1e10, l, r;
  scanf("%d", &n);M=n;
  for (i = 1; i <= n; i++) scanf("%lf %lf", &P[i].x, &P[i].y), p[i] = i;
  random_shuffle(p + 1, p + n + 1);
  for (i = 1; i <= n; i++)
    if (check(p[i], ans)){
      for (l = 0, r = ans; r - l > 1e-6; )
    if (check(p[i], m)) r = m; else l = m;
      ans = r;
    }
  printf("%.6lf", ans);
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int n,i,a[1000],s[1000],d[1000],f[10000],g,h,j,k,w[1000],flg;
	while(1){
	scanf("%d",&n);
	if(n==0) break;
	for(i=0;i<n;i++){
	scanf("%d %d %d %d",&a[i],&s[i],&d[i],&f[i]);
	w[i]=4*s[i]+9*d[i]+4*f[i];
	}
	scanf("%d %d %d %d",&g,&h,&j,&k);
		flg=0;
	for(i=0;i<n;i++){
	if(s[i]<=g&&d[i]<=h&&f[i]<=j&&w[i]<=k){
		printf("%d\n",a[i]);
		flg=1;
		}
	}
	if(flg==0){
		printf("NA\n");
		}
	}
return 0;
}

Measured memory_bytes: 1064
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
using namespace std;

typedef long long ll;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N), S(N+1);
    S[0] = 0;
    map<ll, ll> map;
    map[0] = 1;
    ll ans = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        S[i+1] = S[i]+A[i];
        if(map.count(S[i+1]%M)){
            map[S[i+1]%M] += 1;
        } else {
            map[S[i+1]%M] = 1;
        }
    }
    
    for(auto key: map){
        //cout << key.first << " " << map[key.first] << endl;
        ans += key.second*(key.second-1)/2;
    }
    cout << ans << endl;
}

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

int main(){
	double x;
	while(scanf("%lf",&x) == 1){
		double ans = x;
		for(int i = 0; i < 9; i++){
			if(i % 2 == 0){
				x *= 2;
			}
			else{
				x /= 3;
			}
			ans += x;
		}
		printf("%.8f\n",ans);
	}
	return 0;
}



Measured memory_bytes: 3200
#include <iostream>
#include <stdio.h>
#include <string>
#include <list>
#include <vector>
#include <algorithm>

#define rep(i,n) for(ll i = 0;i < n;i++)
#define REP(i,n,k) for(ll i = n;i < k;i++)
#define P(p) cout << (p) << endl;//print
typedef long long ll;
using namespace std;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int a,b;
    cin >> a >> b;
    cout << (a+b+1)/2 << endl;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  long double X, Y;
  cin >> X >> Y;
  long double x, y;
  cin >> x >> y;
  cout << X * Y / 2 << " ";

  if(x == X/2 && y == Y/2){
    cout << 1 <<endl;
  } else{
    cout << 0 <<endl;
  }
}


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

using namespace std;

int main()
{
	int x,n,t;
	cin>>x>>n;
	unordered_set<int> arr;
	for(int i=0;i<n;i++)
	{
		cin>>t;
		arr.insert(t);
	}
	//sort(arr.begin(),arr.end());
	auto itr=arr.find(x);
	if(itr==arr.end())
	{
		cout<<x<<endl;
		return 0;
	}
	else
	{
		int flag=0;
		for(int i=x-1,j=x+1;flag==0;i--,j++)
		{
			auto itri=arr.find(i);
			auto itrj=arr.find(j);
			if(itri==arr.end())
			{
				cout<<i<<endl;
				flag=1;
			}
			else if(itrj==arr.end())
			{
				cout<<j<<endl;
				flag=1;
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////


int main(){
    ll h,w;cin>>h>>w;
    ll a[h+1],b[w+1];
    rep(i,0,h-1)cin>>a[i];
    rep(j,0,w-1)cin>>b[j];
    sort(a,a+h);reverse(a,a+h);a[h]=-1;
    sort(b,b+w);reverse(b,b+w);b[w]=-1;
    rep(i,0,h-2){
        if(a[i]==a[i+1]){
            cout<<0;return 0;
        }
    }
    rep(i,0,w-2){
        if(b[i]==b[i+1]){
            cout<<0;return 0;
        }
    }
    ll n=h*w;
    ll posh=0,posw=0;
    ll ans=1;
    for(ll i=n;i>=1;i--){
        if(a[posh]==i&&b[posw]==i){
            posh++;posw++;
        }else if(a[posh]==i){
            ans=mod(ans*posw);
            posh++;
        }else if(b[posw]==i){
            ans=mod(ans*posh);
            posw++;
        }else{
            ll res=posw*posh-(n-i);
            if(res<=0){
                cout<<0<<endl;return 0;
            }
            ans=mod(ans*res);
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <complex>
#include <cstring>
#include <set>
using namespace std;
#define loop(i,a,b) for(int i=a; i<b; i++)
#define rep(i,a) loop(i,0,a)

int input[1111][3];
int res[1111];

int main(){
    int a,b,c;
    while(cin>>a>>b>>c && a){
        int n;
        cin>>n;
        rep(i,n){
            rep(j,3){
                cin >> input[i][j];
            }
            cin>>res[i];
        }

        bool ok[1111]={};
        bool bad[1111]={};
        while(1){
            bool fine = true;
            rep(i,n){
                int a=0,b=0;
                int x,y,z;
                tie(x,y,z)=tie(input[i][0],input[i][1],input[i][2]);
                for(int j : {x,y,z}){
                    if(ok[j])a++;
                    if(bad[j])b++;
                }
                if(res[i]){
                    if(a!=3){
                        ok[x]=ok[y]=ok[z]=true;
                        fine = false;
                    }
                }else{
                    if(a==2 && b!=1){
                        for(int j : {x,y,z}){
                            if(!ok[j])bad[j]=true;
                            fine = false;
                        }
                    }
                }
            }
            if(fine) break;
        }
        for(int i=1;i<=a+b+c;i++){
            if(ok[i] && !bad[i])cout<<1;
            else if(!ok[i] && bad[i])cout<<0;
            else cout<<2;
            cout<<endl;
        }
    }
}

Measured memory_bytes: 1180
/*input
7 4
*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>*/
using namespace std;
/*using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;*/
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long ll;
typedef long double ld;
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=1e5+5;
const ll maxlg=__lg(maxn)+2;
void solve(){ 
    ll n,k;
    cin>>n>>k;
    cout<<min(n%k,abs(k-n%k));
}
int32_t main(){
    int t=1;
    //cin>>t;
    REP1(i,t){
       //printf("Case #%d: ",i);
        solve();
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n,m;

int main(){
	cin>>n>>m;
	cout<<min(n%m,m-n%m)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	int n, a[110], count = 0;
	cin >> n;
	rep(i,n) {
		cin >> a[i];
	}
	rep(i,n) {
		int Min = i;
		rep2(j,i,n) {
			if(a[j] < a[Min]) {
				Min = j;
			}
		}
		if(i != Min) {
			swap(a[i],a[Min]);
			count++;
		}
	}
	rep(i,n) {
		cout << a[i];
		if(i < n - 1) cout << " ";
	}
	cout << endl;
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
      Scanner sc =new Scanner(System.in);
      int A = sc.nextInt();
	  int B = sc.nextInt();
      if(A * B % 2 == 1) {
        System.out.print("Yes");
      } else {
        System.out.print("No");
      }
    }
}

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

int n;
int a[100005];
int l[100005], r[100005];

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

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];

  for (int i = 1; i <= n; i++) l[i] = gcd(l[i - 1], a[i]);
  for (int i = n; i >= 1; i--) r[i] = gcd(r[i + 1], a[i]);

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, gcd(l[i - 1], r[i + 1]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
import math
import sys
import os

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


N = I()
D = [LI() for _ in range(N)]

count = 0
for i in range(N):
    if D[i][0]==D[i][1]:
        count +=1
    else:
        count = 0
    if count == 3:
        print('Yes')
        exit()
ans = 'No'

print(ans)

Measured memory_bytes: 9224
_ = gets.to_i
as = gets.split(" ").map(&:to_i)

hoge = []
as.each_with_index do |a,i|
  hoge << a - (i+1)
end
hoge.sort!


if hoge.size.odd?
  b = hoge[hoge.size/2]
else
  i = hoge.size/2
  b = (hoge[i-1] + hoge[i]) / 2
end

ans = 0
as.each_with_index do |a,i|
  ans += (a - (b+i+1)).abs
end

puts ans

Measured memory_bytes: 19896
flag = true
while flag
  a, op, b = gets.split
  a, b = [a, b].map(&:to_i)
  case op
  when "+"
    puts a + b
  when "-"
    puts a - b
  when "*"
    puts a * b
  when "/"
    puts a / b
  when "?"
    flag = false
  end
end


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

int main()
{
	int h, w; cin >> h >> w;
	
	vector<vector<char>> c(h + 2, vector<char>(w + 2));
	vector<vector<char>> d(h + 2, vector<char>(w + 2));

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> c[i][j];
			d[i][j] = c[i][j];
		}
	}

	vector<int> dh(8), dw(8);
	dh = { 1, 0,-1, 0, 1,-1, 1,-1 };
	dw = { 0, 1, 0,-1, 1,-1,-1, 1 };

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			int cnt = 0;
			for (int k = 0; k < 8; k++) {
				if (c[i + dh[k]][j + dw[k]] == '#') cnt++;				
			}
			if (c[i][j]=='.') d[i][j] = (char)(cnt + '0');
		}
	}

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cout << d[i][j];
		}
		cout << endl;
	}
		
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n;
  cin>>n;
  priority_queue<P,vector<P>,greater<P>> unused;
  queue<int> after;
  bool used[505];
  for(int i=0;i<=n;i++) used[i]=false;
  int array[505]={0};
  vector<int> ans(n*n+1,0);
  for(int i=1;i<=n;i++){
    int ps;
    cin>>ps;
    for(int j=1;j<i;j++) {
      unused.push(P(ps,i));
    }
    array[ps]=i;
    ans[ps]=i;
  }
  for(int i=1;i<=n*n;i++){
    if(ans[i]!=0){
      used[ans[i]]=true;
      for(int j=ans[i]+1;j<=n;j++) after.push(ans[i]);
      continue;
    }
    if(!unused.empty()){
      P p=unused.top();
      unused.pop();
      int tp=p.second;
      if(used[tp]){
        cout<<"No"<<endl;
        return 0;
      }
      ans[i]=tp;
    }
    else{
      if(after.empty()){
        cout<<"No"<<endl;
        return 0;
      }
      ans[i]=after.front();
      after.pop();
    }
  }
  if(!unused.empty()||!after.empty()){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  for(int i=1;i<=n*n;i++) cout<<ans[i]<<(i==n*n?"\n":" ");
}


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

int main() {
    string card[3];
    for(int i=0; i<3; ++i) {
        cin >> card[i];
    }
    int cnt[3] = {0, -1, -1};
    int turn = 0;
    while(cnt[turn] < card[turn].size()) {
        turn = card[turn][cnt[turn]] - 'a';
        cnt[turn] += 1;
    }
    if(turn == 0) {
        cout << "A" << endl;
    } else if(turn == 1) {
        cout << "B" << endl;
    } else {
        cout << "C" << endl;
    }
}


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

int n;
char event[16];
int out;
int base[4];

int main(void)
{
	int n;
	
	scanf("%d", &n);
	while (n > 0){
		scanf("%s", event);
		if (strcmp(event, "HIT") == 0){
			base[3] += base[2];
			base[2] = base[1];
			base[1] = base[0];
			base[0] = 1;
		}
		if (strcmp(event, "HOMERUN") == 0){
			base[3] += base[0] + base[1] + base[2] + 1;
			base[0] = base[1] = base[2] = 0;
		}
		if (strcmp(event, "OUT") == 0){
			out++;
			if (out == 3){
				n--;
				printf("%d\n", base[3]);
				base[0] = base[1] = base[2] = base[3] = 0;
				out = 0;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int n,k;
    cin>>n>>k;
    int i,a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    long int sum=0;
    i=0;
    while(k--)
    {
        sum+=a[i++];
    }
    cout<<sum;
}

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

int main(){
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    cout << 60 * H2 + M2 - 60 * H1 - M1 - K << endl;
    return 0;
}

Measured memory_bytes: 3620
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

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

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;



void solve()
{
	ll n;cin>>n;
	string s;cin>>s;

	ll i,cnt=0;
	rep(i,n-2)
	{
		string ss=s.substr(i,3);
		if(ss=="ABC")
			cnt++;
	}
	cout<<cnt;
}

int main()
{
	//fio();
	fast
	ll t=1;
	//cin>>t;

	while(t--){
		solve();
	}
	return 0;
}

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

namespace ABC130_1
{
    class A
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (a[0] < a[1]) Console.WriteLine(0);
            else Console.WriteLine(10);
        }
    }
}


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

using namespace std;
#define lint long long
#define P pair<int, int>

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    
    int B[M];
    
    int A[N][M];
    
    for(int i = 0; i < M; ++i){
        cin >> B[i];
    }
    
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < M; ++j){
            cin >> A[i][j];
        }
    }
    
    int ans = 0;
    for(int i = 0; i < N; ++i){
        lint num = C;
        
        for(int j = 0; j < M; ++j){
            num += (lint)A[i][j] * B[j];
        }
        if(num > 0){
            ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256