akhauriyash/Code-Regression huggingface dataset:
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/20/2019 2:11:28 AM
*************************************************************************/
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
#define ull unsigned long long
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#define lowbit(x) x&(-x)
#define ls(u) u<<1
#define rs(u) u<<1|1
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const double clf = 1e-8;
const int MMAX = 0x7fffffff;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
ostream& operator <<(ostream &out, pii &p){
	return out<<p.first<<" "<<p.second;
}
istream& operator >>(istream &in, pii &p){
	return in>>p.first>>p.second;
}
int a[20];
int x[20][20],y[20][20];
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//ifstream cin("C:\\Users\\LENOVO\\Desktop\\in.txt");
	//ofstream cout("C:\\Users\\LENOVO\\Desktop\\out.txt");
	int n;cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		for(int j=1;j<=a[i];j++) cin>>x[i][j]>>y[i][j];
	}
	int res=0;
	for(int state=0;state<(1<<n);state++){
		bool flag=true;
		for(int i=0;i<n;i++){
			if(state&(1<<i)){
				for(int j=1;j<=a[i];j++){
					if(y[i][j]&&!(1<<(x[i][j]-1)&state)){
						flag=false;
						break;
					}
					if(!y[i][j]&&(1<<(x[i][j]-1)&state)){
						flag=false;
						break;
					}
				}
				if(!flag) break;
			}
		}
		if(flag) res=max(res,__builtin_popcount(state));
	}
	cout<<res<<endl;
	return 0;
}


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

using namespace std;

long long res;
int dem[500];
string s;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    cin >> s;
    for (auto ch: s){
        for (char i = 'a'; i <= 'z'; i++)
            if (i != ch)
                res += 1LL * dem[i];
        dem[ch]++;
    }
    cout << 1 + res;
}


Measured memory_bytes: 720
#include<iostream>
#include<algorithm>
using namespace std;
#define INF 10e9+10
static const int MAX_N=10e5;
int A[MAX_N],B[MAX_N];
int main(void){
	int N,M;
		cin >> N >> M;
	for(int i=0;i<N;i++)
		cin >> A[i];
	sort(A,A+N);
	
	
	for(int i=1;i<N;i++)
		B[i]=A[i]-A[i-1]+B[i-1];
	int res=INF;
	
	for(int i=M-1;i<N;i++){
		res=min(res,B[i]-B[i-M+1]);
	}
	cout << res << endl;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,a,sum=0;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>a;
		sum+=a;
	}
	if(n<sum)cout<<"-1";
	else cout<<n-sum;
	return 0;
}

Measured memory_bytes: 3636
// https://atcoder.jp/contests/abc117/tasks/abc117_c
// +build ignore

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m, ans int
	fmt.Scanf("%d %d", &n, &m)

	// Slices can be created with the built-in make function; this is how you create dynamically-sized arrays.
	xs := make([]int, m)
	ds := make([]int, m-1)

	for i := 0; i < m; i++ {
		fmt.Scan(&xs[i])
	}

	if n >= m {
		fmt.Println(0)
		return
	}

	sort.Sort(sort.IntSlice(xs))
	for i := 0; i < m-1; i++ {
		ds[i] = xs[i+1] - xs[i]
	}
	sort.Sort(sort.IntSlice(ds))
	ds = ds[:len(ds)-(n-1)]

	for i := 0; i < len(ds); i++ {
		ans += ds[i]
	}
	fmt.Println(ans)
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
char a[105];
bool c,f;
int main()
{
	c=false;f=false;
	cin>>a;
	for(int i=0;i<=strlen(a)-1;i++)
	{
		if(a[i]=='C'&c==false)c=true;
		if(a[i]=='F'&c==true)f=true;
	}
	if(c==true&f==true) cout<<"Yes";
		else cout<<"No";
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main(void)
{
    int x, a, b;

    cin >> x >> a >> b;

    if(abs(x-a) > abs(x-b)){
        cout << 'B' << endl;
    }

    else{
        cout << 'A' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << "\n"; }
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using ti3 = tuple<int, int, int>;
using tl3 = tuple<ll, ll, ll>;

int main() {
	string s; cin >> s;
	int N = s.length();
	bool f = false;
	rep(i, N - 1) {
		if (f) break;
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			f = true;
		} else if (i < N - 2 and s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			f = true;
		}
	}
	if (!f) cout << "-1 -1" << endl;
	/*
	vector<vector<int>> n(26, vector<int>(N + 1));
	rep(i, N) {
		char c = s[i];
		rep(j, 26) {
			if (j == c - 'a') n[j][i + 1] = n[j][i] + 1;
			else n[j][i + 1] = n[j][i];
		}		
	}
	dbvv(n);
	*/	
}

Measured memory_bytes: 512
from collections import Counter

# UnionFind
class UnionFind():

    #0~Nまでの頂点数で初期化していることに注意
    def __init__(self, n):
        self.n = n
        self.root = [-1] * n

    def FindRoot(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.FindRoot(self.root[x])
            return self.root[x]

    def Unite(self, x, y):
        x = self.FindRoot(x)
        y = self.FindRoot(y)

        if x == y:
            return False
        if self.Size(x) < self.Size(y):
            x, y = y, x
        self.root[x] += self.root[y]
        self.root[y] = x

        return True

    def isSameGroup(self, x, y):
        return self.FindRoot(x) == self.FindRoot(y)

    def Size(self, x):
        return -self.root[self.FindRoot(x)]

N, K, L = map(int, input().split())

Uni1 = UnionFind(N)

for _ in range(K):
    p, q = map(int, input().split())
    Uni1.Unite(p-1, q-1)

Uni2 = UnionFind(N)

for _ in range(L):
    r, s = map(int, input().split())
    Uni2.Unite(r-1, s-1)

pair = []
for i in range(N):
    pair.append((Uni1.FindRoot(i), Uni2.FindRoot(i)))

c = Counter(pair)
cnt = []
for i in range(N):
    cnt.append(c[pair[i]])

print(*cnt)


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


int main() {
    int n;
    cin >> n;
    cout << n*800 - (n/15)*200 << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int main(){
  int K,T;
  cin >> K >> T;
  int M=0,x,sum=0;
  for(int i=0;i<T;i++){
    cin >> x;
    M=max(M,x);
    sum += x;
  }
  sum -= M;
  cout << max(M-sum-1,0) << endl;
}

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

const int INF=2e9;

int dp[2048][2048];
int n;

bool type[4048];
int a[4048];

int pos1[2048],pos2[2048];
set<int> ws1,ws2,bs1,bs2;
int bmark[4048][2048],smark[4048][2048];
int bsmall[4048][2048],ssmall[4048][2048];

inline int calc(int pos,int p1,int p2)
{
    return pos-bmark[pos][p1]-smark[pos][p2]-1;
}

int main ()
{
    int i,j;
    scanf("%d",&n);string ss;
    for (i=1;i<=n*2;i++)
    {
        cin>>ss;
        scanf("%d",&a[i]);
        if (ss=="B") type[i]=false; else type[i]=true;
        if (!type[i]) pos1[a[i]]=i; else pos2[a[i]]=i;
    }
    for (i=1;i<=n*2;i++)
        for (j=1;j<=i-1;j++)
            if (!type[j]) bmark[i][a[j]]++; else smark[i][a[j]]++;
    for (i=1;i<=n*2;i++)
        for (j=2;j<=n;j++)
        {
            bmark[i][j]+=bmark[i][j-1];
        }
    for (i=1;i<=n*2;i++)
        for (j=2;j<=n;j++)
            smark[i][j]+=smark[i][j-1];
    for (i=0;i<=n;i++)
        for (j=0;j<=n;j++)
            dp[i][j]=INF;
    dp[0][0]=0;
    for (i=0;i<=n;i++)
    {
        for (j=0;j<=n;j++)
        {
            if (!i && !j) continue;
            if (i) dp[i][j]=min(dp[i][j],dp[i-1][j]+calc(pos1[i],i-1,j));
            if (j) dp[i][j]=min(dp[i][j],dp[i][j-1]+calc(pos2[j],i,j-1));
        }
    }
    printf("%d\n",dp[n][n]);
    return 0;
}

Measured memory_bytes: 82304
#include<stdio.h>
#include<string.h>
int main()
{
	char s[128];
	int list[26];
	int i,j;
	for(i=0;i<26;i++){
		list[i]=0;
	}
	scanf("%s",s);
	for(i=0;i<strlen(s);i++){
		for(j=0;j<26;j++){
			if(s[i]==j+97){
				list[j]++;
			}
		}
	}
	for(i=0;i<26;i++){
		if(list[i]%2==1){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
a,b,c=map(int,input().split())
ans=3
if a==b:
    ans-=1
    if b==c:
        ans-=1
elif a==c:
    ans-=1
    if b==a:
        ans-=1
elif c==b:
    ans-=1
    if a==c:
        ans-=1
print(ans)       


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
using namespace std;
struct st{
    string a;
};
int main(){
    int n;
    string g;
    cin >> g >> n;
    int big = g.size();
    vector<st>s(n);
    int a = 0;
    for(int i = 0;i < n;i++){
        cin >> s[i].a;
    }
    //cout << big << endl;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < s[i].a.size();j++){
            if(s[i].a[j] == g[0]){
                int l = j;
                bool judge = true;
                for(int k = 1;k < big;k++){
                    if(l + k == s[i].a.size()){
                        l = 0 - k;
                    }
                    //cout << i << " " << l + k << " " << s[i].a[l+k] << " " << g[k] <<endl;
                    if(s[i].a[l + k] != g[k]){
                        judge = false;
                        //cout << "fales" <<endl;
                        break;
                    }

                }
                if(judge == true){
                    //cout << "true" <<endl;
                    a++;
                    break;
                }
            }
        }
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>

int main(void){
  int n;
  long long T, t[200200], ans = 0;

  scanf("%d", &n);
  scanf("%lld", &T);

  scanf("%lld", &t[0]);
  ans += T;
  for (long long i = 1; i < n; i++) {
    scanf("%lld", &t[i]);
    if (t[i] >= (t[i-1]+T)) {
      ans += T;
    }else{
      ans = ans + T + (t[i] - (t[i-1] + T));
    }
  }
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
    int N, count = 0, max_count = 0;
    cin >> N;
    vector<int> a(100001);
    for(int i=0; i<N; i++) {
        int x;
        cin >> x;
        a[x]++;
    }

    for(int i=1; i<a.size()-1; i++) {
        count = a[i-1]+a[i]+a[i+1];
        max_count = max(max_count, count);
    }
    cout << max_count << endl;

}

Measured memory_bytes: 3716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException
	{
		int i,j,n,m;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

		String[] nm = br.readLine().split(" ");

		n = Integer.parseInt(nm[0]);//input n
		m = Integer.parseInt(nm[1]);//input m

		int[][] matrix = new int[n][m];
		int[] vector = new int[m];
		int[] out = new int[n];

		for(i=0; i<n; i++)//get matrix
		{
			String[] str = br.readLine().split(" ");

			for(j=0; j<m; j++)
			{
				matrix[i][j] = Integer.parseInt(str[j]);
			}
		}

		for(i=0; i<m; i++)//get Vmatrix
		{
			String str = br.readLine();
			vector[i] = Integer.parseInt(str);
		}

		for(i=0; i<n; i++)//calc
		{
			for(j=0; j<m; j++)
			{
				out[i] = out[i] + matrix[i][j]*vector[j];
			}

			System.out.println(out[i]);
		}

/*++++++++++++++++++++++++++++++++++++*/
/*		for(i=0; i<n; i++)
		{
			for(j=0; j<m; j++)
			{
				System.out.print(matrix[i][j]);
			}

			System.out.println();
		}

		for(i=0; i<m; i++)
		{
			System.out.println(vector[i]);
		}*/

	}
}

Measured memory_bytes: 27492
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

int calc(string s) {
    int ans = 0;
    int lo = 0;
    int hi = cast(int) s.length - 1;
    while (lo < hi) {
        if (s[lo] == s[hi]) {
            lo++;
            hi--;
        }
        else if (s[lo] == 'x') {
            lo++;
            ans++;
        }
        else if (s[hi] == 'x') {
            hi--;
            ans++;
        }
        else {
            return -1;
        }
    }
    return ans;
}

void main() {
    auto s = readln.chomp;
    writeln(calc(s));
}


Measured memory_bytes: 2428
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>
#include <climits>

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline int lcm(int a,int b){return a*b/gcd(a,b);}
typedef long long ll;
typedef std::vector<int> VI;
typedef std::pair<int, int> PII;

using namespace std;


int main()
{
  int N;
  cin >> N;
  double t = 0.0;
  REP(i,N) {
    int a;
    cin >> a;
    t += 1.0 / (double)a;
  }
  printf("%.8lf\n", 1.0 / t);
}


Measured memory_bytes: 256
import sys
from fractions import gcd
input = sys.stdin.readline

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

L = [0] * (N+1)
R = [0] * (N+1)

def calc_gcd(x, y):
  if x == 0:
    return y
  elif y == 0:
    return x
  else:
    return gcd(x, y)

for i in range(N):
  L[i+1] = calc_gcd(L[i], A[i])
  R[N-1-i] = calc_gcd(R[N-i], A[N-1-i])

print(max(list(gcd(L[i], R[i+1]) for i in range(N))))

Measured memory_bytes: 16112
import * as fs from "fs";
var sum  = function(arr) {
    return arr.reduce(function(prev, current, i, arr) {
        return prev+current;
    });
};

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");

const [n, m] = input[0].split(" ").map((x: string): number => +x);
const a = input[1].split(" ").map((x: string): number => +x);

const d = sum(a) / (4 * m);

var fav = 0;

a.forEach((v) => {
    if (v >= d) {
        fav++
    }
})
console.log(fav >= m ? "Yes" : "No")

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#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[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

typedef string::const_iterator State;
string s;

string add(string s){
    if(s[0]=='Z')s[0]='A';
    else s[0]++;
    return s;
}
string dec(string s){
    if(s[0]=='A')s[0]='Z';
    else s[0]--;
    return s;
}

bool anspro(){
    string t;
    ll ls=s.length();
    ll pos=ls-1;
    while(pos>=0){
        string no;
        if('A'<=s[pos]&&s[pos]<='Z'){
            no+=s[pos];
            pos--;
            while(pos>=0){
                if(s[pos]=='+'){
                    no=add(no);
                    pos--;
                }else if(s[pos]=='-'){
                    no=dec(no);
                    pos--;
                }else{
                    break;
                }
            }
            t+=no[0];
        }else if(s[pos]=='?'){
            pos--;
            while(pos>=0){
                if(s[pos]=='+'||s[pos]=='-'){
                    pos--;
                }else{
                    break;
                }
            }
            t+='A';
        }else{
            t+=s[pos];
            pos--;
        }
    }
    reverse(t.begin(),t.end());
    //cout<<t<<endl;
    stack<string>st;
    rep(i,0,t.length()-1){
        if(t[i]==']'){
            queue<string>q;
            while(1){
                string k=st.top();st.pop();
                if(k[0]=='['){
                    while(!q.empty()){
                        string top=q.front();q.pop();
                        st.push(top);
                    }
                    break;
                }else{
                    q.push(k);
                }
            }
        }else{
            string k;k+=t[i];
            st.push(k);
        }
    }
    string ans;
    while(!st.empty()){
        string add=st.top();st.pop();
        ans+=add;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    
    
    return 0;
}

int main(){fastio
    while(1){
        cin>>s;
        if(s[0]=='.')break;
        anspro();
    }
    
    return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
int x[100005],y[100005],c[100005];
int n,k;
int num1[2005][2005],num2[2005][2005];
int get1(int a,int b,int c,int d)
{
	if(c<a||d<b) return 0;
	//cout<<num1[c][d]+num1[a-1][b-1]-num1[a-1][d]-num1[c][b-1]<<" ";
	return num1[c][d]+num1[a-1][b-1]-num1[a-1][d]-num1[c][b-1];
}
int get2(int a,int b,int c,int d)
{
	if(c<a||d<b) return 0;
	return num2[c][d]+num2[a-1][b-1]-num2[a-1][d]-num2[c][b-1];
}
int main()
{
	n=read();k=read();int n1=0;
	for(int i=1;i<=n;i++)
	{
		int x=read(),y=read();
		x%=2*k;y%=2*k;
		char op[2];
		scanf("%s",op);
		if(op[0]=='W')
		num1[x+1][y+1]++;else 
		{
			n1++;
			num2[x+1][y+1]++;
		}
	}
	for(int i=1;i<=2*k;i++)
	{
		for(int j=1;j<=2*k;j++)
		{
			num1[i][j]+=num1[i][j-1]+num1[i-1][j]-num1[i-1][j-1];
			num2[i][j]+=num2[i][j-1]+num2[i-1][j]-num2[i-1][j-1];
			//cout<<num1[i][j]<<" ";
		}
		//cout<<endl;
	}
	int ans=0;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			//cout<< get1(i,j,i+k-1,j+k-1)<<" "<<get1(i+k,j+k,2*k,2*k)<<" "<<get1(1,j+k,i-1,2*k)<<" "<<get1(1,1,i-1,j-1)<<" "<<get1(i+k,1,2*k,j-1)<<endl;
			int temp=get1(i,j,i+k-1,j+k-1)+get1(i+k,j+k,2*k,2*k)+get1(1,j+k,i-1,2*k)+get1(1,1,i-1,j-1)+get1(i+k,1,2*k,j-1)
			+(n1-get2(i,j,i+k-1,j+k-1)-get2(i+k,j+k,2*k,2*k)-get2(1,j+k,i-1,2*k)-get2(1,1,i-1,j-1)-get2(i+k,1,2*k,j-1));
			ans=max(ans,temp);
			ans=max(ans,n-temp);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 31616
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define a first
#define b second

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K;
	vector<pair<int,int>> in;
	
	cin>>N>>K;
	
	in.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>in[i].a>>in[i].b;
	}
	
	sort(in.begin(), in.end());
	
	for(int i = 0, sum = 0; i < N; i++){
		sum += in[i].b;
		
		if(sum >= K){
			cout<<in[i].a<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
H, W = map(int, input().split())
grid = [[1 if i == "." else 0 for i in input()] for _ in range(H)]

inf = 10**5
wf = np.ones((H*W, H*W), dtype=int)*inf
DX = (0, 1, 0, -1)
DY = (1, 0, -1, 0)

for i in range(H):
    for j in range(W):
        if not grid[i][j]:
            continue
        for dx, dy in zip(DX, DY):
            x = i + dx
            y = j + dy
            if x < 0 or x >= H or y < 0 or y >= W:  # 範囲外ならだめ
                continue
            if not grid[x][y]:  # 壁ならだめ
                continue
            orig = W * i + j
            to = orig + dx * W + dy
            wf[orig][to] = 1
            wf[to][orig] = 1

wf = floyd_warshall(wf)
wf[wf >= inf] = 0.
ans = int(wf.max())
print(ans)


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

int main() {
    string s;cin>>s;
    bool flg =false;

    if(s=="keyence"){
        cout<<"YES"<<endl;
    }
    else {
        for(int i=0;i<=7;i++){
            string ss=s;
            ss.erase(i,ss.size()-7);
            if(ss=="keyence"){
                cout<<"YES"<<endl;
                flg=true;
                break;
            }
        }
        if(flg==false){
            cout<<"NO"<<endl;
        }
    }
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        sc.nextLine();
        String[] a = new String[h];
        for(int i = 0;i<h;i++){
            a[i] = sc.nextLine();
        }
        for(int i = 0;i<h+2;i++){
            if(i == 0 || i == h+1){
                for(int j = 0;j<w+1;j++){
                    System.out.print("#");
                    if(j==w){
                        System.out.println("#");
                    }
                }
            }else{
                System.out.print("#");
                System.out.print(a[i-1]);
                System.out.println("#");
            }
        }
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static boolean is_prime(int n) {
		int square_root = (int)Math.sqrt(n);
		for (int i = square_root; i > 1; i--) {
			if (n % i == 0) {
				return false;
			}
		}
		return true;
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int num_of_primes = 0;
		for (int i = 0; i < n; i++) {
			int m = s.nextInt();
			if (is_prime(m))
				num_of_primes++;
		}
		System.out.println(num_of_primes);
	}
}



Measured memory_bytes: 42212
#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>;

int main() {
    int n;
    cin >> n;
    ll ans = 1;
    vector<ll> b(n);
    rep(i,n) {
        cin >> b[i];
        if(b[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll anspre = 1;
    rep(i,n) {
        ans *= b[i];
        if(ans > 1000000000000000000LL || ans < 0LL 
            || b[i] > 1000000000000000000LL || ans < anspre) {
            cout << -1 << endl;
            return 0;
        }
        anspre = ans;
    }

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

Measured memory_bytes: 4052
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
typedef pair<double,double> pdd;
const double EPS=1e-9;
#define debug(c) (cerr<<#c<<": "<<c<<"\n")
#define fi first
#define se second
#define mod 1000000007
#define pi acos(-1)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
int main()
{
	ios;
	ll n,x,t,d;
	cin>>n>>x>>t;
	d=ceil(n/(x*1.0d))*t;
	cout<<d<<endl;
}


Measured memory_bytes: 3592
<>;
map{push@$_,$_[--$|]for@_=glob}<>;
$m=1e9+7;
sub f{
	my($x,$y)=@_;
	my($b,$w)=(1,1);
	for(@$x){
		($c,$d)=f($_,$x),$b=$b*$c%$m,$w=$w*$d%$m if$_!=$y
	}
	($w,($b+$w)%$m)
}
print+(f 1)[1]

Measured memory_bytes: 186368
#include <map>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	vector<string> S(N);
	for (int i = 0; i < N; ++i) {
		cin >> S[i];
	}
	if (A + B + C >= 3) {
		string seq;
		bool ok = true;
		for (int i = 0; i < N; ++i) {
			if (S[i] == "AB") {
				if (A >= B) {
					--A;
					++B;
					seq += "B";
				}
				else {
					--B;
					++A;
					seq += "A";
				}
				if (A < 0 || B < 0) {
					ok = false;
					break;
				}
			}
			if (S[i] == "BC") {
				if (B >= C) {
					--B;
					++C;
					seq += "C";
				}
				else {
					--C;
					++B;
					seq += "B";
				}
				if (B < 0 || C < 0) {
					ok = false;
					break;
				}
			}
			if (S[i] == "AC") {
				if (C >= A) {
					--C;
					++A;
					seq += "A";
				}
				else {
					--A;
					++C;
					seq += "C";
				}
				if (C < 0 || A < 0) {
					ok = false;
					break;
				}
			}
		}
		if (ok) {
			cout << "Yes" << '\n';
			for (int i = 0; i < N; ++i) {
				cout << seq[i] << '\n';
			}
		}
		else {
			cout << "No" << '\n';
		}
	}
	else {
		vector<map<vector<int>, vector<int> > > dp(N + 1);
		dp[0][{A, B, C}] = { -1, -1, -1 };
		for (int i = 0; i < N; ++i) {
			map<vector<int>, vector<int> >::iterator it = dp[i].begin();
			while (it != dp[i].end()) {
				vector<int> v = it->first;
				for (int j = 0; j < 3; ++j) {
					if (j == 0 && S[i] != "AB") continue;
					if (j == 1 && S[i] != "BC") continue;
					if (j == 2 && S[i] != "AC") continue;
					if (v[j] >= 1) {
						vector<int> w = v;
						--w[j];
						++w[(j + 1) % 3];
						dp[i + 1][w] = v;
					}
					if (v[(j + 1) % 3] >= 1) {
						vector<int> w = v;
						--w[(j + 1) % 3];
						++w[j];
						dp[i + 1][w] = v;
					}
				}
				++it;
			}
		}
		if (dp[N].empty()) {
			cout << "No" << endl;
		}
		else {
			vector<int> p = dp[N].begin()->first;
			string seq;
			for (int i = N - 1; i >= 0; --i) {
				vector<int> np = dp[i + 1][p];
				for (int j = 0; j < 3; ++j) {
					if (np[j] < p[j]) {
						seq += char('A' + j);
					}
				}
				p = np;
			}
			reverse(seq.begin(), seq.end());
			cout << "Yes" << '\n';
			for (int i = 0; i < N; ++i) {
				cout << seq[i] << '\n';
			}
		}
	}
	return 0;
}

Measured memory_bytes: 30924
M = 10**9+7

memo = {}
x = []

def dfs(b):
    if b in memo:
        return memo[b]
    if b < 3:
        return 0
    if b < 6:
        memo[b] = 1
        return 1
    t = 0
    for i in range(3, b - 3+1):
        r = dfs(b - i)
        # print(f"({i},{b-i})", r, memo)
        t += r
        t %= M
    if b >= 6:
        t += 1
    memo[b] = t % M
    return memo[b]


def main():
    s = int(input())
    print(dfs(s) % M)


if __name__ == '__main__':
    main()


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

int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(),a.end());
  if(a[0]==5 && a[1]==5 && a[2]==7){
    cout << "YES";
  }else{
    cout << "NO";
  }
}

Measured memory_bytes: 256
function Main(input){
	input = input.split("\n");
	var arr = input[1].split(" ").map(Number);
	var mem = input[0].split(" ").map(Number);
	var x = mem[1];
	var now = 0;
	var sum = 1;
	for(var i=0;i<arr.length;i++){
		now += arr[i];
		if(now<=x) sum++;
		else break;
	}
	console.log(sum)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 11468
// Problem : A - The Number of Even Pairs
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define vl vector<ll>


/*#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}*/


//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

using namespace __gnu_pbds;
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,s1,s2;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>x>>y;
	cout<<x*(x-1)/2+y*(y-1)/2;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int> > edges(n);
    vector<vector<bool> > graph(n, vector<bool>(n, false));
    for(int i=0; i<m; ++i){
        int a, b;
        cin >> a >> b;
        -- a;
        -- b;
        edges[a].push_back(b);
        graph[a][b] = true;
    }

    for(int x=0; x<n; ++x){
        vector<int> prev(n, -1);
        queue<int> q;
        q.push(x);
        while(!q.empty()){
            int a = q.front();
            q.pop();
            for(int b : edges[a]){
                if(prev[b] == -1){
                    prev[b] = a;
                    q.push(b);
                }
            }
        }

        if(prev[x] != -1){
            vector<bool> used(n, false);
            int y = x;
            do{
                used[y] = true;
                y = prev[y];
            }while(y != x);

            for(int i=0; i<n; ++i){
                for(int j=0; j<n; ++j){
                    if(!used[i] || !used[j])
                        continue;
                    if(graph[i][j] && prev[j] != i){
                        int a = prev[j];
                        while(a != i){
                            used[a] = false;
                            a = prev[a];
                        }
                        prev[j] = i;
                    }
                }
            }

            vector<int> ans;
            for(int i=0; i<n; ++i){
                if(used[i])
                    ans.push_back(i+1);
            }
            cout << ans.size() << endl;
            for(int a : ans)
                cout << a << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll d[305][305],n,ans;
vector<pair<ll,pair<int,int> > >vi;
int main(){
	cin>>n;
	repn(i,n)repn(j,n){
		int a;cin>>a;
		if(i<j){
			vi.pb(mp(a,mp(i,j)));
		}
		if(i!=j) d[i][j] = 1e18;
	}
	SORT(vi);
	rep(i,vi.size()){
		ll v = vi[i].fi; int x = vi[i].sc.fi,y = vi[i].sc.sc;
		if(d[x][y] > v){
			ans += v;
			repn(i,n){
				repn(j,n){
					d[i][j] = min(d[i][j],d[i][x]+v+d[y][j]);
					d[i][j] = min(d[i][j],d[i][y]+v+d[x][j]);
				}
			}
		}
	}
	rep(i,vi.size()){
		ll v = vi[i].fi; int x = vi[i].sc.fi,y = vi[i].sc.sc;
		if(d[x][y] != v){
			puts("-1"); return 0;
		}
	}
	cout<<ans<<endl;
}

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

//const int INF = 1001001001;

/*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; }*/

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

    int ans = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                int num = 500 * i + 100 * j + 50 * k;
                if (x == num)
                    ans++;
            }
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
  int prime[1000001];

int main(){

  fill(prime,prime+1000001,1);
  prime[0] = prime[1] = 0;
  for(int i = 2 ; i*i < 1000001 ; i++ ){
    if(prime[i])for(int j = i*2 ; j < 1000001 ; j+=i )prime[j] = 0;
  }

  int a[2];
  while(cin >> a[0] >> a[1] , a[0]+a[1]){
    int sum[2] = {0};
    for(int i = 0 ; i < 2 ; i++ ){
      int f = 1;
      for(int j = a[i] ; j >= 2 ; j-- ){
	if(a[i]%j == 0 && prime[j] == 1){
	  if(f == 1){
	    sum[i] = j;
	    f = 0;
	  } else sum[i] -= j;
	}
      }
    }

    if(sum[0] > sum[1])cout << "a" << endl;
    else cout << "b" << endl;
  }
}

Measured memory_bytes: 5056
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 99999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long  int ll;

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

ll a,b,c;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>a>>b>>c;
  ll tmp;
  tmp=a;
  REP(i,b){
    if(tmp%b==c){
      cout <<"YES" <<endl;
      return 0;
    }
    tmp +=a;
  }

  cout <<"NO" <<endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 200000

int main(){
  int i,n,max,min;
  int data[MAX];

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d",&data[i]);
  }

  min = data[0];
  max = data[1] - min;
  if(data[1] < min){
    min = data[1];
  }

  for(i = 2;i < n;i++){
    if(max < data[i]-min){
      max = data[i] - min;
    }
    if(data[i] < min){
      min = data[i];
    }
  }
  printf("%d\n",max);
}



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

#define MAX 100000

int main(void){
    int N;
    char S[MAX][2];
    int C[4] = {0, 0, 0, 0}; //AC, WA, TLE, RE
    int AC = 0;
    int WA = 1;
    int TLE = 2;
    int RE = 3;

    cin >> N;
    for(int i = 0; i < N; ++i){
        cin >> S[i];
    }
    
    for(int i = 0; i < N; ++i){
        char c = S[i][0];
        switch (c)
        {
        case 'A':
            ++C[AC];
            break;
        case 'W':
            ++C[WA];
            break;
        case 'T':
            ++C[TLE];
            break;
        case 'R':
            ++C[RE];
            break;
        default:
            break;
        }
    }

    cout << "AC x " << C[AC] << endl;
    cout << "WA x " << C[WA] << endl;
    cout << "TLE x " << C[TLE] << endl;
    cout << "RE x " << C[RE] << endl;
}

Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string x,y;
    cin>>x>>y;
    int m=x.length(),n=y.length();
    vector<vector<int>> dp(m+1,vector<int>(n+1,0));
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(x.at(i-1)==y.at(j-1))
            dp[i][j]=1+dp[i-1][j-1];
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    if(dp[m][n]==0)
    cout<<"";
    else{
    string ans;
    int i=m,j=n;
    while(i&&j){
        if(x.at(i-1)==y.at(j-1)){
            ans.insert(0,1,x.at(i-1));
            i--,j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        i--;
        else
        j--;
    }
    cout<<ans;
    }
	return 0;
}


Measured memory_bytes: 38516
import java.io.*;
import java.util.StringTokenizer;
import java.util.ArrayList;

class List {
	ArrayList<Integer> number = new ArrayList<Integer>();
	ArrayList<Integer> score = new ArrayList<Integer>();
	int max_score,max_n;

	List() {
		max_score = 0;
		max_n = 21;
	}
	void add(int n,int s) {
		number.add(n);
		score.add(s);
		if (s>max_score) {
			max_score = s;
			max_n = n;
		} else if (s==max_score) {
			if (max_n>n) max_n = n;
		}
	}
	void MaxPrint() {
		System.out.println(max_n+" "+max_score);
	}
}

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int n = Integer.parseInt(br.readLine());
			List list = new List();
			for (int i=0;i<n;i++) {
				StringTokenizer st = new StringTokenizer(br.readLine());
				int number = Integer.parseInt(st.nextToken());
				int score = Integer.parseInt(st.nextToken());
				list.add(number,score);
			}
			list.MaxPrint();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17068
s = int(input())
A = set([])
B = [s]

cnt = 1
while True:
    last = B[-1]
    if last in A:
        print(cnt)
        exit()
    A.add(last)
    if last % 2 == 0:
        B.append(last // 2)
    else:
        B.append(3 * last + 1)
    cnt += 1


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

using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<ll> as(n), bs(n);
  for (auto &a : as)
    cin >> a;
  for (auto &b : bs)
    cin >> b;

  ll asum = accumulate(as.begin(), as.end(), 0LL);
  ll bsum = accumulate(bs.begin(), bs.end(), 0LL);

  ll cnt = 0;
  for (int i = 0; i < n; ++i)
    cnt += max((bs[i] - as[i] + 1) / 2, 0LL);

  if (cnt <= bsum - asum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    --x;
    --y;

    int prizes[3] = {300000, 200000, 100000};

    int total = 0;
    if (x < 3) {
        total += prizes[x];
    }
    if (y < 3) {
        total += prizes[y];
    }
    if (x == 0 && y == 0) {
        total += 400000;
    }
    cout << total << endl;
}

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

int main(void){
    long x, y;
    cin >> x >> y;
    if(x%y==0){
        cout << -1;
        return 0;
    }else{
        for(long a=x;; a+=x){
            if(a%y!=0){
                cout << a;
                return 0;
            }
        }
    }
}


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

int main(){
  int n;
  cin >> n;
 vector<int> p(n);
 int sum=0;
 for(int i=0; i<n; i++){
   cin >> p.at(i);
   sum += p.at(i);
 }
 sort(p.begin(), p.end());
 cout << sum-p.at(n-1)/2 << endl;
  return 0;
}


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

int main(){
	
	int x,y,z,k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x), b(y), c(z);
	rep(i,x) cin >> a[i];
	rep(i,y) cin >> b[i];
	rep(i,z) cin >> c[i];

	priority_queue<ll> queab;
	rep(i,x){
		rep(j,y){
			queab.push(a[i]+b[j]);
		}
	}
	
	vector<ll> d;
	while(!queab.empty() && d.size() < k){
		d.push_back(queab.top());
		queab.pop();
	}
	
	priority_queue<ll> quedc;
	rep(i,d.size()){
		rep(j,z){
			quedc.push(d[i]+c[j]);
		}
	}
	
	rep(i,k){
		cout << quedc.top() << endl;
		quedc.pop();
	}
	
	return 0;
}


Measured memory_bytes: 43144
#include<iostream>
#include<cmath>
#include<complex>
#include<vector>
using namespace std;
typedef complex<double> P;

double length(P a,P b){
    double t=2;
    return sqrt(pow(a.real()-b.real(),t)+pow(a.imag()-b.imag(),t));
}

double heron(double a, double b, double c){
    double z = (a+b+c)/2;
    return sqrt(z*(z-a)*(z-b)*(z-c));
}

int main(){
    vector<P> p(20);
    double x, y;
    int i=0;
    while(scanf("%lf,%lf", &x, &y) != EOF){
        p[i] = P(x,y);
        i++;
    }
    double sum = 0;
    for(int j = 1; j < i-1; j++){
        sum += heron(length(p[0], p[j]), length(p[j], p[j+1]), length(p[j+1], p[0]));
    }
    printf("%.6lf\n", abs(sum));
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/**
*   author: j o s e m a g o
*   user: m a m i s a k i
**/
using namespace std;

/***PLANTILLA***/

using namespace __gnu_pbds; //*st.find_by_order(1);  st.order_of_key(p);
#pragma GCC optimize ("Ofast")
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef double dbl;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;

string tostring(auto a){
    stringstream ss;ss<<a;string s = ss.str();
    return s;
}

/**Mi Debug**/
#define var(x) cout<<#x<<" = ";
#define db(x) cout<<#x<<" = "<<x<<"\n";
void dbvector(vector<auto>&v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}
void dbmapa(map<auto,auto>mp){
   for(auto x : mp) cout<<"{"<<x.first<<":"<<x.second<<"} ";cout<<"\n";
}
void dbstring(string v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}

/***********Code***************/

const int JJJ = 100100;










int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

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


    ll n;
    cin >> n;
    ll suma = 0;
    for(int a = 1;a <= n;a++){
        for(int b = 1;b <= n;b++){
            for(int c = 1;c <= n;c++){
                suma += (__gcd(a,__gcd(b,c)));
            }
        }
    }
    cout<<suma;




    return 0;
}


Measured memory_bytes: 3688
# 値の取得
H, W = map(int, input().split())
# 配列の準備
A = []
# #がある列のみをAについか
for i in range(H):
    a = list(input())  # 一文字ずつに分割されたリストなる
    if '#' in a:
        A.append(a)
    else:
        H = H - 1
# .のみの行を削除
for i in range(W - 1, -1, -1):  # rangeはiの値をfor文中でいじっても変更不可
    ch = 0
    for j in range(H):
        if A[j][i] == '#':
            ch = 0
            break
        else:
            ch = 1
    if ch == 1:
        for k in range(H):
            del A[k][i]
# 出力
for i, a in enumerate(A):
    print(''.join(a))


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    int sn = s.size(), ze = 0, it = 0;
    for (int i = 0; i < sn; i++) {
        if (s[i] == '0') {
            ze++;
        } else {
            it++;
        }
    }

    cout << 2 * min(ze, it) << endl;

    return 0;
}


Measured memory_bytes: 512