akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) x.begin(), x.end()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define fill(x,y) memset(x,y,sizeof(x))
#define endl "\n"
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
double eps = 1e-7;
ll mod = 1000000007;
ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

void solve()
{
	ll n, i, ans;
	double ma, mb;
	cin >> n;
	ll a[n], b[n];
	rep(i, 0, n)
	{
		cin >> a[i] >> b[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	if(n & 1)
		ans = b[n / 2] - a[n / 2] + 1;
	else
	{
		ma = (a[n / 2] + a[n / 2 - 1]) / (double)2.0;
		mb = (b[n / 2] + b[n / 2 - 1]) / (double)2.0;
		ans = (mb - ma) * 2LL + 1;
	}
	cout << ans << endl;
}

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

	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 6772
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

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

  REP(i, 3) {
    string s;
    cin >> s;
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if ((b - a) == (c - b))
			System.out.println("YES");
		else
			System.out.println("NO");
		sc.close();
	}
}

Measured memory_bytes: 21588
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int s;
  cin >> s;

  int a = 1e9;
  int d = s/a + (s%a>0);
  int b = 1;
  int c = a*d-s;

  cout << 0 SP 0 SP a SP b SP c SP d << endl;

  return 0;
}

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

typedef long long ll;

// 階乗 (mod 対応版)
ll factorial_mod(int n, int m) {
  long long ret = 1;
  for (int i = n; i > 0; --i) ret = (ret * i) % m;
  return ret;
}

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

  long long power = factorial_mod(N, 1000000007);

  cout << power << endl;
}

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

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

    vector<int> x(n);
    for(int i=0; i<n; i++){
        cin>>x.at(i);
    }

    int d_sum=0;

    for(int i=0; i<n; i++){
        if(x.at(i)<k-x.at(i)){
            d_sum+=x.at(i)*2;
        }else{
            d_sum+=(k-x.at(i))*2;
        }
    }

    cout<<d_sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector <int> g[100010];
bool v[100010];
vector <int> A, B;

void dfs(int x, vector <int> &arr) {
    v[x] = true;
    arr.push_back(x);
    for(auto i : g[x]) {
        if(v[i] == false) {
            dfs(i, arr);
            break;
        }
    }
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= m; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(1, A);
    reverse(A.begin(), A.end());
    for(auto i : g[1]) {
        if(v[i] == false) {
            dfs(i, B);
            break;
        }
    }
    printf("%d\n", (int) A.size() + B.size());
    for(auto i : A) {
        printf("%d ", i);
    }
    for(auto i : B) {
        printf("%d ", i);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 9720
#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 rrep(i, n) for(int i=((int)(n)-1); i>=0; i--)
#define ALL(a) (a).begin(), (a).end()
#define pb push_back
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}
ll INF = 1e18;

struct edge{
	ll to, cost;
};

int main(){
	ll N, M, S; cin >> N >> M >> S;
	vector<edge> G[125000];
	rep(i, M){
		ll u, v, a, b; cin >> u >> v >> a >> b;
		u--; v--;
		rep(j, 2500){
			if(j - a >= 0){
				G[u*2500+j].pb({v*2500+j-a, b});
				G[v*2500+j].pb({u*2500+j-a, b});
			}
		}
	}
	rep(i, N){
		ll c, d; cin >> c >> d;
		rep(j, 2500){
			if(j+c >= 2499){
				G[i*2500+j].pb({i*2500+2499, d});
			}else{
				G[i*2500+j].pb({i*2500+j+c, d});
			}
		}
	}
	priority_queue<P, vector<P>, greater<P> > pq;
	if(S >= 2500) S = 2499;
	pq.push(P(0, S));
	ll d[2500*N];
	rep(i, 2500*N) d[i] = INF;
	d[S] = 0;
	while(!pq.empty()){
		P p = pq.top(); pq.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		rep(i, G[v].size()){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				pq.push(P(d[e.to], e.to));
			}
		}
	}
	rep(i, N-1){
		ll ma = 1e18;
		rep(j, 2500) chmin(ma, d[2500*(i+1)+j]);
		cout << ma << "\n";
	}
	return 0;
}

Measured memory_bytes: 23740
//2020.1.22
//s1270188 xxxmk2
//alds1_11a

#include<stdio.h>
#define N 100

int main(){
  int data[N][N];
  int num, i, j, a, b, c;

  //input num
  scanf("%d",&num);

  //reset
  for(i=0;i<num;i++){
    for(j=0;j<num;j++) data[i][j]=0;
  }

  //input data
  for(i=0;i<num;i++){
    scanf("%d %d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&c);
      data[a-1][c-1]=1;
    }
  }

  //output
  for(i=0;i<num;i++){
    for(j=0;j<num-1;j++) printf("%d ",data[i][j]);
    printf("%d\n",data[i][j]);
  }

  return 0;
}



Measured memory_bytes: 2088
#include<iostream>
#include<string>
#include<vector>
#include<climits>
#include<cmath>

using namespace std;

int recur(string s,string t,int i,int j)
{
    if(i<0 || j<0)
        return 0;
    if(s[i]==t[j])
        return 1 + recur(s,t,i-1,j-1);
    return max(recur(s,t,i,j-1),recur(s,t,i-1,j));
}

void bottomup(string s,string t)
{
    int n1 = s.length(),n2 = t.length();
    vector<vector<int>> dp(n1+1,vector<int>(n2+1,0));
    for(int i=1;i<=n1;i++)
    {
        for(int j=1;j<=n2;j++)
        {
            if(s[i-1] == t[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
        }
    }
    // for(int i=1;i<=n1;i++)
    // {
    //     for(int j=1;j<=n2;j++)
    //         cout<<dp[i][j]<<" ";
    //     cout<<"\n";
    // }
    

    string ans="";
    int i=n1,j=n2;
    while(i>0 && j>0 )
    {
        if(s[i-1]==t[j-1])
        {
            ans = s[i-1] + ans;
            i--;
            j--;
        }
        else if(dp[i][j-1]>dp[i-1][j])
        {
            j--;
        }
        else
        {
            i--;
        } 
    }
    cout<<ans<<"\n";

}
int main()
{
    string s,t;
    cin>>s>>t;
    // int ans = recur(s,t,s.length()-1,t.length()-1);
    // cout<<ans;
    bottomup(s,t);
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

void read() {
	ll x;
	cin >> x;
	cout << 2 * acos(-1) * x << endl;
}

void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 3780
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

mod = 1000000007

"""
# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

# 商がより小さくなるような値を使っているという点では共通している
# 5 % -3 = -1 (-3 * -2 - 1)
# 4 % -3 = -1 (-3 * -2 - 2)
# 5 %  3 = 2  (3 * 1 + 2)
# 4 %  3 = 2  (3 * 1 + 1)

# -5 % -3 = -2 (-3 * 1 -2)

if __name__ == "__main__":
    N = int(sys.stdin.readline())
    ls = []
    if N == 0:
        print(0)
    else:
        while True:
            if N == 0:
                break
            if N % 2 == 0:
                ls.append("0")
            else:
                ls.append("1")
                # より小さくなるような商を取る仕様になっている
                # 従って、Nが負のときも-1することによって、より小さい商を取ることになる
                N -= 1
            N = N // -2
        ls.reverse()
        print("".join(ls))

Measured memory_bytes: 5204
from itertools import combinations, islice

N, K = map(int, input().split(' '))

M = (N - 1) * (N - 2) // 2

if K <= M:
	C = (N - 1) + (M - K)
	print(C)
	for a, b in islice(combinations(range(1, N + 1), r=2), C):
		print(a, b)
else:
	print(-1)


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
 cout<<max(max(a+b,a-b),a*b)<<endl;
  
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

k = 0
amax = max(a)
while n - 1 < amax:
    for i in range(n):
        if n - 1 < a[i]:
            d = a[i] // n
            k += d
            for j in range(n):
                if j == i:
                    a[j] -= d * n
                else:
                    a[j] += d
    amax = max(a)

print(k)

Measured memory_bytes: 42332
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pl, null_type,less<pl>, rb_tree_tag,tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define pld pair<long double,long double>
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define rep(i, begin, end) for (__typeof(begin) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define mod ((ll)(1e9+7))
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define in3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define inv(v) for(auto&i:v) in(i)
#define all(x) x.begin(), x.end()
#define vl vector<ll>
#define ml unordered_map<ll,ll> 
#define vpl vector<pair<ll,ll>>
#define INF 0x3f3f3f3f
 
template<typename T, typename TT>
ostream& operator<<(ostream &os, const pair<T, TT> &t) { return os<<t.first<<" "<<t.second; }
template<typename T>
ostream& operator<<(ostream& os, const vector<T> &t) { for(auto& i: t) os<<i<<" "; return os; }

int main() {
    // fast;
    // int t; scanf("%d",&t);
    // while(t--) {
    // }
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans =0;
    ans = min(k,a);
    k-=ans;
    if(k) k-=min(k,b);
    if(k) ans-=k;
    cout<<ans<<endl;
    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 100100;

int n, cnt[M];
bool can[M];

void read() {
  cin >> n;
  can[1] = true;
  fill(cnt + 1, cnt + (n + 1), 1);
}


void kill() {
  int m;
  cin >> m;

  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    
    can[y] |= can[x];

    cnt[y]++, cnt[x]--;

    can[x] &= cnt[x] > 0;
  }

  int ans = 0;
  for (int i = 1; i <= n; ++i)
    ans += can[i] ? 1 : 0;

  cout << ans << endl;
}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, x; cin >> n >> x;
    vector<ll> a(n); cin >> a;
    vector<ll> b = a;
    ll ans = linf;
    rep(i, n) {
        rep(j, n) {
            chmin(b[j], a[(j+i)%n]);
        }
        ll sum = 0;
        rep(j, n) sum += b[j];
        chmin(ans, sum + x * i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    int N, K, i, s = 1;
    
    scanf("%d %d", &N, &K);
    
    for(i = 0; i < N; i++){
        if(s * 2 <= s + K){
            s = s * 2;
        }else if(s * 2 > s + K){
            s = s + K;
        }
    }
    printf("%d\n", s);
    
}


Measured memory_bytes: 1680
S = input()
x = ['A', 'C', 'T', 'G']

i = 0
count = 0
ans = 0
while i < len(S):
    if S[i] in x:
        count += 1
        ans = max(ans, count)
    else:
        count = 0
    i += 1
print(ans)


Measured memory_bytes: 9000
/*
	Created by Faisal Ahmed
*/

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n, arr[200010];
	
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	//	if(temp[arr[i]] == 0) temp[arr[i]] = i;
	}
	
//	sort(arr + 1, arr + n + 1);
	
	int cnt = 0, curr = 1;
	for(int i = 1; i <= n; i++){
		if(arr[i] == curr){
		//	cout << i << " " << arr[i] << endl;
			cnt++;
			curr++;
		}
	}

	if(cnt > 0) cout << n - cnt << endl;
	else cout << -1 << endl;	
	
	return 0;
} 

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ma = sc.nextInt();
        int mb = sc.nextInt();
        int[][] a = new int[n][3];
        int amax = 0;
        int bmax = 0;
        for (int i = 0; i < n; i++) {
            a[i][0] = sc.nextInt();
            a[i][1] = sc.nextInt();
            a[i][2] = sc.nextInt();
            amax += a[i][0];
            bmax += a[i][1];
        }
        int[][] dp = new int[amax+1][bmax+1];
        for (int i = 0; i < amax+1; i++) {
            Arrays.fill(dp[i], Integer.MAX_VALUE/2);
        }
        dp[0][0] = 0;
        for (int k = 0; k < n; k++) {
            for (int i = amax; i >= 0; i--) {
                if(i - a[k][0] < 0)continue;
                for (int j = bmax; j >= 0; j--) {
                    if(j - a[k][1] < 0)continue;
                    if(dp[i-a[k][0]][j-a[k][1]] + a[k][2] < dp[i][j]) dp[i][j] = dp[i-a[k][0]][j-a[k][1]] + a[k][2];
                }
            }
        }
        int r = 1;
        int ans = Integer.MAX_VALUE;
        while(ma*r <= amax && mb*r <= bmax){
            if(dp[ma*r][mb*r] < ans) ans = dp[ma*r][mb*r];
            r++;
        }
        System.out.println(4000 < ans ? -1 : ans);
        sc.close();

    }

}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);


int main()
{
	ll n,i,j;
	cin >> n;
	vector<ll>v,vv;
	map<ll,ll>mp;
	map<ll,ll>::iterator it;
	ll mx=0,mn=1e9;
	rep(i,n)
	{
		ll m;
		lsc(m);
		mp[m]++;
		vv.pb(m);
		mx=max(mx,m);
		mn=min(mn,m);
	}
	
	if(n==1)
	{
		cout << 1 << endl;
		return 0;
	}
	if(mn==mx)
	{
		cout << 0 << endl;
		return 0;
	}
	for(it=mp.begin();it!=mp.end();it++)
	{
		if((it->second)==1)
		{
			v.pb(it->first);
		}
	}
	ll sz=v.size();
	for(i=0;i<n;i++)
	{
		ll k=vv[i];
		for(j=(2LL*k);j<=mx;j+=k)
		{
			if(mp[j]==1)
			{
				sz--;
				mp[j]=0;
			}
		}
	}
	cout << sz << endl;
	return 0;
}


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

public class Main{
    public static void main(String arg[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int count;
        for(int i=0;i<n;i++){
            count=0;

            int[] data=new int[9];
            for(int j=0;j<9;j++)data[j]+=sc.nextInt();
            //十の位を定める(B,G,R)
            for(int j=0;j<9;j++){
                String str=sc.next();
                if(str.equals("B"))data[j]+=1*10;
                else if(str.equals("G"))data[j]+=2*10;
                else data[j]+=3*10;
            }
            Arrays.sort(data);
            if( ( data[0]==data[1] && data[1]==data[2] ) || ( data[1]==(data[0]+1) && data[2]==(data[1]+1) ) )count++;
            if( ( data[3]==data[4] && data[4]==data[5] ) || ( data[4]==(data[3]+1) && data[5]==(data[4]+1) ) )count++;
            if( ( data[6]==data[7] && data[7]==data[8] ) || ( data[7]==(data[6]+1) && data[8]==(data[7]+1) ) )count++;
            if( ( data[0]==data[1] && data[2]==data[3] && data[4]==data[5] ) || ( data[3]==data[4] && data[5]==data[6] && data[7]==data[8] ) )count+=2;
            if(count>=3)System.out.println(1);
            else System.out.println(0);
        }
        sc.close();
    }
}


Measured memory_bytes: 28832
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define cps CLOCKS_PER_SEC
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
#define MOD 1000000007
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
int power(int x,int y){ int res = 1; while(y>0){   if(y&1) res = (res*x)%MOD;
        y >>= 1; x = (x*x)%MOD; } return res; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;

bool check(int mid,int x,int y){
    int ret = 0;
    for(int i=max(mid/2-100,1LL);i<=min(mid/2+100,mid);i++){
        int a = i,b = mid-i+1;
        if(a >= x) a++;
        if(b >= y) b++;
        ret = max(ret,a*b);
    }
    return ret < x*y;
}

void solve(){
    int q; cin>>q;

    while(q--){
        int x,y; cin>>x>>y;

        int s = 1,e = 3e9;
        int ans = 0;

        while(s <= e){
            int mid = (s+e)>>1;
            if(check(mid,x,y)) ans = mid,s = mid+1;
            else e = mid-1;
        }

        cout<<ans<<endl;
    }
}
 
signed main(){

    FastRead; 


    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    map<ll, ll, greater<> > m;
    for (ll i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        m[a]++;
    }
    ll a;
    for (auto&& p : m)
    {
        if (p.second > 1)
        {
            p.second -= 2;
            a = p.first;
            break;
        }
    }
    for (auto &&p : m)
    {
        if (p.second > 1)
        {
            cout << a * p.first << endl;
            exit(0);
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int N,i;
  vector<int> A;
  for(i=0;i<3;i++){
    cin>>N;
    A.push_back(N);
  }
  sort(A.begin(),A.end());
  cout<<(A[2]-A[1])+(A[1]-A[0]);
  cout<<endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main(void){
   
   int height,width;
   

    cin >> height >> width;

   int A[height][width];
   int B[width];

   for(int i=0; i<height; i++){
      for(int j=0; j<width; j++){
        cin >> A[i][j];
      }
   }
   for(int i=0; i<width; i++)
        cin >> B[i];

   for(int i=0; i<height; i++){
      int calc = 0;

      for(int j=0; j<width; j++){
        calc += A[i][j] * B[j]; 
      }

      cout << calc << endl;
   }


   return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vector<vector<int>> a(3, vector<int>(3)), used(3, vector<int>(3, 0));
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            cin >> a[i][j];

    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 3; k++){
                if (a[j][k] == x)
                    used[j][k] = 1;
            }
        }
    }
    
    vector<int> x({1, 1, 0, -1}), y({0, 1, 1, 1});
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            if (used[i][j] == 1){
                for (int k = 0; k < (int) x.size(); k++){
                    int xx = i + x[k], yy = j + y[k];
                    int cnt = 1;
                    while (xx >= 0 && xx < 3 && yy >= 0 && yy < 3){
                        if (used[xx][yy] == 1)
                            cnt += 1;
                        xx = xx + x[k];
                        yy = yy + y[k];
                    }

                    if (cnt == 3){
                        cout << "Yes\n";
                        return 0;
                    }
                }
            }
        }
    }
    
    cout << "No\n";

    return 0;
}


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

int a[105];
int main() {
  int n,m;
  cin>>n>>m;
  int x=0;
  int s=0;
  for(int i=1;i<=n;i++) {
    cin>>a[i];
    s+=a[i];
  }
  for(int i=1;i<=n;i++) {
    if(a[i]>=1.0*s/(m*4)) {
      x++;
    }
  }
  if(x>=m) {
    cout<<"Yes";
  }else {
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 256
def main():
    S = input()
    from collections import deque
    S = deque(S)
    ans = 0
    while S:
        if S[0] == S[-1]:
            S.popleft()
            if S:
                S.pop()
        elif S[0] != "x" and S[-1] != "x":
            return print(-1)
        elif S[0] == "x":
            S.append("x")
            ans += 1
        else:
            S.appendleft("x")
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int flag;
int bo = 0;
int max = 0;
int minu = 0;
long long a,b,oa,ob;
int tot = 1;
//int sosu[100000];

int main(void){
    cin >> a >> b;

    if(a <= b){
        minu = a;
    }else{
        minu = b;
    }
	
  	oa = a;
    ob = b;
  
    for(int i = 2; i<=minu; i++){
        while((a % i == 0) && (b%i == 0)){
            a /= i;
            b /= i;
            tot *= i;
        }
    }

  	long long out = oa * ob / tot;
  	printf("%ld\r\n", out);
  
}

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

 
 
using namespace std;
 
 
 
 
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}

	long long sum=1;
	for(int i=0; i<n; i++){
		if (a[i]%2==0) sum=sum*2;
	}

	cout<< pow(3,n)-sum<<endl;
	
 
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int h,n;
    scanf("%d %d",&h,&n);
    int res = 0;
    for (int i = 0; i < n; i++) {
        int tmp;
        scanf("%d",&tmp);
        res += tmp;
    }    
    if (res < h) printf("No\n");
    else printf("Yes\n");
}

Measured memory_bytes: 256
s = gets.chomp
up = [0]
down = [0]
tmp = 0

s.each_char do |c|
  c == '<' ? tmp += 1 : tmp = 0
  up << tmp
end

tmp = 0

s.reverse.each_char do |c|
  c == '>' ? tmp += 1 : tmp = 0
  down << tmp
end

size = s.size + 1

puts size.times.map { |i| [up[i], down[size - 1 - i]].max }.inject(:+)

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

int main()
{
  double a,b,C;
  cin >> a >> b >> C;
  double S=a*b*sin((C*M_PI)/180.0)/2.0;
  double L=a+b+sqrt(a*a+b*b-2*a*b*cos((C*M_PI)/180.0));
  double h=b*sin((C*M_PI)/180.0);

  cout << fixed << S << endl << L << endl << h << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
int main(){
    int n, card[4][13] = {0}, x;
    char s;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf(" %c %d", &s, &x);
        if (s == 'S'){
            card[0][x - 1] = 1;
        }else if (s == 'H'){
            card[1][x - 1] = 1;
        }else if (s == 'C'){
            card[2][x - 1] = 1;
        }else if (s == 'D'){
            card[3][x - 1] = 1;
        }
    }
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 13; j++){
            if (card[i][j] == 0){
                if (i == 0){
                    printf("S %d\n", j + 1);
                }else if(i == 1){
                    printf("H %d\n", j + 1);
                }else if(i == 2){
                    printf("C %d\n", j + 1);
                }else if(i == 3){
                    printf("D %d\n", j + 1);
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2064
#!/usr/bin/env python3
import sys


def solve(K: int):
    ret = (K // 2) * ((K + 1) // 2)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


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

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

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

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

   cout << lcm(360, x)/x << endl;
   return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;

class UnionFind{
public:
	vector<ll> par;
	vector<ll> d;
	//0-indexed
	UnionFind(ll n){
		init(n);
	}
	void init(ll n = 1) {
		par.resize(n);
		d.resize(n,0);
		for (ll i = 0; i < n; ++i) par[i] = i;
	}
	ll len1(ll x){
		if(par[x]==x)return 0;
		ll ans = d[x];
		ans += len1(par[x]);
		return ans;
	}
	ll root(ll x = 1){
		if(par[x]==x)return x;
		else{
			d[x] = len1(par[x]) + d[x];
			return par[x] = root(par[x]);
		}
	}
	ll length(ll x,ll y){
		return len1(y) - len1(x);
	}
	void unite(ll x,ll y,ll dd){
		while(par[x]!=x){dd+=d[x];x=par[x];}
		while(par[y]!=y){dd-=d[y];y=par[y];}
		if(x==y)return;
		if(dd>=0){
			d[y] = dd;
			par[y] = x;
		}else{
			d[x] = -dd;
			par[x] = y;
		}
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	//ifstream in("input.txt");
	//cin.rdbuf(in.rdbuf());
	ll n,m;
	cin >> n >> m;
	UnionFind uf(n+1);
	ll l,r,d;
	FOR(i,0,m){
		cin >> l >> r >> d;
		if(uf.root(l)==uf.root(r)){
			if(uf.length(l,r)!=d){
				cout << "No" << endl;
				return 0;
			}
		}else{
			uf.unite(l,r,d);
			//cout << uf.length(l,r) << endl;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iostream>
#define LL long long int
#define FOR(a,b) for(int a=1;a<b;a++)
using namespace std;
LL n,game[201][201],hito[201],g;
int main(){
            cin >> n;
        FOR(a,n+1)
        FOR(b,4){
            cin >> g;
            if(game[b][g]<1)game[b][g]=a;
            else{
                game[b][g]=300;
            }
        }
        FOR(a,4){
            FOR(b,101){
                if(game[a][b]!=0||game[a][b]!=300)
                hito[game[a][b]]+=b;
            }
        }
        FOR(a,n+1)cout << hito[a] << endl;

return 0;
}

Measured memory_bytes: 1168
import java.util.Scanner;

public class Main {

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

		if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}

		sc.close();

	}

}

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

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define For(i, a) for (int i=0; i<a; i++)
#define FORR(i,a,b) for (int i = a; i >= b; i--)
#define Forr(i,a) for (int i = a; i >= 0; i--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args)
{cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }
const int INF=1e9;

void solve(){
  string s,t; cin >> s >> t;
  int mn=INF;
  for(int i=0;i<s.length();i++){
    int cnt=0;
    for(int j=0;j<t.length();j++){
      if(i+j<s.length()){
        if(t[j]!=s[i+j]){
          cnt++;
        }
      }
      else cnt=INF;
    }
    mn=min(mn,cnt);
  }
  cout << mn << "\n";
}

int32_t main(){
  ios_base:: sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  for(int tt=1;tt<=t;tt++){
    solve();
  }
}

Measured memory_bytes: 3656
/*Be patient && calm!
All our dreams can come true, if we have the courage to pursue them.
The secret of getting ahead is getting started.
It is hard to beat a person who never gives up.
First, solve the problem. Then, write the code.
Fix the cause, not the symptom.
Simplicity is the soul of efficiency.
Make it work, make it right, make it fast.*/
#include "iostream"
#include "vector"
#include "algorithm"
#include "queue"

using namespace std;
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i = j; i < k; i += step)
#define loop(i, j, k) for (int i = j; i < k; i++)
#define rloop1(i, j, k, step) for (int i = j; i >= k; i -= step)
#define rloop(i, j, k) for (int i = j; i >= k; i--)
#define rep(i, k) for (int i = (0); i < (k); i++)
#define rrep(i, k) for (int i = k - 1; i >= 0; i--)
#define forall(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define lin "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)
#define PI 2 * acos(0.0)
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// bool sortinrev(const pair<int, int> &a,
//                const pair<int, int> &b)
// {
//     return (a.first > b.first);
// }
// bool spOrder(const pair<int, int> &a,
//              const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first > b.first;
//  }
int a[2 * N];
queue<int> b;
ll Sum[2 * N];

void pSum(int n) {
    Sum[0] = a[0];
    for (int i = 1; i < n; ++i) {
        Sum[i] = Sum[i - 1] + a[i];
    }

}

void solve() {
    ll n, m, k;
    cin >> n >> m >> k;
    ll aSum = 0, bSum = 0;
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, m) {
        int x;
        cin >> x;
        bSum += x;
        b.push(x);
    }
    pSum(n);
    int pos = 1;
    int ans = distance(Sum, upper_bound(Sum, Sum + n, k));
    while (!b.empty() && k > 0) {
        k -= b.front();
        int x = distance(Sum, upper_bound(Sum, Sum + n, k));
        if (k >= 0)
            ans = max(ans, x + pos);
        b.pop();
        pos++;
    }
    cout << ans << lin;
}

int main() {
    // auto start = clock();
    fast_io;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    // auto stop = clock();
    // cerr << "time taken:" << double(stop - start) / double(CLOCKS_PER_SEC) << " s" << endl;
    return 0;
}

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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;
constexpr double PI=3.14159265358979323846;




int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,m;
    cin >> n >> m;
    graph g(n+1);

    int one,two;
    rep(i,m){
        cin >> one >> two;
        g[one].push_back(two);
        g[two].push_back(one);
    }
  
    vector<int> dist(n+1,INF);
    vector<int> to(n+1,0);
    dist[1]=0;
    queue<int> next;
    vector<bool> seen(n,false);
    int site;
    next.push(1);
    while(!next.empty()){
        site=next.front();
        next.pop();
        if(seen[site-1]) continue;
        seen[site-1]=true;
        for(auto v : g[site]){
            if(dist[site]>dist[v]+1){
                to[site]=v;
                dist[site]=dist[v]+1;
            }
            if(!seen[v-1]) next.push(v);
        }
    }

    cout << "Yes" << "\n";
    fr(i,2,n+1){
        cout << to[i] << "\n";
    }
    
}   

Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=3010;
int C[maxn][maxn],S[maxn][maxn];
inline int qpow(int base,int _pow,int m){
	int res=1;
	while(_pow){
		if(_pow&1) res=(ll)res*base%m;
		_pow>>=1;
		base=(ll)base*base%m;
	}
	return res;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	S[0][0]=1;
	for(int i=1;i<=n+1;i++)
		for(int j=1;j<=i;j++)
			S[i][j]=((ll)S[i-1][j]*j+S[i-1][j-1])%m;
	C[0][0]=1;
	for(int i=1;i<=n+1;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%m;
	}
	int ans=0;
	for(int i=0;i<=n;i++){
		int add=0;
		for(int j=0;j<=i;j++)
			add=(add+(ll)S[i+1][j+1]*qpow(qpow(2,n-i,m),j,m))%m;
		add=(ll)add*C[n][i]%m*qpow(2,qpow(2,n-i,m-1),m)%m;
		if(i&1) ans=(ans+m-add)%m;
		else ans=(ans+add)%m;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 69632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)


int main() {
    string s, ans;
    cin >> s;
    ans = s[0] + s[1] + s[2];
    cout << s[0] << s[1] << s[2] << endl;
}

Measured memory_bytes: 3596
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static final String EOF = "END_OF_TEXT";
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String keyWord = sc.nextLine().toLowerCase();
      int count = 0;
      String[] strArr;
      boolean exit = false;
      
      while(!exit){
         strArr = sc.nextLine().split(" ");
         for(int i = 0; i < strArr.length; i ++){
            
            //end of loop
            if(strArr[i].equals(EOF)){
               exit = true;
               break;
            }
            
            //if not the end of the string
            if(strArr[i].toLowerCase().equals(keyWord)){
               count++;
            }
            
         }
      }
      System.out.println(count);
   }//main
   
   
}//class


Measured memory_bytes: 26100
#include<stdio.h>
int main()
{
    int n;
    int a[10]={0,2,4,8,16,32,64};
    while (~scanf("%d",&n))
    {
        int t;
        for(int i=0;i<7;i++)
        {
            if(n>=a[i])
                t=a[i];
            else
                break;
        }
        if(n==1)
            printf("1\n");
        else
        printf("%d\n",t);
    }
}

Measured memory_bytes: 256
#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;
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(void){
  string s,t; cin >> s >> t;
  int ans = 0;
  rep(i,s.size()){
    if(s.at(i) != t.at(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3916
# -*- coding: utf-8 -*-
while True:
    a, op, b= input().split(" ")
    a = int(a)
    b = int(b)
    
    if op == "?":
        break
    elif op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)

Measured memory_bytes: 7660
//#pragma GCC optimize("O-fast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma comment(linker, "/STACK:367077216")

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define pii pair<int, int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define pop pop_back

vector <int> c;
vector <vector <int>> a;
int n, m, x;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> m >> x;
	c.resize(n);
	a.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
		for (int j = 0; j < m; ++j) {
			int x; cin >> x;
			a[i].push_back(x);
		}
	}
	int ans = 1000000000;
	vector <int> check(m, 0);
	for (int mask = 0; mask < (1 << n); ++mask) {
		int cost = 0;
		for (int i = 0; i < n; ++i) {
			if (mask & (1 << i)) {
				cost += c[i];
				for (int j = 0; j < m; ++j) {
					check[j] += a[i][j];
				}
			}
		}
		bool ok = true;
		for (int i = 0; i < m; ++i) {
			if (check[i] < x) {
				ok = false;
				break;
			}
		}
		if (ok) {
			ans = min(ans, cost);
		}
		fill(all(check), 0);
	}
	cout << ((ans == 1000000000) ? -1 : ans);
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i] >> b[i];

  ll t = 0;

  for (int i = n - 1; i >= 0; --i)
  {
    if ((t + a[i]) % b[i] == 0)
      continue;
    else
    {
      t += ((a[i] + t) / b[i] + 1) * b[i] - (a[i] + t);
    }
  }

  cout << t << endl;

  return 0;
}


Measured memory_bytes: 1792
#ss
s = input() 
if ( len(s)%2 ==1 ):
    s = s[:-1]
else:
    s = s[:-2]

while 1:
    l = int(len(s)/2)
    if (s[:l]==s[l:] ):
        print(l*2)
        break
    else:
        s = s[:-2]
    if ( len(s)==0 ):
        break

Measured memory_bytes: 3060
def com_div(x, y):
    dv = []
    m = min(x, y)
    for i in range(1, m + 1):
        if x % i == 0 and y % i == 0:
            dv.append(i)
    dv.sort()
    return dv[::-1]


a, b, k = list(map(int, input().split()))
print(com_div(a, b)[k - 1])

Measured memory_bytes: 8968
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb emplace_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<int, pii>
#define puu pair<ULL, ULL>
#define pdd pair<long double, long double>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e5 + 10;
int a[N], n;
LL ans[N];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	LL tot = 0;
	for (int i = n; i >= 1; --i) {
		if(i%2) tot += a[i]*2LL;
		else tot -= a[i]*2LL;
	}
	ans[1] = tot/2;
	for (int i = 2; i <= n; ++i) ans[i] = 2LL*a[i-1]-ans[i-1];
	for (int i = 1; i <= n; ++i) printf("%lld%c", ans[i], " \n"[i==n]);
	return 0;
}
/*
a[i] = x[i+1]/2+x[i]/2;
2*a[i] = x[i+1] + x[i];
x[1];
x[2] = 2*a[1]-x[1]
x[3] = 2*a[2]-x[2] = 2*a[2]-2*a[1]+x[1]

x[n+1] = 2*a[n]-2*a[n-1]+2*a[n-2] + ... - x[1]
*/

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

int main(void)
{
  string str;
  cin >> str;

  if (str[2] == str[3] && str[4] == str[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256