akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
int a[200010],b[200010];
int ai[200010],bi[200010];
int z[600010],res[600010];
vector<PII> v;
void zalgor()
{
	int l=0,r=0;
	for (int i=1;i<3*n;i++)
	{
		if (i>r)
		{
			while (i+res[i]<3*n && z[i+res[i]]==z[res[i]]) res[i]++;
			l=i,r=i+res[i]-1;
		}
		else
		{
			res[i]=min(r-i+1,res[i-l]);
			while (i+res[i]<3*n && z[i+res[i]]==z[res[i]]) res[i]++;
			if (i+res[i]-1>r) l=i,r=i+res[i]-1;
		}
	}
} 
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if (i) ai[i-1]=a[i]^a[i-1];
	}
	ai[n-1]=a[n-1]^a[0];
	for (int i=0;i<n;i++)
	{
		scanf("%d",&b[i]);
		if (i) bi[i-1]=b[i]^b[i-1];
	}
	bi[n-1]=b[n-1]^b[0];
	for (int i=0;i<n;i++) z[i]=bi[i];
	for (int i=n;i<2*n;i++) z[i]=ai[i-n];
	for (int i=2*n;i<3*n;i++) z[i]=ai[i-2*n];
	zalgor();
	/*for (int i=0;i<n;i++) cout <<ai[i]<<" ";
	cout <<"\n";
	for (int i=0;i<n;i++) cout <<bi[i]<<" ";
	cout <<"\n";
	for (int i=0;i<3*n;i++) cout <<z[i]<<" ";
	cout <<"\n";
	for (int i=0;i<3*n;i++) cout <<res[n+i]<<" ";
	cout <<"\n";*/
	for (int i=0;i<n;i++)
	{
		if (res[n+i]>=n)
		{
			int t=(i<n ? i : i-n);
			v.push_back(MP(t,a[t]^b[0]));
		}
	}
	for (int i=0;i<v.size();i++) printf("%d %d\n",v[i].Fst,v[i].Snd);
	return 0;
} 

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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    string ans = "Yes";
    if ((a == b && b == c) || (a != b && b != c && c != a)) ans = "No";
    cout << ans << endl;
}


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

int hantei(int x){
	if(x%10==(x/10)%10 && x%10==x/100)
      return x;
  	
  return 0;
}

int main() {

  int a,b,c,d,sum;
  string s,t;
  cin>>a;
  
  sum=0;
  for(int i=a;i<=999;i++){
  	if(hantei(i)!=0){
    	b=i;
      break;
    }
  }
  
  cout<<b<<endl;
  return 0;
}

Measured memory_bytes: 256
// 入力とかに使うもの
var reader = require('readline').createInterface({ input: process.stdin, output: process.stdout });
var lines = [];
reader.on('line', function (line) { lines.push(line); });

// メイン
reader.on('close', function () {
	var a = lines[0].split(" ");
	var b = "";
	for(var c in a) b = b + a[c].slice(0,1);
	console.log(b);
});

Measured memory_bytes: 11596
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,start,end) for(int i=start; i<end; i++)
#define pb push_back
#define ll long long int
#define mp make_pair
#define pii pair<int, int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define endl "\n"
#define graph vector<vector<ll>>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    cout<<a*b;
}

Measured memory_bytes: 3648
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum cs = [6,36,216,1296,7776,46656,279936,9,81,729,6561,59049,531441];

void main()
{
    auto N = readln.chomp.to!int;

    auto DP = new int[][](cs.length, N+1);
    foreach (ref dp; DP) dp[] = -1;
    int solve(int i, int n) {
        if (i == cs.length) return n;

        if (DP[i][n] == -1) {
            if (n >= cs[i]) {
                DP[i][n] = min(solve(i+1, n), solve(i, n-cs[i]) + 1);
            } else {
                DP[i][n] = solve(i+1, n);
            }
        }
        return DP[i][n];
    }
    writeln(solve(0, N));
}

Measured memory_bytes: 19068
///
// File:  0000.cpp
// Author: ymiyamoto
//
// Created on Sat Nov  4 15:30:20 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  for (uint32_t i = 1; i <= 9; i++) {
    for (uint32_t j = 1; j <= 9; j++) {
      cout << i << "x" << j << "=" << i * j << endl;
    }
  }

  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    if (s.at(0) == '1') {
        cnt++;
    }
    if (s.at(1) == '1') {
        cnt++;
    }
    if (s.at(2) == '1') {
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int []a = new int [5];
		int []b = new int [5];
		int max = 0;
		int sum = 0;
		
		for(int i = 0; i < 5; i++) {
			a[i] = sc.nextInt();
			b[i] = (10 - (a[i] % 10))%10;
			max = Math.max(max, b[i]);
 		}
		for(int j = 0; j < 5; j++) {
			sum += a[j] + b[j] ;
		}
		
		System.out.println(sum - max);
	}

}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
ans = sum(A[1])+A[0][0]
for i in range(N-1) :
    tmp = sum(A[0][:i+2]) + sum(A[1][i+1:])
    if ans < tmp :
        ans = tmp
else :
    print(ans)

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

ll P = 1000003;

class C {
public:
  int n;
  vector<long long> fac, inv, facInv;

  long long power(long long e, long long x) {
    if (x == 0)
      return 1;
    if (x == 1)
      return e;
    if (x % 2 == 0)
      return power((e * e) % P, x / 2);
    return (e * power(e, x - 1)) % P;
  }

  C(int n_) {
    n = n_;
    fac.resize(n + 1);
    inv.resize(n + 1);
    facInv.resize(n + 1);
    fac[0] = fac[1] = 1;
    for (int i = 2; i <= n; i++)
      fac[i] = (i * fac[i - 1]) % P;
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; i++)
      inv[i] = power(i, P - 2);
    facInv[0] = facInv[1] = 1;
    for (int i = 2; i <= n; i++)
      facInv[i] = (inv[i] * facInv[i - 1]) % P;
  }

  long long comb(int N, int K) {
    if (N < K || K < 0 || N < 0)
      return 0;
    if (N == 0 || K == 0 || K == N)
      return 1;
    return ((fac[N] * facInv[K]) % P * facInv[N - K]) % P;
  }

  long long hcomb(int N, int K) {
    if (N == 0 && K == 0)
      return 1;
    return comb(N + K - 1, K);
  }

  long long mul(long long a, long long b) { return (a * b) % P; }

  long long add(long long a, long long b) { return (a + b) % P; }

  // find c
  // where a^c = b (mod P)
  long long dlp(long long a, long long b) {
    long long m = ceil(sqrt(P));
    map<long long, long long> mp;
    for (int i = 0; i < m; i++)
      mp[power(a, i)] = i;
    long long ainvm = power(power(a, m), P - 2);
    cout << m << endl;
    for (int i = 0; i < m; i++) {
      if (mp.find(b) != mp.end()) {
        return i * m + mp[b];
      }
      b = mul(b, ainvm);
    }
    return -1;
  }
};

C cmp(1000003);

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  vector<vector<ll>> memo(P);

  ll q;
  cin >> q;
  vector<ll> x(q), d(q), n(q);
  for (int i = 0; i < q; i++) {
    cin >> x[i] >> d[i] >> n[i];
  }
  for (int i = 0; i < q; i++) {
    if (d[i] == 0) {
      cout << cmp.power(x[i], n[i]) << endl;
      continue;
    }
    if (n[i] >= P) {
      cout << 0 << endl;
      continue;
    }
    ll dx = (d[i] * cmp.inv[x[i]]) % P;
    ll xx = cmp.power(x[i], n[i]);
    ll p = cmp.power(dx, n[i]);
    ll dxinv = cmp.power(dx, P - 2);
    if (n[i] + dxinv > P)
      p = 0;
    else
      p *= cmp.fac[n[i] + dxinv - 1];
    p %= P;
    p *= cmp.power(cmp.fac[dxinv - 1], P - 2);
    p %= P;
    cout << (xx * p) % P << endl;
  }

  return 0;
}


Measured memory_bytes: 50176
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))

using namespace std;

const double eps = 1e-8;

#define PB push_back
#define MP make_pair

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;
typedef unsigned long long ULL;

int main() {
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
n,s=map(int,input().split())
a=list(map(int,input().split()))
dp=[]
for i in range(0,n+1):
  dp.append([])
  for j in range(0,s+1):
    dp[i].append(0)
dp[0][0]=1
for i in range(0,n):
  for j in range(0,s+1):
    dp[i+1][j]=(dp[i+1][j]+2*dp[i][j])%998244353
    if j+a[i]<=s:
      dp[i+1][j+a[i]]=(dp[i+1][j+a[i]]+dp[i][j])%998244353
print(dp[n][s])

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n; int v_max = 1 << n;
    vector<long> v(v_max), u;
    rep(i, v_max) cin >> v[i];
    sort(all(v), greater<long>());

    u.push_back(v[0]); v[0] = -1;
    rep(i, n){
        int m = 1 << i; int l = 0;
        rep(j, m){
            while(1){
                l++;
                if(l == v_max){
                    out("No"); return 0;
                }
                if(v[l] == -1) continue;
                if(v[l] < u[j]){
                    u.push_back(v[l]);
                    v[l] = -1;
                    break;
                }
            }
        }
        sort(all(u), greater<long>());
    }
    out("Yes");
}

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  for(int i=0;i<m;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<m;i++){
    n=n-a.at(i);
  }
  if(n>=0){
    cout<<n;
  }else{
    cout<<"-1";
  }
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    vector<ll> ABCDE(5);
    cin >> N >> ABCDE[0] >> ABCDE[1] >> ABCDE[2] >> ABCDE[3] >> ABCDE[4];
    ll min_value=*min_element(ABCDE.begin(),ABCDE.end());

    ll ans = ceil((N-1)/min_value)+5;    
    cout << ans << endl;
   // system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

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

Measured memory_bytes: 256
import math

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

if not abs(n-m)<=1:
    print('0')
    exit()

if n==m:
    print((2*math.factorial(m)*math.factorial(n))%(10**9+7))
    exit()
if abs(n-m)==1:
    print((math.factorial(m)*math.factorial(n))%(10**9+7))
    exit()
    


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

ll gcd(ll a, ll b){
	if(b == 0) return a;
	return gcd(b, a % b);
}


int main() {
	ll N, M;
	cin >> N >> M;
	string x, y;
	cin >> x;
	cin >> y;
	ll ans = N * M;
	ans /= gcd(N, M);
	
	for(int i = 0;i < N;i++) {
		ll tmp = (i * (ans /N));
		
		if(tmp % (ans / M) == 0) {
			ll sad = tmp /(ans / M);
			//cout << tmp << " " << sad << " " << i << "\n";
			if(x[i] != y[sad]) {
				cout << -1 << "\n";
				return 0;
			}
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include<vector>
#include <queue>
#include <string>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >>c;
	int d;
	if (b < a) { d = b; b = a; a = d; }
	if (c < b) { d = c; c = b; b = d; }
	if (b < a) { d= b; b = a; a = d; }
	//cout << a << b << c << endl;
	int ans = (c - b) / 2 + (c - a) / 2;
	a += (c - a) / 2 * 2;
	b += (c - b) / 2 * 2;
	if (a == b && b == c)cout << ans << endl;
	else if (abs(b - a)== 1)cout << ans + 2 << endl;
	else/* if ((b-a)+(c-a)==2 )*/cout << ans+1 << endl;

}

Measured memory_bytes: 256
require 'prime'
a, b = gets.chomp.split(' ').map(&:to_i)
factors_a = a.prime_division.map{ |i| i[0] }
factors_b = b.prime_division.map{ |i| i[0] }
factors_hash_a = Hash.new(false)
factors_a.each do |i|
  factors_hash_a[i] = true
end
count = 0
factors_b.each do |i|
  count += 1 if factors_hash_a[i]
end
puts count + 1

Measured memory_bytes: 2300
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;

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

	double ans;
	if (n % 2 == 1) {
		ans = (n + 1) / 2;
	}
	else {
		ans = n / 2;
	}
	ans = ans/double(n);
	printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define PI acos(-1)
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	#ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	#endif

	int n;
	cin >> n;
	int a[n];
	map<int, int> m;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		int tmp = a[i];
		for(int j = 2; j * j <= tmp; j++) {
			int cur = 0;
			while(tmp % j == 0) {
				cur++;
				tmp /= j;
			}
			if(cur) {
				m[j] = max(m[j], cur);
			}
		}
		if(tmp != 1) {
			m[tmp] = max(m[tmp], 1LL);
		}
	}
	int l = 1;
	for(auto it : m) {
		int tmp = it.se;
		while(tmp--) {
			l = l * it.fi % mod;
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		ans = (ans + l * modpow(a[i], mod - 2, mod) % mod) % mod;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define pb push_back
using namespace std;

int main(void){
  long long int n,N,W;
  vector<vector<long long int> > w(4);
  long long int tw,tv,moto;
  long long int res,tmp;
  long long int i,j,k,l,m;
  cin>>N>>W;
  cin>>tw>>tv;
  n=N;

  moto=tw;
  w[0].pb(tv);
  for(i=1;i<N;i++){
    cin>>tw>>tv;
    w[tw-moto].pb(tv);
  }
  for(i=0;i<4;i++) sort(w[i].begin(),w[i].end(),greater<long long int>());

  tmp=res=0;
  for(i=0;i<=w[0].size();i++){
    for(j=0;j<=w[1].size();j++){
      for(k=0;k<=w[2].size();k++){
        for(l=0;l<=w[3].size();l++){
          tmp=0;
          if((i*moto + j*(moto+1) + k*(moto+2) + l*(moto+3))>W) continue;
          //cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;                                                                                                                                                                
          for(m=0;m<i;m++) tmp+=w[0][m];
          for(m=0;m<j;m++) tmp+=w[1][m];
          for(m=0;m<k;m++) tmp+=w[2][m];
          for(m=0;m<l;m++) tmp+=w[3][m];
          if(tmp>res) res=tmp;
        }
      }
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
import copy

def cnt(a, m, i):
    if a[i] < m:
        a[i] += 1
    else:
        a = cnt(a, m, i-1)
        a[i] = copy.deepcopy(a[i-1])
    return a

def check(a, ab):
    score = 0
    for i in range(q):
        ai, bi = ab[i][0], ab[i][1]
        if a[bi] - a[ai] == ab[i][2]:
            score += ab[i][3]
    return score
  
n, m, q = map(int,input().split())
ab = []
for i in range(q):
    ab.append(list(map(int,input().split())))

a = [1] * (n+1)
a[0] = 0
ans = 0
while a[0] == 0:
    x = check(a, ab)
    ans = max(ans, x)
    # print(a, ans)
    a = cnt(a, m, -1)
print(ans)


Measured memory_bytes: 9336
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 300

const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int dp[ARRAY_MAX][ARRAY_MAX];

int main() {

	string s;
	vector<vector<int> > vec;

	while (getline(cin, s))
	{
		vector<int> a;
		int siz = s.size();
		int t = 0;
		for (int i = 0; i < siz; i++)
		{
			if (isdigit(s[i]))
			{
				t = t * 10 + s[i] - '0';
			}
			if (s[i] == ',' || i == siz - 1)
			{
				a.push_back(t);
				t = 0;
			}
		}
		vec.push_back(a);
	}


	dp[0][0] = vec[0][0];
	int center = vec.size() / 2;


	for (int i = 0; i < vec.size() - 1; i++)
	{
		for (int j = 0; j < vec[i].size(); j++)
		{
			if (i < center)
			{
				//配るdp
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + vec[i + 1][j]);
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + vec[i + 1][j + 1]);
			}
			else
			{
				if (j == 0)
				{

					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + vec[i + 1][j]);
				}
				else if (j == vec[i].size() - 1)
				{
					dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + vec[i + 1][j - 1]);
				}
				else
				{
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + vec[i + 1][j]);
					dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + vec[i + 1][j - 1]);
				}
			}
		}
	}
	cout << dp[vec.size() - 1][0] << endl;

	return 0;
}


Measured memory_bytes: 3260
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val p = Array(n) { sc.nextInt() }
    val q = Array(n) { sc.nextInt() }
    var a = mutableListOf<Int>()
    for (i in 0 until n) {
        a.add(i + 1)
    }
    var x = -1
    var y = -1
    var i = 0
    do {
        if ((0 until n).all { a[it] == p[it] }) {
            x = i
        }
        if ((0 until n).all { a[it] == q[it] }) {
            y = i
        }
        i++
    } while (nextPermutation(a))
    println(Math.abs(x - y))
}

fun nextPermutation(array: MutableList<Int>): Boolean {
    var tmp = 0
    for (i in array.size-2 downTo 0) {
        if (array[i] < array[i+1]) {
            for (j in array.size-1 downTo i+1) {
                if (array[j] > array[i]) {
                    tmp = array[i]
                    array[i] = array[j]
                    array[j] = tmp

                    val tmpArray = array.takeLast(array.size-(i+1)).sorted()
                    tmpArray.forEachIndexed { index, e ->
                        array[i+1+index] = e
                    }

                    return true
                }
            }
        }
    }

    return false
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 39092
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,ans;
char s[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int l=1,r=1;l<=n;l=r+1)
	{
		while(r<n&&s[r+1]==s[l])r++;
		int gs=r-l+1;
		if(gs%3==1)ans+=gs/3*2+1;
		else if(gs%3==0)ans+=gs/3*2;
		else if(r<n){ans+=gs/3*2+2;r++;}
		else ans+=gs/3*2+1;
	}
	cout<<ans;
}

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

ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    else return gcd(b,a%b);
}

int main(){
    ll a,b;
    cin >> a>>b;
    cout << a*b/gcd(a,b)<<endl;
    return 0;
}

Measured memory_bytes: 3552
#include <cstdio>
#include <cstring>
using namespace std;
const int mx = 1e5+5;
int a[mx];
int main(int argc, char** argv) 
{
	int n;
	scanf("%d",&n);
	for(int i=1,v; i<=n; ++i)
		scanf("%d",&v),a[i] = v-i;
	int ans = 0;
	for(int i=1; i<=n;)
	{
		int num = 0,j = i;
		while(i<=n && !a[i])
			num++,i++;
		ans+=(num+1)>>1;
		if(j==i)
			i++;
	}
	printf("%d\n",ans);
	return 0;
}






















Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
vll d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}
void sortll(vll &a) {sort(a.begin(), a.end());}
void sortc(string &a) {sort(a.begin(), a.end());}
void sorts(vs &a) {sort(a.begin(), a.end());}

int main() {
  ll n;
  cin >> n;
  vll a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0) {
      if (a[i] % 3 > 0 && a[i] % 5 > 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(x: "List[int]", y: "List[int]"):
    d = (x[1] - x[0], y[1] - y[0])
    x2 = x[1] - d[1] 
    y2 = y[1] + d[0] 
    x3 = x[0] - d[1] 
    y4 = y[0] + d[0] 
    return ' '.join([str(z) for z in [x2, y2, x3, y4]])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = [int()] * (2)  # type: "List[int]" 
    y = [int()] * (2)  # type: "List[int]" 
    for i in range(2):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    result = solve(x, y)
    print(result)

if __name__ == '__main__':
    main()


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

int main()
{
    double r,a,b;
	cin >>r;
	a=r*r*3.141592653590;
	b=2*r*3.141592653590;
	printf("%.10lf", a);
	cout <<" ";
	printf("%.10lf\n", b);
	return 0;
}

Measured memory_bytes: 1252
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    N = input()
    P = list(map(int, input().split()))
    P_s = sorted(P)

    flag = 0
    for i in range(len(P)):
        if P[i] != P_s[i]:
            flag += 1
        if flag > 2:
            print("NO")
            break
    if flag < 3:
        print("YES")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>

class Usable_num {
	int *_memo{ new int[10] };
	int *_end{ _memo };
public:
	~Usable_num() { delete[] _memo; }
	Usable_num() {};
	Usable_num(Usable_num &&un) : _memo{ un._memo }, _end{ un._end } {
		un._memo = nullptr;
		un._end = nullptr;
	}
	int size() const{ return _end - _memo; }
	void add(const int &n) {
		*(_end++) = n;
	}
	int operator[](const int &n) const {
		return _memo[n];
	}
	int const *begin() const { return _memo; }
	int const *end() const { return _end; }
	int cal_max(const int &digit) const {
		return (digit == 0) ? 0 : *(_end - 1) + cal_max(digit - 1) * 10;
	}

};
class Hated_num {
	bool memo[10]{ false };
public:
	void hate(const int &n) {
		memo[n] = true;
	}
	Usable_num to_usable_num() const {
		Usable_num res;
		for (auto i = 0; i < 10; ++i)
			if (memo[i] == false) res.add(i);
		return res;
	}
};
int log_ten(const int &num) {
	return (num == 0) ? 0 : 1 + log_ten(num / 10);
}
int cal_num(const Usable_num &num, const int &digit, const int &pattern) {
	return (digit == 0) ? 0 : (num[pattern % num.size()] + cal_num(num, digit - 1, pattern / num.size()) * 10);
}
int cal_digit(const Usable_num &num, const int &target) {
	auto temp_digit = log_ten(target);
	if (num.cal_max(temp_digit) >= target) return temp_digit;
	else return temp_digit + 1;
}
int bin_search(const Usable_num &num, const int &digit, const int &target, const int &left, const int &right) {
	if (left >= right) return left;
	else {
		auto mid = (right + left) >> 1;
		auto pat_mid = cal_num(num, digit, mid);
		if (pat_mid < target) return bin_search(num, digit, target, mid + 1, right);
		else return bin_search(num, digit, target, left, mid);
	}
}
int exp(const int &base, const int &ex) {
	return (ex == 0) ? 1 : base * exp(base, ex - 1);
}
int main() {
	Hated_num hn;
	int n, k;
	std::cin >> n >> k;
	for (int a; k > 0; --k) {
		std::cin >> a;
		hn.hate(a);
	}
	auto num = hn.to_usable_num();
	auto pat = bin_search(num, cal_digit(num, n), n, 0, exp(num.size(), cal_digit(num, n)) - 1);
	std::cout <<  cal_num(num, cal_digit(num, n), pat) << std::endl;
	return 0;
}

Measured memory_bytes: 256
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
int n, g[10], l[10], vis[10], s[10], v[10];
int ans = 2000000000;
void dfs(int a) {
	if (a == n + 1) {
		ms(s, 0), ms(v, 0);
		for (int i = 1; i <= n; ++i) {
			s[vis[i]] += l[i];
			++v[vis[i]];
		}
		if (s[1] == 0 || s[2] == 0 || s[3] == 0) return ;
		for (int i = 1; i <= 3; ++i) {
			v[i] = (v[i] - 1) * 10;
			v[i] += abss(g[i] - s[i]);
		}
		ans = min(ans, v[1] + v[2] + v[3]);
		return ;
	}
	for (int i = 0; i <= 3; ++i) vis[a] = i, dfs(a + 1);
}
int main() {
	cin >> n;
	for (int i = 1; i <= 3; ++i) cin >> g[i];
	for (int i = 1; i <= n; ++i) cin >> l[i];
	dfs(1);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
s = input()
x = int(input())
tank = []
for c in list(s):
    if c=='a':
        tank.append(0)
    else:
        tank.append(ord('z') + 1 - ord(c))
res = ''
for i in range(len(tank)):
    if tank[i] == 0:
        res += s[i]
    elif tank[i] <= x:
        x -= tank[i]
        tank[i] = 0
        res += 'a'
    else:
        res += s[i]

c = res[-1]
x %= 26
if ord(c)+x <= ord('z'):
    res = res[:-1] + chr(ord(c)+x)
else:
    res = res[:-1] + chr(ord(c)+x-ord('z')+ord('a')-1)
print(res)

Measured memory_bytes: 4980
while True:
    li = input().split()

    a, b = int(li[0]), int(li[2])
    op = li[1]
    
    if op == '?':
        break
    
    if op == "+":
        ans = a + b
    elif op == "-":
        ans = a - b
    elif op == "*":
        ans = a * b
    elif op == "/":
        ans = a // b
        
    print(ans)


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

int main() {
  int n; cin >> n;
	vector<vector<int>> A(n, vector<int>(n, -1));
	for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    while (a--) {
      int x, y; cin >> x >> y;
      --x;
      A[i][x] = y;
    }
	}
  int ans = 0;
  for (int S = 0; S < (1<<n); ++S) {
    bool test = true;
    for (int i = 0; i < n; ++i) if (S&1<<i) {
      for (int j = 0; j < n; ++j) {
        test &= A[i][j] == -1 or A[i][j] == (S>>j&1);
      }
    }
    if (test) ans = max<int>(ans, __builtin_popcount(S));
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
K = int(input())
X = [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]
print(X[K - 1])


Measured memory_bytes: 2940
from fractions import gcd
from math import factorial, ceil, sqrt, atan2, log, pi, e, asin,acos, cos, sin, floor, atan
from itertools import *
from fractions import Fraction
import string
import copy
import random
import bisect
from decimal import *
from collections import deque
from sys import *
digs = string.digits + string.ascii_letters

def id_generator(size=20, chars=string.digits):
    return ''.join(random.choice(chars) for _ in range(size))
 
def mp():
    return map(int,str(raw_input()).strip().split())

clear=stdout.flush()

n=input()
l=list(mp())
l.sort()
z=sum(l[:n-1])
if z>l[-1]:
	print "Yes"
else:
	print "No"

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

int max(int a, int b){
  return a >= b ? a : b;
}
int lmax(long int a, long int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int lmin(long int a, long int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
long int power(int a,int b){
  long int count=1;
  for(int i=0;i<b;i++){
    count *= 2;
  }
  return count;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(b/a < c)printf("%d",b/a);
  else printf("%d",c);
  return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBeautifulStrings solver = new BBeautifulStrings();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBeautifulStrings {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            char[] chars = s.toCharArray();
            int[] res = new int[26];
            for (int i = 0; i < chars.length; i++) {
                res[chars[i] - 'a']++;
            }
            for (int i = 0; i < res.length; i++) {
                if (res[i] > 0 && res[i] % 2 != 0) {
                    out.println("No");
                    return;
                }
            }
            out.println("Yes");
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public void close() {
        }

    }
}



Measured memory_bytes: 22100
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

a, b, c, k = input_a

if a >= k
  puts k
  exit
end

if a < k
  if a + b >= k
    puts a
  else
    tmp = k - (a + b)
    puts a - tmp
  end
end


Measured memory_bytes: 14316
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	int n;//???????????°
	int y;//????????????????????´??°
	int b[101];//????????????
	int  t;//??????????¨????
	float r;//??´?????????????????????
	float genri[101],temp,temp2;
	while (1) {
		cin >> n;
		if (n == 0)return 0;
		cin >> y;
		for (int i = 0; i < n; i++) {
			cin >> b[i] >> r >> t;
			if (t == 1) {
				genri[i] = 10000 *(1 + y*(r / 100));
				//cout <<"i==1"<<" ,"<< (1 + y*(r / 100)) << endl;
			}
			else if(t==2){
				 temp = 1+(r/100);
				 temp2 = temp;
				for (int i = 0; i < y-1; i++) {
					temp2 = temp2*temp;
					//cout <<"t==2"<<"," <<temp2 << endl;
				}
				genri[i] = (float)10000 * temp2;
			}
		}
		float max = 0;
		int  max2 = 0;
		for (int i = 0; i < n; i++) {
			//cout << genri[i] << endl;
		}
		for (int i = 0; i < n; i++) {
			if (genri[i] > max) {
				max = genri[i];
				//cout <<"i="<<i+1<< genri[i] << endl;
				max2 = b[i];
			}
		}
		cout << max2 << endl;
		max = 0;
		max2 = 0;
		for (int i = 0; i < n; i++)genri[i] = 0;
	}
}

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

int main(){
  long long n, k; cin >> n >> k;
  long long data[200010]; //dp[i] i個選んだ時のありえる和の数
  for(int i = 1; i <= n+1; i++){
    data[i] = (n - i + 1) * i + 1;
  }
  long long ans = 0, cnt;
  for(int i = k; i <= n + 1; i++){
    cnt = data[i];
    cnt %= 1000000007;
    ans += cnt;
  }
  ans %= 1000000007;
  cout << ans << endl;
}
    
  

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

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector <int> A(N+2,0);
  A[0] = 0;
  for(int i=0;i<N;i++ )
    cin >> A[i+1];
  A[N+1] = 0;

  vector <int> lsum(N,0);
  int l = 0;
  for(int i=0;i<N;i++ )
    {
      lsum[i] = l;
      l+=abs(A[i+1]-A[i]);
    }
  vector <int> rsum(N,0);
  int r = 0;
  for(int i=N-1;i>=0;i-- )
    {
      rsum[i] = r;
      r+=abs(A[i+2]-A[i+1]);            
    }

  for(int i=0;i<N;i++ )
    cout << lsum[i]+abs(A[i]-A[i+2])+rsum[i] << endl;
    
}



Measured memory_bytes: 2432
while 1:
  n,x = map(int,input().split())
  c = 0
  if n == x == 0:
    break
  else:
    for i in range(1,n+1):
      for j in range(i,n+1):
        for k in range(j,n+1):
          if i==j or i==k or j==k:
            pass
          elif i + j + k == x:
            c += 1
          else:
            pass
    print(c)


Measured memory_bytes: 5596
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }

            sort(arr);
            int min = arr[0];
            int max = arr[n - 1];

            int ansMinCost = Integer.MAX_VALUE;

            for (int num = min; num <= max; num++) {
                int cost = 0;
                for (int i = 0; i < n; i++) {
                    cost += (arr[i] - num) * (arr[i] - num);
                }
                ansMinCost = Math.min(ansMinCost, cost);
            }

            out.println(ansMinCost);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }

}

Measured memory_bytes: 29900
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace ABC126
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);
            int[] L = new int[M];
            int[] R = new int[M];

            int Lres = 1;
            int Rres = N;

            for (int i = 0; i < M; i++)
            {
                s = Console.ReadLine().Split(' ');
                L[i] = int.Parse(s[0]);
                R[i] = int.Parse(s[1]);
                if (Lres < L[i])
                {
                    Lres = L[i];
                }
                if (R[i] < Rres)
                {
                    Rres = R[i];
                }
            }

            int res = (Lres <= Rres)? Rres - Lres + 1: 0;
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 15820
n = int(input())
ab =[list(map(int,input().split())) for i in range(n)]
ab.sort(key=lambda x:x[1])

time = 0
for i in range(n):
    time +=ab[i][0]
    if time>ab[i][1]:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 90200
n,m=map(int,input().split())
box=list(list(map(int,input().split())) for i in range(n))
ans = 0
for i in (1,-1):
    for j in (1,-1):
        for k in (1,-1):
            cost=list(i*x+j*y+z*k for x,y,z in box)
            cost.sort(reverse=True)
            ans=max(ans,sum(cost[:m]))
print(ans)

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

int main() {

    string a,b;

    cin >> a >> b;

    if(a.size() > b.size()){
        cout << "GREATER" << endl;
    }
    else if(a.size() < b.size()){
        cout << "LESS" << endl;
    }
    else{
        for(int i=0; i<a.size(); i++){
            if(a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
            }
            else if(a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
	ll n;
	cin>>n;
	ll a[n],b[n],c[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	ll dp[n]={0};
	ll s1=a[0],s2=b[0],s3=c[0];
	for(ll i=1;i<n;i++)
	{
	  ll s11,s22,s33;
	  s11=max(s2+a[i],s3+a[i]);
	  s22=max(s1+b[i],s3+b[i]);
	  s33=max(s1+c[i],s2+c[i]);
	  s1=s11;
	  s2=s22;
	  s3=s33;
	}
	cout<<max(max(s1,s2),s3)<<endl;
}

Measured memory_bytes: 3328
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

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

map<char, long long> cnts;

int main(){
	FIO
	
	int n;cin >> n;
	forn(i, n){
		string s;cin >> s;
		if(s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H')
			cnts[s[0]]++;
	}
	//if(cnts.size() < 3){cout << 0;return 0;}
	long long ans = 0;
	vector<long long> nums;
	for(auto i:cnts)nums.emplace_back(i.second);
	deb(nums);
	for(int i = 0; i < (int)nums.size(); i++){
		for(int j = i + 1; j < (int)nums.size(); j++){
			for(int k = j + 1; k < (int)nums.size(); k++){
				ans += nums[i] * nums[j] * nums[k];
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 384