akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 2002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int dp[MAX_N][MAX_N]={};

int main() {
	string s;
	cin>>s;
	cout<<s.substr(0,s.length()-8)<<endl;

	return 0;
}


Measured memory_bytes: 256
import sys

MOD=10**9+7
N,M=map(int,input().split())
bad=set(map(int,sys.stdin))

a,b=0,1
for i in range(1,N+1):
    if i in bad:
        a,b=b,0
        if a==0:
            break
    else:
        a,b=b,(a+b)%MOD

print(b)


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

using namespace std;

int cnt[10][10];

int prvaCif(int x)
{
    int c=x%10;
    x/=10;
    while(x>0)
    {
        c=x%10;
        x/=10;
    }
    return c;
}

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cnt[prvaCif(i)][i%10]++;

    int res=0;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
            res+=cnt[i][j]*cnt[j][i];
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new  Scanner(System.in);
		int loop = in.nextInt();
		for(int i=0; i<loop; i++) {
			int[] ball = new int[10];
			boolean judge = true;
			for(int j=0; j<10; j++) ball[j] = in.nextInt();
			int b, c;
			b = ball[0];
			c = 0;
			for(int j=1; j<10; j++) {
				if(b < c) { //常にcのが小さくなる
					int tmp = b;
					b = c;
					c = tmp;
				}
				if(ball[j] > b) b = ball[j];
				else if(ball[j] > c) c = ball[j];
				else {
					System.out.println("NO");
					judge = false;
					break;
				}
			}
			if(judge) System.out.println("YES");
		}
	}
}

Measured memory_bytes: 18108
#include <iostream>
#include <cstdlib>

using namespace std;

int main(){
  string A, B;
  bool flag = true;
  cin >> A >> B;
  
  if(A.size() > B.size()){
    cout << "GREATER" << endl;
  }else if(A.size() < B.size()){
    cout << "LESS" << endl;
  }else{
    for(int i = 0 ; i <(int)A.size() ; i++){
      if((A[i]-'0') > (B[i]-'0')){
	cout << "GREATER" << endl;
	flag = false;
	break;
      }else if((A[i]-'0') < (B[i] - '0')){
	cout << "LESS" << endl;
	flag = false;
	break;
      }
    }
    if(flag) cout << "EQUAL" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  for(int i=0; i<n; i++){
	string s;
    cin >> s;
    if(s == "Y"){
      cout << "Four" << endl;
      return 0;
    }
  }
  
  cout << "Three" << endl;
}

Measured memory_bytes: 256
//by Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<s32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cout << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

int main()
{
	FASTIO;
	ll a,b;
	cin >> a >> b;
	ll ans = max({a + b,a - b,a * b});
	cout << ans << ln;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e4 + 3;

int main(){
    fast;
    ll n, k;
    cin >> n >> k;
    ll a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    ll low = 1, high = 1e9 + 5, ans;
    while(low <= high){
        ll mid = (low + high) / 2, sum = 0;
        for(int i = 0; i < n; ++i){
            ll g;
            if(a[i] < mid) continue;
            if(a[i] % mid == 0) g = a[i]/mid - 1;
            else g = a[i] / mid;
            sum += g;
        }
        if(sum > k) low = mid + 1;
        else if(sum <= k){
            ans = mid;
            high = mid - 1;
        }
    }
    cout << ans;
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}

Measured memory_bytes: 5332
import sys
sys.setrecursionlimit(100000000)




def main():
    k = int(input())
    a, b = map(int, input().split())

    ok = False
    for i in range(a,b+1):
        if i % k == 0:
            ok = True
            break

    if ok:
        print("OK")
    else:
        print("NG")


main()


Measured memory_bytes: 9176
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n,W;
    cin>>n>>W;
    vector<ll> dp(W+1,0);
    ll mx=0;
    for(int i=0;i<n;i++){
        ll w,v;
        cin>>w>>v;
        for(ll t=W;t>=0;t--){
            if(t+w<=W){dp[t+w]=max(dp[t+w],dp[t]+v); mx=max(mx,dp[t+w]);}
        }
    }
    cout<<mx<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<algorithm>
#include<cstdio>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int bm = 3010;
ll BIT[bm];
void add(int A, ll B) {
	while (A <= bm) {
		BIT[A] = max(BIT[A], B);
		A += A & -A;
	}
}
ll query(int A) {
	ll kotae = 0;
	while (A > 0) {
		kotae = max(BIT[A], kotae);
		A -= A & -A;
	}
	return kotae;
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

ll V[200000], tmp[200000];

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


	int R = getint(), C = getint(), K = getint();

	rep(i, K) {
		ll r = getint(), c = getint(), v = getint();
		V[i] = v << 30 | r << 12 | c;
	}

	const int b = 12;
	int kazu[1 << b] = {}, kazu2[1 << b] = {};
	rep(i, K) kazu[V[i] & ((1 << b) - 1)]++;
	rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
	for (int i = K - 1; i >= 0; i--) tmp[--kazu[V[i] & ((1 << b) - 1)]] = V[i];
	rep(i, K) kazu2[tmp[i] >> b & ((1 << b) - 1)]++;
	rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
	for (int i = K - 1; i >= 0; i--) V[--kazu2[tmp[i] >> b & ((1 << b) - 1)]] = tmp[i];

	int mae = -1;
	ll A[4] = {};
	ll L[3001];
	int l = 0;
	rep(k, K) {
		int v = V[k] >> 30;
		int i = V[k] >> 12 & 4095;
		int j = V[k] & 4095;
		if (mae != i) {
			mae = i;
			A[0] = 0;
			A[1] = 0;
			A[2] = 0;
			A[3] = 0;
			rep(a, l) add(L[a] & 4095, L[a] >> 12);
			l = 0;
		}
		ll kari = query(j);
		A[0] = kari;
		chmax(A[3], kari);
		chmax(A[2], kari);
		chmax(A[1], kari);
		chmax(A[3], A[2] + v);
		chmax(A[2], A[1] + v);
		chmax(A[1], A[0] + v);
		L[l++] = A[3] << 12 | j;
	}

	rep(a, l) add(L[a] & 4095, L[a] >> 12);
	ll kotae = query(C);

	printf("%lld\n", kotae);

	Would you please return 0;
}

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

int main()
{
    string s,s1;
    cin>>s;
    s1=s;
    reverse(s1.begin(),s1.end());
    if(s==s1)
    {
        s1.clear();
        for(int i=0;i<(s.size()-1)/2;i++)
            s1.push_back(s[i]);
        string s2 =s1;
        reverse(s2.begin(),s2.end());
        if(s2==s1)
        {
            s1.clear();
            s2.clear();
            for(int i=((s.size()+3)/2)-1;i<s.size();i++)
                s1.push_back(s[i]);
            s2=s1;
            reverse(s2.begin(),s2.end());
            if(s2==s1)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
        else
            cout<<"No"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,p = 0x7fffffff,a[105];
int s(int a,int b){
	return (a - b) * (a - b);
}
int f(int k){
	int step = 0;
	for(int i = 1; i <= n; i++)step += s(a[i],k);
	return step;
}
signed main(){
//	freopen("date.in","r",stdin);
//	freopen("date.out","w",stdout);
	scanf("%d",&n);
	for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
	sort(a + 1,a + n + 1);
	for(int i = a[1]; i <= a[n]; i++) p = min(f(i),p);
  	printf("%d",p);
}



Measured memory_bytes: 3752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_ExaWizards_2019
{
    class Program
    {

        static void Main(string[] args)
        {

            int[] cntArr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            string ret = "No";
            if (cntArr[0] == cntArr[1] && cntArr[1]== cntArr[2]) ret = "Yes";

            Console.WriteLine(ret);

        }
    }
}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,cost[300][300],calc[300][300],ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			cin >> cost[i][j];
			calc[i][j] = INF;
		}
		calc[i][i] = 0;
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			bool flag = true;
			for(int k = 0;k < n;k++){
				if(i == k || j == k) continue;
				if(cost[i][k] + cost[k][j] == cost[i][j]) flag = false;
			}
			if(flag){
				calc[i][j] = cost[i][j];
				ans += calc[i][j];
			}
		}
	}
	for(int k = 0;k < n;k++){
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++) calc[i][j] = min(calc[i][j],calc[i][k] + calc[k][j]);
		}
	}
	bool flag = true;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			if(calc[i][j] != cost[i][j]) flag = false;
		}
	}
	if(flag) cout << ans / 2 << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
#define pii pair <int ,int >
#define bug(x)  cout<<"passed "<<x<<endl;

long long const inf = 2e18, linf = 2e9, mod = 1e9+7;
int const mxn = 1e6 + 10 ;  ; 

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

long long ans , ans2 ; 
int R[mxn] , G[mxn] , B[mxn]  ; 
string  s; 
int main(){
	int n ; 
	cin>> n ; 
	cin>>s ; 
	s = "." + s ; 
	for (int i = 1; i <= n ; i++){
		R[i] = R[i-1] + (s[i]=='R') ; 
		G[i] = G[i-1] + (s[i]=='G') ; 
		B[i] = B[i-1] + (s[i]=='B') ; 
	}
	
	
	
	for (int i = 1 ; i <= n ; i++){
		if (s[i]=='R'){
			ans+=G[i] * (B[n] - B[i]) ; 
			ans+=B[i] * (G[n] - G[i]) ; 
		}
		if (s[i]=='G'){
			ans+=R[i] * (B[n] - B[i]) ; 
			ans+=B[i] * (R[n] - R[i]) ; 
		}
		if (s[i]=='B'){
			ans+=R[i] * (G[n] - G[i]) ; 
			ans+=G[i] * (R[n] - R[i]) ;
		}
	}
	for (int i = 1 ; i <=n ; i++){
		for (int j = i+1 ; j <=n ; j++){
			if ((j - i)%2==0){
				int b = (j+i) / 2; 
				if (s[i]!=s[j] and s[b]!=s[j] and s[b]!=s[i])
					ans2++ ;
			}
		}
	}
	//cout<<ans<<endl;
	cout<<ans - ans2  ; 

}

Measured memory_bytes: 3700
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int a, b;
  	cin >> a >> b;
  	if(a<b){
  		for(int i=0;i<b;i++){
  			cout << a;
  		}
  		cout <<endl;
  	}else{
  		for(int i=0;i<a;i++){
  			cout << b;
  		}
  		cout <<endl;
  	}

    
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,a,n) for(int i = a ; i < (int)n ; i++)
typedef long long int ll;
 
int sign(int a){
    return a/abs(a);
}
 
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll a[100001];
int n;
cin>>n;
 
rep(i,n) cin >> a[i];
 
ll sum=0;
ll c=1;
ll c1=0,c2=0;
//奇数番目を正とする
rep(i,n){
    sum+=a[i];
    if(sum*c<=0){
        c1+=abs(sum)+1;
        sum=c;
    }
    c*=-1;
}
//奇数番目を偶数とする
c=-1;
sum=0;
rep(i,n){
    sum+=a[i];
    if(sum*c<=0){
        c2+=abs(sum)+1;
        sum=c;
    }
    c*=-1;
}
cout<<min(c1,c2)<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 1024
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();
    String s = sc.next();
    char p[] = s.toCharArray();
    int flag = 0;
    for(int i = 0;i < a;i++){
      if(p[i] < '0' || p[i] > '9'){
        flag = 1;
      }
    }
    if(p[a] != '-'){
      flag = 1;
    }
    for(int i = a + 1;i <= a + b;i++){
      if(p[i] < '0' || p[i] > '9'){
        flag = 1;
      }
    }
    if(flag == 0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string S;
    cin >> S; // a 4-digit code
    bool A = true;
    if (S[0] == S[1]) A = false;
    if (S[1] == S[2]) A = false;
    if (S[2] == S[3]) A = false;
    if (A) cout << "Good" <<endl;
      else cout << "Bad" <<endl;   
    
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
int n,x,y,z;
vector<ll> a,b,c;
bool solve(ll P){
  int cnt=0;
  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
      for(int k=0;k<z;k++){
        if(a[i]+b[j]+c[k]<P) break;
        cnt++;
        if(cnt>=n) return true;
      }
    }
  }
  return false;
}

int main(){
  cin>>x>>y>>z>>n;
  a.resize(x),b.resize(y),c.resize(z);
  for(int i=0;i<x;i++){
    cin>>a[i];
  }sort(a.rbegin(),a.rend());
  for(int i=0;i<y;i++){
    cin>>b[i];
  }sort(b.rbegin(),b.rend());
  for(int i=0;i<z;i++){
    cin>>c[i];
  }sort(c.rbegin(),c.rend());
  ll l=1,r=30000000000;
  while(r-l!=1){
    ll mid=(l+r)/2;
    if(solve(mid)){
      l=mid;
    }else{
      r=mid;
    }
  }
  vector<ll> ans;
  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
      for(int k=0;k<z;k++){
        if(l+1>a[i]+b[j]+c[k]) break;
        ans.push_back(a[i]+b[j]+c[k]);
      }
    }
  }
  sort(ans.rbegin(),ans.rend());
  for(int i=0;i<n;i++){
    if(i>=ans.size()){
      cout<<l<<endl;
    }
    else{
      cout<<ans[i]<<endl;
    }
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std; 
#define priority_queue pq
#define pu push
#define loop for(int i=0;i<n;i++)
int ar[100001];
int32_t  main()
{ 
	int n;
	cin>>n;
	int ar[n];
	loop
	ar[i]=0;
	for(int i=0;i<n-1;i++)
	{
		int a;
		cin>>a;
		ar[a-1]++;
	}
	loop
	{
		cout<<ar[i]<<endl;
	}
}

		


Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 , -1};
struct mint {
  int x; // typedef long long ll;
  mint(int 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(int 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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        } else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
signed main() {
    int a,b;cin >> a >> b;
    if(a < b) cout << "a < b" << endl;
    else if(a > b) cout << "a > b" << endl;
    else cout << "a == b" << endl;
}



Measured memory_bytes: 3084
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int N;
  scanf("%d",&N);
  char s[N+1][11];
  for(int i=0;i<N;i++){	
    scanf("%s",s[i]);
  }
  if(N==1){
    printf("%s",s[0]);
    return 0;
  }
  
  qsort(s,N,sizeof(char)*11,strcmp);
  
 /* for(int i=0;i<N;i++){	
    printf("%s\n",s[i]);
  }*/
 int max=-1;
  int anser[200001];
  for(int i=0;i<N;i++){
     anser[i]=1;
    }
  for(int i=0;i<N-1;i++){
    if(strcmp(s[i],s[i+1])==0){
      anser[i+1]=anser[i]+1;
    }
    if(anser[i+1]>max)max=anser[i+1];
  }
  
 /* for(int i=0;i<N;i++){
      printf("%d\n",anser[i]);
    }
  */
 for(int i=0;i<N;i++){
    if(anser[i]==max){
      printf("%s\n",s[i]);
    }
  }
  
  
  return 0;
}

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

    

int main(){
  ll N,K,C,t=0;
  string S;
  cin >> N >> K >> C >> S;
  vector<ll> L(K),R(K);
  rep(i,N){
    if(S.at(i)=='o'){
      L.at(t)=i;
      t++;
      i+=C;
    }
    if(t==K){
      break;
    }
  }
  t=K-1;
  rep(i,N){
    if(S.at(N-i-1)=='o'){
      R.at(t)=N-i-1;
      t--;
      i+=C;
    }
    if(t==-1){
      break;
    }
  }
  rep(i,K){
    if(L.at(i)==R.at(i)){
      cout << L.at(i)+1 << endl;
    }
  }
      
}

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

using namespace std;
using ll = long long;
map<ll,ll> mp;

ll luca(ll n) {
  ll ans;
  if (n == 0)
    return 2L;
  else if (n == 1)
    return 1L;
  auto iter = mp.find(n);
  if (iter != end(mp))
    return iter->second;
  else {
    ans = luca(n - 1)+luca(n - 2);
    mp[n] = ans;
  }
  return ans;
}

int main() {
  ll n;
  cin >> n;
  ll ans = luca(n);
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
 
            String[] str = reader.readLine().split(" ");
            int Hrow = Integer.parseInt(str[0]);
            int Wcol = Integer.parseInt(str[1]);
            int Kcnt = Integer.parseInt(str[2]);
            // int[] nums = { Integer.parseInt(str[0]), Integer.parseInt(str[1]),
            // Integer.parseInt(str[2]) };
            // 0:行H 1:列W 2:黒マスの残数K
 
            // H行W列の配列
            int[][] HWC = new int[Hrow][Wcol];
            // int Kcnt = 0;
            int answer = 0; // 答え 何通りあるか
 
            for (int i = 0; i < Hrow; i++) {
                String read = reader.readLine();
                for (int j = 0; j < Wcol; j++) {
                    if (read.charAt(j) == '#') {
                        HWC[i][j] = 1;
                    } else {
                        HWC[i][j] = 0;
                    }
                }
            }
            reader.close();
            for (int Hmask = 0; Hmask <= ((1 << Hrow) - 1); Hmask++) {
                for (int Wmask = 0; Wmask <= ((1 << Wcol) - 1); Wmask++) {
                    int Black_cnt = 0;
                    for (int i = 0; i < Hrow; i++) {
                        for (int j = 0; j < Wcol; j++) {
                            if ((((Hmask >> i) & 1) == 0) && (((Wmask >> j) & 1) == 0) && (HWC[i][j] == 1))
                                Black_cnt++;
                        }
                    }
                    if (Black_cnt == Kcnt) {
                        answer++;
                    }
 
                }
            }
 
            System.out.println(answer);
 
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

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

int main () {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (x >= a.at(i)) {
      if (i == N-1) {
        if (x == a.at(i)) ans++;
      }
      else {
        ans++;
        x -= a.at(i);
      }
    }
    else break;
  }
  cout << ans << 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 K=sc.nextInt();
		 ArrayList<Integer> D=new ArrayList<Integer>();
		 for(int i=0;i<K;i++) {
			 D.add(sc.nextInt());
		 }
	     sc.close();
	     
	     int ans=0;
	     for(int count=N;;count++) {
	    	 if(!fanc(count,D)) {
	    		 ans=count;
	    		 break;
	    	 }
	     }
	     System.out.println(ans);
	 }
	public static boolean fanc(int number,ArrayList<Integer> D) {
		int num=number;
		while(num>0) {
			int N=num%10;
			if(D.contains(N))
				return true;
			num/=10;
		}
		return false;
	}
}


Measured memory_bytes: 22612
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

    int maxx = h[0];
    int cnt = 1;
    for(int i=1;i<n;i++){
        if(h[i] >= maxx){
            cnt++;
        }
        maxx = max(maxx, h[i]);
    }
    cout << cnt << endl;
    return 0;
}
      

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
//	freopen("C.in","r",stdin);
	int N,M,n,m;
	scanf("%d%d%d%d",&N,&M,&n,&m);
	if(N%n==0&&M%m==0){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	for(int i=1;i<=N;i++)
	{
		for(int j=1;j<=M;j++)
		{
			if((i%n==1||n==1)&&(j%m==1||m==1))
				printf("100000000 ");
			else if(i%n==0&&j%m==0)
				printf("-100000001 ");
			else
				printf("0 ");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

int main() {
	int h,w;
	std::cin >> h >> w;
	std::map<int,int> map;
	std::map<int,int> cost;
	rep(i,w) {
		map[i]=i;
	}
	cost[0]=w;
	int y=0;
	rep(i,h) {
		int l,r;
		std::cin >> l >> r;
		l--;
		if(y>=l&&y<r) {
			y=r;
		}
		{
			int last=-1;
			while(map.lower_bound(l)!=map.end()&&map.lower_bound(l)->first<r) {
				auto b=map.lower_bound(l);
				last=b->second;
				int c=b->first-b->second;
				cost[c]--;
				if(cost[c]==0) cost.erase(c);
				map.erase(b);
			}
			if((~last)&&!map.count(r)&&r<w) {
				map[r]=last;
				cost[r-last]++;
			}
		}
		if(y==w) print(-1);
		else print(cost.begin()->first+i+1);
	}
}


Measured memory_bytes: 12988
#include<iostream>
using namespace std;
int main()
{
	bool p[1000000] = { false };
	int n;
	for (int i = 2; i <1000000; i++){
		for (int i2 = 2; i*i2 <= 1000000; i2++){
				p[i*i2] = true;
			}
		}
		p[2] = false;
		p[3] = false;
	while (cin >> n){
		
		
		int c = 0;
		for (int i = 2; i <= n; i++){
			if (!p[i])c++;
		}
		cout << c << endl;
	}
}

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

int main() {
	int a, b, k;
	cin >> k >> a >> b;
	int tol = 0;

	for (int i = 1; i <= 1000; i++) {
		for (int j = a; j <= b; j++) {
			if (j % (k * i) == 0) {
				tol++;
			}
		}
	}

	if (tol >= 1) {
		cout << "OK" << endl;
	}else {
		cout << "NG" << endl;
	}

	return 0;
}

Measured memory_bytes: 3636
A = list(map(int, input().split()))
ans = 200
for i in range(3):
  for j in range(3):
    if j == i:
      continue
    for k in range(3):
      if k == i or k == j:
        continue
      ans = min(ans, abs(A[k] - A[j]) + abs(A[j] - A[i]))
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t W, H, x, y;
  cin >> W >> H >> x >> y;
  if (W%2==1 && H%2==1){
    cout << fixed << setprecision(6);
    cout << double(W*H/2)+0.500000 << endl;
  }
  else {
    cout << fixed << setprecision(6);
    cout << double(W*H/2) << endl;
  }
  if(2*x==W && 2*y==H) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/arc059/tasks/arc059_a
# 全探索してもいいし、二乗誤差の最小化から平均値を求めても良い

N = int(input())
A = list(map(int, input().split()))
candi1 = sum(A) // N
candi2 = candi1 + 1

ans1 = ans2 = 0
for a in A:
    ans1 += (a - candi1)**2
    ans2 += (a - candi2) ** 2
print(min(ans1, ans2))


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, k;
	cin >> n >> k;

	string a; cin >> a;

	ll runs = 0;
	FOR(i,0,sz(a)) if (i == 0 || a[i] != a[i-1]) runs++;

	cout << n - max(runs-2*k,1LL) << endl;
}



Measured memory_bytes: 512
"""
最も時間ロスが大きい注文は最後に注文することで時間が節約できる
時間のロスは(10-(調理時間の1の位の値))で計算できる == 1の位が最小
最後の注文以外の注文時間は1の位繰り上げの値となる
最後の注文の切り上げ分を最終結果からマイナスしておく
"""

def ceil(a, b):
  return -(-a//b) * 10

A = [int(input()) for _ in range(5)]
ceiled = [ceil(a,10) for a in A]
loss = [x-y for x,y in zip(ceiled, A)]
print(sum(ceiled) - max(loss))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

using ll = long long;

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

int main()
{
	string s;
	cin >> s;
	int from = -1;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'A' && from == -1)
		{
			from = i;
			break;
		}
	}

	int to = -1;
	for (int i = s.length() - 1; i >= 0; i--)
	{
		if (s[i] == 'Z' && to == -1)
		{
			to = i;
			break;
		}
	}

	cout << (to - from + 1) << endl;
}

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1e9+7
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'

struct custom_hash {    // anti-hack for unordered_map. To declare: unordered_map<long long, int, custom_hash> safe_map;
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//


void solve()
{
    int n;
    cin>>n;
    while(n>=1000)
        n-=1000;
    if(n!=0)
    cout<<1000-n<<endl;
    else
    cout<<0<<endl;
}

int main()
{
	fastio;
    // int T;
    // cin>>T;
    // while(T--)
        solve();
	return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

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


signed main(){

	int N;
	cin >> N;
	double ans = 0.0;
	rep(i, N){
		double x;
		string u;
		cin >> x;
		cin >> u;
		if (u[0] == 'J') ans += x;
		else ans += 380000.0 * x;
	}
	printf("%20.9f\n",  ans);


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>  
#include<cstring>  
using namespace std;  
string a,b;  
int main()  
{ 
    cin>>a>>b;
    if(a.size()>b.size())cout<<"GREATER"<<endl;
     else if(a.size()<b.size())cout<<"LESS"<<endl;
     else if(a.size()==b.size())
	 {
	 	if(a>b)cout<<"GREATER"<<endl;
     if(a<b)cout<<"LESS"<<endl;
     if(a==b)cout<<"EQUAL"<<endl;
	 }
	return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashSet;

fn main() {
  let n = read::<i64>();
  let mut d = HashSet::new();

  for _ in 0..n {
    d.insert(read::<i64>());
  }

  println!("{}", d.len());

}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define IOS   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp    make_pair
#define pb    push_back
#define F     first
#define pi 	  3.14159265358979323846
#define S     second
#define ll    long long
#define ld    long double
#define sz(s) (ll)s.size()
#define vl    vector < ll >
#define pll   pair < ll, ll >
#define ml    map < ll, ll >
#define mod   1000000007
#define qe	  998244353
#define maxn  100005
#define mx    1005
#define rep(i,a,b)  for(i=a;i<b;i++)
#define inv(i,a,b)  for(i=a;i>=b;i--)
#define all(a)  (a).begin(),(a).end()
using namespace std;
int main(){
//	#ifndef ONLINE_JUDGE
//    if (fopen("input.txt", "r"))
//    {
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
//    }
//	#endif
	IOS;
	ll t,n,l;
	ll i,m,mn,q,j,x,y,ans,sum=0,k,c;
	string s,s1;
	cin>>s>>s1;
	ans=mod;
	rep(i,0,sz(s)-sz(s1)+1){
		k=i;
		j=0;
		ll ans1=0;
		while(j<sz(s1)){
			if(s[k]!=s1[j])ans1++;
			j++,k++;
		}
		ans=min(ans1,ans);
	}
	cout<<ans;
}

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline
h,w = map(int,input().split())
a = []
for i in range(h):
  s = list(map(int,input().split()))
  a.append(s)
  
b = []
for i in range(h):
  s = list(map(int,input().split()))
  b.append(s)
  
dp = [[0]*w for i in range(h)]
t = 80*(h+w)
dp[0][0] = 2**(t+abs(a[0][0]-b[0][0]))

for i in range(h):
  for j in range(w):
    r = abs(a[i][j]-b[i][j])
    if j > 0:
      dp[i][j] |= (dp[i][j-1]<<r | dp[i][j-1]>>r)
    if i > 0:
      dp[i][j] |= (dp[i-1][j]<<r | dp[i-1][j]>>r)
      
a = dp[h-1][w-1]>>t
m = a&(-a)
print(m.bit_length()-1)

Measured memory_bytes: 26088
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

x = int(input())
chk = 0
i = 1

while chk < x:
	chk = chk + i
	i = i + 1
	#print(chk,i)

print(i-1)


Measured memory_bytes: 38640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
using namespace std;



int main() {

	int r, g, b;
	cin >> r >> g >> b;

	int a = 100 * r + 10 * g + b;

	if (a % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}




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

int main() {
	long long l, r, ans = 2018;
	cin >> l >> r;
	r = min(r, l + 2018);
	for (long long i = l; i <= r; ++i) {
		for (long long j = i + 1; j <= r; ++j) {
			ans = min(ans, i * j % 2019);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s;
  ll k;
  cin >> s >> k;
  int n = s.size();
  vector<ll> dif(n);
  rep(i,n) dif[i] = 'z' - s[i] + 1;
  rep(i,n) {
    if (dif[i] <= k && s[i] != 'a') {
      k -= dif[i];
      s[i] = 'a';
    }
    if (i == n-1) {
      k %= 26;
      rep(_,k) {
        if (s[i] == 'z') s[i] = 'a';
        else s[i]++;
      }
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 1360
s=input()
l=len(s)
ans=0
for i in range(2**(l-1)):
    temp=0
    for j in range(l-1):
        if i&1:
            ans+=int(s[temp:j+1])
            temp=j+1
        i>>=1
    ans+=int(s[temp:l])
print(ans)

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=2e5+5;
int mark[maxm];
signed main(){
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int a=abs(i-j);//按原来的路走
            int b=abs(x-i)+abs(y-j)+1;//走x-y
            int d=min(a,b);
            mark[d]++;
        }
    }
    for(int i=1;i<=n-1;i++)cout<<mark[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
def solve(num,n)
	oe=[0,0]
	num.each do |x|
		x%2==1 ? oe[0]+=1 : oe[1]+=1
	end
	puts oe[0]%2==0 ? "YES" : "NO"
end

if __FILE__==$0
	
	rl_i=lambda{|str,dl|str.strip.split(dl).map(&:to_i)}
	r_i=lambda{|str|str.strip.to_i}
	dl=" "
	n=r_i[gets]
	num=rl_i[gets,dl]
	solve(num,n)
end

Measured memory_bytes: 9484
#include <iostream>
#define lli long long int
using namespace std;

int main()
{
    lli n, sum = 0;
    
    cin >> n;
    lli b[n - 1];
    for(lli i = 0; i < n - 1; i++)
    {
        cin >> b[i];
        if(i == 0)
        {
            sum += 2*b[i];
        }
        else
        {
            if(b[i] >= b[i-1])
                sum += b[i];
            else
                sum += 2*b[i] - b[i - 1];
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L, R; cin >> L >> R;
    vector<int> v;
    int ans = 2020;
    REP(i, L, min(R, L + 4020)) { 
        REP(j, i + 1, min(R, L + 4020)) {
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
const int N = 2500 + 3, M = 5000 + 3, OO = 1.2e9;
int head[N], nxt[M], to[M], cost[M], n, ne;
int dist[N];
void init() {
	ne = 0;
	memset(head, -1, n * sizeof head[0]);
}
void addEdge(int u, int v, int c) {
	to[ne] = v;
	cost[ne] = c;
	nxt[ne] = head[u];
	head[u] = ne++;
}
vector<int> inCycle;
bool inQ[N];
int bellman() {
	memset(dist, '?', sizeof dist);
	dist[0] = 0;
	queue<int> q;
	q.push(0);
	bool edit = true;
	for (int i = 0; i <= n && q.size(); ++i) {
		edit = false;
		int sz = q.size();
		while (sz--) {
			int u = q.front();
			q.pop();
			inQ[u] = false;
			for (int e = head[u]; ~e; e = nxt[e]) {
				int v = to[e];
				if (dist[v] > dist[u] + cost[e]) {
					edit = true;
					dist[v] = min(OO, dist[u] + cost[e]);
					if (i == n)
						inCycle.push_back(u);
					if (!inQ[v]++)
						q.push(v);
				}
			}
		}
	}
	if (edit)
		return OO;
	return dist[n - 1];
}
bool vis[N];
bool go(int u) {
	if (u == n - 1)
		return true;
	if (vis[u]++)
		return false;
	for (int e = head[u]; ~e; e = nxt[e]) {
		int v = to[e];
		if (go(v))
			return true;
	}
	return false;
}
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
	int m, p;
	scanf("%d %d %d", &n, &m, &p);
	init();
	while (m--) {
		int u, v, c;
		scanf("%d %d %d", &u, &v, &c);
		addEdge(--u, --v, -(c - p));
	}
	int res = bellman();
	if (res == OO) {
		for (auto u: inCycle) {
			if (go(u)) {
				puts("-1");
				return 0;
			}
		}
		res = dist[n - 1];
	}
	printf("%d\n", max(0, -res));
	return 0;
}

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

int main () {

  int n, m; cin >> n >> m;
  
  vector<int>a(n);
  int count = 0;
  double ans =0;
  for (int i=0; i<n; i++) {
    cin >> a[i];
    ans += a[i];
  }
  double sum = ans/(4*m);
  
  for (int i=0; i<n; i++) {
    if (a[i] >=sum) count++;
  }
    if (count >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
  
}


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

main() {
    int N; cin >> N;
    if(N>=195) cout << 5 << endl;
    else if(N>=189) cout << 4 << endl;
    else if(N>=165) cout << 3 << endl;
    else if(N>=135) cout << 2 << endl;
    else if(N>=105) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())
if A == 0 or B == 0:
    print("0 0")
elif N >= A + B:
    a = min(A,B)
    print("{} {}".format(a,0))
else:
    a = min(A,B)
    b = A + B - N
    print("{} {}".format(a,b))

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

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

    int N; cin >> N;
    double T, A; cin >> T >> A;
    int pos = 0;
    double tmp = 1 << 30;
    for (int i = 1; i <= N; i++) {
        int H; cin >> H;
        double t = abs(A - (T - H * 0.006));
        if (t < tmp) {
            pos = i;
            tmp = t;
        }
    }
    cout << pos << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i) for(int i=0;i<n;i++)
using namespace std;int n,c,a[110],b[110];int main(){while(cin>>n&&n){rep(i)a[i]=1145141919,b[i]=0;rep(i)rep(j){cin>>c;a[i]=min(a[i],c);b[j]=max(b[j],c);}rep(i)rep(j)if(a[i]==b[j]){cout<<a[i]<<endl;goto loop;}cout<<"0"<<endl;loop:;}return 0;}

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

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    int sum = (c-a)*60 + (d-b);
    cout << sum - e;
}

Measured memory_bytes: 3636
#include <iostream>
#include <queue>

using namespace std;
//queueで実装
//queue<int>でqueue生成
//int top = queue.front();
//queue.pop(); 取り出したqueueは用済み
//while top < n
//topが3&&5&&7がそれぞれ1個以上ならcounter++
//top=top*10;
//queue.push(top+3),queue.push(top+5),queue.push(top+7)
bool stgExist(long x);
int main(void) {
  int n;
  cin >> n;
  queue<int> a;
  a.push(0);
  int counter = 0;
  while(true) {
    long top = a.front();
    if(top > n) break;
    a.pop();
    if(stgExist(top))
      counter++;
    top *= 10;
    a.push(top+3);
    a.push(top+5);
    a.push(top+7);
  }
  cout << counter << endl;
  return 0;
}
bool stgExist(long x) {
  int a = 0, b = 0,c = 0;
  while(x > 0) {
    if(x % 10 == 3) a++;
    if(x % 10 == 5) b++;
    if(x % 10 == 7) c++;
    x /= 10;
  }
  if(a > 0 && b > 0 && c > 0) return true;
  else return false;
}

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

using i64 = int64_t;

class UnionFindTree {
  private:
    vector<int> par;   // 親
    vector<int> depth; // 木の深さ

  public:
    vector<int> size;

    // n要素で初期化
    UnionFindTree(int n) {
        for (int i = 0; i < n; i++) {
            par.push_back(i);
            depth.push_back(0);
            size.push_back(1);
        }
    }

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

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

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

    // xとyが同じ集合に属するか否か
    bool same(int x, int y) { return find(x) == find(y); }
};


int main(){
    i64 n, m;
    cin >> n >> m;
    vector<pair<int, int>> bridges;
    for(int i=0;i<m;++i){
        int a, b;
        cin >> a >> b;
        bridges.emplace_back(a, b);
    }
    UnionFindTree uft = UnionFindTree(n + 1);
    i64 sum = n * (n-1) / 2;

    deque<i64> ans;
    ans.push_front(sum);
    for(int i=(int)bridges.size()-1;i>0;--i){
        i64 num;
        if(uft.same(bridges[i].first, bridges[i].second))num = 0;
        else{
            int par1 = uft.find(bridges[i].first), par2 = uft.find(bridges[i].second);
            num = uft.size[par1] * uft.size[par2];
        }
        ans.push_front(ans[0] - num);
        uft.unite(bridges[i].first, bridges[i].second);
    }

    for(auto e: ans){
        cout << e << endl;
    }

    return 0;
}


Measured memory_bytes: 4212
#include <stdio.h>
int main(void) {
  
  int i;
  int N;
  int A[200010];
  int B[200010];
  scanf("%d",&N);
  for(i = 1; i <= N; i++){
      B[i] = 0;
  }
  for(i = 2; i <= N ; i++){
      scanf("%d",&A[i]);
  }
  for(i = 2; i <= N ; i++){
      B[A[i]] += 1;
  }
  for(i = 1; i <= N; i++){
      printf("%d\n",B[i]);
  }
  
  return 0;
}

Measured memory_bytes: 3288
#!/usr/bin/env python3
import sys
from itertools import chain


def max_add_1_to_n(loop, n):
    # print('  max_add_1_to_n', loop, n)
    l = len(loop)
    acc = loop.copy()
    # print('    ', acc)
    max_val = max(acc)
    for i in range(1, n):
        for j in range(0, l):
            acc[j] += loop[(i + j) % l]
        # print("    ", acc)
        max_val = max(max(acc), max_val)
    return max_val


def max_add_0_to_n(loop, n):
    # print('  max_add_0_to_n', loop, n)
    if n >= 1:
        return max(max_add_1_to_n(loop, n), 0)
    else:
        return 0


def max_loop_k(loop, K):
    l = len(loop)
    if K <= 2 * l:
        return max_add_1_to_n(loop, K)
    # K は 2 * l より長い
    l_sum = sum(loop)
    if l_sum <= 0:
        return max_add_1_to_n(loop, l)
    else:
        Kdiv = K // l
        Kmod = K % l
        # print('  l Kdiv Kmod', l, Kdiv, Kmod)
        return max_add_0_to_n(loop, l + Kmod) + l_sum * (Kdiv - 1)


def solve(N: int, K: int, P: "List[int]", C: "List[int]"):
    # 簡単のためインデックスを 0 からにする
    # (使用済みは -1 を入れる)
    P = [i - 1 for i in P]
    answer = -float("inf")
    for i0 in range(N):
        if P[i0] == -1:
            continue
        loop = []
        i = i0
        while P[i] != -1:
            loop.append(C[i])
            i_next = P[i]
            P[i] = -1
            i = i_next
        answer = max(answer, max_loop_k(loop, K))

    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, K, P, C)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 74356
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  	int N;
  	cin >> N;
  	vector<int> a(N);
  	for(int i = 0; i < N; i++){
      	cin >> a.at(i);
    }
  	sort(a.begin(), a.end());
  	int c = 1, ans = 0;
  	for(int i = N - 1; i >= 0; i--){
      	ans += a.at(i) * c;
      	c *= -1;
    }
  	cout << ans;
	return 0;
}

Measured memory_bytes: 256