akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li a[200200];

int main() {
    cin >> n;
    rin{
        cin >> a[i];
    }
    li res = 0;

    map<li, li> l;
    rin{
        // a[0] + a[i] == i
        res += l[i - a[i]];
        l[a[i] + i]++;
    }

    map<li, li> r;
    for (li i = n - 1; i >= 0; i--) {
        // a[n-1] + a[i] == n-1-i
        res += r[n - 1 - i - a[i]]; //
        r[a[i] + n - 1 - i]++;
    }
    cout << res / 2 << endl;


    return 0;
}

Measured memory_bytes: 50576
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	c0, c1 := 0, 0
	for _, r := range s {
		switch r {
		case '0':
			c0++
		case '1':
			c1++
		}
	}
	if c0 > c1 {
		fmt.Println(c1 * 2)
	} else {
		fmt.Println(c0 * 2)
	}
}


Measured memory_bytes: 1280
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <stdio.h>
using namespace std;
const int maxn=1e5+100;
int a[maxn];
char sto[maxn],st[maxn];
int n;
int jj(int mid,int left,int right)
{
	if (sto[mid]=='w')
		{
			if (a[mid]==0)
			{
				if (sto[left]==sto[right])
					return 0;
			}
			else
			{
				if (sto[left]!=sto[right])
					return 0;
			}
		}
		else if (sto[mid]=='l')
		{
			if (a[mid]==0)
			{
				if (sto[left]!=sto[right])
					return 0;
			}
			else
			{
				if (sto[left]==sto[right])
					return 0;
			}
		}
		return 1;
}
int judge()
{
	for (int i=1;i<n-2;i++)
	{
		if (sto[i]=='w')
		{
			if (a[i]==1)
				sto[i+1]=sto[i-1];
			else
			{
				if (sto[i-1]=='w')
					sto[i+1]='l';
				else
					sto[i+1]='w';
			}
		}
		else if (sto[i]=='l')
		{
			if (a[i]==1)
			{
				if (sto[i-1]=='w')
					sto[i+1]='l';
				else
					sto[i+1]='w';
			}
			else
				sto[i+1]=sto[i-1];
		}
	}
	if (jj(n-2,n-3,n-1)&&jj(n-1,0,n-2))
	return 1;
	return 0;	
}
void print()
{
	for (int i=0;i<n;i++)
	{
		if (sto[i]=='w')
			cout<<"W";
		else
			cout<<"S";
	}
	cout<<endl;
}
int main()
{
	cin>>n;
	char ch;
	for (int i=0;i<n;i++)
	{
		cin>>ch;
		if (ch=='o')
			a[i]=0;
		else if (ch=='x')
			a[i]=1;
	}
	if (a[0]==0)
	{
		sto[0]='w';sto[1]='l';sto[n-1]='w';
		if (judge())
		{
			print();
			return 0;
		}
		sto[0]='w';sto[1]='w';sto[n-1]='l';
		if (judge())
		{
			print();
			return 0;
		}
		sto[0]='l';sto[1]='w';sto[n-1]='w';
		if (judge())
		{
			print();
			return 0;
		}
		sto[0]='l';sto[1]='l';sto[n-1]='l';
		if (judge())
		{
			print();
			return 0;
		}
	}
	else if (a[0]==1)
	{
		sto[0]='l';sto[1]='l';sto[n-1]='w';
		if (judge())
		{
			print();
			return 0;
		}
		sto[0]='l';sto[1]='w';sto[n-1]='l';
		if (judge())
		{
			print();
			return 0;
		}
		sto[0]='w';sto[1]='w';sto[n-1]='w';
		if (judge())
		{
			print();
			return 0;
		}
		sto[0]='w';sto[1]='l';sto[n-1]='l';
		if (judge())
		{
			print();
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
} 

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int n,a[1005];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	cout<<abs(a[n-1]-a[0]);
	return 0;
}

Measured memory_bytes: 256
N=int(input())
AB=[]
for i in range(N):
    ab=list(map(int,input().split()))
    AB.append(ab)
AB=sorted(AB,key = lambda x:x[1])
S=0
flag=0
for i in range(N):
    S+=AB[i][0]
    if S> AB[i][1]:
        print("No")
        flag=1
        break
if flag == 0:
    print("Yes")


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

typedef long long ll;

int main()
{
    ll n, x;
    ll ans, c;
    cin >> n >> x;
    vector<int> a(n), b(n - 1);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    ans = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] + a[i + 1] < x)
            continue;
        if (min(a[i], a[i + 1]) >= x)
        {
            c = a[i + 1] + a[i] - x;
            a[i] = x;
            a[i + 1] = 0;
        }
        else
        {
            c = a[i + 1] + a[i] - x;
            a[i + 1] -= c;
        }
        ans += c;
    }
    cout << ans << endl;
}


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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S1, S0;
    cout << "0" << endl << flush;
    
    cin >> S1; if (S1 == "Vacant") return 0;
    S0 = S1;
    
    int left = 0, right = N-1;
    int middle0 = 0;
    int middle1 = (left + right)/2;
    cout << middle1 << endl << flush;
    cin >> S1; if (S1 == "Vacant") return 0;
    char state = 'r';
    rep(i, 18) {
        //dump(state); dump(S1 == S0); dump(abs(middle1-middle0) % 2);
        if (state == 'r' && S1 == S0 && abs(middle1-middle0) % 2 == 0 || 
        state == 'r' && S1 != S0 && abs(middle1-middle0) % 2 == 1) {
            left = middle1+1;
            int tmp = middle1;
            middle1 = (left + right)/2;
            middle0 = tmp;
        }
        else if (state == 'l' && S1 == S0 && abs(middle1-middle0) % 2 == 0 || 
        state == 'l' && S1 != S0 && abs(middle1-middle0) % 2 == 1) {
            right = middle1-1;
            int tmp = middle1;
            middle1 = (left + right)/2;
            middle0 = tmp;
        }
        else if (state == 'r' && S1 != S0 && abs(middle1-middle0) % 2 == 0 || 
        state == 'r' && S1 == S0 && abs(middle1-middle0) % 2 == 1) {
            right = middle1-1;
            int tmp = middle1;
            middle1 = (left + right)/2;
            middle0 = tmp;
            state = 'l';
        }
        else if (state == 'l' && S1 != S0 && abs(middle1-middle0) % 2 == 0 || 
        state == 'l' && S1 == S0 && abs(middle1-middle0) % 2 == 1) {
            left = middle1+1;
            int tmp = middle1;
            middle1 = (left + right)/2;
            middle0 = tmp;
            state = 'r';
        }
        //dump(left); dump(right);
        cout << middle1 << endl << flush;
        S0 = S1;
        cin >> S1; if (S1 == "Vacant") return 0;
    }





    return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
long int power(long int x, long int n, long int waru){
  long int tmp;
 
  if(n == 0){
    return 1;
  }
  tmp = power(x*x%waru, n/2, waru);
  if(n % 2 == 1){
    tmp = tmp * x % waru;
  }
  return tmp;
}

int main(void){
  long int m, n, ans;
 
  scanf("%ld%ld", &m, &n);
  ans = power(m, n, 1000000007);
  printf("%ld\n", ans);
  return 0;
}
 



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

int main(){
  int N;
  bool ans = true;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    if(A.at(i)%2==0){
      if(A.at(i)%3!=0&&A.at(i)%5!=0){
        ans = false;
        break;
      }
    }
  }
  if(ans==true){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 3636
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int n,a[60];
int box[5];
ll x=1;

int main(){
    I(n);
    REP(i,n){
        I(a[i]);
        box[a[i]+2]++;
    }
    int ret = 0;
    ret += box[4];

    if (box[0] & 1){
        if (box[1]){
            ret += box[0] + 1;
            cout << ret << endl;
            bool flag = true;
            REP(i,n){
                if (a[i] == 2 || a[i] == -2) cout << i+1 << endl;
                if (flag && a[i] == -1) {
                    cout << i+1 << endl;
                    flag = false;
                }
            }
        } else {
            box[0]--;
            ret += box[0];
            cout << ret << endl;
            REP(i,n){
                if (a[i] == 2) cout << i+1 << endl;
                if (a[i] == -2 && box[0]) {
                    cout << i+1 << endl;
                    box[0]--;
                }
            }
        }
    } else {
        ret += box[0];
        cout << ret << endl;
        REP(i,n){
            if (a[i] == 2 || a[i] == -2) cout << i+1 << endl;
        }
    }
}



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

int main(){
  int n;
  cin>>n ;
  long l[n];

  for(int i = 0;i<n;i++){
    cin>>l[i];
  }
 int kind=0;

 for(int i=0;i<=n-3;i++){
   for(int j=i+1;j<=n-2;j++){
     for(int k=j+1;k<n;k++){
       if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]&&l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[k]+l[i]>l[j]){
         kind=kind+1;
       }
     }
   }
 }
 cout<<kind<<endl;
  
}

Measured memory_bytes: 3648
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>

#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

bool check(llong P, vector<llong> &W, llong k){
    vector<llong> Track(k,0);
    llong track_idx=0;
    for(int i=0; i<W.size();){
        if((Track[track_idx]+W[i])<=P){
            Track[track_idx] += W[i];
            i++;
            continue;
        }
        track_idx++;
        if(track_idx==Track.size()){
            return false;
        }
    }
    return true;
}

int main(){
    llong n, k;
    cin >> n >> k;
    vector<llong> W(n);
    for(int i=0; i<W.size(); i++){
        cin >> W[i];
    }

    llong right=1000000000000, left=0;
    llong mid;

    while((right-left)>1){
        mid = (right+left)/2;
        if(check(mid, W, k)){
            right = mid;
        }else{
            left = mid;
        }
    }
    cout << right << endl;
    return 0;
}






Measured memory_bytes: 4460
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
    set<int> s;
    int q, x, y;
  	cin >> q;
    for (int i = 0; i < q; i++){
        cin >> y >> x;
        if (y == 0) {
            s.insert(x);
            cout << s.size() << endl;
        }
        else {
            auto t = s.find(x);
            if (t != s.end()) cout << 1 << endl;
            else cout << 0 << endl;
        }
        
    }
	return 0;
}


Measured memory_bytes: 12468
from itertools import permutations


def solve():
    A, B, C = map(str, input().split())
    ans = 0
    for a, b, c in permutations(A + B + C, 3):
        ans = max(ans, int(a + b) + int(c))
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
    int x, y, r, w, h;
    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
    if((x>w) || (y>h)){
        printf("No\n");
    }else if ((x<0) || (y<0)){
        printf("No\n");
    }else if ((x+r>w) || (y+r>h)){
        printf("No\n");
    }else if ((x-r<0) || (y-r<0)){
        printf("No\n");
    }else {
        printf("Yes\n");
    }
}


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

int main(){
	long long int a,b,c;
	cin >> a >> b >> c;
  	if(c-a-b > 0){
      if((4*a*b) < ((c-a-b)*(c-a-b))) cout << "Yes" << endl;
  	  else cout << "No" << endl;
    }else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  ll n,k,maxi=0;
  cin>>n>>k;
  ll p[n],sum[n+1];
  sum[0]=0;
  rep(i,n){
    cin>>p[i];
    sum[i+1]=sum[i]+p[i];
  }
  for(ll i=0;i<=n-k;i++){
    maxi=max(maxi,sum[i+k]-sum[i]);
  }
  cout<<setprecision(12)<<((double)maxi+k)/2;
}


Measured memory_bytes: 3328
input_number = int(input())
number_list_A = (1,2,3,4,5,6,7,8,9)
number_list_B = number_list_A
number_list_AB = []

for a in number_list_A:
	a = int(a)
	for b in number_list_B:
		b = int(b)
		number_list_AB.append(a*b)

if input_number in number_list_AB:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
#include <stdio.h>
int n;//数字を入力
int cnt = 0;//同じ数字をカウント
int nums[4];//四文字を入れるための配列
int flag = 0;//三文字以上の文字列を見つけた時のフラグ
int main() {
	scanf("%d", &n);
	for (int i = 0; i < 4; i++) {
		nums[i] = n % 10;
		
		n = (int)(n / 10.0);
	}
	/*for (int i = 0; i < 4; i++) {
		printf("%d ", nums[i]);
	}
	printf("\n");*/
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			if(nums[i] == nums[j] ) {
				if (nums[j] == nums[j - 1] || j == 0 || j==1) {
					cnt++;
				}
			}
		}
		if (cnt >= 3) {
			flag = 1;
			break;
		}
		cnt = 0;
	}
	if (flag == 1) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}


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

using namespace std;
long long dp[5005][5005];
long long mod = 1e9+7;
string s;

signed main()
{
    long long n;
    cin>>n>>s;

    dp[0][0] = 1;
    for(long long j=1;j<=n;j++)
    {
        dp[0][j] += (dp[0][j-1] + dp[1][j-1]*2 )%mod;
        dp[0][j] %= mod;
        for(long long i=1;i<=n;i++)
        {
            dp[i][j] += dp[i-1][j-1] + dp[i+1][j-1]*2 ;
            dp[i][j] %= mod;
        }
    }

    long long sz = s.length();
    cout<<dp[sz][n];
}


Measured memory_bytes: 195840
import math
k=int(input())
s=0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            if math.gcd(a,b) == 1 or math.gcd(b,c)==1 or math.gcd(c,a)==1:
                s+=1
            else:
                g=math.gcd(a,b)
                s+=math.gcd(g,c)
print(s)

Measured memory_bytes: 73792
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char S[500011];

bool ok(int mid) {
    int carry = mid;
    int sum = 0;
    REP (i, N) {
	carry += (S[i]-'0')*9;
	sum += carry % 10;
	carry /= 10;
    }
    while (carry) {
	sum += carry % 10;
	carry /= 10;
    }
    return sum <= mid;
}

void MAIN() {
    scanf("%s", S);
    N = strlen(S);
    reverse(S, S+N);

    int lo = 0, hi = 1;
    while (!ok(hi)) {
	lo = hi;
	hi += hi;
    }
    while (hi - lo > 1) {
	int mid = (lo+hi)/2;
	(ok(mid)? hi: lo) = mid;
    }
    eprintf("%d\n", hi);
    printf("%d\n", (hi+8)/9);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxM = 1e5+7;
const int maxV = 90010;
 
const int MOD = 1e9+7;
 
int T;
const int maxN = 1e5+8;
const ll INF = 1000000000000000010LL;
const int K = 15;
ll a[maxN];
ll b[maxN];
pii c[maxN];
string s[maxN];
vector<int> d[maxN];
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		d[x].push_back(y);
	}
	priority_queue<int> Q;
	ll ans = 0;
	for(int i = 1;i<=m;i++)
	{
		for(auto e:d[i])
		{
			Q.push(e);
		}
		if(!Q.empty())
		{
			ans += Q.top();
			Q.pop();
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7424
#include <stdio.h>

int main()
{
  int num;
  double weight,hight;
  while (scanf("%d,%lf,%lf",&num,&weight,&hight)!=EOF){
    double bmi=weight/(hight*hight);
    if (bmi>=25)
      printf("%d\n",num);
  }

  return 0;
}

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


int main()
{
int a , b ;
cin >> a >> b ;
for (int i = 1; i<=1500 ; i++){
        int x= i*0.08, y=0.1*i;
    if (x==a&&y==b){
        cout << i;
        return 0;
    }
}
cout << -1;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cctype>
#include <cmath>
#include <cassert>
#include <bitset>
using namespace std;

#define dump(a) (cerr << #a << " = " << (a) << endl)
constexpr double EPS = 1e-9;

struct point {
  double x, y;
  point(double x_ = 0.0, double y_ = 0.0):x(x_), y(y_) {}
  point(const point &p):x(p.x), y(p.y) {}

  point operator+(const point &p) const {
	return point(x + p.x, y + p.y);
  }

  point operator-(const point &p) const {
	return point(x - p.x, y - p.y);
  }
};

ostream &operator<<(ostream &os, const point &p) {
  return os << '(' << p.x << ", " << p.y << ')';
}

double angle(const point &p) {
  return atan2(p.y, p.x);
}

double norm(const point &p) {
  return p.x * p.x + p.y * p.y;
}

double normalize(double theta) {
  if(theta < -M_PI) return theta + 2 * M_PI;
  if(theta > M_PI) return theta - 2 * M_PI;
  return theta;
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout.precision(1);
  cout.setf(ios::fixed);
  constexpr double INF = 1e9;

  for(int n; cin >> n && n;) {
	vector<point> flags;
	flags.reserve(n);

	for(int i = 0; i < n; ++i) {
	  double x, y;
	  cin >> x >> y;
	  flags.emplace_back(x, y);
	}

	double ans = 0.0;
	point pos(0, 0);
	double dir = M_PI / 2;
	bitset<400> visited;

	for(int i = 0; i < n; ++i) {
	  pair<double, double> best(INF, INF);
	  int next = -1;
	  double next_angle;

	  for(int v = 0; v < n; ++v) {
		if(visited[v]) continue;

		double dist2 = norm(flags[v] - pos);
		double theta = normalize(dir - angle(flags[v] - pos));

		pair<double, double> tmp(theta, dist2);

		if(tmp < best) {
		  best = tmp;
		  next = v;
		  next_angle = angle(flags[v] - pos);
		}
	  }

	  assert(next != -1);

	  ans += sqrt(best.second);
	  pos = flags[next];
	  dir = next_angle;
	  visited.set(next);
	}

	cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1396
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll N;
  cin >>N;
  string S;
  cin >>S;
  ll lef=0;
  ll rig=0;
  string s;
  rep(i,N) {
    if(S.at(i)=='(') {
      lef++;
    }
    else if(S.at(i)==')') {
      rig++;
    }
    if(rig>lef) {
      while(rig>lef) {
      s=s+"(";
        lef++;
      }
    }
    else {
      continue;
    }
    
    
  }
  S=s+S;
  lef=0;
  rig=0;
  rep(i,S.size()) {
     if(S.at(i)=='(') {
      lef++;
    }
    else if(S.at(i)==')') {
      rig++;
    }
  }
    
  
  if(lef>rig) {
    rep(i,lef-rig) {
      S=S+')';
    }
  }
  
  
  cout<<S<<endl;
}
      

  
  
        
      
      
    
  
  
  

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

int main(){
  int N; cin >> N;
  int res = 0;
  int counter = 0;
  for(int i=0; i<N; i++){
    int a, b;
    cin >> a >> b;

    if (a==b) counter++;
    else counter = 0;

    res = max(counter, res);
  }
  cout << ((res >= 3) ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n;
vector<ll> G[200100];
ll used[200100]={};

ll bfs(ll s){
	queue<ll> q1;
	used[s]=1;
	ll count_x=0;
	ll count_y=0;
	ll count_e=0;
	q1.push(s);
	while(q1.size()){
		ll qt=q1.front();q1.pop();
		count_e+=G[qt].size();
		if(qt<=100000)count_x++;
		else count_y++;
		for(ll i=0;i<G[qt].size();i++){
			if(used[G[qt][i]]==0){
				used[G[qt][i]]=1;
				q1.push(G[qt][i]);
			}
		}
	}
	count_e/=2;
	//cout<<"x:"<<count_x<<" y:"<<count_y<<" e:"<<count_e<<endl;
	return count_x*count_y-count_e;
}
int main(){
	cin>>n;
	REP(i,n){
		ll x,y;
		cin>>x>>y;
		y+=100000;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	ll ans=0;
	for(ll i=0;i<=100000;i++){
		if(used[i])continue;
		if(G[i].size()==0)continue;
		ans+=bfs(i);
		//cout<<i<<" "<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    string ans = "No";
    if (n >= 30) ans = "Yes";

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

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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  
  int n = a / k;
  if (n * k < a && b < (n + 1) * k ) {
    cout << "NG" << endl;
  }
  else {
    cout << "OK" << endl;
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int d, t, s;
  cin >> d >> t >> s;

  cout << (s * t >= d ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3536
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = Long.parseLong(sc.next());
        long d = Long.parseLong(sc.next());

        long n = b - a + 1;
        long cc = (b / c) - ((a - 1) / c);
        long dd = (b / d) - ((a - 1) / d);
        long cd = (b / lcm(c, d)) - ((a - 1) / lcm(c, d));

        System.out.println(n - cc - dd + cd);

    }

    static long gcd(long a, long b) {
        return b > 0 ? gcd(b, a % b) : a;
    }

    static long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }
}


Measured memory_bytes: 21716
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int Maxn = 1e5 + 5;
const int inf = 1 << 30;
const LL Inf = 1LL << 60;
int main ()
{
	LL a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	LL s;
	s = a*b*c;
	if (s%2 == 0) printf("0");
	if (s%2 == 1)
		{
			LL d;
			d = min(a*b,b*c);
			d = min(d,a*c);
			printf("%lld",d);
			}
	return 0;
	}

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

int main(){
  int n;
  cin >> n;
  vector<int> data(n);
  for(int i = 0; i < n; i++){
    cin >> data.at(i);
  }
  
  int x = n * (n - 1) / 2;
  vector<int> answer(x, 0);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i == j){
        continue;
      } 
      else{ 
      int c = data.at(i) * data.at(j);
      answer.push_back(c);
      }
    }
  }
  int count = 0;
  for(auto y : answer){
    
    count += y;
  }
  cout << count / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<pair<pp,pp> >
#define pq_min priority_queue<ll,vector<ll>,greater<ll>>
#define pq_max priority_queue<ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define r(i,a,b) for(ll i=a;i>=b;i--)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair<pp,pp> ppll;
const ll mod=1e9+7;
const ll N=2e18 + 5;

ll power(ll a,ll b,ll p)
{
    a=a%p;
    ll ans=1;
    while(b>0)
    {
        if(b%2==1)
        {
            ans=(ans*a)%p;
        }
        b=b/2;
        a=(a*a)%p;
    }
    return ans;
}

 
int main()
{
    fast;
    ll k,n;
    cin>>k>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll b[n+1];
    b[0]=(k-a[n-1]+a[0]);
    for(ll i=1;i<n;i++)
    {
        b[i]=a[i]-a[i-1];
    }
    ll ans=k;
    for(ll i=0;i<n;i++)
    {
        ans=min(ans,k-b[i]);
    }
    cout<<ans;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        if ("Sunny".equals(s)) {
            System.out.println("Cloudy");

        } else if ("Cloudy".equals(s)) {
            System.out.println("Rainy");

        } else {
            System.out.println("Sunny");

        }
    }
}


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

int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  
  if(e-a<=k){
    cout<<"Yay!"<<endl;
  }
  else{
    cout<<":("<<endl;
  }
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
const ll MAX = 4;
ll LIMIT = 45;

ll A[MAX][MAX];
ll x[4] = {0, 1, 0, -1};
ll y[4] = {1, 0, -1, 0};
pll P[MAX * MAX + 1];

ll dfs(pll s, ll match, pll prev = pll(-1, -1), ll cnt = 0) {
    if (match == MAX * MAX - 1) {
        return cnt;
    }

    if (MAX * MAX - 1 - match + cnt > LIMIT)
        return INF;
    if (LIMIT <= cnt)
        return INF;
    if (LIMIT < cnt + (MAX - s.first - 1) + (MAX - s.second - 1))
        return INF;

    ll diff = 0;
    REP(i, MAX) {
        REP(j, MAX) {
            ll t = A[i][j];
            if (t == 0)
                continue;
            pll p = P[t];
            diff += abs(p.first - i) + abs(p.second - j);
        }
    }
    if (cnt + diff > LIMIT)
        return INF;

    ll ret = INF;
    REP(i, 4) {
        ll nx = x[i] + s.first, ny = y[i] + s.second;
        if (nx < 0 || ny < 0 || nx >= MAX || ny >= MAX)
            continue;
        if (prev.first == nx && prev.second == ny)
            continue;
        ll m = match;
        if (A[nx][ny] == nx * MAX + ny + 1)
            m--;
        else if (A[nx][ny] == s.first * MAX + s.second + 1)
            m++;
        swap(A[s.first][s.second], A[nx][ny]);
        ret = std::min(ret, dfs(pll(nx, ny), m, s, cnt + 1));
        LIMIT = std::min(LIMIT, ret);
        swap(A[s.first][s.second], A[nx][ny]);
    }
    return ret;
}

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

    pll s;
    REP(i, MAX) {
        REP(j, MAX) {
            cin >> A[i][j];
            if (A[i][j] == 0)
                s = pll(i, j);
        }
    }

    REP(i, MAX) {
        REP(j, MAX) {
            ll n = i * MAX + j + 1;
            P[n] = pll(i, j);
        }
    }
    P[0] = pll(MAX - 1, MAX - 1);

    ll match = 0;
    REP(i, MAX) {
        REP(j, MAX) {
            ll num = i * MAX + j + 1;
            if (A[i][j] == num)
                match++;
        }
    }

    cout << dfs(s, match) << endl;
    return 0;
}


Measured memory_bytes: 3220
#include <stdio.h>

int GCD (int a, int b) {
	int c;
	c = a % b;
	if (c == 0) {
		return b;
	} else {
		return GCD (b, c);
	}
	
}

int main () {
	int x, y, z;
	
	while (scanf("%d %d", &x, &y) != EOF) {
		
		z = GCD (x, y);
		
		printf ("%d\n", z);
	}
	
	return 0;
}

Measured memory_bytes: 596
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val a = new Array[Int](n)
    for (i <- 0 until n) {
      a(i) = sc.nextInt
    }

    val aWithIndex = a.zipWithIndex.sortBy(_._1)

    val pw = new java.io.PrintWriter(System.out)
    for (i <- 0 until n) {
      pw.println(aWithIndex(i)._2 + 1)
    }
    pw.flush()
  }
}


Measured memory_bytes: 75628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 2e7+5;
ll a[N];
ll b[N];
void solve(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[a[i]]++;
    }
    sort(a,a+n);
    int ans = 0;
    for(int i=00;i<n;i++){
        for(int j=i+1;j<n;j++){
            int x = a[i]+a[j];
            int cnt=  1;
            if(a[i]==a[j])cnt=2;
            int y = (upper_bound(a,a+n,x-1)-a);
            if(y>j)ans+=y-j-1;
        }
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()



int main()
{
	int x; cin >> x;
	if (x == 3 || x == 5 || x == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
//==========================================
// ABC141d
//
// 2019/09/15
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  int n, m;
  cin >> n >> m;
  vector<long> a(n);
  for(int i=0; i<n; ++i)
  {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<long>());

  long maxi=0;
  for(int i=0; i<m; ++i)
  {
    a[maxi] /= 2;
    if(maxi >= n-1 || a[0] >= a[maxi + 1])
    {
      sort(a.begin(), a.end(), greater<long>());
      maxi=0;
    }
    else
    {
      maxi++;
    }
  }

  long sum=0;
  for(auto x: a) sum += x;
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<set>
#include<iomanip>
#include<utility>
#include<deque>
#include<vector>
#include<locale>
#include<sstream>
#define f(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
using namespace std;
int n,a[100001],x,ans;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(x>n) ans++;
        else a[x]++;
    }
    for(int i=1;i<=n;i++){
        if(a[i]==0) continue;
        if(a[i]<i) ans+=a[i];
        else if(a[i]>i) ans+=a[i]-i;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<vector>
#include<cstdio>
#include<climits>
#include<cfloat>
#include<cstring>
#define foreach(t,p) for(t::iterator it=p.begin();it!=p.end();++it)
#define rforeach(t,p) for(t::reverse_iterator it=p.rbegin();it!=p.rend();++it)
#define all(p) p.begin(),p.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define FOREACH(t,p,tit) for(t::iterator tit=p.begin();tit!=p.end();++tit)
using namespace std;
char tiles[110][110];

int main()
{
    int w,h;
    while(cin >> h >> w)
    {
        memset(tiles,'.',sizeof(tiles));
        if(w==0&&h==0){break;}
        rep(j,h)rep(i,w){cin >> tiles[i][j];}

        int x,y,nextx,nexty;
        x=0;
        y=0;
        int loop = 0;
        char nowtile;
        while(1)
        {
            nowtile = tiles[x][y];
            tiles[x][y] = 'x';
            if(nowtile=='x'){loop=1;break;}
            if(nowtile=='.'){break;}
            if(nowtile=='>'){x++;continue;}
            if(nowtile=='<'){x--;continue;}
            if(nowtile=='v'){y++;continue;}
            if(nowtile=='^'){y--;continue;}

        }
        if(loop){cout << "LOOP"<<endl;continue;}
        //cout <<x << " "<<y << endl;
        printf("%d %d\n",x,y);
    }

    return 0;
}

Measured memory_bytes: 0
n=int(input())
hani=[]
for i in range(n):
    x,l=map(int,input().split())
    hani.append([x-l,x+l])
hani2=sorted(hani)
#print(hani2)
no=0 #削除するロボット
bef=0
af=1
for i in range(n-1):
    a,b,a2,b2=hani2[bef][0],hani2[bef][1],hani2[af][0],hani2[af][1]
    if a<=a2<b:
        no+=1
        if b<b2: #前者を採用
            af+=1
        else:
            bef=af
            af+=1
    else:
        bef=af
        af+=1
print(n-no)

Measured memory_bytes: 59992
// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.
import java.util.*;
import java.io.*;

class Main
{
	public static void main(String[] args)
	{
		new Main().run();
	}
	
	void run(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] A=new int[N];
		int[] A_diff=new int[2*N-1];
		int[] B=new int[N];
		int[] B_diff=new int[N];
		for(int i=0;i<N;++i)A[i]=sc.nextInt();
		for(int i=0;i<N;++i)B[i]=sc.nextInt();
		for(int i=0;i<N;++i)A_diff[i]=A[i]^A[(i+1)%N];
		for(int i=0;i<N;++i)B_diff[i]=B[i]^B[(i+1)%N];
		for(int i=0;i<N-1;++i)A_diff[i+N]=A_diff[i];
		boolean[] search=search(A_diff,B_diff);
		int ans=0;
		PrintWriter pw=new PrintWriter(System.out);
		for(int i=0;i<N;++i){
			if(search[i]){
				pw.println(i+" " +(B[0]^A[i]));
			}
		}
		pw.close();
	}
	
	boolean[] search(int[] a,int[] b){
		int[] border=border(b);
		boolean[] ret=new boolean[a.length];
		int s=0,t=0,match=0;
		for(int i=0;i<a.length;++i){
			while(match>=0&&(match>=b.length||b[match]!=a[i]))match=(match==0?-1:border[match-1]);
			++match;
			if(match==b.length){ret[i-match+1]=true;}
		}
		return ret;
	}
	
	int[] border(int[] b){
		int n=b.length;
		int[] pat=new int[n];
		int match=0;
		for(int i=1;i<n;++i){
			while(match>=0&&b[i]!=b[match])
				match=(match==0?-1:pat[match-1]);
			++match;
			pat[i]=match;
		}
		return pat;
	}
	
	void tr(Object...o){System.out.println(Arrays.deepToString(o));}
}

// OpenJDK reference:
//   http://openjdk.java.net/

// Java language references:
//   http://docs.oracle.com/javase


Measured memory_bytes: 139344
X = str(input())

#末尾2桁を取り出す
last2 = int(X[len(X)-2::])

#last2をできるだけ少ないものの個数で処理する
pc = last2//5
last2 = last2 % 5
candy = last2//4
last2 = last2 % 4
cake = last2//3
last2 = last2 % 3
cookie = last2//2
last2 = last2 % 2
sandwitch = last2//1
last2 = last2 % 1

X = int(X)-105*pc-104*candy-103*cake-102*cookie-101*sandwitch

if X%100==0 and X>=0:
  print(1)
else:
  print(0)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] row = new int[sc.nextInt()];
		for(int i = 0; i < row.length; i++){
			row[i] = i + 1;
		}
		int ctimes = sc.nextInt();
	
		sc.nextLine();
		for(int j = 0; j < ctimes; j++){
			int[] ch = new int[2];
			String[] s = sc.nextLine().split(",");
			ch[0] = Integer.parseInt(s[0]) -1;
			ch[1] = Integer.parseInt(s[1]) -1;
			
			int temp = row[ch[0]];
			row[ch[0]] = row[ch[1]];
			row[ch[1]] = temp;
		}

		for(int i = 0; i < row.length; i++){
			System.out.println(row[i]);
		}
	}
}

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

long long mod=1e9+7;

long long qpow(long long base,long long times)
{
	long long res=1;
	long long tmp=base%mod;
	while(times>0)
	{
		if(times%2==1)
			res=(res*tmp)%mod;
		tmp=(tmp*tmp)%mod;
		times/=2;
	}
	return res%mod;
}

long long C(long long n, long long m)
{
	long long ans=1;
	for(long long i=1;i<=m;i++)
	{
		ans=ans*(n-m+i)%mod;
		ans=ans*qpow(i,mod-2)%mod;
	}
	return ans%mod;
}

int main()
{
	long long ans;
	long long n,x,y;
	cin>>n>>x>>y;
	ans=qpow(2,n)-1;
	cout<<((ans-C(n,x)+mod)%mod-C(n,y)+mod)%mod<<endl;
}

Measured memory_bytes: 256
n, ma, mb = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(n)]

INF = 40 * 100 + 1
ab_max = 10 * n

dp = [[[INF] * (ab_max + 1) for _ in range(ab_max + 1)] for _ in range(n + 1)]
dp[0][0][0] = 0

for i, (a, b, c) in enumerate(abc, 1):
    for j in range(ab_max + 1):
        for k in range(ab_max + 1):
            dp[i][j][k] = dp[i-1][j][k]
            if j - a >= 0 and k - b >= 0:
                if dp[i-1][j-a][k-b] != INF:
                    dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-a][k-b] + c)


ans = INF
for j in range(1, ab_max + 1):
    for k in range(1, ab_max + 1):
        if j * mb == k * ma:
            ans = min(ans, dp[n][j][k])

if ans == INF:
    ans = -1

print(ans)


Measured memory_bytes: 98012
program ABC170D
    implicit none
    integer(8)::N,i,j,ans=0,amax,as,flg
    integer(8),allocatable::A(:),B(:)
    read*,N
    allocate(A(N))
    read*,A
    amax=maxval(A)
    allocate(B(amax))
    B=0
    call heapsort(N,A)
    do i=1,N
        B(A(i))=1
    end do

    flg=0
    do i=1,N-1
        if(A(i)/=A(i+1).and.flg==1)then
            flg=0
            A(i)=0
        else if(A(i)==A(i+1))then
            flg=1
            A(i)=0
            if(i==N-1)A(N)=0
        end if
    end do

    do i=1,N
        if(A(i)/=0)then
            as=int(sqrt(real(A(i))))
            flg=0
            do j=2,as
                if(mod(A(i),j)==0)then
                    if(B(j)==1.or.B(A(i)/j)==1)then
                        flg=1
                        exit
                    end if
                end if
            end do
            if(B(1)==1.and.A(i)/=1)flg=1
            if(flg==0)ans=ans+1
        end if
    end do

    print'(i0)',ans
end program ABC170D

subroutine heapsort(n,array)
    implicit none
    integer(8),intent(in) :: n
    integer(8),intent(inout) :: array(1:n)
   
    integer(8) ::i,k,j,l
    integer(8) :: t
   
    if(n.eq.1)return
  
    l=n/2+1
    k=n
    do while(k.ne.1)
       if(l.gt.1)then
          l=l-1
          t=array(L)
       else
          t=array(k)
          array(k)=array(1)
          k=k-1
          if(k.eq.1) then
             array(1)=t
             exit
          endif
       endif
       i=l
       j=l+l
       do while(j.le.k)
          if(j.lt.k)then
             if(array(j).lt.array(j+1))j=j+1
          endif
          if (t.lt.array(j))then
             array(i)=array(j)
             i=j
             j=j+j
          else
             j=k+1
          endif
       enddo
       array(i)=t
    enddo
  
    return
end subroutine heapsort

Measured memory_bytes: 12312
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve(){
		UL Q; cin >> Q;
		multiset<LL> Al, Ar;
		Al.insert(-10000000000);
		Ar.insert(10000000000);
		LL B = 0;
		rep(i, Q) {
			UL c; cin >> c;
			if (c == 1) {
				LL a, b; cin >> a >> b;
				B += b;
				if (Al.size() == Ar.size()) {
					LL m = *--Al.end();
					if (a <= m) {
						B += m - a;
						Al.insert(a);
					}
					else if (a <= *Ar.begin()) {
						Al.insert(a);
					}
					else {
						Ar.insert(a);
						LL nm = *Ar.begin();
						B += a - nm;
						Al.insert(nm);
						Ar.erase(Ar.begin());
					}
				}
				else {
					LL m = *--Al.end();
					if (a <= m) {
						B += m - a;
						Al.insert(a);
						Ar.insert(max(a, m));
						Al.erase(--Al.end());
					}
					else {
						Ar.insert(a);
						B += a - m;
					}
				}
			}
			else if (c == 2) {
				cout << (*--Al.end()) << " " << B << endl;
			}
		}
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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

public class Main {
    public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] array = br.readLine().split(" ");

	int S = Integer.parseInt(array[0]), W = Integer.parseInt(array[1]);

	System.out.println(W >= S ? "unsafe" : "safe");
    }
}

Measured memory_bytes: 32404
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t = 1,n,m,x,y,id[100009];
set <ll> s;
ll find(ll x){return x == id[x] ? x : id[x] = find(id[x]);}
int main(){
	cin>>n>>m;
	for (ll i = 1;i <= n;i += 1) id[i] = i;
	for (ll i = 0;i < m;i += 1) cin>>x>>y,id[find(x)] = find(y);
	for (ll i = 1;i <= n;i += 1) s.insert(find(i));
	cout<<s.size() - 1;
	return 0;
}

Measured memory_bytes: 8096
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
 
using vd=vector<double>;
using vvd=vector<vd>;
 
 
int main(){
    int h,w;
    cin>>h>>w;
    vvi f(h+2,vi(w+2,1));
    vvi walk(h+2,vi(w+2,0));
    int gy,gx,y=0,x=0,v=0;
    range(i,1,h+1)range(j,1,w+1){
        char c;
        cin>>c;
        switch(c){
            case 'G': gy=i,gx=j,f[i][j]=0; break;
            case '.': f[i][j]=0;break;
            case '#': break;
            case '^': y=i,x=j,v=0,f[i][j]=0; break;
            case '>': y=i,x=j,v=1,f[i][j]=0; break;
            case 'v': y=i,x=j,v=2,f[i][j]=0; break;
            case '<': y=i,x=j,v=3,f[i][j]=0; break;
        }
    }
    walk[y][x]=1;
    rep(loop,3000){
        vvi vec={{-1,0},{0,1},{1,0},{0,-1}};
        if(f[y+vec[(v+1)%4][0]][x+vec[(v+1)%4][1]]==0){ //右手が道なら右に曲がって前に進む
            //cout<<"hoge";
            v=(v+1)%4;
            y+=vec[v][0], x+=vec[v][1];
            walk[y][x]=1;
        }else if(f[y+vec[v][0]][x+vec[v][1]]==1){ //（右が壁で、）正面が壁なら左に回る
            //cout<<"fuga";
            v=(v+3)%4;
        }else{ //そうでないならまえに進む
            //cout<<"zako";
            y+=vec[v][0],x+=vec[v][1];
            walk[y][x]=1;
        }
        if(y==gy&&x==gx){
            break;
        }
        // cout<<y<<","<<x<<","<<v<<endl;
        // rep(i,h+2){
        //     rep(j,w+2){
        //         if(i==y&&j==x){
        //             cout<<"^>v<"[v];
        //         }else{
        //             cout<<".#"[f[i][j]];
        //         }
        //     }
        //     cout<<endl;
        // }
    }
    if(y==gy&&x==gx){
        int ans=0;
        rep(i,h+2)rep(j,w+2)ans+=walk[i][j];
        cout<<ans<<endl;
    }else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3192
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

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

    int N = sc.nextInt();

    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }

    int count = selectionSort(A, N);

    printArray(A);
    System.out.println(count);
  }

  public static int selectionSort(int[] a, int n) {
    int count = 0;

    for (int i = 0; i < n; i++) {
      int minj = i;
      for (int j = i; j < n; j++) {
        minj = a[j] < a[minj] ? j : minj;
      }
      if (i != minj) {
        swap(a, i, minj);
        count++;
      }
    }

    return count;
  }

  private static void printArray(int[] a) {
    System.out.println(
      Arrays.stream(a)
        .mapToObj(String::valueOf)
        .collect(Collectors.joining(" ")));
  }

  public static void swap(int[] a, int n, int m) {
    int tmp = a[n];
    a[n] = a[m];
    a[m] = tmp;
  }
}


Measured memory_bytes: 32352