akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
template<class T>
void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>
void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=c-a,y=d-b;
	puta(c-y,d+x,c-y-x,d+x-y);
	return 0;
}

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

public class Main{
    public static void main(String[] args){
        long sum=0;
        List<Integer> list = Collections.synchronizedList(new ArrayList<Integer>());
        Scanner sc = new Scanner(System.in);
int a =sc.nextInt();
for(int i=0;i<a;i++){
    int b=sc.nextInt();
    list.add(b);
    sum+=b;
}
System.out.println(Collections.min(list)+" "+Collections.max(list)+" "+sum);
    }
}


Measured memory_bytes: 41288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    bool flag = false;
    int n;
    cin>>n;
    vector<int>a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];

    rep(i,n-2){
        if(a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2])flag = true;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main(){
    int N;
    cin>>N;
    vector<int> a(N);
    vector<int> count(N,0);
    for (int i = 0; i < N; i++)
    {
        cin>>a.at(i);
        while (a.at(i)%2==0){
            a.at(i)/=2;
            count.at(i)++;
        }
    }
    sort(count.begin(), count.end());
    cout<<count.at(0)<<endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
const long long mod = 1000000007;
//const long long mod = 998244353;

class Combination {
	int MAX;
	int mod;
	long long *kai;
	long long modpow(long long a, long long n) {
		long long res = 1;
		while (n > 0) {
			if (n & 1) res = res * a % mod;
			a = a * a % mod;
			n >>= 1;
		}
		return res;
	}
	long long modinv(long long a) {
		return modpow(a, mod - 2);
	}
	void Init() {
		for (int i = 1; i < MAX; i++) {
			kai[i] = kai[i - 1] * i;
			kai[i] %= mod;
		}
	}
public:
	Combination(int max, int mod) :mod(mod), MAX(max + 5) {
		kai = new long long[max + 5]{ 1 };
		Init();
	}
	~Combination() {
		delete[] kai;
	}
	long long operator()(int n, int k) {
		if (n < 0 || k < 0 || n < k)return 0;
		long long res = kai[n];
		res *= modinv(kai[k]);
		res %= mod;
		res *= modinv(kai[n - k]);
		res %= mod;
		//printf("%d C %d = %d\n", n, k, res);
		return res;
	}
};
long long modpow(long long a, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
long long modinv(long long a) {
	return modpow(a, mod - 2);
}

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	Combination nck(2 * n, mod);
	long long res = nck(2 * n - 1, n - 1);
	if (k < n) {
		for (int i = 1; i < n - k; i++) {
			long long minus = (nck(n - 1, i - 1)*nck(n, i)) % mod;
			res = (res + mod - minus) % mod;
		}
	}
	printf("%lld\n", res);
	return 0;
}

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

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int s = 0;               

            for (int i = 1; i <= n; i++)
            {
                s += i;
            }

            Console.WriteLine(s);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
int a,b,c;
cin>> a>>b >> c;
if (a==b&&b==c)
{
    cout << '1' << endl;
}else if (a==b||b==c||a==c)
{
    cout << '2' << endl;
}else
{
    cout << '3' << endl;
}






//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

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

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int dice[6];
int dir = 0;

class Dice{
public:
	//(front,back,up,down,right,left) = (1,3,5,0,2,4)
	int dat[6];

	void front(){
		int tmp = dat[0];
		dat[0] = dat[1];
		dat[1] = dat[5];
		dat[5] = dat[3];
		dat[3] = tmp;
	}
	void back(){
		int tmp = dat[0];
		dat[0] = dat[3];
		dat[3] = dat[5];
		dat[5] = dat[1];
		dat[1] = tmp;
	}
	void right(){
		int tmp = dat[0];
		dat[0] = dat[2];
		dat[2] = dat[5];
		dat[5] = dat[4];
		dat[4] = tmp;
	}
	void left(){
		int tmp = dat[0];
		dat[0] = dat[4];
		dat[4] = dat[5];
		dat[5] = dat[2];
		dat[2] = tmp;
	}
};

Dice d[2];

bool init(){
	rep(i, 7){
		if (d[0].dat[1] == d[1].dat[1])return true;
		d[1].front();
	}
	d[1].right();
	rep(i, 7){
		if (d[0].dat[1] == d[1].dat[1])return true;
		d[1].front();
	}
	return false;
}

bool init2(){
	rep(i, 7){
		if (d[0].dat[0] == d[1].dat[0])return true;
		d[1].right();
	}
	return false;
}

int main(){
	rep(i, 2)std::cin >> d[i].dat[5] >> d[i].dat[1] >> d[i].dat[2] >> d[i].dat[4] >> d[i].dat[3] >> d[i].dat[0];
	if (!init() || !init2())std::cout << "No" << std::endl;
	bool ans = true;
	REP(i, 3, 6){
		if (d[0].dat[i] != d[1].dat[i])ans = false;
	}
	if (ans)std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
	return 0;
}

Measured memory_bytes: 1160
n, m = map(int, input().split())

import numpy as np

rets = np.array([0] * n)
lmax = 1
rmin = n
for _ in range(m):
  l, r = map(int, input().split())
  lmax = max(l, lmax)
  rmin = min(r, rmin)
print(rmin - lmax + 1 if rmin - lmax + 1 > 0 else 0)




Measured memory_bytes: 14024
#include<stdio.h>
int memo[45];
int fib(int n){
  if(memo[n]!=-1)return memo[n];
  return memo[n]=fib(n-1)+fib(n-2);
}
int main(){
  int i,n;
  for(i=0;i<45;i++)memo[i]=-1;
  memo[0]=memo[1]=1;
  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<P> s(n), cp(m);
    rep(i, n) cin >> s[i].first >> s[i].second;
    rep(i, m) cin >> cp[i].first >> cp[i].second;
    rep(i, n)
    {
        int d = 1e9, id = -1;
        rep(j, m)
        {
            int x = abs(s[i].first - cp[j].first);
            int y = abs(s[i].second - cp[j].second);
            if (x + y < d)
            {
                d = x + y;
                id = j + 1;
            }
        }
        cout << id << endl;
    }
}

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

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 1e5 + 5;
int main()
{
	int n , m;
	cin >> n >> m;
	if(n == 1)n = 14;
	if(m == 1)m = 14;
	if(n > m)cout << "Alice" << endl;
	else if(n < m)cout << "Bob" << endl;
	else cout << "Draw" << endl;
	return 0;
	}

Measured memory_bytes: 256
"use strict"
// inputに入力データ全体が入る
function Main(input){
    let line = input.split("\n");
    let str = line[0] + line[0];
    console.log(str.includes(line[1]) ? "Yes" : "No");
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21948
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int a,b,c,d;
	string s;
	cin>>s;
	a=s[0]-'0';b=s[1]-'0';c=s[2]-'0';d=s[3]-'0';
	if (a-b-c-d ==7) printf("%d-%d-%d-%d=7\n",a,b,c,d);
	else if (a-b-c+d ==7) printf("%d-%d-%d+%d=7\n",a,b,c,d);
	else if (a-b+c-d ==7) printf("%d-%d+%d-%d=7\n",a,b,c,d);
	else if (a-b+c+d ==7) printf("%d-%d+%d+%d=7\n",a,b,c,d);
	else if (a+b-c-d ==7) printf("%d+%d-%d-%d=7\n",a,b,c,d);
	else if (a+b-c+d ==7) printf("%d+%d-%d+%d=7\n",a,b,c,d);
	else if (a+b+c-d ==7) printf("%d+%d+%d-%d=7\n",a,b,c,d);
	else if (a+b+c+d ==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD=1e9+7;

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

  int n,m,l,k,a,h;
  //????????°?????´???????????§?????¶??????????????????????¨??????°??????????????°???????????????????????¢??????
  while(true){
      cin>>n>>m>>l>>k>>a>>h;
      if(n==0) break;
      VVI dis(n,vector<int>(n,INF));
      for(int i=0;i<n;i++) dis[i][i]=0;
      bool f[n+1]={false};
      f[a]=true;f[h]=true;
      for(int i=0;i<l;i++){
          int c;cin>>c;f[c]=true;
      }
      for(int i=0;i<k;i++){
          int x,y,t;cin>>x>>y>>t;
          dis[x][y]=t;dis[y][x]=t;
      }
      for(int k=0;k<n;k++){
          for(int i=0;i<n;i++){
              for(int j=0;j<n;j++){
                  dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
              }
          }
      }
      for(int i=0;i<n;i++){
          for(int j=0;j<n;j++){
              if(!f[i]||!f[j]|| dis[i][j]>m) dis[i][j]=INF;
          }
      }
      for(int k=0;k<n;k++){
          for(int i=0;i<n;i++){
              for(int j=0;j<n;j++){
                  dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
              }
          }
      }
      if(dis[a][h]==INF){
          cout<<"Help!"<<endl;
      }
      else if(dis[a][h]<=m){
          cout<<dis[a][h]<<endl;
      }
      else{
          cout<<dis[a][h]*2-m<<endl;
      }
  }
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    //各チャンネルごとに番組が流れる時刻を記録して、
    //その後、各番組の時刻の情報でimos法をして一番値の大きい数を返すようにする

    int n,c;
    cin >> n >> c;

    vector<vector<int>> v(c, vector<int>(200002));

    rep(i,n){
        int s,t,tmpc;
        cin >> s >> t >> tmpc;

        tmpc--;

        if(v[tmpc][s * 2] != -1){
            v[tmpc][s * 2 - 1]++;
        }else v[tmpc][s * 2]++;
        v[tmpc][t * 2]--;
    }

    rep(i,c){
        for(int j = 1; j <= 200001; j++){
            v[i][j] = v[i][j] + v[i][j - 1];
        }
    }

    int ans = 0;

    for(int i = 1; i <= 200000; i++){
        int tmpans = 0;

        rep(j,c){
            if(v[j][i] == 1) tmpans++;
        }

        ans = max(ans,tmpans);
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 24576
#include<bits/stdc++.h>
using namespace std;
int a[100006], t;
int ans = 0;
int main()
{
	int N; scanf("%d", &N);
	int flag = 0;
	for (int i = 1; i <= N; i++) {
		scanf("%d", &a[i]);
		if (a[i] == i)flag++;
		else {
			ans += (flag + 1) / 2;
			flag = 0;
		}
	}
	ans += (flag + 1) / 2;
	printf("%d", ans);
}

Measured memory_bytes: 640
#include<stdio.h>
using namespace std;

int main()
{
	int length;
	int a, b, c,tmp;
	a = b = c = 0;

	for (int i = 0; i < 10; i++)
	{
		scanf("%d",&length);
		if (length > a)
		{
			if (length > b)
			{
				a = b;
				if (length > c)
				{
					b = c;
					c = length;
				}
				else
				{
					b = length;
				}
			}
			else
			{
				a = length;
			}
		}
	}
	printf("%d\n", c);
	printf("%d\n", b);
	printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 2728
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse = True)
d = {} # d[i] = number of i
ans = 0
for i in A:
	for j in range(31, 0, -1):
		x = 2 ** j - i
		if x in d and d[x] > 0:
			ans = ans + 1
			d[x] -= 1
			break
	else:
		d[i] = d.get(i, 0) + 1
print(ans)

Measured memory_bytes: 114004
function main(arg) {
	var x = arg.split("\n")[0].split("")
	var g = ['A','C','G','T']
	var ans = 0
	for (var i = 0; i < x.length; i++) {
		var xi = x[i]
		for (var j = 0; j < g.length; j++) {
			if (g[j] == xi) {
				x[i] = '*'
			}
		}
	}
	var max = 0
	x = x.join("").split(/[a-bA-b]/)
	for (var i = 0; i < x.length; i++) {
		var n = x[i].length
		if (max < n) {
			max = n
		}
	}
	console.log(max)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
// author: vinoda

#include<bits/stdc++.h>
using namespace std;

int main(){
  int n;
  long long k;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0; i<n; ++i)
    cin>>v[i];

  vector<int> check(n, -1), dummy;
  int cur=0;
  while(check[cur] == -1){
    check[cur] = v[cur]-1;
    cur=check[cur];
    dummy.push_back(cur);
  }

  int l=1, j=cur;
  j=check[j];
  while(j != cur){
    j=check[j];
    ++l;
  }
  int rem=(k-dummy.size()+l)%l;
  if(k<=dummy.size())  cout<<1+dummy[k-1]<<endl;
  else{
    while(rem){
      cur=check[cur];
      --rem;
    }
    cout<<1+cur<<endl;
  }
}


Measured memory_bytes: 5804
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;

ll n, k, a[N], v, u, koj[N];
vl g[N];
ll mark[N];

void DFS(ll v, ll col){
	mark[v] = col;
	for (auto u:g[v]){
		if (mark[u] == 0){
			DFS(u, col);
		}
		
		
	}
	
}



int main(){
	IOS;
	cin >> n >> k;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		koj[a[i]] = i;
	}
	for (int i = 1; i <= k; i++){
		cin >> v >> u;
		g[v].pb(u);
		g[u].pb(v);
	}
	ll com = 1;
	for (int i = 1; i <= n; i++){
		if (mark[i] == 0){
			DFS(i, com);
			com ++;
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++){
		if (mark[koj[i]] == mark[i]) ans++;
	}
	cout << ans;
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 13440
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N = ir()
    ans = 0
    for i in range(1, N+1):
        if i%3 != 0 and i%5 != 0:
            ans += i
    print(ans)
resolve()

Measured memory_bytes: 72744
#include<stdio.h>
#include<string.h>

int main(void){
  int n;
  char str[150];
  while((scanf("%s",str))!=EOF){
    for(int i=0;i<strlen(str);i++){
      if(str[i]=='@'){
        i++; n=str[i]-'0';
        i++; while(n-->0){ printf("%c",str[i]); }
      }
      else printf("%c",str[i]);
    }
    printf("\n");
    str[0]='\0';
  }
  return 0;
}




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

int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b / a) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    double pai = 3.141592653589;
    int n, m, t;
    scanf("%d %d",&n,&m);
    int a[n][m], b[m], ans[n];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(int i = 0; i < m; i++){
        scanf("%d",&b[i]);
    }
    for(int i = 0; i < n; i++){
        t = 0;
        for(int j = 0; j < m; j++){
            t+=(a[i][j]*b[j]);
        }
        ans[i] = t;
    }
    for(int i = 0; i < n; i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 2124
S = str(input())
s = [S[i] for i in range(len(S))]

yer = int(S[0])*1000 + int(S[1])*100 + int(S[2])*10 + int(S[3])
mon = int(S[5])*1000 + int(S[6])*100 + int(S[8])*10 +int(S[9])
if mon > 430:
    print('TBD')
else:
    print('Heisei')

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


A, B = MAP()
C = (B-A)/(A-1) +1
if C%1 == 0:
  print(int(C))
else:
  print(int(C+1))

Measured memory_bytes: 5524
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	int a[N];
	for(int i = 0;i<N;i++){
		cin>>a[i];
	}
	for(int k = 0;k<N-1;k++){
		cout<<a[k]<<" ";
	}
	cout<<a[N-1];
	cout<<endl;
	int j,v;
	for(int i = 1;i<=N-1;i++){
		v = a[i];
		j = i -1;		
		
		while(j>= 0 && a[j] > v){
			a[j + 1] = a[j];
			j--;
			a[j+1] = v;	
		}
		for(int k = 0;k<N-1;k++){
			cout<<a[k]<<" ";
		}
		cout<<a[N-1];
		cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;

int main(){
	int a,b,c,k;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	int ans=0;
	if(k<=a) {printf("%d",k);return 0;}
	ans+=a;
	k-=a;
        k-=b;
        if(k>0)
            {ans-=k;
            printf("%d",ans);}
        else
            printf("%d",ans);
	return 0;
}


Measured memory_bytes: 3828
//RohitKaushal
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define print(x) cerr << (#x) << "is "<< x << "\n"
typedef long long ll;
const int MOD = 1e9+7;


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

   ll n,k,q;
   cin>>n>>k>>q;
   ll tmp;
   std::vector<int> v(n,k-q);

   for (int i = 0; i < q; ++i)
   {
   	 cin>> tmp;
   	 v[tmp-1]++;
   }

   for (int i = 0; i < n; ++i)
   {
   		if(v[i]>0){
   			cout<<"Yes\n";
   		}
   		else{
   			cout<<"No\n";
   		}
   }

   return 0;
} 


Measured memory_bytes: 1024
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	char c11,c12,c13,c21,c22,c23;


		cin>>c11>>c12>>c13;
		cin>>c21>>c22>>c23;
		if(c11==c23&&
				c12==c22&&
				c13==c21){
			cout<<"YES"<<endl;
		}else{cout<<"NO"<<endl;

		}










}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int i, j;
	for (i = 1; i <= 9; i++) {
		for (j = 1; j <= 9; j++) {
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	getchar();

	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
const int mod = 1'000'000'007, maxn = 200200;
int mul(long long a, long long b){
	return a * b % mod;
}
int pwr(long long a, long long b){
	int r = 1;
	for(;b; b >>= 1, a = mul(a,a)) if(b&1) r = mul(r, a);
	return r;
}
int fat[maxn], ifat[maxn];
void init(){
	fat[0] = 1;
	for(int i = 1; i < maxn; i++) fat[i] = mul(i, fat[i - 1]);
	ifat[maxn - 1] = pwr(fat[maxn - 1], mod - 2);
	for(int i = maxn - 2; i >= 0; i--) ifat[i] = mul(i + 1, ifat[i + 1]);
	for(int i = 0; i < maxn; i++) assert(mul(fat[i], ifat[i]) == 1);
}
int ncr(int n, int r){
	if(n < r) return 0;
	return mul(fat[n], mul(ifat[r], ifat[n - r]));
}
int paths(int n, int m){
	return ncr(n - 1 + m - 1, n - 1);	
}
int main(){
	init();
	int h, w, a, b; cin >> h >> w >> a >> b;
	int ans = 0;
	for(int i = a+1; i <= h; i++){
		ans += mul(paths(i, w - b), paths(h - i + 1, b));
		if(ans >= mod) ans -= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rnk(x, V) lower_bound(all(V),x)-V.begin()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cerr<<#x<<" = " <<x<<", "
#define de(x) cerr<<#x<<" = " <<x<<endl
//-------

const int MAXN = 2e5 + 7;

int n, a[MAXN];
ll sum[MAXN];

bool findJK(int i, ll lb, pair<int, int> &jk) {
	// sum[j] >= lb + sum[i]
	int j = lower_bound(sum + i + 1, sum + 1 + jk.first, sum[i] + lb) - sum;
	if (j > jk.first) return false;
	// sum[n] - sum[k] >= lb
	int k = upper_bound(sum + jk.second, sum + 1 + n, sum[n] - lb) - sum - 1;
	if (k < jk.second) return false;	
	if (j >= k) return false;
	if (sum[k] - sum[j] < lb) return false;
	jk = {j, k};
	return true;
}

ll getKM(int j, int k) {
	return max(sum[k] - sum[j], sum[n] - sum[k]);	
}

ll solve() {
	ll ret = LLONG_MAX;
	rep(i, 1, n + 1)
		sum[i] = sum[i - 1] + a[i];
//	rep(i, 1, n + 1) dd(i), de(a[i]);

	// (0, i] is maximum
	rep(i, 1, n + 1) {
		if (4 * sum[i] < sum[n])
			continue;
		int JU = upper_bound(sum + i, sum + n + 1, 2 * sum[i]) - sum - 1;
		int KL = lower_bound(sum + i, sum + n + 1, sum[n] - sum[i]) - sum;	
		pair<int, int> jk;
		ll l = 1, r = sum[i]; 		
		while (l + 1 < r) {
			ll lb = (l + r) / 2;
			findJK(i, lb, jk = {JU, KL}) ? l = lb : r = lb;
		}
		if (findJK(i, r, jk = {JU, KL})) {
		} else if (findJK(i, l, jk = {JU, KL})) {
		} else {
			jk = {-1, -1};
		}
		if (jk.first == -1) continue;
		int j, k; tie(j, k) = jk;
		if (sum[k] - sum[j] > sum[i]) continue;	
		ll lb = min(sum[j] - sum[i], min(sum[k] - sum[j], sum[n] - sum[k]));	
		ret = min(ret, sum[i] - lb);
	}

	// (i, j] is maximum
	for (int j = 1, k = 2; j < n; ++j) {
		while (k < n && getKM(j, k) > getKM(j, k + 1))
			++k;
		ll jk = sum[k] - sum[j], kn = sum[n] - sum[k];		
		if (sum[j] - sum[1] >= max(jk, kn) && sum[j] - sum[1] >= sum[1]) {
			// sum[j] - sum[i] >= max(jk, kn)		
			// sum[j] - sum[i] >= sum[i]
			ll up_i = min(sum[j] - max(jk, kn), sum[j] / 2);	
			int i = upper_bound(sum + 1, sum + j, up_i) - sum - 1;
			if (i <= 0) continue;	
			ret = min(ret, (sum[j] - sum[i]) - min(sum[i], min(jk, kn)));
		}
	}
	return ret;
}

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

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

	ll ret = solve();
	reverse(a + 1, a + 1 + n);
	ret = min(ret, solve());
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
using namespace std;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// A - Multiple of 2 and N
int main(){
    int N;
    cin >> N;
    int ans=0;
    if(N%2==0){
        ans=N;
    }else{
        ans=N*2;
    }

    cout << ans << endl;
    return 0;
}




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

struct Room
{
    vector<int> toRooms;
    int steps = 0;
    int fromRoom = -1;
};

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

    vector<Room> rooms(n);

    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        rooms[a - 1].toRooms.push_back(b - 1);
        rooms[b - 1].toRooms.push_back(a - 1);
    }

    rooms[0].steps = 0;
    deque<int> nextRooms;
    nextRooms.push_back(0);

    while (nextRooms.size())
    {
        const int number = nextRooms[0];
        const auto &currentRoom = rooms[number];
        nextRooms.pop_front();

        int step = currentRoom.steps + 1;
        for (auto idx : currentRoom.toRooms)
        {
            if (rooms[idx].steps)
                continue;

            rooms[idx].steps = step;
            rooms[idx].fromRoom = number;
            nextRooms.push_back(idx);
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < n; ++i)
        cout << (rooms[i].fromRoom + 1) << endl;

    return 0;
}

Measured memory_bytes: 10644
import java.io.*;
import java.util.*;
class Main{
  static Node root = null;
  static StringBuilder bl = new StringBuilder();
  public static void main(String args[])throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    String [] s = new String[2];
    for(int i = 0; i<n; i++){

      s = br.readLine().split("\\s+");

      if(s[0].charAt(0) == 'i'){
        Insert( Integer.parseInt(s[1]));
      }
      else if(s[0].charAt(0) == 'p'){
        inorder(root);
        bl.append("\n");
        preorder(root);
        bl.append("\n");
      }else{
        if( find(root, Integer.parseInt(s[1]))){
          bl.append("yes\n");
        }else{
          bl.append("no\n");
        }
      }
    }
    System.out.print(bl);
  }
  
  static void Insert (int k){
    Node y = null;
    Node x = root;
    Node z = new Node();
    z.key = k;
    z.left = null;
    z.right = null;

    while(x != null){
      y = x;
      if(z.key < x.key){
        x = x.left;
      }else{
        x = x.right;
      }
    }
    z.parent = y;

    if( y == null){
      root = z;
    }else if( z.key < y.key){
      y.left = z;
    }else{
      y.right = z;
    }
  }

  static boolean find(Node u, int k){
    while( u != null){
      if(k == u.key){
        return true;
      }
      if(k<u.key){
        u = u.left;
      }else{
        u = u.right;
      }
    }
    return false;
  }

  static void preorder(Node u){
    if( u == null) return;
    bl.append(" ").append(u.key);
    preorder(u.left);
    preorder(u.right);
  }

  static void inorder(Node u){
    if(u == null) return;
    inorder(u.left);
    bl.append(" ").append(u.key);
    inorder(u.right);
  }

}

class Node{
  int key;
  Node parent;
  Node right;
  Node left;
  Node(){};
}


Measured memory_bytes: 204144
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using flt = double;
const flt eps = 1e-12, inf = 1e18, PI = acos(-1.0);
template<typename T>
inline T sqr(T x) {return x * x;}
inline flt cmp(flt a, flt b, flt e = eps) {
  return fabs(a - b) >= e + fabs(a) * e ? a - b : 0;
}
inline int sgn(flt x, flt e = eps) {return x < -e ? -1 : (x > e);}
inline flt fix(flt x, flt e = eps) {return cmp(x, 0, e);}

struct point {
  flt x, y;
  point(flt x = 0, flt y = 0): x(x), y(y) {}
  bool operator < (const point &rhs) const {
    return cmp(x, rhs.x) < 0 || (cmp(x, rhs.x) == 0 && cmp(y, rhs.y) < 0);
  }
  bool operator == (const point &rhs) const {
    return cmp(x, rhs.x) == 0 && cmp(y, rhs.y) == 0;
  }
  point operator + (const point &rhs) const {
    return point(x + rhs.x, y + rhs.y);
  }
  point operator - (const point &rhs) const {
    return point(x - rhs.x, y - rhs.y);
  }
  point operator * (const flt k) const {
    return point(x * k, y * k);
  }
  point operator / (const flt k) const {
    return point(x / k, y / k);
  }
  point operator ~ () const {// counter clockwise rotate 90 degree
    return point(-y, x);
  }
  flt dot(const point &rhs) const {
    return x * rhs.x + y * rhs.y;
  }
  flt det(const point &rhs) const {
    return x * rhs.y - y * rhs.x;
  }
  flt norm2() const {
    return x * x + y * y;
  }
  flt norm() const {
    return hypot(x, y);
  }
  point rot(flt a) const {// counter clockwise rotate A rad
    return point(x * cos(a) - y * sin(a), x * sin(a) + y * cos(a));
  }
  point rot(flt cosa, flt sina) const {// counter clockwise rotate using cos/sin
    return point(x * cosa - y * sina, x * sina + y * cosa);
  }
  point trunc(flt a = 1.0) const {
    return (*this) * (a / this->norm());
  }
};

int main() {
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    point A, B, C, D;
    scanf("%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y);
    scanf("%lf%lf%lf%lf", &C.x, &C.y, &D.x, &D.y);
    if (!sgn((B - A).det(D - C))) puts("2");
    else if (!sgn((B - A).dot(D - C))) puts("1");
    else puts("0");
  }
  return 0;
}

Measured memory_bytes: 2756
#include<cstdio>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    long int a[n];
    for(int i = 0; i < n; i++){
        scanf("%ld", &a[i]);
    }
    int ans = 0;

    for(int i = 0; i < n; i++){
        while(true){
            if (a[i] % 2 == 0){
                ans++;
                a[i] /= 2;
            }else break;
        }
    }
    printf("%d\n", ans);   
}

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

using namespace std;


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

int fix(string &n, int i, set<char> &ok, bool change = false)
{
    if (ok.find(n[i]) == ok.end() || change)
    {
        for (auto item : ok)
        {
            if (item > n[i])
            {
                n[i] = item;
                return i;
            }
        }
        if (i == 0)
        {
            string x;
            x += *ok.begin();
            if (x == "0")
                x[0]++;
            n.insert(0, x);
            return 0;
        }
        else
        {
            return fix(n, i - 1, ok, true);
        }
    }
    return -1;
}

int main()
{
    ios_base::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
    string n;
    int k;
    cin >> n >> k;
    set<char> ok;
    for (int i = '0'; i <= '9'; ++i)
        ok.insert(i);
    rep(i, k)
    {
        char temp;
        cin >> temp;
        ok.erase(temp);
    }
    int index = -1;
    for (int i = 0; i < n.size(); ++i)
    {
        index = fix(n, i, ok);
        if (index != -1)
            break;
    }
    if (index != -1)
    {
        for (int i = index + 1; i < n.size(); ++i)
        {
            n[i] = *ok.begin();
        }
    }
    cout << n << endl;
    return 0;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    int N;
    cin >> N;
    vector<int> v(N);
    REP(i,N) cin >> v[i];
    int j;
    REP(i,N) {
        int pick = v[i];
        j = i-1;
        while ( j >=0 && v[j] > pick) {
            v[j+1] = v[j];
            j--;
        }
        v[j+1] = pick;
        REP(k,N-1)  cout << v[k] << " ";
        cout << v[N-1] << endl;
    }
}

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


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

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

Measured memory_bytes: 3592
#!/usr/bin/env python3
k, t, *a = map(int, open(0).read().split())
a.sort()
c = [0]
for i in a:
    c.append(c[-1]+i)
print(min(abs(c[-1] - c[i]*2) - (c[-1]!= c[i]*2) for i in range(t+1)))


Measured memory_bytes: 9064
import functools
import operator

def calc(exps, level):
    lst = []
    while exps:
        exp = exps[0]
        nlevel = len(exp)-1

        if nlevel < level:
            break
        else:
            val = exps.pop(0)[-1]
            if val in ('+', '*'):
                operand = calc(exps, level+1)
                if val == '+':
                    val = sum(operand)
                else:
                    val = functools.reduce(operator.mul, operand)

            elif '0' <= val <= '9':
                val = int(val)

            lst.insert(0, val)

    return lst

def main():
    while True:
        n = int(input().strip())
        if n == 0:
            break
        exps = [input().strip() for _ in range(n)]
        print(calc(exps, 0)[0])

if __name__ == '__main__':
    main()



Measured memory_bytes: 6292
#include <stdio.h>

int main(void)
{
  int x, y, r;

  scanf("%d%d", &x, &y);

  r = x % y;

  while(r!=0) {
    x = y;
    y = r;
    r = x % y;
  }
  printf("%d\n", y);

  return 0;
}

Measured memory_bytes: 2752
#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 all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

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

   int k, n;
   cin >> k >> n;
   vector<int> a(n + 1);
   rep(i, 0, n) cin >> a[i];
   a[n] = k + a[0];
   vector<int> diff(n);
   rep(i, 0, n) diff[i] = a[i + 1] - a[i];
   sort(diff.rbegin(), diff.rend());
   int ans = k - diff[0];
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1792
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    ll n,m,k;cin>>n>>m>>k;
    vl a(n+1), b(m+1);
    rep(i, 1, n+1) cin>>a[i];
    rep(i, 1, m+1) cin>>b[i];

    vl aa(a);
    rep(i, 1, n+1) aa[i] += aa[i-1];
    vl bb(b);
    rep(i, 1, m+1) bb[i] += bb[i-1];
    bb.pb(INF);

    ll ans = 0;
    rep(i, n+1){
        ll r = k - aa[i];
        auto j = ub(all(bb), r) - bb.begin();
        if (j==0) continue;
        chmax(ans, i+j-1);
    }
    cout << ans << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 11088
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <utility>
#include <map>
#include <climits>
using namespace std;

int digiSum(int);

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

  int ans = INT_MAX;
  for(int a=1; a<=n-1; a++){
    int b = n-a;

    int m = digiSum(a) + digiSum(b);
    ans = min(m, ans);
  }

  cout << ans << endl;

  return 0;
}

int digiSum(int n){
  string s = to_string(n);

  int res = 0;
  for(int i=0; i<s.length(); i++){
    res += s[i]-'0';
  }

  return res;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = ll;

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vint a(n);
	rep(i, 0, n)
		cin >> a[i];
	rep(i, 1, m + 1){
		rep(j, 0, n-1){
			if (a[j] % i > a[j + 1] % i){
				int temp;
				temp = a[j];
				a[j] = a[j+1];
				a[j+1] = temp;
			}
		}
	}
	rep(i, 0, n)
		cout << a[i] << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <stdio.h>
void swap (int *x, int *y){
int temp;
temp = *x; *x = *y; *y = temp;
}
int partition (int array[], int left, int right){
int i, j,pivot;
i = left;
j = right+1;
pivot = left;
do {
  do { i++;}
  while (array[i] < array[pivot]);
  do { j--;}
  while (array[pivot] < array[j]);
  if (i < j){
  swap(&array[i], &array[j]);
}
}
while (i < j);
swap(&array[pivot], &array[j]); return j; }
/* クイックソート */
void quick_sort (int array[], int left, int right){
  int pivot; if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);
    quick_sort(array, pivot+1, right);
  }
}
 //kokkara
int main (void) {
int i,n=0,h=9,j=0;
int kore[1002];
for (i = 0; i < 5; i++) {
 scanf("%d", &kore[i]);
 	}
  ///↓///////quick_sort( 配列, 始点, 終点)で小→大の順でやってくれる/
 quick_sort( kore, 0, 4);
for (i = 0; i < 5; i++) {
  if (kore[i]%10==0){
  n=(((kore[i]/10)+1)*10)+n-10;
    j++;
  }
  else{
n=(((kore[i]/10)+1)*10)+n;
  }
  if (h>kore[i]%10 && kore[i]%10!=0){h=kore[i]%10;}
 	}
if (j==5){
n=n+1;
}
   printf ("%d",n+h-10);
 return 0;
 }


Measured memory_bytes: 128
import copy
H,W,K = map(int,input().split())
maze = []
for i in range(H):
    maze.append(input())
ans = 0

for i in range(1 << H):
    badH = []
    for j in range(H):
        if (i >> j) & 1 ==1:
            badH.append(j)
    for k in range(1 << W):
        badW = []
        count = 0
        for l in range(W):
            if (k >> l) & 1 ==1:
                badW.append(l)
        for m in range(H):
            for n in range(W):
                if maze[m][n] == '#':
                    if m not in badH and n not in badW:
                        count += 1
        if count == K:
            ans += 1
print(ans)

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

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

int H, W;
vector<string> S;

int search(pair<int, int> pos) {
  map<pair<int, int>, int> s;
  queue<pair<int, int>> q;
  s[pos] = 0;
  q.push(pos);
  int md = -1;
  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    int d = s[p];
    md = max(md, d);
    rep(i, 4) {
      int x = p.first + dx[i], y = p.second + dy[i];
      auto np = make_pair(x, y);
      if (s.find(np) != s.end() || x < 0 || x >= W || y < 0 || y >= H ||
          S[y][x] != '.')
        continue;
      s[np] = d + 1;
      q.push(np);
    }
  }
  return md;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> H >> W;
  S.resize(H);
  rep(i, H) cin >> S[i];
  int ans = 0;
  rep(y, H) rep(x, W) if (S[y][x] == '.') ans = max(ans, search({x, y}));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
const ans = main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );
console.log( ans );

function main(lines) {
  const N = +lines[0];

  const cnt = Array(N+1).fill(0);
  for (let x = 1; x < 100; x++) {
    for (let y = 1; y < 100; y++) {
      for (let z = 1; z < 100; z++) {
        const val = x*x + y*y + z*z + x*y + y*z + z*x;
        if (val <= N) cnt[val]++;
      }
    }
  }

  return cnt.slice(1).join('\n');
}



function splitN(s) {
  return s.split(' ').map(Number);
}

Measured memory_bytes: 32904
#include<stdio.h>

int Q,B,C1,C2,L,m,l,a1,a2,t;


int main()
{
	for(;~scanf("%d%d%d%d%d",&Q,&B,&C1,&C2,&L),Q;)
	{
		a1=0;
		for(m=0;m<=L;m++)
		{
			t=B-m*C1;
			t=t<0?0:t;
			if(m+t/C2>=Q&&m*C1+t<=B)
			{
				a1=m;
				a2=t/C2;
			}
		}
		if(a1<1)puts("NA");
		else printf("%d %d\n",a1,a2);
	}
	return 0;
}

Measured memory_bytes: 612
import itertools
import operator

line = int(input())
inputs = [input() for _ in range(line)]

def is_right_triangle(a, b, c):
    a, b, c = list(sorted([a,b,c]))
    return a**2 + b**2 == c**2

for line in inputs:
    a, b, c = line.split()
    print("YES" if is_right_triangle(int(a), int(b), int(c)) else "NO")

Measured memory_bytes: 7900
from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce


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


def iinput():
    return int(input())


def tinput():
    return input().split()


def rinput():
    return map(int, tinput())


def rlinput():
    return list(rinput())


mod = int(1e9)+7


def factors(n):
    return set(reduce(list.__add__,
                      ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))


# ----------------------------------------------------

if __name__ == "__main__":
    n, weigh = rinput()
    w, v = [], []
    for i in range(n):
        wi, vi = rinput()
        w.append(wi)
        v.append(vi)

    mxv = sum(v)
    dp = [[99999999999 for i in range(mxv+1)]for j in range(n+1)]
    for i in range(n+1):
        dp[i][0]=0
    # print(w_v)
    for item in range(1, n+1):
        for val in range(1, mxv+1):
            if v[item-1] <= val:
                dp[item][val] = min(
                    dp[item-1][val-v[item-1]]+w[item-1], dp[item-1][val])
            else:
                dp[item][val] = dp[item-1][val]
    # print(dp)
    ans=0
    for i in range(mxv+1):
        if dp[n][i]<=weigh:
            ans=i
    print(ans)



Measured memory_bytes: 173684