akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>

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

using namespace std;

int n,m,card[100000];

int solve(const int A[500][500],int win){ // win : ツ堕オツつヲツづゥツづ猟つォツ療アツづ個古つ青?
	static int X[1000001],Y[1000001];
	rep(i,1000001) X[i]=-1;
	rep(i,n) rep(j,n) X[A[i][j]]=j, Y[A[i][j]]=i;

	int tate[500]={},yoko[500]={},naname1=0,naname2=0;
	rep(i,m){
		if(X[card[i]]==-1) continue;

		int x=X[card[i]],y=Y[card[i]];
		if(++tate[x]==n) win--;
		if(++yoko[y]==n) win--;
		if(x-y== 0  && ++naname1==n) win--;
		if(x+y==n-1 && ++naname2==n) win--;

		if(n==1) win+=3;

		if(win<=0) return i;
	}
	return m;
}

int main(){
	int usagi,neko; scanf("%d%d%d%d",&n,&usagi,&neko,&m);
	static int U[500][500],N[500][500];
	rep(i,n) rep(j,n) scanf("%d",U[i]+j);
	rep(i,n) rep(j,n) scanf("%d",N[i]+j);
	rep(i,m) scanf("%d",card+i);

	int ans_u=solve(U,usagi);
	int ans_n=solve(N,neko);
	if     (ans_u<ans_n) puts("USAGI");
	else if(ans_u>ans_n) puts("NEKO");
	else                 puts("DRAW");

	return 0;
}

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 100 + 9;

int n;
double a[maxN];

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

	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}

	double den = 0;

	for(int i = 1; i <= n; i++){
		den += (1.00 / a[i]);
	}

	double ans = 1.00 / den;
	
	cout << setprecision(10) << fixed << ans << '\n';

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
struct node {
	int a, b;
}le[5000000];
bool cmp(node a, node b) {
	return a.b < b.b;
}
int main()
{
	int n, i;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> le[i].a >> le[i].b;
	}
	sort(le, le + n, cmp);
	int t = 0;
	for (i = 0; i < n; i++) {
		t += le[i].a;
		if (t > le[i].b) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> a(n+1,0);
    int answer;
    for(int i=0; i<q; i++){
        cin >> answer;
        a[answer]++;
    }
    for(int i=1; i<=n; i++){
        if(a[i]>q-k)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int ruijou(int);

main(){
  int n;
  while(cin >> n){
    for(int i=0;i<n;i++){
      string in;
      cin >> in;
      int data[8];
      for(int j=0;j<8;j++){
	data[j]=in[j]-'0';
      }
      sort(data, data+8);
      int min=0;
      for(int j=7, k=0;j>=0;j--, k++){
	if(data[j]==0) continue;
	min+=ruijou(k)*data[j];
      }
      reverse(data, data+8);
      if(data[0]==0){
	cout << 0 << endl;
	continue;
      }
      int max=0;
      for(int j=7, k=0;j>=0;j--, k++){
	if(data[j]==0) continue;
	max+=ruijou(k)*data[j];
      }
      cout << max-min << endl;
    }
  }
  return 0;
}

int ruijou(int n){
  int ans=1;
  for(int i=0;i<n;i++){
    ans*=10;
  }
  return ans;
}

Measured memory_bytes: 0
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0,nn=(intl)(n);i<nn;++i)
#define Rep1(i,n) for(intl i=1,nn=(intl)(n)+1;i<nn;++i)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(intl ii=0,nn=(intl)(a.size());ii<nn;ii++){cin>>(a).at(ii);}
#define Input2(a,b) for(intl ii=0,nn=(intl)(a.size());ii<nn;ii++){cin>>(a).at(ii);cin>>(b).at(ii);}
#define mp make_pair
#define mt make_tuple
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
using si = set<intl>;
using vsi = vec<si>;
using mii = map<intl,intl>;
using vmii = vec<mii>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;



int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  intl N;
  cin >>N;
  vi nums(N+1,0);
  vi A(N+1);
  Rep1(i,N){
    cin >>A[i];
    nums[A[i]] ++;
  }
  
  intl all =0;
  Rep1(i,N){
    all += nums[i]*(nums[i]-1)/2;
  }
  Rep1(i,N){
    cout << all - ( (nums[A[i]])?nums[A[i]]-1:0)<<'\n';
  }
}
  

Measured memory_bytes: 6328
n=int(input())
a=list(map(int,input().split()))
a1=[a[i] for i in range(0,len(a),2)]
a2=[a[i] for i in range(1,len(a),2)]

import collections
c1=collections.Counter(a1)
c2=collections.Counter(a2)

c1=sorted(c1.items(),key=lambda x:x[1],reverse=True)
c2=sorted(c2.items(),key=lambda x:x[1],reverse=True)
ans=0
if c1[0][0]==c2[0][0]:
  if len(c1)==1:
    ans+=(n//2)
  elif c1[1][1]<=c2[1][1]:
    ans+=(n//2)-c1[0][1]
    ans+=(n//2)-c2[1][1]
  else:
    ans+=(n//2)-c1[1][1]
    ans+=(n//2)-c2[0][1]
else:
  ans=0
  ans+=(n//2)-c1[0][1]
  ans+=(n//2)-c2[0][1]

print(ans)

Measured memory_bytes: 19040
xy = list(map(int, input().split()))

flag = 0

for i in range(xy[0] + 1):
  total = i * 2 + (xy[0] - i) * 4
  if total == xy[1]:
    flag = 1
    break

if flag == 0:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 9124
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;

int vx[8] = {0, 0, 1, 1, -1, -1, 1, -1};
int vy[8] = {1, -1, 1, -1, 1, -1, 0, 0};
int h, w;

bool isIn(int x, int y){
    return (x < h && y < w && x >= 0 && y >= 0);
}

signed main()
{
    tezz
    
    cin>>h>>w;
    string mat[h];

    for(int i=0;i<h;i++) cin>>mat[i];

    char dp[h][w];
    memset(dp, 0, sizeof(dp));

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(mat[i][j] == '#')  {dp[i][j] = '#'; continue;}
            int count = 0;

            for(int k=0;k<8;k++){
                int dx = i + vx[k], dy = j + vy[k];

                if(isIn(dx, dy) && mat[dx][dy] == '#') count++;
            }
            dp[i][j] = count + '0';
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
             cout<<dp[i][j];
        } 
            cout<<endl;
    }
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int MAX=100000;

int h[MAX];
int DP[MAX];

int cost(int next, int now){
    return DP[now] + abs(h[now]-h[next]);
}

int main(){
    int N, K, min; cin >> N >> K;
    for(int i=0; i<N; i++) cin >> h[i];
    DP[0] = 0;
    for(int i=1; i<N; i++){
        min = cost(i, i-1);
        for(int j=2; j<K+1; j++){
            if(i<j) break;
            if(min > cost(i, i-j)) min = cost(i, i-j);
        }
        DP[i] = min;
    }
    cout << DP[N-1] << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var A = ReadLongs();
            var sum = 0L;
            for (int i = 1; i < N; i++)
            {
                var dif = A[i - 1] - A[i];
                if (dif > 0)
                {
                    sum += dif;
                    A[i] += dif;
                }
            }
            return sum;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 47492
using System;
using System.Collections.Generic;
using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        int[] abc = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int a = abc[0];
        int b = abc[1];
        int c = abc[2];

        int n1 = a - c;
        int n2 = b - c;

        if (Math.Sign(n1) * Math.Sign(n2) < 0)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

vi G[200];
int cnt=1;
int s[200],f[200];
void dfs(int v){
    s[v]=cnt++;
    rep(k,SZ(G[v])){
        if(s[G[v][k]]) continue;
        dfs(G[v][k]);
    }
    f[v]=cnt++;
}
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    rep(i,N){
        int a,n; cin >> a >> n;
        a--;
        rep(j,n){
            int b; cin >> b;
            b--;
            G[a].eb(b);
        }
    }
    rep(i,N){
        if(!s[i]) dfs(i);
    }
    rep(i,N){
        cout << i+1 << " " << s[i] << " " << f[i] << "\n";
    }
}


Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
string s, N = "x";
int K;
ll dp[105][4][2];

int main(void) {
    cin >> s;
    N += s;
    
    scanf("%d", &K);
    int sz = (int)N.size();
    dp[0][0][0] = 1;
    for(int i=1; i<=sz-1; i++) for(int j=0; j<=K; j++) for(int k=0; k<=1; k++) {
      int u = k ? 9 : N[i] - '0';
      if (j == K) u = 0;
      for (int l = 0; l<=u; l++){
        dp[i][j+(l!=0)][(k || l<u)] += dp[i-1][j][k];
      }
    
    } 

    printf("%lld\n", dp[sz-1][K][0]+dp[sz-1][K][1]);

    return 0;
}



Measured memory_bytes: 256
n , m = map(int,input().split())
dic = {}
for _ in range(n):
    lis = list(map(int,input().split()))
    a = lis[0]
    b = lis[1]
    if a not in dic:
        dic[a] = b
    else:
        dic[a] += b
s = sorted(dic.items())

answer = 0
for ss in s:
    if ss[1]>=m:
        answer += m*ss[0]
        print(answer)
        exit()
    else:
        answer += ss[1]*ss[0]
        m -= ss[1]
        continue

Measured memory_bytes: 23020
n = int(input())
a_list = [int(x) for x in input().split()]
s = set()
o = 0
for a in a_list:
    r = a // 400
    if r >= 8:
        o += 1
    else:
        s.add(r)
c = len(s)
print(c if c > 0 else 1, c + o)

Measured memory_bytes: 61868
void main() {
	auto N = ri;
	int[] C, S, F;
	foreach(i; 0..N-1) {
		auto ip = readAs!(int[]), c_ = ip[0], s_ = ip[1], f_ = ip[2];
		C ~= c_; S ~= s_; F ~= f_;
	}
	foreach(i; 0..N-1) {
		int t = 0;
		foreach(j; i..N-1) {
			if(t < S[j]) t = S[j];
			else if(t % F[j] != 0) t += F[j] - t % F[j];
			t += C[j];
		}
		t.writeln;
	}
	0.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

int main(){
  int n;
  cin >> n;
  vector<char> s(n+1);
  for(int i=1; i<=n; i++) cin >> s[i];
  ll r=0, b=0, g=0;
  for(int i=1; i<=n; i++){
    if(s[i] == 'R') r++;
    if(s[i] == 'B') b++;
    if(s[i] == 'G') g++;
  }
  ll ans = r*b*g;
  for(int i=1; i<=n; i++)for(int j=i+1; j<=n; j++){
    int k = 2*j-i;
    if(k <= n){
      if(s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) ans--; 
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
const int INF = 1e9;
const int MOD = 1e9+7;

vi f(10), inv(10);

void trans(string &n)
{
    REP(i, n.length())
    {
        n[i] = f[n[i]-'0'] + '0';
    }
}

void invtrnas(string &n)
{
    REP(i, n.length())
    {
        n[i] = inv[n[i]-'0'] + '0';
    }
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int N; cin >> N;
    cout << (N+1) / 2 << endl;
}

Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int M; cin >> M; ll a[M], b[M]; ll sum = 0; ll digsum = 0;
  rep(i, M){
    cin >> a[i] >> b[i];
    digsum += a[i]*b[i];
    sum += b[i];
  }
  ll ans = (sum - 1)  + ((digsum-1)/9);
  cout << ans << endl;
}
    

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;
vector<vector<int>> adj;
void dfs(int,int,int);
long long k,ans=1;
int done[100005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,a,b;
    cin>>n>>k;
    adj.resize(n+1);
    for(int i=0;i<n-1&&cin>>a>>b;i++)
        adj[a].push_back(b),
        adj[b].push_back(a);
    dfs(1,0,0);
    cout<<ans;
    return 0;
}

void dfs(int u,int last,int depth)
{
    ans*=k-min(depth,2)-done[last];
    ans%=MOD;
    for(auto v:adj[u])
    {
        if(v==last)
            continue;
        dfs(v,u,depth+1);
        done[u]++;
    }
    return;
}


Measured memory_bytes: 14852
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#include <climits>
#include <cmath>
#include <cstring>

#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int n;
	cin >> n;
	ll arr[n];
    
	for(int i=0 ; i<n ; i++)
		cin >> arr[i];
		
	ll m = *max_element(arr , arr+n);
	ll r = 0;
	ll orig = 0;
	ll morig = 0;
	for(int i=0 ; i<n ; i++)
	{
		orig = arr[i];
		if(m-arr[i] < arr[i] && arr[i] != m)
			arr[i] = m-arr[i];

 		if((arr[i] != m && r < arr[i]))
 			r = arr[i],morig=orig;
	}

	cout << m << " " << morig;
 	return 0;
}


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

int main(){
	char s[101], p[101];
	cin >> s >> p;
	char s2[201];
	for (int i = 0; i < strlen(s) ; i++){
		s2[i] = s[i];
	}
	for (int j = 0 ; j < strlen(s) + 1 ; j++){
		s2[strlen(s) + j] = s[j];
	}



	if (strstr(s2, p) == NULL) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}



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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define eb emplace_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "CPU time: " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;
/*}}}*/


void solve(){

    int n,k;
    cin >> n >> k;
    if(n==1) cout << 1 << "\n";
    else cout << ceil(log(n)/log(k)) << "\n";
    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


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

int main(){
	int m,n;
	cin >> n >> m;
	int t;
	if(m < 0){
		if(-1*m <= n-1)t=0;
		else t = m+n-1;
	}else{
		t = m;
	}
	int ans = 0;
	for(int i = m;i <= m+n-1;i++){
		ans += i;
	}
	cout << ans-t;
	return 0;
}


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

def isOk(k):
    n = N
    while n % k == 0:
        n //= k
    return n % k == 1

# 約数の全列挙
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort(reverse=True)  # ソート
    return divisors

div1 = divisors(N)
div2 = divisors(N - 1)

ans = len([0 for d in div1 if d != 1 and isOk(d)]) + len([0 for d in div2 if d != 1 and isOk(d)])
print(ans)


Measured memory_bytes: 3188
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
// using ll = long long;
// using vi = vector<int>;
// using vvi = vector<vi>;
// using vl = vector<long long>;
// using vvl = vector<vl>;
// using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }


int main () {
  int m,d,a,b,count = 0;
  cin >> m >> d;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= d; j++) {
      a = j%10;
      b = j/10;
      if(a* b == i && a >= 2 && b >= 2) {
        count++;
      }
    }
  }

  cout << count << endl;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll K,N,A[202020];

ll i, j, k, ans;
int main(){
    scanf("%lld%lld", &K,&N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    ans = A[N-1] - A[0];
    fornum(i,1,N){
        ans = min(K - A[i] + A[i - 1], ans);
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 1792
import math

N = int(input())

total=0
A=[0]*N
B=[0]*N

for i in range(N):
    A[i],B[i]=map(int,input().split())

for i in range(N-1,-1,-1):
    total+=B[i]*math.ceil((A[i]+total)/B[i])-(A[i]+total)
print(total)



Measured memory_bytes: 10868
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
s = ns()

def make(s, m):
    n = len(s)-1
    ldp = [99999999] * (n+1)
    ldp[0] = 0
    p = 0
    for i in range(1, n+1):
        if s[i] == "1":
            continue
        while p + m < i or s[p] == "1":
            p += 1
        if p >= i:
            print(-1)
            sys.exit(0)
        ldp[i] = ldp[p] + 1
    return ldp

dp = make(s, m)
rdp = make(s[::-1], m)

pre = 0
prex = 0
for i in range(n+1):
    if s[i] == "0":
        if pre < dp[i] and dp[i] + rdp[n-i] == dp[n]:
            sys.stdout.write(str(i-prex))
            sys.stdout.write(" ")
            prex = i
            pre = dp[i]


Measured memory_bytes: 44600
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

//Ford-Fulkerson(O(FE))
const int MAX_V=210;
const int INF=10010;

struct edge{int to, cap, rev; };
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].pb(edge{to, cap, sz(G[to])});
    G[to].pb(edge{from, 0, sz(G[from])-1});
}

int dfs(int v, int t, int f){
    if(v==t) return f;
    used[v]=true;
    for(edge &e : G[v]){
        if(!used[e.to]&&e.cap>0){
            int d=dfs(e.to, t, min(f, e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

//sからtへの最大流
int max_flow(int s, int t){
    int flow=0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f=dfs(s,t,INF);
        if(f==0) return flow;
        flow+=f;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H,W;
    cin>>H>>W;
    rep(i,0,H){
        rep(j,0,W){
            char a;
            cin>>a;
            if(a=='S'){
                add_edge(H+W, i, INF);
                add_edge(H+W, j+H, INF);
            }
            if(a=='T'){
                add_edge(i, H+W+1, INF);
                add_edge(j+H, H+W+1, INF);
            }
            if(a=='o'){
                add_edge(j+H, i, 1);
                add_edge(i, j+H, 1);
            }
        }
    }
    int t=max_flow(H+W, H+W+1);
    if(t>=INF) t=-1;
    cout <<t<<"\n";
}

Measured memory_bytes: 896
import java.util.*;

class Main{

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

		int N = sc.nextInt();
		int T = sc.nextInt();
		int min = 1001;
		String ans = "TLE";

		for(int i = 0; i < N; i++){
			int c = sc.nextInt();
			int t = sc.nextInt(); 

			if((c < min) && (t <= T)){
				min = c;
				ans = "" + c;
			}
		}
		System.out.println(ans);


	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	REP(i, m)cin >> x[i];
	if (n >= m) cout << "0" << endl;
	else {
		sort(x.begin(),x.end());
		vector<int> diff(m);
		REP(i, m - 1) { diff[i] = x[i + 1] - x[i]; }
		sort(diff.begin(),diff.end());
		int ans = 0;
		REP(i, m - n + 1) { ans += diff[i]; }
		cout << ans << endl;
	}
	
	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int n,i,A[100005],val;
long long sum,aux;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(i=1; i<=n; i++)
        cin>>A[i];
    sort(A+1,A+n+1);
    if(n%2==1)
    {
        val=n/2;
        for(i=1; i<val; i++)
        {
            sum=sum+2LL*A[n-i+1];
            sum=sum-2LL*A[i];
        }
        sum=sum+1LL*A[n-val+1];
        sum=sum+1LL*A[n-val];
        sum=sum-2LL*A[val];
        aux=sum;
        sum=0;
        for(i=1; i<val; i++)
        {
            sum=sum+2LL*A[n-i+1];
            sum=sum-2LL*A[i];
        }
        sum=sum+2LL*A[n-val+1];
        sum=sum-1LL*A[n-val];
        sum=sum-1LL*A[val];
        sum=max(sum,aux);
    }
    else
    {
        val=n/2;
        for(i=1; i<val; i++)
        {
            sum=sum+2LL*A[n-i+1];
            sum=sum-2LL*A[i];
        }
        sum=sum+1LL*A[n-val+1];
        sum=sum-1LL*A[val];
    }
    cout<<sum<<"\n";
    return 0;
}


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

int main(){
	int N, i, ans = 0;
	scanf("%d", &N);
	vector<int> A(N, 1000000000), B(N - 1);
	for(i = 0; i < N - 1; i++){
		scanf("%d", &B[i]);
		A[i] = min(A[i], B[i]);
		A[i + 1] = min(A[i + 1], B[i]);
	}
	for(i = 0; i < N; i++){
		ans += A[i];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void main(){
  int a, b, k;
  scanf("%d %d %d",&k,&a,&b);
  
  for(int i=a; i<b+1; i++){
    if(i%k==0){
      printf("OK");
      return;
    }
  }
  printf("NG");
}

Measured memory_bytes: 1736
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const ll MAX = 1000010;
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(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
const ll ainf = 998244353;

struct cell {
	int x, y;
	int deep;
	cell(int x, int y, int deep) : x(x), y(y), deep(deep) {}
};

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

int W, H, N;
int X1[500], X2[500], Y1[500], Y2[500];

bool fld[500 * 6][500 * 6];
int compress(int* x1, int* x2, int w) {
	vector<int> xs;
	for (int i = 0; i < N; i++)
	{
		for (int d = -1; d <= 1; d++)
		{
			int tx1 = x1[i] + d, tx2 = x2[i] + d;
			if (1 <= tx1 && tx1 <= W) xs.push_back(tx1);
			if (1 <= tx2 && tx2 <= W) xs.push_back(tx2);
		}
	}

	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());

	for (size_t i = 0; i < N; i++)
	{
		x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
		x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
	}
	return xs.size();
}
const int MAX_N = 1 << 17;

void solv() {

	int a, b, c;
	cin >> a >> b >> c;
	cout << c - min(a - b, c) << endl;

}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,x,answer=0;
    cin >> n >> x;
    vector<ll>a(n);
    REP(i,n)cin>>a[i];
    REP(i,n-1){
        if(a[i]+a[i+1]<=x)continue;

        ll ex = a[i]+a[i+1]-x;
        answer+=ex;
        a[i+1]=max((ll)0,a[i+1]-ex);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        decimal[] inpt = Reader.ReadLine().Split(' ').Select(a => decimal.Parse(a)).ToArray();
        int ans = (int)Math.Ceiling(inpt.Sum()/2);
        Console.WriteLine(ans);
    }


    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



7 4



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13396
#include <cctype>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int total = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == t[i]) {
            total++;
        }
    }
    cout << total;
}


Measured memory_bytes: 3624
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int total = 0;
        for (int i = 1; i <= K; i++) {
            for (int j = 1; j <= K; j++) {
                int a = gcd(i,j);
                for (int k = 1; k <= K; k++) {
                    total += gcd(a,k);
                }
            }
        }
        System.out.println(total);
    }
    private static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}


Measured memory_bytes: 27200
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int main() {
	std::cin.tie(0); std::cin.sync_with_stdio(false);
	int n, m; std::cin >> n >> m;
	std::vector<std::vector<int>> rooms(n), inv(n);
	for (auto i = 0; i < m; ++i) {
		int s, t; std::cin >> s >> t;
		rooms[s - 1].push_back(t - 1);
		inv[t - 1].push_back(s - 1);
	}
	std::vector<double> default_est(n, 0.0), changed_est(n); default_est[n - 1] = 0;
	for (int i = n - 2; i >= 0; --i) {
		for (const auto next : rooms[i]) {
			default_est[i] += default_est[next];
		}
		default_est[i] /= rooms[i].size();
		default_est[i] += 1;
	}
	double result = default_est[0];
	for (int remove = 0; remove < n - 1; ++remove) if (rooms[remove].size() > 1) {
		std::copy(default_est.begin(), std::next(default_est.begin(), remove), changed_est.begin());
		double sum = 0;
		double max = 0;
		for (const auto next : rooms[remove]) {
			sum += default_est[next];
			max = std::max(max, default_est[next]);
		}
		changed_est[remove] = (sum - max) / (rooms[remove].size() - 1) + 1;
		for (int current = remove; current >= 0; --current) if (changed_est[current] != default_est[current]) {
			for (const auto prev : inv[current]) {
				changed_est[prev] += (changed_est[current] - default_est[current]) / rooms[prev].size();
			}
		}
		result = std::min(result, changed_est[0]);
	}
	std::cout << std::setprecision(15) << std::fixed << result << '\n';
}

Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n;
int a[100000];

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

	cin >> n;
	rep(i, n)cin >> a[i];


	cout << (any_of(a, a + n, [](int x) { return x % 2 == 1; }) ? "first" : "second") << endl;


	return 0;
}

Measured memory_bytes: 640
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
x = int(raw_input())

def run():
 if x % 50 != 0 or a*500 + b*100 + c*50 < x:
  return 0

 #greedy
 an = 0
 bn = 0
 cn = 0
 
 xa = x
 while xa >= 500:
  xa -= 500
  an += 1
 while xa >= 100:
  xa -= 100
  bn += 1
 while xa >= 50:
  xa -= 50
  cn += 1
 if xa != 0:
  return 0 #wtf?
 
 ret = 0
 while an >= 0:
  if an <= a and bn <= b and cn <= c:
   ret += 1
  if bn > 0:
   bn -= 1
   cn += 2
  else:
   an -= 1
   bn = 5 + (cn / 2)
   cn = cn % 2
 return ret
print run()

Measured memory_bytes: 2696
#include <stdio.h>
#define MAX 150
#define NIL -1
#define N 10000

int graph[MAX][MAX];
int d[MAX];
int n;
  
int Que[N];
int head=0, tail=0;
 
void enQue(int q){
  Que[head]=q;
  head++;
}
 
int deQue(void){
  tail++;
  return Que[tail-1];
}
 
int size(void){
  return head-tail;
}
 
 
void bfs(int i){

  int j;
  
  for( j = 0; j < n; j++){
  
    if(graph[i][j]==1 && d[j]==NIL){
      d[j]=d[i]+1;
      enQue(j);
    }
  }
}
 
int main(){

  int u,k,i,j,v;
  
  scanf("%d",&n);
  
  for(i = 0; i < MAX; i++) d[i]=NIL;
  for(i = 0; i < n; i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      graph[u-1][v-1]=1;
    } 
  }
  d[0]=0;
  bfs(0);
  
  while(size() != 0){
    bfs(deQue());
  }
  
  for(i = 0; i < n; i++){
    printf("%d %d\n",i+1,d[i]);
  }
return 0;
}

Measured memory_bytes: 664
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==7 && b==5 && c==5){
		cout<<"YES"<<endl;
	}
	else if(a==5 && b==5 && c==7){
		cout<<"YES"<<endl;
	}
	else if(a==5 && b==7 && c==5){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

type sugarWater struct {
	sugar, water int
}

var (
	checked          = map[sugarWater]struct{}{}
	a, b, c, d, e, f int
	ans              sugarWater
)

func dfs(sugar, water int) {
	if sugar+water > f || 100*sugar > e*water {
		return
	}
	if _, in := checked[sugarWater{sugar, water}]; in {
		return
	}
	if sugar*ans.water >= water*ans.sugar {
		ans = sugarWater{sugar, water}
	}
	checked[sugarWater{sugar, water}] = struct{}{}

	dfs(sugar, water+100*a)
	dfs(sugar, water+100*b)
	dfs(sugar+c, water)
	dfs(sugar+d, water)
}

func main() {
	ans = sugarWater{0, math.MaxInt32}
	fmt.Scan(&a, &b, &c, &d, &e, &f)

	dfs(0, 100*a)
	dfs(0, 100*b)

	fmt.Println(ans.sugar+ans.water, ans.sugar)
}


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

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int a[m];
    long long int sum=0;
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    if(sum<=n)
    {
        cout<<n-sum<<endl;
    }else
    {
        cout<<-1<<endl;
    }

}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, a[123456], b[123456], m, c;

int main() {
	cin >> n;
	rep(i,n) cin >> a[i] >> b[i];
	repr(i,n-1) {
		m = (a[i]+c+b[i]-1) / b[i];
		c += m*b[i] - (a[i]+c);
	}
	cout << c << ln;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include"list"
using namespace std;
#define ll long long
#define inf (long long)1e10
#define IO {\
	freopen("input.txt","r",stdin);\
	freopen("output.txt","w",stdout);\
}
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define bug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}



int main(){
    string s1;
    cin>>s1;
    int l=s1.size();
    for(int i=0;i<l;i++)cout<<"x";
    cout<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    string s;
    cin >> s;
    string t = "";
    rep(i, s.size())
    {
        if(s[i] == 'B' && t ==""){
        }else if (s[i] == 'B'){
            t.erase(t.size() - 1);
        }else{
            t += s[i];
        }
    }
    cout << t << endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int A, B;
    cin >> A >> B;
    if(A <= 5) {
        printf("0\n");
    }
    else if(6 <= A && A <= 12) {
        printf("%lld\n", B / 2);
    }
    else {
        printf("%lld\n", B);
    }
    return 0;
}


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

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

    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < 14; j++) {
            if (4 * i + 7 * j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int D = N % 10;
        N /= 10;
        int C = N % 10;
        N /= 10;
        int B = N % 10;
        N /= 10;
        int A = N % 10;
        sc.close();

        if(A+B+C+D == 7){
            System.out.println(A + "+" + B + "+" + C + "+" + D + "=7");
            return;
        }
        if(A-B+C+D == 7){
            System.out.println(A + "-" + B + "+" + C + "+" + D + "=7");
            return;
        }
        if(A+B-C+D == 7){
            System.out.println(A + "+" + B + "-" + C + "+" + D + "=7");
            return;
        }
        if(A+B+C-D == 7){
            System.out.println(A + "+" + B + "+" + C + "-" + D + "=7");
            return;
        }
        if(A-B-C+D == 7){
            System.out.println(A + "-" + B + "-" + C + "+" + D + "=7");
            return;
        }
        if(A-B+C-D == 7){
            System.out.println(A + "-" + B + "+" + C + "-" + D + "=7");
            return;
        }
        if(A+B-C-D == 7){
            System.out.println(A + "+" + B + "-" + C + "-" + D + "=7");
            return;
        }
        if(A-B-C-D == 7){
            System.out.println(A + "-" + B + "-" + C + "-" + D + "=7");
            return;
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

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

int main(){
    int K;
    cin >> K;
    long long ans = 0;
    for(int i=1; i<=K; i++){
    for(int j=1; j<=K; j++){
    for(int k=1; k<=K; k++){
        long long g = gcd(gcd(i, j), k);
        ans += g;
    }
    }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
N,X = [int(x) for x in input().split()]
a,p = [1],[1]
for i in range(N):
  a.append(2*a[i]+3)
  p.append(2*p[i]+1)
def f(N,X):
  if N==0:
    return 0 if X<=0 else 1
  elif X<=1+a[N-1]:
    return f(N-1,X-1)
  else:
    return p[N-1]+1+f(N-1,X-2-a[N-1])
    
print(f(N,X))

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

using namespace std;
using ll = long long;

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

const int mod = 1e9 + 7;

ll modpow(ll k, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * k % mod;
    k = k * k % mod;
    n /= 2;
  }
  return res;
}

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

  vector<ll> f(2005), fi(2005);
  f[0] = 1;
  rep(i, 2004) f[i + 1] = (i + 1) * f[i] % mod;
  rep(i, 2005) fi[i] = modpow(f[i], mod - 2);

  auto choose = [&](int a, int b) {
    if (a < b) return 0LL;
    return (f[a] * fi[b] % mod) * fi[a - b] % mod;
  };

  for (int i = 1; i <= k; ++i) {
    ll now = choose(n - k + 1, i);
    now = now * choose(k - 1, i - 1) % mod;
    cout << now << endl;
  }
  return 0;
}


Measured memory_bytes: 3632