akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890l
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define space " "
#define cbr cout << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, m, k=INF,ans,t=-1;
void base2(ll x)
{
	for(ll i = 6; i >= 0; i--)
	{
		cerr << (bool)(x&(1<<i));
	}
	cerr<<'\n';
}
int main()
{
	cin>>n>>m; if(n==m) { cout<<1<<"\n";return 0;} cerr<<'\n';base2(n); base2(m);
	for(ll i = 61; i >= 0; i--)
	{
		if( (p2(i)&n) == (m&p2(i)) )
		{
			if((p2(i)&n))
			{
				n^=(p2(i));
				m ^= (p2(i));
			}
		}
		else { k = i; break; }
	}
	cerr<<k<<'\n'; assert(k<INF-1);
	ans += (p2(k)-1ll-n+1ll);
	for(ll i = 0; i <= 61; i++)
	{
		if( p2(k) + p2(i) <= m) t = max(t,i);
	}
	cerr << t << '\n';
	// assert(t==0);
	ans += (p2(k)+p2(t+1)-1ll-p2(k)+1ll);
	ans += (2ll*p2(k)-1 - (p2(k)+n) + 1);
	ans -= max(0ll,(p2(k)+p2(t+1)-1)-(p2(k)+n)+1);
	cout<<ans<<"\n";
}


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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;
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class T>
inline void out(T a) {
	cout<<a<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int X;

void input() {
	cin>>X;
}

void solve() {
	cout<<8-(X-400)/200<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


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

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
    int a,b,c,d;
    cin >>a >> b >> c >> d;
    while(1)
    {
        c-=b;
        if(c<=0)
        {
            cout << "Yes" << endl;
            break;
        }
        a-=d;
        if(a<=0)
        {
            cout << "No" << endl;
            break;
        }
    }
    
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string str[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string s;
  cin >> s;

  for (int i = 0; i < 7; i++) {
    if (str[i] == s) {
      cout << 7 - i << endl;
    }
  }

  return 0;
}


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

int main() {
  int k;
  std::cin >> k;
  std::string s;
  std::cin >> s;
  if (s.length() <= k) {
    std::cout << s << std::endl;
  }
  else {
    s = s.substr(0,k);
    std::cout << s << "..." << std::endl;
  }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i,n) for(int i=0;i<n;i++) 
#define all(v) v.begin(),v.end()
#define F first
#define S second

void solve()
{
	int n;
	double m;
	cin>>n>>m;
	int arr[n];
	ll sum=0;
	rep(i,n)
	{
		cin>>arr[i];
		sum+=arr[i];
	}
	ll val=ceil(sum/(4*m));
	ll count=0;
	rep(i,n)
	{
		if(arr[i]<val)
		{
			count++;
		}
	}
	if(n-count>=m)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}

	
}

int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
	int t;
	t=1;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1010101010
#define MOD 1000000007
#define LL long long
using Coord = pair<int, int>;

int cnt[30][51];

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

    for (int i = 0; i < n; i++) {
        string tmp;
        cin >> tmp;
        for (const char &c: tmp) cnt[c - 'a'][i]++;
    }
 
    for (int i = 0; i <= 'z' - 'a'; i++) {
        int c = *min_element(cnt[i], cnt[i]+n);
        rep(j, c)
            cout << (char)('a' + i);
    }
    cout << endl;
}

Measured memory_bytes: 256
/*
我的心脏怦怦跳，监管者就在附近
*/
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
int a,b,c,f[3];
int main()
{
	int n;
	cin>>a>>b>>c;
	f[0]=a;
	f[1]=b;
	f[2]=c;
	sort(f,f+3);
	cout<<f[0]+f[1];
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define go(i, a, n) for (ll i = a; i < n; i++)
#define gor(i, a, n) for (int i = n - 1; i >= a; i--)
#define show(x) cout << x << '\n'
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vpair vector<pair<ll, ll>>
#define vtuple vector<tuple<ll, ll, ll>>
#define ff first
#define ss second
#define mod 1000000007
#define memset(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
auto t1 = chrono::high_resolution_clock::now();
bool prime[1000001];

ll expo(ll a, ll b)
{
	a = a % mod;
	b = b % mod;
	if (b == 0)
		return 1;
	if (b % 2)
		return ((a % mod) * (expo((a * a) % mod, b / 2) % mod)) % mod;
	return expo((a * a) % mod, b >> 1) % mod;
}

ll mul(ll a, ll b)
{
	a = a % mod;
	b = b % mod;
	if (b == 0)
		return 0;
	if (b % 2)
		return ((a % mod) + (mul((a + a) % mod, b >> 1) % mod)) % mod;
	return mul((a + a) % mod, b >> 1) % mod;
}

bool ispoweroftwo(ll x)
{
	return x && !(x & (x - 1));
}

ll xorcal(ll n)
{
	if (n % 4 == 0)
		return n;
	if (n % 4 == 1)
		return 1;
	if (n % 4 == 2)
		return n + 1;
	if (n % 4 == 3)
		return 0;
}

void sieve(ll n)
{
	memset(prime, true);
	prime[0] = false;
	prime[1] = false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (prime[i] == true)
		{
			for (ll j = i * i; j <= n; j += i)
				prime[j] = false;
		}
	}
}

ll modinverse(ll a, ll m)
{
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m;
		a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

void binary(ll a[], ll n)
{
	gor(i, 0, 64)
	{
		ll k = n >> i;
		a[i] = k & (ll)1;
	}
}

ll countBits(ll n)
{
	if (n == 0)
		return 0;
	return 1 + countBits(n & (n - 1));
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ld r;
	cin>>r;
	cout<<fixed<<setprecision(20)<<(ld)2*M_PI*r<<endl;
	auto t2 = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
	clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
	return 0;
}


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

int main(){
int a,b,n;
int m[17][17];
int x,y;
while(cin>>a>>b>>n){
for(int i=0;i<17;i++){
for(int j=0;j<17;j++){
if(i==0||j==0){m[i][j]=0;}
else m[i][j]=1;}}
for(int i=0;i<n;i++){
cin>>x>>y;
m[x][y]=0;}
for(int i=2;i<a+1;i++){if(m[i][1]!=0){m[i][1]=m[i-1][1];}}
for(int j=2;j<b+1;j++){if(m[1][j]!=0){m[1][j]=m[1][j-1];}}
for(int i=2;i<a+1;i++){
for(int j=2;j<b+1;j++){
if(m[i][j]!=0){m[i][j]=m[i][j-1]+m[i-1][j];}}}
cout<<m[a][b]<<endl;
}}

Measured memory_bytes: 1160
#include<stdio.h>

int main(){
	int a=1;
	int b=1;
	int i=0;
	int j=0;
	for (j=0;j<=8;j++){
		for(i = 0;i<=8;i++){
			printf("%dx%d=%d\n",a,b,a*b);
			b++;
		}
		b=1;
		a++;
	}
	return 0;
}

Measured memory_bytes: 524
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int n,i;
int sum=1;
int main(){
	cin>>n;
	while(n>1){n=n/2;i++;};
	for(int j=0;j<i;j++)sum=sum*2;
	cout<<sum<<endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; 
using namespace std;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " is " << (x) << endl
#define dbg(x)     cout << x << ' '
#define here cout << " Hey baitch!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld PI = 3.1415926535898;

int32_t main()
{
	SYNC
	string s,t;
	cin >> s >> t;
	if(sz(s) == sz(t)-1) {
		t.pop_back();
		if(s == t)	return cout << "Yes",0;
	}
	cout << "No";
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main () {
  long Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  S = min(S, min(Q * 4, H * 2));
  D = min(D, S * 2);
  cout << (N % 2 == 0? N * D / 2: S + (N / 2) * D) << endl;
  return 0;
}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            var result = new int[N];

            for(int i = 0; i < N - 1; i++)
            {
                result[input[i] - 1]++;
            }

            foreach(var r in result)
            {
                Console.WriteLine($"{r}");
            }
        }
    }
}


Measured memory_bytes: 54208
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>

int main()
{
    int n;
    std::cin >> n;

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

    int ave = std::round((double)std::accumulate(a.begin(), a.end(), 0.0) / a.size());

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (ave - a[i]) * (ave - a[i]);
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] A = new int[N + 1];
		int[] num = new int[200001];
		for (int i = 1; i <= N; i++) {
			A[i] = sc.nextInt();
			num[A[i]]++;
		}
		Arrays.sort(num);
		int ans = 0;
		for (int i = 1; i < 200001 - K; i++) {
			ans += num[i];
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 67108
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, a[101];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> a[i];

	int ans = 0;
	rep(i, 0, N) if (i % 2 == 0 && a[i] % 2 == 1) ans++;
	cout << ans << endl;
}







Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main() {

	//B
	string s;
	int i;
	cin >> s;
	int num = 0;
	char a[10];
	for (i = 0; i < s.length(); i++) {
		if (s[i] == '0' || s[i] == '1') {
			a[num] = s[i];
			num++;
		}
		else {
			if (num > 0)num--;
		}
	}
	for (i = 0; i < num; i++) {
		cout << a[i];
	}
	cout << endl;
	return 0;

	//C
	/*int a[100];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int sum;
	int min = 100000000;
	for (int i = -100; i <= 100; i++) {
		sum = 0;
		for (int j = 0; j < n; j++) {
			sum = sum + (i - a[j]) * (i - a[j]);
		}
		if (sum < min)min = sum;
	}
	cout << min << endl;
	return 0;*/


	//D
	/*
	string s;
	cin >> s;
	int i, j, k;
	int ab[26];
	for (i = 0; i < 26; i++) {
		ab[i] = 0;
	}
	for (j = 0; j < s.length() - 1; j++) {
		if (s[j] == s[j + 1]) {
			cout << j + 1 << ' ' << j + 2 << endl;
			return 0;
		}
		else if (j < s.length() - 2) {
			if (s[j] == s[j + 2]) {
				cout << j + 1 << ' ' << j + 3 << endl;
				return 0;
			}
		}
	}
	cout << -1 << ' ' << -1 << endl;
	return 0;*/
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll a, b, c, m, n, ans;

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

    cin >> n >> a >> b;
    vi A(n);
    rep(i, n) cin >> A[i];
    int count = n;
    rep(i, n)
        count += (a - 1) / A[i];

    cout << count + b << endl;

    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2019/08/10.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef LONG_MAX
#undef LONG_MIN

#define LONG_MAX	9223372036854775807
#define LONG_MIN	(-LONG_MAX  -1)

#define ll long long

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	ll a,b;
	cin >> a >> b;

	//max(max(a+b,a-b),a*b);
	
	cout << max(max(a+b,a-b),a*b) << endl;
	return 0;
}


Measured memory_bytes: 256
def yumiri(L, n):
  for i in range(len(L)):
    if L[i] > n:
      return i - 1

def parunyasu(a, b, p, q):
  reans = ans
  rd1, rq1, d1, nd1, nq1, q1, newans = naobou(a, q, reans)
  rd2, rq2, d2, nd2, nq2, q2, newans = naobou(b, p, newans)

  if reans <= newans:
    t[d1 - 1] = q1
    t[d2 - 1] = q2
    return newans
  else:
    ayaneru(rd2, rq2, d2, nd2, nq2)
    ayaneru(rd1, rq1, d1, nd1, nq1)
    return reans

def ayaneru(rd, rq, d, nd, nq):
  ZL[rd].insert(rq, d)
  del ZL[nd][nq + 1]

def naobou(d, q, ans):
  newans = ans

  rd = t[d - 1] - 1
  rq = yumiri(ZL[rd], d)
  newans += SUMD[ZL[rd][rq] - ZL[rd][rq - 1] - 1] * c[rd]
  newans += SUMD[ZL[rd][rq + 1] - ZL[rd][rq] - 1] * c[rd]
  newans -= SUMD[ZL[rd][rq + 1] - ZL[rd][rq - 1] - 1] * c[rd] 
  del ZL[rd][rq]

  nd = q - 1
  nq = yumiri(ZL[nd], d)
  newans += SUMD[ZL[nd][nq + 1] - ZL[nd][nq] - 1] * c[nd]
  newans -= SUMD[d - ZL[nd][nq] - 1] * c[nd]
  newans -= SUMD[ZL[nd][nq + 1] - d - 1] * c[nd]
  ZL[nd].insert(nq + 1, d)

  newans -= s[d - 1][rd]
  newans += s[d - 1][nd]

  return rd, rq, d, nd, nq, q, newans

def rieshon():
  ans = 0
  for i in range(D):
    ans += s[i][t[i] - 1]
    for j in range(26):
      if t[i] - 1 == j:
        L[j] = 0
        ZL[j].append(i + 1)
      else:
        L[j] += 1
        ans -= L[j] * c[j]
  for i in range(26):
    ZL[i].append(D + 1)
  return ans

import time
import random
startTime = time.time()

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

L = [0] * 26
ZL = [[0] for _ in range(26)]
SUMD = [0] * (D + 1)
for i in range(1, D + 1):
  SUMD[i] = SUMD[i - 1] + i

RD = [0] * 26
t = [0] * D
for i in range(D):
  RD[0] += 1
  ma = s[i][0] + RD[0] * c[0]
  man = 0
  for j in range(1, 26):
    RD[j] += 1
    k = s[i][j] + RD[j] * c[j]
    if k > ma:
      ma = k
      man = j
  t[i] = man + 1
  RD[man] = 0

ans = rieshon()
while time.time() - startTime < 1.8:
  l = random.randrange(min(D - 1, 26)) + 1
  d = random.randrange(D - l) + 1
  p = t[d - 1]
  q = t[d + l - 1]
  if p == q: continue
  ans = parunyasu(d, d + l, p, q)

for i in range(D):
  print(t[i])


Measured memory_bytes: 86180
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, P; 
  cin >> N >> P;

  string s;
  cin >> s;

  if(P == 2 || P == 5){
    int ans = 0;
    REP(i, N){
      if((s[i]-'0')%P == 0) ans += i+1;
    }
    cout << ans << "\n";
    return 0;
  }

  map<int, int> m;
  m[0]++;
  int cur = 0;
  int ten = 1;
  RREP(i, N){
    (cur += (s[i]-'0')*ten) %= P;
    (ten *= 10) %= P;
    m[cur]++;
  }

  int ans = 0;
  for(auto p : m){
    ans += p.second*(p.second-1)/2;
  }
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1044
#include <stdio.h>

int
main(void)
{
	int i;
	int num;
	int idx = 0;
	int input_num[10000];

	while (1) {
		scanf("%d", &num);
		if (num == 0) break;
		input_num[idx] = num;
		idx++;
	}
	for (i = 1; i < idx + 1; i++) {
		printf("Case %d: %d\n", i, input_num[i-1]);
	}

	return 0;
}


Measured memory_bytes: 1968
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
 
  // 変数aで入力を受け取る
  cin >> x;
 if (x <= 599) {
   cout << "8" << endl;
 }else if (x <= 799) {
    cout << "7" << endl;
 }else if (x <= 999) {
      cout << "6" << endl;
    }else if (x <= 1199) {
      cout << "5" << endl;
    }else if (x <= 1399) {
      cout << "4" << endl;
    }else if (x <= 1599) {
      cout << "3" << endl;
    }else if (x <= 1799) {
      cout << "2" << endl;
    }else  {
      cout << "1" << endl;
    }
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define L 100000
 
main() {
 
  int n;
  int q;
  int Time = 0;
 
  int head=0;
  int tail=1;
 
  char name[L][11];
  int time[L];
 
 
  scanf("%d%d", &n, &q);
 
  for( tail=0; tail<n; tail++) {
    scanf("%s%d", name[tail], &time[tail]);
  }
 
  while(head != tail) {
     
    if( time[head] <= q ) { 
      Time += time[head];
      printf("%s %d\n", name[head], Time);
    }
 
    else {
      Time += q;
      strcpy(name[tail], name[head]);
      time[tail] = time[head] - q;
 
      if( tail+1 >= L ) {
    tail = 0;
      }
      else {
    tail++;
      }
    }
     
    if( head+1 >= L ) {
      head = 0;
    }
    else {
      head++;
    }
  }
 
  return 0;
 
}

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

using namespace std; 	
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e5+50;
const int oo = 1e9;
const int mod = 1e5;

int main(){
	ll n,m;
	cin>>n>>m;
	if(n==m || m==1 || n%m==0){
		puts("-1");
		return 0;
	}
	cout << n << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();

		long ans = a * c;

		ans = Math.max(ans, a * d);
		ans = Math.max(ans , b * c);
		ans = Math.max(ans , b * d);

		System.out.println(ans);

	}


}

Measured memory_bytes: 35676
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
	int n; cin >> n;
	if(!n)break;
	vector<pair<int,int>> v;
	for(int i=1;i<=n;i++){
		int x; cin >> x;
		if(i%2){
			if(v.size()){
				if(v.back().first==x){
					v.back().second++;
				}
				else{
					v.push_back({x,1});
				}
			}
			else{
				v.push_back({x,1});
			}
		}
		else{
			if(v.back().first==x){
				v.back().second++;
			}
			else{
				int p=v.back().second+1;
				v.pop_back();
				if(v.size()){
					v.back().second+=p;
				}
				else{
					v.push_back({x,p});
				}
			}
		}
	}
	int res=0;
	for(auto p:v){
		if(p.first==0)res+=p.second;
	}
	printf("%d\n",res);
	}
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<ll,ll> P;

ll n,k;
ll mp[666];
ll dp[666][666];
ll comb[666];
ll imos[666];

void init(){
	comb[0] = 1;
	REP(i,666){
		imos[i]++;
		mp[i] = -1;
		if(i)comb[i] = comb[i-1] * (2 * i - 1) % MOD;
		REP(j, 666){
			dp[i][j] = -1;
		}
	}
}

ll dfs(int l, int r){
	if(dp[l][r] != -1)return dp[l][r];
	
	int cou = 0;
	for(int i = l;i <= r;i++){
		if(mp[i] != -1){
			if(mp[i] > r || mp[i] < l){
				return dp[l][r] = 0;
			}
		}
		else {
			cou++;
		}
	}
	
	if(cou % 2) return dp[l][r] = 0;
	ll ret = comb[cou/2];
	for(int i = l;i < r;i++){
		int seica = imos[r] - imos[i-1] ;
		ret = (ret - dfs(l, i) * comb[seica/2] + MOD) % MOD;
	}
	return dp[l][r] = ret;
}

int main(){
	
	init();
	
	cin >> n >> k;
	REP(i, k){
		int a, b;cin >> a >> b;
		mp[a] = b;
		mp[b] = a;
		imos[a]--;
		imos[b]--;
	}
	REP(i,665)imos[i+1] += imos[i];
	
	ll ans = 0;
	for(int i = 1;i <= 2 * n;i++){
		for(int j = i + 1;j <= 2 * n;j++){
			ans = (ans + dfs(i, j) * comb[(2 * (n - k) - (imos[j]-imos[i-1]))/2] % MOD) % MOD;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3712
#pragma warning(disable: 4996)
#define _USE_MATH_DEFINES
#include <iostream>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
using namespace std;

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

	int N;
	cin >> N;
	long long sum_A = 0;
	vector<long long> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		sum_A += A[i];
	}

	long long min_ans = 10000000001;
	long long left_sum = 0, ans = 0;
	for (int i = 0; i < N; ++i) {
		left_sum = left_sum + A[i];
		long long right_sum = sum_A - left_sum;
		//右-左が正なら右-左 左合計と右合計が同じなら０ 左-右が正なら左-右
		if (left_sum == right_sum) ans = 0;
		else if (left_sum > right_sum) ans = left_sum - right_sum;
		else if (right_sum > left_sum) ans = right_sum - left_sum;

		min_ans = min(min_ans, ans);
	}
	cout << min_ans << endl;
	return 0;
}


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

int main() {
  int a;
  int b;
  int c;
  cin >> a >> b;
  c = ( a * b ) % 2;
  if ( c == 1 ){
    cout << "Odd" << endl;
  }else if ( c == 0 ){
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>

#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define ALL(X)      (X).begin(),(X).end()
typedef long long LL;

using namespace std;

int main(void){
    string s;
    cin >> s;
    int flag=0;
    for(int i=0;i<SZ(s);i++){
        if(flag==0&&s[i]=='C')
            flag++;
        if(flag==1&&s[i]=='F')
            flag++;
    }
    if(flag==2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
     return 0;
}


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n, k;
    cin >> n >> k;

    vs32 x(n);
    rep (i, n) cin >> x[i];

    int ans = 1e9;
    for (int l = 0; l <= n - k; ++l)
    {
        int r = l + k - 1;
        int v1 = abs(x[l]) + abs(x[l] - x[r]);
        int v2 = abs(x[r]) + abs(x[r] - x[l]);
        ans = MIN(ans, MIN(v1, v2));
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 640
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

ans=0
for i in range(n):
    for j in range(i+1,n):
        # print(i,j)
        ans+=d[i]*d[j]
print(ans)

Measured memory_bytes: 69876
N = int(input())
lst = [[] for i in range(N)]
for i in range(N):
  for j in range(int(input())):
    lst[i].append(list(map(int,input().split())))
ans = 0
for i in range(2**N):
  flag = True
  bin_lst = list(bin(i)[2:].zfill(N))
  for idx,j in enumerate(bin_lst):
    if (j == '1'):
      for v, w in lst[idx]:
        if (bin_lst[v-1] != str(w)):
          flag = False
  if (flag):
    ans = max(ans,bin_lst.count('1'))
print(ans)


Measured memory_bytes: 43996
fun main(arr:Array<String>) {
    val (itemCount,rangeEnd) = readLine()!!.split(" ") .map { it.toLong() }
    val numList = readLine()!!.split(" ").map { it.toLong() }
    if(numList.map { div2Count(it) }.sorted().let { it.first() != it.last() }) {
        println(0)
        return
    }

    val minKoubai = numList.map { it/2 }.reduce { acc, l -> getKoubai(acc, l) }
    var maxKoubai = rangeEnd / minKoubai
    if(maxKoubai % 2 == 0L) {
        maxKoubai--
    }
    if(maxKoubai <= 0) {
        println(0)
        return
    }
    println((maxKoubai+1)/2)
}

fun getKoubai(num1:Long,num2:Long):Long {
    val kouyaku = getKouyaku(num1, num2)
    return kouyaku * (num1/kouyaku) * (num2/kouyaku)
}
fun getKouyaku(num1:Long, num2:Long):Long {
    if(num1 % num2 == 0L) {
        return num2
    }
    return getKouyaku(num2, num1 % num2)
}

fun div2Count(num:Long):Int {
    var ans = 0
    var current = num
    while (current%2==0L) {
        ans++
        current /= 2
    }
    return ans
}


Measured memory_bytes: 68044
import numpy as np
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    ruiseki = [0]
    ans = 0
    for i in range(n):
        ruiseki.append(ruiseki[i]+a[i])
    c = collections.Counter(ruiseki).values()
    for i in c:
        ans += i*(i-1)//2
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 51264
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n[10],minn=100000;
    for(int i=0;i<s.size()-2;i++){
        n[i]=(s[i]-48)*100+(s[i+1]-48)*10+(s[i+2]-48);
        if(abs(n[i]-753)<minn)
            minn=abs(n[i]-753);
    }
    cout<<minn<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * @author : ashish1610
 */
#include <bits/stdc++.h>
using namespace std;
#define ll	long long int
#define MOD	1000000007
ll solve(string s, int idx, ll cur_val, ll run_res) {
	if(idx == (int)(s.length())) {
		return cur_val + run_res;
	}
	ll res = solve(s, idx + 1, cur_val * 10 + (s[idx] - '0'), run_res);
	res = res + solve(s, idx + 1, 0, cur_val + run_res);
	return res;
}
int main() {
	string s;
	cin >> s;
	cout << solve(s, 0, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
# aで1~Nまでの数を割っていったときにK以下はいくつあるか？


def f(a, n, k):
    syou, amari = divmod(n, a)
    one_syou = max(a - k, 0)
    plus = max(amari+1 - k, 0) if k != 0 else amari
    # print(syou, amari, one_syou, plus)
    return syou * one_syou + plus


ans = 0
for a in range(1, N+1):
    ans += f(a, N, K)
    # print(a, f(a, N, K))

print(ans)


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

int n;
int a[100010];
int x;
int ans;

int main()
{
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>x;
        a[x]++;
        a[x+1]++;
        a[x+2]++;
    }
    for (int i=0;i<100010;i++) if (a[i]>a[ans]) ans=i;
    cout<<a[ans]<<endl;

}

Measured memory_bytes: 640
N,M = gets.split("\s").map {|s|s.to_i}

a_ary = Array.new(N){ Array.new(N) }
b_ary = Array.new(M){ Array.new(M) }

N.times do |y|
  tmp = gets.chomp
  N.times do |x|
    a_ary[x][y] = tmp[x]
  end
end

M.times do |y|
  tmp = gets.chomp
  M.times do |x|
    b_ary[x][y] = tmp[x]
  end
end

ox = 0
oy = 0
cnt = 0
while(true)do
  cnt += 1
  hit = 1
  M.times do |y|
    M.times do |x|
      #puts "(ox+x,oy+y)=(#{ox+x},#{oy+y}) : (x,y)=(#{x},#{y})"
      if a_ary[ox+x][oy+y] != b_ary[x][y] then
        hit = 0
        #puts "compare NG : #{a_ary[ox+x][oy+y]},#{b_ary[x][y]}"
      else
        #puts "compare OK : #{a_ary[ox+x][oy+y]},#{b_ary[x][y]}"
      end
    end
  end

  if hit==1 then
    puts "Yes"
    exit
  else
    hit = 1
    if ox < N-M then
      ox += 1
    elsif ox == N-M then
      if oy < N-M then
        oy += 1
      else
        break
      end
      ox = 0
    end
  end

  if cnt > 100000 then
    puts "timeout"
    break
  end
end

puts "No"


Measured memory_bytes: 1916
from itertools import permutations
from math import factorial
n = int(input())
town = [complex(*map(int,input().split())) for _ in range(n)]
d = 0
for l in permutations(town):
  for i in range(n-1):
    d += abs(l[i]-l[i+1])
print(d/factorial(n))

Measured memory_bytes: 9184
c = []
for i in range(3):
  c.append(list(map(int, input().split())))
a = [c[0][1]-c[0][0], c[0][2]-c[0][1]]
b = [c[1][0]-c[0][0], c[2][0]-c[1][0]]
f = True
for i in range(3):
  t = []
  for j in range(2):
    t.append(c[i][j+1] - c[i][j])
  if a != t:
    f = False

for i in range(3):
  t = []
  for j in range(2):
    t.append(c[j+1][i] - c[j][i])
  if b != t:
    f = False
if f: print("Yes")
else: print("No")

Measured memory_bytes: 3064
#include <stdio.h>
const int MOD=998244353;
const int N=1e7+10;
long long int f[N],inf[N];
long long int POW(long long int a,long long int b){
	long long int ans=1;
	while(b){
		if(b&1)ans=(ans*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return ans;
}
long long int Inv(long long int n){return POW(n,MOD-2);}
long long int C(long long int n,long long int m){return (f[n]*((inf[m]*inf[n-m])%MOD))%MOD;}
void pre(){
	inf[0]=inf[1]=f[0]=f[1]=1;
	for(int i=2;i<N;i++)f[i]=(f[i-1]*i)%MOD;
	inf[N-1]=Inv(f[N-1]);
	for(int i=N-2;i>=2;i--)inf[i]=(inf[i+1]*(i+1))%MOD;
	return ;
}
int main(){
	pre();
	int n;
	long long int ans=0,temp;
	scanf("%d",&n);
	ans=POW(3,n);
	for(int i=n/2+1;i<=n;i++){
		temp=POW(2,n-i+1);
		temp=(temp*C(n,i))%MOD;
		ans=(ans-temp+MOD)%MOD;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 156416
import java.util.*;

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


Measured memory_bytes: 44576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    
    int ans = 0;
    for(int i = 0; i < n; i++){
        if (p[i]-i == 0){
            if (i == 0) swap(p[i], p[i+1]);
            else if (i == n-1) swap(p[i], p[i-1]);
            else{
                if ((p[i+1] - i-1) == 0) swap(p[i], p[i+1]);
                else swap(p[i], p[i-1]);
            }
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define MOD 1000000007
#define PI acos(-1)
int main()
{
	IOS
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a)
	cout<<k;
	else
	{
		ll ans=a;
		ll left=k-a;
		if(left<=b)
		ans+=0;
		else
		{
			left=left-b;
			if(left<=c)
			ans=ans-left;
			else
			ans=ans-c;
		}
		cout<<ans;
	}
}

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

int main() {
  int S;
  cin >> S;
  int h,m,sec;
  sec = S % 60;
  m = S % 3600 / 60;
  h = S / 3600;
  cout << h << ":" << m << ":" << sec << endl;
}



Measured memory_bytes: 3092
#include <cstdio>
#include <cstring>

using namespace std;

const int N = 1005;

char A[N][N];
int w, h;

int main(){
	scanf("%d%d", &w, &h);
	for(int i = 0;i < w;i++)
		for(int j = 0;j < h;j++)
			scanf(" %c", &A[i][j]);
	for(int i = 0;i < w;i++){
		for(int j = 0;j < h;j++){
			if(j != h - 1 && (j == 0 || i % 2 == 0))
				printf("#");
			else
				printf("%c", A[i][j]);
		}
		printf("\n");
	}
	printf("\n");
	for(int i = 0;i < w;i++){
		for(int j = 0;j < h;j++){
			if(j != 0 && (j == h - 1 || i % 2 == 1))
				printf("#");
			else
				printf("%c", A[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int sum(int x){
    return x%10+(x%100)/10+(x%1000)/100+(x%10000)/1000+(x%100000)/10000;
}

int main() {
    int N;
    cin >> N;
    int min=100000;
    for(int i=1; i<=N/2; i++){
        int a, b, add;
        b=i;
        a=N-b;
        add=sum(b)+sum(a);
        if(min>add) min=add;
    }
    cout << min;
}

Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let (n, m): (usize, usize) = parse_line().unwrap();
    let mut city: Vec<u32> = vec![0; n];

    for _ in 0..m {
        let (a, b): (usize, usize) = parse_line().unwrap();
        city[a - 1] += 1;
        city[b - 1] += 1;
    }
    for num in city {
        println!("{}", num);
    }
}


Measured memory_bytes: 2108
n,k = map(int, raw_input().split())
ans = 0.0
for i in range(1, n+1):
    times = 0
    j = i
    while j < k:
        j *= 2
        times += 1
    ans += (0.5**times)
    #print times
print ans * (1.0 / n)



Measured memory_bytes: 5764
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	double ans = 0;
	for (int n = 0;n<N;++n) {
		double x;
		string u;
		cin >> x >> u;
		if ("JPY" == u) {
			ans += x;
		}
		else {
			ans += 380000.0*x;
		}
	}
	//printf("%.10f\n",ans);
	cout << (ans) / 1.0 << endl;
}

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

int main()
{
  string S;
  cin >> S;
  int c[26] = {};
  for(int i = 0; i < S.size(); ++i){
    if(c[S[i]-'a'] == 0) c[S[i]-'a']++;
    else{
      cout << "no\n";
      return 0;
    }
  }
  cout << "yes\n";
}

Measured memory_bytes: 256
#include <iostream>


int main()
{
	int n, x;
	std::cin >> n >> x;
	
	int d = 0;
	int l;
	
	int i;
	
	for (i = 0; i < n; ++i)
	{
		std::cin >> l;
		d += l;
		if (d > x)
		{
			break;
		}
	}
	std::cout << i + 1 << std::endl;
}

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

#define roop(p,q) for(p=1;p<=q;q++)

int powten(long long int x);

int main(){

 long long int N,M;
  scanf("%lld %lld",&N,&M);

/*
  char A[];
  scanf("%s",A);
  */

 /* 
  long long int A[N+1];
  long long int i;
  for(i=1;i<=N;i++){
   scanf("%lld",&A[i]);
   }
  */
  
  long long int A,B;
  long long int i,j;
  A=0;
  i=0;
  B = M;
  while(N != 0){
   A += N%B *powten(i)/(B/M);
   N = N-N%B;
   i += 1;
   B = B * M;
  } 

  printf("%lld",i);





 return(0);
 }

int powten(long long int x){
  int j;
  int a;
  a=1;
  for(j=1;j<=x;j++){
   a=a*10;
  }
  return(a);
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <queue>
 
using namespace std;
#define N 100
#define INF 2000000
 
int n, M[N][N];
int d[N];
 
void bfs(int s){
    int i,u,v;
 
    queue<int> q;
    q.push(s);
    for(i = 0; i < n; i++){
        d[i] = INF;
    }
 
    d[s] = 0;
 
    while(!q.empty()){
        u = q.front();
        q.pop();
        for(v = 0; v < n; v++){
            if(M[u][v] == 0) continue;
            if(d[v] != INF) continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for(i = 0; i < n; i++){
        if(d[i] == INF){
            printf("%d -1\n", i+1);
        }else{
            printf("%d %d\n", i+1, d[i]);
        }
    }
}
 
 
int main(void){
    int i,j,u,k,v;
 
    scanf("%d", &n);
 
    for(i = 0;i < n; i++){
        for(j = 0; j < n; j++){
            M[i][j] = 0;
        }
    }
 
    for(i = 0; i < n; i++){
      cin >> u >> k;
        u--;
        for(j=0;j<k;j++){
          cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
 
    bfs(0);
 
    return 0;
}



Measured memory_bytes: 3180
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        d: usize,
    }

    let mut taka_attack = c / b;
    let taka_mod = c % b;
    let mut ao_attack = a / d;
    let ao_mod = a % d;

    if taka_mod != 0 {
        taka_attack = taka_attack + 1;
    }

    if ao_mod != 0 { 
        ao_attack = ao_attack + 1;
    }

    if taka_attack <= ao_attack {
        println!("Yes");
    }else{
        println!("No");
    }

   
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<pair<int,int>> A(1<<N);
	for (int i = 0; i < (1<<N); ++ i) {
		int x;
		cin >> x;
		int k = ((1<<N)-1)&~i;
		for (int j = k; ; j=(j-1)&k) {
			int jj = i|j;
			//cerr << "*" << jj << " " << i << endl;
			if (x > A[jj].first) {
				A[jj].second = A[jj].first;
				A[jj].first = x;
			} else if (x > A[jj].second) {
				A[jj].second = x;
			}
			if (j == 0) break;
		}
	}
	int res = A[0].first + A[0].second;
	for (int K = 1; K < (1<<N); ++ K) {
		//cerr << A[K].first << " " << A[K].second << endl;
		res = max(res, A[K].first + A[K].second);
		cout << res << endl;
	}
}


Measured memory_bytes: 5120
#include<stdio.h>
int binarySearch(int[],int,int);

main(){
  int i,n,q;
  int res=0;
  int S[100000];
  int T[50000];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }



  for(i=0;i<q;i++){
    if(binarySearch(S,T[i],n)==0) res++;
  }

  printf("%d\n",res);



  return 0;
}

int binarySearch(int S[],int key,int n){
  int left=0;
  int right=n;
  int mid;

  while(left<right){
    mid=(left+right)/2;
    if(S[mid]==key) return 0;
    else if(key<S[mid]) right=mid;
    else left=mid+1;
  }
  return 1;
}

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

using namespace std;

const int N = 1e3+5;

const int mod = 1e9 +7;

long long n;

int main(){
    cin >> n;
    long long ans = 1;
    for(long long i = 1; i <= n; i++){
        ans *= i;
        ans %= mod;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<string> a;
int main() {
  string s;
  int k;
  cin >> s >> k;
 
  for(int i = 0; i < s.size(); i++) {
    for(int j = 1; j <= k; j++) {
      if(i+j > s.size()) continue;
      string tmp = s.substr(i,j);
      a.push_back(tmp);
    }
  }
  sort(a.begin(),a.end());
  unique(a.begin(),a.end());

  cout << a[k-1] << endl;
}


Measured memory_bytes: 1660