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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

char c[10];
int k[10];
bool not0[10];
// vi hoge;
int m;

int dfs(int idx, int used, int lr) {
  if (idx >= m) {
    // if (lr == 0) {
    //   REP(i, hoge.size() / 3) {
    //     LOG("%c:%d*%d=%d ", c[i], hoge[i * 3], hoge[i * 3 + 1], hoge[i * 3 + 2]);
    //   }
    //   LOG("%d ", lr);
    //   LOG("\n");
    // }
    return lr == 0;
  }
  int res = 0;
  FOR(i, not0[idx] ? 1 : 0, 10) {
    if (BIT(used, i)) continue;
    // hoge.push_back(i);
    // hoge.push_back(k[idx]);
    // hoge.push_back(k[idx] * i);
    res += dfs(idx + 1, (used | 1 << i), lr + k[idx] * i);
    // hoge.pop_back();
    // hoge.pop_back();
    // hoge.pop_back();
  }
  return res;
}

int main() {
  int n;
  while(cin >> n, n) {
    fill_n((int*)k, 10, 0);
    fill_n((bool*)not0, 10, false);

    vector<string> str(n);
    map<char, pair<int, bool>> alpha;
    REP(i, n){
      cin >> str[i];
      REP(j, str[i].length()){
        alpha[str[i][j]] = {0, false};
      }
    }
    m = (int) alpha.size();

    REP(i, n - 1){
      for(int j = str[i].length() - 1, n = 1; j >= 0; j--, n *= 10) {
        alpha[str[i][j]].first += n;
      }
    }
    for(int j = str[str.size() - 1].length() - 1, n = 1; j >= 0; j--, n *= 10) {
      alpha[str[str.size() - 1][j]].first -= n;
    }
    REP(i, n){
      if (str[i].length() > 1)
        alpha[str[i][0]].second = true;
    }

    int ii = 0;
    for(auto it = alpha.begin(); it != alpha.end(); it++, ii++) {
      c[ii] = it->first;
      k[ii] = it->second.first;
      not0[ii] = it->second.second;
    }
    // REP(i, m){
    //   LOG("%c %d %s\n", c[i], k[i], not0[i] ? "true" : "false");
    // }

    // getchar(); getchar();
    cout << dfs(0, 0, 0) << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back

void solve(){
    int n;
    scanf("%d", &n);
    vi h(n), dp(n + 1, INT_MAX);
    dp[0] = 0;
    for (int i = 0; i < n; i++) scanf("%d", &h[i]);
    for (int i = 0; i < n - 1; i++){
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
        // (dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }
    printf("%d", dp[n - 1]);
}
int main()
{
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,m,sum=0;
	cin>>n>>m;
	if(n>=m/2){
		cout<<m/2;return 0;
	}
	sum+=n;
	m-=2*n;
	sum+=m/4;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import copy

N, X, Y = map(int, input().split())
def check(num, distance):
    if num!=0:
        distance[num-1]=min(distance[num]+1, distance[num-1])
    if num!=N-1:
        distance[num+1]=min(distance[num+1], distance[num]+1)
    if num==X-1:
        distance[Y-1]=min(distance[Y-1], distance[X-1]+1)
    elif num==Y-1:
        distance[X-1] = min(distance[X-1], distance[Y-1]+1)
total_answer=[]
answer=[N]*N
for k in range(N):
    temp=copy.copy(answer)
    temp[k]=0
    #print(temp)
    for i in range(0, N):
        check(i, temp)
        #print(temp)
    #print(temp)
    for j in range(N-1,-1,-1):
        check(j, temp)
    #print(temp)
    #print('/n')

    for i in range(0, N):
        check(i, temp)

    for j in range(N - 1, -1, -1):
        check(j, temp)
    for i in range(0, N):
        check(i, temp)

    for j in range(N - 1, -1, -1):
        check(j, temp)

        #print(temp)
    #print(temp)
    total_answer+=temp
#print(total_answer)
import collections
dict=collections.Counter(total_answer)
#print(dict)
for i in range(1, N):
    print(dict[i]//2)

Measured memory_bytes: 152276
a, b, c, d = map(int, tuple(input()))
if a+b+c+d == 7:
    print('{}+{}+{}+{}=7'.format(a, b, c, d))
elif a+b+c-d == 7:
    print('{}+{}+{}-{}=7'.format(a, b, c, d))
elif a+b-c+d == 7:
    print('{}+{}-{}+{}=7'.format(a, b, c, d))
elif a+b-c-d == 7:
    print('{}+{}-{}-{}=7'.format(a, b, c, d))
elif a-b+c+d == 7:
    print('{}-{}+{}+{}=7'.format(a, b, c, d))
elif a-b+c-d == 7:
    print('{}-{}+{}-{}=7'.format(a, b, c, d))
elif a-b-c+d == 7:
    print('{}-{}-{}+{}=7'.format(a, b, c, d))
elif a-b-c-d == 7:
    print('{}-{}-{}-{}=7'.format(a, b, c, d))


Measured memory_bytes: 3064
# D
n, k = map(int, input().split())
s = str(input())
r = 0
l = 0
max_len = 0
count = k
ans = 0
if all([int(i) == 1 for i in list(s)]):
    ans = len(s)
else:
    while r < n:
        if r == n-1:
            break
        while count > 0:
            if r == n-1:
                break
            if int(s[r]) == 1:
                r += 1
                continue
            else:
                count -= 1
                while int(s[r]) == 0:
                    if r == n-1:
                        break
                    r += 1
                while int(s[r]) == 1:
                    if r == n-1:
                        break
                    if r == n-2 and int(s[n-1]) == 0:
                        break
                    if int(s[r+1]) == 0:
                        break
                    r += 1
                continue
        ans = max(ans, r - l + 1)
        while int(s[l]) == 1:
            if l == n-1:
                break
            l += 1
        while int(s[l]) == 0:
            if l == n-1:
                break
            l += 1
        count += 1
print(ans)

Measured memory_bytes: 4980
from collections import deque

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

graph = [[] for _ in range(n+1)]

for i in range(m):
 a, b = map(int, input().split())
 graph[a].append(b)
 graph[b].append(a)

#a,b = 1 2 (頂点1,2が隣接)
#a,b = 2 3 (頂点2,3が隣接)
#a,b = 3 4 (頂点3,4が隣接)
#a,b = 4 2 (頂点2,2が隣接)

#G = [[],[2],[1,3,4],[2,4],[3,2]]

ans = [0] * (n-1)

d = deque()
d.append(1)
#頂点1を訪問した

while d:
 v = d.popleft()
 for i in graph[v]:
   if ans[i-2] != 0 or i == 1:
     continue
   ans[i-2] = v
   d.append(i)

print("Yes")
print(*ans, sep="\n")

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


#define CMAX 200000

ll solve(int N, vi& _a) {

    vi a;
    a.reserve(N);
    int last = -1, cmax = -1;
    for(int ai: _a){
        if (ai == last) continue;
        a.pb(ai); last = ai;
        amax(cmax, ai);
    }
    N = a.size();

    vvi loc(cmax+1);
    rep(i,N) loc[ a[i] ].pb(i);

    vll dp(N+1, 0);
    dp[0] = 1;

    rep(i,N){
        int Ci = a[i];

        (dp[i+1] += dp[i]) %= MOD;

        auto it = find(ALL(loc[Ci]), i) + 1;
        if (it != loc[Ci].end()) {
            int j = *it;
            (dp[j] += dp[i]) %= MOD;
        }
    }

    return dp[N];
}

int main() {
    int N; scanf("%d", &N);
    vi a(N); rep(i,N) { scanf("%d", &a[i]); a[i]--; }
    cout << solve(N,a) << endl;
    return 0;
}


Measured memory_bytes: 14336
#include <iostream>

using namespace std;

int main()
{
	int a, b, ans;

	ans = 0;

	cin >> a >> b;

	

	if (a > b) {
		ans += a;
		a--;
	}
	else {
		ans += b;
		b--;
	}

	if (a > b) {
		ans += a;
		a--;
	}
	else {
		ans += b;
		b--;
	}

	cout << ans;
	
	return 0;

	

	

}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

class Program {

    static void Main (string[] args) {
        var Stemp = Console.ReadLine ().Split (' ');
        int A = int.Parse (Stemp[0]);
        int B = int.Parse (Stemp[1]);
        Console.WriteLine (A * B);
    }

    //1000000007
}
//dotnet run --project test

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

int main() {
  int n;
  cin >> n;
  vector<ll> s(n);
  
  rep(i, n){
    cin >> s.at(i);
  }
  
  ll max = s.at(0);
  ll ans = 0;
  for(int i = 1; i < n; i++){
    if(s.at(i) < max){
      ans += max - s.at(i);
    }
    else{
      max = s.at(i);
    }
  }
  cout << ans << endl;
  
}
 
 //vector<int> a(3);
 //a.at(0);
 //a.size();
 //vector<vector<int>> a(3, vector<int>(3));
 //uint64_t sum = 0;
 //max(a, b);
 //min(a, b);
 //swap(a, b);
 //sort(vec.begin(), vec.end());  昇順
 //reverse(vec.begin(), vec.end());  降順


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

int main(){

    int a, b, c, num = 0;

    cin >> a >> b >> c;

    for(int i=a; i<=b; i++){
        if(c%i==0){
            num += 1;
        }
    }

    cout << num << "\n";

    return 0;  
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <math.h>
#include <string.h>
#define pai 3.1415926535

int main(void) {
	int N, A;
	scanf("%d%d", &N, &A);
	if (N % 500 <= A) {
		printf("Yes");
	}
	else {
		printf("No");
	}



	return 0;
}
	

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    vint l(n); rep(i,n){ cin>>l[i];}

    ll ans = 0;
    rep(i,n){
        repf(j,i+1,n){
            repf(k,j+1,n){
                vint v;
                v.push_back(l[i]); v.push_back(l[j]); v.push_back(l[k]);
                set<ll> s;
                for(auto e:v) s.insert(e);
                if(s.size() != 3) continue;
                sort(ALL(v));
                if(v[0] + v[1] > v[2]) ans++;
            }
        }
    }
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
long long A;
int B,C;
int main()
{
	scanf("%lld%d%*c%d",&A,&B,&C);
	//printf("%lld %d %d\n",A,B,C);
	A=A*(B*100+C);
	A/=100;
	printf("%lld\n",A);
	return 0;
}


Measured memory_bytes: 3784
# -*- coding: utf-8 -*-
# import time
import sys
from collections import Counter, defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))

gpw = None


class RH():
    def __init__(self, s, base, mod):
        self.base = base
        self.mod = mod

        l = len(s)
        self.h = h = [0]*(l+1)
        tmp = 0
        for i in range(l):
            tmp = (tmp*base + s[i]) % mod
            h[i+1] = tmp

        global gpw
        if gpw is None:
            self.pw = pw = [1]*(len(s)+1)
            v = 1
            for i in range(l):
                pw[i+1] = v = v * base % mod
            gpw = pw
        else:
            self.pw = gpw

    def calc(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod


def slv(N, A, B):
    L = max(max(A), max(B)).bit_length()
    ah = []
    bh = []
    bnh = []
    for i in range(L):
        ta = []
        tb = []
        tbn = []
        for a, b in zip(A, B):
            ta.append(a >> i & 1)
            tb.append(b >> i & 1)
            tbn.append(tb[-1] ^ 1)
        ah.append(RH(ta, 641, 10**9+7))
        bh.append(RH(tb, 641, 10**9+7))
        bnh.append(RH(tbn, 641, 10**9+7))

    ans = []
    x = [0] * N
    for i in range(L):
        for k in range(N):
            l = ah[i].calc(k, N)
            r = ah[i].calc(0, k)
            if x[k] is None:
                continue
            if l == bnh[i].calc(0, N-k) and r == bnh[i].calc(N-k, N):
                x[k] += 1 << i
            elif l == bh[i].calc(0, N-k) and r == bh[i].calc(N-k, N):
                pass
            else:
                x[k] = None
    for k, xx in enumerate(x):
        if xx is not None:
            ans.append('%d %d' % (k, xx))

    return ans


def main():
    N = read_int()
    A = read_int_n()
    B = read_int_n()
    print(*slv(N, A, B), sep='\n')

if __name__ == '__main__':
    main()


Measured memory_bytes: 277700
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
	int n, in[3];
	string res;
	cin >> n;
	for (int i = 0; i < n; ++i){
		res = "NO";
		for (int j = 0; j < 3; ++j)	cin >> in[j];
		for (int j = 0; j < 3; ++j){
			if (pow(in[j%3], 2) == pow(in[(j+1)%3], 2) + pow(in[(j+2)%3], 2)){
				res = "YES";
			}
		}
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
// https://atcoder.jp/contests/abc091/tasks/abc091_b
"use strict";
function Main(input) {
  const params = input.trim().split("\n");
  const N = Number(params[0].trim());
  const M = Number(params[N + 1].trim());
  const blueCards = params.slice(1, N + 1);
  const redCards = params.slice(N + 2);

  let cardCount = {};
  for (const card of blueCards) {
    const c = card.trim();
    if (cardCount.hasOwnProperty(c)) {
      cardCount[c] = cardCount[c] + 1;
    } else {
      cardCount[c] = 1;
    }
  }

  for (const card of redCards) {
    const c = card.trim();
    if (cardCount.hasOwnProperty(c)) {
      cardCount[c] = cardCount[c] - 1;
    } else {
      cardCount[c] = 1;
    }
  }

  let maxMoney = 0;
  for (const [key, money] of Object.entries(cardCount)) {
    if (maxMoney < money) {
      maxMoney = money;
    }
  }

  console.log(maxMoney);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
    int n,a,b,c;
    cin>>n;
  	a=n/100;
  	b=(n/10)%10;
  	c=n%10;
    int ans=0;
    if(a) ans++;
    if(b) ans++;
    if(c) ans++;
    cout<<ans<<endl;
    }


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), a[] = new int[n];
        List<Integer> ans = new ArrayList<>();
        for (int j = 0; j < n; j++)
            a[j] = scanner.nextInt();
        for (int j = n - 1; j >= 0; j -= 2)
            ans.add(a[j]);
        for (int j = n & 1; j < n; j += 2)
            ans.add(a[j]);
        System.out.println(ans.stream().map(String::valueOf).collect(Collectors.joining(" ")));
    }
}

Measured memory_bytes: 94544
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        System.out.println(c >= a && c <= b ? "Yes" : "No");
    }
}

Measured memory_bytes: 21712
import math
from functools import reduce

def lcm_base(x, y):
  return (x * y) // math.gcd(x, y)

def lcm(list):
  return reduce(lcm_base, list, 1)

n = int(input())
a = list(map(int, input().split()))
l = lcm(a) - 1
ans = 0
for i in range(n):
  ans += l % a[i]
print(ans)

Measured memory_bytes: 9588
#include<stdio.h>
#include<string.h>
int main ()
{
	int aa,bb,cc;
	char a[10],b[10],c[10];
	scanf("%s",a);
	scanf("%s",b);
	scanf("%s",c);
	aa=strlen(a);
	bb=strlen(b);
	cc=strlen(c);
	if(a[aa-1]==b[0]&&b[bb-1]==c[0])
	printf("YES");
	else
	printf("NO");
	return 0;
	
 } 

Measured memory_bytes: 128
using System;

namespace CSharpTest
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var mainclass = new MainClass();
            mainclass.calc();
        }

        private void calc()
        {

            Int64 inp = int.Parse(Console.ReadLine());
            Console.WriteLine(3 * Math.Pow(inp, 2));
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;


int digitSum(int num) {
	int res = 0;
	string a = to_string(num);
	for (int i = 0; i < a.length(); i++) {
		res += int(a[i] - '0');
	}
	return res;
}

int main() {
	int n, ans = INT32_MAX;
	cin >> n;
	for (int i = 1; i <= n/2; i++) {
		ans = min(ans, digitSum(n - i) + digitSum(i));
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
s = []
for i in range(N):
    s.append(str(input()))
M = int(input())
t = []
for i in range(M):
    t.append(str(input()))

s = sorted(s)
t = sorted(t)
c_list = []
for i in range(len(s)):
    c = 0
    for j in range(len(s)):
        if s[i] == s[j]:
            c += 1
    for j in range(len(t)):
        if s[i] == t[j]:
            c -= 1
    c_list.append(c)

for i in range(len(t)):
    c = 0
    for j in range(len(s)):
        if t[i] == s[j]:
            c += 1
    for j in range(len(t)):
        if t[i] == t[j]:
            c -= 1
    c_list.append(c)

if max(c_list) >= 0:
    print(max(c_list))
else:
    print(0)

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

int main(){
    int x;
    cin>>x;
    int lcm,div=x,divi=360,tmp;
    while(div!=0){
        tmp=divi;
        divi=div;
        div=tmp%div;
    }
    lcm = 360*x/divi;
    cout<<lcm/x;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
#define ll long long int


int main()
{
	ll X,upper = 119;
	cin>>X;
	for(ll a = 0; a <=upper ; a++)
	{
		for(ll b = 0; b <=a ; b++)
		{
			{
				if(((pow(a,5))-(pow(b,5)))==X)
				{
					cout<<a<<" "<<b<<endl;
					return 0;
				}
				if(pow(a,5)+pow(b,5) == X)
				{
					cout<<a<<' '<<(-1*b)<<endl;
					return 0;
				}
			}
		}
		
	}
}

Measured memory_bytes: 3560
def check(p):
    i = 0
    for _ in range(k):
        s = 0
        while s+n_list[i] <= p:
            s += n_list[i]
            i += 1
            if i == n:
                return n
    return i

def solve():
    left   = 0
    right  = 10**5 * 10**4
    middle = 0
    while(right-left > 1):
        middle = (left+right)//2
        v = check(middle)
        if(v >= len(n_list)):
            right = middle
        else:
            left = middle
    return right

n,k = map(int,input().split())
n_list = [int(input()) for _ in range(n)]
ans = solve()
print(ans)


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N,K,a; cin >> N >> K;
  map<ll,ll> m;
  for (ll i = 0; i < N; ++i) {
    cin >> a;
    m[a] += 1;
  }
  if (m.size() <= K) cout << 0 << endl;
  else {
    vector<ll> v(m.size());
    ll pos = 0;
    for (auto itr = m.begin(); itr != m.end(); ++itr) {
      v[pos] = itr->second;
      pos++;
    }
    sort(v.begin(),v.end());
    ll ans = accumulate(v.begin(),v.begin()+m.size()-K,0);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 14336
s, t = [], []
d = {}

N = int(input())
for i in range(N):
    s.append(input())

M = int(input())
for i in range(M):
    t.append(input())

for i in s:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
for i in t:
    if i in d:
        d[i] -= 1
    else:
        d[i] = -1

print(str(max(max(d.values()), 0)))

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int D, T, S;
    cin >> D >> T >> S;
    if (S*T >= D) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3652
import itertools 

N,M,R = map(int,input().split())
r = list(map(int,input().split()))

class WarshallFloyd:
    def __init__(self,n):
        self.v = n
        self.d = [[1e100]*n for _ in range(n)]
        for i in range(n):
            self.d[i][i] = 0

    def path(self,x,y,c):
        if x == y:
            return False
        self.d[x][y] = c
        self.d[y][x] = c
        return True

    def build(self):
        for k in range(self.v):
            for i in range(self.v):
                for j in range(self.v):
                    self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])
        return self.d
wf = WarshallFloyd(N)

for i in range(M):
    a,b,c = map(int,input().split())
    wf.path(a-1,b-1,c)

d = wf.build()
ans = 1e100
for T in itertools.permutations(r):
    Td = 0
    for i in range(len(T) - 1):
        Td += d[T[i]-1][T[i+1] - 1]
    ans = min(ans , Td)
print(ans)


Measured memory_bytes: 59992
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        long N = sc.nextLong();
        StringBuilder ans = new StringBuilder();
       while(N > 0){
        long kari =  N % 26l;
          if(kari == 0) kari = 26;
          char alp = (char) (96 + kari);
          ans.append(alp);
         N -= 1;
         N /= 26l;
       }
      ans.reverse();
      System.out.println(ans.toString());
    } 
}

Measured memory_bytes: 27036
#include<iostream>
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(c - a) <= d) {
        cout << "Yes" << endl;
    } else if (abs(b - a) <= d && abs(c - b) <= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
L = [0 for _ in range(n)]
L[0] = a[0]
for i in range(1, n):
  L[i] = L[i-1] + a[i]
delay = 0
all_over = 0
anti_delay = 0
anti_all_over = 0
if a[0] != 0:
  antiL = L[:]
  sign = (a[0] > 0) - (a[0] < 0)
  for i in range(1, n):
    L[i] += delay
    if L[i] <= 0 and sign == -1:
      delay += 1 - L[i]
      all_over += 1 - L[i]
      L[i] = 1
    elif L[i] >= 0 and sign == 1:
      delay -= L[i] + 1
      all_over += L[i] + 1
      L[i] = -1
    sign *= -1
  if antiL[0] < 0:
    sign = 1
    anti_delay = 1 - antiL[0]
    anti_all_over = 1 - antiL[0]
  else:
    sign = -1
    anti_delay = -(antiL[0] + 1)
    anti_all_over = antiL[0] + 1
  for i in range(1, n):
    antiL[i] += anti_delay
    if antiL[i] <= 0 and sign == -1:
      anti_delay += 1 - antiL[i]
      anti_all_over += 1 - antiL[i]
      antiL[i] = 1
    elif antiL[i] >= 0 and sign == 1:
      anti_delay -= antiL[i] + 1
      anti_all_over += antiL[i] + 1
      antiL[i] = -1
    sign *= -1
  print(min(anti_all_over, all_over))
else:
  posL = L[:]
  negL = L[:]
  pos_delay, neg_delay = 1, -1
  pos_all_over, neg_all_over = 1, 1
  sign = 1
  for i in range(1, n):
    posL[i] += pos_delay
    if posL[i] <= 0 and sign == -1:
      pos_delay += 1 - posL[i]
      pos_all_over += 1 - posL[i]
      posL[i] = 1
    elif posL[i] >= 0 and sign == 1:
      pos_delay -= posL[i] + 1
      pos_all_over += posL[i] + 1
      posL[i] = -1
    sign *= -1
  sign = -1
  for i in range(1, n):
    negL[i] += neg_delay
    if negL[i] <= 0 and sign == -1:
      neg_delay += 1 - negL[i]
      neg_all_over += 1 - negL[i]
      negL[i] = 1
    elif negL[i] >= 0 and sign == 1:
      neg_delay -= negL[i] + 1
      neg_all_over += negL[i] + 1
      negL[i] = -1
    sign *= -1
  print(min(pos_all_over, neg_all_over))


Measured memory_bytes: 21836
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S >> T;
  int ans=0;
  for (int i=0;i<3;i++){
    if (S[i]==T[i]){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<string>
#include<cmath>
using namespace std;
int a[100000];

int main(){
	int N,j,num;
	num=0;
	cin >> N;
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<N;i++){
		j = a[i];
		if(a[j-1]==i+1)
			num = num+1;	
	}
	cout << num/2 << endl;
	return 0;
};

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

#define ll long long
#define endl "\n"

int n, k;
vector <int> digits;

bool check(int number){
	string num = to_string(number);
	
	for (char c:num){
		for (int dig:digits){
			if (c - '0' == dig) return false;
		}
	}
	
	return true;
}

int main ()
{

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #define int ll
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);

	int n, k;
	cin >> n >> k;
	
	for (int i=0; i<k; i++){
		int a;
		cin >> a;
		digits.emplace_back(a);
	}	
	
	int ans;
	for (int i=n; true; i++){
		if (check(i)){
			cout << ((n+i-1)/i)*i << endl;
			return 0; 
		}
	}
	    	
    return 0;

}

Measured memory_bytes: 3756
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::min;

#[fastout]
fn main() {
    input! {
    n: usize,
    mut a: [i64; n]
    }
    a.insert(0, 0);
    a.push(0);
    let s = (0..=n).map(|i| (a[i + 1] - a[i]).abs()).sum::<i64>();
    for i in 1..=n {
        let ans = s - (a[i] - a[i - 1]).abs() - (a[i + 1] - a[i]).abs() + (a[i + 1] - a[i - 1]).abs();
        println!("{}", ans);
    }
}


Measured memory_bytes: 3440
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
   
  while(x->l != NIL){
    x = x->l;
  }
  return x;
}
 
Node treeSearch(Node u, int k){
   
  if(u == NIL || k == u->key) return u;
  if(k < u->key) return treeSearch(u->l,k);
  else  return treeSearch(u->r,k);
   
}
 
Node treeSuccessor(Node x){
  Node y = NIL;
   
  if(x->r != NIL) return treeMinimum(x->r);
  y = x->p;
   
  while(y != NIL && x == y->r){
    x =y;
    y = y->p;
  }
  return y;
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
  if(z->l == NIL || z->r == NIL) y = z;
  else y = treeSuccessor(z);
   
  if(y->l != NIL) x = y->l;
  else x = y->r;
   
  if(x != NIL) x->p = y->p;
  if(y->p == NIL) root = x;
  else if(y == y->p->l) y->p->l = x;
  else y->p->r = x;
   
  if(y != z) z->key = y->key;
   
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
   
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
   
  while(x != NIL){
    y = x;
     
    if(k < x->key) x = x->l;
    else x = x->r;
  }
  z->p = y;
   
  if(y == NIL) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z;
}
 
void inorder(Node u){
   
  if(u ->l != NIL) {
    inorder(u->l);
    printf(" %d",u->key);
  }
   
  else printf(" %d",u->key);
   
  if(u->r != NIL) inorder(u->r);
}
 
void preorder(Node u){
  printf(" %d",u->key);
   
  if(u->l != NIL) preorder(u->l);
  if(u->r != NIL) preorder(u->r);
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
   
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll ans = 0;
    int n ;
    cin >> n;
    
    for(int i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0){
            ans += (ll)i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int N;
int x, y, z;

int min(int a, int b) {
    if(a <= b) {
        return a;
    } else {
        return b;
    }
}

int max(int a, int b) {
    if(a >= b) {
        return a;
    } else {
        return b;
    }
}

int main() {
    scanf("%d", &N);

    int i = 0, a = 0, b = 0, c = 0;
    for(i = 0; i < N; ++i) {
        scanf("%d %d %d", &x, &y, &z);
        a = min(x, min(y, z));
        c = max(x, max(y, z));
        b = (x + y + z) - (a + c);

        if(a*a + b*b == c*c) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
}


Measured memory_bytes: 2028
# うしろから確定していく（前のやつはうしろのやつをいじれない）のでうしろからみていく。
N = int(input())
a, b = [], []
for _ in range(N):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
a = a[::-1]
b = b[::-1]
cur = 0

for i in range(N):
    if (a[i] + cur) % b[i] == 0:
        continue
    tmp = b[i] * ((a[i] + cur) // b[i] + 1) - (a[i] + cur)
    cur += tmp

print(cur)


Measured memory_bytes: 11868
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;


int main() {
	ll N;
	vector<ll> a(200000 + 100);
	cin >> N;
	for (ll i = 0; i < N; ++i) {
		cin >> a[i];
	}
	ll crr = 1; // 今の数字
	ll cnt = 0; // 割った数
	bool valid = false;
	for (ll i = 0; i < N; ++i) {
		if (a[i] != crr) {
			cnt++;
		}
		else {
			crr++;
			valid = true;
		}
	}
	if (valid) {
		cout << cnt << endl;
	}
	else {
		cout << -1 << endl;
	}

}


Measured memory_bytes: 1792
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    IFOR(i, l, r){
        if(i % d == 0)
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  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 <stdio.h>
#include <stdlib.h>



int main()
{

 char S[3];

 scanf("%s",S);

 for (int i = 0;i<3;i++)
 {
  if (S[i]=='9')S[i]='1';
  else if(S[i]=='1')S[i]='9';
 }

 printf("%s",S);


 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define maxn 200010
using namespace std;
int f[maxn],g[maxn],ans[maxn],a[20],b[20],n,x,y,k,i,j,t,s1=0,s2=0,cnt;
void work(int f[],int a[],int s)
{
	int i,j,k,t=0,num=0,x;
	f[++t]=0;
	f[++t]=a[1];
	for (i=2;i<=s;i+=2)
	{
		k=t;
		for (j=k;j;j--)
			f[++t]=f[j]^a[i+1];
		for (j=1;j<k;j++)
			f[++t]=f[j]^a[i]^a[i+1];
		x=f[t]^a[i+1];
		if (i==2)
		{
			for (j=1;j<=(1<<(i-2));j++)
				f[++t]=x^f[j];
			for (j=(1<<(i-2));j;j--)
				f[++t]=x^a[i-i/4-1]^f[j];
		}
		else
		{
			for (j=1;j<=(1<<(i-3));j++)
				f[++t]=x^f[j];
			for (j=(1<<(i-3));j;j--)
				f[++t]=x^f[j]^a[i-2];
			for (j=1;j<=(1<<(i-3));j++)
				f[++t]=x^f[j]^a[i-2]^a[i-1];
			for (j=(1<<(i-3));j;j--)
				f[++t]=x^f[j]^a[i-1];
		}
		f[++t]=f[k]^a[i]^a[i+1];
	}
}
int main()
{
	scanf("%d%d%d",&n,&x,&y);
	k=x^y;
	for (i=k;i;i-=i&-i)
		a[++s1]=i&-i;
	t=1;
	for (j=0;j<n;j++)
		if ((1<<j)!=a[t]) b[++s2]=(1<<j);
			else t++;
	if (!(s1&1)) printf("NO");
		else
		{
			printf("YES\n");
			work(f,a,s1);
			if (s2)
			{
				if (s2&1) work(g,b,s2);
					else
					{
						work(g,b,s2-1);
						t=1<<(s2-1);
						for (i=t;i;i--)
							g[++t]=g[i]^b[s2];
					}
			}
			t=0;
			for (i=1;i<=(1<<s1);i++)
			{
				if (i&1)
				{
					for (j=1;j<=(1<<s2);j++)
						ans[++t]=f[i]^g[j];
				}
				else
				{
					for (j=(1<<s2);j;j--)
						ans[++t]=f[i]^g[j];
				}
			}
			for (i=1;i<=(1<<n);i++)
				ans[i]^=x;
			for (i=1;i<=(1<<n);i++)
				printf("%d ",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

struct SegmentTree{
    private:
        int n;
        vector<ll> node; //セグ木の持つデータの型を入力
        ll e = 0; //単位元
    public:
        ll F(ll a,ll b){
            return max(a,b);//二項演算
        }

        void init(vector<ll> v) {
            int sz = v.size();
            n = 1; while(n < sz) n *= 2;
            node.resize(2*n-1, e);

            rep(i,sz) node[i+n-1] = v[i];
            per(i,n-1) node[i] = F(node[2*i+1], node[2*i+2]);

            //rep(i,2*n-1) cout << node[i] << endl;
        }

        void update(int x,ll val){
            x += n-1;
            node[x] = val;
            while(x > 0) {
                x =(x-1)/2;
                node[x]=F(node[2*x+1],node[2*x+2]);
            }
        
        }

        ll get(int a, int b, int k=0, int l=0, int r=-1) {
            if(r < 0) r = n;
            if(r <= a || b <= l) return e;
            if(a <= l && r <= b) return node[k];

            ll vl = get(a, b, 2*k+1, l, (l+r)/2);
            ll vr = get(a, b, 2*k+2, (l+r)/2, r);
            return F(vl, vr);
        }
};

int n;
vector<ll> a;
vector<P> f;

void solve(){
    cin >> n;
    a.resize(n,0);
    f.resize(n,P(0,0));
    rep(i,n) {
        cin >> f[i].first;
        f[i].first-=1;
    }
    rep(i,n) cin >> f[i].second;
    SegmentTree s;s.init(a);
    rep(i,n){
        s.update(f[i].first,s.get(0,f[i].first)+f[i].second);
    }
    cout << s.get(0,n) << endl;

}

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

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main(){
    int nsovled =0;
    int n,m,c;cin>>n>>m>>c;
    vector<int >b(m,0);
    for(int i=0;i<m;i++)cin>>b[i];
    for(int i=0;i<n;i++){
        int final=0;
        for(int j=0,a;j<m;j++){cin>>a;
            final+=a*b[j];
        }
        if((final+c)>0)nsovled+=1;
    }
    cout<<nsovled;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class   Main       {
	public static void main(String[] args) 
	{
		InputReader in = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
		int A = in.nextInt();
		int B = in.nextInt();
		if(A%3==0||B%3==0||(A+B)%3==0)
			w.println("Possible");
		else
			w.println("Impossible");
		
		//w.println(n);
		w.close();
	}
	static class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		public InputReader(InputStream st) {
			this.stream = st;
		}
		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
		
		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
		
		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}
		
		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}
		
		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
		
		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
		
	}
	
}

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

int main() {
  int n, k, r, s, p, score = 0;
  string t, te = "";
  cin >> n >> k >> r >> s >> p >> t;
  for(int i = 0; i < n; ++i){
    if(t.at(i) == 'r') te += 'p';
    else if(t.at(i) == 's') te += 'r';
    else if(t.at(i) == 'p') te += 's';
  }
  for(int i = 0; i < n; ++i){
    if(i < k){
      if(te.at(i) == 'r') score += r;
      else if(te.at(i) == 's') score += s;
      else if(te.at(i) == 'p') score += p;
    }
    else{
      if(te.at(i) == te.at(i - k)) te.at(i) = '.';
      else{
        if(te.at(i) == 'r') score += r;
      	else if(te.at(i) == 's') score += s;
      	else if(te.at(i) == 'p') score += p;
      }
    }
  }
  cout << score << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可

const ll INF=1e18;

//const ll MAX = 200010;//自分で大きさを調節
// const ll MOD = 1000000007;

//long long fac[MAX], finv[MAX], inv[MAX];

// // テーブルを作る前処理
// void COMinit() {
//     fac[0] = fac[1] = 1;
//     finv[0] = finv[1] = 1;
//     inv[1] = 1;
//     for (int i = 2; i < MAX; i++){
//         fac[i] = fac[i - 1] * i % MOD;
//         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
//         finv[i] = finv[i - 1] * inv[i] % MOD;
//     }
// }

// // 二項係数計算
// long long COM(ll n,ll k){
//     if (n < k) return 0;
//     if (n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }

ll mod_pow(ll x,ll n,ll m){
    if(n==0) return 1;
    ll res=mod_pow(x*x%m,n/2,m);
    if(n&1) res=res*x%m;
    return res;
}

// ll mod_fact(ll n,ll p,ll &e){
//     e=0;
//     if(n==0) return 1;
//     ll res=mod_fact(n/p,p,e);
//     e+=n/p;
//     if(n/p%2!=0) return res*(p-fac[n%p])%p;
//     return res*fac[n%p]%p;
// }

ll c(ll n,ll k){
    if(k==0||n==k||n==0) return 1;
    if(k==1) return n;
    return (c(n-1,k-1)+c(n-1,k))%mod;
}

signed main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=0;
    ll cnt=1;
    ll bb=1;
    for(ll i=0;i<=a-1;i++) cnt=cnt*(n-i)%mod;
    for(ll i=2;i<=a;i++) cnt=cnt*mod_pow(i,mod-2,mod)%mod;
    for(ll i=0;i<=b-1;i++) bb=bb*(n-i)%mod;
    for(ll i=2;i<=b;i++) bb=bb*mod_pow(i,mod-2,mod)%mod;
    ans=(mod_pow(2,n,mod)-1-cnt-bb)%mod;
    if(ans<0){
        while(ans<0) ans+=mod;
    }
    cout<<ans<<endl;
}

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

typedef long l;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int DX[] = {1, 0, -1, 0, 1, 1, -1, -1}, DY[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

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

  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  int res = 0;
  res += min(a, k);
  k -= a;

  if (k <= 0) {
    cout << res << endl;
    return(0);
  }

  k -= b;

  if (k <= 0) {
    cout << res << endl;
    return(0);
  }

  res -= min(c, k);
  k -= c;

  if (k <= 0) {
    cout << res << endl;
    return(0);
  }

}



Measured memory_bytes: 3604
import itertools
N, a, b, c = [int(_) for _ in input().split()]
L = [int(input()) for _ in range(N)]
ans = 10**10
for K in itertools.product(range(4), repeat=N):
    A = [[] for _ in range(4)]
    for i in range(N):
        A[K[i]] += [L[i]]
    if len(A[1]) and len(A[2]) and len(A[3]):
        cost = 10 * (N - len(A[0]) - 3)
        cost += abs(a - sum(A[1]))
        cost += abs(b - sum(A[2]))
        cost += abs(c - sum(A[3]))
        ans = min(cost, ans)
print(ans)


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

int main()
{
	int a, b;

	cin >> a >> b;
	if (a < b)
	{
		cout << "a < b" << endl;
	}
	if (a == b)
	{
		cout << "a == b" << endl;
	}
	if (a > b)
	{
		cout << "a > b" << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    string s;
    cin>>s;
    sort(s.begin(), s.end());
    if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;
    vi h(N+1, 0); REP(i, N) cin >> h[i];

    stack<int> l;
    vector<pii> lr;
    REP(i,N+1) {
        if (l.size() < h[i]) {
            while (l.size() < h[i]) l.push(i);
            
        } else if (l.size() > h[i]) {
            while(l.size() > h[i]) {
                lr.push_back(pii(l.top(), i));
                l.pop();
            }
        } else {
            // NOP
        }
    }

    int ans = lr.size();
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384