akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 1000000007
#define endl "\n"
const int INF = 1e18;
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
int32_t main() 
{
	fastio();
	map<string,int>mpp;
	mpp["SUN"]=0;
	mpp["MON"]=1;
	mpp["TUE"]=2;
	mpp["WED"]=3;
	mpp["THU"]=4;
	mpp["FRI"]=5;
	mpp["SAT"]=6;
	string s;
	cin>>s;
	cout<<7-mpp[s];
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <istream>
#include <assert.h>
#include <vector>
#include <cstdio>

using namespace std;

int main()
{
//    freopen("input.txt", "r", stdin);
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int a_b = (a-b);
    if(c <= a_b) b += c, c = 0;
    else b += a_b, c -= a_b;

    printf("%d\n", c);
    return 0;
}



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

#define ll long long

using namespace std;
const ll mod = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int inf  = 0x3f3f3f3f;
const ll  INF  = 0x3f3f3f3f3f3f3f3f;

string s[MAXN];
int mp[MAXN];
int p[MAXN];
int k[MAXN];
int mp1[MAXN];

int main()
{
	int n, m;
	int sum = 0;

	string s1 = "WA";
	string s2 = "AC";
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		cin >> p[i] >> s[i];
		if (s[i] == s2)
		{
			mp[p[i]] = -1;
		}
	}
	for (int i = 1; i < MAXN; i++)
	{
		if (mp[i] == -1)
		{
			sum++;
		}
	}
	cout << sum << " ";
	int sum1 = 0;
	for (int i = 1; i <= m; i++)
	{
		if (s[i] == s1)
		{
			if (mp[p[i]] == -1)
			{
				sum1++;
			}
		}
		else
		{
			mp[p[i]] = 0;
		}
	}
	cout << sum1;
	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define mod 1000000007  
//#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main(){
    //fast_cin();
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
        string s;
        cin>>s;
        vector<int> var;
        int count=0;
        for(int i=0;i<3;i++){
          if(s[i]=='R'){
            count++;}
            else{
              var.push_back(count);
              count=0;
            }
          }
          var.push_back(count);
            cout<<*max_element(var.begin(),var.end());
        
        
  
      
      }
    

      
        

      
       
    
    
  
      

      




Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve(){
	int n,m;
	cin>>n>>m;
	vector<int> heights(n,0);
	for(int i=0;i<n;i++){
		cin>>heights[i];
	}
	vector<vector<int>> g(n);
	vector<int> res(n,1);
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		if(heights[a-1] <=heights[b-1]){
			res[a-1] = 0;
		}
		if(heights[b-1]<=heights[a-1]){
			res[b-1] = 0;
		}
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		ans+=res[i];
	}
	cout<<ans<<endl;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 6356
'use strict'

function main(input) {
  input = input.split(' ').map(v => ~~v)

  const x = input[0]
  const a = input[1]
  const b = input[2]
  const c = a - b

  let ans = ''

  if (c >= 0) {
    ans = 'delicious'
  } else if (x + a >= b) {
    ans = 'safe'
  } else {
    ans = 'dangerous'
  }
  console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<iostream>
using namespace std; // 575

int main() {
	int N, H, high = 0, ans = 0;
	cin >> N;
	for (int i = 0;i < N;++ i) {
		cin >> H;
		if (high <= H) ++ ans;
		high = max(high, H);
	}
	cout << ans << endl;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

サンプル通らなかったんだけど改行の有無か？
*/

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> A(n);
	for(int i = 0; i < n; i++) {
		cin >> A[i];
	}
		
	int ans = 0;
	bool flag = false;

	while(1){
		for(int i = 0; i < n; i++) {
			if(A[i] % 2 == 0) {
				A[i] /= 2;
			}else{
				flag = true;
			}
		}
		if(flag) break;
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;

const int N=55;

ll dp[N][N][N*N];
ll a[N];
int32_t main(){
    ll n,k;
    cin >> n >> k;
    for (int i=0;i<n;i++){
        cin >> a[i];
    }
    for (int i=1;i<=n;i++){

        dp[i][1][a[i-1]]++;

        for (int j=1;j<=i;j++){
            for (int l=1;l<N*N;l++){
                dp[i][j][l]+=dp[i-1][j][l];
                ll p=l-a[i-1];
                if (p>=0)
                    dp[i][j][l]+=dp[i-1][j-1][p];

              //  cout << i << " " << j << " " << l << " " << dp[i][j][l] << endl;
            }
        }

    }
    ll ans=0;
    for (int i=0;i<N;i++){

        ans+=dp[n][i][i*k];
    }
    cout << ans;
}


Measured memory_bytes: 65792
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
long long dp[2100][2100];
long long sum[2100][2100];
int main(){
	init_C(4100);
	int a,b;scanf("%d%d",&a,&b);
	long long ret=1;
	for(int i=a;i>0;i--){
		for(int j=1;j<=b;j++){
			if(i-(b-j)<0)continue;
			dp[i-(b-j)][b-j]=(dp[i-(b-j)][b-j]+Comb(b-1,j-1))%mod;
		}
	}
	for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)ret+=dp[i][j];
	ret%=mod;

	for(int i=0;i<=b;i++){
		for(int j=a;j>0;j--){
			dp[j-1][i]=(dp[j-1][i]+dp[j][i])%mod;
		}
	}
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			sum[i+1][j]=(sum[i][j]+dp[i][j])%mod;
		}
	}
	for(int i=1;i<=b;i++){
		for(int j=1;i-j>=0;j++){
			long long ks=Comb(i-1,j-1);
			int L=max(1,i-j);
			ret=(ret+(sum[a+1][i]-sum[L][i]+mod)*ks)%mod;
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 73856
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

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

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

const int Maxn = 100010;

int n, k;
ll a[Maxn];
ll sum1[Maxn], sum2[Maxn];

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

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum1[i + 1] = sum1[i] + a[i];
        sum2[i + 1] = sum2[i] + (a[i] > 0 ? a[i] : 0);
    }

    ll ans = 0;
    for (int i = 0; i + k - 1 < n; ++i) {

        ans = max(ans, sum2[i] + max(sum1[i + k] - sum1[i], 0LL) + sum2[n] - sum2[i + k]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

li = na()
li.sort()
print('Yes' if li[0] + li[1] == li[2] else 'No')


Measured memory_bytes: 3316
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if (a == b && a != c) || (a == c && a != b) || (b == c && b != a) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define endl '\n'
typedef long long ll;

int main(){
	string s; cin>>s;
	int size = s.size();
	deque<char> dq(size);
	for(int i=0; i<size; i++){
		dq[i] = s[i];
	}	
	int c, n; cin>>c;
	bool change = false;
	while(c--){
		cin>>n;
		if(n==1){
			change = !change;
		}
		else{
			int ind; cin>>ind;
			char x; cin>>x;
			if(change)ind==1?ind++:ind--;
			if(ind == 1)dq.push_front(x);
			else dq.push_back(x);
		}
	}
	if(change){
		int tam = dq.size();
		for(int i=tam-1; i>=0; i--){
			cout<<dq[i];
		}
		cout<<endl;
	}
	else{
		for(auto&x: dq){
			cout<<x;
		}
		cout<<endl;
	}
}


Measured memory_bytes: 4016
import bisect
import itertools

inf = float('inf')
A, B, Q = map(int, input().split())
s = [-inf]+[int(input()) for _ in range(A)]+[inf]
t = [-inf]+[int(input()) for _ in range(B)]+[inf]
X = [int(input()) for _ in range(Q)]


def most_simRL(ds, x):
    index = bisect.bisect(ds, x)
    return ds[index-1:index+1]


for x in X:
    s_ind = bisect.bisect(s, x)
    t_ind = bisect.bisect(t, x)
    ans = inf
    for a, b in itertools.product((s[s_ind-1], s[s_ind]), (t[t_ind-1], t[t_ind])):
        ans = min(ans, min(abs(a-x), abs(b-x)) + abs(a-b))
    print(ans)


Measured memory_bytes: 16152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,K;
    string S;
    cin >> N >> S >> K;
    for(int i=0;i<N;i++){
        if(S.at(K-1)!=S.at(i)) S.at(i)='*';
        cout << S.at(i);
    }
    cout << endl;
}

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


int main()
{
	int P,Q,R;
	cin>>P>>Q>>R;
	cout<<min(min(P+Q,P+R),Q+R)<<endl;
	return 0;
}


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


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

using namespace std;

int main(){
    ll N;
    cin >> N;
    string res = "Yes";

    vector <ll> t(N+ 1);
    vector <ll> x(N+ 1);
    vector <ll> y(N+ 1);

    t[0] = 0;
    x[0] = 0;
    y[0] = 0;

    for(ll i = 1; i <= N; i++)
    {
        cin >> t[i] >> x[i] >> y[i];
    }

    //t <=　x+y で、tとx+yの偶奇関係が正しければ大丈夫そう
    //t[i+1] - t[i]か

    ll kyori = 0;
    ll kyori_x = 0;
    ll kyori_y = 0;

    for(ll i = 1; i <= N; i++)
    {
        kyori = t[i] - t[i-1];

        kyori_x = abs(x[i] - x[i-1]);
        kyori_y = abs(y[i] - y[i-1]);

        if(kyori < kyori_x + kyori_y)
        {
            res = "No";
            break;
        }
        //偶奇
        if(t[i] % 2 == 0)
        {
            if((x[i] + y[i]) % 2 != 0)
            {
                res = "No";
                break;
            }
        }
        else
        {
            if((x[i] + y[i]) % 2 != 1)
            {
                res = "No";
                break;
            }
        }
    }

    cout << res << endl;
}




Measured memory_bytes: 2560
use std::io::*;

fn read_spc<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    some_sums();
}

fn some_sums() {
    let nab: Vec<u64> = read_spc();
    let n: u64 = nab[0];
    let a: u64 = nab[1];
    let b: u64 = nab[2];
    let mut m: u64 = 0;
    for i in 1..(n + 1) {
        if a <= sum_position(i) && sum_position(i) <= b {
            m += i;
        }
    }
    println!("{}", m);
}

fn sum_position(n: u64) -> u64 {
    let v = n.to_string().chars().collect::<Vec<char>>();
    let mut m = 0;
    for i in v {
        m += i as u64 - 48;
    }
    return m
}

Measured memory_bytes: 4352
#!/usr/bin/perl
my ($n) = map {$_ - 0} split(/\s+/o,<STDIN>);
my $ans = "No";
for(my $i=0;$i<=25;$i++){
  for(my $j=0;$j<=15;$j++){
    $ans = 'Yes' if( $i * 4 + $j * 7 == $n );
  }
}
print "$ans\n";


Measured memory_bytes: 512
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def primeCount(N):
    R = int(N**(0.5)) + 1  # 素数の範囲
    primes = {}  # 素数のリスト
    n = N
    for num in range(2, R):
        primes[num] = 0
        while n % num == 0:
            n //= num
            primes[num] += 1
    if n > 1 :
        primes[n] = 1
    return { key : val for key, val in primes.items() if val > 0}  # フィルターをかける

def sol():
    A, B = map(int, input().split())

    primeA = primeCount(A)
    primeB = primeCount(B)

    ans = 1
    for a in primeA.keys():
        if a in primeB:
            ans += 1

    print(ans)

sol()

Measured memory_bytes: 135800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=2e5+23;

int n;

int cnt[100][100];

int main(){
	cin>>n;
	ll ans=0;
	for(int i=0;i<n;i++){
		double xx;
		scanf("%lf",&xx);
		xx*=1e9;
		ll a=xx+0.5;
		int _2=0,_5=0;
		while(1){
			if(a%2==0){
				a/=2;
				_2++;
			}
			else if(a%5==0){
				a/=5;
				_5++;
			}
			else break;
		}
		int x=max(0,18-_2);
		int y=max(0,18-_5);
		ans+=cnt[x][y];
		for(int i=0;i<=_2;i++){
			for(int j=0;j<=_5;j++) cnt[i][j]++;
		}
		// printf("%.3f %d %d\n",xx,_2,_5);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3788
class RangeSumQuery(object):

    def __init__(self, size):
        self.size = 1
        while self.size <= size:
            self.size *= 2
        self.data = [0] * (self.size*2-1)

    def add(self, idx, value):
        k = idx + self.size - 1
        self.data[k] += value
        while k > 0:
            k = (k - 1) / 2
            self.data[k] += value

    def get_sum(self, start, end):
        def query(k, left, right):
            if right <= start or end <= left:
                return 0
            if start <= left and right <= end:
                return self.data[k]
            vl = query(k*2+1, left, (left+right)/2)
            vr = query(k*2+2, (left+right)/2, right)
            return vl + vr
        return query(0, 0, self.size)


def main():
    n, q = map(int, raw_input().split())
    rsq = RangeSumQuery(n)
    for _ in xrange(q):
        com, x, y = map(int, raw_input().split())
        if com == 0:
            rsq.add(x, y)
        else:
            print rsq.get_sum(x, y+1)

if __name__ == "__main__":
    main()

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

// (-y1,x1).(x2,y2)
int check(int x1, int y1, int x2, int y2){
  ll a = (ll)x1*y2-(ll)y1*x2;
  if (a>0) return 0;
  else if (a<0) return 1;
  else{
    if ((ll)x1*x2>0) return 2;
    else return 3;
  }
}

double dist(int x, int y){
  double a = sqrt((ll)x*x+(ll)y*y);
  return a;
}

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i,n){
    cin >> x[i] >> y[i];
  }
  double max = 0;
  rep(i,n){
    vector<int> mx(4,0),my(4,0);
    rep(j,n){
      mx[check(x[i],y[i],x[j],y[j])]+=x[j];
      my[check(x[i],y[i],x[j],y[j])]+=y[j];
    }
    rep(k,4){
    if (max<dist(mx[k],my[k])) max = dist(mx[k],my[k]);
    }
    if (max<dist(mx[0]+mx[2],my[0]+my[2])) max = dist(mx[0]+mx[2],my[0]+my[2]);
    if (max<dist(mx[0]+mx[3],my[0]+my[3])) max = dist(mx[0]+mx[3],my[0]+my[3]);
  }

  cout << setprecision(15) <<max << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long N = input.nextLong();
		long hi = N;
		long lo = 1;
		for (long i = 2; i <= Math.sqrt(N); i++) {
			if (N%i==0) {
				lo = i;
				hi = N/i;
			}
		}
		System.out.println(lo+hi-2);
	}
}

Measured memory_bytes: 23124
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
// 104, 79, 118, 87
// 169, 133, 17, 98
// 180, 106, 125, 39
// 171, 42, 159, 14
// 45, 76, 101, 56
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	long long ks=1;
	long long ret2=0;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		printf("? %d %d %d %d\n",i,j,i,j);
		fflush(stdout);
		int t;
		scanf("%d",&t);
		if(t)ret=(ret+ks)%d;
		if(i==0)ret2=(ret2+ks)%d;
		ks=ks*2%d;
	}
	int sz=ret2%200;
	char *p = new char[sz*1000000];
	for(int i=0;i<sz*1000000;i++)p[i]='e';
	printf("! %lld\n",ret);
}

Measured memory_bytes: 189132
N = int(input())
A = sorted(map(int, input().split()))[::-1]
for i in range(N-3):
  if A[i]==A[i+1]==A[i+2]==A[i+3]:
    print(A[i]**2)
    exit()
  elif A[i]==A[i+1]:
    for j in range(i+2, N):
      if A[j]==A[j+1]:
        print(A[i]*A[j])
        exit()
    else:
      print(0)
      exit()
else:
  print(0)

Measured memory_bytes: 19956
import java.util.*;

class Main {
	public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        
        int num1,num2;
        String op;
        while(true){
            num1 = sc.nextInt();
            op = sc.next();
            num2 = sc.nextInt();

            if(op.equals("?"))   break;

            switch(op){
                case "+":
                    System.out.println(num1 + num2);
                    break;
                case "-":
                    System.out.println(num1 - num2);
                    break;
                case "*":
                    System.out.println(num1 * num2);
                    break;
                case "/":
                    System.out.println(num1 / num2);
                    break;
            }
        }
    }
}


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

using namespace std;

const int MAX_N = 700 + 5;

int N, M, n1, n2, K;
char m[MAX_N][MAX_N], vis[MAX_N];
bool f[2][MAX_N << 1];
int a[MAX_N][2];

void dfs(int u, int color) {
    vis[u] = color;
    color == 1 ? n1 ++ : n2 ++;
    for (int v = 1; v <= N; v ++) {
        if (u != v && !m[u][v]) {
            if (vis[v] == color) {
                printf("-1\n");
                exit(0);
            } else if (!vis[v]) {
                dfs(v, color ^ 3);
            }
        }
    }
}

int main() {
    scanf("%d%d", &N, &M);
    for (int i = 1; i <= M; i ++) {
        int x, y;
        scanf("%d%d", &x, &y);
        m[x][y] = 1;
        m[y][x] = 1;
    }
    for (int i = 1; i <= N; i ++) {
        if (!vis[i]) {
            n1 = n2 = 0;
            dfs(i, 1);
            a[++ K][0] = n1;
            a[K][1] = n2;
        }
    }
    f[0][0] = 1;
    for (int i = 1, s = 0; i <= K; i ++) {
        int x = a[i][0], y = a[i][1];
        s += abs(x - y);
        for (int j = 0; j <= s; j ++) {
            f[i & 1][j] = f[i & 1 ^ 1][abs(j + x - y)] || f[i & 1 ^ 1][abs(j - x + y)];
        }
    }
    for (n1 = 0; !f[K & 1][n1]; n1 ++);
    n1 = N + n1 >> 1;
    n2 = N - n1;
    M = n1 * (n1 - 1) + n2 * (n2 - 1) >> 1;
    printf("%d\n", M);
    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<algorithm>
using namespace std;
int abs(int a)
{
    if(a>=0)
        return a;
    return -a;
}
int a[109];
int main()
{
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }

    int t,s1=0,s2=0,s,Min=1000000;
    for(i=0;i<n;i++)
    {
        s1=0;s2=0;
        for(j=0;j<i;j++)
            s1+=a[j];
        for(j=i;j<n;j++)
            s2+=a[j];
        s=s1-s2;
        Min=min(Min,abs(s));
    }
    printf("%d\n",Min);
    return 0;
}


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

using namespace std;

typedef long long ll;



ifstream fin ("calafat.in");
ofstream fout ("calafat.out");

int n, r;

int main()
{
  int n, k;
  cin >> n >> k;
  ll p = 1, e = 1;
  while (p * k <= n) {
    p *= k;
    e++;
  }
  cout << e;
  return 0;
}


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

int main(){
  int ans = 0;
  string s ;
  cin >> s ;
  int ss = s.size();
  
  for(int i=0;i<ss-1;i++){
    if(s[i]=='0'&&s[i+1]=='0'){
      ans++;
      s[i+1] = '1';
    }
    if(s[i]=='1'&&s[i+1]=='1'){
      ans++;
      s[i+1]='0';
    }
  }
  
  cout << ans << endl;
}
      


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

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

	int a = n % 10;
	n = n / 10;

	int b = n % 10;
	n = n / 10;

	int c = n;

	if (a == 7 || b == 7 || c == 7) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

const int mod = 1e9+7;
const int inf = 2e18;

int32_t main()
{	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string s;
	string t;
	cin>>s;
	cin>>t;
	if(t.size()!=(s.size()+1))
	{
		cout<<"No"<<'\n';
	}
	else
	{
		string temp = t.substr(0,s.size());
		if(temp==s)
		{
			cout<<"Yes"<<'\n';
		}
		else
		{
			cout<<"No"<<'\n';
		}
	}
	
	return 0;
}	

Measured memory_bytes: 3656
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
 
typedef long long ll;
 
using namespace std; 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;
 
#define REP(inc, bgn, end) for (int inc = bgn; inc < end; inc++)

int main() {
    int n;
    cin >> n;
    vector<ll> h(n+5);
    REP(i,0,n+5) cin >> h[i];
    
    vector<ll> dp(n+5);
    REP(i,0,n+5) dp[i] = INF;
    dp[0] = 0;

    REP(i,0,n) {
        chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int main() {
	cin >> n;
	bool f = false;
	for (int i = 1; i <= 3500 && !f; i++) {
		for (int j = 1; j <= 3500; j++) {
			long long p = 1LL * n * i * j, q = 4 * i * j - n * (i + j);
			if (q >= 1 && p % q == 0 && p / q <= 3500) {
				cout << i << ' ' << j << ' ' << p / q << endl;
				f = true;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef complex<double> point;

#define X real()
#define Y imag()
#define angle(a) (atan2((a).imag(), (a).real()))
#define vec(a, b) ((b) - (a))
#define same(p1, p2) (dp(vec(p1, p2), vec(p1, p2)) < EPS)
#define dp(a, b) ((conj(a) * (b)).real())
#define cp(a, b) ((conj(a) * (b)).imag())
#define length(a) (hypot((a).imag(), (a).real()))
#define normalize(a) (a) / length(a)
#define rotateO(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotateO(vec(about, p), ang) + about)
#define reflectO(v, m) (conj((v) / (m)) * (m))
#define clr(a, b) memset(a, b, sizeof(a));

const ll N = 1005;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

ll h, w;
ll memo[N][N];
char grid[N][N];

ll solve(ll i, ll j)
{
	if(i == h - 1 && j == w - 1)
		return 1;
	if(i >= h || j >= w)
		return 0;
	if(grid[i][j] == '#')
		return 0;

	ll& ret = memo[i][j];

	if(~ret)
		return ret;

	ret = (solve(i + 1, j) % MOD + solve(i, j + 1) % MOD) % MOD;

	return ret;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    clr(memo, -1);
    cin >> h >> w;
    for(int i = 0; i < h; i++)
    	for(int j = 0; j < w; j++)
    		cin >> grid[i][j];
    cout << solve(0, 0) << endl;
}

Measured memory_bytes: 9216
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, s: "List[str]", t: "List[int]", X: str):
    ret = 0
    flg = False
    for i in range(N):
        if flg:
            ret += t[i]
        if s[i] == X:
            flg = True
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [str()] * (N)  # type: "List[str]"
    t = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        s[i] = next(tokens)
        t[i] = int(next(tokens))
    X = next(tokens)  # type: str
    solve(N, s, t, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#define MAX 30

#include<stdio.h>

int main(void){
	int w, n, a[MAX], p, q, temp, i;

	scanf("%d", &w);
	if (w > MAX) {
		printf("Error!\n");
		return 0;
	}
	for ( i = 0; i < w; i++) {
		a[i] = i + 1;
	}

	scanf("%d", &n);
	if (n > MAX) {
		printf("Error!\n");
		return 0;
	}

	for ( i = 0; i < n; i++) {
		scanf("%d,%d", &p, &q);

		temp = a[p - 1];
		a[p - 1] = a[q - 1];
		a[q - 1] = temp;
	}

	for ( i = 0; i < w; i++) {
		printf("%d\n", a[i]);
	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <iostream> 
#include <algorithm>
#include <math.h>
#include <map>  
#include <string.h> 
#include <string> 
#include <cctype> 

using namespace std;

int counter[10000];

int main(){	
  
string s="abcdefghijklmnopqrstuvwxyz";
  
char ch;

while (cin>>ch){
  
    if(islower(ch)||isupper(ch)){
  
    ch=tolower(ch);
  
    int num=ch-'a';
  
    counter[num]++;
    
    }
    
}
  
for(int i=0; i<26; i++){
  cout<<s[i]<<' '<<':'<<' '<<counter[i]<<endl;
  }
   

}

Measured memory_bytes: 3200
n = int(input())
nn = (n + 1) // 2
s = [0]*n
print(0)
s[0] = input()
if s[0] == "Vacant":
    exit()
print(n-1)
s[n-1] = input()
if s[n-1] == "Vacant":
    exit()
ll = 0
hh = nn-1
while hh - ll > 1:
    l = ll*2
    h = hh*2
    ii = (ll + hh) // 2
    i = ii*2
    print(i)
    s[i] = input()
    if s[i] == "Vacant":
        exit()
    elif s[i] != s[l]:
        hh = ii
    else:
        ll = ii
print(ll+hh)

Measured memory_bytes: 4424
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
lens = len(s)
for i in range(2, lens, 2):
  if s[:(lens - i) // 2] == s[(lens - i) // 2:lens - i]:
    print(lens - i)
    exit()
    

















Measured memory_bytes: 27024
def x a,b,c,d,e,f,s,t
((a-c)*(b-t)-(a-s)*(b-d)>0)==(k=(c-e)*(d-t)-(c-s)*(d-f)>0)&&k==(e-a)*(f-t)-(e-s)*(f-b)>0
end
gets.to_i.times{*a,g,h,i,j=gets.split.map &:to_i
puts x(*a,g,h)^x(*a,i,j)?:OK:"NG"}

Measured memory_bytes: 6176
#include <bits/stdc++.h>
template<typename T>
class fixed_point : T {
  public:
    explicit constexpr fixed_point (T&& t) noexcept
      : T(std::forward<T>(t)) {}
    template<typename... Args>
    constexpr decltype(auto) operator()(Args&&... args) const
      {return T::operator()(*this, std::forward<Args>(args)...);}
};
template<typename T>
static inline constexpr decltype(auto) fix (T&& t) noexcept {
  return fixed_point<T>{std::forward<T>(t)};
}
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  auto make = fix([&] (auto make, long long N, long long A, long long B)
    -> std::vector<int>
    {
    if (N == 0 || A == 0) {
      assert(N == 0 && A == 0);
      return {};
    }
    assert(A + B - 1 <= N && N <= A * B);
    long long r = std::min(B, std::max(1LL, N - ((A - 1) * B)));
    long long a = A - 1, b = B, n = N - r;
    auto ret = make(n, a, b);
    assert((int)ret.size() == n);
    auto another = std::vector<int>(r);
    std::iota(another.begin(), another.end(), n + 1);
    std::reverse(another.begin(), another.end());
    ret.insert(ret.end(), another.begin(), another.end());
    assert((int)ret.size() == N);
    return ret;
  });
  auto err = [&] {
    std::cout << -1 << std::endl;
    exit(0);
  };
  long long N, A, B;
  std::cin >> N >> A >> B;
  if (N < A + B - 1 || A * B < N) err();
  auto ret = make(N, A, B);
  assert((int)ret.size() == N);
  for (int i = 0; i < N; i++) {
    std::cout << (i > 0 ? " " : "") << ret.at(i);
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 26096
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		List<Integer> inputs = new ArrayList<>();
		
		while(true) {
			int i = sc.nextInt();
			if(i == 0) break;
			inputs.add(i);
		}
		sc.close();
		
		int cases = 1;
		
		for(int i : inputs) {
			System.out.println("Case " + cases + ": " + i);
			cases++;
		}
		
	}

}

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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  i64 n;
  cin >> n;

  vector<i64> a(n+1), b(n+1);
  i64 a_sum = 0, b_sum = 0;

  rep(i, n) {
    cin >> a[i];
    a_sum += a[i];
  }

  rep(i, n) {
    cin >> b[i];
    b_sum += b[i];
  }

  if (a_sum > b_sum) {
    cout << "No" << "\n";
    return 0;
  }

  i64 cnt = b_sum - a_sum;
  i64 cnt_2 = 0;
  rep(i, n) {
    if (a[i] < b[i]) {
      i64 diff = b[i] - a[i];
      cnt_2 += (diff + 1) / 2;
    }
  }

  cout << (cnt_2 <= cnt ? "Yes" : "No") << "\n";

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fir first
#define sec second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 5;
const int M = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = 1e-8;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ull qpow(ull a, ull b, ull c)
{
    ull ans = 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a % c;
        a = a * a % c;
        b >>= 1;
    }
    return ans;
}
int ans[2020][2020];
int k[2020];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, y;
    cin >> n >> x >> y;
    int d = y - x - 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            if (i == x && j == y)
                ans[i][j] = 1;
            else if ((i <= x && j <= x) || (i >= y && j >= y))
                ans[i][j] = j - i;
            else if (i <= x && j >= y)
                ans[i][j] = j - i - d;
            else if (i <= x && j >= x)
                ans[i][j] = min(j - i, x - i + 1 + y - j);
            else if (i <= y && j >= y)
                ans[i][j] = min(j - i, j - y + 1 + i - x);
            else
                ans[i][j] = min(j - i, i - x + 1 + y - j);
            k[ans[i][j]]++;
        }
    }
    // for (int i = 1; i <= n; i++)
    // {
    //     for (int j = i + 1; j <= n; j++)
    //     {
    //         cout << ans[i][j] << ' ';
    //     }
    //     cout << '\n';
    // }
    for (int i = 1; i < n; i++)
        cout << k[i] << '\n';
}

Measured memory_bytes: 15360
#include<iostream>
#include<vector>

using namespace std;

int main() {
	int num[101] = { 0 };
	int a;
	while (cin >> a) {
		num[a] += 1;
	}
	int max = -1;
	vector<int> vec;
	for (int i = 0; i <= 100; i++) {
		if (num[i] == max) {
			vec.push_back(i);
		}

		if (num[i] > max) {
			max = num[i];
			vec.clear();
			vec.push_back(i);
		}
	}
	for (int j = 0; j < vec.size(); j++) {
		cout << vec[j] << endl;
	}
}


Measured memory_bytes: 3144
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<map>
#include<algorithm>
using namespace std;

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

    vector<string> S(N);
    for (int i = 0; i < N; i++)
        cin >> S[i];

    map<string, int> mp;
    for (int i = 0; i < N; i++)
        mp[S[i]]++;

    int mx = 0;
    for (int i = 0; i < N; i++)
        mx = max(mx, mp[S[i]]);

    vector<string> v;
    for (auto it = mp.begin(); it!=mp.end(); it++)
        if (it->second == mx)
            v.push_back(it->first);

    sort(v.begin(), v.end());

    for (int i = 0; i < (int)v.size(); i++)
        cout << v[i] << endl;

    return 0;
}


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

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

int main()
{
    long long int a,b,x;cin >> a >> b >> x;
    long long res = b/x - a/x;
    if(a%x==0) res++;
    cout << res << endl;
}

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

int main() {
	int n,d;
	cin >> n >> d;
	cout << (n + 2 * d) / (2 * d + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return (a / gcd(a,b)) * b; }
ll gcd2(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {   x = 1;  y = 0;  return a;   }
    ll xx, yy;
    ll res = gcd2(b, a%b, xx, yy);
    x = yy;     y = xx - yy * (a / b);
    return res;
}

// ll nCr(ll n, ll r) {
//     return ( ( ( (fac[n] * powmod(fac[n-r], mod-2)) % mod ) * powmod(fac[r], mod-2) ) % mod );
// }
// const ll sz = 1e6 + 5;
// vector<ll> fac(sz, 1);

// * ALways PASS arrays, strings etc to functions BY REFERENCE

int main() {
    // for (int i = 1; i < sz; i++)
    //     fac[i] = (fac[i-1] * i) % mod;
    
    int t = 1;
    // cin >> t;
    
    while(t--) {
        string s, tt;
        cin >> s >> tt;
        
        int n = s.size(), m = tt.size(), res = INT_MAX;
        for (int i = 0; i <= n-m; i++) {
            int cnt = 0;
            for (int x = i; x < i+m; x++) {
                if (s[x] != tt[x-i])
                    ++cnt;
            }
            res = min(res, cnt);
        }
        
        cout << res << endl;
    }
    
	return 0;
}


Measured memory_bytes: 3632
use std::collections::HashSet;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

const MOD: i64 = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        mut a: [[i64; 2]; n]
    }

    for x in a.iter_mut() {
        let v = x[0] + x[1];
        x.push(v);
    }

    a.sort_by(|b, c| c[2].cmp(&b[2]));

    let mut v = [0; 2];
    for i in 0..n {
        v[i % 2] += a[i][i % 2];
    }

    println!("{}", v[0] - v[1]);
}


Measured memory_bytes: 12540
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int { sc.Scan(); t, _ := strconv.Atoi(sc.Text()); return t }

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

type job struct {
	t, d int // t => 所要時間、d => 締め切り時間
}
type jobs []job

func (j jobs) Len() int {
	return len(j)
}
func (j jobs) Less(p, q int) bool {
	return j[p].d < j[q].d
}
func (j jobs) Swap(p, q int) {
	j[p], j[q] = j[q], j[p]
}

func main() {
	var n int
	fmt.Scan(&n)
	js := make([]job, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		js[i].t = nextInt(sc)
		js[i].d = nextInt(sc)
	}
	sort.Sort(jobs(js))
	var tot int
	for i := range js {
		tot += js[i].t
		if tot > js[i].d {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 6272
#include<stdio.h>
#include<math.h>

int main(void)
{
    double x1, y1, x2, y2, distance;
    
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    
    distance = sqrt( pow(x1-x2,2)+pow(y1-y2,2) );
    printf("%lf\n", distance);
    
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,i;
	cin>>n;
	int arr1[n],arr2[n];
	for(i=0;i<n;i++)cin>>arr1[i];
	for(i=0;i<n;i++)arr2[arr1[i]-1]=i+1;
	for(i=0;i<n;i++)cout<<arr2[i]<<" ";
	return 0;
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int MOD = 11;
int N, K;
// 桁,mod,より小さい
ll dp[11][11][2];

ll f(int n) {
    if(N < 1)return 0;
    MEM(dp, 0);
    dp[0][0][0] = 1;

    vi di;
    while(n > 0) {
        di.push_back(n % 10);
        n /= 10;
    }
    reverse(all(di));

    rep(d, sz(di))rep(md, 11)rep(ls, 2) {
        ll val = dp[d][md][ls];
        if(val == 0)continue;

        rep(num, 10) {
            if(d == 0 && num == 0)continue;
            if(!ls && num > di[d])break;
            dp[d + 1][(md*10 + num) % MOD][ls || (num < di[d])] += val;
        }
    }

    ll res = 0;
    rep(md, 11)rep(ls, 2) {
        for(int j = 1; j <= 5; ++j) {
            int val = 9 * (7 * md + j - 7) + 72;
            val %= MOD;
            if(val == K)res += dp[sz(di)][md][ls];
        }
    }

    return res;
}

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

    while(cin >> N >> K) {
        N -= 2;
        ll ans = f(N);
        for(ll i = 10; i <= N; i *= 10) {
            ans += f(int(i - 1));
        }
        cout << ans << endl;
    }
}

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

#define int long long

int a[501][501];

void dfs(int l, int r, int c) {
  if ( r-l <= 1 ) return;
  
  int mid = (l+r)/2;
  for ( int i = l; i < mid; i++ ) {
    for ( int j = mid; j < r; j++ ) {
      a[i][j] = a[j][i] = c;      
    }
  }

  dfs(l, mid, c+1);
  dfs(mid, r, c+1);
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  dfs(0, N, 1);

  for ( int i = 0; i < N-1; i++ ) {
    for ( int j = i+1; j < N; j++ ) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 2432
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#pragma comment(linker, "/STACK:336777216")  

using namespace std;

const int MAXN = 40 + 1;
const int MAXBIT = 17;
const int MOD = 1000000007;

int N, X, Y, Z;
int DP[MAXN][1 << MAXBIT];

void Work()
{
	scanf("%d%d%d%d", &N, &X, &Y, &Z);
	DP[0][0] = 1;
	int MSK = (1 << (X + Y + Z - 1)) - 1;
	for (int i = 0; i < N; i ++)
		for (int Mask = 0; Mask <= MSK; Mask ++)
			for (int j = 1; j <= 10; j ++)
			{
				int NewMask = (Mask << j) | (1 << (j - 1));
				if ((NewMask & (1 << (Z - 1))) && (NewMask & (1 << (Y + Z - 1))) && (NewMask & (1 << (X + Y + Z - 1))))
					continue;
				(DP[i + 1][NewMask & MSK] += DP[i][Mask]) %= MOD;
			}
	long long Ans = 1;
	for (int i = 0; i < N; i ++)
		(Ans *= 10LL) %= MOD;
	for (int Mask = 0; Mask <= MSK; Mask ++)
		(Ans += MOD - DP[N][Mask]) %= MOD;
	printf("%d\n", (int) Ans);
}

int main()
{
	Work();
	return 0;
}

Measured memory_bytes: 19584
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

fn main() {
    let n = get!(usize);
    let mut txy = get!(i64, i64, i64; n);

    txy.sort_by_key(|t| t.0);

    let mut x = 0;
    let mut y = 0;
    let mut t = 0;

    for &(t1, x1, y1) in &txy {
        let mut d = (x1 - x).abs() + (y1 - y).abs();
        let dt = t1 - t;

        if dt >= d && (dt - d) % 2 == 0 {
            t = t1;
            x = x1;
            y = y1;
        } else {
            println!("No");
            return;
        }
    }

    println!("Yes");
}


Measured memory_bytes: 8444
#include<iostream>
using namespace std;
int main()
{
	int ans=0;
	string c="CODEFESTIVAL2016";
	string s;
	cin>>s;
	for(int i=0;i<c.length();i++)
		if(c[i]!=s[i])
			ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

signed main(){
    int n, m;
    cin >> n >> m;

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

    vector<vector<int>> edge(n, vector<int>());
    rep(i, m){
        int x, y;
        cin >> x >> y;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }

    if(m == n - 1){
        cout << 0 << endl;
        return 0;
    }

    if(n < 2 * (n - m - 1)){
        cout << "Impossible" << endl;
        return 0;
    }

    vector<int> mark(n, -1);
    rep(i, n){
        if(mark[i] != -1){
            continue;
        }
        stack<int> st;
        st.push(i);

        while(not st.empty()){
            int v = st.top();
            st.pop();

            if(mark[v] != -1){
                continue;
            }
            mark[v] = i;

            for(int u : edge[v]){
                if(mark[u] == -1){
                    st.push(u);
                }
            }
        }
    }

    priority_queue<P, vector<P>, greater<P>> pq;
    vector<bool> used(n, false);
    rep(i, n){
        pq.emplace(a[i], mark[i]);
    }

    int ans = 0;
    int remain = 2 * (n - m - 1) - (n - m);
    rep(i, n){
        int cost = pq.top().first;
        int v = pq.top().second;
        pq.pop();

        if(not used[v]){
            used[v] = true;
            ans += cost;
            continue;
        }

        if(remain > 0){
            ans += cost;
            remain--;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9976