akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>

using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

typedef vector<vector<ll> > Matrix;

const ll INF = 100000000;
Matrix d; // グラフの距離を格納した2次元配列（隣接行列）
          // d[u][v]は辺e=(u,v)のコスト（辺が存在しない場合はINF、ただしd[i][i]=0）

int warshall_floyd(int n) { // nは頂点数
    for (int i = 0; i < n; i++){      // 経由する頂点
        for (int j = 0; j < n; j++){    // 開始頂点
            for (int k = 0; k < n; k++){  // 終端
                if( (d[j][k] % 2) != (d[j][i] + d[i][k]) % 2 ){
                    if(d[j][k] != INF && d[j][i] != INF && d[i][k] != INF) return -1;
                }
                //cout << d[j][i] << d[i][k] << endl;
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
}

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

    //コストマップを初期化
    d = Matrix(n, vector<ll>(n, INF));
    for (int i = 0; i < n; i++){
        d[i][i] = 0;
    } 
    
    //コストマップに代入
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        for(int j = 0; j < n; j++){
            if(s[j] == '1'){
                d[i][j] = 1;
                d[j][i] = 1;
            }
        }
    }


    //引数：頂点数
    if( warshall_floyd(n) == -1 ){
        cout << -1 << endl;
        return 0;
    }

    /*
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cout << d[i][j] << " " ;
        }
        cout << endl;
    }
    */

    ll ans = 0;
    for(int i = 0; i < n ; i++){
        for(int j = 0 ; j < n; j++){
            if(i != j)  ans = max(ans, d[i][j]);
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define irp(i,s,e) for(int i=(int)(s);i>(int)(e);--i)

// #define NMAX 1000000000
int a,b,c,k;

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

	int ans = min(k,a);
	if(k-a-b > 0 ) ans -= k-a-b;
	cout<<ans<<"\n";

}


Measured memory_bytes: 3596
fn main() {
	use std::io::Read;
	let mut s = String::new();
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let k: usize = s.next().unwrap().parse().unwrap();
	let s: Vec<char> = s.next().unwrap().chars().collect();
	let mut l = 0;
	let mut r = 0;
	let mut cnt = 0;
	let mut ans = 0;
	while l < s.len() {
		while r < s.len() {
			if s[r] == '0' {
				if cnt >= k {
					break;
				}
				while r < s.len() && s[r] == '0' {
					r += 1;
				}
				cnt += 1;
			} else {
				r += 1;
			}
		}
		if r - l > ans {
			ans = r - l;
		}
		if s[l] == '1' {
			while l < s.len() && s[l] == '1' {
				l += 1;
			}
		}
		if l < s.len() {
			if cnt > 0 {
				cnt -= 1;
			}
			while l < s.len() && s[l] == '0' {
				l += 1;
			}
		}
	}
	println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 998244353
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
char S[301010];
int cal[303030];

void calc(int t)
{
	int r = 0, g = 0, b = 0;
	for (int i = 0; i < 3 * N; ++i) {
		int m = max(r, max(g, b));
		switch(S[i]) {
			case 'R': ++r; break;
			case 'G': ++g; break;
			case 'B': ++b; break;
		}
		if (max(r, max(g, b)) != m) {
			cal[i] = t;
		}
	}
}

int trans(char c)
{
	if (c == 'R') return 0;
	if (c == 'G') return 1;
	return 2;
}
int main()
{
	scanf("%d%s", &N, S);
	fill(cal, cal + 3 * N, 2);
	calc(0);
	reverse(cal, cal + 3 * N); reverse(S, S + 3 * N);
	calc(1);
	reverse(cal, cal + 3 * N); reverse(S, S + 3 * N);

	i64 ret = 1;
	for (int i = 1; i <= N; ++i) ret = ret * i % MOD;
	
	int nz[3] = {0, 0, 0};
	int nt[3] = {0, 0, 0};

	int waf = 0;
	for (int i = 0; i < 3 * N; ++i) {
		int v = trans(S[i]);
		/*
		if (cal[i] == 0) waf -= i;
		if (cal[i] == 1) waf += i;
		if (cal[i] == 0) ++nz[v];
		else if (cal[i] == 2) ++nt[v];
		else {
			printf("%d: %c\n", i, S[i]);
			if (nz[(v + 1) % 3] != 0 && nt[(v + 2) % 3] != 0) {
				printf("%d %d\n", nz[(v + 1) % 3], nt[(v + 2) % 3]);
				ret = ret * nz[(v + 1) % 3] % MOD; --nz[(v + 1) % 3];
				ret = ret * nt[(v + 2) % 3] % MOD; --nt[(v + 2) % 3];
			} else {
				printf("%d %d\n", nz[(v + 2) % 3], nt[(v + 1) % 3]);
				ret = ret * nz[(v + 2) % 3] % MOD; --nz[(v + 2) % 3];
				ret = ret * nt[(v + 1) % 3] % MOD; --nt[(v + 1) % 3];
			}
			printf("%lld\n", ret);
		}
		*/
		if (cal[i] == 0) {
			++nz[v];
		} else if (cal[i] == 2) {
			if (nz[(v + 1) % 3] != 0) {
				ret = ret * nz[(v + 1) % 3]-- % MOD;
				++nt[(v + 2) % 3];
			} else {
				ret = ret * nz[(v + 2) % 3]-- % MOD;
				++nt[(v + 1) % 3];
			}
		} else {
			ret = ret * nt[v] % MOD;
			--nt[v];
		}
	}
	//printf("%d\n", waf);
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 1664
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long mod = 1000000007;

template<typename T>
void max_self(T& a, T b)
{
	a = max(a, b);
}

// dp[i] - TRUE if first player wins with i stones remaining

int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n, k;
	cin >> n >> k;
	vi a(n);
	for (int& ac : a)
		cin >> ac;
	vector<bool> dp(k + 1);
	for (int stones = 0; stones <= k; stones++)
		for (int x : a)
		{
			if (stones >= x && !dp[stones - x])
				dp[stones] = true;
		}
	if (dp[k])
		cout << "First";
	else
		cout << "Second";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int n, m, Q;
  cin >> n >> m >> Q;
  int sta[500][500];
  rep(i, m){
    int l, r;
    cin >> l >> r;
    l--;r--;
    sta[l][r]++;
  }
  ll S[500][500];
  rep(i, n) S[i][i] = sta[i][i];
  for(int i = 0; i < n; i++){
    for(int j = i; j < n-1; j++){
      S[i][j+1] = S[i][j] + sta[i][j+1];
    }
  }
  
  rep(i, Q){
    int p, q;
    cin >> p >> q;
    p--;q--;
    ll res = 0;
    for(int j = p; j <= q; j++){
      res += S[j][q];
    }
    cout << res <<endl;
  }
}

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

typedef struct {
    double x, y;
} P;

double
distance(P *, P *);

int
main(void)
{
    P p1, p2;
    scanf("%lf %lf %lf %lf", &p1.x, &p1.y, &p2.x, &p2.y);
    printf("%f\n", distance(&p1, &p2));

    return 0;
}

double
distance(P * p1, P * p2)
{
    double d1 = fabs(p1->x - p2->x);
    double d2 = fabs(p1->y - p2->y);
    return sqrt(d1 * d1 + d2 * d2);
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N, K;
ll A[202020];
ll mk[202020];
ll ans;
ll i, j, k;
int main(){
    scanf("%lld%lld", &N, &K);
    fornum(i,0,N){
        scanf("%lld", &A[i+1]);
    }
    i = 1;
    j = 0;
    while(mk[i]==0){
        mk[i] = ++j;
        i = A[i];
    }
    if(K<j){
        K++;
        fornum(i,0,N){
            if(mk[i+1]==K){
                printf("%lld\n", i + 1);
            }
        }
        return 0;
    }
    K -= mk[i] - 1;
    j = K % (j + 1 - mk[i]);
    j += mk[i];
    fornum(i,0,N){
        if(mk[i+1]==j){
            printf("%lld\n", i + 1);
        }
    }

    return 0;
}

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

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		long N = long.Parse(Console.ReadLine());

		//カウンター
		long cnt = 0;

		//ループ処理
		for(long i=1; i<=N; i++){
				if(i%3 != 0 && i%5 != 0){
						cnt += i;
				}
		}

		Console.WriteLine(cnt);

	}
}


Measured memory_bytes: 17684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  string S;
  cin >> N >> M;
  cin >> S;
  int flag = 0;
  vector<int> result;
  for(int now = N;now > 0;now += 0){
    flag = 0;
    for(int a = min(M,now);a > 0;a -= 1){
      
      if(S[now - a] == '0'){
       now =  now - a;
        result.push_back(a); 
        flag = 1;
        break;
      }
 
    }
    if(flag == 0){
       break; 
      }
      
  }
  if(flag == 0){
    cout<<-1<<endl;
  }else{
    for(int a = result.size() - 1;a >= 0;a -= 1)cout<<result.at(a)<<" ";
  }
 
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
int main(){
  string N;
  int K;
  cin >> N >> K;
  int d = N.size();
  if (K == 1){
    cout << (d - 1) * 9 + N[0] - '0';
  } else if (K == 2){
    if (d == 1){
      cout << 0;
    } else {
      int ans = 81 * (d - 1) * (d - 2) / 2;
      ans += (N[0] - '1') * 9 * (d - 1);
      int z = 1;
      while (N[z] == '0') z++;
      if (z == d){
        cout << ans;
      } else {
        ans += 9 * (d - z - 1);
        ans += N[z] - '0';
        cout << ans;
      }
    }
  } else {
    if (d < 3){
      cout << 0;
    } else {
      int ans = 729 * (d - 1) * (d - 2) * (d - 3) / 6;
      ans += (N[0] - '1') * 81 * (d - 1) * (d - 2) / 2;
      int z1 = 1;
      while (N[z1] == '0') z1++;
      if (z1 == d){
        cout << ans;
      } else {
        ans += 81 * (d - z1 - 1)* (d - z1 - 2) / 2;
        ans += (N[z1] - '1') * 9 * (d - z1 - 1);
        int z2 = z1 + 1;
        while (N[z2] == '0') z2++;
        if (z2 == d){
          cout << ans;
        } else {
          ans += 9 * (d - z2 - 1);
          ans += N[z2] - '0';
          cout << ans;
        }
      }
    }
  }
}

Measured memory_bytes: 256
def interest_rates(y, r, t)
  return t == 1 ? 1 + y * r / 100.0 : (1 + r / 100.0) ** y
end

until (n = gets.to_i).zero?
  y, arr, tmp1, ans = gets.to_i, [], 0, nil
  
  n.times do
    b, r, t = gets.split.map(&:to_i)
    tmp2 = interest_rates(y, r, t)
    if tmp1 < tmp2
      ans = b
      tmp1 = tmp2
    end
  end
  
  puts ans
end

Measured memory_bytes: 6228
N=int(input())
A=list(map(int,input().split()))
if N==2:
    print(max(A))
elif N==3:
    print(max(A))
else:
    if N%2==1:
        dp=[[0 for i in range(0,3)] for i in range(0,N)]
        dp[0][2]=A[0]
        dp[0][1]=-float('inf')
        dp[0][0]=-float('inf')
        dp[1][2]=-float('inf')
        dp[1][1]=A[0]
        dp[1][0]=-float('inf')

        for i in range(2,N):
            if i==N-1:
                dp[N-1][0]=dp[N-3][0]+A[N-1]
            else:
                dp[i][0]=max(dp[i-2][0]+A[i],dp[i-1][1])
                dp[i][1]=max(dp[i-2][1]+A[i],dp[i-1][2])
                dp[i][2]=dp[i-2][2]+A[i]

        test1=dp[N-1][0]

        dp=[[0 for i in range(0,2)] for i in range(0,N)]
        dp[0][1]=-float('inf')
        dp[0][0]=0
        dp[1][1]=A[1]
        dp[1][0]=-float('inf')

        for i in range(2,N):
            if i==N-1:
                dp[N-1][0]=dp[N-3][0]+A[N-1]
            else:
                dp[i][0]=max(dp[i-2][0]+A[i],dp[i-1][1])
                dp[i][1]=dp[i-2][1]+A[i]

        test2=dp[N-1][0]

        A=A[::-1]
        dp=[[0 for i in range(0,2)] for i in range(0,N)]
        dp[0][1]=-float('inf')
        dp[0][0]=0
        dp[1][1]=A[1]
        dp[1][0]=-float('inf')

        for i in range(2,N):
            if i==N-1:
                dp[N-1][0]=dp[N-3][0]+A[N-1]
            else:
                dp[i][0]=max(dp[i-2][0]+A[i],dp[i-1][1])
                dp[i][1]=dp[i-2][1]+A[i]

        test3=dp[N-1][0]

        test4=sum(A[i] for i in range(0,N) if i%2==1)

        print(max(test1,test2,test3,test4))

    if N%2==0:
        dp=[[0 for i in range(0,2)] for i in range(0,N)]
        dp[0][1]=A[0]
        dp[0][0]=-float('inf')
        dp[1][1]=-float('inf')
        dp[1][0]=A[0]

        for i in range(2,N):
            if i==N-1:
                dp[N-1][0]=dp[N-3][0]+A[N-1]
            else:
                dp[i][0]=max(dp[i-2][0]+A[i],dp[i-1][1])
                dp[i][1]=dp[i-2][1]+A[i]

        test1=dp[N-1][0]

        test3=sum(A[i] for i in range(0,N) if i%2==0)
        test4=sum(A[i] for i in range(0,N) if i%2==1)

        print(max(test1,test3,test4))

Measured memory_bytes: 188564
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

int main(){

    ll N, X;
    cin >> N >> X;
    vector<ll> L(N);
    for(int i = 0; i < N; i++) cin >> L[i];

    ll p = 0;
    int cnt = 0;
    for(ll i = 0; i < N; i++){
        if(p <= X ) cnt++;
        p += L[i];
    }
        if(p <= X ) cnt++;

    cout << cnt << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;
class v {
public:
	int x;
	int y;
	int tag;

	v(int x, int y, int tag) {
		this->x = x;
		this->y = y;
		this->tag = tag;
	}

	int d(v obj) {
		return abs(obj.x - this->x) + abs(obj.y - this->y);
	}

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

	vector<v> a;
	for (int i = 0; i < n; i++) {
		int ta, tb;
		cin >> ta >> tb;
		a.push_back(v(ta, tb, i+1));
	}
	vector<v> c;
	for (int i = 0; i < m; i++) {
		int tc, td;
		cin >> tc >> td;
		c.push_back(v(tc, td, i+1));
	}

	for (auto e : a) {
		int min = 2000000000;
		int mintag = 55;
		for (auto f : c) {
			if (min > e.d(f)) {
				min = e.d(f);
				mintag = f.tag;
			}
		}
		cout << mintag << endl;
	}

	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
int main(void){
    int A,B;
    int ans;
    char op;
    scanf("%d %c %d",&A,&op,&B);

    if(op=='+'){
        ans=A+B;
    }else{
        ans=A-B;
    }

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

map<string, int> mp;
int N;
string S;

int main() {

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> S;
		mp[S] = mp[S] + 1;
	}

	int max = 0;
	for (auto i = mp.begin(); i != mp.end(); ++i) {
		int m = i->second;
		if (max < m) { max = m; }
	}

	for (auto i = mp.begin(); i != mp.end(); ++i) {
		int m = i->second;
		if (max == m) { cout << i->first << "\n"; }
	}
	
}

Measured memory_bytes: 25216
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var q = ReadLine().Split(' ').Select(long.Parse).ToList();
            long a = q[0];
            long b = q[1];
            long x = q[2];

            long n = a / x + 1;
            long m = b / x + 1;
            WriteLine(a % x == 0 ? m - n + 1 : m - n);

        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 11348
def p_d():
    n, x = map(int, input().split())
    b, p = [1], [1]
    for i in range(n):
        b.append(b[i] * 2 + 3)
        p.append(p[i] * 2 + 1)

    def solve(n, x):
        if n == 0:
            return 0 if x <= 0 else 1
        elif x <= 1 + b[n - 1]:
            return solve(n - 1, x - 1)
        else:
            return p[n - 1] + 1 + solve(n - 1, x - 2 - b[n - 1])

    print(solve(n, x))


if __name__ == '__main__':
    p_d()

Measured memory_bytes: 38384
import numpy as np

CHAR = "abcdefghijklmnopqrstuvwxyz"

N = int(input()) - 1
s = ""

while(True):
    b = N % 26
    N = N // 26
    s = CHAR[b] + s
    if(N == 0):
        print(s)
        break
    N -= 1


Measured memory_bytes: 27140
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    long long N;
    string S;
    long long alphabet[26]={0};

    cin >> N;

    // S_0だけ先に入力
    cin >> S;
    rep(j,S.length()){
        alphabet[S[j]-'a']++;
    }

    rep(i,N-1){
        long long alphabet2[26]={0};
        cin >> S;
        rep(j,S.length()){
            alphabet2[S[j]-'a']++;
        }
        rep(j,26){
            alphabet[j] = min(alphabet[j],alphabet2[j]);
        }
    }

    for(int i=0; i<26; i++){
        char alpha='a'+i;
        for(int j=0; j<alphabet[i]; j++){
            cout << alpha;
        }
    }

    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

 
int main(){
	int N,M; cin >> N >> M;
	vector<ll> x(N),y(N),z(N);
	rep(i,N){
		cin >> x[i] >> y[i] >> z[i];
	}
	ll ans = 0;
	rep(i,1<<3){
		vector<ll> wa(N);
		rep(j,3){
			rep(k,N){
				if(i>>j&1){
					if(j == 0) wa[k] += x[k];
					if(j == 1) wa[k] += y[k];
					if(j == 2) wa[k] += z[k];
				}
				else{
					if(j == 0) wa[k] += -x[k];
					if(j == 1) wa[k] += -y[k];
					if(j == 2) wa[k] += -z[k];
				}
			}
		}
		sort(wa.begin(),wa.end(),greater<ll>());
		ll sum = 0;
		rep(j,M){
			sum += wa[j];
		}
		ans = max(ans,sum);
	}
	cout << ans << endl;
}


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

struct Node {
	int key;
	Node *next, *prev;
};

int main()
{
	Node *nil = new Node;
	nil->next = nil;
	nil->prev = nil;

	int n;
	scanf( "%d", &n );
	for( int i = 0; i < n; i++ ) {
		char command[32];
		int key;
		scanf( "%s", command );
		if( strcmp( command, "insert" ) == 0 ) {
			scanf( "%d", &key );
			Node *node = new Node;
			node->key = key;
			node->next = nil->next;
			nil->next->prev = node;
			nil-> next = node;
			node->prev = nil;
		}
		else if( strcmp( command, "delete" ) == 0 ) {
			scanf( "%d", &key );
			Node *cur = nil->next;
			while( cur != nil && cur->key != key ) {
				cur = cur->next;
			}
			if( cur != nil ) {
				cur->prev->next = cur->next;
				cur->next->prev = cur->prev;
				delete cur;
			}
		}
		else if( strcmp( command, "deleteFirst" ) == 0 ) {
			Node *cur = nil->next;
			if( cur != nil ) {
				cur->prev->next = cur->next;
				cur->next->prev = cur->prev;
				delete cur;
			}
		}
		else if( strcmp( command, "deleteLast" ) == 0 ) {
			Node *cur = nil->prev;
			if( cur != nil ) {
				cur->prev->next = cur->next;
				cur->next->prev = cur->prev;
				delete cur;
			}
		}
	}

	Node *cur = nil->next;
	for( int i = 0; cur != nil; i++, cur = cur->next ) {
		if( i ) printf( "%s", " " );
		printf( "%d", cur->key );
	}
	printf( "\n" );
}



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

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

int main(){
  int n;
  cin >> n;
  int x[n], a[n];
  for(int i = 0; i < n; i++){
    cin >> x[i];
    a[i] = x[i];
  }
  sort(a, a+n);
  int m1 = a[(n-1)/2], m2 = a[n/2];
  double idx = (m1 + m2) / 2;
  for(int i = 0; i < n; i++){
    if(x[i] > idx) cout << m1 << endl;
    else cout << m2 << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{	
	long long int i,n,a;
	while(cin>>n)
	{
	a=1;
	for(i=n;i>=1;i--)
	{
	a=a*i;	
	}
    cout<<a<<endl;
}
	return 0;
}

Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
long long int a[100010];
long long int b[100010];
int main()
{
  long long int x,y,z,l=100000000,m=0,n,p,q=0,r,s,t,u,v,w,k,i,j;
  cin>>n>>k;
  for(i=0;i<=n-1;i++)
  {
      cin>>a[i];
  }
  for(i=1;i<=n-1;i++)
  {
      b[i]=100000000000;
  }
for(i=0;i<=n-1;i++)
{

    for(j=1;j<=k;j++)
    {
        if(i+j<=n)
        {
            b[i+j]=min(b[i+j],b[i]+abs(a[i]-a[i+j]));
        }
    }

}
cout<<b[n-1];
}

Measured memory_bytes: 1792
n = int(input())
c = list(input())

# 色の変更で対応する場合のステップ数
numW = c.count('W')
numR = c.count('R')

# スワップするときのステップ数
rindex = [i for i, x in enumerate(c) if x == 'R']
rindextobe = range(0, len(rindex))
swap = len(set(rindex) - set(rindextobe))

print(min(numW, numR, swap))

Measured memory_bytes: 47556
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a, LL b) {LL s = 1; while (b > 0) {if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1;} return s;}
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
typedef pair<int, int> P;
string s[6] = {"Sunny", "Cloudy", "Rainy", "Sunny", "Cloudy", "Rainy"};
int main(void)
{

	string t; cin >> t;
	for (int i = 0; i < 3; ++i)
		if (t == s[i])
			cout << s[i + 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 
#include <numeric>
#include <cctype>

using namespace std; 

const long long mod=1e9+7;


int main(){

    int a,b;
    cin>>a>>b;

    for(int i=0;i<=a;i++){
        if( (a-i)*2+i*4 == b ){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define F first
#define S second
#define INF 10000000
#define inf -10000000
#define pb push_back
#define forr(i,p,n) for(int i=p;i<n;i++)
#define mp make_pair
#define upb(a,s) upper_bound(a.begin(),a.end(),s)
#define lwb(a,s) lower_bound(a.begin(),a.end(),s)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
priority_queue<ll> pq;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll a,b,c,d,n;
    while(cin>>a>>b){
      if(a>b*2){
	cout<<abs(a-b*2)<<endl;
      }
      else cout<<0<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

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

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
    int n,m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i,m) cin >> p[i].first >> p[i].second;
    
    rep(x,1000) {
        int keta = 1;
        int nx =x/10;
        vector<int> d(1,x%10);
        while (nx)
        {
            keta++;
            d.push_back(nx%10);
            nx /= 10;
        }
        if (keta != n) continue;
        bool ok = true;
        reverse(d.begin(), d.end());
        rep(i,m) {
            if (d[p[i].first-1] != p[i].second) ok = false;
        }
        if (ok)
        {
            cout << x << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  long long L[87];
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= n; ++i) L[i] = L[i - 1] + L[i - 2];
  cout << L[n] << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			StringBuilder str = new StringBuilder(sc.next());
			int N = sc.nextInt();
			for (int i = 0; i < N; i++) {
				String order = sc.next();
				int a = sc.nextInt();
				int b = sc.nextInt() + 1;
				if (order.equals("print")) {
					System.out.println(str.substring(a, b));
				} else if (order.equals("reverse")) {
					str.replace(a, b, (new StringBuilder(str.substring(a, b))).reverse().toString());
				} else {
					String x = sc.next();
					str.replace(a, b, x);
				}
			}
		}
	}
}


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

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[][] graph = new int[n][n];
      String[] vInfo;
      int degree;

      for(int i=0; i<n; i++) {
        vInfo = br.readLine().split(" ");
        degree = Integer.parseInt(vInfo[1]);
        for(int j=0,k=2,v=0; j<degree; j++) {
          v = Integer.parseInt(vInfo[k++]);
          graph[i][v-1] = 1;
        }
      }

      StringBuilder buf = new StringBuilder(n*n*2);
      for (int[] vertex : graph) {
        for (int v : vertex) {
          buf.append(v).append(" ");
        }
        buf.setLength(buf.length()-1);
        buf.append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }
}


Measured memory_bytes: 25368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod=1000000007;

int main(){
    string s;cin>>s;
    int ssz=s.size();
    int a[3]={};
    rep(i,ssz){
        if(s[i]=='a')a[0]++;
        else if(s[i]=='b')a[1]++;
        else a[2]++;
    }
    sort(a,a+3);
    if(a[2]-a[0]>1)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

ll n,k,ans=0;

void init(){
	cin>>n>>k;
}

int main(void){
	init();
	while(n>0){
		n/=k;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N;
  cin>>N;
  
  vector<ll>a(N);
  
  rep(i,N){
    cin>>a[i];
  }
  
  ll sum4=0;
  ll sum1=0;
  rep(i,N){
    if(a[i]%4==0){
      sum4++;
    }
    else if(a[i]%2==1){
      sum1++;
    }
  }
  
  
  if(sum1==0){
    cout<<"Yes"<<endl;
  }
  else{
if(sum1==sum4){
  cout<<"Yes"<<endl;
}
    else if(sum1=sum4+1){
      if(N-sum4-sum1==0){
cout<<"Yes"<<endl;
      }
else{
      cout<<"No"<<endl;
}
    }
    else{
       cout<<"No"<<endl;
      
    }

  }

}


Measured memory_bytes: 1024
/* author: jeetganatra */

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define endl            "\n"
#define PI              3.14159265
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

 
void jpg()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int mpow(int base, int exp); 



int32_t main()
{
	jpg();
	int n;
	cin>>n;
	vector<pair<int,int>> a(n);
	fo(i,n)
	{
		cin>>a[i].ff>>a[i].ss;
	}

	int count=0;
	bool ok=false;


	for(int i=0;i<n;)
	{
		if(a[i].ff==a[i].ss)
		{
			count++;
			i++;
			if(count==3)
			{
				ok=true;
				break;
			}
		}

		else
		{
			count=0;
			i++;
		}
	}

	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((int)result * base) % mod;
    base = ((int)base * base) % mod;
    exp >>= 1;
  }
  return result;
}



Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main()
{
    long long int num,smin,smax;
    cin>>num>>smin>>smax;
    if(num<=0 || smin<=0 || smax<=0)
    {
        cout<<0;
        return 0;
    }
    if(smin>smax)
    {
        cout<<0;
        return 0;
    }
    if(num==1 && smin==smax)
    {
        cout<<1;
        return 0;
    }
    if(num==1 && smin!=smax)
    {
        cout<<0;
        return 0;
    }
    else
    {
        cout<<(num-2)*(smax-smin)+1;
    }

    return 0;
}


Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,ans=0;
  cin>>n;
  cout<<n*n<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int> > a(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }
  int ans = 1e9;
  for (int bit = 0; bit < (1 << n); ++bit) {
    vector<int> total(m);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      if (bit >> i & 1) {
        sum += c[i];
        for (int j = 0; j < m; ++j) {
          total[j] += a[i][j];
        }
      }
    }
    bool ok = true;
    for (int i = 0; i < m; ++i) {
      if (total[i] < x) ok = false;
    }
    if (ok) ans = min(ans, sum);
  }
  if (ans == 1e9) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int cnt = 0;
    while (1) {
        for (int i = 0; i < N; i++) {
            if (A[i] % 2 == 0) {
                A[i] = A[i] / 2;
            } else {
                cout << cnt << endl;
                return 0;
            }
        }
        cnt++;
    }
}


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

using namespace std;
typedef long long int ll;

#define ALL(v) v.begin(),v.end()

class UnionFind{
    public:
        vector<ll> uni;
        UnionFind(ll s) : uni(s, -1) { }

       //頂点aが所属するグループを調べる
        ll root(ll a)
        {
            if (uni[a] < 0) return a;
            return uni[a] = root(uni[a]);
        }

        //頂点aと頂点bを繋ぐ。もともと同じグループの時falseを返す
        bool connect(ll a, ll b)
        {
            a = root(a);
            b = root(b);
            if (a == b) return false;

            if (uni[a] > uni[b])
            {
                a ^= b;
                b ^= a;
                a ^= b;
            }

            uni[a] = uni[a] + uni[b];
            uni[b] = a;
            return true;
        }

        //頂点a,bが同じグループであるかを調べる
        bool isConnect(ll a, ll b)
        {
            return root(a) == root(b);
        }

        //頂点aを含むグループの頂点数を調べる
        ll size(ll a)
        {
            return -uni[root(a)];
        }
};

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll> > p;
    for (ll i = 0; i < m; i++)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        p.push_back(make_pair(a, b));
    }

    ll ans = 0;

    for (ll i = 0; i < m; i++)
    {
        UnionFind u(n);
        for (ll k = 0; k < m; k++)
        {
            if (k != i)
            {
                u.connect(p[k].first, p[k].second);
            }
        }
        if (!u.isConnect(p[i].first, p[i].second))
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort()

# 0 ~ T-1分までに食べ終わる時、i番目の品まで選べる場合の最大満足度
dp = [[0 for _ in range(T)] for _ in range(N+1)]

for i in range(N):
    for j in range(T):
        # 時間までに食べきれなくて選べない場合
        if AB[i][0] > j:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j - AB[i][0]] + AB[i][1])


# T分目のタイミングで、残りの中から最も満足度の高い物を食べる
ans = 0
for i in range(N):
    tmp = 0
    if i < N-1:
        for j in range(i+1,N):
            tmp = max(tmp, AB[j][1]) 
    ans = max(ans, dp[i+1][-1] + tmp)

print(ans)

Measured memory_bytes: 123736
M = 1046527
L = 14
H = [""] * M

def getChar(ch):
    if ch == 'A':
        return 1
    elif ch == 'C':
        return 2
    elif ch == 'G':
        return 3
    elif ch == 'T':
        return 4
    else:
        return 0

def getKey(strings):
    Sum = 0
    p = 1
    for i in xrange(len(strings)):
        Sum += p * getChar(strings[i])
        p *= 5

    return Sum

def h1(key):
    return key % M

def h2(key):
    return 1 + (key % (M-1))

def find(strings):
    key = getKey(strings)
    i = 0
    while True:
        h = (h1(key) + i * h2(key)) % M
        if H[h] == strings:
            return 1
        elif len(H[h]) == 0:
            return 0
        else:
            i += 1
    return 0

def insert(strings):
    key = getKey(strings)
    i = 0
    while True:
        h = (h1(key) + i * h2(key)) % M
        if H[h] == strings:
            return 1
        elif len(H[h]) == 0:
            H[h] = strings
            return 0
        else:
            i += 1
    return 0

def main():
    n = input()
    for i in xrange(n):
        com = raw_input().split()
        if com[0][0] == 'i':
            insert(com[1])
        else:
            if find(com[1]):
                print 'yes'
            else:
                print 'no'
    return 0

main()

Measured memory_bytes: 27656
#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
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 = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int l=1, r=n/2; l<r && m; ++l, --r, --m){
        printf("%d %d\n", l, r);
    }
    if(m == 0) return 0;
    for(int l=n/2+1, r=(n-1)/2*2+1; l<r && m; ++l, --r, --m){
        printf("%d %d\n", l, r);
    }
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,y;
    cin>>n>>y;
    string ans;
    for(int i=0; i<=2000; ++i){
        for(int j=0; j<=2000-i; ++j){
            for(int k=0; k<=2000-i-j; ++k){
                if(i+j+k==n){
                    if(i*10000+j*5000+k*1000==y){
                        cout<<i<<" "<<j<<" "<<k<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 256
M, D = map(int, input().split())

ans = 0
for m in range(1, M+1):
  for d in range(1, D+1):
    d_1 = d % 10
    d_10 = d // 10
    if d_10 >= 2 and d_1 >= 2 and d_10 * d_1 == m:
      ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;

lint n, k;
vector<int> a, b;

bool trial(lint x){
	lint ret = 0;
	for(int i=0; i<n; i++){
		ret += max(a[n - 1 - i] - x / b[i], 0ll);
		if(ret > k) break;
	}
	return ret <= k;
}

void solve(){
	scanf("%lld %lld",&n,&k);
	a.resize(n);
	b.resize(n);
	for(auto &i : a) scanf("%d",&i);
	for(auto &i : b) scanf("%d",&i);
	sort(all(a));
	sort(all(b));
	lint s = 0, e = 1e12;
	while(s != e){
		lint m = (s+e)/2;
		if(trial(m)) e = m;
		else s = m + 1;
	}
	printf("%lld\n", s);
}

int main(){	
	/*
	freopen("input.txt", "rb", stdin);
	freopen("output.txt", "wb", stdout);

	int tc; cin >> tc;
	*/ int tc = 1;
	for(int i=1; i<=tc; i++){
		solve();
	}
}





Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

constexpr int N = 1e6 + 5;
constexpr LL mod = 1e9 + 7;

int fact[N];
bitset< N> status;
int in[N], freq[N];

LL power(LL a, int b) {
    LL rv = 1;
    while (b) {
        if (b & 1) rv = rv * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return rv;
}

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

    status.set();
    for (int i = 2; i < N; i++) {
        if (status[i]) {
            for (int j = i; j < N; j += i) {
                status[j] = false;
                fact[j] = i;
            }
        }
    }

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        in[i] = a;
        while (a != 1) {
            int p = fact[a], cnt = 0;
            while (a % p == 0) {
                cnt++;
                a /= p;
            }
            freq[p] = max(freq[p], cnt);
        }
    }

    LL lcm = 1;
    for (int i = 2; i < N; i++) {
        lcm = lcm * power(i, freq[i]) % mod;
    }


    LL result = 0;
    for (int i = 0; i < n; i++) {
        result += lcm * power(in[i], mod - 2) % mod;
        result %= mod;
    }

    cout << result << endl;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T>> &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

int cnt;

void mergeSort(int* a, int left, int right) {
	if (right - left <= 1)
		return;

	int mid = left + (right - left) / 2;
	mergeSort(a, left, mid);
	mergeSort(a, mid, right);

	int n1 = mid - left, n2 = right - mid;
	int L[n1+1], R[n2+1];
	for (int i = 0; i < n1; i++) 
		L[i] = a[left + i];
	for (int i = 0; i < n2; i++)
		R[i] = a[mid + i];
	L[n1] = INF, R[n2] = INF;

	int itr_x = 0, itr_y = 0;
	for (int i = left; i < right; i++) {
		if (L[itr_x] <= R[itr_y]) 
			a[i] = L[itr_x++];
		else
			a[i] = R[itr_y++];
		cnt++;
	}
}

int n, a[500001];
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);

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

	mergeSort(a, 0, n);

	for (int i = 0; i < n; i++) {
		cout << a[i] << (i != n-1 ? " " : "\n");
	}
	cout << cnt << endl;
  return 0;
}




Measured memory_bytes: 10996
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(A[k-1])

Measured memory_bytes: 2940
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;

void main() {
  long n, k;
  readf("%d %d\n", &n, &k);
  size_t count = 0;
  foreach (h; readln().split.map!(to!int)) {
    if (h >= k) ++count;
  }
  writeln(count);
}

Measured memory_bytes: 4104
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

string S;

int main(){
  ll N;
  cin >> N;
  cin >> S;
  int ans=0;

  for(int i=0;i<N;i++){
    if(S[i]=='E'){
      ans++;
    }
  }
  int k=0;
  int j=ans;
  int ans2=k+j;
  for(int i=0;i<N;i++){
    if(S[i]=='E'){
      j--;
    }
    ans2=min(ans2,k+j);
    if(S[i]=='W'){
      k++;
    }
  }
  cout << ans2 << endl;
}

Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, c;
    cin >> n >> c;
    int sum = 0;
    for(int i = 0; i < c; i++)
    {
        int x;
        cin >> x;
        sum += x;
    }
    n++;
    cout << sum / n + (sum % n != 0 ? 1 : 0) << endl; 
    return 0;
}




Measured memory_bytes: 3168