akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 2019;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()



int main()
{
    int N, K;

    cin >> N >> K;

    set<int> S;

    rep(i, K)
    {
        int d;
        cin >> d;

        rep(j, d)
        {
            int a;
            cin >> a;
            S.insert(a);
        }
    }


    cout << N - S.size() << endl;

    return 0;
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

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

	public static void main(String[] args){

		solve_abc164_b();
	}
  
  	public static void solve_abc164_b(){

		FastScanner sc = new FastScanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		int i = 0;
		
		while((a > 0) && (c > 0)){
			
			if(i % 2 == 0) c = c - b;
			else a = a - d;
			
			i++;
		}
		
		String ans;
		
		if(a <= 0) ans = "No";
		else ans = "Yes";
		
		System.out.println(ans);
		


	}
}

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

int main()
{

  int n;
  int a[120] = {0};

  std::cin >> n;
  int j;

  for (j = 0; j < n; ++j) {
    std::cin >> a[j];
  }

  std::sort(a, a+j, [](int l, int r){return l > r;});

  int play = 0;
  int opp = 0;
  for (int i = 0; a[i] != 0; ++i) {
    if (i % 2 == 0) {
      play += a[i];
    } else {
      opp += a[i];
    }
  }
    std::cout << play - opp << std::endl;
  

  return 0;
}


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

using namespace std;

const int maxN = 1e5+5;
const int INF = 1e9;

int A[maxN], DP[maxN];

void solve() {
    int n; cin >> n;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        DP[i] = INF;
    }
    DP[0] = 0;
    for(int i = 1; i < n; i++){
        DP[i] = min(DP[i], abs(A[i]-A[i-1])+DP[i-1]);
        if(i > 1)
            DP[i] = min(DP[i], abs(A[i]-A[i-2])+DP[i-2]);
    }
    cout << DP[n-1] << "\n";

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    bool multitest = false;
    //multitest = true;
    if (multitest) {
        int t; cin >> t;
        while (t--)
            solve();
    }
    else
        solve();
}


Measured memory_bytes: 4324
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord

main :: IO ()
main = breads >>= main'
    where
        main' [_, k] = breads >>= print . solve k 

-- |
-- >>> solve 3 [-30, -10, 10, 20, 50]
-- 40
-- >>> solve 2 [10, 20, 30]
-- 20
-- >>> solve 1 [0]
-- 0
-- >>> solve 5 [-9, -7, -4, -3, 1, 2, 3, 4]
-- 10
solve :: Int -> [Int] -> Int
solve k xs = foldl' ff len $ zip (tail xs) bs
    where
        (b : bs) = drop (k - 1) xs
        len = calc (head xs) b

        ff acc (minv, maxv) = min acc $ calc minv maxv

        calc minv maxv
            | minv >= 0 = maxv 
            | maxv <= 0 = abs minv
            | otherwise = abs minv + maxv + min (abs minv) maxv


breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

Measured memory_bytes: 8572
from collections import deque
K = int(input())
queue = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for i in range(K):
  x = queue.popleft()
  
  if x % 10 != 0:
    queue.append(10 * x + (x % 10) - 1)
    
  queue.append((10 * x) + x % 10)
    
  if x % 10 != 9:
    queue.append(10 * x + (x % 10) + 1)
    
print(x)

Measured memory_bytes: 11908
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <tuple>

using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;

int main()
{
    string s;
    int k;
    cin >> s >> k;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != 'a' && 'z' - s[i] + 1 <= k)
        {
            k -= 'z' - s[i] + 1 ;
            s[i] = 'a';
        }
    }
    for (int i = 0; i < k; i++)
    {
        auto p = s.size() - 1;
        if (s[p] == 'z') s[p] = 'a';
        else s[p]++;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main (){
     int N,x,sum=0;
     cin >> N >> x;
     vector<int> v(N);

     for(int i=0;i<N;i++){
         cin >> v.at(i);
     }

    sort(v.begin(),v.end());
    
    int i;
    for(i=0;i<N;i++){
        if(sum > x){
            break;
        }
        sum += v.at(i);
    }
    //最後の一人が満足してるか？
    if( x == sum ){
        cout << i << endl;
    }
    else{
        cout << i-1 << endl; 
    }
}

Measured memory_bytes: 256
//optimize Algae
//x[i + 1] =rx[i] -D
#include <bits/stdc++.h>

using namespace std;

int x1[12], x, r, d;
int main()
{
	cin >> r >> d >> x;
	x1[1] = r * x - d;
	for(int i = 1; i <= 10; i++)
	{
		x1[i + 1] = x1[i] * r - d;
		cout << x1[i] << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
/*#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}*/
ll pows(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>k>>x;
if(k*500>=x)
{
	cout<<"Yes";
}
else
{
	cout<<"No";
}
}

Measured memory_bytes: 256
#include <stdio.h>
#define dr 1000000007

long mpow(long p0,long p1){
  if(p0==1) return(p0);
  long n=1,a,b;
  a=p0;
  b=p1;
  while(b!=0){
    if(b&1){
      n*=a;
      n%=dr;
    }
    b>>=1;
    a*=a;
    a%=dr;
  }
  return(n);
}

int main(){
  long n,k,i,j,m=0,a[100005],c;
  scanf("%ld",&n);
  scanf("%ld",&k);
  for(i=0;i<k;i++){
    a[i]=0;
  }
  for(i=k;i>0;i--){
    c=mpow(k/i,n);
    for(j=i*2;j<=k;j+=i){
      c+=dr-a[j-1];
      c%=dr;
    }
    m+=c*i;
    m%=dr;
    a[i-1]=c;
  }
  printf("%ld",m);
  return(0);
}

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

#define SIZE 200000

int main(void) {
    long long prime[SIZE + 1] = {};
    long long p[10001] = {};
    int n;
    
    for(long long i = 2; i <= SIZE; ++i) {
        if(prime[i] != 0)   continue;
        long long j = i * 2;
        while(j <= SIZE) {
            ++prime[j];
            j += i;
        }
        
    }
    int j = 2;
    for(int i = 1; i <= 10000; ++i) {
        while(prime[j] != 0) {
            ++j;
        }
        p[i] = p[i - 1] + j;
        ++j;
    }
    
    while(cin >> n) {
        if(n == 0)   break;
        cout << p[n] << endl;
    }
    
    return 0;
}


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

#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int INF = 1e9 + 7;


int main(void)
{
	FAST
	
	map<string, int> cnt;
	int n; cin >> n;
	for(int i = 0; i < n; i++){
		string s; cin >> s;
		cnt[s]++;
	}

	cout << "AC x " << cnt["AC"] << '\n';
	cout << "WA x " << cnt["WA"] << '\n';
	cout << "TLE x " << cnt["TLE"] << '\n';
	cout << "RE x " << cnt["RE"] << '\n';

	return 0;
}


Measured memory_bytes: 3524
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;


int main() {
	string s;
	string t;
	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());

	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
d = [int(input()) for i in range(n)]
pos = 0
ans = "yes"
for i in range(n):
      if pos>=i*10:
            pos = max(pos,i*10+d[i])
      else:
            ans = "no"
            break
      if pos >= (n-1)*10:
            break
pos = 0
for i in range(n):
      if pos>=i*10:
            pos = max(pos,i*10+d[n-1-i])
      else:
            ans = "no"
            break
      if pos >= (n-1)*10:
            break
print(ans)


Measured memory_bytes: 17444
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e19;

//////////////////////////////////////////////////////////////////////
int main() {
	int n; cin >> n;
	vi a(n), b(n);
	ll cum = 0LL;
	rep(n) {
		cin >> a[i] >> b[i];
	}
	for (int i = n - 1; i >= 0; i--) {
		a[i] += cum;
      	if(a[i]%b[i]==0) cum+=0;
		else cum += (1 + (a[i]-1) / b[i])*b[i] - a[i];
	}
	cout << cum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

void insetrtionsort(int a[], int n)
{
    int j, v;
    for (int i = 1; i < n; i++)
    {
        v = a[i];
        j = i - 1;
        while (j >= 0 && a[j] > v)
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        for (int i = 0; i < n; i++)
        {
            cout << a[i] << " ";
        }
        cout << endl;
    }
}

int gcd(int a, int b)
{
    if (a < b)
    {
        int t = a;
        a = b;
        b = t;
    }
    cout << a << " " << b << endl;
    if (b == 0) return a;
    else return gcd(b, b%a);
}

int main()
{
    int n, q, t, x, y;
    cin >> n >> q;
    vector<int> v[n];
    for (int i = 0; i < q; i++){
        cin >> y;
        if (y == 0){
            cin >> t >> x;
            v[t].push_back(x);
        }
        else if (y == 1){
          	cin >> t;
          	for (int j = 0; j < v[t].size(); j++){
              if (j < v[t].size()-1) cout << v[t][j] << " ";
              else cout << v[t][j];
            }
          cout << endl;
        }
        else {
          cin >> t;
          v[t].clear();
		}
    }
    return 0;
}



Measured memory_bytes: 5908
#include <stdio.h>
#include<stdlib.h>
#include<string.h>

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

int main()
{
	long i = 1;
	long a, b, n;
	long ans = 0;
	long r = 0;
	scanf("%ld%ld%ld", &n, &a, &b);
	if (n <= a) {
		printf("%ld", n);
		return 0;
	}
	else if (n <= (a + b)) {
		printf("%ld", a);
		return 0;
	}
	else {
		r = n % (a + b);
		ans = n / (a + b);
		if (r >= a) {
			printf("%ld", (ans + 1)*a);
			return 0;
		}
		else {
			printf("%ld", ans*a + r);
			return 0;
		}
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    ll n,k;
    cin >> n >> k;
    if(abs(n-k) >= n){
        cout << n << endl;
    }else{
        cout << min( abs(n-(n/k)*k) , abs(n-(n/k+1)*k) ) << endl;
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
	char sen[500][50];
	int word[500]={0},smax=0,sh=0,wordmax=0,wordh=0,i=0,o=0;
	while(scanf("%s",sen[i]) != EOF){
		if(smax<strlen(sen[i])){
			smax=strlen(sen[i]);
			sh=i;
		}
		for(o=0;o<i;o++){
			if(strcmp(sen[i],sen[o]) == 0){
					word[o]++;
					break;
			}
		}i++;
	}
	for(o=0;o<i;o++){
		if(word[o] > wordmax){
			wordmax=word[o];
			wordh=o;
		}
	}
	printf("%s %s\n",sen[wordh],sen[sh]);
	return 0;
}

Measured memory_bytes: 564
import java.io.*;
import java.util.*;

public class Main {
    public static void main (String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int[] point = new int[n];

        int cnt = 0;
        for (int i = 0; i < q; i++) {
            int a = sc.nextInt();
            point[a-1]++;
            cnt++;
        }

        for (int i = 0; i < n; i++) {
            if (k - cnt + point[i] > 0)
                System.out.println("Yes");
            else
                System.out.println("No");
        }
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

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

Measured memory_bytes: 46732
#include<stdio.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>

/*
	入力例：
	3
	1 1 3
*/

int main(){
	int i,j;
	long strInput[1];
	for(int i=0;i<1;i++){
	 scanf("%ld", &strInput[i]);
	}

	char strRet[20];
	memset(strRet,0x00,20);
	long tmp=0;
	tmp=strInput[0];
	for(i=0;tmp>0;i++){
			strRet[18-i]='a'+((tmp-1)%26);
//		printf("%d--%c\n",tmp,strRet[15-i]);

		tmp= (long)((tmp - ((tmp-1)%26))/26);
	}
//	printf("end -- %d\n",lastIdx);
	
//	printf("%s\n",strRet[15 - lastIdx +1]);
	char* strRet2;
	for (i=0;i<19;i++){
		if (strRet[i]!=0x00){
			strRet2 = &strRet[i];
			break;
		}
	}
	printf("%s\n",strRet2);
  return 0;
}

Measured memory_bytes: 1656
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    D,X = (int(_) for _ in input().split())
    ans = X
    for i in range(N):
        ans += math.ceil((D/int(input())))
    
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define int long long
using namespace std;

int calc(int a, int b, int c) {
    a = abs(a);
    b = abs(b);
    c = abs(c);

    int ret = 1LL<<62;
    ret = min(ret, abs(c - b) + abs(b - a));
    ret = min(ret, abs(c - a) + abs(a - b));

    return ret;
}
signed main() {
    int A, B, Q;
    cin >> A >> B >> Q;

    vector<int> s(A);
    vector<int> t(B);
    for (int& x : s) cin >> x;
    for (int& x : t) cin >> x;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    vector<int> ss = s;
    vector<int> tt = t;
    reverse(ss.begin(), ss.end());
    reverse(tt.begin(), tt.end());
    for(int& x : ss) x = -x;
    for(int& x : tt) x = -x;

    for (int i = 0; i < Q; i++) {
        int x;
        cin >> x;

        auto sa = lower_bound(s.begin(), s.end(), x);
        auto ta = lower_bound(t.begin(), t.end(), x);
        auto sb = lower_bound(ss.begin(), ss.end(), -x);
        auto tb = lower_bound(tt.begin(), tt.end(), -x);

        int ans = 1LL<<62;
        if (sa != s.end() && ta != t.end()) ans = min(ans, calc(*sa, *ta, x));
        if (sa != s.end() && tb != tt.end()) ans = min(ans, calc(*sa, *tb, x));
        if (sb != ss.end() && ta != t.end()) ans = min(ans, calc(*sb, *ta, x));
        if (sb != ss.end() && tb != tt.end()) ans = min(ans, calc(*sb, *tb, x));

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;

int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	//solve
	vector<string> ans(h);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] != '.')
				continue;
			int num = 0;
			for (int d = 0; d < 8; d++) {
				int ni = i + dy[d];
				int nj = j + dx[d];
				if (ni < 0 or ni >= h) continue;
				if (nj < 0 or w <= nj) continue;
				if (s[ni][nj] == '#') num++;
			}
			s[i][j] = num + '0';
		}
	}
	cout << endl;
	//output 
	for (int i = 0; i < h; i++) {
		cout << s[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative

readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

main = do
  (a,b,k) <- (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2)) <$> getIntVector
  print $ solve a b k


divisor n = loop 1
  where
    loop d
      | n < d^2 = []
      | n == d^2 = [d]
      | otherwise = if r == 0 then d : q : loop (d+1) else loop (d+1)
      where (q,r) = n `divMod` d


solve a b k = (commonDivisor a b) !! (n-k)
  where
    n = length $ commonDivisor a b

commonDivisor a b = loop 1
  where
    loop d
      | min a b < d = []
      -- | a == d^2 && b == d^2 = [d]
      | otherwise = if ra == 0 && rb == 0 then d : loop (d+1) else loop (d+1)
      where
        (qa,ra) = a `divMod` d
        (qb,rb) = b `divMod` d


Measured memory_bytes: 380
n, a, b = gets.split.map(&:to_i)
s = gets.chomp
ab = a + b
m = 0
brank = 0
s.chars.each do |c|
  if c == ?a && m < ab
    m += 1
    puts :Yes
  elsif c == ?b && m < ab && brank < b
    m += 1
    brank += 1
    puts :Yes
  else
    puts :No
  end
end

Measured memory_bytes: 9852
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
void solve()
{
    int x,y;
    cin>>x>>y;
    rep0(i,x+1){
        if(i*2+(x-i)*4==y){
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 3656
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,K = II()
S = str(input())

num = 0
for i in range(N):
    if i==N-1:
        print(N)
        exit()
    if S[i]=='0' and S[i+1]=='1':
        num += 1
        place = i+1
    if num==K:
        break

if num<K:
    print(N)
    exit()

for i in range(place+1,N):
    if i==N-1 and S[i]=='1':
        print(N)
        exit()
    if S[i]=='0':
        break

place = i-1

ans = place+1

for i in range(1,N):
    if S[i-1]=='0' and S[i]=='1':
        val = N-1
        for j in range(place+2,N):
            val = j
            if j==N-1:
                break
            if S[j]=='1' and S[j+1]=='0':
                break
        if val-i+1>ans:
            ans = val-i+1
        place = val

print(ans)

Measured memory_bytes: 41328
import sys
from itertools import product

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    P = product(range(4), repeat=N)

    # 0 -> not used
    # 1 -> A
    # 2 -> B
    # 3 -> C
    ans = INF
    for pattern in P:
        mp = 0
        a = 0
        b = 0
        c = 0
        for i, p in enumerate(pattern):
            if p == 0:
                continue
            elif p == 1:
                if a != 0:
                    mp += 10
                a += L[i]
            elif p == 2:
                if b != 0:
                    mp += 10
                b += L[i]
            else:
                if c != 0:
                    mp += 10
                c += L[i]

        if a == 0 or b == 0 or c == 0:
            continue

        mp += abs(A - a)
        mp += abs(B - b)
        mp += abs(C - c)

        if mp < ans:
            ans = mp

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int T; std::cin >> T;
    while (T--) {
        long long n, a, b, c, d; std::cin >> n >> a >> b >> c >> d;
        std::map<long long, long long> mp;
        std::vector<long long> t = { 2,3,5 }, co = { a,b,c };
        mp[0] = 0; mp[1] = d;
        auto func = [&](auto &self, long long m) {
            if (mp.count(m)) return mp[m];
            long long ret = 2e18;
            if (2e18/d >= m) ret = m*d;
            for (int i = 0; i < 3; i++) {
                ret = std::min(ret,
                    self(self, m / t[i]) + co[i] + (m%t[i])*d);
                ret = std::min(ret,
                    self(self, (m + t[i] - 1) / t[i])
                    + co[i] + (t[i] - m%t[i])*d);
            }
            return mp[m] = ret;
        };
        std::cout << func(func, n) << std::endl;
    }
    return 0;
}


Measured memory_bytes: 4424
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

int N;

void dfs(string s, char mx, std::ostream& out) {
    if (s.length() == N) {
        out << s << '\n';
    } else {
        for (char c = 'a'; c <= mx; c++) {
            dfs(s + c, ((c == mx) ? char(mx + 1) : mx), out);
        }
    }
}

class DStringEquivalence {
public:
	void solve(std::istream& in, std::ostream& out) {
	    in >> N;
	    dfs("", 'a', out);
	}
};


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

	DStringEquivalence solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1536
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

divisors n = dsub 1
  where
    dsub x
      | q<x = []
      | r/=0 = dsub (x+1)
      | x==q = [x]
      | otherwise = [x] ++ dsub (x+1) ++ [q]
      where
        (q,r) = divMod n x

f ds t = subtract t $ head $ dropWhile (<t) ds

main = do
    n <- getInt
    (t:ts) <- sortBy (flip compare) <$> replicateM n getInt
    print $ sum $ map (f $ divisors t) ts


Measured memory_bytes: 40748
#include<bits/stdc++.h>
using namespace std;
struct card{
  int num;
  char c;
  bool operator <(const card &a)const{
    if(c == a.c){
      return num < a.num;
    }
    return c < a.c;
  }
};

int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    card c[9];
    for(int i = 0; i < 9; i++){
      cin >> c[i].num;
    }
    for(int i = 0; i < 9; i++){
      cin >> c[i].c;
    }
    sort(c, c + 9);
    // for(int i = 0; i < 9; i++){
    //   cout << c[i].num << " ";
    // }
    // cout << endl;
    // for(int i = 0; i < 9; i++){
    //   cout << c[i].c << " ";
    // }
    // cout << endl;
    
    bool flag = 0;
    do{
    for(int i = 0; i < 9; i += 3){
      // cout << "i:" << i << endl;
      // cout << c[i].c << " " << c[i + 1].c << endl;
      if(!(c[i].c   == c[i + 1].c   && c[i + 1].c   == c[i + 2].c))break;
      if(!(c[i].num == c[i + 1].num && c[i + 1].num == c[i + 2].num) &&
	 !(c[i].num + 1 == c[i + 1].num && c[i + 1].num + 1 == c[i + 2].num)){
	break;
      }
      if(i == 6){
	flag = 1;
      }
    }
    }while(next_permutation(c, c + 9));
    if(flag)cout << 1 << endl;
    else cout << 0 << endl;
  }
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC130(void);
void ABC131(void);
void ABC132(void);
void ABC133(void);
void ABC134(void);
void ABC135(void);
void ABC136(void);
void ABC137(void);
void ABC138(void);
void ABC139(void);

int main(void){
    ABC130();
}

void ABC130(){
    int n,x,l,sum=0,c=1;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>l;
        sum+=l;
        if(sum<=x)c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
n, A, B, C = map(int,input().split())
l = [int(input()) for i in range(n)]

inf = 10**9

def dfs(cur, a, b, c):
    if cur == n:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else inf#-30は最初に選んだもの
    ret0 = dfs(cur + 1, a, b, c)#何も使わない
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10#Aに使うために合成するとして
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10#Bに使うために合成するとして
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10#Cに使うために合成するとして
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 43996
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
char T[MAXN];
int R, S, P;

int val(char c) {
    if (c == 'r') return P;
    else if (c == 's') return R;
    return S;
}

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    scanf("%d %d %d", &R, &S, &P);
    scanf("%s", T);
    int ans = 0;
    for (int i = 0; i < K; i++) {
        for (int j = i; j < N; j += K) {
            if (j - K < 0) {
                ans += val(T[j]);
                continue;
            }
            if (T[j] == T[j - K]) {
                T[j] = '0';
                continue;
            }
            ans += val(T[j]);
        }
    }
    printf("%d\n", ans);

    return 0;
}


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

int n;

void rec(int pos, string s) {
    if (pos == n) {
        cout << s << endl;
        return;
    }
    int mx = -1;
    rep(i,pos) mx = max(mx, s[i] - 'a');
    rep(k,mx+2) rec(pos+1, s + char('a'+k));
}

int main(void){
    cin >> n;
    rec(0, "");
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

struct rest{
	string name;
	int score, i;
	bool operator<(const rest& other){
		if(name != other.name)
			return name < other.name;
		return score > other.score;
	};
}rests[1000];

int main(){
	ios_base::sync_with_stdio(false);
	int n; cin >> n;
	for(int i=0; i<n; i++){
		string s; int score;
		cin >> s >> score;
		rests[i] = {s, score, i+1};
	}

	sort(rests, rests+n);
	for(int i=0; i<n; i++) cout << rests[i].i << endl;

	return 0;
}

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

struct edge { long long to, cap, rev;};

void add_edge(long long from, long long to, long long cap, vector<edge> G[]){
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size()-1});
}

long long dfs_flow(long long v, long long t, long long f, vector<bool> &used, vector<edge> G[]){
    if(v==t) return f;
    used[v] = true;
    for(long long i=0; i<G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            long long d = dfs_flow(e.to, t, min(f, e.cap), used, G);
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

long long max_flow(long long N, long long s, long long t, vector<edge> G[]){
    long long flow = 0;
    const long long INF = 1e18;
    vector<bool> used(N);
    while(true){
        fill(used.begin(), used.end(), false);
        long long f = dfs_flow(s, t, INF, used, G);
        if(f==0) return flow;
        flow += f;
    }
}

int main(){
    long long i, j, k;
    long long H, W;
    cin >> H >> W;
    vector<edge> edges[202];
    long long S = H+W, T = H+W+1;
    const long long INF = 1e9;
    for(i=0; i<H; i++){
        string str;
        cin >> str;
        for(j=0; j<W; j++){
            if(str[j] == 'S'){
                add_edge(S, i, INF, edges);
                add_edge(S, H+j, INF, edges);
            }else if(str[j] == 'T'){
                add_edge(i, T, INF, edges);
                add_edge(H+j, T, INF, edges);
            }else if(str[j] == 'o'){
                add_edge(i, H+j, 1, edges);
                add_edge(H+j, i, 1, edges);
            }
        }
    }
    long long ans = max_flow(H+W+2, S, T, edges);
    cout << (ans >= INF ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,Y;
    cin>>N>>Y;
    int res10000=-1,res5000=-1,res1000=-1;
    for (int a = 0; a <= N; a++)
    {
        for (int b = 0; b+a <=N ; b++)
        {
            int c=N-a-b;
            int total=10000*a+5000*b+1000*c;
            if (total== Y)
            {
                res10000=a;
                res5000=b;
                res1000=c;

            }
            
        }
        
    }
    cout<<res10000<<" "<<res5000<<" "<<res1000<<endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

class B11
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var ok = false;
		Task.Run(() =>
		{
			Thread.Sleep(100);
			if (ok) return;
			Console.WriteLine("NEGATIVE CYCLE");
			Environment.Exit(0);
		});

		var h = Read();
		var es = new int[h[1]].Select(_ => Read()).ToArray();

		var d = Dijklmna(h[0] - 1, h[2], -1, es);
		Console.WriteLine(string.Join("\n", d.Select(x => x == long.MaxValue ? "INF" : $"{x}")));
		ok = true;
	}

	static long[] Dijklmna(int n, int sv, int ev, int[][] es)
	{
		var map = Array.ConvertAll(new int[n + 1], _ => new List<int[]>());
		foreach (var e in es)
		{
			map[e[0]].Add(new[] { e[1], e[2] });
		}

		var d = Enumerable.Repeat(long.MaxValue, n + 1).ToArray();
		var q = new Queue<int>();
		d[sv] = 0;
		q.Enqueue(sv);

		while (q.Count > 0)
		{
			var v = q.Dequeue();
			foreach (var e in map[v])
			{
				if (d[e[0]] <= d[v] + e[1]) continue;
				d[e[0]] = d[v] + e[1];
				q.Enqueue(e[0]);
			}
		}
		return d;
	}
}



Measured memory_bytes: 23412
#include <stdio.h>

int main(){
	char str[128];
	int i=0;

	gets(str);
	
	while(str[i] != '\0'){
		i++;
	}
	for(i=i-1;i>=0;i--){
		printf("%c",str[i]);
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 520
#include<stdio.h>

int main()
{
  int n;
  scanf("%d", &n);
  
  int nums[100];
  for (int i = 0; i < n; i++) {
    scanf("%d", &nums[i]);
  }
  
  int triangleCount = 0;
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      if (nums[i] == nums[j]) {
        // 同じ長さは使用不可
        continue;
      }
      for (int k = j + 1;  k < n; k++) {
        if (nums[i] == nums[k] || nums[j] == nums[k]) {
          // 同じ長さは使用不可
          continue;
        }
        if (nums[i] + nums[j] > nums[k] && nums[j] + nums[k] > nums[i] && nums[k] + nums[i] > nums[j]) {
          triangleCount++;
        }
      }
    }
  }
  
  printf("%d\n", triangleCount);
  
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (b==0) return a;
    else{
    	return gcd(b,a%b);
    }
}
 
int main() {
	ll a,b;
  	cin >> a >> b;
  	if(a<=b){
      cout << '0' << endl;
    }
  	else{
      cout << a-b << endl;
    }
}


Measured memory_bytes: 256
import itertools
A = []
for i in range(5):
  a = int(input())
  A.append(a)
  
Comb = list(itertools.permutations(A))
min_time = float('inf')
for i in range(len(Comb)):
  tmp = list(Comb[i])
  tmp_time = 0
  for j in range(5):
    if(j != 4):
     if(tmp[j]%10 == 0): tmp_time += tmp[j]
     else: tmp_time += 10*(tmp[j]//10 + 1)
    if(j == 4):
     tmp_time += tmp[j]
  min_time = min(min_time,tmp_time)
print(min_time)

Measured memory_bytes: 3064
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int MAXN = 1e5 + 5;

ll a, b, c;
    
int main() {
	//freopen(NAME".in", "r", stdin);
	//freopen(NAME".out", "w", stdout);

	ios_base::sync_with_stdio(0);
	cin.tie(0);            	
	cout.tie(0);
	
	cin >> a >> b >> c;
	ll mn = min(a, c);
	ll res = 0;
	res += mn;
	a -= mn;
	c -= mn;
	if (b >= c) cout << res + b + c;
	else cout << res + b * 2 + 1;
	return 0;	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<fstream>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
ll D;
ll c[26];
ll s[366][26];
ll t[366];

ll total_max_score;
ll ft[366];

//スコア計算
ll score(ll days){
	ll ans=0;
	ll last[26];
	rep(i,26)last[i]=0;
	for(ll d=1;d<=days;d++){
		ans+=s[d][t[d]];
		last[t[d]]=d;
		rep(i,26){
			ans-=c[i]*(d-last[i]);
		}
	}
	return ans;
}

ll whole_score;
ll score_typ[26];
void recalc(ll i){
	ll ans=0;
	ll last=0;
	for(ll d=1;d<=D;d++){
		if(t[d]==i){
			ans+=s[d][i];
			last=d;
		}
		ans-=c[i]*(d-last);
	}
	whole_score-=score_typ[i];
	score_typ[i]=ans;
	whole_score+=score_typ[i];
}
void change(ll d,ll q){
	ll b=t[d];
	t[d]=q;
	recalc(b);
	recalc(q);
	if(whole_score>total_max_score){
		total_max_score=whole_score;
		for(ll d=1;d<=D;d++){
			ft[d]=t[d];	
		}
	}
}
void init_score(){
	total_max_score=-1e17;
	whole_score=0;
	rep(i,26){
		score_typ[i]=0;
		recalc(i);
	}
}

//貪欲法
void greedy(){
	for(ll d=1;d<=D;d++){
		ll ma=-1e17,pt=0;
		rep(i,26){
			t[d]=i;
			ll res=score(d);
			if(ma<res){
				ma=res;
				pt=i;
			}
		}
		t[d]=pt;
	}
}

//日程を√cに応じて分配
void distribute(){
	vector<ll> v;
	rep(i,26){
		for(ll x=1;x*x<=c[i];x++){
			v.push_back(x);
		}
	}
	for(ll d=1;d<=D;d++){
		t[d]=v[rand()%(ll)v.size()];
	}
}

//局所探索_改
void local_search(){
	rep(u,50000){//日付を一つ選んで、コンテストを変更
		ll d=rand()%D+1;
		ll q=rand()%26;
		ll b=t[d];
		ll bef_score=whole_score;
		change(d,q);
		ll aft_score=whole_score;
		if(bef_score>aft_score){
			change(d,b);
		}
	}
	rep(u,50000){//日付を二つ選んで、コンテストをswap
		ll bef_score=whole_score;
		ll d1,d2;
		do{
			d1=rand()%D+1;
			d2=rand()%D+1;
		}while(d1==d2);
		ll p=t[d1],q=t[d2];
		change(d1,q);
		change(d2,p);
		ll aft_score=whole_score;
		if(bef_score>aft_score+(50000-u)/100){
			change(d1,p);
			change(d2,q);
		}
	}
	rep(u,50000){//近い日付を二つ選んで、コンテストをswap
		ll bef_score=whole_score;
		ll d1,d2;
		ll k=8;
		d1=rand()%(D-k)+1;
		d2=rand()%k+1+d1;
		ll p=t[d1],q=t[d2];
		change(d1,q);
		change(d2,p);
		ll aft_score=whole_score;
		if(bef_score>aft_score+(50000-u)/10){
			change(d1,p);
			change(d2,q);
		}
	}
}


int main(){
	//ifstream ifs("input.txt");
	cin>>D;
	rep(i,26)cin>>c[i];
	for(ll d=1;d<=D;d++)rep(j,26)cin>>s[d][j];
	greedy();
	//distribute();
	init_score();
	local_search();
	//ofstream ofs("output.txt");
	for(ll d=1;d<=D;d++){
		cout<<ft[d]+1<<"\n";
	}
}


Measured memory_bytes: 3676
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef vector<vector<ll>> matrix;

ll l[100005];
ll diff[100005];
void solve() {
  int n;
  cin >> n;
  ll totalSum = 0;
  for(int i = 0; i < n; i++) {
    cin >> l[i];
    totalSum += l[i];
  }
  ll sumInOne = n*(n+1LL) / 2;
  if(totalSum % sumInOne) {
    cout << "NO\n";
    return;
  }
  ll expectedIncOps = totalSum / sumInOne;
  for(int i = 0; i < n; i++) {
    diff[i] = (l[(i+1)%n] - l[i]);
  }
  int desiredIncOps = 0;
  for(int i = 0; i < n; i++) {
    diff[i] -= expectedIncOps;
    if(diff[i] % n || diff[i] > 0) {
      cout << "NO\n";
      return;
    }
    desiredIncOps -= diff[i] / n;
  }
  if(expectedIncOps != desiredIncOps) {
    cout << "NO\n";
    return;
  }
  cout << "YES\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 1792