akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BBounding {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int n, x;
        cin >> n >> x;

        int cur = 0;
        int res = 1;
        REP(i, n) {
            int l;
            cin >> l;
            cur += l;
            if (cur <= x) {
                res++;
            }
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BBounding solver;
    solver.solve(in, out);
    return 0;
}



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

int main(){
	ios::sync_with_stdio(false);

	int N; cin>>N;
	vector<int> a(N);
	rep(i,N) cin>>a[i];

	int now=1, count=0;
	for(int i=0; i<N; i++){
		if(a[i]==now){
			now++;
		}else{
			count++;
		}
	}

	if(count==N){
		cout << -1 << endl;
	}else{
		cout << count << endl;
	}
}


Measured memory_bytes: 4052
X = int(input())

def calculate(X):
    for i in range(1,X+1):
        if X%i == 0:
            a = 0
            while True:
                b=a-i
                f = a**5 - b**5
                if f > X and b>0:
                    break
                if f == X:
                    return([a,b])
                a += 1


ans = calculate(X)
print(ans[0],ans[1])


Measured memory_bytes: 9188
#include<iostream>
using namespace std;
int main(){
    int n,x;
    while(1){
        cin >> n >>x;
        if(n==0 && x==0) break;
        int count = 0;
        for(int i=1; i<=n; i++){
            for(int j=i+1; j<=n; j++){
                for(int k=j+1; k<=n; k++){
                    if(i+j+k==x)count+=1;
                }
            }
        }cout << count << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    cout << (t*s >= d ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3604
import math
from decimal import Decimal
A, B ,X= map(int, input().split())
l=0
r=90
flag=0
pool=0

if X>=A*A*B/2:
    for i in range(100):
        k=math.tan(math.radians((r+l)/2))*A*A*A/2
        if A*A*B-k>=X:
            l=(r+l)/2
        else:
            r=(r+l)/2

    print(r)
else:
    for i in range(100):
        k = math.tan(math.radians(90-(r + l) / 2)) * B * B * A / 2
        if k>=X:
            l=(r+l)/2
        else:
            r=(r+l)/2
    print(r)


Measured memory_bytes: 5076
class SegmentTree
  attr_accessor(:node, :op, :e, :offset)
  
  def initialize(n, op, e)
    @op = op
    @e = e

    ofs = 1
    while ofs < n
      ofs <<= 1
    end
    
    @node = Array.new((ofs << 1) - 1, @e) # 0-indexed
    @offset = ofs - 1 # log2(n).ceil - 1
  end

  def update(i, x) # 一点更新
    i += @offset
    @node[i] = x
    
    while i > 0
      i = (i - 1) >> 1
      @node[i] = @op.call(@node[(i << 1) + 1], @node[(i << 1) + 2])
    end
  end

  def query(l, r) # [l, r)
    l += @offset
    r += @offset

    res = @e
    while l < r
      if l & 1 == 0
        res = @op.call(res, @node[l])
      end
      if r & 1 == 0
        res = @op.call(res, @node[r - 1])
      end
      l = l >> 1
      r = (r - 1) >> 1
    end
    return res
  end
end

m = 3 * (10 ** 5)
chmax = -> (x, y) { (x > y)? x : y }
chmin = -> (x, y) { (x < y)? x : y }
n, k = $stdin.readline.chomp.split.map(&:to_i)
a = Array.new(n) { $stdin.readline.to_i }
seg = SegmentTree.new(m + 1, chmax, 0)

res = 0
a.each do |x|
  v = seg.query(chmax.call(x - k, 0), chmin.call(x + k, m) + 1) + 1
  res = chmax.call(res, v)
  seg.update(x, v)
end
puts res

Measured memory_bytes: 24860
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

string s;
int cur;
/*
pi term();
pi factor();

pi expr(){
	pi t=term();
	while(s[cur]=='|'){
		cur++;
		pi t2=term();
		ll total=(t.fir+t.sec)*(t2.fir+t2.sec);
		t.fir=t.fir*t2.fir%MOD;
		t.sec=(total-t.fir+MOD)%MOD;
	}
	return t;
}

pi term(){
	pi f=factor();
	while(s[cur]=='&'){
		cur++;
		pi f2=factor();
		ll total=(f.fir+f.sec)*(f2.fir+f2.sec);
		f.sec=f.sec*f2.sec%MOD;
		f.fir=(total-f.sec+MOD)%MOD;
	}
	return f;
}

pi factor(){
	if(s[cur]=='x'){
		cur++;
		while(isdigit(s[cur]))cur++;
		return mp(1,1);
	}
	if(s[cur]=='~'){
		cur++;
		pi f=factor();
		swap(f.fir,f.sec);
		return f;
	}
	if(s[cur]=='('){
		cur++;
		pi e=expr();
		cur++;
		return e;
	}
}
*/
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>s;
	s+="@";
	stack<pair<char,pair<int,int>>> S;
	S.push(mp('e',mp(-1,0)));
	pi ret;
	while(sz(S)){
		pair<char,pair<int,int>>& P=S.top();
		char type=P.fir;
		pair<int,int>& p=P.sec;
		//cout<<type<<" "<<p.fir<<" "<<p.sec<<endl;
		
		if(type=='e'){
			if(p.fir==-1){
				p.fir=-2;
				S.push(mp('t',mp(-1,0)));
				continue;
			}else{
				if(p.fir==-2){
					p=ret;
				}
				else{
					ll total=(ll)(p.fir+p.sec)*(ret.fir+ret.sec);
					p.fir=(ll)p.fir*ret.fir%MOD;
					p.sec=(total-p.fir+MOD)%MOD;
				}
				if(s[cur]=='|'){
					cur++;
					S.push(mp('t',mp(-1,0)));
					continue;
				}
				else{
					ret=p;
					S.pop();
					continue;
				}
			}
		}
		
		if(type=='t'){
			if(p.fir==-1){
				p.fir=-2;
				S.push(mp('f',mp(-1,0)));
				continue;
			}else{
				if(p.fir==-2){
					p=ret;
				}else{
					ll total=(ll)(p.fir+p.sec)*(ret.fir+ret.sec);
					p.sec=(ll)p.sec*ret.sec%MOD;
					p.fir=(total-p.sec+MOD)%MOD;
				}
				if(s[cur]=='&'){
					cur++;
					S.push(mp('f',mp(-1,0)));
					continue;
				}
				else{
					ret=p;
					S.pop();
					continue;
				}
			}
		}
		
		if(type=='f'){
			if(p.fir==-1){
				if(s[cur]=='x'){
					cur++;
					while(isdigit(s[cur]))cur++;
					ret=mp(1,1);
					S.pop();
					continue;
				}
				if(s[cur]=='~'){
					p.fir=-2;
					cur++;
					S.push(mp('f',mp(-1,0)));
					continue;
				}
				if(s[cur]=='('){
					p.fir=-3;
					cur++;
					S.push(mp('e',mp(-1,0)));
					continue;
				}
			}
			if(p.fir==-2){
				swap(ret.fir,ret.sec);
				S.pop();
				continue;
			}
			if(p.fir==-3){
				cur++;
				S.pop();
				continue;
			}
		}
	}
	cout<<ret.sec<<endl;
}

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
// get decimal pert of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = "And I feel fine...";
    istringstream iss(sentence);
*/  

double eps = .000000001;
long long sums[200001];
long long vals[200001];
vector<int> graph[200001];
bool vis[200001];
void smear(int cur, int cursum){
    if (vis[cur]){
        return;
    }
    vis[cur] = true;
    long long mysum = cursum+sums[cur];
    vals[cur] = mysum;
    for (int i=0; i<graph[cur].size(); i++){
        smear(graph[cur][i], mysum);
    }
    
}
int main ()
{
  prep();
  int n, q;
  cin >> n >> q;
  
  for (int i=0; i<n-1; i++){
      int a, b;
      cin >> a >> b;
      graph[a].push_back(b);
      graph[b].push_back(a);
  }
  for (int i=0; i<q; i++){
      int p, x;
      cin >> p >> x;
      sums[p] += x;
  }
  smear(1, 0);
  for (int i=1; i<=n ;i++){
      cout << vals[i] << ' ';
  }
  return 0; 
}

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

int main(){
  constexpr int Dmax= 9;
  int N;
  cin >> N;

  bool possible= false;
  for(int i=1; i<=Dmax; i++){
    for(int j=0; j<=Dmax; j++){
      if(i*j==N){
        possible= true;
        break;
      }
    }
    if(possible){ break; }
  }

  string ans= possible ? "Yes"
                       : "No";

  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

struct data{
    int a, b;
    double c;
    bool operator > (const data &right) const{
        return c > right.c;
    }
};

int requireProfit(int i, int j, int d, int x, int p[16][16]){
    vector<data> v;
    rep(k,d){
        v.emplace_back(data{p[j][k], p[i][k], static_cast<double>(p[i][k]) / p[j][k]});
    }
    sort(all(v), greater<data>());

    //?????????x??????????????????????????§????????????????????¨???
    int dp[100005] = {0};
    memset(dp,-1,sizeof(dp));
    dp[0] = 0;
    //int c[100005] = {0};
    rep(k,d){
        if(v[k].c <= 1.0) continue;
        //show(k);
        for(int l = v[k].a; l <= x; l++){
            if(dp[l - v[k].a] == -1) continue;

            if(dp[l] < dp[l - v[k].a] + v[k].b){
                dp[l] = dp[l - v[k].a] + v[k].b;
            }else{
                dp[l] = dp[l];
            }
        }
    }
    int res = 0;
    rep(i,x + 1){
        res = max(res, dp[i] + x - i);
    }
    return res;
}

int main(){
    int n, d, x;
    cin >> d >> n >> x;

    int p[16][16];
    rep(i,n){
        rep(j,d){
            cin >> p[i][j];
        }
    }

    int dp[16] = {0};
    dp[0] = x;
    rep(i,n){
        rep(j,i){
            //cout << i << ' ' << j << endl;
            dp[i] = max(dp[i], requireProfit(i,j,d,dp[j],p));
        }
    }
    cout << dp[n - 1] << endl;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

signed main(){
  int n; cin >> n;
  vi a(n+1), b(n+1);
  rep(i,n+1) cin >> a[i];
  rep(i,n+1) cin >> b[i];
  if(accumulate(all(a),0) != n or accumulate(all(b),0) != n){
    cout << "NO\n";
    return 0;
  }
  int an = 0, bn = 0;
  rep(i,n+1){
    an += i * a[i];
    bn += i * b[i];
  }
  if(an != bn){
    cout << "NO\n";
    return 0;
  }

  vi d(n); // どのノードの次数がいくつか
  vector<pii> c(n);
  int j = 0, k = 0;
  rep(i,n+1){
    rep(_,a[i]){
      c[j].fst = i;
	  c[j].snd = j;
      j++;
    }
    rep(_,b[i]){
      d[k] = i;
      k++;
    }
  }
  sort(rall(d));
  dump(c,d);
  vvi g(n,vi(n));
  rep(x,n){
    sort(rall(c));
    rep(y,n){
      if(d[x] > 0 and c[y].fst > 0){
	g[x][c[y].snd] = 1;
	d[x]--;
	c[y].fst--;
      }
    }
  }    
  dump(g);
  cout << "YES\n";
  rep(i,n){
    cout << g[i][0];
    FOR(j,1,n){
      cout << " " << g[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 3168
#include <cstdio>
#include <vector>

#define MAX(a,b) ((a)>(b)?(a):(b))

using namespace std;


struct BINNODE {
	int parent;
	int depth;
	int degree;
	int sibling;
	int left;
	int right;
	int height;

	BINNODE () { // default constructor
		parent=-1;
		depth=0;
		degree=0;
		sibling=-1;
		left=-1;
		right=-1;
		height=-1;
	}
};

int heightSearch(vector<BINNODE>& node, int target) {
	if(target == -1) return -1;
	else if(node[target].height!=-1) return node[target].height;
	else return MAX(heightSearch(node,node[target].left),heightSearch(node,node[target].right))+1;
}

int main() {
	int n;
	int i,c;
	int id,left,right;
	vector<BINNODE> node;
	scanf("%d",&n);
	node.resize(n);
	for(i=0; i<n; ++i) {
		scanf("%d%d%d",&id,&left,&right);
		node[id].left=left;
		node[id].right=right;
		if(left==-1 && right==-1) {
			node[id].degree=0;
		} else if(left==-1) {
			node[id].degree=1;
			node[right].parent=id;
			node[right].sibling=-1;
		} else if(right==-1) {
			node[id].degree=1;
			node[left].parent=id;
			node[left].sibling=-1;
		} else {
			node[id].degree=2;
			node[left].parent=id;
			node[right].parent=id;
			node[left].sibling=right;
			node[right].sibling=left;
		}
	}
	for(i=0; i<n; ++i) {
		c=0;
		id=i;
		while(node[id].parent!=-1) {
			++c;
			id=node[id].parent;
		}
		node[i].depth=c;
		node[i].height=heightSearch(node,i);
	}
	for(i=0; i<n; ++i) {
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
				,i,node[i].parent,node[i].sibling,node[i].degree,node[i].depth,node[i].height);
		if(node[i].parent==-1) {
			printf("root\n");
		} else if (node[i].left==-1&&node[i].right==-1) {
			printf("leaf\n");
		} else {
			printf("internal node\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2684
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	
	map<char,int> m;
	FOR(i,1,SZ(s)){
		if (s[i]!=s[i-1]){
			m[s[i-1]]++;
		}
	}
	cout << m['W']+m['B'] << "\n";

}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]) {
    ll N, M;
    ll cnt=0, ans;
    cin >> N >> M;
    rep(i,M) {
        ll a;
        cin >> a;
        cnt+=a;
    }
    if(N<cnt){
        ans=-1;
    }else{
        ans=N-cnt;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long n,a,b,c,d;

int32_t main(){
    ios_base :: sync_with_stdio(0);
    cin >> a >> b >> c >> d >> n;
    b=min(b,2*a);
    c=min(c,2*b);
    d=min(d,2*c);
    cout << (n/2)*d+(n%2)*c;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define M 1000000
using namespace std;

//vector<ll> ;

void answer(){
    ll n,m=0,ans=0,f=0;
    double x;
    cin>>n>>m;
    ll a[n+1];
    for(int i=0;i<n;i++){ cin>>a[i]; ans+=a[i]; }
    sort(a,a+n,greater<ll>());
    for(int i=0;i<m;i++){
        x = ans*1.0/(4*m);
        if(x>a[i]) f=1;
    }
    if(f==0){
        cout<<"Yes";
    }
    else cout<<"No";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int q;
    //cin>>q; while(q--)
        answer();
    return 0;
}

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

using namespace std;

int main()
{
	int H, W;
	char point[101][101];
	int result[100][100];

	for (int a = 0; a < 100; a++)
	{
		for (int b = 0; b < 100; b++)
		{
			result[a][b] = 10000;
		}
	}

	cin >> H >> W;

	for (int a = 0; a < H; a++)
	{
			cin >> point[a];
	}

	for (int x = 0; x < H; x++)
	{
		for (int y = 0; y < W; y++)
		{
			for (int z = 0; y - z >= 0; z++)
			{
				if (point[x][y - z] == *"c")
				{
					result[x][y] = min(z, result[x][y]);
				}
			}
		}
	}

	for (int a = 0; a < H; a++)
	{
		for (int b = 0; b < W; b++)
		{
			if (result[a][b] == 10000)
			{
				result[a][b] = -1;
			}

			if (b == W - 1)
			{
				cout << result[a][b] << endl;
			}
			else
			{
				cout << result[a][b] << " ";
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(111111);
  while(n--){
    ll a,b;cin>>a>>b;
    A[a]++;A[b+1]--;
  }
  ll ans = 0;
  for(int i=0;i<111110;i++){
    A[i+1] += A[i];
    ans += (A[i+1] > 0);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1152
def gcd(*nums)
	return nums.inject do |a, b|
		a, b = b, a % b until b.zero?
		a
	end
end

def lcm(*nums)
	return nums.inject {|a, b| a * b / gcd(a, b)}
end

gets
p lcm(*gets.split.map(&:to_i))

Measured memory_bytes: 6100
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
S = Counter(S)
for key in ['AC', 'WA', 'TLE', 'RE']:
    if key not in S:
        print(f'{key} x 0')
    else:
        print(f'{key} x {S[key]}')

Measured memory_bytes: 16612
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#include <queue>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long ll;
typedef vector<ll> vll;

int main(void) {
    ll num_of_passenger, capacity, limit_time;
    cin >> num_of_passenger >> capacity >> limit_time;
    priority_queue<ll, vll, greater<ll>> time;
    for (int i = 0; i < num_of_passenger; ++i) {
        ll temp;
        cin >> temp;
        time.push(temp);
    }

    ll ans = 0;
    ll limit = time.top() + limit_time;
    ll rest = 0;
    while (!time.empty()) {
        if (time.top() > limit || rest == 0) {
            ans++;
            rest = capacity - 1;
            limit = time.top() + limit_time;
        } else {
            rest--;
        }
        time.pop();
    }
    cout << ans << endl;

}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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 () {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  vi nums;
  int now = 1;
  int cnt = 0;
  rep(i,n) {
    if (s[i] == (char)(now + '0')) cnt++;
    else {
      nums.pb(cnt);
      now = 1 - now; // now ^= 1;
      cnt = 1;
    }
  }
  //if (cnt != 0) nums.pb(cnt);
  nums.pb(cnt);
  if (nums.size()%2 == 0) nums.pb(0);

  //rep(i,nums.size()) printf("%d%c", nums[i], i==nums.size()-1?'\n':' ');

  int add = 2*k + 1;
  int ans = 0;
  for (int i = 0; i < nums.size(); i += 2) {
    int tmp = 0;
    
    int left = i;
    int right = min(i+add, (int)nums.size());
    for (int j = left; j < right; ++j) {
      tmp += nums[j];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1020
use std::io;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn str_join<T: std::string::ToString>(s: &Vec<T>) -> String {
    s.iter()
        .map(|i| i.to_string())
        .collect::<Vec<_>>()
        .join(" ")
}

fn main() {
    let size: Vec<usize> = read_vec();
    let r = size[0];
    let c = size[1];
    let mut sheet: Vec<Vec<i32>> = Vec::new();
    for _ in 0..r {
        let mut row = read_vec();
        let sum = row.iter().sum();
        row.push(sum);
        sheet.push(row);
    }
    let mut bottom = Vec::new();
    for j in 0..c + 1 {
        let mut sum = 0;
        for i in 0..r {
            sum += sheet[i][j];
        }
        bottom.push(sum);
    }
    sheet.push(bottom);
    for x in &sheet {
        println!("{}", str_join(x));
    }
}



Measured memory_bytes: 5060
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)'''

n,k=map(int, input().split())
p=list(map(int, input().split()))
p.sort()
print(sum(p[:k]))

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

int main() {
    int n,k,count=0;
    cin>>n>>k;
    vector<int> h(n);
    rep(i,n) cin>>h[i];

    rep(i,n) {
        if (h[i] >= k) count++;
    }

    cout<<count<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

int main(){
    string S;cin>>S;
    ll sum = 0;
    int n = S.size();
    for(int bit = 0; bit < (1<<(n-1)); bit++)
    {
        int last = 0;
        REP(j,n-1){
            if(bit&(1<<j)) 
            {
                    //cout<<"hoge"<<" j"<<j-last+1<<endl;
                    string tmp = S.substr(last,j-last+1);
                    sum+= stoll(tmp);
                    last = j + 1;
                    //cout<<stoll(tmp)<<endl;
            }
        }
        sum+=stoll(S.substr(last,n-last));
        //cout<<"last"<<endl;
        //cout<<stoll(S.substr(last,n-last))<<endl;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
cost = [abs(A[i] - A[i + 1]) for i in range(N + 1)]
start = 0
end = sum(cost[2:])
for n in range(N):
    print(start + abs(A[n] - A[n + 2]) + end)
    if n != N - 1:
        start += cost[n]
        end -= cost[n + 2]


Measured memory_bytes: 14048
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=25000 +117;
const int MM=417;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}

const int mod=1e9+7;
int m,n,k;
LL pre[NN][MM]={};
LL suf[NN][MM]={};
int a[NN]={};
LL ksm(LL a,LL b){
	LL ret=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ret=ret*a%mod;
	return ret;
}
LL getfact(int n){
	LL ret=1;
	for(int i=1;i<=n;++i)ret=ret*i%mod;
	return ret;
}
int t[NN]={};
int getlas(){
	int pos=1;
	for(int i=1;i<=k;++i)t[i]=0;
	for(int i=1;i<=m;++i){
		++t[a[i]];
		if(t[a[i]]==2){
			while(a[pos]!=a[i]){
				t[a[pos]]--;
				++pos;
			}
			t[a[pos]]--;
			++pos;
		}
		if(i-pos+1==k)return k;
	}
	return m+1-pos;
}
int main(){
	//open();
	n=read();
	k=read();
	m=read();
	LL ans=0;
	for(int i=1;i<=m;++i){
		a[i]=read();
	}
	int tp=getlas();
	ans=ksm(k,n-m)*(n-m+1)%mod;
	if(tp==k){
		ans-=0;
		
	}
	else if(tp!=m){
	pre[0][tp]=1;
	for(int i=0;i<n-m;++i){
		for(int j=1;j<k;++j){
			pre[i+1][1]+=pre[i][j];
			pre[i+1][j+1]+=(k-j-1)*pre[i][j]%mod;
			pre[i+1][j+2]-=(k-j)*pre[i][j]%mod;
		}
		for(int j=2;j<k;++j){
			pre[i+1][j]+=pre[i+1][j-1];
			pre[i+1][j]%=mod;
		}
	}
	for(int i=1;i<=m/2;++i){
		swap(a[i],a[m+1-i]);
	}
	tp=getlas();
	suf[0][tp]=1;
	for(int i=0;i<n-m;++i){
		for(int j=1;j<k;++j){
			suf[i+1][1]+=suf[i][j];
			suf[i+1][j+1]+=(k-j-1)*suf[i][j]%mod;
			suf[i+1][j+2]-=(k-j)*suf[i][j]%mod;
		}
		for(int j=2;j<k;++j){
			suf[i+1][j]+=suf[i+1][j-1];
			suf[i+1][j]%=mod;
		}
	}
	for(int i=0;i<=n-m;++i){
		int a=i,b=n-m-i;
		LL sa=0,sb=0;
		for(int j=1;j<k;++j){
			sa=(sa+pre[a][j])%mod;
			sb=(sb+suf[b][j])%mod;
		}
		ans-=sa*sb%mod;
		ans%=mod;
	}
	}
	else{
		suf[1][1]=k;
		pre[1][1]=(m==1?k:0);
		for(int i=1;i<n;++i){
			for(int j=1;j<k;++j){
				suf[i+1][1]+=suf[i][j];
				suf[i+1][j+1]+=(k-j-1)*suf[i][j]%mod;
				suf[i+1][j+2]-=(k-j)*suf[i][j]%mod;
				pre[i+1][1]+=pre[i][j];
				pre[i+1][j+1]+=(k-j-1)*pre[i][j]%mod;
				pre[i+1][j+2]-=(k-j)*pre[i][j]%mod;
			}
			for(int j=2;j<k;++j){
				suf[i+1][j]+=suf[i+1][j-1];
				suf[i+1][j]%=mod;
				pre[i+1][j]+=pre[i+1][j-1];
				pre[i+1][j]%=mod;
			}
			for(int j=m;j<k;++j){
				pre[i+1][j]+=suf[i+1][j];
				pre[i+1][j]%=mod;
			}
		}
		LL tp=0;
		for(int j=1;j<k;++j){
			tp+=pre[n][j];
			tp%=mod;
		}
		tp=tp*getfact(k-m)%mod*ksm(getfact(k),mod-2)%mod;
		ans=(ans-tp)%mod;
	}
	ans=(ans+mod)%mod;
	printf("%lld\n",ans);
	close();
	return 0;
}

Measured memory_bytes: 163840
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;

int main()
{
    int n,a;
    while(scanf("%d%d",&n,&a) != EOF)
    {
        int temp = n%500;
        if(temp <= a) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


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

int main(void)
{
    int x1, x2, x3, x4, y1, y2, y3, y4;
    cin >> x1 >> y1 >> x2 >> y2;

    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x1 - (y2 - y1);
    y4 = y1 + (x2 - x1);

    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iostream>
#include <unordered_map>
#include <vector>

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

#define INF 1000000000

using namespace std;

int main() {
    int N, M;

    unordered_map<string, int> map;

    cin >> N;
    REP(i, N) {
        string str;
        cin >> str;
        auto it = map.find(str);

        if (it == map.end())
            map[str] = 1;
        else
            (it->second)++;
    }

    cin >> M;
    REP(i, M) {
        string str;
        cin >> str;
        auto it = map.find(str);

        if (it == map.end())
            map[str] = -1;
        else
            (it->second)--;
    }

    int max_v = 0;
    string max_str = "";

    for (auto it = map.begin(); it != map.end(); ++it) {
        if (it->second >= max_v) {
            max_v = it->second;
            max_str = it->first;
        }
    }

    cout << max_v << endl;

    return 0;
}


Measured memory_bytes: 256
require 'set'
h = Set.new
n = gets.to_i
n.times{|i|
    x, y = gets.split
    case x
    when "insert" then
        h.add(y)
    when "find" then
        if h.include?(y) then
            puts "yes"
        else
            puts "no"
        end
    end
}


Measured memory_bytes: 39728
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric> 
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1e9 + 5;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
///////////////////////////////////////////////////////////////////////

const int N = 101;
const int W = 1e5 + 5;

int n, w;
int weight, value;
vector<ll> dp(W);

int main() {
    scanf("%d%d", &n, &w);
    ll res = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &weight, &value);
        for (int weight_already = w - weight; weight_already >= 0; --weight_already) {
            chmax(dp[weight_already + weight], dp[weight_already] + value);
            chmax(res, dp[weight_already + weight]);
        }
    }
    printf("%lld\n", res);
}

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

int main() {
  int N;
  cin >> N;
  int ma = 0;
  int sum = 0;
  int p;
  for (int i=0;i<N;i++){
    cin >> p;
    sum += p;
    ma = max(ma, p);
  }
  cout << sum - ma/2 << endl;
}

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

int main()
{
    /* ------- 宣言と入力 ------- */

    int N, R;

    cin >> N >> R;

    /* ------- 計算 ------- */

    int ans;

    if (N < 10)
    {
        ans = R + 100 * (10 - N);
    }
    else
    {
        ans = R;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int a, b;
    cin >> a >> b;
    
    if (a >= 10 || b >= 10) cout << -1 << endl;
    else cout << a*b << endl;
    

    return 0;
}

Measured memory_bytes: 764
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		 Scanner sc = new Scanner(System.in);
	       int a = sc.nextInt();
	       int b = sc.nextInt();
	     
	     if (a<b){System.out.println("a < b");}
	     else if (a>b){System.out.println("a > b");}
	     else {System.out.println("a == b");}
	}

}

Measured memory_bytes: 26332
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k,x,i;
    cin>>k>>x;
    if(k==1)
    cout<<x<<endl;
    else if(k>1)
    {   
        for(i=x-(k-1);i<=x+(k-1);i++)
        {
            cout<<i<<" ";
        }
    }
    
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Team {
    int id;
    int correct;
    int pena;
    vector<int> ngcount;

    void Correct(int P, int t) {
        ++correct;
        pena += ngcount[P-1]*1200 + t;
    }

    void Wrong(int P, int t) {
        ++ngcount[P-1];
    }
};

bool operator < (const Team& a, const Team& b) {
    if(a.correct!=b.correct)
        return a.correct > b.correct;
    if(a.pena!=b.pena)
        return a.pena < b.pena;
    return a.id < b.id;
}

int main()
{
    while(1) {
        vector<Team> teams;
        int T, P, R;
        cin >> T >> P >> R;

        if(T==0 && P==0 && R==0) break;

        teams.resize(T);
        for(int i=0;i<T;++i) {
            teams[i].id = i+1;
            teams[i].correct = 0;
            teams[i].pena = 0;
            teams[i].ngcount.resize(P);
            fill(teams[i].ngcount.begin(), teams[i].ngcount.end(), 0);
        }

        for(int i=0;i<R;++i) {
            int tid, pid, t;
            string msg;
            cin >> tid >> pid >> t >> msg;
            if(msg=="CORRECT") {
                teams[tid-1].Correct(pid, t);
            } else {
                teams[tid-1].Wrong(pid, t);
            }

        }

        sort(teams.begin(), teams.end());
        for(int i=0;i<T;++i) {
            cout << teams[i].id << " " << teams[i].correct << " " << teams[i].pena << endl;
        }
    }
}

Measured memory_bytes: 936
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int K = cin.nextInt();
        long[] A = cin.ArrayLong(N);
        long[] sumA = new long[N + 1];
        long[] sumB = new long[N + 1];
        for (int i = 0; i < N; i++)
        {
            sumA[i + 1] = sumA[i] + A[i];
            sumB[i + 1] = sumB[i] + Math.Max(A[i], 0);
        }
        long ans = 0;
        for (int i = K; i <= N; i++)
        {
            ans = Math.Max(ans, sumB[N] - (sumB[i] - sumB[i - K]) + (sumA[i] - sumA[i - K]));
            ans = Math.Max(ans, sumB[N] - (sumB[i] - sumB[i - K]));
        }
        Console.WriteLine(ans);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 28764
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
const double PI = 3.14159265359;

int main(void) {
	ll n; cin >> n;
	unordered_map<ll, ll> m;
	for (ll i = 1;i <= n; i++) {
		ll t;
		cin >> t;
		m.emplace(t, i);
	}
	for (ll i = 1; i <= n; i++) {
		cout << m[i];
		if (i != n)cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 4900
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a,b,r;
	
	cin>>a>>b;
	while(1){
		if(a<b)	swap(a,b);
		r=a%b;
		if(r==0)	break;
		a=b;
		b=r;
	}
	cout<<b<<endl;
	return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N,M; cin >> N >> M;
    ll x[1005],y[1005],z[1005];
    rep(i,0,N) cin >> x[i] >> y[i] >> z[i];
    ll ans = 0;
    rep(i,0,(1<<3)){
        vector<ll> v;
        rep(j,0,N){
            ll tmp = 0;
            if(1<<0 & i) tmp += x[j];
            else tmp -= x[j];
            if(1<<1 & i) tmp += y[j];
            else tmp -= y[j];
            if(1<<2 & i) tmp += z[j];
            else tmp -= z[j];
            v.pb(tmp);
        }
        sort(allr(v));
        ll tmp2 = 0;
        rep(i,0,M) tmp2 += v[i];
        chmax(ans, tmp2);
    }

    cout << ans << ednl;
    return 0;
}


Measured memory_bytes: 3676
#include <stdio.h>

int main(void)
{
	int n;
	int debt = 100000;
	double  risi;
	int siri;
	int i, j;
	
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		risi = debt * 0.05;
		siri = risi;
		if (siri % 1000 != 0){
			siri = siri - siri % 1000;
			siri += 1000;
		}
		debt += siri;
	}
	
	printf("%d\n", debt);
	
	
	return (0);
}

Measured memory_bytes: 592
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define It iterator
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=100003;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

ll c[20001],a[20001],b[20001],p=0,n,m;

int main(){
    //freopen("test.in","r",stdin);
    cin>>m;
    rep(i,0,m) {int t; cin>>t; c[t-1]=i;}

    b[0]=p; a[0]=n=c[0]-p;
    rep(i,1,m){
        if(c[i]<c[i-1]) {p-=(c[i-1]-c[i]+1); n++;}
        else {p--; n+=(c[i]-c[i-1]+1);}
        a[i]=n; b[i]=p;
    }
    rep(i,0,m) cout<<a[i]+400000000<<" "; cout<<endl;
    rep(i,0,m) cout<<b[i]+400000000<<" "; cout<<endl;
    return 0;
}


Measured memory_bytes: 1152
def main():
    s = input()
    keyence = 'keyence'

    if keyence == s:
        print("YES")
        return

    List = []
    for i in range(len(keyence)):
        List.append((keyence[0:i], keyence[i:len(keyence)]))

    ans = "NO"

    for left, right in List:
        l = len(left)
        r = len(right)
        if s[0:l] == left and s[-r:] == right:

            ans = "YES"

    print(ans)
    return


main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

void cp()
{
    string s;
    cin >> s;
    int sum = 0;
    for(char x : s)
        sum = (sum + (x - '0')) % 9;
    cout << (sum ? "No" : "Yes");
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define pb push_back
#define int long long
#define pii pair<int, int>
#define tupint tuple<int, int, int>
#define tupint2 tuple<int, int, int, int>
#define str string
using namespace std;
const int M = 1e9 + 7;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k; cin >> n; k = 2;
    vector<int> H(n);
    for (int i = 0; i < n; i++) cin >> H[i];
    vector<int> dp = {0};
    for (int i = 1; i < k; i++) {
        int ans = 1e17;
        for (int j = 0; j < i; j++) {
            ans = min(ans, abs(H[i] - H[j]));
        }
        dp.pb(ans);
    }
    for (int i = k; i < n; i++) {
        int ans = 1e17;
        for (int j = 1; j <= k; j++) {
            ans = min(ans, dp[i - j] + abs(H[i] - H[i - j]));
        }
        dp.pb(ans);
    }
    cout << dp[n - 1];
}

Measured memory_bytes: 2168
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N=int.Parse(Console.ReadLine());
            var cards = new List<KeyValuePair<string,int>>();
            for(var i = 0;i<N;i++)
            {
                cards.Add(new KeyValuePair<string, int>(Console.ReadLine(),1));
            }
            var M=int.Parse(Console.ReadLine());
            for (var i = 0; i < M; i++)
            {
                cards.Add(new KeyValuePair<string, int>(Console.ReadLine(),-1));
            }
            var cs = cards.GroupBy(x => x.Key).ToArray();
            var maxstr = "";
            var maxnum = 0;
            foreach(var item in cs)
            {
                var tmpsum = 0;
                foreach(var c in item)
                {
                    tmpsum += c.Value;
                }
                if(maxnum<tmpsum)
                {
                    maxstr = item.Key;
                    maxnum = tmpsum;
                }
            }

            Console.WriteLine(maxnum<0?0: maxnum);
        }
    }
}


Measured memory_bytes: 13408
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scanf("%d", &a)
	fmt.Scanf("%d", &b)
	if a > b {
		c = a
		a = b
		b = c
	}
	if a == 1 && b == 2 {
		c = 3
	} else if a == 2 && b == 3 {
		c = 1
	} else {
		c = 2
	}
	fmt.Printf("%d\n", c)
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        boolean rslt = false;
        for (int i = 1; i <= 9; i++) {
            if (0 < n%i) continue;
            if (9 < n/i || n/i < 0) continue;
            rslt = true;
            break;
        }
        System.out.println(rslt?"Yes":"No");
    }
}

Measured memory_bytes: 25300
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int H[] = new int[N];

		// DPの作成と初期化
		int dp[] = new int[N];
		dp[0] = 0;
		final int INF = 1000000000;

		for (int i = 0; i < N; i++) {
			H[i] = sc.nextInt();

			if (i > 0) {
				dp[i] = INF; // DPをMAXで埋めておく
			}
		}

		for (int i = 1; i < N; i++) {
			// INF, i+1の移動で比較 => 必ずi+1
			dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(H[i] - H[i - 1]));

			if (i > 1) {
				// i+1とi+2で比較してDPを更新
				dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(H[i] - H[i - 2]));
			}
		}

		System.out.println(dp[N - 1]);

		sc.close();
	}

	public static int chmin(int a, int b) {
		if (a > b) {
			return b;
		} else {
			return a;
		}
	}
}


Measured memory_bytes: 48836