akhauriyash/Code-Regression huggingface dataset:
from math import sqrt
inpl = lambda: list(map(int,input().split()))
MOD = 10**9 + 7
N, K = inpl()
sqN = int(sqrt(N))
bound = [0]*(sqN+2)
for i in range(1,sqN+2):
    bound[i] = N//i
bound[sqN+1] = sqN
group_size = [0]*(sqN+1)
for i in range(1,sqN+1):
    group_size[i] = bound[i]-bound[i+1]

cur_small = [1] * (sqN+1)
cur_small[0] = 0
cur_large = [ s for s in group_size ]
for k in range(K-1):
    prev_small = cur_small
    cur_small = [0] * (sqN+2)
    prev_large = cur_large
    cur_small = [0] * (sqN+2)
    cur_small[sqN+1] = sum(prev_small[:sqN+1])
    for n in range(sqN,0,-1):
        cur_small[n] = (prev_large[n] + cur_small[n+1]) % MOD
    acc_prev_small = 0
    for n in range(1,sqN+1):
        acc_prev_small += prev_small[n]
        cur_large[n] = acc_prev_small*group_size[n] % MOD

print((sum(cur_small[:sqN+1])+sum(cur_large[:sqN+1]))%MOD)

Measured memory_bytes: 54108
using System.Collections.Generic;
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var n = int.Parse(ReadLine());
    var seq = ReadLine().Split(' ').Select(long.Parse).ToArray();

    var table = new long[n+1];
    for(int i = 0; i < n; i++)
    {
      table[i+1] = table[i] + seq[i];
    }

    var min = long.MaxValue;
    for(int i = 1; i < n; i++)
    {
      min = Math.Min(min, Math.Abs((table[i] << 1) - table[n]));
    }

    var ans = min;
    WriteLine(ans);
  }
}

Measured memory_bytes: 36036
#include <iostream>
#include <cstdlib>
#include <vector>
#include <stack>

int main()
{
   int64_t N;
   std::cin >> N;
   std::cin.ignore();
   int n = N;
   int cnt =0;
   int prev = -1;
   int pprev = -1;
   int swapTarget =-1;
   bool ok = true;
   while(n-->0){
       int P;
       std::cin >> P;
       if(prev > P) {
           if( cnt ==1 ) {
               ok=false;
               break;
           }
           if(swapTarget==-1) {
             swapTarget = prev;
             if (n == 0 && pprev < P) cnt++; 
           } else {
               if(swapTarget <= prev) {
                   ok = false;
                   break;
               }
               cnt++;
               prev = swapTarget;
               continue;
           }
       }
       pprev = prev;
       prev = P;
   }
   if(ok) ok = swapTarget == -1 || cnt==1;
   if(ok) {
       std::cout << "YES" <<std::flush;
   } else {
       std::cout << "NO" <<std::flush;
   }
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int k = stdIn.nextInt();
        int s = stdIn.nextInt();
        int ans = 0;
        for(int i = 0; i <= k; i++){
            for(int j = 0; j <= k; j++){
                if(s - (i+j)  <= k && 0 <= s - (i + j)) ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n, m, c, ans = 0;
  cin >> n >> m >> c;
  int a[n][m], b[m];
  REP(i, m) { cin >> b[i]; }
  REP(i, n) {
    REP(j, m) { cin >> a[i][j]; }
  }
  REP(i,n){
    int tmp = 0;
    REP(j, m) { tmp += a[i][j] * b[j]; }
    if (tmp + c > 0) ans++;
  }
  cout << ans << "\n";
  return 0;
}


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

using namespace std;

int main(){
  int n,i;
  cin >> n;
  long long a[n],maxi=0;
  for (i=0;i<n;++i) {
    cin >> a[i];
    if (a[i] > a[maxi]) {
      maxi = i;
    }
  }
  double b=a[maxi]/2.0;
  int medi=0;
  if (maxi==0) {
    medi=1;
  }
  for (i=1;i<n;++i) {
    if (i!=maxi && fabs(a[medi]-b) > fabs(a[i] - b)) {
      medi = i;
    }
  }
  cout << a[maxi] << " " << a[medi] << endl;
  return 0;
}


Measured memory_bytes: 1024
#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() {
   int N, M;
   string ans = "IMPOSSIBLE";
   cin >> N >> M;
   vector<int> a(M), b(M), C;
   rep(i, M) {
     cin >> a.at(i) >> b.at(i);
     if (a.at(i) == 1) C.push_back(b.at(i));
     if (b.at(i) == N) C.push_back(a.at(i));
   }

   int c = C.size();
   sort(C.begin(), C.end());
   C.erase(unique(C.begin(), C.end()), C.end());
   if (C.size() < c) ans = "POSSIBLE";

   cout << ans << endl;
 }


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

using namespace std;

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define show(x) cerr << #x << " " << x << endl

typedef long long ll;
typedef unsigned long long ull;

constexpr const int INT_INF=0x3f3f3f3f; // 1061109567
constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f; // 4557430888798830399

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;
}

// INT
#define GCD(a, b) __gcd(a, b)
template <typename T> T LCM(T a, T b) {return a / GCD(a, b) * b;}
template <typename T> T EXTGCD(T a, T b, T& x, T& y) {
    T d = a;
    if (b != 0) {d=EXTGCD(b,a%b,y,x);y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> bool is_prime(T a) {
    for(int i=2;i*i<=a;i++)if(a%i==0)return 1;
    return 0;
}

// MOD
const ll MOD = 1000000000 + 7;
#define add(a, b) ((a % MOD) + (b % MOD)) % MOD
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define sub(a, b) ((a % MOD) + MOD - (b % MOD)) % MOD
template <typename T> T mod_inverse(T a, T mod, bool prime){ // if mod is prime, "prime" is true.
    if(prime){
        T tmp=mod-2,now=a,res=1;while(tmp){if(tmp&1)res=mul(res,now);now=mul(now,now);tmp>>=1;}
        return res;
    }else{T x,y;EXTGCD(a,mod,x,y);return (mod+x%mod)%mod;}
}
#define divide(a, b) ((a % MOD) * (mod_inverse(b, MOD, true))) % MOD

//LLの数値をつかう時は最後にLをつける癖をつけよう
//
//  　　┓　　　┏
//  　＊┗┓　┏┛
//  　　　┫　┣　＊
//  　┏┳┻━┻┳┓
//  　┗┫　　　┣┛
//  ＊　┣　　━┃　＊        Merry Christmas!!
//  　┏┛　　〃┃
//  　┃●　　　┣━┳┓
//  　┗┻┳━━┛　┣┛
//  　＊　┃┏┓┣┓┃
//WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

int n;
int a[200001];
int b[200011];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1 = freopen("/Users/aim_cpo/CLionProjects/competitive/in.txt", "r", stdin);
    //stream2 = freopen("out.txt", "w", stdout);
    if (stream1 == nullptr) return 0;
    //if (stream2 == NULL) return 0;
#endif
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        b[a[i]] = b[a[i] - 1] + 1;
    }
    int _max = -1;
    for (int i = 1; i <= n; i++) {
        chmax(_max, b[i]);
    }
    cout << n - _max << endl;
#ifdef  LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
	int w,cost;
	while(1){cost=0;
		scanf("%d",&w);
		if(!(w+1))break;
		while(w>30){w--;cost+=160;}
		while(w>20){w--;cost+=140;}
		while(w>10){w--;cost+=125;}
		cost+=1150;
		printf("%d\n",4280-cost);
	}
	return 0;
}

Measured memory_bytes: 600
fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];
    if a + b < 10 {
        println!("{}", a + b);
    } else {
        println!("error");
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define forep(i, a, b) for(int64_t i=(a);i<(b);++i)
#define all(obj) (obj).begin(), (obj).end()
#define in(x) cin >> (x)
#define out(y) cout << (y) << "\n"
#define i64 int64_t
#define str string
using namespace std;
void Main() {
	/*----------------------------------------------------------------------------------------------------*/
	i64 A, V, B, W, T;
	in(A); in(V); in(B); in(W); in(T);

	i64 dir = 0;
	if (A > B) dir = -1;
	else dir =1;

	V *= dir;
	W *= dir;

	for (i64 i = 0; i < T; ++i)
	{
		A += V;
		B += W;
		if ((dir == 1 && A >= B) || (dir == -1 && A <= B)) {
			out("YES");
			return;
		}
	}

	out("NO");

	/*----------------------------------------------------------------------------------------------------*/
}
int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
	return 0;
}

Measured memory_bytes: 3612
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')

h,w,a,b = map(int,input().split())
if a > w // 2 or b > h // 2:
    print('No')
    exit()
l = [0] * (w - a) + [1] * a
for i in range(h):
    for j in l:
        p = j ^ (i < b)
        print(p, end = '')
    print()


Measured memory_bytes: 8916
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int inputN, *inputA, *inputB, *inputC, answer = 0, tmpA;
    scanf("%d", &inputN);
    inputA = (int *)malloc(sizeof(int) * inputN);
    inputB = (int *)malloc(sizeof(int) * inputN);
    inputC = (int *)malloc(sizeof(int) * (inputN - 1));
    for (int count = 0; count < inputN; count++)
    {
        scanf("%d", &inputA[count]);
    }
    for (int count = 0; count < inputN; count++)
    {
        scanf("%d", &inputB[count]);
    }
    for (int count = 0; count < inputN - 1; count++)
    {
        scanf("%d", &inputC[count]);
    }
    for (int count = 0; count < inputN; count++)
    {
        if (count > 0)
        {
            tmpA = inputA[count - 1];
        }
        else
        {
            tmpA = -1;
        }
        answer += inputB[count];
        if (tmpA + 1 == inputA[count])
        {
            answer += inputC[tmpA - 1];
        }
    }
    printf("%d", answer);

    free(inputA);
    free(inputB);
    free(inputC);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
	int a,b,c;

	cin >> a >> b >> c;

	if(c > a && c < b){
		cout << "Yes" << endl;
	}
	else if(c > b && c < a){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
n,k = gets.chomp.split(" ").map(&:to_i)
d = []
b = Array.new(n,0)
k.times.map{ 
  d << gets.chomp.to_i
  a = gets.chomp.split(" ").map(&:to_i) 
  a.map{|i|
    b[i-1]+=1
  }
}

puts b.count(0)

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


void solve(long long N, std::vector<long long> A){
  vector<long long> ret(N);
  for (int i = 0; i < N; ++i) {
    ret[A[i] - 1] = i + 1;
  }
  for (int i = 0; i < N; ++i) {
    cout << ret[i];
    if (i == N - 1) { cout << endl; }
    else { cout << " "; }
  }
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    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: 2432
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(void){
  string s;
  vector<int> num(4);
  cin >> s;

  for(int i = 0; i < 4; i ++){
    num.at(i) = s.at(i)-48;
  }

  int bits;
  for(bits = 0; bits < pow(2, 3); bits ++){
    int sum = num.at(0);
    for(int i = 0; i < 3; i ++){
      if((bits << i) & 4){
        sum -= num.at(i+1);
      }
      else sum += num.at(i+1);
    }
    if(sum == 7){
      cout << num.at(0);
      for(int i = 0; i < 3; i ++){
        if((bits << i) & 4) cout << "-" << num.at(i+1);
        else cout << "+" << num.at(i+1);
      }
      cout << "=7" << endl;

      return 0;
    }
  }

  return 0;
}


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

int main() {
    string O, E; cin >> O >> E;
    for (int i = 0; i < E.size(); i++) {
        cout << O[i] << E[i];
    }
    if (O.size() > E.size()) {
        cout << O[O.size() - 1];
    }
    cout << endl;
}


Measured memory_bytes: 3636
use std::io;
use std::str::FromStr;


fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (a, b, c) = (it.next().unwrap(), it.next().unwrap(), it.next().unwrap());
    if a + b >= c {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
def main():
	H, W = map(int, input().split())
	h, w = map(int, input().split())
	m = []
	for i in range(H):
		t = []
		for j in range(W):
			t.append(1)
		m.append(t)
	for i in range(h):
		for j in range(W):
			m[i][j] = 0
	for i in range(w):
		for j in range(H):
			m[j][i] = 0
	s = 0
	for i in range(H):
		s += sum(m[i])
	print(s)
	return

if __name__ == '__main__':
	main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long n;
    cin >> n;
    vector<long> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    long sum = accumulate(l.begin(), l.end(), 0L), summ = sum;
    if(sum % 10 == 0){
        for(int i = 0; i < n; i++){
            if(l[i] % 10 == 0) continue;
            else{
                sum -= l[i];
                break;
            }
        }
        if(sum == summ) sum = 0;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

// (行き先,容量,逆辺)
struct edge{ int to,cap,rev; };

const int MAX_V = 202; // TODO:initialize
const int F_INF = 191919; // TODO:initialize
vector<edge> G[MAX_V];
int level[MAX_V]; // sからの距離
int iter[MAX_V]; // どこまで調べ終わったか

void add_edge(int from, int to, int cap){
    G[from].pb({to,cap,(int)G[to].size()});
    G[to].pb({from,0,(int)G[from].size()-1});
}

void dinic_bfs(int s){
    memset(level,-1,sizeof(level));
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        rep(i,G[v].size()){
            edge &e = G[v][i];
            if(e.cap>0 && level[e.to]<0){
                level[e.to] = level[v]+1;
                que.push(e.to);
            }
        }
    }
}

// 増加パスをdfsで探す
int dinic_dfs(int v, int t, int f){
    if(v==t) return f;
    for(int &i=iter[v]; i<(int)G[v].size(); ++i){
        edge &e=G[v][i];
        if(e.cap>0 && level[v]<level[e.to]){
            int d = dinic_dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// sからtへの最大流
int max_flow(int s, int t){
    int flow = 0;
    while(1){
        dinic_bfs(s);
        if(level[t]<0) return flow;
        memset(iter,0,sizeof(iter));
        int f;
        while((f=dinic_dfs(s,t,F_INF))>0) flow+=f;
    }
}

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

    int T = 2*n;

    vector<int> a(m),b(m);
    rep(i,m){
        cin >>a[i] >>b[i];
        --a[i];
        --b[i];

        rep(j,MAX_V) G[j].clear();
        rep(j,n) add_edge(j,j+n,1);

        rep(j,i){
            add_edge(a[j]+n, b[j],1);
            add_edge(b[j]+n, a[j],1);
        }

        add_edge(a[i]+n,T,1);
        add_edge(b[i]+n,T,1);

        int f = max_flow(n,T);
        printf("%s\n", f==2?"Yes":"No");
    }

    return 0;
}



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

int main(){
  int c,sum = 0;
  int coin[6] = {1, 5, 10, 50, 100, 500};
  for (int i = 0; i < 6; i++){
    cin>>c;
    sum += coin[i] * c;
  }
  if (sum >= 1000) {
    cout << 1 << endl; 
  }else{
    cout << 0 << endl; 

  }
  return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N;cin>>N;
  int ans = 0;
  REP(i,N) {
    int a;cin>>a;
    while (a%2==0) {
      ans++;
      a /= 2;
    }
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main()
{
	char s[1000000];
	int i, j, p = 0, a, k;
	gets(s);
	a = strlen(s);
	for (i = 0; i < a ; i++)
	{
		p = p + (s[i] - '0');
		p = p % 9;
	}
	if (p % 9 == 0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (i <= N - 3) {
            if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		long k=s.nextLong();
		
		long num=0;
		
		int p=0;
		int count=0;
		
		for(int i=0;i<10000000;i++)
		{
			num=((num%k)*(10%k))%k;
			num=(num%k+7%k)%k;
			
			count++;
			
			if(num==0)
			{
				p=1;
				break;
			}
		}
		
		if(p==0)
		{
			System.out.println(-1);
		}
		else
		{
			System.out.println(count);
		}
		
	}
	
}

Measured memory_bytes: 35664
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(){


	int n;
	while(cin >> n && n != 0){
		set<int> taro,hanako;
		for(int i = 1; i <= 2*n; i++)
			hanako.insert(i);
		for(int i = 0; i < n; i++){
			int tmp;
			cin >> tmp;
			hanako.erase(tmp);
			taro.insert(tmp);
		}
		int placedNum = -1;
		// 0:taro,1:hanako
		int tern = 0;
		while(!(taro.size() == 0 || hanako.size() == 0)){
			if(tern==0){
				tern=1;
				set<int>::iterator it = taro.lower_bound(placedNum);
				if(it == taro.end()){
					placedNum = -1;
					continue;
				}
				else{
					placedNum = *it;
					taro.erase(*it);
				}
			}
			else{
				tern=0;
				set<int>::iterator it = hanako.lower_bound(placedNum);
				if(it == hanako.end()){
					placedNum = -1;
					continue;
				}
				else{
					placedNum = *it;
					hanako.erase(*it);
				}
			}
		}
		cout << hanako.size() << endl;
		cout << taro.size() << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<map>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
const int N = 1e5+5;

struct node{
	double x,y;
}g[N];
ll a[N],b[N],c[N],ans;
priority_queue<ll>q;
bool cmp(ll a,ll b)
{
	return a>b;
}
vector<ll>v;
int main()
{
	int x,y,na,nb,nc;
	scanf("%d%d%d%d%d",&x,&y,&na,&nb,&nc);
	for(int i=0;i<na;i++)scanf("%lld",&a[i]);
	for(int i=0;i<nb;i++)scanf("%lld",&b[i]);
	for(int i=0;i<nc;i++)
	{
		ll x;
		scanf("%lld",&x);
		q.push(x);
	}
	sort(a,a+na,cmp);
	sort(b,b+nb,cmp);
	for(int i=0;i<x;i++)
	{
		ans+=a[i];
		v.push_back(a[i]);
	}
	for(int i=0;i<y;i++)
	{
		ans+=b[i];
		v.push_back(b[i]);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		if(q.empty())break;
		ll t=q.top();q.pop();
		if(t>v[i])ans=ans-v[i]+t;
		else break;
	}
	printf("%lld",ans);
	return 0;
}



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

int main(){
  int n;
  long long X=0,x=0,ans=1000000000000000000LL;
  cin>>n;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    X+=a[i];
  }
  for(int i=0;i<n;i++){
    x+=a[i];
    if(i+1<n)ans=min(ans,abs(X-2*x));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4808
use std::fmt::Debug;
fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("No Line");
    buffer
}
fn read_value<T: std::str::FromStr>() -> T {
    read_line().trim().parse().ok().unwrap()
}
fn read_values<T: std::str::FromStr>() -> Vec<T> {
    read_line().trim().split(' ').map(|x| x.parse().ok().expect("Can't Parse")).collect::<Vec<T>>()
}
fn read_multi_line<T: std::str::FromStr>(count: usize) -> Vec<T> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for i in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(buffer.parse().ok().expect("Can't Parse"));
    }
    vec
}

macro_rules! ignore {
    ($id:ident) => {};
}
macro_rules! assign {
    (let $($id:ident),* = $value:expr) => {
        let ($($id), *) = {
            let mut iter = $value.into_iter();
            ($({ignore!($id); iter.next().unwrap()}), *)
        }
    };
}
fn inspect<T: Debug>(vec: &Vec<T>) -> () {
    if let Some(first) = vec.first() {
        println!("Vec({:?}", first);
        for i in 1..vec.len() {
            println!(", {:?}", vec[i]);
        }
        println!(")");
    }else {
        println!("Vec()");
    }
}

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    }else {
        gcd(b, a % b)
    }
}

fn main() {
    let k = read_value::<usize>();
    let mut sum = 0usize;
    for a in 1 ..= k {
        for b in 1 ..= k {
            for c in 1 ..= k {
                sum += gcd(a, gcd(b, c));
            }
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 2164
import heapq
n,m=map(int,input().split())
ab=[]
for i in range(m+1):
    ab.append([])
for i in range(n):
    a,b=map(int,input().split())
    if a<=m:
        ab[a].append(b)
h = []
s=0
for i in range(1,m+1):
    for v in ab[i]:
        heapq.heappush(h,-1*v)
    if len(h)>0:
        s+=-1*heapq.heappop(h)
print(s)

Measured memory_bytes: 18392
import java.util.*;

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

        for (;;) {
            int n = scanner.nextInt();
            int x = scanner.nextInt();

            if (n == 0 && x == 0) {
                return;
            }

            int cnt = 0;
            for (int i = 1; i <= n; ++i) {
                for (int j = i+1; j <= n; ++j) {
                    for (int k = j+1; k <= n; ++k) {
                        if (i + j + k == x)
                                ++cnt;
                    }
                }
            }

            System.out.println(cnt);
        }
    }
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  string str[n];
  int alfa[30]={};
  for(int i=0;i<n;i++){
    cin>>str[i];
    for(int j=0;j<m;j++){
      alfa[str[i][j]-'a']++;
    }
  }
  if(n%2==0&&m%2==0){
    bool flag=true;
    for(int i=0;i<26;i++){
      if(alfa[i]%4!=0)
	flag=false;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }else if(n%2==1&&m%2==0){
    bool kisuu=false;
    int ni=0;
    for(int i=0;i<26;i++){
      if(alfa[i]%4==0){;
      }else if(alfa[i]%2==0){
	ni++;
      }else kisuu=true;
    }
    if(kisuu==false&&ni<=m/2)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }else if(n%2==0&&m%2==1){
    bool kisuu=false;
    int ni=0;
    for(int i=0;i<26;i++){
      if(alfa[i]%4==0){;
      }else if(alfa[i]%2==0){
	ni++;
      }else kisuu=true;
    }
    if(kisuu==false&&ni<=n/2)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }else{
    int kisuu=0;
    int ni=0;
    for(int i=0;i<26;i++){
      if(alfa[i]%4==0){;
      }else if(alfa[i]%2==0){
	ni++;
      }else{
	kisuu++;
	if((alfa[i]-1)%4!=0)
	  ni++;
      }
    }
      if(kisuu<=1&&ni<=(n-1)/2+(m-1)/2)
	cout<<"Yes"<<endl;
      else
	cout<<"No"<<endl;
    
  }
  return 0;
}


Measured memory_bytes: 256
N, T = map(int, input().split())
BAD = 10000
min_cost = BAD
for i in range(N):
    c, t = map(int, input().split())
    if t <= T and c < min_cost:
        min_cost = c
if min_cost == BAD:
    print("TLE")
else:
    print(min_cost)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll n;
ll f[62][2][2];
ll dp(int i, int mod , bool ok)
{
	ll& ans=f[i][mod][ok];
	if(ans!=-1)return ans;
	if(i==60)return ans=(mod==0 and ok==0);
	int nthbit=(n>>i)&1;
	ans=0;
	for(int a=0;a<2;a++)
	{
		for(int b=0;b<=a;b++)
		{
			int curbit=(a+b+mod)%2;
			int nmod=(a+b+mod)/2;
			bool nok=ok;
			if(curbit>nthbit)nok=1;
			if(curbit<nthbit)nok=0;
			ans+=dp(i+1, nmod, nok);
			ans=ans%MOD;
		}
	}
	return ans;
}
int main()
{
	cin>>n;
	memset(f, -1, sizeof f);
	cout<<dp(0,0,0);
	
	
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

struct UnionFind{
    vector<int> branch;
    UnionFind(int N=0):branch(N,-1){}
    int find(int x){
        if(branch[x]<0){
            return x;
        }
        else{
            return branch[x]=find(branch[x]);//メモ化、要素を入れて根が返ってくる    
        }
    }
    bool unite(int x, int y){
        int rx,ry;
        rx=find(x);
        ry=find(y);
        if(rx==ry){
            return false;//連結できたかどうかが大事なこともあるらしい
        }
        if(-branch[rx]<-branch[ry]){//bramch[rx]を常に大きい方にする
            swap(rx,ry);    
        }
        branch[rx]+=branch[ry];//木のサイズを負の値で管理
        branch[ry]=rx;
        return true;
    }
    bool same(int x, int y){
        if(find(x)==find(y)){
            return true;
        }
        else{
            return false;
        }
    }
    int size(int x){
        return -branch[find(x)];
    }
};

    
int main(){
    int N,M,K;
    cin >> N >> M >> K;
    UnionFind tree(N);
    int num_friend[N]={};
    vector<int> num_block[N]={};
    for (int i = 0; i < M; i++){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        tree.unite(x,y);
        num_friend[x]++;
        num_friend[y]++;
    }
    for (int i = 0; i < K; i++){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        num_block[x].push_back(y);
        num_block[y].push_back(x);
    }

    for (int i = 0; i < N; i++){
        int ans=tree.size(i)-num_friend[i]-1;
        for (auto j:num_block[i]){
            if(tree.same(i,j)){
                ans--;
            }
        }
        cout << ans << ' ';
    }
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 3.14159265358979323846
#define pdd pair<double,double>
bool comp(int a,int b)
{
	return a>b;
}
int main() 
{
	ll x;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	x=max(a*c,max(a*d,max(b*c,b*d)));
	cout<<x;
	return 0;    
}

Measured memory_bytes: 3616
#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 n;
cin>>n ;
vector<int> A(n) ;
rep(i,n) cin>>A[i]  ;

vector<int> B(n) ;
rep(i,n) B[A[i]-1] =i+1 ;


rep(i,n)
cout << B[i]  <<endl ;
  return 0;

}


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

#define MAXN 10010

long long int N, W;
long long int dp[110][MAXN], w[110], v[110];
/*
int solve(int i, int weigth){
	if (i == N+1) return 0;
	
	if (dp[i][weigth] != -1) 
		return dp[i][weigth];
	
	int ans = solve(i+1, weigth);
	if (weigth - w[i] >= 0) return max(ans, solve(i+1, weigth - w[i]) + v[i]);
	return dp[i][weigth] = ans; 
}
*/
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	cin >> N >> W;	
	for (int i = 1; i <= N; i++)
		cin >> w[i] >> v[i];

	for (int i = 1; i <= N; i++) {
		for (int j = W; j >= 0; j--) {
			long long int ans = dp[i-1][j]; 
			if (j-w[i] >= 0)
				ans = max(ans, dp[i-1][j-w[i]] + v[i]);
			dp[i][j] = ans;
		}
	}

	cout << dp[N][W] << endl;
	
	return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

void bfs(vector<ll>* edges,ll n,ll* distance,ll ind){
	queue<ll> q;
	bool visited[n+1];
	REP(i,0,n+1) visited[i] = 0;

	q.push(ind);
	visited[ind] = 1;
	while(q.size()){
		ll curr = q.front();
		q.pop();
		for(auto u : edges[curr]){
			if(!visited[u]){
				visited[u] = 1;
				distance[u] = distance[curr] + 1;
				q.push(u);
			}
		}
	}
}

int main() 
{
	ll n,x,y;
	cin>>n>>x>>y;
	vector<ll> edges[n+1];

	edges[x].push_back(y);
	edges[y].push_back(x);
	REP(i,1,n){
		edges[i].push_back(i+1);
		edges[i+1].push_back(i);
	}
	ll ans[n] = {0};
	REP(i,1,n+1){
		ll* distance = new ll[n+1];
		REP(j,0,n+1) distance[j] = 0;

		bfs(edges,n,distance,i);
		REP(j,i+1,n+1){
			ans[distance[j]]++;
		}
	}
	REP(i,1,n){
		cout<<ans[i]<<endl;
	}
	return 0;
}  


Measured memory_bytes: 31616
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> InputList = new List<int>();
            List<List<int>> ResultList = new List<List<int>>();

            string putputstring = string.Empty;

            while (true)
            {
                var Input = Console.ReadLine().Split(' ');
                int H = int.Parse(Input[0]);
                int W = int.Parse(Input[1]);

                if (H == 0 && W == 0) break;

                InputList = new List<int>();

                InputList.Add(H);
                InputList.Add(W);
                ResultList.Add(InputList);
            }


            foreach (var InThelist in ResultList)
            {
                //#?????°?????£????????????(W)
                for (int x = 0; x < InThelist[1]; x++)
                {
                    putputstring += "#";
                }

                //?????????Consle.WriteLine???????????????
                for (int y = 0; y < InThelist[0]; y++)
                {
                    Console.WriteLine(putputstring);
                }

                putputstring = string.Empty;
                Console.WriteLine();   
            }

        }

    }

}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(b-a)<=d && abs(b-c)<=d) cout << "Yes" << endl;
    else if(abs(c-a)<=d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    string s; cin >> s;
    ll k; cin >> k;
    int idx = 0;
    rep(i, s.size()) if(s[i] != '1') {
        idx = i; break;
    }
    int ans = 0;
    if(k <= idx) ans = 1;
    else ans = s[idx] - '0';
    cout << ans;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
	int S[10005],T[505],n,q;
	
	while(cin>>n)
	{
		for(int i=0;i<n;i++)
		{
			cin>>S[i];
		}
		cin>>q;
		for(int j=0;j<q;j++)
		{
			cin>>T[j];
		}
		
		int count=0;
		
		for(int i=0;i<q;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(T[i]==S[j])
				{
					count++;
					break;
				}
			}
		}
		cout<<count<<endl;
	}
	
	return 0;
}

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

int main()
{
    int64_t n, t;
    std::cin >> n >> t;
    int64_t start{}, prev{};
    for (int i{}; i < n; i++)
    {
        int64_t h;
        std::cin >> h;
        if (h < prev)
        {
            start += h - prev;
            h = prev;
        }
        if (t < start)
            puts("1");
        else
            std::cout << (t - start) / h + 1 << std::endl;
        
        start += h;
        prev = h;
    }
    return 0;
}


Measured memory_bytes: 3112
n = input()
keta = len(n)
n = int(n)

ans = 0
for i in range(1,keta,2):
	ans += 9 * (10 ** (i-1))

if keta % 2 == 0:
	print(ans)
else:
	ans += n - 10**(keta-1) + 1
	print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	int n;
	cin >> n;
	
	vector<int>L(n,0);
	
	for(int i = 0; i < n; i++) {
		cin >> L.at(i);
	}
	
	std::sort(L.begin(), L.end(),std::greater<int>());
	//これで大きいものから順にソートされた
	
	long long ans = 0;
	int a,b,c,base;
	
	for(int i = 0; i < n-1; i++) {
		for(int j = i+1; j < n-1; j++) {
			
			//cout << "Loop " << "i:" << i << ", j:" << j << endl;
			
			base = j+1;
			
			a = L.at(i);
			b = L.at(j);
			c = L.at(base);
			while((a < b+c) && (base < n)) {
				ans++;
				
				//cout << "a:" << a << ", b:" << b << ", c:" << c << endl;
				
				base++;
				if ( base < n) c = L.at(base);
			}
		}
	}
	
	cout << ans << endl;
	
	
	return 0;
}


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

int main(void){

  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c)
    cout<<1<<endl;
  else if(a==b)
    cout<<2<<endl;
  else if(a==c)
    cout<<2<<endl;
  else if(b==c)
    cout<<2<<endl;
  else
    cout<<3<<endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CGacha {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      set<string> st;
      rep(i, n) {
        string s; cin >> s;
        st.insert(s);
      }
      cout << st.size() << endl;
    }
};

signed main() {
  CGacha solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

    using namespace std;

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

        int n;
        cin>>n;
        int k=n%10;
        if(k==2 || k==4 || k==5 || k==7 || k==9){
            cout<<"hon";
        }
        else if(k==3){
            cout<<"bon";
        }
        else
            cout<<"pon";
        return 0;
    }


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <sstream>

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define C(x) cout << x << endl //テスト出力

//関数
//nCkの計算の関数(呼び出しは[cbn])
ll cbn(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
// a^n mod を計算する
ll powmod(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}
//２つの最大公約数
int gcb(int a, int b){
    if(a < b){
        int x = a;
        a = b;
        b = x;
    }
    int amari = a % b;
    if(amari == 0) return b;

    return gcb(b, amari);
}
//３つの最大公約数
int gcb_3(int a, int b, int c){
    return gcb(gcb(a, b), c);
}

/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;
vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))*/

/*-----------------------------ここから-----------------------------*/

int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n,a,b; cin>>n;
bool judge = false;
ll cnt = 0;
REP(i,n){
  cin>>a>>b;
  if(a==b) cnt++;
  else cnt=0;
  if(cnt==3) judge=true;
}
if(judge) cout<<"Yes";
else cout <<"No";
}

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

int main(){
  int N;
  cin >> N;
  bool y = false;
  for(int i = 0; i < N; i++){
    char color;
    cin >> color;
    if(color == 'Y'){
      y = true;
      cout << "Four" << endl;
      break;
    }
  }
  if(y == false)
    cout << "Three" << endl;
}

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() {
   int N;
   ll sum = 0;
   cin >> N;

   vector<ll> a(N);
   rep(i, N) {
     cin >> a.at(i);
     sum += a.at(i);
   }

   ll x = a.at(0), y = sum - a.at(0), ans = 100000000000000000;

   if (N == 2) ans = abs(x - y);
   else {
     for (int i = 1; i < N - 1; i++) {
       x += a.at(i);
       y -= a.at(i);
       ans = min(ans, abs(x - y));
     }
   }

   cout << ans << endl;
 }


Measured memory_bytes: 1792
N = int(input())
p = []

for i in range(N):
    p.append(input())

p.sort()
c = 1
ans = 0
for i in range(1, len(p)):
    if p[i] == p[i - 1]:
        c += 1
    else:
        if c % 2 == 1:
            ans += 1
        c = 1
if c % 2 == 1:
    ans += 1
print(ans)


Measured memory_bytes: 10588
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int main() {
	long long sum;
	int a,c=0;
	cin >> sum;
	char b;
	while (cin>>b&&b!='=') {
		cin >> a;
		if (b == '+') {
			sum += a;
		}
		else if (b == '-') {
			sum -= a;
		}
		else if (b == '*') {
			sum *= a;
		}
		else {
			sum = floor(sum / a);
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3076
INF = float("inf")

N, K, *H = map(int, open(0).read().split())
H = [0] + H

if N == K:
    print(0)
    quit()

dp = [0] + [INF] * N
for i in range(1, N - K + 1):
    dp = [INF] * i + [min(dp[k] + max(0, h - H[k]) for k in range(i - 1, j)) for j, h in enumerate(H[i:], i)]

print(min(dp))

Measured memory_bytes: 9160
from collections import defaultdict
import sys

input = lambda: sys.stdin.readline().rstrip()

def mod_inv(a):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, M
  while z1 != 1:
    d, m = divmod(z2, z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1%M

def mex(s):
  for i in range(N+1):
    if i not in s:
      return i

def calc_grundy(edge):
  grundy = [{} for i in range(3)]
  sum_g = [defaultdict(int, {0:W_sum}) for i in range(3)]
  W = W_last
  for i in range(N, 0, -1):
    for g, s, e in zip(grundy, sum_g, edge):
      if i in e:
        m = mex({g.get(j, 0) for j in e[i]})
        if m:
          g[i] = m
          s[g[i]] =  (s[g[i]] + W) % M
          s[0] =  (s[0] - W) % M
    W = W * B_inv % M
  return sum_g

def read_edge():
  M = int(input())
  e = defaultdict(list)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].append(b)
  return e

N = int(input())
M = 998244353
B = pow(10, 18, M)
B_inv = mod_inv(B)
W_last = pow(B, N, M)
W_sum = (W_last - 1) * B * mod_inv(B-1) % M

edge = [read_edge() for i in range(3)]
sum_g = calc_grundy(edge)
ans = 0
for gx, sx in sum_g[0].items():
  for gy, sy in sum_g[1].items():
    gz = gx^gy
    sz = sum_g[2][gz]
    if sz:
      ans = (ans + sx*sy*sz) % M
print(ans)


Measured memory_bytes: 90332
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n, m;
vector<pair<ll, ll>> key;
VLL dp;

int main()
{
    cin>>n>>m;
    key.resize(m);
    dp.resize(pow(2, n), INF * 100);
    dp[0] = 0ll;
    REP(i,m) {
        ll a, b;
        cin>>a>>b;
        key[i] = {a, 0ll};
        REP(j,b) {
            int c;
            cin>>c;
            key[i].scd += pow(2, c - 1);
        }
    }

    REP(i,m) {
        REP(j,pow(2, n)) {
            dp[key[i].scd|j] = min(dp[key[i].scd|j], key[i].fst + dp[j]);
        }
    }

    cout<<(dp[pow(2, n) - 1] == INF * 100 ? -1: dp[pow(2, n) - 1])<<endl;

    return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll r;
  cin >> r;

  cout << 3 * r * r << "\n";
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    // 処理
    // 出力
    cout << s1[0] << s2[0] << s3[0] << endl;

    return 0;
}


Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << '\n';
}


Measured memory_bytes: 888