akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int a =  N%10;
  if(a==2||a==4||a==5||a==7||a==9){
    cout << "hon" << endl;
  }else if(a==0||a==1||a==6||a==8){
    cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }
}


Measured memory_bytes: 3636
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=[0]*(n+1)
cnt=0
for i in range(1,n+1):
    d[i]=d[i-1]+l[i-1]
    if d[i]<=x:
        cnt+=1
print(cnt+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,i;bool p=true;
  cin>>n;
  while(p)
  {
  	for(i=2;i*i<=n;i++)
  	{
  		if(n%i==0){n++;p=false;break;
		  }
	  }
	  if(!p){p=true;continue;
	  }
	  else
	  break;
  }
  cout<<n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 400010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    string s;
  cin >> s;
  FOR(i,0,2) {
    int g = s[i] - '0';
    cout << 10 - g;
  }
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

//方針はBFS
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<List<Integer>> edge = new ArrayList<>(N+1);
        List<List<Integer>> cost = new ArrayList<>(N+1);
        for(int i=1;i<=N+1;i++){
          edge.add(new ArrayList<>());
          cost.add(new ArrayList<>());
        }

        for(int i=1;i<=N;i++){
          edge.get(i).add(0);
          cost.get(i).add(0);
        }

        for(int i=1;i<=N-1;i++){
          int u = sc.nextInt();
          int v = sc.nextInt();
          int w = sc.nextInt();

            edge.get(u).add(v);
            edge.get(v).add(u);
            cost.get(u).add(w);
            cost.get(v).add(w);

        }


        Deque <Integer> dq = new ArrayDeque<>();
        int status [] = new int[N+1];
        int ans [] = new int[N+1];
        int chakushuzumi = 0;


        for(int i=1;i<=N;i++){
            ans[i]=0;
            status[i]=0;
        }
        dq.push(1);
        status[1]=1;
        while(!dq.isEmpty()){
            int last_in = dq.pollFirst();
            for(int i = 1; i <= edge.get(last_in).size()-1;i++){
                if(status[edge.get(last_in).get(i)] == 0){
                    int u = edge.get(last_in).get(i);
                    int w = cost.get(last_in).get(i);
                    ans[edge.get(last_in).get(i)] = (ans[last_in] + w) % 2;
                    status[edge.get(last_in).get(i)]=1;
                    dq.push(edge.get(last_in).get(i));
                }
            }

        }
        for (int i=1;i<=N ;i++) {
            System.out.println(ans[i]);
        }
    }
    }


Measured memory_bytes: 117992
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var R = 1;
  var B = 0;
  var G = 0;
  var output = 3;
  var mod = 1000000007;
  if(list[0] != 0){
    myout(0);
    return;
  }
  for(var i = 1; i < N; i++){
    var count = 0;
    var added = false;
    if(list[i] == R){
      count++;
      R++;
      added = true;
    }
    if(list[i] == B){
      count++;
      if(!added){
        B++;
        added = true;
      }
    }
    if(list[i] == G){
      count++;
      if(!added){
        G++;
        added = true;
      }
    }
    output *= count;
    output %= mod;
    //myerr(output);
  }
  myout(output);
}


Measured memory_bytes: 40700
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <functional>
#define rep(i, a, n) for(int i = int(a);i < int(n);++i)
#define repe(i, a, n) for(int i = int(a);i <= int(n);++i)
#define repr(i, a, n) for(int i = int(a);i > int(n);--i)
#define reper(i, a, n) for(int i = int(a);i >= int(n);--i)
#define size(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using namespace std;


int N;
int X[200010];
int A[200010];


void solve(){
	sort(&A[1], &A[N+1], greater<int>());
	repe(i, 1, N){
		if(X[i] < A[N/2]) cout << A[N/2] << endl;
		else cout << A[N/2+1] << endl;
	}
}


int main(){
	cin >> N;
	repe(i, 1, N) cin >> X[i], A[i] = X[i];

	solve();

	return 0;
}

Measured memory_bytes: 3712
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(A: int, B: int, K: int):
    t = max(0, A-K)
    a = B
    if A-K > 0:
        a = B
    else:
        a = max(0, a- (K-A))

    print(t, a)
    return



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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> L(N);
    REP(i,N) cin >> L[i];
    int ans=0;

    sort(ALL(L));
    REP(i,N){
        for(int j=i+1;j<N;j++){
            int sum = L[i]+L[j];
            int idx1 = lower_bound(ALL(L), sum) - L.begin();  //a+b < cでなければいけない
            int cnt = idx1 - j - 1;
            ans += cnt;
        }
    }


    cout << ans << endl;
}

Measured memory_bytes: 256
s, n, ans = input(), 0, 0
mods = [0]*2019
mods[0] = 1
for i, j in enumerate(reversed(s)):
  n = (n+int(j)*pow(10, i, 2019))%2019
  mods[n] += 1
for i in mods: ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<50);
template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}

int main() {
    cin>>K>>A>>B;
    cout<<(B/K - (A - 1)/K > 0 ? "OK" : "NG")<<endl;
}

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

int main() {
    int k;
    cin >> k;
    vector<ll> a;
    for (int i = 1; i <= 9; ++i) a.push_back(i);
    while (1) {
        if (k <= a.size()) {
            cout << a[k - 1] << endl;
            return 0;
        }
        k -= a.size();
        vector<ll> old;
        swap(old, a);
        for (ll x : old) {
            for (int i = -1; i <= 1; ++i) {
                int d = x % 10 + i;
                if (d < 0 || d > 9) continue; //負になるor桁が変わったら次のループへ
                ll nx = x * 10 + d; //下にくっつける
                a.push_back(nx);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1712
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
  unsigned short *A, *B;

  int C[VMAX + 1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ) {
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ) {
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}


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

int main() 
{
	int n,k;
	cin>>n>>k;
	vector<int >v(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	sort(v.begin(),v.end());
	
	int answer=0;
	for(int i=0;i<k;i++)
		answer+=v[i];
	cout<<answer<<endl;
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<iomanip>
#include<algorithm>
#include<cmath>
using namespace std;



int main() {
	long long H,W;
	cin >> H >> W;

	if (H%3==0||W%3==0){
		cout << 0 << endl;
		return 0;
	}
	long long cutter;
	long long hoge = H*W;
	long long Smax,Smin;

	Smin = floor(H * 1.0 / 3) * W;
	Smax = ceil(H * 1.0 / 3) * W;
	hoge = Smax - Smin;

	Smin = floor(W * 1.0 / 3) * H;
	Smax = ceil(W * 1.0 / 3) * H;
	if(hoge > Smax - Smin) hoge = Smax - Smin;

	for(int i = 1; i<H; i++){
		if(W%2==0){
			cutter = W/2;
		}else{
			cutter = (W-1)/2;
		}
			Smax = max(W*i,max((W-cutter)*(H-i),cutter*(H-i)));
			Smin = min(W*i,min((W-cutter)*(H-i),cutter*(H-i)));
		if (Smax-Smin<hoge){
			hoge = Smax-Smin;
		}
	}
	for(int i = 1; i<W; i++){
		if(H%2==0){
			cutter = H/2;
		}else{
			cutter = (H-1)/2;
		}
		Smax = max(H*i,max((H-cutter)*(W-i),cutter*(W-i)));
		Smin = min(H*i,min((H-cutter)*(W-i),cutter*(W-i)));
		if (Smax-Smin<hoge){
			hoge = Smax-Smin;
		}
	}
	cout << hoge << endl;
	return 0;
}


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

int main(){
  int k,s,x,y,w=0;
  cin>>k>>s;
  for(x=0;x<=k;x++) for(y=0;y<=min(k,s-x);y++) if(s-x-y<=k) w++;
  cout<<w<<endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  if(s[0] == s[1]){
      printf("1 2\n");
      return 0;
  }
  for(int i = 2; i < s.size(); i++){
    if(s[i-2] == s[i]){
      printf("%d %d\n", i-1, i+1);
      return 0;
    }else if(s[i-1] == s[i]){
      printf("%d %d\n", i, i+1);
      return 0;
    }
  }
  printf("-1 -1\n");
}


Measured memory_bytes: 512
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>

using namespace std;

typedef long long LL;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = accumulate(a.begin(), a.begin() + k, 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint D;
llint c[30];
llint s[400][30];
llint ans[405];

llint score(llint ans[], llint n)
{
	llint last[26];
	for(int i = 0; i < 26; i++) last[i] = 0;
	
	llint ret = 0;
	for(int i = 1; i <= n; i++){
		ret += s[i][ans[i]];
		last[ans[i]] = i;
		for(int j = 0; j < 26; j++){
			if(j != ans[i]) ret -= (i - last[j]) * c[j];
		}
	}
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	srand(time(NULL));
	
	cin >> D;
	for(int i = 0; i < 26; i++) cin >> c[i];
	for(int i = 1; i <= D; i++){
		for(int j = 0; j < 26; j++){
			cin >> s[i][j];
		}
	}
	
	for(int i = 1; i <= D; i++){
		llint max_val = -inf, max_j;
		for(int j = 0; j < 26; j++){
			ans[i] = j;
			llint res = score(ans, i);
			if(res > max_val){
				max_j = j;
				max_val = res;
			}
		}
		ans[i] = max_j;
	}
	
	llint cur = score(ans, D);
	for(int t = 0; t < 100000; t++){
		llint x = rand() % D + 1, y = rand() % D + 1;
		swap(ans[x], ans[y]);
		llint nxt = score(ans, D);
		if(nxt < cur) swap(ans[x], ans[y]);
	}
	
	for(int i = 1; i <= D; i++) cout << ans[i]+1 << endl;
	return 0;
}

Measured memory_bytes: 3748
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        List<String> list = new ArrayList<>();
        HashMap<String, Integer> hash = new HashMap<>();
        long cnt = 0;
        for (int i = 0; i < N; i++) {
            List<String> strList = Arrays.stream(sc.next().split("")).sorted(Comparator.naturalOrder()).collect(Collectors.toList());
            String str = String.join("", strList);
            list.add(str);
            if (hash.containsKey(str)) {
                hash.put(str, hash.get(str) + 1);
            } else {
                hash.put(str, 1);
            }
        }

        for (long c : hash.values()) {
            cnt += c * (c - 1) / 2;
        }
        System.out.println(cnt);
        sc.close();
    }
}

Measured memory_bytes: 106744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;
ll n,m,v,p;
vector<ll> a;

ll judge(ll x){
  ll bd = a.at(n-p);
  if(x+p>=v){
    if(bd<=a.at(x)+m) return 1; else return 0;
  }
  if(bd>(a.at(x)+m)) return 0;
  ll rest_vote = (v-(x+p)) * m;
  for(int i=n-p;i>x;i--){
    rest_vote -= (a.at(x)+m) - a.at(i);
  }
  if(rest_vote>0) return 0; else return 1;
}

int main(){
  cin >> n >> m >> v >> p;
  a.resize(n,0);
  for(ll i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  ll l = -1, r = n-1, c = (l+r)/2;
  while(r-l>1){
    if(judge(c) == 1) r=c; else l=c;
    c = (l+r)/2;
  }
  cout << n-r << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int ketawa(int a) {
	if (a < 10)return a;
	else return a % 10 + ketawa(a / 10);
}

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;

int main()
{
	ll n, k; cin >> n >> k;
	ll ans = 0;
	for (ll i = k; i < n + 2; i++) {
		ans += (2 * n - i + 1) * i / 2 - i * (i - 1) / 2 + 1;
		ans = ans % mod;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
//#include <set>
//#include <map>
#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
#include <math.h>
//#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    double r;
    double ans;
    cin >> r;
    ans = 2*r*M_PI;

    cout << setprecision(10) << ans << endl;

    return 0;
}

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

typedef long long ll;
// const int INF = 1e8;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

int N, M;
vector<int> s, c;

int main() {
    cin >> N >> M;
    s.resize(M);
    c.resize(M);
    rep(i, M) {
        cin >> s[i] >> c[i];
    }
    map<int, int> mp;
    rep(i, M) {
        s[i]--;
        if (mp.count(s[i]) && mp[s[i]] != c[i]) {
            cout << -1 << endl;
            return 0;
        }
        mp[s[i]] = c[i];
    }

    vector<int> ans(N);
    // 初期化
    rep(i, N) {
        ans[i] = -1;
    }
    // M個
    rep(i, M) {
        ans[s[i]] = c[i];
    }

    // 0始まり
    if (ans[0] == 0 && N != 1) {
        cout << -1 << endl;
        return 0;
    }

    if (N != 1) {
        if (ans[0] == -1) {
            ans[0] = 1;
        } 
        if (ans[1] == -1) {
            ans[1] = 0;
        }
        if (ans[2] == -1) {
            ans[2] = 0;
        } 
    } else {
        // 1桁
        if (ans[0] == -1) {
            ans[0] = 0;
        }
    } 

    rep(i, N) {
        cout << ans[i];
    }
    cout << endl;
}

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

#include <atcoder/dsu>
using namespace atcoder;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  vector<int> v;
  for (auto& e : a) {
    cin >> e.first >> e.second;
    e.first--, e.second--;
    v.push_back(e.first);
  }
  sort(a.begin(), a.end());

  dsu d(n);
  set<pair<int, int>> s;
  for (auto e : a) {
    bool b = true;
    if (e.first > 0) {
      auto it = s.lower_bound({e.second, e.first});
      while (it != s.begin()) {
        it--;
        d.merge(it->second, e.first);
        b = false;
      }
    }
    if (b) {
      s.insert({e.second, e.first});
    }
  }

  for (int i = 0; i < n; i++) cout << d.size(v[i]) << endl;
}


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

using namespace std;

#define MAX 100005

vector<int> tree[MAX];
vector<long long> dist(MAX);

void dfs(int from,int now){
  for(auto to:tree[now]){
    if(to==from) continue;
    dist[to]=dist[now]+1;
    dfs(now,to);
  }
}

int main(){
  int n,a,b; cin >> n;
  for(int i=0;i<n-1;++i){
    cin >> a >> b;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  dfs(-1,1);
  vector<long long> fedist=dist;
  fill(dist.begin(),dist.end(),0);
  dfs(-1,n);
  int fcnt=0,scnt=0;
  for(int i=1;i<=n;++i){
    if(fedist[i]<=dist[i]) fcnt++;
    else scnt++;
  }
  if(fcnt>scnt) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
  
  return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

int n, m, f[MAXM];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,n) {
        int x, p;
        cin >> p;
        FOR(j,1,p) {
            cin >> x;
            f[x]++;
        }
    }
    int res = 0;
    FOR(i,1,m) res += (f[i] == n);
    cout << res;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

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

    int ans = 0;
    if(a >= 13){
        ans = b;
    }else if(a <=12 && a >= 6){
        ans = b / 2;
    }else{
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
N, Y = map(int, input().split())
flag = False

def isValid(l, m, n):
    sum = l*10000 + m*5000 + n*1000
    if sum == Y:
        return True
    return False

for i in reversed(range(N+1)):
    for j in range(N+1):
        if i + j > N:
            break
        else:
            if isValid(i, j, N-i-j):
                flag = True
                print("{0} {1} {2}".format(i, j, N-i-j))
                break
        if flag:
            break
    if flag:
        break

if not flag:
    print("-1 -1 -1")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main () {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s;
  int n;
  cin >> n >> n;
  cin >> s;
  cout << s.substr(0,n-1) + (char)(s[n-1]+32) + s.substr(n);
  return 0;
}


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

namespace ITP1_10D
{
    class Program
    {
        class Pair<T1, T2>
        {
            public T1 Item1 { get; set; }
            public T2 Item2 { get; set; }
        }


        static IEnumerable<Pair<T1, T2>> GetPair<T1, T2>(IEnumerable<T1> source1, IEnumerable<T2> source2)
        {
            var s1 = source1.GetEnumerator();
            var s2 = source2.GetEnumerator();
            while (s1.MoveNext() && s2.MoveNext()) 
            {
                yield return new Pair<T1, T2> { Item1 = s1.Current, Item2 = s2.Current };
            }
        }


        static T Fn<T>(int count, Func<T, T> f, T x)
        {
            for (var i = 0; i < count; ++i)
            {
                x = f(x);
            }
            return x;
        }


        static double Root(int dimension, double a)
        {
            //return Math.Pow(a, 1.0 / (double)dimension);

            if (a == 0)
            {
                return 0;
            }

            // Newton's Method
            var n = 1.0;
            while (true)
            {
                var powerOfN = Fn(dimension, _ => _ * n, 1.0);
                var fx = powerOfN - a;
                var fx_d = dimension * (powerOfN / n);

                n = n - fx / fx_d;
                if (Math.Abs(fx) < 0.00001)
                {
                    break;
                }
            }

            return n;
        }


        static double MinkowskiDistance(int p, IEnumerable<int> d)
        {
            var sumOfDistance = 0L;
            foreach (var n in d)
            {
                sumOfDistance += Fn(p, _ => _ * n, 1);
            }

            return Root(p, sumOfDistance);
        }


        static void Main(string[] args)
        {
            Console.ReadLine();
            var arrayOfX = Console.ReadLine().Split(' ');
            var arrayOfY = Console.ReadLine().Split(' ');

            var d = GetPair(arrayOfX, arrayOfY)
                .Select(_ => int.Parse(_.Item1) - int.Parse(_.Item2))
                .Select(_ => Math.Abs(_))
                .ToArray();

            Console.WriteLine(MinkowskiDistance(1, d));
            Console.WriteLine(MinkowskiDistance(2, d));
            Console.WriteLine(MinkowskiDistance(3, d));
            Console.WriteLine(d.Max());
        }
    }
}

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

typedef struct _jwe{
    int v;
    int c;
}Jew;
int main(void){

    int N,ans=0;
    cin >> N;
    Jew j[N];
    
    for(int i=0;i<N;i++){
        cin >> j[i].v;
    }
    for(int i=0;i<N;i++){
        cin >> j[i].c;
    }

    for(int i=0;i<N;i++){
        if(j[i].v - j[i].c > 0) ans+= (j[i].v - j[i].c);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define loop(i,n) for(ll i=0;i<(ll)(n);i++)
#define change(a,b) do{ll c=a; a=b; b=c;}while(0)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        change(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll A[3];
  cin>>A[0]>>A[1]>>A[2];
  sort(A,A+3);
  ll dif=A[2]+A[2]-A[0]-A[1];
  if(dif%2==0)cout<<dif/2<<endl;
  else cout<<dif/2+2<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1000000001;
#define MOD 1000000007;
#define INF64 1000000000000000001;

#define F first
#define S second

#define Pii pair<SINT32,SINT32>
#define Pll pair<SINT64,SINT64>


using namespace std;

int main() {

	SINT32 N = 0;

	SINT32 t = 0;
	SINT32 x = 0;
	SINT32 y = 0;

	SINT32 nt = 0;
	SINT32 nx = 0;
	SINT32 ny = 0;

	cin >> N;
	
	rep(i,0,N) {

		cin >> nt >> nx >> ny;
		if ((nt-t) < (ABS(nx-x) + ABS(ny-y))) {
			cout << "No" << endl;
			return 0;
		}

		if (((nt-t)%2) != ((ABS(nx-x) + ABS(ny-y))%2)) {
			cout << "No" << endl;
			return 0;
		}
		t = nt;
		x = nx;
		y = ny;
	}

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

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));	//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define Imax 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  string S;
  cin>>S;
  int first=0;
  int second=0;
  
  rep(i,0,S.length()){
    if((!(i%2))==ctoi(S[i])){
      first++;
    }
    if((i%2)==ctoi(S[i])) second++;
     }
 
  cout<<(first<second?first:second);
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>

int main() {
	int x1,x2,x3,x4;
	int y1, y2, y3, y4;
	std::cin >> x1>> y1 >>x2 >> y2 ;
	x4 = x1 - (y2 - y1);
	y4 = y1+(x2 - x1);

	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);
	std::cout << x3 <<" " <<y3 << " " << x4<< " " <<y4<< std::endl;

	return 0;
}


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

int main() {
	int n;cin>>n;
	long long ans=0;
	for(int i=1;i<=n;i++){
		if(i%3){
			if(i%5){
				ans+=i;
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3632
package main

import (
	"fmt"
)

type Square struct {
	X, Y, Width, Height int
}

func (s *Square) contains(c *Circle) bool {
	cs := c.convertToSquare()
	return cs.X >= s.X &&
		cs.Y >= s.Y &&
		cs.X+cs.Width <= s.Width &&
		cs.Y+cs.Height <= s.Height
}

type Circle struct {
	X, Y, R int
}

func (c *Circle) convertToSquare() Square {
	return Square{c.X - c.R, c.Y - c.R, c.R * 2, c.R * 2}
}

func main() {
	var w, h, x, y, r int
	fmt.Scan(&w)
	fmt.Scan(&h)
	fmt.Scan(&x)
	fmt.Scan(&y)
	fmt.Scan(&r)

	square := Square{0, 0, w, h}
	circle := Circle{x, y, r}

	if square.contains(&circle) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 1156
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long d = sc.nextInt();
        long[] type = new long[4];
        type[0] = a * c;
        type[1] = a * d;
        type[2] = b * c;
        type[3] = b * d;
        Arrays.sort(type);
        System.out.println(type[3]);
    }
}

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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>
ll arr[100010];
ll ans[100010];

int main(){
	fast;
	ll n,k,q;
	memset(arr,0,sizeof(arr));
	cin>>n>>k>>q;
	for(ll te=0;te<q;te++){
		ll xx;
		cin>>xx;
		arr[xx]++;
	}
	for(ll i=1;i<=n;i++){
		ans[i]=k;
	}
	for(ll i=1;i<=n;i++){
		// if(arr[i]!=0){
		ll temp=q-arr[i];
		ans[i]-=temp;
		// }
	}
	for(ll i=1;i<=n;i++){
		if(ans[i]>0){
			cout<<"Yes\n";
		}
		else{
			cout<<"No\n";
		}
	}
	// cout<<endl;
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s,t;
    int cnt=0;
    cin >> s >> t;
    for(int i = 0;i < s.size();i++)
    {
        if(s[i]!=t[i])
            cnt++;
    }
    cout << cnt;
    
    return 0;
}



Measured memory_bytes: 3856
#include <iostream>

using namespace std;

int main(){
	int c[3][3];
	
	for(int i = 0 ; i < 3 ; i++){
		for(int j = 0 ; j < 3 ; j++){
			cin >> c[i][j];
		}
	}
		
	int a1 = 0;
	int a[3], b[3];
		
	a[0] = a1;
	for(int i = 0 ; i < 3 ; i++) b[i] = c[0][i] - a1;
	for(int i = 0 ; i < 3 ; i++) a[i] = c[i][0] - b[0];
		
	bool exists = true;
		
	for(int i = 0 ; i < 3 ; i++){
		for(int j = 0 ; j < 3 ; j++){
			if(a[i] + b[j] != c[i][j]) exists = false;
		}
	}
	
	if(exists) cout << "Yes" << endl;
	else cout << "No" << endl;
		
	//for(int i = 0 ; i < 3 ; i++) printf("a[%d] = %d\n", i+1, a[i]);
	//for(int i = 0 ; i < 3 ; i++) printf("b[%d] = %d\n", i+1, b[i]);

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] t = in.nextIntArray(n);
			int m = in.nextInt();
			int[] p = new int[m], x = new int[m];
			for (int i = 0; i < m; i++) {
				p[i] = in.nextInt() - 1;
				x[i] = in.nextInt();
			}

			long sum = 0;
			for (int i = 0; i < n; i++) {
				sum += t[i];
			}

			for (int i = 0; i < m; i++) {
				out.println(sum - t[p[i]] + x[i]);
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21076
import java.util.Scanner;

/**
 * Created by itounagamitsu on 2017/11/09.
 */
public class Main {

    public static void main(String[] args){
        Scanner scaner = new Scanner(System.in);

        int num = scaner.nextInt();

        for(int i=1;;i++){
            if(i * i > num){
                System.out.println((i-1) * (i-1));
                break;
            }
        }
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> v;
    for(int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        v.push_back(P(b, a));
    }
    sort(all(v));
    ll t = 0;
    for(int i = 0; i < n; i++) {
        t += v[i].second;
        if(t > v[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 6384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;


	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var grid = new int[2, n];
		for(int i = 0; i < 2; i++)
		{
			var p = Input().ToInt();
			for(int j = 0; j < n; j++)
			{
				grid[i, j] = p[j];
			}
		}
		
		var dp = new long[3, n+1];
		for(int i = 0; i < 2; i++)
		{
			for(int j = 0; j < n; j++)
			{
				dp[i, j+1] = Math.Max(dp[i, j+1], dp[i, j] + grid[i, j]);
				
				if(i == 0)
				{
					dp[i+1, j+1] = Math.Max(dp[i, j+1] + grid[1, j], dp[i+1, j+1]);
				}
			}
		}
		Console.WriteLine(dp[1, n]);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



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


int main(){
    int cnt=0;
    string S;
    cin >> S;
    for(int i=0;i<S.length();++i){
        int tmp=0;
        while(S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T'){
            i += 1;
            tmp+=1;
        }
        if(cnt<=tmp) cnt = tmp;
    }
    cout << cnt << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)

template<class Edge, class State>
struct dijkstra{
	using Cost = decltype(State{}.calc_cost(Edge{}));

	static vector<Cost> shortest_path(
		State s,
		const vector<vector<Edge>> & g,
		Cost max_dist
	) {
		vector<Cost> d(State::max_state_id() + 1, max_dist);
		d[s.state_id()] = 0;
		using P = pair<ll, State>;
		priority_queue<P, vector<P>, greater<P>> que;
		que.push(P(0, s));
		while (!que.empty()) {
			Cost cur_d; State cur;
			tie(cur_d, cur) = que.top();
			que.pop();
			auto v = cur.state_id();
			if (d[v] < cur_d) continue;
			for (auto e : g[cur.node_id]) if (cur.is_valid(e)) {
				State next = cur.calc_next(e);
				auto u = next.state_id();
				if (d[u] > d[v] + cur.calc_cost(e)) {
					d[u] = d[v] + cur.calc_cost(e);
					que.push(P(d[u], next));
				}
			}
		}

		return d;
	}
};

struct Edge{ ll to; ll cost; ll h; ll r; };
struct State{
	static ll max_state_id() { return 5000; }
	bool operator<(const State & rhs) const { return node_id < rhs.node_id; }

	ll node_id;
	// more infomation
	ll h, passport;

	ll state_id() { return node_id + h * 100; }
	bool is_valid(Edge e) { return h + e.h < 25; }
	State calc_next(Edge e) { return State{ e.to, e.h + h, passport }; }
	ll calc_cost(Edge e) {
		if ((passport & (1 << e.r)) != 0) return 0;
		return e.cost;
	}
};

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	while (true) {
		ll n, m, H, K;
		cin >> n >> m >> H >> K;
		if (n == 0) break;

		vector<vector<Edge>> g(n);
		REP(i, m) {
			ll a, b, c, h, r; cin >> a >> b >> c >> h >> r;
			a--, b--, r--;
			g[a].push_back({ b, c, h, r });
			g[b].push_back({ a, c, h, r });
		}

		ll S, T, P;
		cin >> S >> T >> P; S--, T--;
		
		ll max_dist = TEN(8);
		vl dp(1 << K, max_dist); dp[0] = 0;
		REP(i, P) {
			ll l, d; cin >> l >> d;
			vl k(l);
			REP(j, l) { cin >> k[j]; k[j]--; }

			ll passport = 0; REP(j, l) passport |= 1 << k[j];
			REP(j, 1 << K) dp[j | passport] = min(dp[j | passport], dp[j] + d);
		}

		ll ans = max_dist;
		REP(passport, 1 << K) {
			auto dist = dijkstra<Edge, State>::shortest_path({ S, 0, passport }, g, max_dist);
			REP(i, H + 1) if (dist[State{ T, i, passport }.state_id()] != max_dist) {
				ans = min(ans, dp[passport] + dist[State{ T, i, passport }.state_id()]);
			}
		}

		cout << (ans == max_dist ? -1 : ans) << endl;
	}
	return 0;
}

Measured memory_bytes: 3380
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;

map<ll,ll>g;
set<ll> h;

void prime_factorize(long long N) {
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        g[a]+=ex;
        h.insert(a);
    }

    // 最後に残った数について
    if (N != 1){g[N]++;h.insert(N);};
    return;
}

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

  ll ans=1;
  for(int i=1;i<=n;i++){
    prime_factorize(i);
  }
  while(!h.empty()){
    auto d=h.begin();
    ans*=g[*d]+1;
    ans%=mod;
    h.erase(d);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;
void battle(int a, int b ,int c, int d){
	c-=b;
	if(c<=0){
		cout<<"Yes"<<endl;
		return ;
	}
	a-=d;
	if(a<=0){
		cout<<"No"<<endl;
		return ;
	}
	battle( a,b,c,d);
}

void solve()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	battle(a,b,c,d);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	ll ans = 0;
	ans = b + min(a+b+1,c);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int h[200000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> h[i];
    sort(h, h + n);
    reverse(h, h + n);
    ll sum = 0;
    for (int i = k; i < n; ++i)
        sum += h[i];
    cout << sum;
}


Measured memory_bytes: 1024