akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

ll f(ll n) {return n * (n+1) / 2;}

int main() {
  int n;
  cin >> n;
  int a = 0, b = 0, c = 0, d = 0;
  rep(i,n) {
    string s;
    cin >> s;
    if (s == "AC") a++;
    if (s == "WA") b++;
    if (s == "TLE") c++;
    if (s == "RE") d++;
  }

  cout << "AC x ";
  cout << a << endl;
  cout << "WA x ";
  cout << b << endl;
  cout << "TLE x ";
  cout << c << endl;
  cout << "RE x ";
  cout << d << endl;
}



Measured memory_bytes: 3624
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li      int64_t
#define ld      double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl          cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

void solve(){
  li x,a,b;cin>>x>>a>>b;
  if(abs(a-x)<abs(b-x)) cout<<"A";
  else cout<<"B";
}

int main(){
  opt
  #ifndef ONLINE_JUDGE
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  #endif
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

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

using namespace std;

int n;
int a[1005], b[1005], c[10005];
bool ifs[1005];
int mins = 10005;
long cost = 0;



int main() {
	long c1, c2, cmin;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (a[i] < mins) {
			mins = a[i];
		}
		b[i] = a[i];
		ifs[i] = false;
	}

	sort(b, b+n);
	for (int i = 0; i < n; ++i) {
		c[b[i]] = i;
	}
	
	for (int i = 0; i < n; ++i) {
		if (ifs[i]) {
			continue;
		}
		int j = i;
		int t = 0;
		c1  = 0;
		c2 = 0;
		cmin = a[j];
		while (1) {
			ifs[j] = true;
			c1 += a[j];
			t++;
			j = c[a[j]];
			if (cmin > a[j]) {
				cmin = a[j];
			}
			if (ifs[j]) break;
		}
		c2 = cmin + c1 + (t + 1) * mins;
		c1 = c1 + (t - 2)*cmin;
		cost += min(c1, c2);
	}

	cout << cost << endl;

	return 0;
}


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

using namespace std;



int main() {
	int A, B, C, K;
	int max = 0;
	int maisuu = 0;

	cin >> A >> B >> C >> K;

	for (int i = 0; i < A; ++i) {
		++max;
		++maisuu;
		if (maisuu == K) {
			cout << max;
			return 0;
		}
	}

	for (int i = 0; i < B; ++i) {
		++maisuu;
		if (maisuu == K) {
			cout << max;
			return 0;
		}
	}

	for (int i = 0; i < C; ++i) {
		--max;
		++maisuu;
		if (maisuu == K) {
			cout << max;
			return 0;
		}
	}

	cout << max;




	return 0;
}

Measured memory_bytes: 3592
/* https://atcoder.jp/contests/abc125/tasks/abc125_a */

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>

using namespace std;

/* {{{ Variables */
int A, B, T;
/* }}} */

int main(int argc, char *argv[])
{
  /* {{{ Input */
  cin >> A >> B >> T;
  /* }}} */

  /* {{{ Output */
  cout << T/A*B << endl;
  /* }}} */

  return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N, M = NMI()
    ab = [NLI() for _ in range(M)]
    
    l = [n for n in range(2,N+1)]
    
    per_list = list(itertools.permutations(l))
    ans = 0
    for p in range(len(per_list)):
        ls_p = list(per_list[p])
        ls_p.insert(0,1)
        
        flg = True
        for n in range(N-1):
            if not [min(ls_p[n],ls_p[n+1]),max(ls_p[n],ls_p[n+1])] in ab:
                flg = False
                continue
        else:
            if flg == True:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

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

int main() {
  vector<string> s(3);
  vector<int> cnt(3);
  rep(i,3)cin>>s[i];
  int x=0;
  while(1){
    if(cnt[x]==s[x].size()){
      cout<<(char)('A'+x)<<endl;
      return 0;
    }
    cnt[x]++;
    x=s[x][cnt[x]-1]-'a';
  }
}

Measured memory_bytes: 3592
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    const ab = arg.slice(1, M + 1);
    
    let map = [...Array(N)].fill(0);
    let answer = "IMPOSSIBLE";
    
    for(let i=0; i<M; i++) {
        let temp = ab[i].split(" ").map(n=>parseInt(n));
        let from = temp[0];
        let to   = temp[1];
        
        if(from === 1) {
            if(map[to] === 1) {
                answer = "POSSIBLE";
                break;
            } else {
                map[to]++;
            }
        }
        
        if(to === N) {
            if(map[from] === 1) {
                answer = "POSSIBLE";
                break;
            } else {
                map[from]++;
            }
        }
    }
        
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 59908
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}


int main() {
	int n = 0, k = 0;
	int x[100000] = {};
	int j = 0;
	ll  dis = 0xFFFFFFFF;
	std::cin >> n >> k;
	rep(i, n) {
		std::cin >> x[i];
	}
	for (int i = 0; i < n - k + 1; i++) {
		j = i + (k-1);
		dis = std::min(dis,(ll)std::min(std::abs(x[i]) + std::abs(x[j] - x[i]), std::abs(x[j]) + std::abs(x[i] - x[j])));
	}
	std::cout << dis << std::endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
int i,j,k,l,x,y,n,m;
std::string a[50],b[50];
main(){
  for(std::cin>>n>>m;i<n;)std::cin>>a[i++];
  for(;j<m;)std::cin>>b[j++];
  for(;k<=n-m;++k)for(l=0;l<=n-m;++l){
      i=0;
      for(x=0;x<m;++x)for(y=0;y<m;)a[k+x][l+y]-b[x][y++]?i=1:0;
      i?0:j=0;
    }
  puts(j?"No":"Yes");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


enum Type{
	UNDEFINED,
	D,
	NOT_D,
};

int N,M,ans;
int min_dist[30];
vector<int> G[30];


bool check(Type array[30]){

	bool FLG;

	for(int i = 0; i < N; i++){

		if(array[i] != NOT_D)continue;

		FLG = false;
		for(int k = 0; k < G[i].size(); k++){
			if(array[G[i][k]] == UNDEFINED || array[G[i][k]] == D){
				FLG = true;
				break;
			}
		}
		if(!FLG)return false;
	}
	return true;
}


void recursive(Type array[30],int num,int count){

	if(count >= ans)return;

	if(num == N){
		ans = count;
		return;
	}

	Type next_arrayD[30];
	for(int i = 0; i < N; i++)next_arrayD[i] = array[i];
	next_arrayD[num] = D;
	recursive(next_arrayD,num+1,count+1);

	Type next_arrayNOT[30];
	for(int i = 0; i < N; i++)next_arrayNOT[i] = array[i];
	next_arrayNOT[num] = NOT_D;
	if(check(next_arrayNOT)){
		recursive(next_arrayNOT,num+1,count);
	}
}


void func(){

	for(int i = 0; i < N; i++){
		G[i].clear();
	}

	int from,to;
	for(int loop = 0; loop < M; loop++){
		scanf("%d %d",&from,&to);
		G[from].push_back(to);
		G[to].push_back(from);
	}

	ans = N;
	Type first[30];
	for(int i = 0; i < N; i++)first[i] = UNDEFINED;

	recursive(first,0,0);

	printf("%d\n",ans);
}

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3276
#include<iostream>

using namespace std;

//累乗
int pow(int a,int b)
{
  int i,ans;
  ans=1;
  for(i=0;i<b;i++)
  {
    ans=ans*a;
  }
  return ans;
}
  

int main() 
{
  int N,K,high,low,ans;
  cin>>N>>K;
  
  for(ans=0;ans<32;ans++)
  {
    high=pow(K,ans);//全部最大値だったとき
    low=pow(K,ans-1);
    if(N>=low&&N<high)
    {
      cout<<ans;
      goto end;
    }
  }
  end:
  ; 
}

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end());
  n/=2;
  cout<<a[n]-a[n-1]<<endl;
}


Measured memory_bytes: 640
import std.algorithm;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;

immutable string YES = "YES";
immutable string NO = "NO";

auto solve(long N, long[] p){
    return p.enumerate(1).count!(t => t[0] != t[1]).among(0, 2) ? YES : NO;
}

void main(){
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] p = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        p[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, p);
    else
        solve(N, p).writeln;
}


Measured memory_bytes: 256
import math

s=input().strip()
t=input().strip()
i=0
j=0
flag=True
while i<len(s) and j<len(t):
	if s[i]==t[j]:
		i+=1
		j+=1
	else:
		flag=False
		break
if i!=len(s):
	flag=False
if flag:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 61852
#include <iostream>

using namespace std;

int judge(int i) {
	int sum = 0;
	for(int j = 1; j <= i; j++)
		if(i % j == 0) sum++;
	
	if(sum == 8) return 1;
	else return 0;
}

int main() {
	int N, sum = 0;
	cin >> N;
	for(int i = 1; i <= N; i+=2)
		sum += judge(i);
	
	cout << sum << endl;
}


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 mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
	int res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res % p;
}
int lcm(int a, int b)
{
	return a / __gcd(a, b) * b;
}
int n;
int dp[1000001][2][2];
int solvedp(int in, int ze, int ni)
{
	if (in == n)
	{
		if (ze && ni)
		{
			return 1;
		}
		return 0;
	}
	int ans = 0;
	if (dp[in][ze][ni] != -1)
	{
		return dp[in][ze][ni];
	}
	for (int i = 0; i <= 9; i++)
	{
		ans = ans + solvedp(in + 1, ((i == 0) ? 1 : ze), ((i == 9) ? 1 : ni));
		ans %= mod;
	}
	return dp[in][ze][ni] = ans;
}
void solve()
{
	memset(dp, -1, sizeof(dp));
	cin >> n;
	cout << solvedp(0, 0, 0);
}
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 112904
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

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


//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, h;
	cin >> n >> h;
	vector<ll>a(n), b(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	ll ans = 0;
	rep(i, n) {
		if (b[i] > a[0]) {
			ans++;
			h -= b[i];
		}
		if (h <= 0)break;
	}
	if (h > 0) {
		ans += (h - 1 + a[0]) / a[0];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4820
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>

#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
long long MOD = 998244353;

using namespace std;


void solve()
{
    ll n; int x;
    scanf("%lld%d%lld", &n, &x, &MOD);

    vector<ll> v;
    v.push_back(0);
    ll sum = 0;
    ll curr = x;
    map<ll, int> z;
    int prev = -1;
    int i;
    for (i = 0; i <= MOD; i++) {
        if(i>0) curr=curr*curr%MOD;
        auto it = z.find(curr);
        if (it != z.end()) {
            prev = it->second;
            break;
        }
        z[curr] = i;
        sum += curr;
        v.push_back(sum);
        if (v.size() == n+1) {
            printf("%lld\n", sum); return;
        }
    }
    assert(prev >= 0);
    assert(v.size() == i+1);
    int mm=i - prev;
    ll sum0 = v[i] - v[prev];

    ll num = n-i;
    ll ans1=(num / mm)*sum0;
    ll ans2 = v[num%mm+prev]-v[prev];
    ll ans = sum + ans1 + ans2;
    printf("%lld\n", ans);

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 6376
#include<cstdio>
#define rep(i, a, b) for (register int i=(a); i<=(b); ++i)
#define per(i, a, b) for (register int i=(a); i>=(b); --i)
using namespace std;
typedef long long ll;
inline void chkmax(int &x, int y){x<y?(x=y):0;}
inline void chkmin(int &x, int y){x>y?(x=y):0;}
const int N=305, P=998244353;
int dp[N][N*N][2];
void add(int &a, int b){a=a+b>=P?a+b-P:a+b;}
void sub(int &a, int b){a=a-b<0?a-b+P:a-b;}
int mul(int a, int b){return 1ll*a*b-1ll*a*b/P*P;}
int Pow(int x, int t)
{
	int res=1;
	for (; t; t>>=1, x=1ll*x*x%P) if (t&1) res=1ll*res*x%P;
	return res;	
}

inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

int main()
{
	int n=read(), sum=0; 
	dp[0][0][0]=dp[0][0][1]=1;
	rep(i, 1, n)
	{
		int x=read(); sum+=x;
		rep(j, 0, sum) 
		{
			add(dp[i][j][0], dp[i-1][j][0]);
			add(dp[i][j][1], mul(dp[i-1][j][1], 2));
			if (j>=x)
			{
				add(dp[i][j][0], dp[i-1][j-x][0]);
				add(dp[i][j][1], dp[i-1][j-x][1]);
			}
		}
	}
	int ans=Pow(3, n);
	rep(i, sum+1>>1, sum) sub(ans, mul(dp[n][i][1], 3));
	if ((sum&1)==0) add(ans, mul(dp[n][sum>>1][0], 3));
	printf("%d\n", ans);
	return 0;
}


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

button_dict = dict()

for i in range(1,N+1):
    button_dict[i] = int(input())

pushed_button_set = set()
i = 1
while 1:
    if i in pushed_button_set:
        print(-1)
        break
    elif i == 2:
        print(len(pushed_button_set))
        break
    else:
        pushed_button_set.add(i)
        i = button_dict[i]

Measured memory_bytes: 26932
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    int n; cin >> n;
    set<int> st;
    rep(i, n){
        int d; cin >> d;
        st.insert(d);
    }
    cout << st.size() << ln;
}
    

 


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>
#include <set>
#include <map>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 500000000  //
#define INFLL 1000000000000000000  //
#define MOD (1e9)+7

typedef long long int ll;

struct edge {
    int to, cost;
};

// a 0x61  z 0x7a  0 0x30

//------------------------------------------------------

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

    bool e1[n + 1] = {};
    bool e2[n + 1] = {};

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        if (a == 1) e1[b] = true;
        else if (b == n) e2[a] = true;
    }

    rep(i, n) {
        if (e1[i] && e2[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 640
$n, $q = gets.chomp.split(' ').map(&:to_i)
tree = Array.new($n) { [] }
result = Array.new($n, 0)

# データ準備
($n - 1).times do
  a, b = gets.chomp.split(' ').map(&:to_i)
  tree[a - 1].push(b - 1)
  tree[b - 1].push(a - 1)
end

# データ準備
$q.times do
  x, p = gets.chomp.split(' ').map(&:to_i)
  result[x - 1] += p
end

visited = Hash.new(false)
queue = [0]
while queue.count > 0 do
  i = queue.shift
  visited[i] = true
  tree[i].each do |next_child|
    next if visited[next_child]
    result[next_child] += result[i]
    visited[next_child] = true
    queue.push(next_child)
  end
end
print result.join(' ')


Measured memory_bytes: 38908
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;

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

    vector<vector <double> > A(n, vector<double>(m));
    vector<vector <double> > B(m, vector<double>(l));
    vector<vector <double> > C(n, vector<double>(l));
    

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cin >> B[i][j];
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l - 1; j++)
        {
            C[i][j] = 0;
            for (int k = 0; k < m; k++)
            {
                C[i][j] += A[i][k] * B[k][j];
            }
            cout << fixed << setprecision(0) << C[i][j] << " ";
        }

        C[i][l - 1] = 0;
        for (int k = 0; k < m; k++)
        {
            C[i][l-1] += A[i][k] * B[k][l-1];
        }
        cout << fixed << setprecision(0) << C[i][l - 1] << endl;
    }

    return 0;
}



Measured memory_bytes: 3408
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const NK = input.shift().split(' ').map(val => Number(val))
  const count = Math.min(...NK)
  input = input[0].split(' ').map(val => Number(val))

  const ans = []

  for(let l = 0; l <= count; l ++) {
    for (let r = 0; r <= count - l; r ++) {
      let temp = [
        ...input.slice(0, l),
        ...input.slice(NK[0] - r)
      ].sort((a, b) => a - b)
      let remain = NK[1] - l - r
      for (let i = 0; i < remain; i++) {
        if (temp[i] >= 0) break;
        temp[i] = 0
      }
      ans.push(temp.reduce((p, c) => p + c, 0))
    }
  }
  console.log(Math.max(...ans))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 10500
#include <iostream>
#include <string>
#include <vector>

int main(void){
    int a,b,c;
    std::cin >> a >> b >> c;
    for(int i = 0; i<b; i++){
        if(i*a % b == c){
            std::cout << "YES";
            return 0;
        }
    }

    std::cout << "NO";
    return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while(0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll N;
vector<ll> a, psum;

signed main() {
  cin >> N;
  a.resize(N);
  psum.resize(N,0);
  rep(i,N)
    cin >> a[i];
  psum[0] = a[0];
  for (ll i=1; i<N; i++) {
    psum[i] = psum[i-1] + a[i];
  }

  ll diff = 3030303030;
  rep(i,N){
    ll p = psum[i];
    ll q = psum[N-1] - p;
    diff = min(diff, abs(p-q));
  }
  cout<<diff<<endl;
  return 0;
}


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

int main() {
  
  vector<int> abc(3);
  for (int i = 0; i < 3; i++) {
    cin >> abc.at(i);
  }
  sort(abc.begin(), abc.end());
  for (int i = 0; i < 3; i++) {
    cout << abc.at(i);
    if (i != 2) {
      cout << ' ';
    } else {
      cout << endl;
    }
  }
 
}


Measured memory_bytes: 3144
#include<stdio.h>

typedef struct point {
    int x_elm;
    int y_elm;
} point;

point shift_point(point, int, int);

int main() {
    int x1, y1, x2, y2;
    point p1, p2;
    point p3, p4;

    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

    p1.x_elm = x1;
    p1.y_elm = y1;
    p2.x_elm = x2;
    p2.y_elm = y2;
    
    p3 = shift_point(p2, y1 - y2, x2 - x1);
    p4 = shift_point(p1, y1 - y2, x2 - x1);

    printf("%d %d %d %d\n", p3.x_elm, p3.y_elm, p4.x_elm, p4.y_elm);

    return 0;
}

point shift_point(point p, int x, int y) {
    point p_shifted;
    p_shifted.x_elm = p.x_elm + x;
    p_shifted.y_elm = p.y_elm + y;
    return p_shifted;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  string s;cin >> s;
  for(int i=0;i<s.size();i++){
    if(!(i&1)) cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("text1.in","r",stdin);
	//freopen("text1.out","w",stdout);
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b; 
	return 0;
}


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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
#define sysp system("pause")
//}

#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 0

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
inline long long digitsum(long long v){long long d=0;while(v){d+=v%10;v/=10;}return d;}
inline long long digitnumbersum(long long a){long long b=0;while(a){a/=10;b++;}return b;}
inline long long mysqrt(long long a){long long i=0;for(i=1;a>0;i++){a-=i*2+1;}return i-1;}
//}

long long n,a,ans;

int main(){
	cin>>n>>a;
	if(2*n>a){
		cout<<a/2<<endl;
		system("pause");
		return 0;
	}
	cout<<n+(a-2*n)/4<<endl;
	system("pause");
}
 

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+100;
const int INF=0x3f3f3f3f;
int n,a[N],k;
int sum;


int main()
{
    cin>>n;
    cin>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int pos=-1;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>=0)
        {
           pos=i;
           break;
        }
    }
    if(a[1]>=0)
    {
        sum=a[k];
    }
    else
    {
        if(a[n]<=0)
        {
            sum=abs(a[n-k+1]);
        }
        else
        {
            sum=INF;
            for(int i=pos-1;i>=1;i--)
            {
                if(i+k-1<=n)
                {
                    sum=min(sum,a[i+k-1]-2*a[i]);
                }
                else
                {
                    continue;
                }
            }
            for(int i=pos;i<=n;i++)
            {
                if(i>=k)
                {
                    sum=min(sum,2*a[i]-a[i-k+1]);
                }
            }


        }
    }
    cout<<sum<<endl;






    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

int n;
char ch[200005], ns[400005];
int cans[400005], mu[400005];

int check(int x)
{
	if(n % x == 0) return 0;
	
	int ret = 0;
	rep(i, x / 2) {
		ret = 2LL * ret % MOD; 
		if(ch[i] == '1') ret = (ret + 1) % MOD;
	}
	
	rep(i, x) ns[i] = ch[i % (x / 2)] ^ (i / (x / 2));
	rep(i, n) ns[i] = ns[i % x];
	
	rep(i, n) if(ns[i] > ch[i]) return ret;
	else if(ns[i] < ch[i]) return (ret + 1) % MOD;
	return (ret + 1) % MOD;
}

int main()
{
	scanf("%d%s", &n, ch);
	int cur = 2 * n;
	
	for(int i = 1; i <= cur; i ++)
	if(cur % i == 0) cans[i] = check(i);
	
	mu[1] = 1;
	rep1(i, cur) for(int j = 2 * i; j <= cur; j += i)
	mu[j] -= mu[i];
	
	for(int i = cur; i >= 1; i --) for(int j = 2 * i; j <= cur; j += i)
	cans[j] = (cans[j] + 1LL * (MOD + mu[j / i]) * cans[i]) % MOD;
	
	int ans = 0;
	rep1(i, cur) if(cur % i == 0 && n % i != 0) ans = (ans + 1LL * cans[i] * i) % MOD;
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
   string str;
   long long int a;
   
   cin>> str;
   
   for (int i = 0; i < str.size(); ++i)
   {
       a = a + str[i]-'0';
   }
    
    if(a%9==0)
    cout<<"Yes";
    else
    cout<<"No";
    
    return 0;
}

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

int main() {
  int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
  
  if(2*C >= A+B) {
    cout << A*X+B*Y << endl;
    return 0;
  }
  
  int ans = 0;
  while(X>0 && Y>0) {
    X--;
    Y--;
    ans += 2*C;
  }
  if(2*C >= A) {
    while(X>0) {
      X--;
      ans += A;
    }
  }
  if(2*C >= B) {
    while(Y>0) {
      Y--;
      ans += B;
    }
  }
  if(X==0 && Y==0) {
    cout << ans << endl;
    return 0;
  } else {
    while(X>0) {
      X--;
      ans += 2*C;
    }
    while(Y>0) {
      Y--;
      ans += 2*C;
    }
    cout << ans << endl;
    return 0;
  }
  

}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

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

int main(void){
  LL n;
  cin >> n;
  vector<LL> a(n), b(n), c(n);

  repl(i, n) cin >> a[i];
  repl(i, n) cin >> b[i];
  repl(i, n) cin >> c[i];

  sort(a.begin(), a.end());
  sort(c.begin(), c.end());

  LL sum = 0;
  repl(i, n) {
    vector<LL>::iterator num_a = lower_bound(a.begin(), a.end(), b[i]);
    vector<LL>::iterator num_c = upper_bound(c.begin(), c.end(), b[i]);
    sum += (num_a - a.begin()) * (n - (num_c - c.begin()));
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 2560
k = int(input())
lis = [1,2,3,4,5,6,7,8,9]
i=0
while len(lis) < k:
	m = lis[i]%10
	if m != 0:
		lis.append(int(str(lis[i])+str(m-1)))
	lis.append(int(str(lis[i])+str(m)))
	if m!= 9:
		lis.append(int(str(lis[i])+str(m+1)))
	i+=1
print(lis[k-1])

Measured memory_bytes: 6980
def examA():
    N = I()
    ans = N*N
    print(ans)

def examB():
    N = I()


import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

Measured memory_bytes: 38384
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

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

	ll X; cin >> X;

	ll cnt = X / 11 * 2;
	
	ll M = X % 11;
	if (M != 0) {
		if (M <= 6) cnt++;
		else cnt += 2;
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
	  #define endl "\n"
	  #define ll long long int
	  #define mod 1000000007
	  #define inf 1000000000000000001;
	  using namespace std;
	  int main()
	  {
	    //  #ifndef ONLINE_JUDGE
	    //  // for getting input from input.txt
	    //  freopen("input.txt", "r", stdin);
	    //  // for writing output to output.txt
	    //  freopen("output.txt", "w", stdout);
	    // #endif
	    std::ios::sync_with_stdio(false);
	    cin.tie(NULL);
	    int n;
	    cin>>n;
	    if(n >= 400 & n < 600){
	    	cout<<"8"<<endl;
	    }
	    else if(n >= 600 & n < 800){
	    	cout<<"7"<<endl;
	    }
	    else if(n >= 800 & n < 1000){
	    	cout<<"6"<<endl;
	    }
	    else if(n >= 1000 & n < 1200){
	    	cout<<"5"<<endl;
	    }
	    else if(n >= 1200 & n < 1400){
	    	cout<<"4"<<endl;
	    }
	    else if(n >= 1400 & n < 1600){
	    	cout<<"3"<<endl;
	    }
	    else if(n >= 1600 & n < 1800){
	    	cout<<"2"<<endl;
	    }
	    else if(n >= 1800 & n < 2000){
	    	cout<<"1"<<endl;
	    }


	    return 0;
	  }


Measured memory_bytes: 3648
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

//////////////////////////

int main(){fastio
    ll n,m;cin>>n>>m;
    vector<l_l>ans;
    if(n%2==1){
        rep(i,1,m){
            ans.pb({i,n-i});
        }
    }else{
        ll t=(m+1)/2;
        rep(i,1,t){
            ans.pb({i,2*t+1-i});
        }
        ll s=m-t;
        rep(i,2*t+1,2*t+s){
            ans.pb({i,n-(i-2*t)});
        }
    }
    for(auto x:ans){
        cout<<x.fi<<" "<<x.se<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 5216
import java.util.Scanner;
class Main {
    public void kami() {
        		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
    }
	public static void main(String[] args) {
        new Main().kami();
	}

}

Measured memory_bytes: 17356
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using ll = long long;
using namespace std;
int main(){
  int ans = 0;
  rep(i, 6){
    char s;
    cin >> s;
    if(s == '1') ans++;
  }
  cout << ans << endl;
  return 0;
}

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

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

Measured memory_bytes: 384
mod vectools {

///C++のupper_boundと同等の実装
pub fn upper_bound<T>(v: &Vec<T>, k: T) -> usize
where
    T: PartialOrd,
{
    let mut from = 0;
    let mut to = v.len();

    while to - from > 1 {
        let mid = (from + to) / 2;
        if v[mid] <= k {
            from = mid;
        } else {
            to = mid;
        }
    }
    if v[from] > k {
        from
    } else {
        to
    }
}

///C++のlower_boundと同等の実装
pub fn lower_bound<T>(v: &Vec<T>, k: T) -> usize
where
    T: PartialOrd,
{
    let mut from = 0;
    let mut to = v.len();

    while to - from > 1 {
        let mid = (from + to) / 2;
        if v[mid] < k {
            from = mid;
        } else {
            to = mid;
        }
    }

    if v[from] < k {
        to
    } else {
        from
    }
}

///次の順列を求める。
pub fn next_permutation<T>(v: &mut Vec<T>) -> bool
where
    T: PartialOrd,
{
    let mut pivot = v.len() - 1;
    loop {
        if pivot == 0 {
            return false;
        }
        if v[pivot] > v[pivot - 1] {
            pivot -= 1;
            break;
        }
        pivot -= 1;
    }
    let mut pivot_swap = v.len() - 1;
    while v[pivot] >= v[pivot_swap] {
        pivot_swap -= 1;
    }
    v.swap(pivot, pivot_swap);
    v[pivot + 1..].reverse();
    true
}

}

use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

use vectools::*;

fn main() {
    input! {
        n:usize,m:usize,k:usize,
        a:[usize;n],
        b:[usize;m],
    }

    let mut sa = vec![0];
    let mut sb = vec![0];

    let mut sum = 0;
    for i in 0..a.len() {
        sum += a[i];
        sa.push(sum);
    }
    let mut sum = 0;
    for i in 0..b.len() {
        sum += b[i];
        sb.push(sum);
    }

    let mut ans = 0_usize;
    for i in 0..sa.len() {
        let buf = sa[i];
        if buf > k {
            break;
        }
        let j = upper_bound(&sb, k - buf);
        ans = std::cmp::max(ans, i + j - 1);
    }

    println!("{}", ans);
}



Measured memory_bytes: 12692
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i=0; i<n; i++) cin >> s[i];

    sort(s.begin(), s.end());
    string a = "";
    for(int i=0; i<n; i++) {
        a += s[i];
    }
    cout << a << endl;

    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



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

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

    int d_1, d_10;
    int ans = 0;

    for(int i = 1; i <= n; i++){
        for(int j = 22; j <= d; j++){
            d_1 = j % 10;
            d_10 = j / 10;
            if(d_1 >= 2 && d_10 >= 2){
                if(d_1 * d_10 == i){
                    //cout << i << " " << j << endl;
                    ans++;
                }
            }
        }
    }
    

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int r, c ;
  int i, j, x ;

  int tab[105][105] = {} ;

  scanf("%d %d", &r, &c) ;

  for( i = 0 ; i < r ; i++ ){
    for( j = 0 ; j < c ; j++ ){
      scanf("%d",&x) ;
      tab[i][j] = x ;
      tab[r][j] += x ;
      tab[i][c] += x ;
      tab[r][c] += x ;
    }
  }

  for( i = 0 ; i < r+1 ; i++ ){
    for( j = 0 ; j < c+1 ; j++ ){
      if( j < c ){
        printf("%d ", tab[i][j]) ;
      }else{
        printf("%d", tab[i][j]) ;
      }
    }
    printf("\n") ;
  }

  return 0 ;
}


Measured memory_bytes: 2048
D,G = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(D)]

ans = 10**9
for b in range(2**D):
    score = 0
    ac = 0
    for k in range(D):
        if b&(1<<k):
            p,c = src[k]
            score += c
            ac += p
            score += p*(k+1)*100
    if score >= G:
        ans = min(ans,ac)
        continue
    for k in range(D-1,-1,-1):
        if b&(1<<k)==0:
            p,c = src[k]
            if score + p*(k+1)*100 < G:
                score += p*(k+1)*100
                ac += p
            else:
                rem = G-score
                ac += -(-rem // (k+1)//100)
                ans = min(ans,ac)
                break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}

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

    int res = 0;
    FOR(b, 1, N+1) {
        int p = N/b, r = N%b;
        res += p*max(0, b-K) + max(0, r-K+1);
    }
    if(K==0) res-=N;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//
//  ALDS1_4_A_Linear Search.cpp
//  test
//
//  Created by Sajor on 2019/3/25.
//  Copyright © 2019年 Sajor. All rights reserved.
//

#include<iostream>
#include<cstdio>

using namespace std;

bool linear_search(int *a, int b, int n){
    a[n] = b;
    int i=0;
    for(; i<n; i++) if(a[i] == b) break;
    if(i == n)
        return false;
    return true;
}

int main()
{
    int i, n, m, S[10005], T[505], count=0, b;
    cin >> n;
    for(i=0; i<n; i++)
        scanf("%d", &S[i]);
    cin >> m;
    for(i=0; i<m; i++){
        scanf("%d", &b);
        if(linear_search(S, b, n)) count++;
    }
    cout << count << endl;
    
//        scanf("%d", &T[i]);
    
    
    
}



Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int dp[100000];
long long int n;
int find(vector<int> &v, int i)
{
	if(i+1>=n&&i+2>=n) return 0;
	if(dp[i] != -1) return dp[i];
	int oneJump=1e9,twoJump=1e9;
	if(i+1<n) oneJump =	abs(v[i] - v[i+1]) + find(v,i+1);
	if(i+2<n) twoJump = abs(v[i]-v[i+2]) + find(v,i+2);
	return dp[i] = min(oneJump,twoJump);
}


int main()
{
	// fio;
	// #ifndef ONLINE_JUDGE 
	// freopen("input.txt", "r", stdin); 
	// freopen("output.txt", "w", stdout); 
	// freopen("error.txt", "w", stderr); 
	// #endif
	long long int x;
	cin>>n;
	vector<int> v;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
	{
		cin>>x;
		v.push_back(x);
	}
	cout<<find(v,0)<<"\n";

}

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

int main() {
  ll a;
  double b;
  cin >> a >> b;
  ll ib = b * 100 + 0.5;
  a *= ib;
  a /= 100;
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 3752
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

int dp[205][205][420];
//int dp[55][55][55][55];
int H, W;
int a[205][205];

int main(){
	cin >> H >> W;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> a[i][j];
		}
	}

	for(int i = 0; i < H; i++){
		for(int k = 0; k < H; k++){
			for(int m = 0; m < H + W; m++){
				dp[i][k][m] = -INT_MAX;
			}
		}
	}
	dp[0][0][0] = 0;

	for(int i = 0; i < H; i++){
		for(int k = 0; k < H; k++){
			for(int m = 0; m < H + W - 1; m++){
				int j = m - i;
				int l = m - k;
				if(i == k && j == l){
					if(i != H - 1){
						if(k != H - 1){
							dp[i+1][k+1][i+1+j] = max(dp[i+1][k+1][i+1+j] , dp[i][k][m] + a[i][j]);
						}
						if(l != W - 1){
							dp[i+1][k][i+1+j] = max(dp[i+1][k][i+1+j], dp[i][k][m] + a[i][j]);
						}
					}
					if(j != W - 1){
						if(k != H - 1){
							dp[i][k+1][i+j+1] = max(dp[i][k+1][i+j+1], dp[i][k][m]+ a[i][j]);
						}
						if(l != W - 1){
							dp[i][k][i+j+1] = max(dp[i][k][i+j+1], dp[i][k][m]+ a[i][j]);
						}
					}

				}else{
					if(i != H - 1){
						if(k != H - 1){
							dp[i+1][k+1][m+1] = max(dp[i+1][k+1][m+1], dp[i][k][m]+ a[i][j] + a[k][l]);
						}
						if(l != W - 1){
							dp[i+1][k][m+1] = max(dp[i+1][k][m+1], dp[i][k][m] + a[i][j] + a[k][l]);
						}
					}
					if(j != W - 1){
						if(k != H - 1){
							dp[i][k+1][m+1] = max(dp[i][k+1][m+1], dp[i][k][m] + a[i][j] + a[k][l]);
						}
						if(l != W - 1){
							dp[i][k][m+1] = max(dp[i][k][m+1], dp[i][k][m] + a[i][j] + a[k][l]);
						}
					}
				}
			}
		}
	}
	cout << dp[H-1][H-1][H-1+W-1] + a[H-1][W-1] << endl;
}


Measured memory_bytes: 66816