akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

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

//移動方向のベクトルを配列で用意する
const DI:[isize;4] = [-1,0,1,0];
const DJ:[isize;4] = [0,-1,0,1];

fn main() {
    let h: usize = read();
    let w: usize = read();
    let C:(usize,usize) = (read::<usize>()-1,read::<usize>()-1);
    let D:(usize,usize) = (read::<usize>()-1,read::<usize>()-1);
    let map: Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();

    /*
    println!("{:?}",C);
    println!("{:?}",D);
    println!("{:?}",map);
    */

    //h行w列のベクタで、i64の最大値で初期化
    let mut dist:Vec<Vec<i64>> = vec![vec![std::i64::MAX; w]; h];
    //0-1BFS用のdequeを用意する
    let mut q: VecDeque<(usize,usize)> = VecDeque::new();
    //スタート地点のコストを0に設定
    dist[C.0][C.1] = 0;
    q.push_front((C.0,C.1));

    while !q.is_empty(){
        //dequeの先頭要素を取り出す
        let i = q.front().unwrap().0;
        let j = q.front().unwrap().1;
        q.pop_front();
        //探索点のコストを設定
        let d = dist[i][j];
        //四方への移動を試す（移動A）
        for v in 0..4{
            let ni = i as isize + DI[v];
            let nj = j as isize + DJ[v];
            //移動先がmap内に収まるか判定
            if ni < 0 || ni >= h as isize || nj < 0 || nj >= w as isize{
                continue;
            }
            let ni = ni as usize;
            let nj = nj as usize;
            //移動先が壁でないか判定
            if map[ni][nj] == '#' {
                continue;
            }
            //移動先のコストが現在コストより小さいか判定
            if dist[ni][nj] <= d{
                continue;
            }
            //最小コストを更新
            dist[ni][nj] = d;
            //コスト0側に座標を追加
            q.push_front((ni,nj));

        }
        //ワープを試す（移動B）
        //近傍2x2の周りへワープ可能なので、for2重ループで確認する
        for ei in -2..=2{
            for ej in -2..=2{
                let ni = i as isize + ei;
                let nj = j as isize + ej;
                //移動先がmap内に収まるか判定
                if ni < 0 || ni >= h as isize || nj < 0 || nj >= w as isize{
                    continue;
                }
                let ni = ni as usize;
                let nj = nj as usize;
                //移動先が壁でないか判定
                if map[ni][nj] == '#' {
                    continue;
                }
                //移動先のコストが現在コスト+1(ワープの移動コスト追加)より小さいか判定
                if dist[ni][nj] <= d+1{
                    continue;
                }
                //最小コストを更新
                dist[ni][nj] = d+1;
                //コスト1側に座標を追加
                q.push_back((ni,nj));
            }
        }
    }
    let ans = dist[D.0][D.1];
    if ans == std::i64::MAX {
        println!("-1");
    }else{
        println!("{}",ans);
    }


}


Measured memory_bytes: 14012
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in);) {

			while (true) {
				long H = sc.nextInt();
				long W = sc.nextInt();

				if (H == 0 && W == 0) break;

				StringBuilder sb = new StringBuilder();

				for (int i = 0; i < H; i++) {
					for (int j = 0; j < W; j++) {
						if (j == 0 || j == W - 1 || i == 0 || i == H - 1) {
							sb.append("#");
						} else {
							sb.append(".");
						}
					}
					sb.append("\n");
				}

				System.out.println(sb.toString());
			}
		}
	}
}


Measured memory_bytes: 27780
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, L; cin >> N >> L;
  int mn = 1145141919, sum = 0, num;
  for(int i = L; i < L+N; i++){
    if(mn > abs(i)){
      mn = abs(i);
      num = i;
    }
    sum += i;
  }
  cout << sum - num << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N,x;
    cin >> N >> x;
    if(x == 1 || x == 2 * N - 1) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
        if(N == 2) {
            cout << 1 << endl << 2 << endl << 3 << endl;
            return 0;
        }
        vector<bool> used(2 * N - 1);
        vector<int> ret(2 * N - 1);
        if(x == 2) {
            ret.at(N - 2) = 3;
            ret.at(N - 1) = 2;
            ret.at(N) = 1;
            ret.at(N + 1) = 4;
            used.at(0) = true;
            used.at(1) = true;
            used.at(2) = true;
            used.at(3) = true;
        }
        else {
            ret.at(N - 2) = x - 1;
            ret.at(N - 1) = x;
            ret.at(N) = x + 1;
            ret.at(N + 1) = x - 2;
            used.at(x - 3) = true;
            used.at(x - 2) = true;
            used.at(x - 1) = true;
            used.at(x) = true;
        }
        int itr = 0;
        for(int i = 0;i < 2 * N - 1;i++) {
            if(ret.at(i) == 0) {
                while(true) {
                    if(used.at(itr) == false) {
                        ret.at(i) = itr + 1;
                        used.at(itr) = true;
                        break;
                    }
                    itr++;
                }
            }
        }
        for(int i = 0;i < 2 * N - 1;i++) {
            cout << ret.at(i) << endl;
        }
    }
}

Measured memory_bytes: 3980
package main

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

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	h, _ := strconv.Atoi(stringLineScan())
	w, _ := strconv.Atoi(stringLineScan())
	ans := 0
	if h == 2 && w == 2 {
		ans = 1
	} else if h%3 != 0 && w%3 != 0 {
		ans = smaller(h, w)
		if h > 2 {
			for i := 1; i < h; i++ {
				a := w * i
				b := h - i
				c, d := b*(w/2), b*(w/2+w%2)
				x := max(a, c, d) - min(a, c, d)
				if x < ans {
					ans = x
				}
			}
		}
		if w > 2 {
			for i := 1; i < w; i++ {
				a := h * i
				b := w - i
				c, d := b*(h/2), b*(h/2+h%2)
				x := max(a, c, d) - min(a, c, d)
				if x < ans {
					ans = x
				}
			}
		}
	}
	fmt.Println(ans)
}
func smaller(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}
func max(x, y, z int) int {
	if x > y && x > z {
		return x
	} else if y > z {
		return y
	} else {
		return z
	}
}
func min(x, y, z int) int {
	if x < y && x < z {
		return x
	} else if y < z {
		return y
	} else {
		return z
	}
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

#define N 10000
#define INT(X) \
  ( *( (const int *)(X) ) )

int comparator (
  const void  * a,
  const void  * b
  )
{
  return ( INT( b ) - INT( a ) );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    struct tagCore
    {
      int d;
      int p;
    } d[ N ];
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    for ( i = 0; i < n; ++i )
    {
      int d1, d2;

      scanf ( "%d%d%d", &d[ i ].p, &d1, &d2 );
      d[ i ].d = d1 + d2;
    }

    qsort ( d, n, sizeof ( struct tagCore ), comparator );

    printf ( "%d %d\n", d->p, d->d );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		100000									// 最大配列数

// 内部変数
static int si1Array[D_ARRAY_MAX + 5];							// 配列
static int siACnt;												// 配列数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// ソート関数 - int昇順
int
fSortFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	int *lipVal1 = (int *)pzpVal1;
	int *lipVal2 = (int *)pzpVal2;

	// 昇順
	if (*lipVal1 >  *lipVal2) {
		return(1);
	}
	else if (*lipVal1 < *lipVal2) {
		return(-1);
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 配列数取得
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &siACnt);

	// 配列取得
	for (i = 0; i < siACnt; i++) {
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
		fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
		sscanf(lc1Buf, "%d", &si1Array[i]);
	}

	// ソート
	qsort(si1Array, siACnt, sizeof(int), fSortFnc);

	// 番兵追加
	si1Array[siACnt] = INT_MAX;

	// 奇数個の数字の数を取得
	int liSum = 0;
	int liCnt = 1;
	for (i = 1; i <= siACnt; i++) {
		if (si1Array[i] == si1Array[i - 1]) {	// １つ前と同じ
			liCnt++;
		}
		else {									// １つ前と違う
			if (liCnt % 2 == 1) {					// 奇数個
				liSum++;
			}
			liCnt = 1;
		}
	}

	// 結果セット
	sprintf(lc1Out, "%d\n", liSum);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
#include <stack>
#include <cstring>
 
#define ll long long
#define MP make_pair
#define PB push_back
#define P push
#define f first
#define se second
#define S size()
#define B begin()
#define E end()
#define rB rbegin()
#define rE rend()
#define PI acos(-1)

 
const int N = 1e5 + 100;
const int M = 1e6 + 100;
const ll oo = 1e18;
 
ll n, m, k, t, q, h, a, b, d, c, e, w, x, y, z;
using namespace std;

vector <int> v[N];
int in[N], val[N], vis[N], ans;


void dfs(int n, int las) {
	vis[n] = 1;
	for(int i = 0; i < v[n].S; i++){
		val[v[n][i]] = max(val[v[n][i]], las + 1);
		in[v[n][i]]--;
		if(in[v[n][i]] && !vis[v[n][i]]) continue;

		dfs(v[n][i], val[v[n][i]]);
	}
}


int main() {

	cin >> n >> m;

	for(int i = 0; i < m; i++) {
		cin >> x >> y;
		v[x].PB(y);
		in[y]++;
	}



	for(int i = 1; i <= n; i++){
		if(!in[i] && !vis[i]) dfs(i, val[i]);
	}


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



	cout << ans;


	

    return 0;
}




Measured memory_bytes: 11520
package main
import(
  "fmt"
)
func main(){
  var s, k, x, y, z int
  ans:=0
  fmt.Scan(&k, &s)
  for x=0;x<=k;x++{
    for y=0;y<=k;y++{
      z=s-x-y
      if 0<=z && z<=k{
        ans++
      }
    }
  }
  fmt.Println(ans)
}


Measured memory_bytes: 512
a, v = gets.chomp.split(" ").map(&:to_i)
b , w = gets.chomp.split(" ").map(&:to_i)
t = gets.chomp.to_i
if b > a
    sa = b - a
    if v * t >= w * t + sa
        puts "YES"
    else
        puts "NO"
    end
elsif b < a
    sa = a - b
    if v * t  >= w * t + sa
        puts "YES"
    else
        puts "NO"
    end
else
    puts "YES"
end

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

#define int long long

#define pii pair<int, int>

#define x1 x1228
#define y1 y1228

#define left left228
#define right right228

#define pb push_back
#define eb emplace_back

#define mp make_pair 

#define ff first
#define ss second   

#define matr vector<vector<int> > 

#define all(x) x.begin(), x.end()


using namespace std;
typedef long long ll; 
typedef long double ld; 

const int maxn = 3e5 + 7, mod = 1e9 + 7, inf = 1e18, MAXN = 1e6 + 7;
const double eps = 1e-9;
mt19937 rnd(time(0));
string s; 

void solve() {        
    cin >> s;
    int ans = 0;
    int cur = 0;
    int n = s.size();
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'B') ++cur; 
        else ans += cur;
    }
    cout << ans;
}                               
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1;  
    for (int i = 0; i < t; ++i)              
        solve();
    return 0;
}  

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <limits.h>
#include <math.h>

using namespace std;

int main() {
	int n, c;
	cin >> n >> c;
	vector<vector<int>> da(c, vector<int>(c));
	for (int i = 0;i < c;i++) {
		for (int j = 0;j < c;j++) {
			cin >> da[i][j];
		}
	}
	vector<vector<int>> co(n, vector<int>(n));
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			cin >> co[i][j];
			co[i][j]--;
		}
	}
	vector<vector<pair<long long,int>>> sum(3, vector<pair<long long,int>>(c));
	for (int i = 0;i < 3;i++) {
		for (int j =0 ;j < c;j++) {
			sum[i][j] = make_pair(0, j);
		}
	}
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			for (int k = 0;k < c;k++) {
				sum[(i + j) % 3][k].first = (long long)sum[(i + j) % 3][k].first + da[co[i][j]][k];
			}
		}
	}
	for (int i = 0;i < 3;i++) {
		sort(sum[i].begin(), sum[i].end());
	}
	long long ans = LLONG_MAX;
	for(int i = 0;i < 3;i++) {
		for (int j = 0;j < 3;j++) {
			if (sum[0][i].second == sum[1][j].second) {
				continue;
			}
			for (int k = 0;k < 3;k++) {
				if (sum[0][i].second == sum[2][k].second || sum[1][j].second == sum[2][k].second) {
					continue;
				}
				else {
					ans = min(ans, sum[0][i].first + sum[1][j].first + sum[2][k].first);
				}
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
    int a[110];
    int N;

    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a, a+N);
    reverse(a, a+N);

    int A = 0, B = 0;
    for(int i = 0; i < N; i++) {
        if(i % 2 == 0) {
            A += a[i];
        } else {
            B += a[i];
        }
    }
    cout << A-B << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int ll 
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = 1000005;
#ifndef LOCAL
#define cerr if(0)cout
#endif
int A[MAXN];
int cnt[MAXN]; // cnt of each prime factor

bitset<MAXN+1> isprime;
vector<int> primes;

vector<int> prime_factorize(int x) {
	vector<int> res;
	for(auto i:primes) {
		if(i > x/i) break;
		while(x%i == 0){
			res.pb(i);
			x/=i;
		}
	}
	if(x != 1) res.pb(x);
	return res;
}

void sieve() {
	isprime.reset();
	isprime.flip();
	isprime[0] = isprime[1] = 0;
	primes.pb(2);
	for(int i = 4; i<MAXN;i+=2)isprime[i] = 0;
	for(int i = 3;i<MAXN;i+=2) {
		if(!isprime[i]) continue;
		primes.pb(i);
		for(int j = i*2;j<MAXN;j+=i) {
			isprime[j] = 0;
		}
	}
}

int32_t main() 
{
	IAMSPEED
	sieve();
	int n; cin >> n;
	FOR(i,1,n)cin >> A[i];
	int gcd = A[1];
	FOR(i,2,n) gcd=__gcd(gcd, A[i]);
	FOR(i,1,n) {
		vector<int> factors = prime_factorize(A[i]);
		set<int> s;
		for(auto j:factors)s.insert(j);
		for(auto j:s)cnt[j]++;
	}
	bool pairwise = 1;
	FOR(i,2,MAXN-1) {
		if(cnt[i] > 1) {
			pairwise = 0;
		}
	}
	if(pairwise) {
		cout << "pairwise coprime";
	} else if(gcd == 1) {
		cout << "setwise coprime";
	} else {
		cout << "not coprime";
	}
}



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

int a[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 0;
    rep(i, N) cin >> a[i + 1];
    REP(i, 1, N) {
        if (a[i] == i) {
            ans++;
            i++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N + 1, 1e9);
  vec[0] = 0;
  for (int i = 1; i <= N; i++ ) {
    vec[i] = min(vec[i], vec[i - 1] + 1);
    for (int j = 6; j <= i; j *= 6) {
      vec[i] = min(vec[i], vec[i - j] + 1);
    }
    for (int j = 9; j <= i; j *= 9) {
      vec[i] = min(vec[i], vec[i - j] + 1);
    }
  }
  cout << vec[N] << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
int n,l;
char s[102][102];
char tmp[105];
scanf("%d %d",&n,&l);

for(int i=0;i<n;i++){
    scanf("%s",s[i]);
}

for(int i=1;i<n;i++){
    for(int j=1;j<n;j++){
     if(strcmp(s[j-1], s[j])>0){
        strcpy(tmp, s[j-1]);
        strcpy(s[j-1], s[j]);
        strcpy(s[j], tmp);
      }

    }
}
for(int i=0;i<n;i++){
    printf("%s",s[i]);
}
}


Measured memory_bytes: 128
import math
a,b,C = map(float,input().split())
S = (1/2)*a*b*math.sin(math.radians(C))
L = (a**2+b**2-2*a*b*math.cos(math.radians(C)))**(1/2)+a+b
h = b*math.sin(math.radians(C))
print(f"{S:.8f}")
print(f"{L:.8f}")
print(f"{h:.8f}")


Measured memory_bytes: 5716
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def inv(x):
    return pow(x, mod2 - 2, mod2)

cms = 10**6
cm = [0] * cms

def comb_init():
    cm[0] = 1
    for i in range(1, cms):
        cm[i] = cm[i-1] * i % mod2

def comb(a, b):
    return (cm[a] * inv(cm[a-b]) % mod2) * inv(cm[b]) % mod2

def main():
    n,m,k = LI()
    comb_init()

    a = [0] * n
    a[0] = m
    for i in range(1,n):
        a[i] = a[i-1] * (m-1) % mod2

    r = 0
    for i in range(k+1):
        r += a[n-i-1] * comb(n-1, i)
        r %= mod2

    return r

print(main())





Measured memory_bytes: 58164
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	double t,x;
	cin >> t >> x;
	printf("%.10lf\n",(t/x));
	return 0;
}


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

int main(){
  int k,x;
  cin >> k >> x;
  if(500*k>=x){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

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

using namespace std;
using graph=vector<vector<int>>;

int n;
graph T;

vector<int> color;

void dfs(int u,int p,int dep){
	color[u]=dep%2;
	for(int v:T[u]) if(v!=p) dfs(v,u,dep+1);
}

int main(){
	scanf("%d",&n);
	T.resize(n);
	rep(i,n-1){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		T[u].emplace_back(v);
		T[v].emplace_back(u);
	}

	color.resize(n);
	dfs(0,-1,0);

	int nb=count(color.begin(),color.end(),0);
	int nw=count(color.begin(),color.end(),1);

	if(nb>nw){
		swap(nb,nw);
		rep(u,n) color[u]=1-color[u];
	}

	vector<int> ans(n);
	if(nb<=n/3){
		int bcnt=3,wcnt=1;
		rep(u,n){
			if(color[u]==0) ans[u]=bcnt, bcnt+=3;
			else            ans[u]=wcnt, wcnt+=(wcnt%3==1?1:2);
		}
		rep(u,n) if(ans[u]>n) ans[u]=bcnt, bcnt+=3;
	}
	else{
		int bcnt=1,wcnt=2;
		rep(u,n){
			if(color[u]==0) ans[u]=bcnt, bcnt+=3;
			else            ans[u]=wcnt, wcnt+=3;
		}
		int cnt=3;
		rep(u,n) if(ans[u]>n) ans[u]=cnt, cnt+=3;
	}
	rep(u,n) printf("%d%c",ans[u],u<n-1?' ':'\n');

	return 0;
}


Measured memory_bytes: 17920
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;

int main(){
	string s;
	cin >> s;
	if(s=="AAA" or s=="BBB"){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys

from collections import deque
# q = deque(); q.append(x); q.appendleft(x); q.pop() -> x; q.popleft() -> x
from collections import defaultdict
# d = defaultdict(lambda: []); d[key] -> []
import heapq
# hq = []; heapq.heappush(hq, x); heapq.heappop(hq) -> x; heapq.heappushpop(hq, x) -> x
import bisect
# i = bisect.bisect_left([1,2,3,4], 1.5); i = bisect.bisect_right([4,3,2,1], 1.5)

#import numpy as np
#from scipy.misc import comb

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

# BFS方法
def main():
    N = i2n()
    coins = [1]
    d = 6
    while d <= N:
        coins.append(d)
        d *= 6
    d = 9
    while d <= N:
        coins.append(d)
        d *= 9
    q = deque()
    q.append((0, 0))
    s = set((0,))
    while q:
        i, n = q.popleft()
        for j in coins:
            k = i + j
            if k == N:
                print(n+1)
                return
            if k > N:
                continue
            if k in s:
                continue
            q.append((k, n+1))
            s.add(k)
    print(-1)

main()


Measured memory_bytes: 47088
def main():
    """
    うしろから確定させる
    """
    N = int(input())
    AB = [
        list(map(int, input().split()))
        for _ in range(N)
    ]

    ans = 0
    for a, b in AB[::-1]:
        c = (a + ans) % b
        #if a + ans > b and c == 0:
        if c == 0:
            pass
        else:
            d = b - c
            #print(d)
            ans += d

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28148
n = gets.to_i
x = gets.chomp.split(" ").map(&:to_f)
y = gets.chomp.split(" ").map(&:to_f)
# Minkowski distance
(1..3).each do |i|
  sum = 0.0
  n.times do |j|
    sum += (x[j] - y[j]).abs**i
  end
  puts (sum ** (1 / i.to_f)).round(6)
end

# Chebyshev distance
d = []
n.times do |i|
  d.push (x[i] - y[i]).abs
end
puts d.max

Measured memory_bytes: 8876
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		long k=sc.nextLong();
		long a=sc.nextLong();
		long b=sc.nextLong();
		long ans=0;
		if(b-a<=2) {
			ans=k+1;
		}
		else {
			long d=b-a;
			ans=a;
			ans+=((long)((k-a+1)/2))*d;
			if((k-a+1)%2==1) {
				ans++;
			}
		}
		System.out.println(ans);
	
		
	}	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}






Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int k[11][100+1],p[11][100+1];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=10;j++){
			cin>>k[j][i];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=10;j++){
			cin>>p[j][i];
		}
	} 
	int q[11]={0};
	q[10]=1;
	int w[n+1];
	long long ans=-10000000000;
	while(q[0]==0){
		int j=10;
		while(q[j]==1){
			j--;
		}
		q[j]=1;
		if(j==0)break;
		for(int i=j+1;i<=10;i++){
			q[i]=0;
		}
		long long pro=0;
		
		memset(w,0,sizeof(w));
		for(int i=1;i<=10;i++){
			if(q[i]==0)continue;
			for(j=1;j<=n;j++){
				if(k[i][j]&&q[i]){
					w[j]++;
				}
			}
		}
		for(int i=1;i<=n;i++){
			pro+=p[w[i]][i];
		}
		if(pro>ans)ans=pro;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<fstream>
using namespace std;
//const int N = 1e3 + 5;
int main(){

	int a, b;
	double ave;
	cin >> a >> b;
	ave = (double(a) +double( b)) / 2;
	cout << ceil(ave) << endl;






}

Measured memory_bytes: 3676
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, std::vector<long long> H){
  int ans = 0;
  int k = 0;
  for (int i = 1; i < N; i++) {
    if (H[i-1] >= H[i]) {
      k++;
      ans = max(k, ans);
    } else {
      k = 0;
    }
  }
  std::cout << ans << std::endl;
}

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


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC171D
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            string[] Ainput = Console.ReadLine().Split(' ');
            long[] A = new long[N];
            for(int i = 0; i < N; i++)
            {
                A[i] = long.Parse(Ainput[i]);
            }
            long Q = long.Parse(Console.ReadLine());
            long[] B = new long[Q];
            long[] C = new long[Q];
            for(int i = 0; i < Q; i++)
            {
                string[] BCinput = Console.ReadLine().Split(' ');
                B[i] = long.Parse(BCinput[0]);
                C[i] = long.Parse(BCinput[1]);
            }
            long[] bucket = new long[100000];
            long sum = 0;
            for (int i = 0; i < N; i++)
            {
                sum += A[i];
                bucket[A[i] - 1] += 1;
            }
            //Console.WriteLine(sum);
            for (int i = 0; i < Q; i++)
            {
                long plus = (C[i] - B[i]) * bucket[B[i] - 1];
                bucket[C[i] - 1] += bucket[B[i] - 1];
                bucket[B[i] - 1] = 0;
                sum += plus;
                Console.WriteLine(sum);
            }
        }
    }
}


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

int main() {
    int N;
    cin >> N;
    int count = 0;
    for(int i=1;i<=N;i++){
        string s = to_string(i);  	
        if(s.length()%2 != 0) count += 1;
    }
    cout << count << endl;
    return 0;
}

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

typedef long long int ll;
const ll INF = 100000000;

int N,M;
using Graph = vector<vector<int>>;


int table[200010];
Graph G(10000000);
queue<int> Q;

void bfs(){
   while(Q.size() > 0){
      int a = Q.front();
      Q.pop();
      if(a == N){
         break;
      }
      int n = G[a].size();
      for(int i = 0;i < n;i++){
         if(table[G[a][i]] == INF){
            table[G[a][i]] = table[a] + 1;
            Q.push(G[a][i]);
         }
      }
   }
   return ;
}

int main(){
   cin >> N >> M;
   for(int i = 0;i < M;i++){
      int a,b;
      cin >> a >> b;
      G[a].push_back(b);
   }
   for(int i = 2;i < N+1;i++){
      table[i] = INF;
   }
   /*for(int i = 1; i < N+1;i++){
      int n = G[i].size();
      for(int j = 0;j < n;j++){
         cout << G[i][j] << '/';
      }
      cout << endl;
   }*/
   table[1] = 0;
   Q.push(1);
   bfs();
   if(table[N] <= 2){
      cout << "POSSIBLE" << endl;
   }else{
      cout << "IMPOSSIBLE" << endl;
   }
}

Measured memory_bytes: 239352
using System;

class Program
{
 static void Main(string[] args)
 {
   int coin500;
   int coin100;
   int coin50;
   int sum;
   int buff;
   int loop500;
   int loop100;
   int loop50;
   int cnt500 = 0;
   int cnt100 = 0;
   int cnt50 = 0;
   int paternNum = 0;
   
   coin500 = int.Parse(Console.ReadLine());
   coin100 = int.Parse(Console.ReadLine());
   coin50 = int.Parse(Console.ReadLine());
   sum = int.Parse(Console.ReadLine());
   
   buff = sum / 500;
   loop500 = ( coin500 > buff ? buff : coin500 );
   buff = sum / 100;
   loop100 = ( coin100 > buff ? buff : coin100 );
   buff = sum / 50;
   loop50 = ( coin50 > buff ? buff : coin50 );
   
   do
   {
     for( cnt100 = 0; cnt100 <= loop100; cnt100++ )
     {
       for( cnt50 = 0; cnt50 <= loop50; cnt50++ )
       {
         if( sum == ( ( 500 * cnt500 ) + ( 100 * cnt100 ) + ( 50 * cnt50 ) ) )
         {
           paternNum++;
         }
       }
     }
     cnt500++;
   }while(cnt500 <= loop500);
   
   Console.WriteLine(paternNum);
 }
}


Measured memory_bytes: 11092
#include <cstdio>

const int MAX = 2000000;
const int VMAX = 10000;

int A[MAX+2], C[VMAX+2];

int
main(int argc, const char *argv[])
{
    int n;
    scanf("%d", &n);

    int *B = new int[n];

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

    for (int i = 1; i <= VMAX; ++i) C[i] = C[i] + C[i-1];

    for (int j = n; j >= 1; --j) {
        B[C[A[j]]] = A[j];        
        C[A[j]]--;
    }

    for (int i = 1; i <= n; ++i) {
        if (i > 1) putchar(' ');
        printf("%d", B[i]);
    }
    putchar('\n');

    return 0;
}

Measured memory_bytes: 18376
#include<stdio.h>
#include<string.h>

int main()
{
	int n,p[101],m[101][101],i,j,k,l;

	scanf("%d",&n);
	for(i = 1; i <= n; i++) {
		scanf("%d %d",&p[i-1],&p[i]);
	}
	for (i = 0; i<= n; i++) {
		m[i][i] = 0;
	}
	for (l = 2; l <= n; l++) {
		for (i = 1; i <= n-l+1; i++) {
			j = i + l - 1;
			m[i][j] = 10000000;
			for (k = i; k <= j-1; k++) {
				if (m[i][j] > m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]) {
					m[i][j] = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
				}
			}
		}
	}
	printf("%d\n",m[1][n]);

	return 0;

}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
inline void qread(){}
template<class T1, class ...T2>
inline void qread(T1 &IEE, T2&... ls){
    register T1 __ = 0, ___ = 1;
    register char ch;
    while(!isdigit(ch = getchar())) ___ = (ch == '-') ? -___ : ___;
    do{
        __ = (__ << 1) + (__ << 3) + (ch ^ 48);
    }while(isdigit(ch = getchar()));
    __ *= ___;
    IEE = __;
    qread(ls...);
    return ;
}
ll n;
int main(){
    qread(n);
    n %= 10;
    if(n == 3){
        puts("bon");
    } else if(n == 0 || n == 1 || n == 6 || n == 8){
        puts("pon");
    } else {
        puts("hon");
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define pb push_back

using namespace std;

typedef long long ll;

const int N = 200000;

int n, m, col[N], Bi, uBi, Tak, cnt, Ot;
vector<int> G[N];	
bool mark[N];
bool f = 1;

void DFS(int v){
	mark[v] = 1;
	cnt++;
	for (auto u:G[v]){
		if (!mark[u]){
			col[u] = 1 - col[v];
			DFS(u);
		}else{
			if (col[u] == col[v]) f = 0;
		}
	}
}

int32_t main(){
	cin >> n >> m;
	for (int i = 1; i <= m; i++){
		int v, u;
		cin >> v >> u;
		G[v].pb(u), G[u].pb(v);
	}
	for (int i = 1; i <= n; i++){
		if (!mark[i]){
			cnt = 0;
			f = 1;
			DFS(i);
			if (cnt == 1) Tak ++;
			else{
				Ot += cnt;
				if (f) Bi++;
				else{
					uBi++;
				}
			}
		}
	}
	//cout << Bi << ' ' << uBi << ' ' << Tak << '\n';
	ll ans = 0;
	ans = 2 * Bi + uBi;
	ans += Tak * Tak + Ot * Tak * 2;
	ans += Bi * (Bi - 1) * 2;
	ans += 2 * Bi * uBi + uBi * (uBi - 1);
	cout << ans;
}


Measured memory_bytes: 15360
(defvar dream (concatenate 'list "maerd"))
(defvar erase (concatenate 'list "esare"))


(defmacro dif (lst l)
  `(loop for x in ,l
        unless (eq (pop ,lst) x)
        return t
        finally (return nil)))


(defun solve (lst)
  (loop do (cond
             ((null lst) (return t))
             ((eq (car lst) #\e) (if (dif lst erase) (return)))
             ((eq (car lst) #\m) (if (dif lst dream) (return)))
             (t (unless (and (eq (pop lst) #\r) 
                             (eq (pop lst) #\e)) (return))
                (unless (eq (car lst) #\m) (push #\e lst))))))



(if (solve (nreverse (concatenate 'list (read-line))))
    (princ "YES") (princ "NO"))

Measured memory_bytes: 8552
#include<stdio.h>
int main(void){

	int a,b,d,r;
	double f,a1,b1;
	scanf("%d",&a);
	scanf("%d",&b);
	d=a/b;
	r=a%b;
	a1=a;
	b1=b;
	f=a1/b1;
	printf("%d %d %.8lf\n",d,r,f);
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

    int n;
    cin >> n;
    int ma = 0, ans;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if(ma < a) {
            ma = a;
            ans = a + b;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long int
#define Mod 1000000007

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
  cin>>a>>b>>c;
  cout<<min(b/a,c)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  static int H, W;
  static int max = 0;
  static int[] ih = {1,0,-1,0};
  static int[] iw = {0,1,0,-1};
  static int[][] route;
  static char[][] maze;
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    H = Integer.parseInt(S[0]);
    W = Integer.parseInt(S[1]);
    route = new int[H][W];
    maze = new char[H][W];
    for(int i = 0; i < H; i++){
      String T = sc.nextLine();
      for(int j = 0; j < W; j++){
        maze[i][j] = T.charAt(j);
      }
    }
    
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(maze[i][j] == '#'){
          continue;
        }
        for(int k = 0; k < H; k++){
          for(int l = 0; l < W; l++){
            if(maze[k][l] == '#' || (i == k && j == l)){
              continue;
            }
            func(i, j, k, l);
          }
        }
      }
    }
    System.out.println(max);
  }
  public static void func(int sh, int sw, int gh, int gw){
    for(int i = 0; i < H; i++){
      Arrays.fill(route[i], 0);
    }
    Queue<Integer> qh = new ArrayDeque<>();
    Queue<Integer> qw = new ArrayDeque<>();
    qh.add(sh);
    qw.add(sw);
    
    while(!qh.isEmpty()){
      int nh = qh.poll();
      int nw = qw.poll();
      
      if(nh == gh && nw == gw){
        if(route[gh][gw] > max){
          max = route[gh][gw];
        }
        return;
      }
      
      for(int i = 0; i < 4; i++){
        int fh = nh+ih[i];
        int fw = nw+iw[i];
        
        if(fh < 0 || fh >= H || fw < 0 || fw >= W){
          continue;
        }
        if(maze[fh][fw] == '#' || route[fh][fw] > 0){
          continue;
        }
        
        qh.add(fh);
        qw.add(fw);
        route[fh][fw] = route[nh][nw]+1;
      }
    }
  }
}


Measured memory_bytes: 43972
from collections import Counter, defaultdict
n = int(input())
S = []
for i in range(n):
    S.append(Counter(input()))
dic = defaultdict(int)
ans = ''
for i in [chr(ord('a') + i) for i in range(26)]:
    ls = []
    for x in S:
        if i in x:
            ls.append(x[i])            
    if len(ls) == n:
        dic[i] = min(ls)
ans = ''
for i in [chr(ord('a') + i) for i in range(26)]:
    ans += i*dic[i]
print(ans)

Measured memory_bytes: 3316
n=int(input())
ans=10**10
dp=[0]*100001
for i in range(1,n+1):
  tmp=[dp[i-1]+1]
  if i>=6**1:
    tmp.append(dp[i-6**1]+1)
  if i>=9**1:
    tmp.append(dp[i-9**1]+1)
  if i>=6**2:
    tmp.append(dp[i-6**2]+1)
  if i>=9**2:
    tmp.append(dp[i-9**2]+1)
  if i>=6**3:
    tmp.append(dp[i-6**3]+1)
  if i>=9**3:
    tmp.append(dp[i-9**3]+1)
  if i>=6**4:
    tmp.append(dp[i-6**4]+1)
  if i>=9**4:
    tmp.append(dp[i-9**4]+1)
  if i>=6**5:
    tmp.append(dp[i-6**5]+1)
  if i>=9**5:
    tmp.append(dp[i-9**5]+1)
  if i>=6**6:
    tmp.append(dp[i-6**6]+1)
  if i>=9**6:
    tmp.append(dp[i-9**6]+1)
  dp[i]=min(tmp)
print(dp[n])

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

int main() {
  int N,P,W,G,Y;
  string S;
  cin >> N;
  P=W=G=Y=0;

  for(int i=0; i<N; i++) {
    cin >> S;
    if (S=="P") {
      P=1;
    } else if(S=="W") {
      W=1;
    } else if(S=="G") {
      G=1;
    } else if(S=="Y") {
      Y=1;
    }
  }
  int sum = P+W+G+Y;
  if (sum == 3) {
    cout << "Three" << endl;
  } else if(sum == 4) {
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("op.txt","w",stdout);
	// #endif

	clock_t startTime=clock();

	ll n,k;
	cin>>n>>k;
	ll ar[n];
	rep(i,0,n)
	{
		cin>>ar[i];
	}
	sort(ar,ar+n);
	ll sum=0;
	rep(i,0,k)
	{
		sum+=ar[i];
	}
	cout<<sum<<endl;

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

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

int main() {
  int A, B;
  cin >> A >> B;
  int ans;
  
  for(int i=A; i<=B; i++){
	int s = i%10, t = i/10000;
    int u = i/10%10, v = i/1000%10;
    if(s==t&&u==v) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main(){
  string S,T,U;
  int A,B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if (U == S){
    A -= 1;
  }else {
    B -= 1;
  }

  cout << A << " " << B << endl;
  return 0;
}


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

int main()
{
    int n, m, out = 0;
    cin >> n >> m;

    for (int i = 1; i < n; i++)
    {
        out = out + i;
    }

    for (int i = 1; i < m; i++)
    {
        out = out + i;
    }

    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools

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

cnt = 0

L = list(itertools.combinations(L,3))

for l in L:
    if l[0] + l[1] > l[2] and l[1] + l[2] > l[0] and l[2] + l[0] > l[1] and l[0] != l[1] and l[1] != l[2] and l[2] != l[0]:
        cnt += 1

print(cnt)

Measured memory_bytes: 20620
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n;
    scanf("%d", &n);
    int h[n];
    rep(i, n) scanf("%d", &h[i]);

    int ans = 0;
    for(int l=0; l<n;){
        int r = l;
        while(r < n-1 && h[r] >= h[r+1]) ++r;
        chmax(ans, r-l);
        l = r+1;
    }
    printf("%d\n", ans);
}

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

using namespace std;

bool f(string s){
	bool si = true;
	int a = 0, b = s.size() - 1;

	while(a < b){
		if(s[a] != s[b])
			si = false;
		a++;
		b--;
	}
	return si;
}
int main(){
	string s;
	cin >> s;
	if(f(s)){
		int mitad = (s.size())/2;
		string sub = s.substr(0, mitad);
		if(f(sub)){
			int index = (s.size()+2)/2;
			string fin = s.substr(index);
			if(f(fin)){
				cout << "Yes" << '\n';
				return 0;
			}
		}
	}
	cout << "No" << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <iterator>
#include <string>
using namespace std;

int main() {
    int n; scanf("%d", &n);
    map<string, int> si;

    for (int i = 0; i < n; i++) {
        string s; cin>>s;
        si[s]++;
    }

    int m = -1e9;
    for (auto it = si.begin(); it != si.end(); it++) 
        m = max(m, it->second);
    for (auto it = si.begin(); it != si.end(); it++) {
        if (it->second == m) cout<<it->first<<endl;
    }

    return 0; 
}


Measured memory_bytes: 19308
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
public static void main (String[] args){
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
	int[] a = new int[n];
	int count = 0, p = 0, q = 0;
	for(int i = 0; i < n; i++){
		a[i] = Integer.parseInt(sc.next());
	}
	for(int i = 0; i < n-2; i++){
		if(a[i] > a[i+1])p++;
		if(a[i+2] > a[i+1])q++;
		if((p+q) == 1)count++;
		p=0;
		q=0;
	}
	System.out.println(count);
}
}

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

int main() {
  int K,A,B;
  cin >> K >> A >> B;
  bool flag = false;
  for(int i = A; i <= B ; i++){
    if(i % K == 0) flag = true;
  }
  if(flag) cout << "OK" << endl;
  else cout << "NG" << endl;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main{
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    for(int i=1; i<=5; i++) {
      int x = sc.nextInt();
      if(x==0) {
        System.out.println(i);
        break;
      }
	}
  }
}


Measured memory_bytes: 35696