akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

void bomb( char map[8][8], int x, int y) {
	if (0<=x && 0<=y && x<8 && y<8) if( map[x][y]=='1' ) {
		map[x][y] = '0';
		for( int i=-3; i<=3; i++) {
			if(0<=x+i && x+i<8) if(map[x+i][y]=='1') bomb( map, x+i, y);
			if(0<=y+i && y+i<8) if(map[x][y+i]=='1') bomb( map, x, y+i);
		}
	}
}

int main() {
	int n;
	std::cin >> n;
	
	for( int i=0; i<n; i++) {
		char mapstr[8][8];
		int x, y;
		
		// Load the map
		for( int i=0; i<64; i++) std::cin >> mapstr[i%8][i/8];
		
		// Load the Target
		std::cin >> x >> y;
		
		// Bomb!!
		bomb( mapstr, x-1, y-1);
		
		std::cout << "Data " << (i+1) << ":" << std::endl;
		for( int i=0; i<64; i++) std::cout << mapstr[i%8][i/8] << ( (i%8==7) ? "\n" : "");
	}
	return 0;
}

Measured memory_bytes: 1168
/*
No matter how long a night, dawn will always break.

Simular saying ... The darkest hour is just before the dawn.
 ***************************************   ************************8   **********************************
*/
#include <bits/stdc++.h>
using namespace std;

 
#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define sz(x)	    (int)(x).size()
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define hell        998244353
#define output(x) cout << (x ? "YES" : "NO")<<endl;
 
 
 
 
 
int gcd(int a, int b) {if(a>b)swap(a,b) ;  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}
 
const int N=1e5+5;
vi graph[N];

 int r5(int n){
 	int ans=1;
 	for(int i=0;i<5;i++){
 		ans*=n;
 	}
 	return ans;
 }
 
 
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m,i,j,x,t;
   map<int,int> mp;
   
   cin>>n;
   vi v(n+1);
   int ans=0;
   fo(i,1,n+1){
   	cin>>v[i];
   	ans+=mp[i-v[i]];
   	mp[i+v[i]]++;

   }
   cout<<ans;

   
    return 0;
}

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



int main() 
{
	int a,b,t;
	cin >> a;
	cin >> b;
	if(b<a)
	{
		t=b;
		b=a;
		a=t;
	}
	//cout << a << "\n" << b;
	if(a==1 && b==2)
	{
		cout << "3" << "\n";
	}
	else if(a==1 && b==3)
	{
		cout << "2" << "\n";
	}
	else if(a==2 && b==3)
	{
		cout << "1" << "\n";
	}
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A.sort()
for i in range(N-1):
    if A[i] <= 0 and A[i+1] <= 0:
        A[i] *= -1
        A[i+1] *= -1
    elif A[i] < A[i+1]*(-1):
        A[i] *= -1
        A[i+1] *= -1

print(sum(A))

Measured memory_bytes: 14412
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long n;
    scanf("%ld", &n);
    vector<long> viNum(n);
    for(long i = 0; i < n; i++){
        scanf("%ld", &viNum[i]);
    }
    sort(viNum.rbegin(), viNum.rend());
    long nAns = 0;
    if(viNum[0] < n * n){
        while(viNum[0] >= n){
            viNum[0] -= n;
            for(long i = 1; i < n; i++){
                 viNum[i]++;
            }
            sort(viNum.rbegin(), viNum.rend());
            nAns++;
        }
        printf("%ld", nAns);
        return 0;
    }
    
    vector<long> viRema(n);
    for(long i = 0; i < n; i++){
        viRema[i] = viNum[i] % (n + 1);
    }
    sort(viRema.rbegin(), viRema.rend());
    
    long iMinOfMax = n;
    long iMin = 0;
    long nSum = 0;
    for(long i = 0; i < n; i++){
        viRema[0] -= n;
        for(long i = 1; i < n; i++){
             viRema[i]++;
        }
        sort(viRema.rbegin(), viRema.rend());
        if(viRema[0] < iMinOfMax){
            iMinOfMax = viRema[0];
            nSum = 0;
            for(long i = 0; i < n; i++){
                nSum += viRema[i];
            }
        }
    }
    nSum += (n - 1 - iMinOfMax) * n;
    for(long i = 0; i < n; i++){
        nAns += viNum[i];
    }
    nAns -= nSum;
    printf("%ld", nAns);
    
    return 0;
}


Measured memory_bytes: 3244
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		
		for(int i=0;i<=50000;i++) {
			int now = i*108;
			if(N*100<=now&&now<(N+1)*100) {
				System.out.println(i);
				return;
			}
		}

		System.out.println(":(");
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=4003,INF=1<<30;

int main(){
    
    long double X,P;cin>>X>>P;
    
    if(int(X)%2==0){
        cout<<setprecision(25)<<100.0/P*(X/2.0)<<endl;
    }else{
        cout<<setprecision(25)<<(P/100.0)*(100.0/P)*((X-1.0)/2.0)+((100.0-P)/100.0)*(100.0/P)*((X+1.0)/2.0)+1.0<<endl;
    }
}



Measured memory_bytes: 256
while gets
a=$_.split.map(&:to_i)
b=gets.split.map(&:to_i)
c=d=0
4.times{|i|
c+=1 if a[i]==b[i]
d+=1 if b.find{|j|j==a[i]}&&a[i]!=b[i]
}
puts "#{c} #{d}"
end

Measured memory_bytes: 8580
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int A,B,C;
int INF = INT_MAX;
ll dfs(int n,ll a, ll b, ll c, int count, vector<ll> &vec){
    if(count == n){
        if(0 < a && 0 < b && 0 < c)return abs(a-A) + abs(b-B) + abs(c-C) - 30;
        else return INF;
    }
    ll res0 = dfs(n,a,b,c,count+1,vec);
    ll res1 = dfs(n,a+vec[count],b,c,count+1,vec) + 10;
    ll res2 = dfs(n,a,b+vec[count],c,count+1,vec) + 10;
    ll res3 = dfs(n,a,b,c+vec[count],count+1,vec) + 10;
    return min(min(res0,res1),min(res2,res3));
}

int main(){
    int n; cin >> n;
    cin >> A >> B >> C;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];

    ll ans = dfs(n,0,0,0,0,l);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
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)*}
    };
}

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, i321) => {
        read_value!($next, i32) - 1
    };

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

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input! { a: usize , b: usize }
    if a+b >= 10 {
        println!("error");
    } else {
        println!("{}", a+b);
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int w, h;
char a[50][50];
int BW[50][50];
int dx[] = { 1,0,0,-1 }, dy[] = { 0,1,-1,0 };

void dfs(int x, int y, int flag) {
	for (int i = 0; i < 4; ++i) {
		int nx = x + dx[i], ny = y + dy[i];
		if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
		if (a[nx][ny] != '.') continue;
		if (BW[nx][ny] & flag) continue;
		BW[nx][ny] |= flag;
		dfs(nx, ny, flag);
	}
}

int main() {
	while (cin >> w >> h, w) {
		memset(BW, 0, sizeof(BW));
		for (int i = 0; i < h; ++i)
			for (int j = 0; j < w; ++j)
				cin >> a[i][j];
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				if (a[i][j] == 'B') dfs(i, j, 1);
				else if (a[i][j] == 'W') dfs(i, j, 2);
			}
		}
		int cntb = 0, cntw = 0;
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				if (BW[i][j] == 1) cntb++;
				else if (BW[i][j] == 2) cntw++;
			}
		}
		cout << cntb << " " << cntw << endl;
	}

	return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 




int main(void){
    ll x;
    cin>>x;
    for(ll i=1;i<=100000;i++){
        ll m = i*(i+1)/2;
        if(m-x>=0){
            if(i>m-x){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 256
# ref https://atcoder.jp/contests/agc037/submissions/6962751

import sys
sys.setrecursionlimit(10 ** 7)

S = input().rstrip("\n")

if len(S) == 1:
    print(1)
    exit()

# dp1[i]: i文字目までで、最後が長さ1のときの最大項数
dp1 = [-float("inf")] * len(S)
# dp2[i]: i文字目までで、最後が長さ2のときの最大項数
dp2 = [-float("inf")] * len(S)

# 初期条件
dp1[0] = 1
dp2[1] = 1
if S[0] != S[1]:
    dp1[1] = 2

# 貰うdp
for i in range(2,len(S)):
    # 2文字 -> 1文字
    tmp = dp2[i-1] + 1
    # 1文字 -> 1文字
    if S[i-1] != S[i]:
        tmp = max(tmp, dp1[i-1] + 1)
    dp1[i] = tmp

    # 1文字 -> 2文字
    tmp = dp1[i-2] + 1
    # 2文字 -> 1文字
    if S[i-3:i-1] != S[i-1:i+1]:
        tmp = max(tmp, dp2[i-2] + 1)
    dp2[i] = tmp
    
answer = max(dp1[-1], dp2[-1])
print(answer)

Measured memory_bytes: 19160
// Build Stairs.cpp
// https://atcoder.jp/contests/abc136/tasks/abc136_c


#include <iostream>
using namespace std;
typedef unsigned long long int llu;

int main(){

    // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); cout<<"Build Stairs.cpp\n";
    
    int n;
    cin >>n;

    int lastHeight;
    int height;

    lastHeight = 0;

    for(int i=0; i<n; ++i){
        cin >> height;

        if(height < lastHeight){
            cout<<"No";
            return 0;
        }

        if(height > lastHeight){
            lastHeight = height-1;
        }
    }
    cout<<"Yes";
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        String word = s.next();
        int year =Integer.parseInt(word.substring(0,4)) ;
        int month =Integer.parseInt (word.substring(5,7));
        int day = Integer.parseInt(word.substring(8,word.length()));

        if(year<2019) System.out.println("Heisei");
        else if(year>2019) System.out.println("TBD");
        else{
            if(month<4) System.out.println("Heisei");
            else if(month>4) System.out.println("TBD");
            else {
                if(day<=30) System.out.println("Heisei");
                else System.out.println("TBD");
            }
        }

    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25260
N = int(input())
A = list(map(int,input().split()))
m = min(A)
n = 0
while m != n:
    m = min(A)
    a = [m]
    for i in A:
        i %= m
        if i != 0:
            a.append(i)
    A = a
    n = min(A)
print(n)

Measured memory_bytes: 20120
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long X = sc.nextLong();
    sc.close();

    long ans = 0;
    long n = 100;

    while (n < X) {
      n *= 1.01;
      ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 35908
#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[i]==S[K-1]){
      cout<<S[K-1];
    }
    else{
      cout<<"*";
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int n,l,t;
int x[100005], w[100005];
int X[100005];
int pos[100005];
int ans[100005];
int main(){
    scanf("%d%d%d",&n,&l,&t);
    for (int i = 0; i < n; i++){
        scanf("%d%d",&x[i],&w[i]);
        if (w[i] == 1){
            X[i] = (x[i]+t)%l;
        }
        else{
            X[i] = ((x[i]-t)%l+l)%l;
        }
        pos[i] = X[i];
    }
    int curlabel = 0;
    for (int i = 1; i < n; i++){
        if (w[i] != w[0]){
            int ct = t/l;
            int add = 2*ct;
            int left = t-ct*l;
            int dist = x[i]-x[0];
            if (w[0] == 2) dist = l-dist;
            if (left > (dist+l)/2) add++;
            if (left > dist/2) add++;
            if (w[0] == 1) curlabel += add;
            else curlabel -= add;
        }
    }
    curlabel = (((curlabel%n)+n)%n);
    //printf("final label of ant 0 is %d, pos %d\n",curlabel,X[0]);
    sort(pos,pos+n);
    ans[curlabel] = X[0];
    int start = 0;
    while (pos[start] != X[0]) start++;
    if (start+1 < n && pos[start+1] == pos[start] && w[0] == 2) start++;
    for (int i = 1; i < n; i++){
        int id = (curlabel+i)%n;
        int id2 = (start+i)%n;
        ans[id] = pos[id2];
    }
    /*for (int i = 0; i < n; i++){
        printf("%d ",pos[i]);
    }
    printf("\n");*/
    for (int i =0;  i < n; i++){
        printf("%d\n",ans[i]);
    }
}



Measured memory_bytes: 5672
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	puts(a <= x && x <= a + b ? "YES" : "NO");
}

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

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  ll sum = 0, neg = 0;
  rep(i, n) {
    cin >> v.at(i);
    if (v.at(i) < 0) {
      neg++;
      v.at(i) = abs(v.at(i));
    }
    sum += v.at(i);
  }
  sort(v.begin(), v.end());
  if (neg%2) {
    cout << sum - 2*v.at(0) << endl;
  }
  else cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<(x)<<endl
const int maxn=(int)1e6+5;
typedef long long ll;
const ll mod=(ll)1e9+7;
ll a[maxn];
bool b[maxn];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;

    rep(i,1,n)cin>>a[i];
    int t=61;
    ll b=1;
    ll ans=0;

    while(t--){
        ll zero=0,one=0;
        rep(i,1,n){
            if(a[i]&1)one++;else zero++;
            a[i]>>=1;
        }
        ans+=(one*zero%mod)*(b%mod)%mod;
        ans%=mod;
        b<<=1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include <cstdlib>
using namespace std;
int N, A, B, C;
int l[8];

int DFS(int cur, int a, int b, int c)
{
	if (cur == N)
	{
		if (a > 0 &&( b > 0 && c > 0))
			return abs(a - A) + abs(b - B) + abs(c - C) - 30;
		else
			return 10000000;
	}
	else
	{
		int tmp1 = DFS(cur + 1, a, b, c);
		int tmp2 = DFS(cur + 1, a+l[cur], b, c) + 10;
		int tmp3 = DFS(cur + 1, a, b+l[cur], c) + 10;
		int tmp4 = DFS(cur + 1, a, b, c+l[cur]) + 10;
		return min(min(min(tmp1, tmp2),tmp3),tmp4);
	}
}

int main()
{
	cin >> N >> A >> B >> C;
	for (int i = 0; i < N; i++)
	{
		cin >> l[i];
	}
	int ans = DFS(0, 0, 0, 0);
	cout << ans;
	return 0;

}

Measured memory_bytes: 256
///
// File:  b.cpp
// Author: ymiyamoto
//
// Created on Sat Nov  4 02:09:06 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  int32_t N, K;
  cin >> N;
  cin >> K;

  int32_t n = 1;
  for (int32_t i = 0; i < N; i++) {
    if (n < K) {
      n *= 2;
    } else {
      n += K;
    }
  }

  cout << n << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h,w;
  char s;
  s='#';

    while (1)
  {
    scanf("%d",&h);
    scanf("%d",&w);
    if(w == 0 && h == 0 )break;
    for (int i = 1; i <= h; i++)
    {
      for (int j = 1; j <= w; j++)
      {
        if( (i % 2 != 0 && j % 2 == 0) || (i % 2 == 0 && j % 2 != 0)) s = '.';
        else
        {
          s = '#';
        }
        
        printf("%c",s);
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;

void solve(long long N, std::vector<long long> X, std::vector<long long> L){
    vector<pair<int, int>> ranges(N);
    rep(i,0,N) ranges[i] = {X[i] + L[i], X[i] - L[i]};
    sort(all(ranges));
    pair<int, int> prev = ranges.front();
    int answer = N;
    rep(i,1,N) {
        pair<int, int> const & current = ranges[i];
        if (prev.first > current.second) answer--;
        else prev = current;
    }
    cout << answer << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(X), std::move(L));
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	int A, B, C; cin >> A >> B >> C;
	int ans = LLINF;
	VI L(N);
	REP(i, N)cin >> L[i];
	SORT(L);
	do {
		int cnt = LLINF;
		VI sum(N + 1, 0);
		REP(i, N)sum[i + 1] = sum[i] + L[i];

		eFOR(i,1, N - 2) {
			eFOR(j, i + 1, N - 1) {
				eFOR(k, j + 1, N) {
					int tmp = 0;
					tmp += abs(sum[i] - A);
					tmp += abs(sum[j] - sum[i] - B);
					tmp += abs(sum[k] - sum[j] - C);

					tmp += 10 * (i - 1);
					tmp += 10 * (j - i - 1);
					tmp += 10 * (k - j - 1);

					chmin(cnt, tmp);
				}
			}
		}

		chmin(ans, cnt);

	} while (next_permutation(L.begin(), L.end()));






	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    cout << (n+k-3)/(k-1) << endl;
    return 0;
}

Measured memory_bytes: 3704
r1,c1,r2,c2=map(int,input().split())
mod=10**9+7
n_max=2*(10**6+1)
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
Inv=[0]*(n_max+1)
Inv[1]=1
for i in range(2,n_max):
  Inv[i]=pow(i,mod-2,mod)


for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
  FI[i+1]=(FI[i]*Inv[i+1])%mod
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod

def f(x,y):
  return comb(x+y+2,y+1)-1

print((f(r2,c2)-f(r2,c1-1)-f(r1-1,c2)+f(r1-1,c1-1))%mod)


Measured memory_bytes: 88540
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

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

int main()
{
  double L;
  std::cin >> L;
  std::cout << std::fixed << std::setprecision(10);
  std::cout << std::pow(L/3.0, 3) << std::endl;
  return 0;
}



Measured memory_bytes: 256
# Problem C - Sqrt Inequality

# 注意：ルートの計算は近似計算によりWAとなってしまう。
#    ：整数に落とし込んで計算しよう

# input process
a, b, c = map(int, input().split())

# initialization
tochu_1 = c - a - b
tochu_2 = 4 * a * b

# output process
if tochu_1>0 and (tochu_1)**2>tochu_2:
    print("Yes")
else:
    print("No")


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

int main() {
    int A, B, res;
    cin >> A >> B;

    if(A <= 5) res = 0;
    else if(A <= 12) res = B/2;
    else res = B;

    cout << res << endl;
    return 0;
}

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

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

  set<int> ans;

  for (int i = a; i <= min(b,a+k-1); i++)
  {
    ans.insert(i);
  }

  for (int i = b; i >= max(a,b-k+1); i--)
  {
    ans.insert(i);
  }

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

}

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

int h,w;

int id(int i,int j){
    return i*w+j;
}

int main(){
    cin >> h >> w;
    vector<string> s(h); rep(i,h) cin >> s[i];
    int d[h*w][h*w]; rep(i,h*w) rep(j,h*w) d[i][j] = 100000;

    if(h == 1){
        cout << w-1 << endl;
        return 0;
    }else if(w == 1){
        cout << h-1 << endl;
        return 0;
    }else{
    rep(i,h) rep(j,w){
        if(s[i][j] == '.'){
            if(i == 0 && j == 0){ // 左上
                if(s[i][j+1] == '.') d[id(i,j)][id(i,j)+1] = 1; // 右
                if(s[i+1][j] == '.') d[id(i,j)][id(i,j)+w] = 1; // 下
            }else if(i == 0 && j == w-1){ // 右上
                if(s[i+1][j] == '.') d[id(i,j)][id(i,j)+w] = 1; // 下
                if(s[i][j-1] == '.') d[id(i,j)][id(i,j)-1] = 1; // 左
            }else if(i == 0){ // 上
                if(s[i][j+1] == '.') d[id(i,j)][id(i,j)+1] = 1; // 右
                if(s[i+1][j] == '.') d[id(i,j)][id(i,j)+w] = 1; // 下
                if(s[i][j-1] == '.') d[id(i,j)][id(i,j)-1] = 1; // 左
            }else if(i == h-1 && j == 0){ // 左下 
                if(s[i-1][j] == '.') d[id(i,j)][id(i,j)-w] = 1; // 上
                if(s[i][j+1] == '.') d[id(i,j)][id(i,j)+1] = 1; // 右
            }else if(i == h-1 && h == w-1){ // 右下
                if(s[i-1][j] == '.') d[id(i,j)][id(i,j)-w] = 1; // 上
                if(s[i][j-1] == '.') d[id(i,j)][id(i,j)-1] = 1; // 左
            }else if(i == h-1){ // 下
                if(s[i-1][j] == '.') d[id(i,j)][id(i,j)-w] = 1; // 上
                if(s[i][j+1] == '.') d[id(i,j)][id(i,j)+1] = 1; // 右
                if(s[i][j-1] == '.') d[id(i,j)][id(i,j)-1] = 1; // 左
            }else if(j == 0){ // 左
                if(s[i-1][j] == '.') d[id(i,j)][id(i,j)-w] = 1; // 上
                if(s[i][j+1] == '.') d[id(i,j)][id(i,j)+1] = 1; // 右
                if(s[i+1][j] == '.') d[id(i,j)][id(i,j)+w] = 1; // 下
            }else if(j == w-1){ // 右
                if(s[i-1][j] == '.') d[id(i,j)][id(i,j)-w] = 1; // 上
                if(s[i+1][j] == '.') d[id(i,j)][id(i,j)+w] = 1; // 下
                if(s[i][j-1] == '.') d[id(i,j)][id(i,j)-1] = 1; // 左
            }else{ // 通常
                if(s[i-1][j] == '.') d[id(i,j)][id(i,j)-w] = 1; // 上
                if(s[i][j+1] == '.') d[id(i,j)][id(i,j)+1] = 1; // 右
                if(s[i+1][j] == '.') d[id(i,j)][id(i,j)+w] = 1; // 下
                if(s[i][j-1] == '.') d[id(i,j)][id(i,j)-1] = 1; // 左
            }
        }        
        }
    }

    // warshal-floyd
    rep(i,h*w) rep(j,h*w) rep(k,h*w) d[j][k] = min(d[j][i] + d[i][k], d[j][k]);

    // calc
    int ans = -1;
    rep(i,h*w) rep(j,h*w){
        if(s[i/w][i%w] == '.' && s[j/w][j%w] == '.') ans = max(ans, d[i][j]);
    }

    // output
    cout << ans << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include<stdio.h>
#include<cstring>
using namespace std;

int main()
{
    char dadin[4];
    while(cin>>dadin){
        int money=700;
        for(int i=0;i<3;i++)if(dadin[i]=='o')money+=100;
        cout<<money<<endl;
    }

    return 0;
}


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

int main(){
	int x, a;
	cin >> x >> a;
	if(x < a){
    	cout << 0 << endl;
    }else{
    	cout << 10 << endl;
    }
}

Measured memory_bytes: 256
object Main extends App {
	val Array(n, k) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val h = new Array[Long](n)

	for(i<-0 until n){
		h(i) = scala.io.StdIn.readLong
	}

	val h1 = h.sorted

	var ans = Long.MaxValue

	for(j<-0 to n - k){
		ans = math.min(ans, h1(j+k-1) - h1(j))
	}

	println(ans)

}

Measured memory_bytes: 38940
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	ll N, K, pR, pS, pP; cin >> N >> K >> pR >> pS >> pP;
	string T; cin >> T;

	string rsp = { 'r','s','p' };
	string win = { 'p','r','s' };
	vector<ll> points = { pP, pR, pS };
	vector<ll> won(N, 0);

	ll sum = 0;
	rep(i, K) {
		rep (j,3) {
			if (T[i] == rsp[j]) {
				sum += points[j];
				T[i] = win[j];
				won[i] = 1;
				break;
			}
		}
	}
	REP(i, K, N) {
		rep (j,3) {
			if (T[i] == rsp[j]) {
				if ((T[i - K] == win[j]) && (won[i - K] == 1)) break;
				sum += points[j];
				T[i] = win[j];
				won[i] = 1;
				break;
			}
		}
	}
	cout << sum << endl;
}

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

	return 0;
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

int main(){
  int n;
  long double sum=0;
  long double x;
  string u;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x>>u;
    if(u[0]=='J'){
      sum+=x;
    }else{
      x=x*380000.0;
      sum+=x;
    }
  }
  cout<<sum<<endl;

  return 0;
}


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

using namespace std;

const int Nmax = 1e5+5;
int i, n, a[Nmax], j, k, dp[Nmax];

int solve(int id)
{
    if(id==n+1) return 0;

    int i, j;

    for(i=id; i<n && a[i] <= a[i+1]; ++i);
    for(j=id; j<n && a[j] >= a[j+1]; ++j);

    return 1 + solve(max(i,j) + 1);
}

int main()
{
   
    cin.sync_with_stdio(false);

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

    cout << solve(1) << '\n';

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int dp[ten5];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,small=0;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=0,now=0;
    //vector <int> v;
    //float f,g,h;
    //char now,pre;
    //string a;
    cin>>n>>k;
    int *pos=new int [k];
    for(i=0;i<k;i++) cin>>pos[i];
    sort(pos,pos+k);
    for(i=0;i<k-1;i++)
    {
        pos[i]=pos[i+1]-pos[i];
    }
    sort(pos,pos+k-1);
    for(i=0;i<k-n;i++) sum+=pos[i];
    delete [] pos;
    cout<<sum;
    return 0;
}





Measured memory_bytes: 640
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      char[] s = sc.next().toCharArray();
      if (s.length == 2) {
        System.out.println(s);
      } else {
        for (int i = 0; i < 3; i++) {
          System.out.print(s[2-i]);
        }
      }
    } finally {
      sc.close();
    }
  }
}


Measured memory_bytes: 35616
#include <stdio.h>
long long a, v, b, w, t, x;
int main() {
	scanf("%lld%lld%lld%lld%lld", &a, &v, &b, &w, &t);
	if (v <= w) {
		printf("NO\n");
		return 0;
	}
	x = a - b;
	if (x < 0)x = -x;
	t *= (v - w);
	if (t >= x)printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 1620
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int deg[5];
int main(){
	for(int i = 1;i <= 3;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		deg[u]++;
		deg[v]++;
	}
	int num = 0;
	for(int i = 1;i <= 4;i++){
		num += (deg[i] & 1);
	}
	if(num == 0 || num == 2) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
 os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os << "(" << P.first << "," << P.second << ")";}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif


#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	string s,t;
	ll q;cin>>s>>t>>q;
	ll i,j,a,b,c,d;
	ll n = s.size();ll m = t.size();
	vll v(n+1,0);vll w(m+1,0);
	// trace(s,t);
	for(i=0;i<n;i++){
		v[i+1] = (v[i] + ((s[i]=='A')?(-1):(1)) + 3)%3;
	}
	for(i=0;i<m;i++){
		w[i+1] = (w[i] + ((t[i]=='A')?-1:1) + 3)%3;
	}
	// trace(v,w);
	while(q--){
		cin>>a>>b>>c>>d;
		a = (v[b] - v[a-1] +3)%3;
		c = (w[d] - w[c-1] +3)%3;
		// trace(a,c);
		if(a==c)cout<<"YES\n";
		else cout<<"NO\n";
	}
}


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int w, h, x, y; scanf("%d%d%d%d", &w, &h, &x, &y);
	printf("%lf %d", double(w) * double(h) /2, x + x == w && y + y == h);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int N,data[100];
 
void input(){
  scanf("%d",&N);
  int i;
  for(i = 0; i < N; i++) scanf("%d",&data[i]);
}
 
void print(){
  int i;
  for(i = 0; i < N; i++){
    if(i) printf(" ");
    printf("%d",data[i]);
  }
  printf("\n");
}
 
void insertion_sort(){
  print();
  int i,j;
  for(j = 1; j < N; j++){
    int key = data[j];
    i = j-1;
    while(i >= 0 && data[i] > key){
      data[i+1] = data[i];
      i--;
    }
    data[i+1] = key;
    print();
  }
}
 
int main(){
  input();
  insertion_sort();
  return 0;
}


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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;

int main(){
	int x;cin>>x;
	cout<<(!x)<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N;
    cin >> N;
    vi a(N);
    rep(i,N) cin >> a[i];
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int d = abs(a[i] - a[j]);
            if(d%(N-1) == 0){
                cout << a[i] << " "  << a[j] << endl; 
                return 0;
            }
        }
    }
}



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

using namespace std;

int n;
bool adj[201][201];
int dist[201];
int ans = 0;

bool bfs(int src) {
	queue<int> q;

	fill(dist + 1, dist + n + 1, -1);
	dist[src] = 0;
	q.push(src);

	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int v = 1; v <= n; v++) {
			if (adj[u][v]) {
				if (dist[v] == -1) {
					dist[v] = dist[u] + 1;
					q.push(v);
				} else {
					if (dist[v] != dist[u] + 1 && dist[u] != dist[v] + 1) {
						return false;
					}
				}
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		ans = max(ans, dist[i] + 1);
	}

	return true;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			char ch;
			while (isspace(ch = getchar())) {
			}
			adj[i][j] = ch ^ '0';
		}
	}

	for (int i = 1; i <= n; i++) {
		if (!bfs(i)) {
			puts("-1");
			exit(0);
		}
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
/**
 *      ABC 97 B
 *      author  : kyomukyomupurin
 *      created : 2018/08/23
**/

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

int main(){
    int X; cin >> X;
    vector<int> v;
    v.push_back(1);
    for (int i = 2; i < 10; ++i) {
        v.push_back(pow(2, i));
    }
    for (int i = 2; i < 7; ++i) {
        v.push_back(pow(3, i));
    }
    for (int i = 2; i < 5; ++i) {
        v.push_back(pow(5, i));
    }
    for (int i = 6; i < 9; ++i) {
        for (int j = 2; j < 4; ++j) {
            v.push_back(pow(i, j));
        }
    }
    for (int i = 2; i < 4; ++i) {
        v.push_back(pow(10, i));
    }
    for (int i = 11; i < 32; ++i) {
        v.push_back(pow(i, 2));    
    }
    sort(v.begin(), v.end());


    if (X == 1) cout << 1 << endl; 
    else if (X == 1000) cout << 1000 << endl;
    else {
        for (int i = 0; i < v.size(); ++i){
            if (X >= v.at(i) && X < v.at(i + 1)){
                cout << v.at(i); break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
t = [0]+list(map(int,input().split()))+[0]
s = [0]+list(map(int,input().split()))+[0]

mod = 10**9+7
if max(t) != max(s):
    print(0)
    exit()
ans = 1
for i in range(1,n+1):
    d = False
    if t[i] != t[i-1]:
        d = True
        x = t[i]
    if s[i] != s[i+1]:
        if d:
            if x != s[i]:
                print(0)
                exit()
        else:
            d = True
            x = s[i]
    if d:
        if x > t[i] or x > s[i]:
            print(0)
            exit()
    if not d:
        ans *= min(s[i],t[i])
        ans %= mod
print(ans%mod)


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}


void dfs(int v, set<int> &visit, deque<int> &visit2, vector<vector<int>> &G, bool flag) {

    for(int i = 0; i < G[v].size(); i++) {
        if (visit.find(G[v][i]) == visit.end()) {
            visit.insert(G[v][i]);
            
            if (!flag) visit2.push_front(G[v][i]);
            else visit2.push_back(G[v][i]);
            
            dfs(G[v][i], visit, visit2, G, flag);
            return; // 枝分かれしない
        }
    }
    return;
}

void solve() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    set<int> visit;
    deque<int> visit2;
    visit.insert(0);
    visit.insert(G[0][0]);
    visit2.push_back(0);
    visit2.push_back(G[0][0]);

    dfs(G[0][0], visit, visit2, G, true);
    dfs(0, visit, visit2, G, false);

    cout << visit2.size() << endl;
    for (int i = 0; i < visit2.size(); i++) {
        cout << visit2[i] + 1 << " ";
    }
    cout << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 11392
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;
typedef long long int lli;

int main(void)
{
	int N; cin >> N;
	vector<lli> X(N); rep(i, 0, N)cin >> X[i]; 
	vector<lli> store(N); rep(i, 0, N)store[i] = X[i];
	sort(X.begin(), X.end());
	lli pre = X[N / 2 - 1], next = X[N / 2];
	rep(i, 0, N)cout << (store[i]<=pre?next:pre) << endl;

	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/22  Problem: ABC 054 D / Link: http://abc054.contest.atcoder.jp/tasks/abc054_d  ----- */


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

	LL N, ta, tb; cin >> N >> ta >> tb;
	vector<LL>a(N), b(N), c(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i] >> b[i] >> c[i];
	}
	auto chmin = [](LL &a, const LL b) {
		a = min(a, b);
	};
	vector<VVL>dp(N + 1, VVL(421, VL(421, LINF)));
	dp[0][0][0] = 0;
	FOR(i, 0, N) {
		FOR(ap, 0, 401) {
			FOR(bp, 0, 401) {
				chmin(dp[i + 1][ap][bp], dp[i][ap][bp]);
				chmin(dp[i + 1][ap + a[i]][bp + b[i]], dp[i][ap][bp] + c[i]);
			}
		}
	}
	LL ans = LINF;
	FOR(i, 1, 401) {
		int aa = ta * i, bb = tb * i;
		if (aa <= 400 && bb <= 400)
			chmin(ans, dp[N][aa][bb]);
	}

	cout << (ans==LINF?-1:ans) << "\n";

	return 0;
}


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

int main(){
    int A,B,C,D,K;
    cin >> A >> B >> C >> D >> K;
    int S;
  	if(C<A){
      if(B<D){
      	S = (C+24-A)*60+(D-B);
      }else{
        S = (C+23-A)*60+(D+60-B);
      }
    }else{
    	if(A<C){
          S = (C-A)*60 + (D-B);
        }else{
          S = (C-A-1)*60 + (60-B+D);
        }
    }
    cout << S-K << endl;
    
}

Measured memory_bytes: 3624
#include <iostream>

int main(void)
{
    int n;
    int a=0,b=0;
    while(true)
    {
        std::cin >> n;
        if(n==0) break;
        a=b=0;
        for(int i=0;i<n;i++)
        {
            int a1,b1;
            std::cin >> a1 >> b1;
            if(a1==b1) {a+=a1;b+=b1;}
            else if(a1>b1) {a+=a1+b1;}
            else {b+=a1+b1;}
        }
        std::cout << a << " " << b << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
  
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c; cin>>a>>b>>c;
    string ans;
    ll d = c-b-a;
    if((d>0) && (a*b*4 < d*d)) {
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256