akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int qsort_int(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}

int main(int argc, char *argv[])
{
    int n;
    int a[100000];
    int log[100000][2];

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    qsort(a, n, sizeof(int), qsort_int);

    int p = 0;
    int q = n - 1;
    int logNext = 0;
    while (q - p > 1) {
        if (a[p + 1] > 0) {
            const int x = a[p];
            const int y = a[p + 1];
            const int val = x - y;
            p++;
            a[p] = val;

            // logging
            log[logNext][0] = x;
            log[logNext][1] = y;
            logNext++;
        } else {
            const int x = a[q];
            const int y = a[p + 1];
            const int val = x - y;
            p++;
            a[p] = a[p - 1];
            a[q] = val;

            // logging
            log[logNext][0] = x;
            log[logNext][1] = y;
            logNext++;
        }
    }

    int x = a[q];
    int y = a[p];
    int val = x - y;

    log[logNext][0] = x;
    log[logNext][1] = y;
    logNext++;

    printf("%d\n", val);

    for (int i = 0; i < logNext; i++) {
        printf("%d %d\n", log[i][0], log[i][1]);
    }

    return 0;
}


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

int main(){
  int n, i;
  char *p;
  char  str[1003];
  scanf("%d\n", &n);
  while(n--){
    fgets(str, sizeof(str), stdin);
    while((p = strstr(str, "Hoshino")) != NULL)
      p[6] = 'a';
    printf("%s", str);
  }
  return 0;
}

Measured memory_bytes: 608
def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

N = int(input())
A = list(map(int, input().split(" ")))

for i in range(N-1):
  A[i+1] = gcd(A[i], A[i+1])
  
print(A[N-1])

Measured memory_bytes: 14252
<>=~$";@a=glob`dd`;$a[$_-1]%2&&++$a[$%=$_%$'?$_:$_<$`*$'&&$_-1+$']*$%&&push@_,"@{[map{$_/$'+1|0,$_%$'+1}$_-1,$%]}
"for 1..$`*$';print@_.$/,@_

Measured memory_bytes: 64328
S = input()[::-1]
ws = ["dream", "dreamer", "erase", "eraser"]
ws = [w[::-1] for w in ws]

s = S
ans = True
T = ""
while S != T:
    if s[:7] == ws[1]:
        T, s = T + ws[1], s[7:]
    elif s[:6] == ws[3]:
        T, s = T + ws[3], s[6:]
    elif s[:5] == ws[2]:
        T, s = T + ws[2], s[5:]
    elif s[:5] == ws[0]:
        T, s = T + ws[0], s[5:]
    else:
        ans = False
        break

print("YES" if ans else "NO")

Measured memory_bytes: 3552
import collections


def calc(balla, ballb):
    xa, ya = balla
    xb, yb = ballb
    return xa - xb, ya - yb


n = int(input())
balls = [tuple(map(int, input().split())) for _ in range(n)]

if n == 1:
    print(1)
    exit()

a = []
for i in range(0, n - 1):
    for j in range(i + 1, n):
        tmp = calc(balls[i], balls[j])
        a += [tmp, tuple(-i for i in tmp)]
counts = collections.Counter(a)

print(n - max(counts.values()))


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

int main() {

    int n; cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    rep(i, n) {
        cin >> s[i] >> t[i];
    }
    string x; cin >> x;


    bool flag = false;
    int ans = 0;
    rep(i, n) {
        if(flag) {
            ans += t[i];
        } else {
            if(s[i] == x) flag = true;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

ll stone[100010];
bool ch[100010];

ll dfs(int key, vector<vector<int>> &g){
    ch[key]=1;
    ll sum=0, mx=0;
    int cnt=0;
    for(int i=0; i<g[key].size(); ++i){
        if(!ch[g[key][i]]){
            ++cnt;
            ll p=dfs(g[key][i], g);
            if(p<0) return -1;
            sum += p;
            mx=max(mx, p);
        }
    }
    if(cnt==0) return stone[key];
    if(cnt==1){
        if(sum==stone[key]) return stone[key];
        else return -1;
    }
    ll num_pair=sum-stone[key];
    if(num_pair<0 || min(sum/2, sum-mx)<num_pair) return -1;
    stone[key] -= num_pair;
    return stone[key];
}

int main() {
	int N;
	cin >> N;
	for(int i=1; i<=N; ++i) cin >> stone[i];
	vector<vector<int>> v(N+1);
	for(int i=1; i<N; ++i){
	    int a, b;
	    cin >> a >> b;
	    v[a].push_back(b);
	    v[b].push_back(a);
	}
	if(N==2){
	    cout << (stone[1]==stone[2] ? "YES" : "NO") << endl;
	    return 0;
	}
	int t=1;
	while(v[t].size()==1) ++t;
	if(dfs(t, v)==0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 13312
import java.util.Scanner;

public class Main {

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

    }

}

Measured memory_bytes: 22996
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};


int main() {
  int N, X, T;
  std::cin >> N >> X >> T;
  std::cout << T*((N+X-1)/X) << std::endl;
  return 0;
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
   
/* brownsands :Arpit */	
int level[T],mark[T],dp[T];vi v[T];		
void dfs(int root)
{
	mark[root]++;
	//in[root]=timer++;
	for(int i:v[root])
	{
		if(i>root)
		{  level[i]=min(level[i],level[root]+1);
         dfs(i);
      }
	}
	//out[root]=timer++;
}
void solve()
{    int n,x,y,z,k,i,j;
   cin >> n >> x >> y;
   for(i=1;i<n;i++)
   {
      v[i].pb(i+1);
      v[i+1].pb(i);
   }
   for(i=1;i<=n;i++){dp[i]=0;level[i]=INT_MAX;}
   v[x].pb(y);
   v[y].pb(x);
   level[1]=0;dfs(1);
   z=y-x;
   k=1;
   // for(i=1;i<=n;i++)cout<<level[i]<<" ";
   // cout<<endl;
   for(i=1;i<=n;i++)
   {
      //for(j=1;j<=n;j++)
     for(j=i+1;j<=n;j++)
     {
        //dp[min(abs(level[i]-level[j])]++;
        dp[min(abs(i-j),abs(i-x)+abs(j-y)+1)]++;
     }
   }
   for(i=1;i<n;i++)cout<<dp[i]<<endl;

}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 29056
#include <stdio.h>

int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0) break;
    for(j=0; j<H; j++){
      if(j%2==0){
	for(i=0; i<W; i++){
	  if(i%2==0) printf("#");
	  else  printf(".");
	}
      }
      else{
	for(i=0; i<W; i++){
	  if(i%2==0) printf(".");
	  else  printf("#");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let N = S.len();
    let ans = if (0..(N + 1)).any(|i|
        (i..(N + 1)).any(|j| format!(
            "{}{}",
            S[..i].iter().map(|&c| c).collect::<String>(),
            S[j..].iter().map(|&c| c).collect::<String>()
        ) == "keyence"
    )) { "YES" } else { "NO" };

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

Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
	int a, b;
	scanf("%d%d", &a, &b);
	if (a < b){
		printf("a < b\n");
	}
	else if (a > b){
		printf("a > b\n");
	}
	else printf("a == b\n");

	return 0;
}

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

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] A = inpNum(n);
		Arrays.sort(A);
		cd(A);
	}

	private static void cd(int[] a) {
		boolean isCD = true;

		System.out.println(1);
		for (int i = 2; i <= a[0]; i++) {
			isCD = true;
			for (int j = 0; j < a.length; j++) {
				if ( a[j] % i > 0) {
					isCD = false;
					break;
				}

			}

			if ( isCD ) {
				System.out.println(i);
			}
		}

	}

	private static int[] inpNum(int n) {
		int[] nums = new int[n];

		for (int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
		}
		return nums;
	}

}


Measured memory_bytes: 26328
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

PII operator-(const PII &a, const PII &b){
    return PII(a.first - b.first, a.second - b.second);
}
bool operator==(const PII &a, const PII &b){
    return (a.first == b.first) && (a.second == b.second);
}
int main(){
    int N;
    cin >> N;
    vector<int> line(N);
    REP(i, N){
        cin >> line[i];
    }
    sort(ALL(line));
    int minx = line[0];
    int maxx = line.back();
    line.pop_back();
    vector<PII> ans;
    REPA(i, line.size()){
        if(line[i] > 0){
            ans.push_back({minx, line[i]});
            minx -= line[i];
        }else{
            ans.push_back({maxx, line[i]});
            maxx -= line[i];
        }
    }
    ans.push_back({maxx, minx});
    maxx -= minx;
    cout << maxx << endl;
    REP(i, ans.size()){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}



int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  int n;
  cin >> n;
  int ans = 0;
  reps(i,n){
	  int a;
	  cin >> a;
	  if(i%2==1 && a%2 == 1){
		  ans++;
	  }
  }
  cout << ans << endl;;
  return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int t=1;
    while(true){
       int x=sc.nextInt();
       if(x==0){
          break;
       }
       System.out.println("Case "+ t++ +": "+x);
    }
  }
}



Measured memory_bytes: 42440
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {

    void solve() throws IOException {
        String a = ns();
        String b = ns();

        boolean t1 = a.equals("H");
        boolean t2 = b.equals("H");

        out.println(t1 ^ t2 ? "D" : "H");
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 23124
#include<stdio.h>
#include <limits.h>
 
#define N 101
#define Black 2
#define White 0
#define Gray  1
 
 
 
int n=0;
//int z=0;
int G[N][N];
int d[N];
//int f[N];
int color[N];
int que[N];
int head=0;
int tail=0;
 
void Enqueue(int s){
  que[tail] = s;
  tail++;
}
 
int Dequeue(){
  int y;
  y = que[head];
  head+=1;
  return y;
} 
   
 
void BFS(int s){
  int u,w;
  for(u=1;u<=n;u++){
    color[u] = White;
    d[u] = -1;
  }
  color[s] = Gray;
  d[s] = 0;
  Enqueue(s);
  while(head != tail){
    u = Dequeue();
    for(w=1;w<=n;w++){
      if(color[w] == White && G[u][w] == 1){
        color[w] = Gray;
        d[w] = d[u] + 1;
        Enqueue(w);
      }
    }
    color[u] = Black;
  }
}
 
 
 
main(){
  int i,j,s,v,r;
  int p = 1;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1; j<=n;j++){
      G[i][j] = 0;
    }
  }
  for(i=1;i<=n;i++){
    scanf("%d%d", &v,&r);
    for(j=1;j<=r;j++){
      scanf("%d",&s);
      G[i][s] = 1;
    }
  }
  BFS(p);
  for(i=1;i<=n;i++){
    printf("%d %d\n",i, d[i]);
  }
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, d, x;
  cin >> n >> d >> x;
  rep(i, n) {
    ll a;
    cin >> a;
    x += (d - 1) / a + 1;
  }
  cout << x << endl;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
struct Node
{
	int val;
	int id;
	int aorb;
}a[200005];
int n,type[200005],c[4];
bool cmp(Node a,Node b)
{
	return a.val<b.val;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		a[2*i-1].val=x;
		a[2*i-1].aorb=1;
		a[2*i-1].id=i;
		a[2*i].val=y;
		a[2*i].aorb=2;
		a[2*i].id=i;
	}
	sort(a+1,a+2*n+1,cmp);
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i].val;
		c[type[a[i].id]]--;
		c[type[a[i].id]^=a[i].aorb]++;
	}
	if(c[3]||!c[1]||!c[2])
	{
		printf("%lld\n",sum);
		return 0;
	}
	sum+=a[n+1].val-a[n].val;
	c[type[a[n].id]]--;
	c[type[a[n].id]^=a[n].aorb]++;
	c[type[a[n+1].id]]--;
	c[type[a[n+1].id]^=a[n+1].aorb]++;
	if(c[3]||!c[1]||!c[2])
	{
		printf("%lld\n",sum);
		return 0;
	}
	printf("%lld\n",sum+min(a[n].val-a[n-1].val,a[n+2].val-a[n+1].val));
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )
 
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  int N;
  cin >> N;

  set<int> paper;
  REP(i, N) {
    int A;
    cin >> A;
    if ( paper.count(A) ) {
      paper.erase(A);
    } else {
      paper.insert(A);
    }
  }

  cout << paper.size() << endl;  

  return 0;
}


Measured memory_bytes: 8244
def main():
  _map, _range, _int = map, range, int
  n, q = _map(_int, input().split())
  values = [0] * (n + 1)
  parents = [0] * (n + 1)
  for i in _range(n - 1):
    a, b = _map(_int, input().split())
    parents[b] = a
  for _ in _range(q):
    p, x = _map(_int, input().split())
    values[p] += x
  for i in _range(1, n + 1):
    values[i] += values[parents[i]]
  print(*values[1:])
main()


Measured memory_bytes: 66136
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        double h = x / (double)(a * a);
        double hh;
        double ans;
        if (h > (b / 2.0)) {
            h = b - h;
            hh = 2 * h * a / a;
            ans = Math.atan(hh / a);
            System.out.println(Math.toDegrees(ans));
        } else {
            hh = 2 * h * a / b;
            ans = Math.atan(hh / b);
            System.out.println(Math.toDegrees((Math.PI / 2.0) - ans));
        }
    }
}

Measured memory_bytes: 21972
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main(void){
	while(true){
		int m,f,r;
		cin >> m >> f >> r;
		if(m == -1 && f == -1 && r == -1){
			break;
		} else if(m == -1 || f == -1){
			cout << "F" << endl;
		} else if(m + f >= 80){
			cout << "A" << endl;
		} else if(m + f >= 65){
			cout << "B" << endl;
		} else if(m + f >= 50){
			cout << "C" << endl;
		} else if(m + f >= 30){
			if(r >= 50){
				cout << "C" << endl;
			} else {
				cout << "D" << endl;
			}
		} else {
			cout << "F" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long int
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define pb           push_back
#define ff           first
#define ss           second
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define Pi           2*acos(0.0)
#define pii          pair<int,int>
#define pll          pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
using namespace std;

ll expo(ll a,ll b,ll m = mod){
	a%=mod;
	ll res = 1;
	while(b){
		if(b&1)
			res = (res*a)%m;
		a = (a*a)%m;
		b>>=1;
	}
	return res;
}
ll gcd(ll a,ll b){
	while(b>0){
		ll r = a%b;
		a = b; b = r;
	}
	return a;
}
int main()
{
	 
   boost
   #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int t=1;
// 	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    int a[n],b[n],c[n];
	    for(int i=0;i<n;i++){
	        cin>>a[i]>>b[i]>>c[i];
	    }
	    int dp[n][3];
	    mem(dp,0);
	    dp[0][0] = a[0]; dp[0][1] = b[0] ; dp[0][2]=c[0];
	    for(int i=1;i<n;i++){
	        dp[i][0] = a[i]+max(dp[i-1][1],dp[i-1][2]);
	        dp[i][1] = b[i]+max(dp[i-1][0],dp[i-1][2]);
	        dp[i][2] = c[i]+max(dp[i-1][0],dp[i-1][1]);
	    }
	    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
	}
    return 0;
}


Measured memory_bytes: 5892
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn u64() -> u64 {
    read()
}

fn vec_u64(n: usize) -> Vec<u64> {
    let mut vec = Vec::new();
    for _ in 0..n {
        vec.push(u64())
    }
    vec
}

fn main() {
    let input = vec_u64(4);
    let a = input[0] - 1;
    let b = input[1];
    let c = input[2];
    let d = input[3];

    let lcm = lcm(c, d);
    let aa = (a - a / c) + (a - a / d) - (a - a / lcm);
    let bb = (b - b / c) + (b - b / d) - (b - b / lcm);
    println!("{}", bb - aa);
}

fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

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


Measured memory_bytes: 4352
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define DECIMAL setprecision(17)
#define DEBUG(a) cout<<a<<" "
#define NEWLINE cout<<"\n"
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false)

  
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
const ll inf=1ll<<29;
int main(){
      SPEEDUP;
      ll n;
      cin>>n;
      ll a[n];
      rep0(i,n)cin>>a[i];
    int mochi=0;
  rep0(i,n-1) if(a[i+1]<=a[i]) mochi=1;
  if(!mochi){
    cout<<1<<endl;
    return 0;
  }
      ll ng=1;
      ll ok=200002;
      map<ll,ll> counter;
      while(ok-ng>1){
            bool good=true;
            ll now=(ok+ng)/2;
            map<ll,ll> counter;
            rep0(i,n-1){
                  if(a[i+1]>a[i]) continue;
                  ll j=a[i+1];
                  while(1){
                        if(j<=-1){
                          good=false;
                          break;
                        }
                        if(counter[j]==(now-1)){
                              --j;
                        }
                        else if(counter[j]<now-1){
                          	counter[j]++;
                              counter.erase(counter.lower_bound(j+1),counter.end());
                              break;
                        }
                  }
                  //rep0(i,10) DEBUG(counter[i]);
                  //NEWLINE;
                  }
            if(counter[0]>0) good=false;
                  //NEWLINE;
            if(good) ok=now;
            else ng=now;
      }
      cout<<ok<<endl;
      return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
using namespace std;
const int a[10] = {111, 222, 333, 444, 555, 666, 777, 888, 999};
int upd(int x){
    for(int i = 0; i < 9; ++i){
        if(x <= a[i]){
            return a[i];
        }
    }
}
int main(){
    int n;
    while(~scanf("%d", &n)){
        printf("%d\n", upd(n));
    }
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[],int n,int g){
  int i;

  for(i=g;i<n;i++){
    int v=A[i];
    int j=i-g;

    while(j>=0 && A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int A[],int n){
  int i,h;
  
  for(h=1; ; ){
    if(h>n) break;
    G.push_back(h);
    h=3*h+1;
  }

  for(i=G.size()-1;i>=0;i--){
    insertionSort(A,n,G[i]);
  }
}

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

  for(i=0;i<n;i++)
    cin>>A[i];
  //scanf("%d",&A[i]);
  cnt=0;

  shellSort(A,n);

  cout<<G.size()<<endl;

  for(i=G.size()-1;i>=0;i--){
    cout<<G[i];
    //printf("%d",G[i]);
    if(i)
      cout<<endl;
    //printf(" ");
  }
  cout<<endl;
  cout<<cnt<<endl;
  //printf("\n");
  //printf("%d\n",cnt);

  for(i=0;i<n;i++)
    //printf("%d\n",A[i]);
    cout<<A[i]<<endl;
  return 0;
}



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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }




int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	map<int, int> mp;
	rep(i, n){
		int a; cin >>a;
		mp[a]++;
	}
	int ans =0;
	for(auto x: mp){
		if(x.second > x.first) ans += x.second - x.first;
		else if(x.second < x.first) ans += x.second;
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
using ll = long long; using ld = long double; const char nl = '\n';
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

#include <bits/extc++.h>
namespace pbds =  __gnu_pbds;
template <typename key, typename val=pbds::null_type, typename comp=less<key>>
using ostree=pbds::tree<key,val,comp,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
using vi = vector< int >; using vll = vector< ll >;
#define all(x) std::begin(x), std::end(x)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&);
string to_string(string const&s){return '"'+s+'"';}
string to_string(char const &c) {return to_string(string(1,c));}
string to_string(char const *c) {return to_string(string(c));}
string to_string(bool const &b) {return (b ? "1" : "0");}
template<typename... Args> string to_string(pair<Args...> const&p)
{return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&S)
{string s = "{"; for(auto const& e: S)s+=" "+to_string(e);s+=" }"; return s;}
template<typename Tail> void debug_out(Tail t) {cerr<<" "<<to_string(t)<<" ]"<<endl;}
template<typename Head, typename... Tail> void debug_out(Head h, Tail... t)
{cerr << " " << to_string(h) << ","; debug_out(t...);}
#define pr(...) cerr<<"["<<(#__VA_ARGS__)<<"] : [", debug_out(__VA_ARGS__)
template <typename T> void dbr(T lb, T ub)
{cerr<<'{';for(auto it=lb; it!=ub; it++)cerr<<' '<<to_string(*it); cerr<<" }"<<endl;}
template<typename T, typename Comp=less<T>> bool smin(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(v, mem) ? mem = v, true : false;}
template<typename T, typename Comp=less<T>> bool smax(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(mem, v) ? mem = v, true : false;}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */



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

  int n, l;
  cin >> n >> l;
  vi a(n);
  iota(all(a), l);
  ll tot = accumulate(all(a), 0ll);
  ll opt = 1e10;

  for(int i=0; i<n; i++) {
    vi b = a;
    b.erase(b.begin()+i);
    // pr(b);
    ll c = accumulate(all(b), 0ll);
    if( abs(c - tot) < abs(opt - tot) ) opt = c;
  }
  cout << opt << endl;

}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }
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;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
using namespace std;
int dp[110][3][3];
int p[110];
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    for(int i=0;i<110;i++)p[i]=-1;
    for(int i=0;i<b;i++){
        int s,t;scanf("%d%d",&s,&t);
        s--;t--;
        p[s]=t;
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(p[0]!=-1&&p[0]!=i)continue;
            if(p[1]!=-1&&p[1]!=j)continue;
            dp[2][i][j]=1;
        }
    }
    for(int i=2;i<a;i++){
        for(int j=0;j<3;j++)for(int k=0;k<3;k++)for(int l=0;l<3;l++){
                    if(j==k&&k==l)continue;
                    if(p[i]!=-1&&l!=p[i])continue;
                    dp[i+1][k][l]=(dp[i+1][k][l]+dp[i][j][k])%10000;
                }
    }
    int ret=0;
    for(int i=0;i<3;i++)for(int j=0;j<3;j++){
            ret=(ret+dp[a][i][j])%10000;
        }
    printf("%d\n",ret);
}



Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    ll n;
    cin >> n;
    vector <ll> v;
    for (ll i=0;i<n;i++){
        ll tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    ll ans = 0;
    for (ll i=1;i<n-1;i++){
        if((v[i-1]-v[i])*(v[i]-v[i+1]) > 0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//file_name:ABC63_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("yes");}else{puts("no");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;

    int flag = 0;

    rep(i,s.size()){
        rep(j,s.size()){
            if(i==j)continue;
            if(s[i]==s[j])flag=1;
        }
    }

    if(flag==0)yn;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int sum;
int main() {
	int n, m;
	cin >> n >> m;
	int a;
	rep(i,m) {
		cin >> a;
		sum += a;  
	} 

	cout << max(n-sum, -1) << endl;
	return 0;
}

Measured memory_bytes: 3636
a,b=map(int,(input()).split())
def f(n):
  if n%4==0:
    return n
  elif n%4==1:
    return 1
  elif n%4==2:
    return n+1
  else:
    return 0
B=str(bin(f(b)))[2:]
if a==0:
  A="0"
else:
  A=str(bin(f(a-1))[2:])
m=max(len(A),len(B))
A=A.zfill(m)
B=B.zfill(m)
ans=""
for i in range(len(B)):
  if B[i]==A[i]:
    ans+="0"
  else:
    ans+="1"
print(int(ans,2))


Measured memory_bytes: 3188
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B = LS()

    A = int(A)
    B0 = int(B[0])
    B1 = int(B[2])
    B2 = int(B[3])
    ans = (A*B0*100 + A*B1*10 + A*B2) // 100
    print(ans)

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int t, n;
  while (cin >> t >> n, t) {
    int m = to_string(n).size();
    V<> a;
    map< int, VV<> > mp;
    auto dfs = [&](auto dfs) -> void {
      if (accumulate(begin(a), end(a), 0) == m) {
        int i = 0, s = 0;
        for (int e : a) {
          s += stoi(to_string(n).substr(i, e));
          i += e;
        }
        if (s <= t) mp[s].push_back(a);
        return;
      }
      for (int i = 1; accumulate(begin(a), end(a), 0) + i <= m; ++i) {
        a.push_back(i);
        dfs(dfs);
        a.pop_back();
      }
    };
    dfs(dfs);
    if (mp.empty()) cout << "error\n";
    else if (rbegin(mp)->second.size() >= 2) cout << "rejected\n";
    else {
      cout << rbegin(mp)->first;
      int i = 0;
      for (int e : rbegin(mp)->second[0]) {
        cout << ' ' << to_string(n).substr(i, e);
        i += e;
      }
      cout << '\n';
    }
  }
}


Measured memory_bytes: 3244
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] input = scanner.nextLine().split("");
        if(!(input.length%2==0)){
            System.out.println("No");
            return;
        }
        boolean hiString = true;
        for(int x =0; x<input.length-1; x+=2){
            if(!(input[x].equals("h") && input[x+1].equals("i"))){
                hiString = false;
                break;
            }
        }
        System.out.println(hiString?"Yes":"No");

    }

}


Measured memory_bytes: 21972
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
const int N=1000+7;
int n,size[N],w[N],f[N];
int lst[N],nxt[N],to[N],tot;
void add(int x,int y){
    nxt[++tot]=lst[x];
    to[tot]=y;
    lst[x]=tot;
}
void init(){
    cin>>n;
    int fa;
    for(int i=2;i<=n;i++){
        scanf("%d",&fa);
        add(fa,i);
    }
    for(int i=1;i<=n;i++) scanf("%d",&w[i]);
}
bool run(int u){
    int sum=0,cnt=0,box[N];
    for(int i=lst[u];i;i=nxt[i]){
        int v=to[i];
        if(!run(v)) return 0;
        size[u]+=size[v];
        int les=min(w[v],size[v]-w[v]);
        int lar=max(w[v],size[v]-w[v]);
        sum+=les;
        box[++cnt]=lar-les;
    }
    if(sum>w[u]){ return 0; }
    sum=w[u]-sum; int maxn=0;
    /*for(int i=1;i<=cnt;i++) printf("%d ",box[i]);
      printf("\n");*/
    sort(box+1,box+1+cnt);
    //memset(f,0,sizeof(f));
    priority_queue<int> h[cnt+7];
    for(int i=1;i<=cnt;i++){
        //printf("%d ",box[i]);
        if(box[i]>sum) break;
        for(int j=i;j>=1;j--){
            int tmp=0;
            if(!h[j-1].empty()) tmp=h[j-1].top();
            while(!h[j-1].empty()&&tmp+box[i]>sum){ h[j-1].pop();tmp=h[j-1].top(); }
            if(tmp+box[i]>sum) continue;
            h[j].push(tmp+box[i]);
            maxn=max(maxn,tmp+box[i]);
            }
    }
    //printf("\n");
    size[u]+=sum-maxn;
    //printf("%d: %d %d\n\n",u,w[u],size[u]);
    return 1;
}
int main(){
    //freopen("tree.in","r",stdin);
    init();
    if(run(1)) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mp(x,y) make_pair(x,y)
const int nax=2001;
void solve(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    map<int,int> m;
    ll ans=0;
    for(int i=0;i<n;i++){
        int g=i-a[i];
        if(m.count(g)==1)
        ans+=m[g];
        m[i+a[i]]++;
    }
    cout<<ans<<'\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tc;
    tc=1;
    while(tc--){
        solve();
    }
return 0;
}


Measured memory_bytes: 13804
#include <stdio.h>

int main()
{
	int n, q, x, ans = 0;
	int S[10001];
	int T[500];
	
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) { scanf("%d", &S[i]); }
	scanf("%d", &q);
	for(int i = 0; i < q; ++i) { scanf("%d", &T[i]); }

	for(int i = 0; i < q; ++i)
	{
		// 番兵設定
		S[n] = T[i];

		// 線形探索
		x = 0;
		while(S[x] != T[i])
		{
			++x;
		}

		// 番兵でなければカウント
		if(x != n)
		{
			++ans;
		}
	}
	printf("%d\n", ans);
}



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

int main (){
    int a,b,C;
    double S,L,h,si,c;
    cin>>a>>b>>C;
    double pi = acos(-1);
    si=C*pi/180;
    S=a*b*sin(si)/2;
    c=sqrt(a*a+b*b-2*a*b*cos(si));
    L=a+b+c;
    h=S*2/a;
    printf("%lf\n%lf\n%lf\n",S,L,h);
    return 0;
}


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

int main() {
  int H, W, i;
  cin >> H >> W;
  vector<string> pic(H);
  
  for(i = 0; i < H; i++){
    cin >> pic.at(i);
  }
  
  // 以降, 出力する
  for(i = 0; i < W+2; i++){
    cout << '#';
  }
  cout << endl;
  for(i = 0; i < H; i++){
    cout << '#' << pic.at(i) << '#' << endl;
  }
  for(i = 0; i < W+2; i++){
    cout << '#';
  }
  cout << endl;
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll a[3],b[3];
    ll cnt[4];
    mem0(cnt);
    for (int i = 0; i < 3; i++) {
        cin >> a[i] >> b[i];
        cnt[a[i]-1]++;
        cnt[b[i]-1]++;
    }
    ll c[10];
    mem0(c);
    for (int i = 0; i < 4; i++) {
        c[cnt[i]]++;
    }
    YES(cnt[1] == 2 && cnt[2] == 2);
}

Measured memory_bytes: 3508
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

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

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXC = 10;
LL res[MAXC];

int h, w, n;

map<PII, int> cnt;

inline bool isvalid(int x, int y) {
    return x >= 1 && x <= h && y >= 1 && y <= w;
}

int main() {
    GI(h); GI(w); GI(n);

    FORN(i, n) {
        int a, b; GI(a); GI(b);

        for (int dx = -2; dx <= 0; dx++) {
            for (int dy = -2; dy <= 0; dy++) {
                int ca = a + dx;
                int cb = b + dy;

                if (isvalid(ca, cb) && isvalid(ca+2, cb+2)) {
                    cnt[MP(ca, cb)]++;
                }
            }
        }
    }

    res[0] = 1LL * (h-2) * (w-2);

    for (auto& p : cnt) {
        res[p.SS]++;
        res[0]--;
    }

    FORN(i, MAXC) cout << res[i] << "\n";

    return 0;
}

Measured memory_bytes: 56448
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N;
	cin>>N;
	VI A(N*3);
	REP(i,3*N)cin>>A[i];
	rSORT(A);
	ll ans=0;
	for(int i=1;i<2*N;i+=2)ans+=A[i];
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1408