akhauriyash/Code-Regression huggingface dataset:
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int w, h;
	while(cin >> w >> h){
		if(w == 0 && h == 0)break;
		for(int i = 0; i < w; i++){
			for(int j = 0; j < h; j++)cout << '#';
			cout << '\n';
		}
		cout << '\n';
	}
	return 0;
}



Measured memory_bytes: 3116
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (int i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (int i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

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

    ll n, d;
    cin >> n >> d;
    ll x, y, ans = 0;
    REP(i, 0, n)
    {
        cin >> x >> y;
        if (x * x + y * y <= d * d)
            ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;

inline ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
inline void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}

int main()
{
	ri a,b;cin>>a>>b;
	--b;--a;
	if(b%a==0) cout<<b/a;
	else cout<<b/a+1;
	return 0; 
}

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

using namespace std;

template<typename T>
struct BIT {
  int size;
  vector<T> node;
  BIT(int n) {
    size = n+1;
    node.assign(n+1, 0);
  }
  void add(int idx, int x) {
    for (int i = idx; i < size; i += (i & -i)) {
      node[i] += x;
    }
  }
  T sum(int idx) {
    T ret = 0;
    for (int i = idx; i > 0; i -= (i & -i)) {
      ret += node[i];
    }
    return ret;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main() {
  int n, q;
  string s;
  cin >> n >> s >> q;

  vector<BIT<int>> trees(26, BIT<int>(n+10));
  for (int i = 0; i < n; i++) {
    trees[s[i]-'a'].add(i+1, 1);
  }
  while (q--) {
    int type; cin >> type;
    if (type == 1) {
      int idx; char c; cin >> idx >> c;
      int prev_c = s[idx-1] - 'a';
      int next_c = c - 'a';
      trees[prev_c].add(idx, -1);
      trees[next_c].add(idx, 1);
      s[idx-1] = c;
    }
    if (type == 2) {
      int l, r; cin >> l >> r;  // [l, r]
      //cout << "l, r: " << l << "  " <<r << endl;
      int ret = 0;
      for (int i = 0; i < 26; i++) {
        if (trees[i].sum(l, r+1) != 0) {
          //cout << (char)('a' + i) << endl;
          ret++;
        }
      }
      cout << ret << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 53636
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const ll M = 1000000000 + 7;
#define MAX_N 1000000

vector<ll> fac(MAX_N+1);
vector<ll> ifac(MAX_N+1);

ll mpow(ll x,ll n){
	if(n == 0) return 1;
	if( n % 2 == 0) return mpow(x*x % M,n/2);
	return (mpow(x,n-1)*x) % M;
}

void combInit(){
	fac[0] = 1;
	ifac[0] = 1;
	for(ll i = 0; i < MAX_N; i++){
		fac[i+1] = fac[i]*(i+1) % M;
		ifac[i+1] = ifac[i]*mpow(i+1,M-2) % M;
	}
}

ll comb(ll a,ll b){
	if(a==0 && b == 0) return 1;
	if(a < b || a < 0) return 0;
	ll tmp = ifac[a-b] * ifac[b] % M;
	return tmp * fac[a]%M;
}

int main()
{
	ll X,Y;
	cin>>X>>Y;
	ll a,b;
	a = (2*X - Y)/3;
	b = (2*Y - X)/3;
	combInit();
	if( (2*X - Y) >= 0 && (2*Y - X) >= 0 && (2*X - Y) % 3 == 0 && (2*Y - X) % 3 ==0){
		cout<<comb((a+b),a)<<endl;
	}else{
		cout<<0<<endl;
	}
	
	return 0;
}



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

int n;
vector<int> a(11);
vector<vector<int>> b;

void dfs(int t, vector<int> v = vector<int>()) {
  if ((int)v.size() >= n) {
    b.push_back(v);
    return;
  }
  for (int i=-1; i<=1; i++) {
    v.push_back(a[t]-i);
    dfs(t+1, v);
    v.pop_back();
  }
}

int main()
{
  cin >> n;
  rep(i, n) cin >> a[i];
  dfs(0);
  int ans = 0;
  for (auto v:b) {
    for (auto c:v) {
      if (c%2==0) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLL = vector<PLL>;
using VPLD = vector<PLD>;

const int IINF = numeric_limits<int>::max();

int main() {

    LL n, h;
    cin >> n >> h;
    VLL a(n), b(n);
    REP(i,n) cin >> a[i] >> b[i];

    sort(a.begin(), a.end());
    sort(b.rbegin(), b.rend());

    LL ans = 0;
    REP(i,n) {
        if (b[i]>a[n-1]) {
            h -= b[i];
            ans++;
            if (h<=0) {
                cout << ans << endl;
                return 0;
            }
        }
    }

    ans += (h+a[n-1]-1)/a[n-1];
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4836
from itertools import permutations as perm
n,m = map(int,input().split())
coor = [[False]*n for _ in range(n)]
for i in range(m):
	a,b = map(int,input().split())
	a,b = a-1,b-1
	coor[a][b] = True
	coor[b][a] = True
ll = list(range(n))
res = 0
for l in perm(ll):
	if l[0]!=0:
		continue
	for (i,j) in zip(l,l[1:]):
		if not coor[i][j]:
			break
	else:
		res += 1
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 


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

int N, M;cin >> N >> M;
VI s(M), c(M); rep(i, 0, M) cin >> s[i] >> c[i];

if (N == 1){
    rep(n, 0, 10){
        bool ok = true;
        rep(i, 0, M) if (n != c[i]) ok = false;
        if (ok){
            cout << n << "\n";
            return 0;
        }
    }
}
else {
    rep(n, pow(10, N-1), pow(10, N)){
        bool ok = true;
        rep(i, 0, M){
            if (n / (i64)pow((i64)10, N-1 - (s[i]-1)) %10 != c[i]) ok = false;
        }
        if (ok){
            cout << n << "\n";
            return 0;
        }
    }
}

cout  << "-1\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



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

// 計算済みの結果は再利用するようにする。
public class Main {

    private int redNum;
    private int blueNum;
    private static long MOD = (long)(Math.pow(10,9) + 7);
    private static int ARRAY_NUM = 2048;
    private long[][] memo = new long[ARRAY_NUM][ARRAY_NUM];

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        redNum = N - K;
        blueNum = K;

        for (int i = 0; i < ARRAY_NUM; i++) {
            for (int j = 0; j < ARRAY_NUM; j++) {
                memo[i][j] = -1;
            }
        }
        for (int i = 1; i <= K; i++) {
            double count = calcCount(i);
            System.out.println((int)(count));
        }
    }

    private long calcCount(int i) {
        long posCntToPlaceBlue = calcNumOfCombination(redNum + 1, i);
        long splitCntOfBlue = calcNumOfCombination(blueNum - 1, i - 1);
        long ansCount = posCntToPlaceBlue * splitCntOfBlue % MOD;
        //long ansCount = posCntToPlaceBlue * splitCntOfBlue;
        return ansCount;
    }

    // 計算結果をmodしても、先にmodしてから計算しても、結果は同じ。
    private long calcNumOfCombination(int n, int r) {
        if (n == r) {
            memo[n][r] = 1;
            return memo[n][r];
        }
        else if (n < r) {
            memo[n][r] = 0;
            return memo[n][r];
        }
        else if (memo[n][r] != -1) {
            return memo[n][r];
        }
        else if (memo[n][n - r] != -1) {
            return memo[n][n - r];
        }
        else {
            BigInteger result = BigInteger.valueOf(1);
            for (int i = 1; i <= r; i++) {
                result = result.multiply(BigInteger.valueOf(n - (i - 1))).divide(BigInteger.valueOf(i));
            }
            memo[n][r] = result.mod(BigInteger.valueOf(MOD)).longValue();
            return memo[n][r];
        }
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 161768
/*input

*/
#ifdef UncleGrandpa
#include <prettyprint.hpp>
#endif
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp ' '
#define fi first
#define se second
#define bit(x,y) ((x>>y)&1)
#define loop(i,l,r) for(int i=(l); i<=(r); i++)
#define rloop(i,l,r) for(int i=(l); i>=(r); i--)
#define debug(x...) {cout << "[" << #x << "] ="; _print(x);}
void _print() {cout << endl;}
template<typename T, typename... Ts> void _print(const T& value, const Ts&... values) {cout << ' ' << value; _print(values...);}
template<typename T, typename... Ts> void print(const T& value, const Ts&... values) {cout << value; _print(values...);}
// change cout to cerr for debug in crash
// for struct, can write print operator to use print() (even with SegTree)
// const int N =;

int A, B;

bool ask(int x, int y) {
	cout << "?" << sp << x << sp << y << endl;
	char c; cin >> c;
	return (c == 'Y');
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> A >> B;
	if (A <= B) {
		cout << "Impossible" << endl;
		exit(0);
	}
	stack<int> st;
	loop(i, 0, A + B - 1) {
		if (st.empty()) {
			st.push(i);
			continue;
		}
		auto rec = ask(st.top(), i);
		if (!rec) st.pop();
		else st.push(i);
	}
	int piv = st.top();
	string s;
	loop(i, 0, A + B - 1) {
		if (ask(piv, i)) s += "1";
		else s += "0";
	}
	cout << "! " << s << endl;
}

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

int main() {
  int n;
  cin >> n;
  int count = 0;
  int prev;
  cin >> prev;
  int num = 1;
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    if (a == prev) {
      num++;
    } else {
      count += num / 2;
      num = 1;
    }
    if (i == n - 1) {
      count += num / 2;
      num = 1;
    }
    prev = a;
  }
  cout << count << endl;
  return 0;
}


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

int main() {
	long int in, hour, seconds, minuites, m;
	std::cin >> in;
	seconds = in % 60;
	m = in / 60;
	minuites = m % 60;
	hour = m / 60;
	std::cout << hour << ":" << minuites << ":" << seconds << std::endl;
	return 0;
}

Measured memory_bytes: 3084
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
	let S = read_line();
	let S = S.split("").collect::<Vec<&str>>();
	let mut flag:bool = true;
	for i in 1..(S.len()-1) {
		for j in 1..(S.len() - 1) {
			if i == j {
				continue;
			}
			if S[i] == S[j].to_string() {
				flag = false;
				break;
			}
 		}
	}
	if flag == true {
		println!("yes");
	}else{
		println!("no");
	}
}


Measured memory_bytes: 4352
N, L = map(int, input().split())
T = 0
for i in range(N):
    T += L + i

ans = 0
mina = 10**9
for i in range(N):
    tmp = T - L - i
    if mina > abs(tmp - T):
        ans = tmp
        mina = abs(tmp - T)
print(ans)

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
    if (ch == 'A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    
    return sum;
}

int h1(int key) {
    return key % M;
}

int h2(int key) {
    return 1 + (key % (M - 1));
}

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0;;i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0 ) return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++) {
        H[i][0] = '\0';
    }
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%s %s", com, str);
        
        if (com[0] == 'i') {
            insert(str);
        }
        else {
            if (find(str)) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 17068
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

int main(){
    int n,m;cin>>n>>m;
    vpii v(n);
    rep(i,n){
        int a,b;cin>>a>>b;
        v[i]=mp(a,b);
    }
    sort(all(v));
    ll sum=0;
    ll ans=0;
    rep(i,n){
        if(sum+v[i].second<m){
            ans+=(ll)v[i].first*v[i].second;
            sum+=(ll)v[i].second;
        }
        else{
            ans+=(ll)v[i].first*(m-sum);
            break;
        }
    }
    cout<<ans<<endl;
}

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

int map[12][12];

int main(){
	int n;
	while(cin >> n, n){
		int solve = 0;
		for(int i=0; i < n; i++){
			for(int j=0; j < n; j++){
				cin >> map[i][j];
			}
		}

		for(int i=0; i < n; i++){
			int total = 0;
			for(int j=0; j < n; j++){
				printf("%5d", map[i][j]);
				total += map[i][j];
			}
			printf("%5d\n", total);
			map[i][n+1] = total;
		}
		for(int j=0; j < n; j++){
			int total = 0;
			for(int i=0; i < n; i++){
				total += map[i][j];
			}
			printf("%5d", total);
			solve += total;
		}
		printf("%5d\n", solve);
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int  main()
{
int a,b,c,d;
scanf("%d %d %d %d",&a,&b,&c,&d);
int f=min(a,b);
int g=min(c,d);
printf("%d\n",f+g);
    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
int k[1111];
string s[1111];

void dfs(int d,int dd){
	while(1){
		int ni=-1;
		rep(i,n){
			if(k[i]==d){
				ni=i;
				break;
			}
		}
		if(ni==-1)return;
		rep(i,dd)cout<<".";
		cout<<s[ni]<<endl;
		k[ni]=-1;
		dfs(ni+1,dd+1);
	}
}

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n)cin>>k[i]>>s[i];
	dfs(0,0);
	return 0;
}

Measured memory_bytes: 3364
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string input;
	cin>>input;
	size_t found = input.find("7");
	if (found!=string::npos)
    	cout << "Yes" << endl;
    else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 3652
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);

int main(){
    int A, B;
    cin >> A >> B;
    cout << MAX(A+(A-1),MAX(A+B,(B+(B-1))));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    string s;
    cin>>s;
    bool ok=true;
    for (int i = 0; i < s.size(); i+=2)
    {
        /* code */
        if(s[i]=='L'){
            ok=false;
            break;
        }
    
    }
    for (int i = 1; i < s.size(); i+=2)
    {
        /* code */
        if (s[i]=='R')
        {
            /* code */
            ok=false;
            break;
        }
        
    }
    if(ok){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    
   }

Measured memory_bytes: 256
n=int(input())
a=[0]+list(map(int,input().split()))
b=[0]*(n+1)
c=0

for i in reversed(range(1,n+1)):
  d=n//i-1
  e=0
  for j in range(2,d+2):
    
    if b[i*j]%2==1:e+=1#
  if (a[i]==0 and e%2==1) or (a[i]==1 and e%2==0):
    b[i]=1
    c+=1
print(c)
b2=[i+1 for i in range(n) if b[i+1]>0]
print(*b2 if len(b)>0 else "")
    
    

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

using namespace std;

#define ll long long

#define all(x) x.begin(), x.end()

int main(){

	cin.tie(0);
	cin.sync_with_stdio(0);

	#ifdef Cyborg101
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ll n;
	cin >> n;

	if(n % 2 == 0){
		cout << n << " " << n << " " << n / 2 << endl;
		return 0;
	}

	for(int i = 1; i <= 3500; ++i){
		for(int j = i; j <= 3500; ++j){
			ll num = 4 * (i * 1ll * j) - (n * 1ll * (i + j));
			ll den = i * 1ll * j * n;

			if(den > 0 && num > 0 && den % num == 0){
				cout << i << " " << j << " " << den / num << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[]) {
  stack<pair<int,char> > S;
  int section_num=0;
  int pool_sum=0;

  string input;
  std::cin >> input;;

  vector<pair<int, int> > pools;
  pools.reserve(20000);

  for (size_t i = 0; i < input.length(); i++) {
    if(input[i]=='_'){
      continue;
    }else if(input[i]=='\\'){
      pair<int,char> p = make_pair(i, input[i]);
      S.push(p);
    }else if(input[i]=='/'){
      if(S.empty()){ continue; }
      pair<int,char> l = S.top(); S.pop();
      int left = l.first;
      pair<int, int> section = make_pair(left, i);
      pools.push_back(section);
      section_num++;
      pool_sum += i - left;
    }
  }

  std::cout << pool_sum << '\n';

  sort(pools.begin(), pools.end());

  std::vector<int> pool_section; pool_section.push_back(0);

  int pool_num=0;
  pair<int,int> L = make_pair(pools[0].first, pools[0].second);

  for (size_t j = 0; j < section_num; j++) {
    if(L.first <= pools[j].first && pools[j].second <= L.second){
      pool_section[pool_num] += pools[j].second - pools[j].first;
    }else{
      pool_section.push_back(pools[j].second - pools[j].first);
      L = pools[j];
      pool_num++;
    }

  }



    if (pool_sum!=0) {
      std::cout << pool_num+1;
      for (size_t i = 0; i <= pool_num; i++) {
        std::cout << ' ' << pool_section[i];
        }
    }else{
      std::cout << "0";
    }


    std::cout  << '\n';



  return 0;

}



Measured memory_bytes: 3300
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <bitset>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const ll inv2=5e8+4;
int n;

void solve(){
	scanf("%d",&n);
	ll sum1=0,sum2=0;
	for(int i=1;i<=n;i++){
		ll x;
		scanf("%lld",&x);
		sum1=(sum1+x)%MOD;
		sum2=(sum2+x*x%MOD)%MOD;
	}
	ll res=(sum1*sum1%MOD-sum2+MOD)%MOD*inv2%MOD;
	printf("%lld\n",res);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 3804
#include <iostream>

using namespace std;

int main() {
    int n, A, B;
    while (cin >> n && n != 0) {
        int sumA = 0, sumB = 0;
        for (int i=0; i<n; ++i) {
            cin >> A >> B;
            if (A == B) {
                sumA += A;
                sumB += B;
            } else if (A < B) {
                sumB += A + B;
            } else {
                sumA += A + B;
            }
        }
        cout << sumA << " " << sumB << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
a, b = map(int, input().split())

result = 0


#b-aを行う事によって、隣接する棟の感覚を割り出す事が可能である。rangeの仕様でbの一つ前のaで棟が完成する。なので-aするとぱーぺき
for i in  range(1,b-a):
    result += i
print(result-a)


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

int main() {
	int s1s2s3;
  cin >> s1s2s3;
  
 cout << s1s2s3 / 100 + s1s2s3 % 100 / 10 + s1s2s3 % 10 << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	int n, k;
	cin >> n >> k;
	VI a(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, k, n) {
		if (a[i] > a[i - k]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    REP(i,Q) cin >> A[i];
    sort ALL(A);
    int ans[N] = {};
    REP(i,Q){
        --A[i];
        ans[A[i]]++;
    }
    REP(i,N){
        if(K - (Q - ans[i]) >= 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;

class Program
{
    #region library
    static int n = 0;
    static int r = 0;
    static int c = 0;
    static int x = 0;
    static int y = 0;
    static string s = "";
    static string[] ss;
    static long sum = 0;
    static long cnt = 0;
    static long max = -1;
    static long min = 2147483647;
    static bool flg = false;
    static bool flg2 = false;
    static string alpha = "abcdefghijklmnopqrstuvwxyz";
    static int[] arr;
    static char[,] map;
    static int[,] imap;
    static string rl()
    {
        return Console.ReadLine();
    }
    static string[] rls()
    {
        return Console.ReadLine().Split();
    }
    static void wl(object obj = null)
    {
        Console.WriteLine(obj);
    }
    static void w(object obj)
    {
        Console.Write(obj);
    }
    static int Int(string s)
    {
        return int.Parse(s);
    }
    static void yes()
    {
        wl("YES");
    }
    static void no()
    {
        wl("NO");
    }
    static void Sum()
    {
        wl(sum);
    }
    static void Cnt()
    {
        wl(cnt);
    }
    static void setarray(int num = -1)
    {
        if (n == 0)
        {
            n = Int(rl());
        }
        arr = new int[n];
        if (num == -1) ss = rls();
        for (int i = 0; i < n; i++)
        {
            if (num == -1)
                arr[i] = Int(ss[i]);
            else
                arr[i] = num;
        }
    }
    static void setmap(char def = '@')
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        map = new char[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == '@') s = rl();
            for (int j = 0; j < c; j++)
            {
                map[i, j] = (def == '@') ? s[j] : def;
            }
        }
    }
    static void setimap(int def = -1)
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        imap = new int[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == -1) s = rl();
            for (int j = 0; j < c; j++)
            {
                imap[i, j] = (def == -1) ? Int(s[j].ToString()) : def;
            }
        }
    }
    #endregion

    static void Main(string[] args)
    {
        x = Int(rl());
        while(true)
        {
            if (IsPrime(x)) break;
            x++;
        }
        wl(x);
    }

    static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }


}



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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, std::vector<long long> A){
    vector<vector<ll>> dp(2001, vector<ll>(2001, 0));
    vector<pair<ll, int>> a(N);
    rep(i,0,N) a[i] = {A[i], i};
    sort(all(a), greater<>());
    ll answer = 0;
    rep(i,0,N+1) rep(j,0,N-i+1) {
        ll lValue = 0, rValue = 0;
        if (i>0) lValue = dp[i-1][j] + a[i+j-1].first * abs((i-1)-a[i+j-1].second);
        if (j>0) rValue = dp[i][j-1] + a[i+j-1].first * abs((N-j)-a[i+j-1].second);
        dp[i][j] = max(lValue, rValue);
        answer = max(dp[i][j], answer);
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 34880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vll = vector<ll>;
using vvll = vector<vll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using plli = pair<ll, int>;
using vplli = vector<pair<ll, int>>;
using pllll = pair<ll, ll>;
using vpllll = vector<pair<ll, ll>>;

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

//pow(llpow,modpow)
template <class T>
ll llpow(ll x, T n)
{
    ll ans = 1;
    if (x == 0)
        ans = 0;
    while (n)
    {
        if (n & 1)
            ans *= x;
        x *= x;
        n >>= 1;
    }
    return ans;
}
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
template <class T>
inline T gcd(T x, T y)
{
    if (y == 0)
        return x;
    else
    {
        return gcd(y, x % y);
    }
}
//最小公倍数
template <class T>
inline T lcm(T x, T y) { return x / gcd(x, y) * y; }
//逆元
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i - 1; i >= (ll)end_i; i--)

long long INF = 1LL << 60;
int main()
{
    string s;
    cin >> s;
    ll n = s.size();
    vvll dp(n + 1, vll(13, 0));
    dp[0][0] = 1;
    ll mod=1e9+7;
    rep(i, 0, n)
    {
        if (s[i] == '?')
        {
            rep(fd, 0, 13)
            {
                rep(now, 0, 10)
                {
                    ll to = (fd * 10 + now) % 13;
                    dp[i + 1][to] += dp[i][fd];
                    dp[i+1][to]=(dp[i+1][to]%mod+mod)%mod;
                }
            }
        }
        else
        {
            ll now = s[i] - '0';
            rep(fd, 0, 13)
            {
                ll to = (fd * 10 + now) % 13;
                dp[i + 1][to] += dp[i][fd];
                dp[i+1][to]=(dp[i+1][to]%mod+mod)%mod;
            }
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}


Measured memory_bytes: 13696
#include <vector>
#include <cmath>
#include <limits>
#include <functional>
#include <iostream>

template<typename T>
class Segtree{
  int nbin;
  T param_def;
  std::vector<T> seg_vec;
  std::function<T(T, T)> seg_func;
  T segtree_query_partial(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return param_def;
    if(a <= l && r <= b) return seg_vec[k];
    const T v_l = segtree_query_partial(a, b, k*2+1, l, (l+r)/2);
    const T v_r = segtree_query_partial(a, b, k*2+2, (l+r)/2, r);
    return seg_func(v_l, v_r);
  }
  auto max_bit(int32_t n){
    n = n & 0xFFFF0000 ? n & 0xFFFF0000 : n;
    n = n & 0xFF00FF00 ? n & 0xFF00FF00 : n;
    n = n & 0xF0F0F0F0 ? n & 0xF0F0F0F0 : n;
    n = n & 0xCCCCCCCC ? n & 0xCCCCCCCC : n;
    n = n & 0xAAAAAAAA ? n & 0xAAAAAAAA : n;
    return n;
  }
  public:
  Segtree(const std::vector<T>& data, const std::function<T(T, T)>& _seg_func, const T _param_def) :
    seg_func(_seg_func), param_def(_param_def) {
      nbin = max_bit(data.size()-1)*2;
      seg_vec.resize(nbin*2-1, param_def);
      auto insert_top = seg_vec.begin();
      insert_top += nbin-1;
      std::copy(data.cbegin(), data.cend(), insert_top);
      for(int i = nbin-2; i >= 0; i--){
        seg_vec[i] = seg_func(seg_vec[i*2+1], seg_vec[i*2+2]);
      }
    }
  void update(int i, int x){
    i += nbin-1;
    seg_vec[i] = x;
    while(i > 0){
      i = (i-1)/2;
      seg_vec[i] = seg_func(seg_vec[i*2+1], seg_vec[i*2+2]);
    }
  }
  T query(int a, int b){
    return segtree_query_partial(a, b, 0, 0, nbin);
  }
};

int main(){
  int N;
  std::cin >> N;
  std::vector<int>A_arr(N);
  for(int i = 0; i < N; i++){
    std::cin >> A_arr[i];
  }

  Segtree<int> seg(A_arr, [](int l, int r){return std::max(l, r);}, -1);
  for(int i = 0; i < N; i++){
    std::cout << std::max(seg.query(0, i), seg.query(i+1, N)) << "\n";
  }

  return 0;
}




Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    long long N, K;
    cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        --A[i];
    }
    vector<bool> seen(N, false);
    seen[0] = true;
    int city_num = 0;
    int dist = 0;
    map<int, int> d;
    d[0] = 0;
    vector<int> mp;
    mp.push_back(0);
    while (1)
    {
        dist++;
        city_num = A[city_num];
        mp.push_back(city_num);
        if (seen[city_num])
        {
            break;
        }
        seen[city_num] = true;
        d[city_num] = dist;
    }
    int round = dist - d[city_num];
    if (K < dist)
    {
        cout << mp[K] + 1 << endl;
    }
    else
    {
        K -= d[city_num];
        K %= round;
        cout << mp[d[city_num] + K] + 1 << endl;
    }
}

Measured memory_bytes: 13936
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------

int main(void) {
  string t;
  cin >> t;
  int n=t.size();

  vecb hatena(n, false);
  rep(i,n){
    if(t[i]=='?'){
      t[i]='D';
      hatena[i]=true;
    }
  }

  prt(t);
}


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

struct edge {
  int to;
  int cost;
};

int main() {
  int N, M, R;
  cin >> N >> M >> R;
  vector<int> town(R);
  rep(i,R) {
    int r;
    cin >> r;
    --r;
    town[i] = r;
  }
  sort(town.begin(), town.end());
  
  vector<vector<edge>> G(N);
  rep(i,M) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;  // 0-indexed
    G[a].push_back(edge{b,c});
    G[b].push_back(edge{a,c});
  }

  /* dijkstra */
  Graph d(N, vector<int>(N, INFTY));
  rep(i,N) {
    d[i][i] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0,i));
    while (!que.empty()) {
      auto p = que.top();
      que.pop();
      int &v = p.second;
      for (auto e : G[v]) {
        if (d[i][v] + e.cost < d[i][e.to]) {
          d[i][e.to] = d[i][v] + e.cost;
          que.push(P(d[i][e.to], e.to));
        }
      }
    }
  }

  int ans = INFTY;
  do {
    int sum = 0;
    rep(i,R-1) {
      sum += d[town[i]][town[i+1]];
    }
    if (sum < ans) ans = sum;
  } while (next_permutation(town.begin(), town.end()));

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


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int A,B;
  cin >> A >> B;
  B = B + A*3;
  cout << B/2 << endl;
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, Y;

int main() {
    cin >> N >> Y;
    REP(x, N + 1) REP(y, N - x + 1) {
        if(x * 1000 + y * 5000 + (N - x - y) * 10000 == Y) {
            cout << (N - x - y) << " " << y << " " << x << "\n";
            return 0;
        }
    }
    cout << -1 << " " << -1 << " " << -1 << "\n";
}

Measured memory_bytes: 256
import sys
n,y=(int(x) for x in input().split())
for i in range(n+1):
  for j in range(n-i+1):
    if 10000*i+5000*j+1000*(n-i-j)==y:
      print("{} {} {}".format(i,j,n-i-j))
      sys.exit()

print("-1 -1 -1")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
#define endl '\n'
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]= {-1,1,0,0};
int Y[]= {0,0,1,-1};
ll a[200003],b[200002];
ll n,m,k;
ll check(ll x)
{
    if(x>n+m) return  0;
    for(ll i=0; i<=x; i++)
    {
         if(i<=n && x-i<=m)
         {
             if(a[i]+b[x-i]<=k) return  1;
         }
    }
    return  0;
}
int main()
{

    cin>>n>>m>>k;

    for(ll i=1; i<=n; i++)
      {
            cin>>a[i];
            a[i]=a[i]+a[i-1];
      }
    for(ll i=1; i<=m; i++)
      {
            cin>>b[i];
            b[i]=b[i]+b[i-1];
      }
      ll lo=0,hi=2000000000,mid;
      ll ans=0;
      while(lo<=hi)
      {
          mid=(lo+hi)/2;
          if(check(mid))
          {
              ans=mid;
              lo=mid+1;
          }
          else hi=mid-1;
      }
      cout<<ans<<endl;
}




Measured memory_bytes: 6660
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    REP(i, 0, N) {
        cin >> A[i];
    }
    REP(i, 0, N) {
        cin >> B[i];
    }
    REP(i, 0, N) {
        cin >> C[i];
    }

    sort(begin(A), end(A));
    sort(begin(B), end(B));
    sort(begin(C), end(C));
    ll ans = 0;
    REP(i, 0, N) {
        ll a = lower_bound(begin(A), end(A), B[i]) - begin(A);
        ll c = end(C) - upper_bound(begin(C), end(C), B[i]);
        ans += a * c;
    }

    cout << ans << endl;

    return 0;
}


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

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

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG 0x3fffFFFFffffFFFFL
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef pair<ll, ll> lpair;
typedef pair<int, int> ipair;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

//C++17からstd::に含まれた
//ll gcd(ll a, ll b){ if (a % b) return (gcd(b, a % b)); else return b; }
//ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

signed main()
{
//    cout << fixed << setprecision(9);

    int N; cin >> N;
    vector<ll> A(N); rep(i, N) cin >> A[i];

    vector<ll> x(N);
    x[0] = 0L;
    rep(i, N){
        if(i & 1) // 0-base で奇数番めの場合
            x[0] -= A[i];
        else
            x[0] += A[i];
    }
    x[0] /= 2;
    rep(i, N - 1) x[i + 1] = A[i] - x[i];

    rep(i, N) print(x[i] * 2);
    puts("");    

    return 0;
}


Measured memory_bytes: 2816
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
 
d1 = [c2[i] - c1[i] for i in range(3)]
d2 = [c3[i] - c1[i] for i in range(3)]
 
if(d1[0] == d1[1] and d1[0] == d1[2] and d2[0] ==d2[1] and d2[0] == d2[2]):
  print("Yes")
else:
  print("No")

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

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

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

    vector<int> v(N);
    iota(all(v), 0);

    double ans = 0;
    do {
        int pre = -1;
        for (auto u : v) {
            if (pre==-1) {
                pre = u;
                continue;
            }
            ans += sqrt(pow(abs(x[u]-x[pre]), 2.0) + pow(abs(y[u]-y[pre]), 2.0));
            pre = u;
        }
    } while (next_permutation(all(v)));

    int sum = 1;
    srep(i,1,N+1) sum *= i;
    ans = ans / (double)sum;
    printf("%.8lf\n", ans);
    return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    
    int N[n];
    int M[m];
    int D[n];
    for(int i=0; i<n; i++){
        D[i] = 0;
    }
    
    for(int i=0; i<n; i++){
        cin >> N[i];
    }
    for(int i=0; i<m; i++){
        cin >> M[i];
        for(int j=0; j<n; j++){
            if(M[i]>=N[j]){
                D[j]++;
                break;
            }
        }
    }
    
    int d=0;
    int max = 0;
    for(int i=0; i<n; i++){
        if(D[i]>max){
            d = i+1;
            max = D[i];
        }
    }
    cout << d << endl;
}

Measured memory_bytes: 3088
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define track  1;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

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

void solve()
{
	int i,j,cnt=0;
	bool flag=0;
	int a,b,c,d;

	cin>>a>>b>>c>>d;

	while(a>0&&c>0)
	{
		cnt++;
		if(cnt&1)
		{
			c -= b;
		}
		else
		{
			a -= d;
		}
	}

	if(cnt&1)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}

	

}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int a[10];
int k;
int main() {
	for(int i=1; i<=5; i++) cin>>a[i];
	cin>>k;
	for(int i=1; i<=5; i++)
		for(int j=i+1; j<=5; j++)
			if(abs(a[j]-a[i])>k) {
				cout<<":(";
				return 0;
			}
	cout<<"Yay!";


	return 0;
}


Measured memory_bytes: 256