akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

using Facts = map<ll, int>; 
void factrize(ll n, Facts& mp) {
  if(n < 2) return;
  ll m = sqrt(n);
  REP(i, 2, m+1) {
    int cnt = 0;
    while(n%i == 0) {
      n /= i;
      ++cnt;
    }
    if(cnt > 0) mp[i] += cnt;
  }
  if(n != 1) mp[n]++;
}


int main(){
    ll n;
    cin >> n;
    Facts f;
    factrize(n, f);
    ll x = 1;
    for(auto&& i : f) x *= (i.se+1);
    cout << max(1, (int)f.size()) << " " << x -1 << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
	int L, b;
	while( 1 ){
		vector<int> a;
		cin >> b >> L;
		a.push_back(b);
		if( a[0] == 0 && L == 0 ) break;
		int i = 0;
		while( i < 20 ){
			vector<int> rank;
			int max = 0, min = 0;
			int number = a[i];
			//cout << number << ' ';
			for( int j = 0; j < L; j++ ){
				rank.push_back(number % 10);
				number /= 10;
			}
			sort( rank.begin(), rank.end() );
			for( int j = 0; j < L; j++ ){
				max += rank[j] * pow(10.0,(double)j);
			}
			sort( rank.begin(), rank.end(), greater<int>() );
			for( int j = 0; j < L; j++ ){
				min += rank[j] * pow(10.0,(double)j);
			}
			i++;
			a.push_back(max - min);		//a[i] = max -min;
			//cout << max << ' ' << min << ' ' << a[i] << endl;
			for( int j = 0; j < i; j++ ){
				if( a[j] == a[i] ){
					cout << j << ' ' << a[i] << ' ' << i - j << endl;
					goto end;
				}
			}
			rank.clear();
		}
	end:
		a.clear();
	}
}

Measured memory_bytes: 1264
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}

void print(int x){
	string s = to_string(x);
	for (int i = 0; i < 6-s.length(); i++){
		cout << 0;
	}
	cout << x;
}

int main(){
	int n, m;
	cin >> n >> m;
	vector<pair<int, pair<int, int> > > data[n+1];
	vector<pair<int, pair<int, int> > > ans;
	for (int i = 0; i < m; i++){
		int p, y;
		cin >> p >> y;
		data[p].push_back(make_pair(y, make_pair(data[p].size(), i)));
	}
	for (int i = 1; i <= n; i++){
		sort(data[i].begin(), data[i].end());
		for (int j = 0; j < data[i].size(); j++){
			ans.push_back(make_pair(data[i][j].second.second, make_pair(i, j+1)));
		}
	}

	sort(ans.begin(), ans.end());
	for (int i = 0; i < ans.size(); i++){
		print(ans[i].second.first);
		print(ans[i].second.second);
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 8308
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険                                   // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    char c; cin >> c;
    char res = (c - 'a' +1) % 26 + 'a';
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n*2);
  for(int i=0;i<n*2;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  int c=0;
  for(int i=0;i<n;i++){
    c+=a.at(i*2);
  }
  cout<<c<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <regex>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

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

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int pcnt(int x){
  return __builtin_popcount(x);
}

int f(int x){
  if(x == 0) return 0;
  return f(x%pcnt(x))+1;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int b = 0;
  for (int i = 0; i < n; ++i) {
    if(s[i] == '1') b++;
  }
  vector<int> ans(n);

  ll sum1 = 0, sum2 = 0;
  for (int i = 0; i < n; ++i) {
    sum1 *= 2;
    sum1 %= b + 1;
    if(s[i] == '1') sum1++;
    sum1 %= b + 1;
    if(b-1 <= 0) continue;
    sum2 *= 2;
    sum2 %= b - 1;
    if(s[i] == '1') sum2++;
    sum2 %= b - 1;
  }

  ll now = 1;
  for (int i = n-1; i >= 0; --i) {
    now %= b+1;
    if(s[i] == '0'){
      ll k = (sum1 + now) % (b+1);
      ans[i] = f(k) + 1;
    }
    now *= 2;
    now %= b+1;
  }

  now = 1;
  for (int i = n-1; i >= 0; --i) {
    if(b-1 <= 0) continue;
    now %= b-1;
    if(s[i] == '1'){
      ll k = (sum2 - now + b - 1) % (b-1);
      ans[i] = f(k) + 1;
    }
    now *= 2;
    now %= b-1;
  }

  rep(i, n) cout << ans[i] << endl;

}


Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
int n,s[111],z=1000,a;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		if((s[i]%10)!=0){
			if(z>s[i])z=s[i];
		}
		a+=s[i];
	}
	if((a%10)==0)a-=z;
	if(z==1000)a=0;
	cout<<a<<endl;
}



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	x := 0
	for i := 1; i <= n; i++ {
		if i %2 == 1 {
			x++
		}
	}

	fmt.Printf("%f", float64(x) / float64(n))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<ll>());
    ll b[N + 1]{};
    for (int i = 0; i < N; i++) {
        b[i + 1] = b[i] + A[i];
    }
    ll A_MAX = 2 * 100000 + 1;
    ll d[A_MAX]{}; // d[i]: パワーi以上を持つ人の数
    for (int i = 0; i < N; i++) {
        d[A[i]]++;
    }
    for (int i = A_MAX - 1; i >= 1; i--) {
        d[i - 1] += d[i];
    }
    ll l = -1;
    ll r = A_MAX + 1;
    while (r - l > 1) {
        ll m = (l + r) / 2;
        ll s = 0;
        for (int i = 0; i < N; i++) {
            s += d[max(0ll, m - A[i])];
        }
        if (s >= M) {
            l = m;
        } else {
            r = m;
        }
    }
    
    ll ans = 0;
    ll s = 0; // 握手した人の合計 
    for (int i = 0; i < N; i++) {
        int v = max(0, (int)(r - A[i]));
        ll t = max(0ll, min(d[v], M - s));
        ans += b[t] + t * A[i];
        s += t;
    }
    ans += l * (M - s);
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main(){

	int a[10] = {}, i, g, n;
	for (i = 0; i < 10; i++){ scanf("%d", &a[i]); }
	for (n = 0; n < 9; n++){
		for (i = 0; i < 9; i++){
			if (a[i] < a[i + 1]){
				g = a[i];
				a[i] = a[i + 1];
				a[i + 1] = g;
			}
		}
	}
	for (i = 0; i < 3; i++){ printf("%d\n", a[i]); }
	return 0;
}

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

int main(void){
	long long h,num,ans;
	cin>>h;
	num=1;
	ans=1;
	while(h>1){
		num*=2;
		ans+=num;
		h/=2;
	}
	cout<<ans<<'\n';	

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {      
      Scanner sc = new Scanner(System.in);
      String w = sc.next();
      char[] a = {'a', 'b', 'c','d','e','f', 'g', 'h', 'i', 'j', 'k', 'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
      int[] check = new int[26];
      int out =0;
      for (int j =0; j<26; j++) {
        for (int i =0; i< w.length(); i++) {
          if (w.charAt(i) == a[j]) check[j]++;
        }
      }
      for (int i=0 ; i<26; i++) {
        if(check[i] % 2 != 0) out++;
      }
      if (out != 0) {
        System.out.println("No");
      } else {
        System.out.println("Yes");
      }
    }
}

Measured memory_bytes: 21588
import math
n,d = map(int,input().split())
x_list = [ list(map(int,input().split())) for i in range(n)]
total = 0
for i in range(n-1):
    for j in range(i+1,n):
        ans = 0
        for k in range(d):
            ans += (x_list[i][k] - x_list[j][k])**2
        if math.sqrt(ans) % 1 == 0:
            total += 1
print(total)

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

int main() {
  int n;
  string s;
  cin >>n >>s;
  int k=0;
  string a="ABC";
  rep(i,n-2){
    if(s.substr(i,3)==a){
      k=k+1;
    }
  }
    
  cout << k <<endl;
}

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

int main(){
    double a,b,t;
    cin >> a >> b >> t;
    int sum,i;
    sum = 0;
    i = a;
    while(i <= t + 0.5){
        sum = sum + b;
        i = i + a;
    }
    cout << sum;
}

Measured memory_bytes: 256
function Main(input) {
	var data = input.split(/\a\n|\a|\n/).map(function(s) { return parseInt(s); });
	var x = [ [data[0], data[1], 0],
				[0, data[2], 0],
				[0, 0, 0] ]
	var sum = 3 * x[1][1]
	x[0][2] = sum - x[0][0] - x[0][1]
	x[2][1] = sum - x[0][1] - x[1][1]
	x[2][2] = sum - x[0][0] - x[1][1]
	x[2][0] = sum - x[2][1] - x[2][2]
	x[1][0] = sum - x[0][0] - x[2][0]
	x[1][2] = sum - x[0][2] - x[2][2]
	
	console.log(x[0][0] + " " + x[0][1] + " " + x[0][2])
	console.log(x[1][0] + " " + x[1][1] + " " + x[1][2])
	console.log(x[2][0] + " " + x[2][1] + " " + x[2][2])
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 6904
mod = 10**9 + 7

def sgn(v):
    return (v > 0) - (v < 0)

def compute_answer():
    v.sort(key=abs, reverse=True)
    prod = 1
    sg = 1
    for a in xrange(k):
        prod *= v[a]
        prod %= mod
        sg *= sgn(v[a])

    if sg >= 0:
        return prod

    if max(v) <= 0:
        prod = 1
        for a in xrange(-k,0):
            prod *= v[a]
            prod %= mod
        return prod

    def find_pair(comp):
        i = k-1
        while i >= 0 and comp(v[i]): i -= 1
        j = k
        while j < n and not comp(v[j]): j += 1
        if j == n: j = i
        return i, j
    i, j = find_pair(lambda w: w >= 0)
    I, J = find_pair(lambda w: w <= 0)
    if I >= 0 and v[j] * v[I] < v[i] * v[J]:
        i = I
        j = J

    prod = v[j]
    for a in xrange(k):
        if a != i:
            prod *= v[a]
            prod %= mod
    return prod

n, k = map(int, raw_input().strip().split())
v = map(int, raw_input().strip().split())
print compute_answer()

Measured memory_bytes: 101600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	int n;
	int k;
	vector<int>x;
	vector<int>y;
	scanf("%d", &n);
	if (n == 3) {
		printf("2\n");
		printf("1 3\n");
		printf("2 3\n");
		return 0;
	}
	k = n / 2;
	k *= 2;
	f(i, k) {
		f(j, k) {
			if (i < j) {
				if (i + j != (k - 1)) {
					x.push_back(i + 1);
					y.push_back(j + 1);
				}
			}
		}
		if (n % 2 == 1) {
			x.push_back(i + 1);
			y.push_back(n);
		}
}
	printf("%d\n", x.size());
	f(i, x.size())printf("%d %d\n", x[i], y[i]);

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define NUM_MEMBER 4000

int main(void) {
	long long int sales[NUM_MEMBER] = {0LL};
	int members[NUM_MEMBER] = {0};
	char exists[NUM_MEMBER] = {0};
	long long int price, num;
	int n, i, id, reg;
	const char *notfound;

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

		for (i = 0; i < NUM_MEMBER; i++) {
			sales[i] = 0LL;
			members[i] = 0;
			exists[i] = 0;
		}
		reg = 0;

		for (i = 0; i < n; i++) {
			scanf("%d %lld %lld", &id, &price, &num);
			id--;
			sales[id] += price * num;
			if (!exists[id]) {
				exists[id] = 1;
				members[reg++] = id;
			}
		}

		notfound = "NA";
		for (i = 0; i < reg; i++) {
			id = members[i];
			if (sales[id] >= 1000000LL) {
				printf("%d\n", id+1);
				notfound = NULL;
			}
		}
		if (notfound != NULL) {
			puts(notfound);
		}
	}
	return 0;
}

Measured memory_bytes: 668
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ======================================================================
    final int INF = (int)(1e9);
    int[][] dp = new int[1000010][2];
    public void solve() {
    	char[] C = ns().toCharArray();
    	for (int i = 0; i < dp.length; i++) {
			dp[i][0] = INF;
			dp[i][1] = INF;
		}
    	dp[0][0] = 0;
    	int k, wk;
    	for (int i = C.length - 1; i >= 0; i--) {
			k = C.length - i - 1;
			wk = (int)(C[i] - '0');
			dp[k+1][0] = Math.min(dp[k+1][0], dp[k][0] + wk);
			dp[k+1][0] = Math.min(dp[k+1][0], dp[k][1] + wk + 1);
			dp[k+1][1] = Math.min(dp[k+1][1], dp[k][0] + 10 - wk);
			dp[k+1][1] = Math.min(dp[k+1][1], dp[k][1] + 10 - wk - 1);
		}
    	out.println(Math.min(dp[C.length][0], dp[C.length][1] + 1));
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 76652
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  string S;
  string trueStr = "keyence";
  sc.scan(S);

  foreach (i; 0 .. trueStr.length) {
    if (S[0 .. i] ~ S[$ - (trueStr.length - i) .. $] == trueStr) {
      writeln("YES");
      return;
    }
  }

  writeln("NO");
}


Measured memory_bytes: 256
from math import gcd
from functools import reduce
import numpy as np

PC = True

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)

MAX = A[0]+1
mp = [0]*MAX

for i in A:
  mp[i] += 1

for i in range(2,MAX):
  if sum(mp[i::i])>1:
    PC = False
    break

if PC:
  print('pairwise coprime')
else:
  if reduce(gcd, A) == 1:
    print('setwise coprime')
  else:
    print('not coprime')

Measured memory_bytes: 150572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
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; }

signed main(){
  int n,m;
  cin >> n >> m;
  if(n == 1 && m == 1){
    cout << 1 << endl;
  }
  else if(n == 1 || m == 1){
    cout << max(n,m) - 2 << endl;
  }
  else{
    cout << (n-2)*(m-2) << endl;
  }
}

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

int main() {
  int n;
  int total=0;
  cin >> n;
  for (int i=0;i<n;i++) {
    int l,r;
    cin >> l >> r;
    total+= r-l+1;
  }
  cout << total << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */
int main()
{
	int		a,b,c,ans = 0;
	
	scanf("%d %d %d", &a,&b,&c);

	ans = min(a,min(b,c));
	printf("%d ",ans);
	if (ans==a) printf("%d %d\n",min(b,c),max(b,c));
	else if (ans==b) printf("%d %d\n",min(a,c),max(a,c));
	else printf("%d %d\n",min(a,b),max(a,b));
	
	return 0;
}



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

int main(){
    int N;
    int a[200];
    cin >> N;
    for(int i=0; i<N; i++)cin >> a[i];
    sort(a, a+N, greater<int>());
    int Alice=0;
    int Bob=0;

    for(int i=0; i<N; i++){
        if(i%2==0){
            Alice += a[i];
        }
        else{
            Bob += a[i];
        }
    }

    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
import sys

def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y)

n, m = map(int, input().split())
a = list(map(int, input().split()))

cur = a[0]
for x in a[1:]:
    g = gcd(cur, x)
    if (cur // 2) % g != (x // 2) % g:
        print(0)
        sys.exit(0)
    else:
        cur = cur // g * x
    if cur > m * 2:
        print(0)
        sys.exit(0)

print((m + cur // 2) // cur)


Measured memory_bytes: 63984
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	//int d;
	int e;
	cin >> a >> b >> c;
	//string s;
	//std::cin >> s;
	if (a == b) {
		cout << c << "\n";
	}
	else if (a == c) {
		cout << b << "\n";
	}
	else if (b == c) {
		cout << a << "\n";
	}
	std::cin >> e;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  string s = readString();
  for (auto &c : s) {
    if (c == ',')
      std::cout << " ";
    else
      std::cout << c;
  }
}


Measured memory_bytes: 2304
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll A, ll B, ll C) {
  cout << (A <= C && C <= B) << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll A;
	ll B;
	ll C;
	scanf("%lld", &A);
	scanf("%lld", &B);
	scanf("%lld", &C);
	solve(A, B, C);
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int mod=1e9+7;
int n,k;
long long ans;

inline int modpow(int x,int y,int res=1) {
	for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod;
	return res;
}
int vis[1000005],mui[1000005],prime[1000005],cnt;
inline void _pre_mui() {
    mui[1]=1;
    for(int i=2;i<=k;++i) {
        if(!vis[i]) prime[++cnt]=i,mui[i]=-1;
        for(int j=1;j<=cnt;++j) {
            if(i*prime[j]>k) break;
            vis[i*prime[j]]=1;
            if(!(i%prime[j])) {mui[i*prime[j]]=0;break;}
            else mui[i*prime[j]]=-mui[i];
        }
    }
}

int main() {
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d",&n,&k);
	//IN(n),IN(k);
	_pre_mui();
	for(int x=1;x<=k;++x) 
	{
		int res=modpow(k/x,n); /*次数*/
		for(int t=2;x*t<=k;++t)
			(res+=1ll*mui[t]*modpow(k/(x*t),n)%mod)%=mod;
		(ans+=1ll*res*x%mod)%=mod; /*贡献*/
	}
	printf("%lld\n",ans);
	return 0;
	//return printf("%d\n",ans),0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
#define ll long long 
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int main(){
	int n;
	cin>>n;
	ll ans=1;
	for(i,2,n) ans=(ans*i)%1000000007;
	cout<<ans<<"\n";
	exit(0);
}

Measured memory_bytes: 256
loop do
    n = gets.chomp.to_i

    break if n == 0

    min_v, max_v = 1e10, -1

    sum = 0

    n.times do |i|
        s = gets.chomp.to_i
        sum += s
        min_v = [s, min_v].min
        max_v = [s, max_v].max
    end

    puts (sum - max_v - min_v) / (n-2)

end


Measured memory_bytes: 6848
#include<iostream>
#include<cstring>
#define maxn  1000000007

using namespace std ;
#define ll long long int
int main()
{
string s ;
    ll d ;
    cin>> s>> d ;


    ll dp[s.length() +2 ] [ d] ={0} ;
    memset(dp , 0 , sizeof(dp)) ;
    dp[0][0] = 1 ;
    for(int i = 0 ;i < 10; i++ )
    {
        dp[1][i%d] = ( dp[1][i%d] +1 )%maxn ;

    }
    for(int i = 2 ; i< s.length() +1 ;i++ )
    {
        for(ll h = 0 ;h < d ;h++)
        {

            for( ll in =  0 ;in< 10 ;in++)
            {

ll  rem  =   (h - (in)%d + d  )%d  ;
dp[ i][h] = (dp[ i][h] + dp[i-1][rem ] )%maxn  ;

            }

        }




    }

 
 
     ll sum = 0 ;
     ll count = 0;
     for(ll i = 0 ; i < s.length() ;i++)
     {

         for(ll j = 0; j < s[i]-'0' ;j++ )
         {

             ll rem = j+sum ;
             rem%= d ;
             rem = (d-rem)%d ;

count = (count + dp[s.length()-i-1][rem]  )%maxn ;

         }
sum+= s[i]-'0' ;



     }
     count= ( count + dp[0][(d -sum%d ) %d ] )%maxn  ;
     

cout<<(maxn + count-1 )%maxn <<endl ;
}


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <cmath>
#include <iomanip>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;
typedef complex<double> P;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<P> A(3);
    REP(i, 0, 3) {
        int x, y;
        cin >> x >> y;
        A[i] = P(x, y);
    }
    vector<double> B(3);
    REP(i, 0, 3) {
        int j = (i + 1) % 3;
        B[i] = abs(A[i] - A[j]);
    }
    double S = [](double a, double b, double c) -> double {
        double s = (a + b + c) / 2;
        return sqrt(s * (s - a) * (s - b) * (s - c));
    }(B[0], B[1], B[2]);
    double r = 2 * S / (B[0] + B[1] + B[2]);
    double t = max({B[0], B[1], B[2]});
    cout << fixed << setprecision(15) << t / (2 + t / r) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int A;
  int zenbu;
  cin >> N >> A;
  zenbu = N%500;
    if (zenbu > A ){
    cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,i,w1,a,b,w2;
	scanf("%d",&n);
	b=-1;
	w2=0;
	for(i=1;i<=n;i++){
	    a=0;
		w1=i;
		while(1){
		    if(w1%2!=0) break; 
		    w1=w1/2;
			a++;
		}
		if(b<a){
		b=a;
		w2=i;
		}
	}
	printf("%d\n",w2);
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

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

  ll len = 0;
  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
    len += a[i];
  }

  ll ln = 0;
  ll rn = len;
  for (ll i = 0; i < n; ++i) {
    ll l = ln + a[i];
    ll r = len - l;
    if (l >= r) {
      ll d = min(abs(r-l), abs(ln-rn));
      cout << d << endl;
      return 0;
    }
    ln = l;
    rn = r;
  }
  
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
using namespace std;

int main(){
	int n;
	int INF = (int)1e9;
	int c = 0;
	while(cin >> n, n){
		vector<string> w(n);
		vector<int> p(n);
		map<string,int> mp;
		map<string,int>::iterator it;
		for(int i = 0; i < n; ++i){
			cin >> w[i] >> p[i];
			mp.insert( make_pair(w[i], p[i]) );
		}
		string s, t;
		cin >> s;

		vector<int> dp(s.size() + 1, -INF);
		dp[0] = 0;
		for(int i = 0; i < s.size(); ++i){
			t.clear();
			for(int j = i; j < s.size(); ++j){
				t += s[j];
				it = mp.find(t);
				if(it != mp.end()){
					dp[j + 1] = max(dp[j + 1], dp[i] + it->second);
				}
			}
		}
		
		int a = dp.back();
		dp.assign(a + 1, INF);
		dp[0] = 0;
		for(int i = 0; i < n; ++i){
			for(int j = p[i]; j <= a; ++j){
				dp[j] = min<int>(dp[j], dp[j - p[i]] + w[i].size());
			}
		}
		
		cout << "Case " << ++c << ": "<< dp[a] << '\n';
	}
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i < en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define int long long
int32_t main(){ fast;
	
	int k, n; cin>>k>>n;
	vector<int> a(n);
	rep(i, n){
		cin>>a[i];
	}
	int maxx = 0, sum = 0;
	for(int i = 1; i < n; i++){
		maxx = max(maxx, a[i] - a[i - 1]);
		sum += a[i] - a[i - 1];
	}
	sum += abs(k - a[n - 1] + a[0]);
	maxx = max(maxx, k - a[n - 1] + a[0]);
	cout<<sum - maxx<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e,f,g,h,i;
	cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
	/* a b c
	   d e f 
	   g h i
	*/
	if(a-b==d-e&&d-e==g-h){
		if(b-c==e-f&&e-f==h-i){
			if(c-a==f-d&&f-d==i-g){
				if(a-d==b-e&&b-e==c-f){
					if(d-g==e-h&&e-h==f-i){
						if(g-a==h-b&&h-b==i-c){
							cout<<"Yes";
							return 0;
						}
					}
				}
			}
		}
	}
	cout<<"No";
} 

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;
int main()
{
    ll N, D;
    cin >> N >> D;
    vector<ll> X(N), Y(N);
    rep(i, N) cin >> X[i] >> Y[i];
    int cnt = 0;
    ll dist = D * D;
    // cout << D * D << endl;
    rep(i, N){
        if(dist -  Y[i]*Y[i] >= X[i]*X[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6416
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <functional>
#include <queue>

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

int main() {
    ll m;
    cin >> m;
    cout << 48 - m << endl;
    return 0;
}


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

long long sum (vector<int> vec) {
    long long ans = 0;
    for (int i = 0; i < vec.size(); i++) ans += vec.at(i);
    return ans;
}

int allmin (vector<int> vec) {
    int ans = 1000000001;
    for (int i = 0; i < vec.size(); i++) {
        ans = min(ans, vec.at(i));
    }
    return ans;
}

int count_minus (vector<int> vec) {
    int ans = 0;
    for (int i = 0; i < vec.size(); i++) {
        if (vec.at(i) < 0) ans++;
    }
    return ans;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i; i < N; i++) cin >> A.at(i);
    
    vector<int> absA(N);
    for (int i; i < N; i++) absA.at(i) = abs(A.at(i));
  	
    long long ans;
    if (count_minus(A)%2 == 0) ans = sum(absA);
    else ans = sum(absA) - 2 * allmin(absA);
    cout << ans << endl;
}


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

long long int a[200001]={0};

int main(){
    int n;
    cin >> n;
    long long int ans=LLONG_MAX, sum=0;
    for(int i=0;i<n;++i){
        cin >> a[i];
        sum += a[i];
    }
    long long int sums = 0;
    for(int i=0;i<n-1;++i){
        sums += a[i];
        ans = min(ans, abs(sum - sums - sums));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#pragma GCC optimize("O2")
static inline int desc(const int*a,const int*b){return *b-*a;}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main()
{
  int i=0,N=IN(),A[200000];long sum=0;
  while(i<N){A[i++]=IN();}
  qsort(A,N,sizeof(int),(int(*)(const void*,const void*))desc);
  i=1;while(i<N){sum+=A[i++/2];}
  return printf("%ld\n",sum),0;
}

Measured memory_bytes: 2980
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let sum = a.iter().fold(0, |x, &y| x^y);
    for i in 0..n {
        puts!("{}{}", sum ^ a[i], if i + 1 == n { "\n" } else { " " });
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 4208
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
using namespace std;
int N, T;
vector< pair<int, int> > haha;
int A[3500], B[3500];
int memo[3500][3500];

int solve(int idx, int curMinutes) {
	if (curMinutes <= 0) return 0;
	if (idx == 0) return 0;
	if (memo[idx][curMinutes] != -1) return memo[idx][curMinutes];
	int ans = solve(idx-1, curMinutes);
	if (curMinutes > 0) ans = max(ans, solve(idx-1, curMinutes-A[idx]) + B[idx]);
	return memo[idx][curMinutes] = ans;
}


int main() {
	
	memset(memo, -1, sizeof(memo));
	
	scanf("%d %d", &N, &T);
	
	
	for(int i=1; i<=N; i++) {

		pair< int, int > lala;
		scanf("%d %d", &lala.first, &lala.second);
		haha.push_back(lala);
	}
	sort(haha.rbegin(), haha.rend());
	
	for(int i=0; i<N; i++) {
		//scanf("%d %d", &lala[i].second, &lala[i].first);
	//	printf(" >> %d %d\n", haha[i].first, haha[i].second);
		A[i+1] = haha[i].first;
		B[i+1] = haha[i].second;
	}

	printf("%d\n", solve(N, T));
	
	
	return 0;
}

Measured memory_bytes: 48256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n; cin >> n;
    vector<ll> t(n);
    ll ans = 0;

    rep(i,n){
        cin >> t[i];
        ans += t[i];
    }

    ll m; cin >> m;
    rep(i,m){
        ll p, x; cin >> p >> x; p--;
        int tmp = x - t[p];

        cout << ans + tmp << endl;
    }
}

Measured memory_bytes: 256
import sys

n, a, b = map(int, sys.stdin.readline().split())

def main(a, b):
    d = b - a
    if d % 2 == 0:
        return d // 2

    if n - b >= abs(1 - a):
        res = a
        b -= res
        a = 1
    else:
        res = n - b + 1
        a += res
        b = n

    res += (b - a) // 2
    return res

if __name__ == '__main__':
    ans = main(a, b)
    print(ans)

Measured memory_bytes: 3064
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

N, M = map(int, input().split())
wuf = WeightedUnionFind(N)

for _ in range(M):
  L, R, D = map(int, input().split())
  if wuf.same(L, R):
    if wuf.diff(L, R) != D:
      print("No")
      exit()
  else:
    wuf.union(L, R, D)

print("Yes")

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

void rotate_s(int (*dice)[4]){
	swap(dice[0][1], dice[1][1]);
	swap(dice[0][1], dice[2][1]);
	swap(dice[0][1], dice[1][3]);
}

void rotate_n (int (*dice)[4]){
	swap(dice[0][1], dice[1][1]);
	swap(dice[1][1], dice[2][1]);
	swap(dice[2][1], dice[1][3]);
}

void rotate_e (int (*dice)[4]){
	swap(dice[0][1], dice[1][0]);
	swap(dice[1][2], dice[2][1]);
	swap(dice[1][0], dice[1][2]);
}

void rotate_w (int (*dice)[4]){
	swap(dice[0][1], dice[1][2]);
	swap(dice[1][0], dice[2][1]);
	swap(dice[1][0], dice[1][2]);
}


int main() {
	int  face[6];
	int dice[3][4];
	string command;

	cin >> dice[0][1] >> dice[1][1] >> dice[1][2] >> dice[1][0] >> dice[1][3] >> dice[2][1];
	cin >> command;

	for(int i = 0; i < command.size(); i++){
		switch (command[i])
		{
		case 'E':
			rotate_e(dice);
			break;
		case 'W':
			rotate_w(dice);
			break;
		case 'N':
			rotate_n(dice);
			break;
		case 'S':
			rotate_s(dice);
			break;
		default:
			break;
		}
	}

	cout << dice[0][1] << endl;


	return 0;
}


Measured memory_bytes: 3212
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<math.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define mod 10007
using  namespace std;
int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}
char a[100005];
int n;
int main()
{
    scanf("%s",a);
    int i=0;
    int flag=0;
    n=strlen(a);
    char d[7]="dream",d1[8]="dreamer",e[7]="erase",e1[8]="eraser";
    i=n-1;
    while(i>=0)
    {
       char temp[10]="\0";
       if(i<4) break;
       for(int j=4;j>=0;j--)
              temp[j]=a[i-4+j];
       if(strcmp(temp,d)==0||strcmp(temp,e)==0)
       {
           i-=5;
           continue;
       }
       for(int j=5;j>=0;j--)
              temp[j]=a[i-5+j];
       if(strcmp(temp,e1)==0)
       {
           i-=6;
           continue;
       }
       for(int j=6;j>=0;j--)
              temp[j]=a[i-6+j];
       if(strcmp(temp,d1)==0)
       {
           i-=7;
           continue;
       }
       break;
    }
    //printf("%d\n",i);
    if(i==-1) printf("YES\n");
    else printf("NO\n");
    return 0;
}


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

int main() {
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    s = min({4 * q, 2 * h, s});

    ll ans = 0;
    if (s * 2 > d)
        ans = n / 2 * d + (n % 2) * s;
    else
        ans = s * n;

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int a, b, c, x;
    vector<int> v(1001, 0);
    cin >> a >> b >> c >> x;
    for (int i = 0; i <= c; ++i) {
        v[i]++;
    }
    for (int j = c; j >= 0; --j) {
        for (int i = 1; i <= b; ++i) {
            v[j+2*i] += v[j];
        }
    }
    for (int k = 2*b+c; k >= 0; --k) {
        for (int i = 1; i <= a; ++i) {
            v[k+10*i]+= v[k];
        }
    }
    cout << v[x/50] << "\n";
    return 0;
}


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

int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1},n=3;
bool check(int x,int y) {return x>=0&&x<n&&y>=0&&y<n;}
vector<char> rotate(vector<char> a,int k) {
  if(k%2) swap(a[0],a[2]);
  else swap(a[0],a[1]);
  return a;
}

char s[3][3];
int ans;
vector<vector<vector<char> > > v;
void dfs(int c,int p) {
  if(c>=ans) return;
  int xx,yy,d=0;
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      if(v[i][j][0]=='E') xx=i,yy=j;
      if(v[i][j][0]!=s[i][j]) d++;
    }
  }
  if(!d) {
    ans=min(ans,c);
    return;
  }
  if(d+c>ans) return;
  for(int i=0; i<4; i++) {
    int x=xx+dx[i],y=yy+dy[i];
    if(!check(x,y)||i==p) continue;
    v[x][y]=rotate(v[x][y],i);
    swap(v[xx][yy],v[x][y]);
    dfs(c+1,(i+2)%4);
    swap(v[xx][yy],v[x][y]);
    v[x][y]=rotate(v[x][y],i);
  }
}

int main() {
  int xx,yy;
  while(cin >> yy >> xx && xx) {
    v.clear();
    for(int i=0; i<n; i++) {
      for(int j=0; j<n; j++) cin >> s[i][j];
    }
    for(int i=1; i<4; i++) {
      vector<vector<char> > a;
      for(int j=1; j<4; j++) {
        vector<char> c;
        if(i==xx&&j==yy) {
          for(int k=0; k<3; k++) c.push_back('E');
        } else {
          c.push_back('W');
          c.push_back('R');
          c.push_back('B');
        }
        a.push_back(c);
      }
      v.push_back(a);
    }
    ans=31;
    dfs(0,-1);
    if(ans==31) ans=-1;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2996