akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll a,b;
    cin >> a >> b;
    cout << (a*3 + b)/2 << endl;

    return 0;
}

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

int main()
{
    string str;
    cin >> str;
    string sub1, sub2, sub3;
    sub1 = str.substr(0, 5);
    sub2 = str.substr(6, 7);
    sub3 = str.substr(14, 5);
    cout << sub1 << " " << sub2 << " " << sub3 << " " << endl;
    return 0;
}

Measured memory_bytes: 256
import fractions
import sys
from functools import reduce
import math

input = sys.stdin.readline


def main():
    n, a, b = input_list()
    if a > b:
        print(0)
        exit(0)
    if n == 1 and a != b:
        print(0)
        exit(0)
    if n == 1 and a == b:
        print(1)
        exit(0)
    min_num = (a*(n-1))+b
    max_num = (b*(n-1))+a
    print(max_num-min_num+1)


def get_camulative(l):
    import itertools
    # 累積和
    return [0] + list(itertools.accumulate(l))

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


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()


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

int main() {
    ll X, Y;
    cin >> X >> Y;
    ll ans = 0;
    ll n = X;
    for(int i = X; n <= Y; i++){
        n = n * 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		boolean flag = true;
		String[] D = S.split("hi");
		for(int i = 0; i < D.length; i++) {
			if(D[i]!="")flag = false;
		}
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23252
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        if ((y-2*x) >= 0 && (y-2*x)%2 == 0 && (4*x-y) >= 0 && (4*x-y)%2 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 300005;

/* ...o(^-^)o... */

map<lint, lint> mp;
lint A,B,C,D;

lint rec(lint n){
    if(n == 0) return 0;
    if(n == 1) return D;
    if(mp[n] != 0) return mp[n]; // 計算済みならもうやらない(メモ化再帰)

    lint ans = n*D; // -1 だけで全部片付けるとき
    if(ans<0) ans = INF; // オーバーフローした場合はどうせダメなのでINFにしておく（やばそう）
    
    lint p[3] = {2,3,5};
    lint q[3] = {A,B,C};
    rep(i,3){ // 2,3,5それぞれに対して
        lint tmp = q[i] + D*(n%p[i]) + rec(n/p[i]); //割り切れる時は割る, 割り切れない時は余りを引いて割る
        if(n%p[i]) tmp = min(tmp, q[i] + D*(p[i]-n%p[i]) + rec(n/p[i]+1)); //割り切れない時は (除数-余り) を足して割るのも試す
        ans = min(ans, tmp);
    }

    mp[n] = ans; // 結果を記録しておく
    return ans;
}

int main(){
    int t; cin>>t;
    rep(i,t){
        lint N;
        cin>>N>>A>>B>>C>>D;
        out(rec(N));
        mp.clear();
    }
}


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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> x(N);
  int cnt = 0;
  rep(i,N){
    cin >> x.at(i); 
    if(x.at(i) > K / 2){
      x.at(i) = K - x.at(i);
    }
    cnt += x.at(i);
  }
  cout << cnt*2 << endl;
}



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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9+7;

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

    int n,d;cin>>n>>d;
    int a[n][d];
    REP(i,n) REP(j,d) cin>>a[i][j];
    ll dis;
    ll ans=0;
    REP(i,n){
        FOR(j,i,n-1){
            dis = 0;
            REP(k,d){
                dis += ll(pow((a[i][k]-a[j][k]),2));    
            }
            for(ll l=1;l*l<=dis;l++){
                if (dis == l*l) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define llint long long int

using namespace std;

int main(){
    string S;

    cin >> S;

    vector<int> ans(S.length(), 0);

    for(int i = 0; i < S.length() - 1; i ++){
        if(S[i] == 'R' && S[i + 1] == 'L'){
            ans[i] ++;

            for(int j = i - 2; j >= 0 && S[j] == 'R' && S[j + 1] == 'R'; j -= 2){
                ans[i] ++;
            }
            for(int j = i + 2; j < S.length() && S[j] == 'L' && S[j - 1] == 'L'; j += 2){
                ans[i] ++;
            }
            ans[i + 1] ++;

            for(int j = i + 1 - 2; j >= 0 && S[j] == 'R' && S[j + 1] == 'R'; j -= 2){
                ans[i + 1] ++;
            }
            for(int j = i + 1 + 2; j < S.length() && S[j] == 'L' && S[j - 1] == 'L'; j += 2){
                ans[i + 1] ++;
            }
        }
    }
    for(int i = 0; i < S.length(); i ++){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define INF 1000000000


int dy[4] = { -1, 0, 1, 0 };
int dx[4] = { 0, 1, 0, -1 };

int main() {
	int W, H;
	while (cin >> W >> H, W || H) {
		int fy, fx;
		char field[21][21];
		bool visit[21][21] = {};
		REP(i, 0, H) REP(j, 0, W) {
			cin >> field[i][j];
			if (field[i][j] == '@') {
				fy = i;
				fx = j;
				visit[i][j] = true;
			}
		}

		queue<pair<int, int>> q;
		pair<int, int> pii;
		q.push(make_pair(fy, fx));
		visit[fy][fx] = true;

		while (!q.empty()) {
			pii = q.front();
			q.pop();

			REP(k, 0, 4) {
				int y = pii.first + dy[k];
				int x = pii.second + dx[k];
				if (y < 0 || x < 0 || y >= H || x >= W) continue;
				if (field[y][x] == '#' || visit[y][x]) continue;

				visit[y][x] = true;
				q.push(make_pair(y, x));
			}
		}

		int ans = 0;
		REP(i, 0, H) {
			REP(j, 0, W) {
				if (visit[i][j]) ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  string z;
  for (int i = 0; i < N; i++) {
    string x;
   
    cin >> x;
    
    if (x == "Y") {
      z = "Four";
      break;
    }
    
    else if (x == "P" || x == "W" || x == "G" ){
      z = "Three";
    }
  }
  
  cout << z << endl;
    
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const int MOD = 1e+9 + 7;

template <typename T>
T pow_mod( T n, T p )  // n^p % m
{
    if( p == 0 ) return 1;
    if( p%2 == 1 ) return pow_mod(n, p-1) * n % MOD;
    else{
        T tmp = pow_mod(n, p/2) % MOD;
        return tmp*tmp % MOD;
    }
}

template <typename T>
T nCk_mod( T n, T k )
{
    if( n < 0 or k < 0 || n < k ) return 0;
    T numerator = 1, denominator = 1;
    for( int i = 1; i <= min(k, n-k); ++i ){
        numerator = numerator*(n-i+1) % MOD;
        denominator = denominator*i %MOD;
    }
    return numerator * pow_mod<T>(denominator, MOD-2) % MOD;
}

int main()
{
    long long N, M, K;
    cin >> N >> M >> K;

    long long fact = nCk_mod<long long>(N*M-2, K-2);

    long long ans = 0;
    // x 方向
    FOR(i, 1, N){  // |x_i - x_j| == i のものを考える
        ans += i * (N-i) * M*M * fact % MOD;
        ans %= MOD;
    }
    // y 方向
    FOR(i, 1, M){
        ans += i * (M-i) * N*N * fact % MOD;
        ans %= MOD;
    }
    cout << ans << endl; 
    
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d%d",$N,$D);
$row=array();
$cnt=0;
for($n=1;$n<=$N;$n++){
    $row[$n]=explode(" ",fgets(STDIN));
    if($n==1)continue;
    for($m=$n-1;0<$m;$m--){
        $dst=0;
        $stp=$n-$m;
        for($d=0;$d<$D;$d++){
            $x=intval($row[$n][$d]);
            $y=intval($row[$n-$stp][$d]);
            $dst+=pow($y-$x,2);
        }
        $sqt=sqrt($dst);
        $cnt+=($sqt-intval(sqrt($dst))==0)?1:0;
    }
}
echo $cnt;

Measured memory_bytes: 3576
import itertools
#h,w=map(int,input().split())
#S=[list(map(int,input().split())) for _ in range(h)]
n=int(input())
A=list(map(int,input().split()))
Ar=list(itertools.accumulate(A))
ans=0
for i in range(n-1):
    ans+=A[i]*(Ar[n-1]-Ar[i])
    ans%=10**9+7
print(ans)


Measured memory_bytes: 31196
#include<cmath>
#include<cstdio>

int N;

int main(){
    scanf("%d",&N);
    int A=0,B=0;
    for(int i=1;i<=N;i++){
        int x;
        scanf("%d",&x);
        A+=x,B+=x*x;
    }
    int k=floor(A*1.0/N+0.5);
    printf("%d",N*k*k-2*A*k+B);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const int MOD=1000000007;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, k;
	cin>>a>>b>>k;
	int cnt=0;
	FORR(i, 1, min(a, b)+1){
		if(a%i==0 && b%i==0){
			if(cnt+1==k){
				cout<<i<<'\n';
				return 0;
			}
			else{
				++cnt;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long int ll;

int main(){

    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0;i < s.length()/2;i++){

        if(s.substr(0,i) == s.substr(i,i)){
            ans = 2*i;
        }
   }
   cout << ans << endl;


    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	set_delete
# CreatedDate:  2020-07-15 11:57:08 +0900
# LastModified: 2020-07-15 12:06:49 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    q = int(input())
    S = set()
    for _ in range(q):
        command = input().split()
        if command[0] == '0':
            S.add(int(command[1]))
            print(len(S))
        elif command[0] == '1':
            if int(command[1]) in S:
                print(1)
            else:
                print(0)
        else:
            S.discard(int(command[1]))


if __name__ == "__main__":
    main()



Measured memory_bytes: 23372
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		List<Integer> inputList = new ArrayList<>();
		sc.nextLine();
        for (int i = 0; i < K; i++) {
        	inputList.add(sc.nextInt());
        }

        int ans = N;

        nLoop : while (true) {
        	String ansString = String.valueOf(ans);
        	for (Integer d : inputList) {
            	if (ansString.contains(String.valueOf(d))) {
            		ans++;
            		continue nLoop;
            	}
            }
        	System.out.println(ans);
        	break;
        };




	}
}

Measured memory_bytes: 36820
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

//main
int main(){
  int A,B;
  cin >> A >> B;
  int ans = 0;
  ans += max(A,B);
  if(ans == A) cout << ans+max(A-1,B) << endl;
  else cout << ans+max(A,B-1) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int N,K;
    cin>>N>>K;
    int arr[N];
    int count=0;
    for(int i=0;i<N;i++){
        cin>>arr[i];
    }
    sort(arr,arr+N);
    for(int i=0;i<K;i++){
        count+=arr[i];
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    
    int n=s.length();
    int zen = (n-1)/2;
    int kou = (n+3)/2;
    
    string z=s.substr(0,zen);
    string k=s.substr(kou-1);
    
    //cout<<z<<k<<endl;
    
    if(z==k){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Linq;
class E { static void Main() => new _K(); }
class _K
{
	int[] G => Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
	public const long Mod = 924844033;
	int N, K;
	long ans, s = 1;
	long[,] comb;
	public _K()
	{
		var I = G;
		N = I[0]; K = I[1];
		var M = N / K + 10;
		comb = new long[M, M];
		for (var i = 0; i < M; i++) comb[i, 0] = 1;
		for (var i = 1; i < M; i++) for (var j = 1; j <= i; j++) comb[i, j] = (comb[i - 1, j] + comb[i - 1, j - 1]) % Mod;
		var p = Convolution(Pow(Chain(N / K), 2 * (K - N % K)), Pow(Chain(N / K + 1), 2 * (N % K)));
		var fact = new long[N + 1];
		fact[0] = 1;
		for (var i = 1; i <= N; i++) fact[i] = (i * fact[i - 1]) % Mod;
		for (var i = 0; i < Math.Min(N + 1, p.Length); i++)
		{
			ans = (ans + s * fact[N - i] * p[i] % Mod) % Mod;
			s *= -1;
		}
		if (ans < 0) ans += Mod;
		Console.WriteLine(ans);
	}
	long[] Chain(int n)
	{
		var p = new long[n / 2 + 1];
		for (var k = 0; k <= n / 2; k++) p[k] = comb[n - k, k];
		return p;
	}
	long[] Pow(long[] a, int n)
	{
		var p = new long[] { 1 };
		var x = a;
		while (n > 0)
		{
			if ((n & 1) == 1) p = Convolution(p, x);
			n >>= 1;
			x = Convolution(x, x);
		}
		return p;
	}
	long[] Convolution(long[] a, long[] b)
	{
		int p = a.Length, q = b.Length;
		var c = new long[p + q - 1];
		for (var i = 0; i < p; i++)
			for (var j = 0; j < q; j++)
				c[i + j] = (c[i + j] + a[i] * b[j] % Mod) % Mod;
		return c;
	}
}


Measured memory_bytes: 25808
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi>b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //------------------------------
    ll k;cin>>k;
    ll n=50;V<ll>a(50);

    for(ll i=0;i<50;i++){
        a[i]=i;
    }

    ll x = k/n;
    for(ll i=0;i<50;i++)a[i]+=x;

    ll c = k%n;

    for(ll j=0;j<c;j++){
        ll now=j;
        //cout<<now<<endl;
        for(ll i=0;i<n;i++){
            if(i==now)a[i]+=n;
            else a[i]--;
        }
    }
    cout<<n<<endl;
    for(ll i=0;i<n;i++){

        cout<<a[i]<<" ";
    }
    cout<<Endl;
    
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------






































Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const int INF=100100100;
const double PI=3.141592653589;


int main(){
  int n,l; cin>>n>>l;
  int ans=0;
  int mi=INF;
  for(int i=1;i<=n;i++){
    int c=i+l-1;
    ans+=c;
    if(c<0)
    c=-c;
    mi=min(mi,c);
  }
  // cout<<ans<<endl;
  // if(l>0){
  //   ans-=l;
  // }else if(l<0){
  //   if(-l>n){
  //     ans-=n+l-1;
  //   }
  // }

  cout<<(ans<0?ans+mi:ans-mi)<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    int a, b, c, n;
    int[] ls;
    int[] ts;

    void run() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        LinkedList<Character> q = new LinkedList<>();
        int cnt = 0;

        for (char c: s.toCharArray()) {
            if (!q.isEmpty() && q.getLast() != c) {
                q.removeLast();
                cnt += 2;
            } else {
                q.addLast(c);
            }
        }
        System.out.println(cnt);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

bool mycomp(tuple<string, int, int> t, tuple<string, int, int> t2)
{
    if (get<0>(t) != get<0>(t2))
        return get<0>(t) < get<0>(t2);
    if (get<1>(t) != get<1>(t2))
        return get<1>(t) > get<1>(t2);
    return get<2>(t) < get<2>(t2);
}

signed main()
{
    int n;
    int p[100];
    string s[100];

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> s[i] >> p[i];

    vector<tuple<string, int, int>> v;
    for (int i = 0; i < n; i++)
        v.push_back(make_tuple(s[i], p[i], i + 1));

    sort(all(v), mycomp);

    for (int i = 0; i < v.size(); i++)
        cout << get<2>(v[i]) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int cnt = 0;
    rep(i, n){
        if(s[i]=='p'){cnt++;}
    }
    cout << n/2-cnt;

}

Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> up(n, 1), down(n, -1);
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    --p;
    up[p] += i;
    if (p != n - 1)
      down[p + 1] -= i;
  }
  up[0] = down[0] = 5e8;
  for (int i = 1; i < n; ++i) {
    up[i] = up[i - 1] + up[i];
    down[i] = down[i - 1] + down[i];
  }
  for (const auto &ans : up) {
    cout << ans << " ";
  }
  cout << endl;
  for (const auto &ans : down) {
    cout << ans << " ";
  }
  cout << endl;
}


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

int main() {
	int max=0, n,x=0,i;
char s[101];
cin >>n;
for(i=0;i<n;i++)
{cin>>s[i];
if (s[i]=='I')
x++;
else x--;
if( x>max)
max = x;
}
cout <<max;
	return 0;
}

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

char a[10000];

int main(){
	int b,c,d=0,e=0,i;
	while(scanf("%s",&a)!=EOF){
		d=0;e=0;
	c=strlen(a);
	for(i=0;i<c-2;i++){
		if(a[i]=='J'&&a[i+1]=='O'&&a[i+2]=='I'){
			d++;
		}
		if(a[i]=='I'&&a[i+1]=='O'&&a[i+2]=='I'){
			e++;
		}
	}
	printf("%d\n%d\n",d,e);
}
}

Measured memory_bytes: 976
#include<iostream>
#include<cstdio>
using namespace std;
typedef pair<int,int> P;
int d[101000];P q[201000];int H=100000,T=100000;
int h[101000],nxt[201000],K=0,to[201000],cost[201000];
void ins(int u,int v,int c){nxt[++K]=h[u];h[u]=K;to[K]=v;cost[K]=c;}
int main()
{
	int k;scanf("%d",&k);
	for(int i=0;i<k;i++)ins(i,i*10%k,0),ins(i,(i+1)%k,1);
	q[T++]=P(1,1);
	while(H<T)
	{
		P p=q[H++];int u=p.first;if(d[u])continue;d[u]=p.second;
		for(int i=h[u];i;i=nxt[i])if(!cost[i])q[--H]=P(to[i],d[u]);else q[T++]=P(to[i],d[u]+1);
	}
	printf("%d",d[0]);return 0;
}
//我们发现，在模k意义下同余的sum是等价的，只要保留答案最小的即可
//新建一个图，共 k 个节点，代表 模k 得到的值。
//建边的依据是已知一个数x%k=p，那么在 x 后面再加一位数得到 y ，可以知道 y%k 的值，于是就得到了一个图，每条边代表往后加一位，边权就是这一位的数字。
//跑一遍最短路，其中 d[i] 意义就是模 k 余 i 的数中每一位的和最少是多少，开始 1~9 都加入队列
//但是还可以优化
//我们是把a向(a*10+b)%k连一条边权为b的边
//画个图我们会发现，只要把a向a*10%k 连一条边权为0的边 和 (a+1)%k 连一条边权为1的边即可，这与原图是等价的
//这种连边可以理解为把这个数后面加一个0或者把这个数加1 
//跑01bfs即可 

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

using namespace std;

int main() {
	int H, W;

	vector<int> move_delta_x = {-1, 1, 0, 0};
	vector<int> move_delta_y = {0, 0, -1, 1};
	vector<int> warp_delta_x = {-2, -2, -2, -2, -2, -1, -1, -1, -1, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2};
	vector<int> warp_delta_y = {2, 1, 0, -1, -2, 2, 1, -1, -2, 2, -2, 2, 1, -1, -2, 2, 1, 0, -1, -2};

	int Ch,Cw,Dh,Dw;
	cin >> H >> W;
	cin >> Ch >> Cw;
	cin >> Dh >> Dw;
	Ch--, Cw--, Dh--, Dw--;


	vector<vector<char>> board(H, vector<char>(W));
	vector<vector<int>> cost(H, vector<int>(W, -1));
	queue<pair<int, int>> checked_move;
	queue<pair<int, int>> checked_warp;
	int y, x;


	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			cin >> board[i][j];
		}
	}

	cost[Ch][Cw] = 0;
	checked_move.push(pair<int, int>(Ch, Cw));
	checked_warp.push(pair<int, int>(Ch, Cw));	

	while(checked_move.empty() == false || checked_warp.empty() == false) {
		if(checked_move.empty() == false) {
			y = checked_move.front().first;
			x = checked_move.front().second;
			checked_move.pop();

			for(int i = 0; i < 4; i++) {
				if(y + move_delta_y[i] >= 0 && y + move_delta_y[i] < H && x + move_delta_x[i] >= 0 && x + move_delta_x[i] < W) {
					if(board[y + move_delta_y[i]][x + move_delta_x[i]] == '.') {
						if(cost[y + move_delta_y[i]][x + move_delta_x[i]] != -1) {
							continue;
						} else {
							cost[y + move_delta_y[i]][x + move_delta_x[i]] = cost[y][x];
							checked_move.push(pair<int, int>(y + move_delta_y[i], x + move_delta_x[i]));
							checked_warp.push(pair<int, int>(y + move_delta_y[i], x + move_delta_x[i]));
						}
					}
				}
			}
		} else {
			y = checked_warp.front().first;
			x = checked_warp.front().second;
			checked_warp.pop();

			for(int i = 0; i < 20; i++) {
				if(y + warp_delta_y[i] >= 0 && y + warp_delta_y[i] < H && x + warp_delta_x[i] >= 0 && x + warp_delta_x[i] < W) {
					if(board[y + warp_delta_y[i]][x + warp_delta_x[i]] == '.') {
						if(cost[y + warp_delta_y[i]][x + warp_delta_x[i]] != -1) {
							continue;
						} else {
							cost[y + warp_delta_y[i]][x + warp_delta_x[i]] = cost[y][x] + 1;
							checked_move.push(pair<int, int>(y + warp_delta_y[i], x + warp_delta_x[i]));
							checked_warp.push(pair<int, int>(y + warp_delta_y[i], x + warp_delta_x[i]));
						}
					}
				}
			}
		}
	}
	

	cout << cost[Dh][Dw] << endl;
	return 0;
}

Measured memory_bytes: 8532
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
#define pb push_back
int main()
{
	int n,m;
	while(1)
	{
		cin >> n >> m;
		if(n == 0 && m == 0) return 0;
		vector<int>vec;
		for(int i=0;i<n;i++)
		{
			int x; cin >> x; vec.pb(x);
		}
		sort(vec.begin(),vec.end(),greater<int>());
		int res = 0;
		for(int i=0;i<vec.size();i++) if(i%m != m-1) res += vec[i];
		cout << res << endl;
	}
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<set<int>>;

void	dfs(const Graph &graph, const vector<int> &H_vec, 
			vector<int> &is_good, vector<bool> &seen, int u)
{
	seen.at(u) = true;
	int H_u = H_vec.at(u);
	bool is_g = true;
	for (int v : graph.at(u)) {
		if (H_u <= H_vec.at(v))
			is_g = false;
		if (seen.at(v))
			continue;
		dfs(graph, H_vec, is_good, seen, v);
	}
	if (is_g)
		is_good.at(u) = 1;
	else
		is_good.at(u) = 0;
}

int	main()
{
	int	N, M;
	cin >> N >> M;
	vector<int>	H_vec(N);
	for (int i = 0; i < N; ++i)
		cin >> H_vec.at(i);
	Graph	graph(N);
	int	A, B;
	for (int i = 0; i < M; ++i) {
		cin >> A >> B;
		--A; --B;
		graph.at(A).insert(B);
		graph.at(B).insert(A);
	}
	vector<bool>	seen(N, false);
	vector<int>		is_good(N, -1);
	for (int i = 0; i < N; ++i) {
		if (is_good.at(i) != -1)
			continue;
		dfs(graph, H_vec, is_good, seen, i); 
	}
	int	cnt = 0;
	for (int i = 0; i < N; ++i) {
		if (is_good.at(i) == 1)
			++cnt;
	}
	cout << cnt << endl;
}



Measured memory_bytes: 20628
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] n = sc.next().split("");
        String[] reverseN = new String[n.length];
        for (int i = 0; i < n.length; i++) {
            reverseN[n.length - i - 1] = n[i];
        }
        for (int i = 0; i < n.length; i++) {
            if (!n[i].equals(reverseN[i])) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }

}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxN = 3005;
const int mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(); cout.tie();
    int n;
    string s;

    cin >> n >> s;

    vector<int> f(maxN);
    f[0] = 1;
    for(int i = 1; i <= n - 1; ++i)
    {
        vector<int> f1(maxN);
        int tmp = 0;
        if(s[i - 1] == '<')
            for(int j = 0; j < i; ++j)
            {
                tmp = (tmp + f[j]) % mod;
                f1[j + 1] = tmp;
            }
        else
            for(int j = i - 1; j >= 0; --j)
            {
                tmp = (tmp + f[j]) % mod;
                f1[j] = tmp;
            }
        f = f1;
    }

    int res = 0;
    for(int i = 0; i < n; ++i)
        res = (res + f[i]) % mod;

    cout << res;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(M);
  vector<int> B(M);
  for(int i=0;i<M;i++){
    cin >> A.at(i) >> B.at(i);
  }
  int l_max = *max_element(A.begin(),A.end());
  int r_min = *min_element(B.begin(),B.end());
  cout << max(0,r_min - l_max + 1) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int a, b, sum, k;
  cin >> a >> b;
  sum = a+b;
  if(sum%2==0){
    printf("%d\n", sum/2);
  }else{
    printf("IMPOSSIBLE\n");
  }
  
  return 0;
}


Measured memory_bytes: 256
fn main() {
    const H_MAX: u64 = 1_000_000_000;
    let v = read_nums();
    let (N, K) = (v[0] as usize, v[1] as usize);
    let mut h = vec![0; N as usize];
    for i in 0..N {
        h[i] = read_num();
    }
    h.sort();
    let mut result = H_MAX;
    for i in 0..N-K+1 {
        result = std::cmp::min(result, h[i + K - 1] - h[i]);
    }
    println!("{}", result);
}

fn read_str() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).expect("Failed to read input.");
    s
}

fn read_num() -> u64 {
    read_str().trim().parse().expect("Could not parse.")
}

fn read_nums() -> Vec<u64> {
    let s = read_str();
    let a: Vec<&str> = s.split(' ').collect();
    let mut v: Vec<u64> = Vec::new();
    for x in a {
        v.push(x.trim().parse().expect("Could not parse."));
    }
    v
}

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


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
    //a^tを求める
    //例：d[i] = mint(k/i).pow(n);
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


mint ans=0;
ll n;
vector<int> g[200005];


ll dfs(ll v, ll p){
  mint alln=mint(2).pow(n-1)-1;
//  cout<<alln<<"all"<<endl;
  ll res=1;
  ll cnt=0;
  for(ll to:g[v]){
    if(to==p)continue;
    ll node=dfs(to,v);
    mint nnow=mint(2).pow(node)-1;
    alln-=nnow;

    res+=node;
    cnt+=node;
  }
  alln-=(mint(2).pow(n-1-cnt)-1);
//  cout<<v<<"v"<<res<<"res"<<ans<<"ans"<<endl;
  ans+=alln;
  return res;
}

int main(){
  //ll n;
  cin>>n;
  rep(i,n-1){
    ll a1,b1;
    cin>>a1>>b1;
    a1--;b1--;
    g[a1].push_back(b1);
    g[b1].push_back(a1);

  }
  dfs(0,-1);
  mint A=ans/mint(2).pow(n);
  cout<<A;


}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
string s;
ll t;
ll ret = 0;

void input() {
  IN(N);
  IN(s);
}

void solve() {
  if (N%2 == 1) {
    PRINT("No");
    return;
  }
  REP(i, N/2) {
    char c1 = s[i];
    char c2 = s[i + N/2];
    if (c1 != c2) {
      PRINT("No");
      return;
    }
  }
  PRINT("Yes");
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
const ll INF = 1000000000000;

int main()
{
    int a,b,c;
    std::cin >> a >> b >> c;
    int cnt = 0;
    for(int i = 1000; i >= 1; i--){
        if(a % i == 0 && b % i == 0)cnt++;
        if(cnt == c){
            std::cout << i << std::endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

c = ns()

flag = False
for b in ['a', 'i', 'u', 'e', 'o']:
    if c == b:
        flag = True

print("vowel" if flag else "consonant")

Measured memory_bytes: 3064
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

/** ワーシャル・フロイド法による全点対最短路探索

    経路を逐次最小化していく。

    頂点番号は0オリジン。

    知らないパスにはコスト大きめを設定しておくこと。
    その初期コストはすべての都市を回ってくるパスよりも大きくすべし。
    ただ、内部で加算するのでオーバーフローに注意。MAXダメ、絶対。
    std::fill(mat.data(), mat.data() + mat.num_elements(), MAXCOST+1);

    O(|V|^3)

    @note 反対方向もいれた？
    mat[a][b] = mat[b][a] = c;

    @note 自分自身へのルートはコスト0か？
    for (int i = 0; i < N; ++i) {
    mat[i][i] = 0;
    }

    @param[in] V  頂点数
    @param[in, out] distance[i][j]: 頂点i -> jのコスト
*/
template<typename T, typename M>
void warshall_floyd(T V, M& distance)
{
    for (T k = 0; k < V; ++k) {
        for (T i = 0; i < V; ++i) {
            for (T j = 0; j < V; ++j) {
                distance[i][j] = std::min(distance[i][j],
                                          distance[i][k] + distance[k][j]);
            }
        }
    }
}


int main()
{
    int64_t N, M, R;
    std::cin >> N >> M >> R;

    std::vector<int64_t> r;
    for (decltype(R) i = 0; i < R; ++i) {
        int64_t t;
        std::cin >> t;
        t--;
        r.push_back(t);
    }

    std::sort(std::begin(r), std::end(r));

    boost::multi_array<int64_t, 2> G(boost::extents[N][N]);
    std::fill(G.data(), G.data() + G.num_elements(), 100000 * 200);

//    for (size_t i = 0; i < N; ++i) {
//        G[i][i] = 0;
//    }

    for (decltype(M) i = 0; i < M; ++i) {
        int64_t a, b, c;
        std::cin >> a >> b >> c;
        a--;
        b--;
        G[a][b] = G[b][a] = c;
    }

    warshall_floyd(N, G);

    int64_t ans = INT64_MAX;

    std::sort(r.begin(), r.end());
    do {
        int64_t d = 0;
        for (int64_t i = 1; i < R; ++i) {
              d += G[ r[i-1] ][ r[i] ];
        }
        ans = std::min(ans, d);
    } while (std::next_permutation(r.begin(), r.end()));

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A);
  REP(i, A) cin >> a[i];
  vector<int> b(B);
  REP(i, B) cin >> b[i];
  vector<vector<int>> x(M,vector<int>(3));
  REP(i, M){
    REP(j, 3){
      cin >> x.at(i).at(j);
    }
  }
  
  int MIN = INF;
  REP(i,M){
    MIN = min(MIN,a.at(x.at(i).at(0)-1)+b.at(x.at(i).at(1)-1)-x.at(i).at(2));
  }

  sort(ALL(a));
  sort(ALL(b));
  MIN = min(MIN,a.at(0)+b.at(0));
  cout << MIN << endl;
}

Measured memory_bytes: 6528
#include<iostream>
#include<stack>

using namespace std;

static const int N = 100;
static const int UNVISITED = 0;
static const int VISITING = 1;
static const int VISITED = 2;


int n;
int A[N][N];
int d[N];
int f[N];
int states[N];
int nt[N];
int t;

int next(int u){
  for(int v = nt[u];v < n;v++){
    nt[u] = v + 1;
    //cout << nt[u] << '\n';
    if(A[u][v]) return v;
  }
  return -1;
}

void dfs_visit(int x){
  for(int i = 0;i < n;i++){
    nt[i] = 0;
  }
  
  stack<int> s;
  s.push(x);
  states[x] = VISITING;
  d[x] = ++t;
  
  while(!s.empty()){
    int u = s.top();
    int v = next(u);
    //cout << "u:" << u << " v:" << v << '\n';
    if(v != -1){
      if(states[v] == UNVISITED){
	states[v] = VISITING;
	d[v] = ++t;
	s.push(v);
      }
    }else{
      s.pop();
      states[u] = VISITED;
      f[u] = ++t;
    }
  }
}

void dfs(){
  for(int i = 0;i < n;i++){
    states[i] = UNVISITED;
  }

  t = 0;

  for(int u = 0;u < n;u++){
    if(states[u] == UNVISITED) dfs_visit(u);
  }
  for(int i = 0;i < n;i++){
    cout << i + 1 << " " << d[i] << " " << f[i] << '\n';
  }
}
         
int main(){ 
  cin >> n;
  
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      A[i][j] = 0;
    }
  }
  
  int k,u,v;
  
  for(int i = 0;i < n;i++){
    cin >> u >> k;
    u--;
    for(int j = 0;j < k;j++){
      cin >> v;
      v--;
      A[u][v] = 1;
    }
  }

  dfs();

  return 0;
}




Measured memory_bytes: 3116
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cassert>
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FOREACH(i,c) for(__typeof((c).begin())i = (c).begin();i!=(c).end(); ++i)



int main() {
  char c;
  scanf("%c", &c);
  printf("%c\n", c + 1);

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	fsc := NewFastScanner()
	A, B, C := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	if B-A == C-B {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


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

int main() {
	int n,s=0;
	cin>>n;
	int a[n],b[n],c[n-1];
	for(int i=0;i<n;i++){
		cin>>a[i];
		
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
		s+=b[i];
	}
	for(int i=0;i<n-1;i++){
		cin>>c[i];
	}
	for(int i=0;i<n-1;i++){
		if(a[i]+1==a[i+1]){
			s+=c[a[i]-1];
		}
	}
	
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    int l[q], r[q], p[100005] = {}, a[100005] = {}, b[100005] = {};
    for (int i = 0 ; i < q ; i++) cin >> l[i] >> r[i];
    for (int i = 2 ; i <= 100000 ; i++) {
    	p[i] = 1;
    	for (int j = 2 ; j * j <= i ; j++) if (i % j == 0) p[i] = 0;
	}
    for (int i = 1 ; i <= 100000 ; i++) if (p[i] && p[(i + 1) / 2]) a[i] = 1;
	for (int i = 1 ; i <= 100000 ; i++) b[i] = b[i - 1] + a[i];
	for (int i = 0 ; i < q ; i++) cout << b[r[i]] - b[l[i] - 1] << endl;
}

Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
long long int a[200000], n, b[200000], co;
int main(){
	cin >> n;
	for(long long int i = 0;i < n;i++){
		b[i] = 0;
	}
	for(long long int i = 0;i < n;i++){
		cin >> a[i];
		b[a[i] - 1]++;
	}
	co = 0;
	for(long long int j = 0;j < n;j++){
		co += (b[j] * (b[j] - 1) / 2);
	}
	for(long long int i = 0;i < n;i++){
		cout << co - (b[a[i] - 1] - 1) << endl;
	}
}


Measured memory_bytes: 5760
/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define LL unsigned long long
#define ll long long
#define LD double
#define HabdModeActive ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define PI acos(-1)
#define MAX 5000005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
int n,m;
const  int N = 1e5+ 5;
vector<int>vec[N];
map<pair<int,int>,int>mp;
int cnt = 1e8;
bool vis[N];
void dfs(int x,int sum)
{
    if(x==n)
    {
        if(sum<cnt)
            cnt = sum;

        return;
    }

    if(vis[x])
        return;
    vis[x]=1;

    for(auto &v:vec[x])
    {
        if(!mp.count({x,v}))
            dfs(v,sum+1);
        else
            dfs(v,sum);
    }


}

int main() {
    HabdModeActive
   /* cin>>n>>m;
    for(int i=0 ; i<m ; i++)
    {
        int x,y;
        cin>>x>>y;
        mp[{x,y}]=1;
        vec[x].push_back(y);
        vec[y].push_back(x);
    }
    dfs(1,0);
    cout<<cnt;
*/

   int n;
   cin>>n;
   vector<pair<LL,LL>>vec;
   LL time =0;
   for(int i=0 ; i<n; i++)
   {
       int x,y;
       cin>>x>>y;
       vec.push_back({y,x});
   }
   sort(vec.begin(),vec.end());
   for(int i=0 ; i<n; i++)
   {
       time+=vec[i].S;
       if(vec[i].F<time)
           return cout<<"No",0;
   }
   cout<<"Yes";

    return 0;
}


Measured memory_bytes: 8688
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define rep(i,a,b) for(int i=int(a),nn=int(b);i<=nn;++i)
#define vep(i,a,b) for(int i=int(a),nn=int(b);i>=nn;--i)
#define xep(i,b) for(int i=0,nn=int(b);i<nn;++i)

typedef long long ll;

ll a, b, same;

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

	cin >> a >> b;

	if (a == b) return puts("1"), 0;
	ll l;
	for (l=1ll<<60; l; l>>=1)
		if ((a&l) == (b&l))
			same |= (a&l);
		else break;

	a = a - same, b = b - same - l;

	ll as = l - a;
	
	ll r;
	for (r = l >> 1; r; r>>=1)
		if (b & r) break;
	if (r)
	r = r << 1,  r = r - 1;

	if (a<=r) as = as + l;
	else as = as*2 + r + 1;

	return printf("%lld\n", as), 0;
}

Measured memory_bytes: 256