akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main(){
   ll n;cin >>n;
   ll a,b,c;
    for (int h = 1; h <=3500; ++h) {
        for (int w =1; w <=3500; ++w) {
            ll t=4*h*w-(w+h)*n;
            if(t<=0)continue;
            if(n*h*w%t==0){
                a=h,b=w,c=n*h*w/t;
                break;
            }
        }
    }
    cout <<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"



signed main()
{
    FAST;
    int t;
    t=1;
    while(t--)
    {
        int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
        int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
        int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
        int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
        int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
        
        cin>>n;
        map<int,int> mp;
        
        for(i=0;i<n;i++)
        {
            cin>>x;
            sum+=x;
            mp[x]++;
        }
        
        cin>>q;
        
        while(q--)
        {
            cin>>x>>y;
            
            if(mp.count(x))
            {
                sum -= (x*mp[x]);
                sum += (y*mp[x]);
                
                if(mp.count(y))
                mp[y]+=mp[x];
                
                else
                mp[y]=mp[x];
                
                mp[x]=0;
            }
            //cout<<x<<" "<<y<<" "<<mp[x]<<" "<<mp[y]<<endl;
            cout<<sum<<endl;
        }
        
        
        
        
    }
        
    
    
    
    
}

Measured memory_bytes: 8700
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#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 (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b > 9)
		cout << "error" << endl;
	else
		cout << a + b << endl;

	return 0;
}

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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()

using namespace std;
using ll = long long;


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

    ll n,m;
    string s;
    ll i,b,c=0,sum=0;
    queue<ll> q;

    cin >> n;

    rep2(i,1,10){
        q.push(i);
    }

    for(i = 0;i <n-1;++i){
        m = q.front();
        q.pop();
        if(m%10 != 0){
            q.push(10 * m +(m%10) -1); 
        }
        q.push(10*m + (m%10));
        if(m%10 != 9){
            q.push(10*m + (m%10)+1);
        }
    }
    cout << q.front() << endl;
    return 0;
}

Measured memory_bytes: 1792
from fractions import gcd

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

forward = []
backward = [0 for x in range(n)]

if n == 2:
    print(max(a[0], a[1]))
    exit(0)

for i in range(n):
    if i == 0:
        forward.append(a[i])
    else:
        forward.append(gcd(forward[i - 1], a[i]))


for i in range(n - 1, -1, -1):
    if i == n - 1:
        backward[i] = a[i]
    else:
        backward[i] = gcd(backward[i + 1], a[i])


ans = 1

for i in range(n):
    if i == 0:
        ans = max(ans, backward[1])
    elif i == n - 1:
        ans = max(ans, forward[n - 2])
    else:
        ans = max(ans, gcd(forward[i - 1], backward[i + 1]))

print(ans)

Measured memory_bytes: 16156
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,A,B,C,D,E;
  cin >>N>>A>>B>>C>>D>>E;
  long long int Q = 0;
  Q = max({(N - 1)/A,(N - 1)/B,(N - 1)/C,(N - 1)/D,(N - 1)/E});
  cout << Q + 5 << endl;
}
  
  
  
    

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, Y;
    cin >> X >> Y;
    int ans = 0;
    while (X <= Y) {
        ++ans;
        X *= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,d[31];

void dfs(int x,int sum,int prev){
  if(n==sum){
    for(int i=0;i<x;i++){
      if(i)cout<<' ';
      cout<<d[i];
    }
    cout<<endl;
  }
  for(int i=min(prev,n-sum);i>=1;i--){
    d[x]=i;
    dfs(x+1,sum+i,i);
  }
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    dfs(0,0,n);
  }
  return 0;
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <time.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define SQR(X) ((X)*(X))

/* Eratosthenes(int prime[],int n)は
nまでの素数をprimeに、2,3,と入れていきます */
/* 実行後arr[i]はiが素数の時1になります */
static ull prime[1000000];
ull Eratosthenes(ull N){
  static ull arr[15000005];
  for(ull i = 0; i < N; i++){
    arr[i] = 1;
  }
  for(ull i = 2; i < sqrt((double)N); i++){
    if(arr[i]){
      for(ull j = 0; i * (j + 2) < N; j++){
        arr[i *(j + 2)] = 0;
      }
    }
  }
  ull a = 0;
  for(ull i = 2; i < N; i++){
    if(arr[i]){
      prime[a++] = i;
    }
  }
  return a;
}

int test = 0;
/* ここからが本編 */
int main(void)
{
  int i,j,k,l;
  int rep = 100000;
  int n;
  while(cin >> n) {
    cout << Eratosthenes(n+1) << endl;
  }
  return 0;
}

Measured memory_bytes: 11384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin >> s;
    set<char> alphabet; 
    
    for (int i=0; i<s.size(); i++) {
        alphabet.insert(s.at(i));
    }
    
    for (int i=0; i<26; i++) {
        char alpha = 'a' + i;
        if (alphabet.count(alpha) == 0) {
            cout << alpha << endl;
            return 0;
        }
    }
    
    cout << "None" << endl;
}


Measured memory_bytes: 3696
#include <stdio.h>
int a,b,c,x,y;
int ans1,ans2,ans3;
int min(int a,int b){
	return a<b?a:b;
}
int main(){
	scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
	ans1 = x > y ? 2*c*y+(x-y)*a : 2*c*x+(y-x)*b;
	ans2 = a*x+b*y;
	ans3 = x>y?2*c*x:2*c*y;
	printf("%d",min(min(ans1,ans2),ans3));
}

Measured memory_bytes: 1708
#include <iostream>

using namespace std;

int n, re;
long long r;

int euclid (int d, int i) {
  int r;
  while (i != 0) {
    r = d % i;
    d = i;
    i = r;
  }
  return d;
}

int main()
{
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        r += euclid (euclid (i, j), k);
  cout << r;
  return 0;
}


Measured memory_bytes: 3632
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int a;
	std::string str;
	std::cin >> a >> str;
	if (a >= 3200)
	{
		std::cout << str << std::endl;
	}
	else
	{
		std::cout << "red" << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int a, b;
    cin >> a >> b;
    if (b % a == 0) cout << a + b << endl;
    else cout << b - a << endl;
    return 0;
}

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

void solve(long long a_I, long long a_O, long long a_T, long long a_J, long long a_L, long long a_S, long long a_Z){
	if ( a_I <= 0 && a_O <= 0 && a_J <= 0 && a_L <= 0 ) {
    printf("0\n"); return;
  }

  long long ans = 0;
  ans = a_O * 2;
  if ( a_I > 0 && a_J > 0 && a_L > 0 ) {
    if ( a_I % 2 == 1 ) {
      if ( a_J % 2 == 1 || a_L % 2 == 1 ) {
        a_J --;
        a_L --;
        a_I --;
        ans = ans + 6;
      }
    } else if ( a_J % 2 == 1 || a_L % 2 == 1 ) {
      if ( a_J % 2 == 1 && a_L % 2 == 1 ) {
        a_J --;
        a_L --;
        a_I --;
        ans = ans + 6;
      }
    }
  }
  /*
  if ( a_I % 2 == 1 ) {
    if ( a_J > 0 && a_L > 0 ) {
      if ( a_J >= 2 && a_L >= 2 && a_J % 2 != 1 && a_L % 2 != 1 ) {
      } else if ( (a_J >= 2 || a_L >= 2) && (a_J % 2 == 1 || a_L % 2 == 1) ) {
        a_J --;
        a_L --;
        a_I --;
        ans = ans + 6;
      } else {
        a_J --;
        a_L --;
        a_I --;
        ans = ans + 6;
      }
    }
  } else if ( a_I % 2 == 0 && a_L % 2 == 1 && a_J % 2 == 1 ) {
    a_J --;
    a_L --;
    a_I --;
    ans = ans + 6;
  }
  */
  ans = ans + (a_I / 2) * 4 + (a_J / 2) * 4 + (a_L / 2 ) * 4;

  printf("%lld\n", ans / 2);
}

int main(){	
	long long a_I;
	long long a_L;
	long long a_Z;
	long long a_J;
	long long a_T;
	long long a_S;
	long long a_O;
	scanf("%lld",&a_I);
	scanf("%lld",&a_O);
	scanf("%lld",&a_T);
	scanf("%lld",&a_J);
	scanf("%lld",&a_L);
	scanf("%lld",&a_S);
	scanf("%lld",&a_Z);
	solve(a_I, a_O, a_T, a_J, a_L, a_S, a_Z);
	return 0;
}



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

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

    std::size_t n;
    std::cin >> n;
    std::vector<int> inputs(n);
    for (std::size_t i = 0; i<n; ++i)
    {
        std::cin >> inputs[i];
    }

    int bAllXor = 0;
    for (std::size_t i = 0; i<n; ++i)
    {
        bAllXor ^= inputs[i];
    }

    for (std::size_t i = 0; i<n; ++i)
    {
        if (i!=0)
        {
            std::cout << " ";
        }
        std::cout << (bAllXor^inputs[i]);
    }
    std::cout << "\n";
}


Measured memory_bytes: 4020
words = lambda t : list(map(t, input().split()))
n = int(input())
a = words(int)

cur_max = 0
cur = 0
for i in range(1,n):
    #(i, a[i], a[i-1])
    if a[i] <= a[i-1]:
        cur += 1
    else:
        cur_max = max(cur_max, cur)
        cur = 0

cur_max = max(cur_max, cur)
print(cur_max)


Measured memory_bytes: 63984
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n){
      if((i + 1) % 2 != 0 && a[i] % 2 != 0) ans++;
    }
    print(ans);
    

}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	char a, b;
	cin >> a >> b;
	if (a == 'H' && b == 'H') {
		cout << 'H' << endl;
	}
	if (a == 'H' && b == 'D') {
		cout << 'D' << endl;
	}
	if (a == 'D' && b == 'H') {
		cout << 'D' << endl;
	}
	if (a == 'D' && b == 'D') {
		cout << 'H' << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N,mx,tmp = 0;
  int mn = 1001;
  cin >> N;
  for(int i = 0; N > i; i++){
    cin >> tmp;
    if(tmp > mx){
      mx = tmp;
    }
    if(mn > tmp){
      mn = tmp;
    }
  }
  cout << mx - mn << endl;
}

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

int main(){
    int n;cin>>n;
    int d,x;cin>>d>>x;
    int a,ans=x;
    fol(i,n){
        cin>>a;
        for(int i=0;i*a<d;++i){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a,b,c,d,e,f=[int(x) for x in input().split()]

ans=0
ans_s=0
ans_all=100*a
wlist=[]
slist=[]
for i in range(f//(100*a)+1):
    for j in range((f-i*100*a)//(100*b)+1):
        wlist.append(100*a*i+100*b*j)
for i in range((f*e//100)//c+1):
    for j in range((f*e//100)//d+1):
        slist.append(c*i+d*j)
wlist=set(wlist)
slist=set(slist)
for w in wlist:
    for s in slist:
        if w+s==0:break
        if s*100/(w+s)>ans and w*e/100>=s and w+s<=f:
            ans=s*100/(w+s)
            ans_s=s
            ans_all=w+s
print(ans_all,ans_s)

Measured memory_bytes: 22548
<?php

fscanf(STDIN, '%d', $N);
$life = explode(' ', fgets(STDIN));

while(count($life) > 1) {
    sort($life);
    $new_life = [];
    $new_life[] = (int)$life[0];
    for ($i = 1; $i <= count($life)-1; ++$i) {
        if (($life_result = (int)$life[$i] % (int)$life[0]) !== 0)
            $new_life[] = $life_result;
    }
    $life = $new_life;
}

echo $life[0];


Measured memory_bytes: 18932
#!usr/bin/env python3
from  heapq import heappush, heappop
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
  V, E, r = LI()
  INF = 10**12

  if V == 1:
    print(0)
    exit()

  # 隣接リスト
  adj = [[] for _ in range(V)]

  for i in range(E):
    s, t, d = LI()
    adj[s].append((t,d))

  # 初期状態
  q = [(0,r)]
  C = [INF] * V# 始点から各頂点までのコスト
  C[r] = 0

  # 本処理
  while len(q) > 0:
    # 未訪問かつ一番コストが小さいものをuとする
    cost, u = heappop(q)
  
    for v,d in adj[u]:
      tmp = C[u] + d
      if tmp < C[v]:
        C[v] = tmp
        heappush(q, (C[v], v))

  for c in C:
    if c == INF:
      print('INF')
    else:
      print(c)
    
#Solve
if __name__ == "__main__":
  main()


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int result = 1;
  for (int i = 0; i < N; i++) {
    int A, B;
    A = result * 2;
    B = result + K;
    if (A < B) {
      result = A;
    }
    else {
      result = B;
    }
  }
  
  cout << result << endl;
}


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

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
   
    cout << (char)(s1.at(0)-32) << (char)(s2.at(0)-32) << (char)(s3.at(0)-32) << endl;
}


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

#define MAX_V 11
#define INF 1e9

int min(int a, int b){
  return a < b ? a : b;
}

int main(void){
  int n, a, b, c;
  int dp[MAX_V][MAX_V];
  
  while(true){
    cin >> n;
    if(n == 0) break;

    // ?????????
    for(int i = 0; i < MAX_V; i++)
      for(int j = 0; j < MAX_V; j++)
        dp[i][j] = INF;

    for(int i = 0; i < MAX_V; i++)
      dp[i][i] = 0;
    
    for(int i = 0; i < n; i++){
      cin >> a >> b >> c;
      dp[a][b] = c;
      dp[b][a] = c;
    }

    // ???????????£???????????????
    for(int k = 0; k < MAX_V; k++)
      for(int i = 0; i < MAX_V; i++)
        for(int j = 0; j < MAX_V; j++)
          dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);


    // ??????????¨????
    int minpoint, mincost = INF;
    for(int i = 0; i < MAX_V; i++){
      // ???????????????????????????????????????????±???????
      int nowcost = 0;
      for(int j = 0; j < MAX_V; j++){
        if(dp[i][j] != INF){ nowcost += dp[i][j]; } 
      }

      // ?????????????????????????????????????????????????°?????????????
      if(nowcost != 0 && mincost > nowcost){
        mincost = nowcost;
        minpoint = i;
      }
    }
    
    // ??????
    cout << minpoint << " " << mincost << endl;
    
  }

  return 0;
}

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

int parent(int i){return i/2;}
int left(int i){return i*2;}
int right(int i){return i*2+1;}

int main(){

    int n;
    while(cin>>n){
        int binary_tree[255];
        for(int i=1;i<=n;i++)
            cin>>binary_tree[i];
        
        for(int i=1;i<=n;i++){
            printf("node %d: key = %d, ",i,binary_tree[i]);
            if(parent(i)>0)
                printf("parent key = %d, ",binary_tree[parent(i)]);
            if(left(i)<=n)
                printf("left key = %d, ",binary_tree[left(i)]);
            if(right(i)<=n)
                printf("right key = %d, ",binary_tree[right(i)]);
            cout<<endl;
        }
    }
}


Measured memory_bytes: 3204
input = input().split(" ")
a, b, c = int(input[0]), int(input[1]), int(input[2])
k = int(input[3])
totalnum = 0
for nuum in range(4):
    if a>=k: #もしaの枚数がkを上回っていたら
        totalnum+=k
        k=0
        break
    elif a<k and a!=0: #もしaの枚数がkを下回っていたら
        totalnum+=a #totalnumをa分足して
        k-=a #kからaの枚数分引く
        a=0
    elif b>=k: #もしbの枚数がkを上回っていたら
        k=0
        break
    elif b<k and b!=0: #もしbの枚数がkを下回っていたら
        k-=b #bの枚数分だけkから引く。
        b=0
    elif c>=k: #もしcのところまで来たら
        totalnum-=k
        break
print(totalnum)

Measured memory_bytes: 61920
// Branch on Condition - Range
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_B
using System;
using System.Linq;

namespace NTL_2_B {
	class Program {
		public Program() {}
		
		public static void Main() {
			new Program().Calc();
		}
		
		void Calc() {
			var n = Input.Split(' ')
                            .Select(i => int.Parse(i))
			                .ToArray();
			Output(judge(n) ? "Yes" : "No");
		}
		
		String Input {
			get {
				return Console.ReadLine();
			}
		}
		
		void Output(String str) {
			Console.WriteLine(str);
		}
		
		bool judge(int[] n) {
            return n[0] < n[1] && n[1] < n[2];
		}
	}
}

Measured memory_bytes: 9376
#include<bits/stdc++.h>
using namespace std;
int main( )
{
	char a[101];
	gets(a);
	int lena=strlen(a);
	for(int i=0;i<lena;i++)
	{
		if(a[i]=='C')
		{
			for(int j=i+1;j<lena;j++)
			{
				if(a[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

const int N = 200200; 
const ll mod = 998244353; 

int n, k;

ll fpw(ll x, ll k, ll p) {
  ll ret = 1; 
  while(k) {
    if(k & 1) ret = ret * x % p; 
    x = x * x % p; k >>= 1; 
  }
  return ret; 
}

ll fac[N], ivf[N]; 

void prework() {
  fac[0] = 1; int m = 2 * (n + k);  
  for(int i = 1; i <= m; i++) {
    fac[i] = 1ll * fac[i - 1] * i % mod; 
  }
  ivf[m] = fpw(fac[m], mod - 2, mod); 
  for(int i = m - 1; i >= 0; i--) 
    ivf[i] = ivf[i + 1] * (i + 1) % mod; 
}

ll C(int n, int m) {
  if(n < 0 || n < m) return 0; 
  return fac[n] * ivf[n - m] % mod * ivf[m] % mod; 
}

int main() {
  cin >> k >> n; 
  prework(); 
  for(int i = 2; i <= 2 * k; i++) {
    int t = 0; 
    for(int j = 1; j <= k; j++) {
      if((i - j) >= 1 && (i - j) <= k) {
        t++; 
      }
    } 
    t = (t + 1) / 2;  
    ll ans = 0; 
    for(int j = 0; j <= t && j + j <= n; j++) {
      ll op = (j & 1) ? (mod - 1) : 1; 
      ans += op * C(t, j) % mod * C(n + k - 2 * j - 1, k - 1) % mod; 
      ans %= mod; 
    }
    printf("%lld\n", ans); 
  }
  return 0; 
}

Measured memory_bytes: 384
n=int(input())
a=[0]+list(map(int,input().split()))+[0]
s = sum([abs(a[i+1]-a[i]) for i in range(n+1)])
for i in range(1,n+1):
  ans = s+abs(a[i-1]-a[i+1])-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1]))
  print(ans)

Measured memory_bytes: 14048
#include <iostream>

using namespace std;

const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};
int w, h;
char map[21][21];
int cnt;

void dfs(int x, int y)
{
    cnt++;
    map[y][x] = '#';

    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];

        if (nx < 0 || ny < 0 || nx >= w || ny >= h) 
            continue;
        else if (map[ny][nx] == '.') {
            dfs(nx, ny);
        }
    }
}

int main()
{
    while (cin >> w >> h, w || h) {
        int sx, sy;

        for (int y = 0; y < h; y++)
            for (int x = 0; x < w; x++) {
                cin >> map[y][x];
                if (map[y][x] == '@') {
                    sx = x;
                    sy = y;
                }
            }

        cnt = 0;
        dfs(sx, sy);
        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

ll mod=998244353;
int D[100010], num[100010];

int main() {
	int N;
	cin >> N;
	int mx=0;
	for(int i=0; i<N; ++i){
		cin >> D[i];
		++num[D[i]];
		mx=max(mx, D[i]);
	}
	if(D[0]>0 || num[0]>1){
		cout << 0 << endl;
		return 0;
	}
	ll ans=1;
	for(int i=1; i<=mx; ++i){
		for(int j=0; j<num[i]; ++j){
			ans=(ans*num[i-1])%mod;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    map<string,int> ma;
    map<string,int> ::iterator it;
    ma["AC"] = 0;
    ma["WA"] = 0;
    ma["TLE"] = 0;
    ma["RE"] = 0;
    while(n--){
        string verdict;
        cin >> verdict;
        ma[verdict]++;
    }
    cout << "AC x " << ma["AC"] << "\n" <<
            "WA x " << ma["WA"] << "\n" <<
            "TLE x " << ma["TLE"] << "\n" <<
            "RE x " << ma["RE"] << "\n";

    return 0;
}




Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int N = 45;
int n, a[N][N], f[N][N][N], g[N][N][N], ans;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
signed main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); n <<= 1;
	for(int i = 1; i <= n; i ++) for(int j = 1; j <= n; j ++) scanf("%1d", &a[i][j]);
	for(int i = 1; i < n; i ++)
	{
		f[i][i][i] = 1;
		for(int j = i + 1; j < n; j ++) g[i][i][j] = a[j][i];
	}
	for(int z = 3; z < n; z += 2)
		for(int i = 1; i <= n - z; i ++)
		{
			int j = i + z - 1;
			for(int p = i; p < j; p += 2)
				for(int q = j; q > p; q -= 2)
				{
					int sum = 0;
					for(int k = q; k <= j; k ++) sum += g[i][p][k] * f[q][j][k];
					for(int k = p + 1; k < q; k ++) f[i][j][k] += sum * f[p + 1][q - 1][k];
				}
			for(int w = i; w <= j; w ++)
				for(int k = j + 1; k < n; k ++)
					g[i][j][k] += f[i][j][w] * a[k][w];
		}
	for(int i = 1; i < n; i ++) if(a[n][i]) ans += f[1][n - 1][i];
	printf("%lld\n", ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())
#define AsceSort(a) sort(a.begin(),a.end())

using namespace std;
typedef long long ll;

int main(void) {
	int n;
	cin >> n;
	if (n == 1)cout << "Hello World" << endl;
	else if (n == 2) {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}





Measured memory_bytes: 256
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 5e5 + 10;

inline void Read(int &x) {
	x = 0; register char cc = '\0'; int fff = 1;
	for (; cc < '0' || cc > '9'; cc = getchar())
		if (cc == '-') fff = -1;
	for (; cc >= '0' && cc <= '9'; cc = getchar())
		x = (x << 1) + (x << 3) + (cc & 15);
	x *= fff;
}

int n, mxn, a[N], b[N];

inline int Check(int x) {
	for (int i = 1; i <= mxn; ++i)
		if (a[i] <= x) b[i] = 0;
		else b[i] = 1;
	if (mxn == 1) return b[1];
	//printf("%d : ", x);
	//for (int i = 1; i <= mxn; ++i) printf("%d ", b[i]);
	//printf("\n");
	for (int i = 0; i < n - 1; ++i) {
		if (b[n - i] == b[n - i - 1]) return b[n - i];
		if (b[n + i] == b[n + i + 1]) return b[n + i];
	}
	if (n & 1 /*mxn & 1*/) return b[n];
	else return (!b[n]);
}

int main()
{
	Read(n);
	mxn = n * 2 - 1;
	for (int i = 1; i <= mxn; ++i) Read(a[i]);
	int L = 1, R = mxn/* n */, mid = 0, fps = 0;
	while (L <= R) {
		mid = (L + R) >> 1;
		if (!Check(mid)) {
			fps = mid;
			R = mid - 1;
		}
		else L = mid + 1;
	}
	printf("%d\n", fps);
	
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    long long int ans = 0;
    cin >> n;
    vector<int> a(n);

    for (int i = 1; i < n+1;i++){
        if(i%3!=0&&i%5!=0){
            ans += i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 7120
n, c = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
a, b = [0] * n, [0] * n
a[0] = s[0][1] - s[0][0]
b[0] = s[n - 1][1] - (c - s[n - 1][0])
for i in range(1, n):
    a[i] = a[i - 1] + s[i][1] - (s[i][0] - s[i - 1][0])
    b[i] = b[i - 1] + s[n - 1 - i][1] - (s[n - i][0] - s[n - 1 - i][0])
maxa, maxb = [0] * n, [0] * n
maxa[0], maxb[0] = a[0], b[0]
for i in range(1, n):
    maxa[i] = max(maxa[i - 1], a[i])
    maxb[i] = max(maxb[i - 1], b[i])
ans = max(maxa[n - 1], maxb[n - 1], 0)
for i in range(n - 1):
    ans = max(ans, a[i] + maxb[n - 2 - i] - s[i][0])
    ans = max(ans, b[i] + maxa[n - 2 - i] - (c - s[n - 1 - i][0]))
print(ans)

Measured memory_bytes: 38052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <iterator>
#include <list>
#include <stack>
#include <queue>
#include <cstdlib>
using namespace std;
int check(int s)
{
    int n = (int)sqrt(s);
    if(n*n == s)return 1;
    return 0;
}
int main()
{
    int n;
    cin >> n;
    for(int i = n;i >= 0;i--)
    {
        if(check(i))
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main(){
  string s;
  long k;
  cin >> s >> k;
  char ret;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '1' && k == i+1){
      ret = '1';
      break;
    }
    else if(s[i] != '1'){
      ret = s[i];
      break;
    }
  }
  cout << ret << endl;
  return 0; 
}



Measured memory_bytes: 256
N=int(input())
ans=[0 for _ in range(10001)]
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            v=i*i+j*j+k*k+i*j+j*k+k*i
            if v<10001:
                ans[v]+=1
for i in range(N):
    print(ans[i+1])

Measured memory_bytes: 9308
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int length[] = new int[N*2];
        int i, niku = 0;
        for (i = 0 ; i < N*2 ; i++) {
            length[i] = sc.nextInt();
        } 
        Arrays.sort(length);
        for (i = 0 ; i < N ; i++) {
            // System.out.println(i);
            // System.out.println("length[2*i] " + length[2*i]);
            // System.out.println("length[2*i+1] " + length[2*i+1]);
            if (length[i] < length[2*i+1]) {
                niku += length[2*i];
            } else {
                niku += length[2*i+1];
            }
        }
        System.out.println(niku);
    }
}


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

using namespace std;

#define forn(i, n) for (int64_t i = 0; i < (int64_t) (n); ++i)
#define endl '\n'

template<typename T> void _dbg(const char*_s,T _h) { cerr<<_s<<" = "<<_h<<"\n"; }

template<typename T, typename... Ts> void _dbg(const char*_s,T _h,Ts... _t) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

#ifdef LOCAL
    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int N = 500 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
string s;
map<char, int> cnt[2];

bool read() {
    if (!(cin >> s))
        return false;

    return true;
}

void solve() {
    n = s.size();
    
    forn (i, n)
        ++cnt[i % 2][s[i]];

    if (cnt[0]['L'] > 0 || cnt[1]['R'] > 0)
        cout << "No\n";
    else
        cout << "Yes\n";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



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

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	int N;
	cin >> N;

	ll sum = 0;
	for (int i = 1; i <= N; ++i)
		if (i % 3 && i % 5) sum += i;

	cout << sum;

	return 0;
}


Measured memory_bytes: 3648
def isdiv3 n
  if n % 3 == 0
    true
  else
    false
  end
end

def isinclude3 n
  while n != 0
    if n % 10 == 3
      return true
    else
      n /= 10
    end
  end
end

n = gets.to_i
for i in 1..n
  if isdiv3(i) || isinclude3(i)
    print " " + i.to_s
  end
end
print "\n"

Measured memory_bytes: 6096
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)

long long gcd(int a, int b){
    if(a % b == 0){
        return b;
    }else{
        return gcd(b, a % b);
    }
}

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

Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1
#define MAX 102000


struct Node{ int p, l, r;
};
struct Node T[MAX];
int n, H, D[MAX];

int wowDep(int);
void print(int);

int main(){
  int i, j, d, v, c, l,n,m;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) T[i].p = T[i].l = T[i].r = NIL;

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
    for ( j = 0; j < d; j++ ){
      scanf("%d", &c);
      if ( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  
  H = 0;
  for ( i = 0; i < n; i++ ){
    D[i] = wowDep(i);
    if ( D[i] > H ) H = D[i];
  }

  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}

int wowDep(int a){
  int depth = 0;
  for(; T[a].p != NIL ;depth++) a = T[a].p;
  return depth;
}
void print(int a){
  int i, c;
  printf("node %d: ", a);
  printf("parent = %d, ", T[a].p);
  printf("depth = %d, ", D[a]);

  if ( T[a].p == NIL ) printf("root, ");
  else if ( T[a].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0, c = T[a].l; c != NIL; i++, c = T[c].r){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}



Measured memory_bytes: 3300
x = input()
y = x.split()
y = [int (i) for i in y]
string = input()

length = y[0]
num    = y[1]
arr    = [0] * (length + 1)
arr[0] = 0

count = 0
for i in range(length-1):
    if string[i] == "A" and string[i+1] == "C":
        count +=1
        arr[i+1] = count
    else:
        arr[i+1] = arr[i]

result   = 0
for i in range(num):
    z = input()
    c = z.split()
    c = [int (i) for i in c]
    l = c[0]
    r = c[1]
    result = arr[r-1] - arr[l-1]

    print(result)
    result = 0


Measured memory_bytes: 6188
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
    }
};

void prog()
{
    input in;
    output out;

    in.read<int>();
    auto s = in.read<std::string>();
    int res = 0;

    auto p = s.find("ABC");
    while (p != std::string::npos) {
        p = s.find("ABC", p + 3);
        ++res;
    }
    out(res);
}

int main()
{
    prog();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,temp;
int main()
{
    cin>>a>>b>>c;
    if(b>=a)//特判 
    {
        cout<<1<<endl;
        return 0;
    }
    if(c>=b)
    {
        cout<<-1<<endl;
        return 0;
    }
    if((a-b)%(b-c)>=1)
	temp=1;
    cout<<((a-b)/(b-c)+temp)*2+1<<endl;
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <array>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int H,W;
string board[405];
int memo[405][405][2];
bool used[405][405];
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  int tmp=0;
  int maxpoint=0;
  for(int i=1;i<=n;i++)
    {
      tmp+=i;
      maxpoint=i;
      if(tmp>=n)break;
    }
  //cout << tmp << ' ' << maxpoint << endl;
  for(int i=1;i<=maxpoint;i++)
    {
      if(i==tmp-n) continue;
      cout << i << endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a;
  int b;
  int c;
  int num;
  scanf("%d%d%d",&a,&b,&c);
  while(a <= b){
    if(c % a == 0){
      num++;
    }
    a++;
  }
  printf("%d\n", num);
}



Measured memory_bytes: 2104
import java.util.ArrayList

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { s -> s.toInt() }
    val x = Array(N) {0L}
    val y = Array(N) {0L}
    val z = Array(N) {0L}

    for (i in 0 until N) {
        val (a, b, c) = readLine()!!.split(" ").map {s -> s.toLong() }
        x[i] = a
        y[i] = b
        z[i] = c
    }

    var res = (-1e18).toLong()

    for (i in -1 .. 1 step 2) for(j in -1 .. 1 step 2) for(k in -1 .. 1 step 2) {
        val v = ArrayList<Long>()

        for(l in 0 until N) {
            v.add(x[l] * i + y[l] * j + z[l] * k)
        }

        v.sort()
        v.reverse()

        res = Math.max(res, v.subList(0, M).sum())
    }

    println(res)
}

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

signed main(void)
{
	vector<int> v(3);
	int ans;
	rep(i, 3) cin >> v.at(i);
	sort(v.begin(), v.end());
	ans = 0;
	for(int i = 1; i < 3; i++)
	{
		ans += v.at(i) - v.at(i - 1);
	}
	cout << ans << endl;
	return 0;
}


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

// g = eGCD(a, b, s, t)  --->  sa + tb = g
constexpr ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

constexpr ll gcd(ll a, ll b) {
  ll dummy1 = 0;
  ll dummy2 = 0;
  return eGCD(a, b, dummy1, dummy2);
}


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  int g = 0;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (i == 0) {
      g = a;
      continue;
    }
    g = gcd(g, a);
  }
  cout << g << endl;

  return 0;
}



Measured memory_bytes: 256
n=int(input())
st=[]
ans=0
for i in range(n):
	x=int(input())
	st.append([x,x%10])
	ans+=x
if ans%10!=0:
	print(ans)
else:
	st.sort(key=lambda x:x[0])
	for i in range(n):
		if st[i][1]!=0:
			print(ans-st[i][0])
			exit()
	print(0)

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

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  ll a, b;cin>>a>>b;
  int ans=0;
  while(a<=b){a*=2;ans++;}
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    string s, t;
    cin >> n >> s >> t;
    int same = 0;
    
    if (s == t) {
        same = n;
    }
    else {
        rep(i, n) {
            bool f = true;
            
            rep(ii, n - i) {
                if (s[i + ii] != t[ii]) {
                    f = false;
                    break;
                }
            }
            
            if (f) {
                same = n - i;
                break;
            }
        }
    }
    
    cout << (2 * n - same) << endl;
    return 0;
}


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

vector<string> s = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main()
{
	reverse(s.begin(),s.end());
	string t;
	cin >> t;
	for(int i = 0;i<7;i++)
	{
		if(s[i]==t)
		{
			cout<<i+1<<endl;
		}
	}
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long 
using namespace std;

signed main() {
	int N,A,B;
	cin >> N >> A >> B;
	string S;
	cin >> S;
	int cnt = 0;
	int other = 0;
	for(int i = 0;i < N;i++) {
		if(S.at(i) == 'a') {
			if(A + B > cnt) {
				cout << "Yes" << endl;
				cnt++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if(S.at(i) == 'b') {
			if(A + B > cnt && other < B) {
				cout << "Yes" << endl;
				cnt++;
				other++;
			}
			else {
				cout << "No" << endl;
			}
		}
      	else {
          	cout << "No" << endl;
        }
	}
}


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


#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
long long inf=1000000007;

long long min1(long long a, long long b, long long c)
{
	return (min(a,min(b,c)));
}

int solve(vector<long long> &arr, vector<long long> &dp, int n)
{
	if (n<=1)
	{
		dp[n]=0;
		return 0;
	}
	if (dp[n]!=-1)
	{
		return dp[n];
	}
	dp[n]=min(abs(arr[n]-arr[n-2])+solve(arr,dp,n-2),abs(arr[n]-arr[n-1])+solve(arr,dp,n-1));
	return dp[n];
}

int main()
{
	fast;
	int n;
	cin >> n;
	vector<long long> arr(n+2);
	arr[0]=	INT_MAX;
	arr[1]=	INT_MAX;
	for (int i=2; i<n+2; i++)
	{
		cin >> arr[i];
	}
	vector<long long> dp(n+2,-1);
	dp[2]=0;
	cout << solve(arr,dp,n+1);
	return 0;
}

Measured memory_bytes: 9600
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  (n:k:_) <- fmap (map read . words) getLine :: IO [Double]
  print $ solve n k

solve :: Double -> Double -> Double
solve n k = foldr (\i acc -> acc + prob i) 0 [1..n] 
  -- sum [ prob i | i <- [1..n]]
  where
    prob :: Double -> Double
    prob i
      | i > k = 1 / n
      | otherwise = 1 / (n * (go 1 i))
    go j i = if i * j >= k then j else go (2*j) i




Measured memory_bytes: 6780
N = int(input())

ans = 0

for i in range(1, N+1):

    for j in range(1, i+1):
        tmp = 0
        if j % 2 == 1:
            for k in range(1, j+1):
                if j % k == 0:
                    tmp += 1
    if tmp == 8:
        ans += 1

print(ans)


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


int main(){
	vector< pair<int, int> > a;
	int k, t;
	cin >> k >> t;
	for(int i = 0; i < t; i++){
		int tmp;
		cin >> tmp;
		if (tmp > 0)
		a.push_back(make_pair(-tmp, i));
	}

	sort(a.begin(), a.end());
	int ret = 0;
	int last = -1;
	while(!a.empty()){
		if (a[0].second == last && a.size() > 1){
			a[1].first++;
			last = a[1].second;
			if (a[1].first == 0)
				a.erase(a.begin() + 1);
		}else{
			if (a[0].second == last)
				ret++;
			last = a[0].second;
			a[0].first ++;
			if (a[0].first == 0)
				a.erase(a.begin());
		}
		sort(a.begin(), a.end());
	}
	cout << ret;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(1,n - 1):
  target = p[i]
  sort_list = [p[i - 1],p[i],p[i + 1]]
  sort_list = sorted(sort_list)
  if sort_list[-2] == target:
    ans += 1
print(ans)

Measured memory_bytes: 3060
n = gets.to_i

a,b = 1,1
n.times do |i|
  l,r = gets.split.map(&:to_i)
  l_large = l
  r_large = r
  if a/l > b/r
    bai = a%l==0 ? a/l : a/l+1
    l_large = l*bai
    r_large = r*bai
  else
    bai = b%r==0 ? b/r : b/r+1
    l_large = l*bai
    r_large = r*bai
  end
  a = l_large
  b = r_large
end
puts a+b


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


int main()
{
int N;
int D;
int X;
int A[102];
int Ans = 0;
cin>>N>>D>>X;

for(int i=1;i<N+1;++i) cin>>A[i];

for(int i=1;i<N+1;++i) 
   {for(int j=0;1+j*A[i]<D+1;j++){
   Ans=Ans+1;
   }
  }


Ans=Ans+X;
cout<<Ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


int main(){
    ll K, N;    cin >> K >> N;
    vector<ll> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    ll res = LONG_LONG_MAX;
    for(int i = 1; i < N; i++){
        ll tmp = K-(a[i] - a[i-1]);
        res = min(res, tmp);
    }
    res = min(res, a[N-1] - a[0]);

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 1792