akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)

int main() {
string name;

cin >> name;
  
  string nic;
  
  rep(i,3){
  nic = nic + name.at(i);
  }
    cout << nic << endl;
  return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;
import java.util.NoSuchElementException;

class Main
{
	public static void main(String args[])
	{
		int num = readInt();
		System.out.println(cubic(num));
	}

	private static int readInt()
	{
		Scanner scanner = new Scanner(System.in);
		try
		{
			return scanner.nextInt();
		} catch (NoSuchElementException e)
		{
			System.out.println("Input Error");
			throw e;
		}
	}

	private static int cubic(int num)
	{
		return num * num * num;
	}
}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
using namespace std;
#define DIM 104
#define ll long long
ll n;
string s;
int main()
{
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '+')
            n++;
        else
            n--;
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	a := getInt()
	b := getInt()

	if a+b >= 10 {
		fmt.Println("error")
	} else {
		fmt.Println(a + b)
	}
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
//#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

int N;
vector<int> A;

const int MEM = 3030;
int dp[MEM][MEM];

int dequeue(int l,int r){
    if(dp[l][r]!=-1){
        return dp[l][r];
    }
    if(l>=r){
        return A[l];
    }
    int k = max(A[l]-dequeue(l+1,r),A[r]-dequeue(l,r-1));
    dp[l][r]=k;
    return k;
}

signed main(void){
    int a;
    cin >> N;
    REP(i,N){cin >> a;A.push_back(a);}
    
    REP(i,MEM){
        REP(j,MEM){
            dp[i][j]=-1;
        }
    }
    
    cout << dequeue(0,N-1) << endl;
    
    return 0;
}



Measured memory_bytes: 72192
#include <iostream>
#include<vector>
#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()
typedef long long ll;

using namespace std;



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

    ll t = 0;
    int i = 0;
    while(t + a[i] <= k && i < n){
        // 条件を満たしている間読む A の冊数を増やす
        t += a[i];
        i++;
    }
    int ans = i, tmp = i;
    --i; // この後で、i には最後に読んだ本(A)の添え字が入っててほしいので
    rep(j, m + 1){
        if(j != 0){
            // B を j 冊読むとする
            t += b[j - 1];
            tmp++;
        }
        while(t > k && i >= 0){
            // 条件を満たすまで読む A の本の数を減らす
            t -= a[i];
            i--;
            tmp--;
        }
        // 読む B の冊数によっては条件を満たしていないことがあるのでチェックする
        if(t <= k) ans = max(ans, tmp);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		N = scanner.nextInt();
		dfs("", 'a');
	}

	static int N;

	static void dfs(String s, char mx) {
		if (s.length() == N) {
			System.out.println(s);
		} else {
			for (char c = 'a'; c <= mx; c++) {
				dfs(s + c, (c == mx ? (char) (mx + 1) : mx));
			}
		}
	}
}


Measured memory_bytes: 44444
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int[] path = new int[4];
        for (int i = 0; i < 3; i++) {
            path[scan.nextInt()-1] += 1;
            path[scan.nextInt()-1] += 1;
        }
        int[] count = new int[5];
        for (int i = 0; i < 4; i++) {
            count[path[i]] += 1;
        }
        if (count[1] == 2 && count[2] == 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

    

    class Program
    {

        
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            var data = new List<int>();
            int sum = 0;

            for(int i = 0; i < N; i++)
            {
                int s = int.Parse(Console.ReadLine());
                sum += s;
                data.Add(s);
            }
            
            data.Sort();

            int mimus = -1;

            if(sum % 10 != 0)
            {
                Console.WriteLine(sum);
                return;
            }
            
            for(int i = 0; i < N; i++)
            {               
                if((sum - data[i]) % 10 != 0)
                {
                    mimus = data[i];
                    break;
                }
            }

            if(mimus == -1)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(sum - mimus);
            }

        }
    }
}


Measured memory_bytes: 11092
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース
  累乗和で解く

  ・総和を求める
  ・取り消すところの一つ先を見る
*/
//main.cpp----------------------------
#define max_n 100000

string s;
int n;
int a[max_n+1];
stack<int> S;

int main() {
  cin >> s;
  n = (int)(s.length());

  rep(i, n) {
    if(s[i]=='0') a[i]=0;
    else a[i]=1;
  }

  int cnt = 0;
  S.push(a[0]);
  for(int i=1; i<n; ++i) {
    if(S.empty()==1) {
      S.push(a[i]);
    }else if(S.top()!=a[i]) {
      S.pop();
      cnt += 2;
    }else {
      S.push(a[i]);
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int solve(int* L, int* R,int* d){
  int count=0;
  for(int i=*L;i<=*R;i++){
  if(i%*d==0){
    count++;
  }
  }
  return count;
}
int main(){
  int L=0,R=0,d=0;
  cin>>L>>R>>d;
  cout<<solve(&L,&R,&d)<<'\n';
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
long long n,s;
long long count(long long b){
    long long ans=0,val=n;
    while(val){
        ans+=val%b;
        val/=b;
    }
    return ans;
}
signed main(){
    cin >> n >> s;
    for(long long i = 2; i * i <= n; i++){
        if(count(i) == s){
            cout << i;
            return 0;
        }
    }
    for(long long i = sqrt(n) - 1; i >= 1; i--){
        if(s < i) continue;
        long long tmp = n - (s - i);
        if((tmp % i) != 0) continue;
        if((tmp / i) <= (s - i)) continue;
        if((tmp / i) == 1) continue;
        cout << tmp / i;
        return 0;
    }
    if(s == 1){
        if(n == 1) cout << 2;
        else cout << n;
        return 0;
    }
    if(s == n){
        cout << n + 1;
        return 0;
    }
    cout << -1;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  ll n, k;
  cin >> n >> k;
  vi a(n), f(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(all(a));
  sort(rall(f));
  ll l = -1, r = 1e12;
  while(l+1 < r) {
    ll mid = (l+r)/2;
    ll cnt = 0;
    rep(i,n) {
      ll d = a[i] - mid / f[i];
      if(d > 0) cnt += d;
    }
    if(cnt <= k) r = mid;
    else l = mid;
  }
  cout << r << endl;
}

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

int main(void) {
    int N,a;
    int sum = 0;
    cin >> N;
    for(int i=0;i<N;i++) {
        cin >> a;
        while((a%2) == 0) {
            sum++;
            a/=2;
        }
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 210, MOD = 998244353;
int power(int a,int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}
typedef double db;
struct point {
  db x,y;
  point(db x_=0, db y_=0): x(x_), y(y_) {}
  point operator + (const point& a) const {
    return point(x + a.x, y + a.y);
  }
  point operator - (const point& a) const {
    return point(x - a.x, y - a.y);
  }
} po[N];
db cross(const point& a,const point& b) {
  return a.x * b.y - a.y * b.x;
}
int n,ans,vis[N];
int main() {
  scanf("%d",&n);
  for (int i = 1, x, y ; i <= n ; ++ i) {
    scanf("%d%d",&x,&y);
    po[i] = point(x,y);
  }
  ans = power(2, n);
  for (int i = 1 ; i <= n ; ++ i) {
    memset(vis,0,sizeof vis);
    ans --;
    for (int j = i + 1 ; j <= n ; ++ j) {
      if (vis[j]) continue;
      int num = 1;
      for (int k = j + 1 ; k <= n ; ++ k) {
	if (cross(po[k] - po[i], po[k] - po[j]) != 0) continue;
	vis[k] = 1;
	++ num;
      }
      (ans -= power(2, num) - 1) %= MOD;
    }
  }
  ans --;
  ans = (ans % MOD + MOD) % MOD;
  printf("%d\n", ans);
  return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int n, l;
    cin >> n >> l;
    int x = 10000;
    int t = 0;
    int j = - 1;
    REP(i, n) {
        t += l + i;
        if (x > abs(l + i)) {
            j = i;
            x = abs(l + i);
        }
    }
    cout << t - (l + j) << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i,N){
    cin >> L.at(i);
  }
  sort(L.begin(),L.end());
  int sum = 0;
  rep(i,N-1){
    sum += L.at(i);
  }
  if(L.at(N-1)<sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
dic = {}
def is_ok(a,b,p,m,n):
    # 条件を満たすかどうか？問題ごとに定義
    d = a*(10**(m-1)) + p*10 + b
    if a*(10**(m-1)) + p*10 + b <= n:
        return True
    return False
def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(i,j,mid,m,n):
            ok = mid
        else:
            ng = mid
    return ok
for i in range(1,10):
    for j in range(1,10):
        ans = 0
        if i == j and i <= n:
            ans += 1
        if 10*i+j <= n:
            ans += 1
        if len(str(n)) >= 3:
            m = len(str(n))
            ans += (10**(m-2)-10)//9
            ng = 10**(m-2)
            ok = -1
            c = meguru_bisect(ng, ok)
            ans += c + 1
        dic[10*i+j] = ans
cnt = 0
for k in range(1,10):
    for l in range(1,10):
        cnt += dic[10*k+l]*dic[10*l+k]
print(cnt)
        

Measured memory_bytes: 64784
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll INF=1e9+7;


int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n),sum(n+1);
    rep(i,n){
        cin >> a[i];
        sum[i+1]=sum[i]+a[i];
    }
    vector<ll> bt;
    for(ll i=0;i<=n;i++){
        for(ll j=i+1;j<=n;j++){
            bt.push_back(sum[j]-sum[i]);
        }
    }
    vector<ll> buf;
    ll ans=0;
    for(ll i=40;i>=0;i--){
        ll cnt=0;
        rep(j,bt.size()){
            if((bt[j]>>i)%2==1){
                cnt++;
                buf.push_back(bt[j]);
            }
        }
        if(cnt>=k){
            bt=vector<ll>(cnt);
            bt=buf;
            ans+=1LL<<i;
        }
        buf.clear();
    }
    cout << ans << endl;
}

Measured memory_bytes: 9020
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(Math.abs(b-x)>Math.abs(a-x)){
      System.out.println("A");
    }else{
      System.out.println("B");
    }
  }
}

Measured memory_bytes: 20948
K, X = map(int, input().split())
min = -1000000
max = 1000000
if X - (K -1) > -1000000:
    min = X-(K-1)
    
if X + (K + 1) < 1000000:
    max = X + (K - 1)
    
for i in range(min,max+1):
    print(i)

Measured memory_bytes: 3064
#!/usr/bin/env python3
b = 0
s = input()
if int(s[:4]) < 2019:
    b = 1
elif int(s[:4]) == 2019:
    if int(s[5:7]) < 4:
        b = 1
    elif int(s[5:7]) == 4:
        if int(s[9:11]) <=30:
            b = 1

if b:
    print('Heisei')
else:
    print('TBD')


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main() {
    int k, n;
    cin >> k >> n;
    int h[200000]={}, i, d[200000]={};
    for(i=0; i<n; i++) {
        cin >> h[i];
    }
    for(i=0; i<n-1; i++) {
        d[i] = h[i+1] - h[i];
    }
    int min=d[0], max2 = h[n-1] - h[0];
    for(i=1; i<n-1; i++) {
        if(min < d[i]) min = d[i];
    }
    min = k-min;
    if(min > max2) min = max2;
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 2424
from sys import stdin
def main():
    readline=stdin.readline
    N,K=map(int,readline().split())
    A=list(map(int,readline().split()))
    A.sort()

    #符号が - → 0 , 0 → + となるindexを求める
    index=[len(A),len(A)]
    mode=0
    for i in range(N):
        if mode==0:
            if A[i]==0:
                index[0]=i
                mode=1
            elif A[i]>0:
                index[0],index[1]=i,i
                break
        else:
            if A[i]>0:
                index[1]=i
                break

    #二分探索
    l=-10**18
    r=10**18+1
    while(l<r-1):
        x=(l+r)//2
        count=0

        #尺取り法
        if x>0:
            now_j=index[0]
            for i in range(index[0]):  #A[i]<0
                for j in range(now_j,-1,-1):
                    if A[i]*A[j-1]>=x:
                        now_j=j
                        count+=len(A)-now_j
                        if now_j<=i:
                            count-=1
                        break
                else:
                    now_j=0
                    count+=len(A)
                    count-=1

            for i in range(index[0],index[1]):  #A[i]=0
                if x>0:
                    count+=len(A)-1
                else:
                    break
            
            now_j=index[0]
            for i in range(len(A)-1,index[1]-1,-1):
                for j in range(now_j,len(A)):
                    if A[i]*A[j]>=x:
                        now_j=j
                        count+=now_j
                        if now_j>=i+1:
                            count-=1
                        break
                else:
                    now_j=len(A)
                    count+=len(A)
                    count-=1

        else:
            now_j=len(A)
            for i in range(index[0]-1,-1,-1):  #A[i]<0
                for j in range(now_j,-1,-1):
                    if A[i]*A[j-1]>=x:
                        now_j=j
                        count+=len(A)-now_j
                        if now_j<=i:
                            count-=1
                        break
            
            now_j=0
            for i in range(index[1],len(A)):
                for j in range(now_j,len(A)):
                    if A[i]*A[j]>=x:
                        now_j=j
                        count+=now_j
                        if now_j>=i+1:
                            count-=1
                        break

        count//=2
        if count<K:
            l=x
        else:
            r=x

    print(l)

if __name__=="__main__":
    main()

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

int main(){
    using namespace std;
    unsigned long K;
    cin >> K;
    unsigned long T{7}, ans{1}, pt{0};
    while(T % K){
        ++ans;
        if(ans > 2 * K)return 0 & puts("-1");
        ((T *= 10) += 7) %= K;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_CHAR_MAX		4005									// 最大文字数
#define D_CHAR_KIND		3										// 文字種類数
#define D_CHAR_SUM		3										// 文字合計

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Str[D_CHAR_MAX];									// 文字列
static int siLen;												// 文字列長
static int si2CCnt[D_CHAR_MAX][D_CHAR_KIND];					// 文字数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// 文字列長 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siLen);

	// 文字列 - 取得
	fgets(sc1Str, sizeof(sc1Str), szpFpI);

	// 数値化
	for (i = 0; i < siLen; i++) {
		switch (sc1Str[i]) {
			case 'R':	sc1Str[i] = 0;		break;
			case 'G':	sc1Str[i] = 1;		break;
			case 'B':	sc1Str[i] = 2;		break;
		}
	}

	// 文字数 - セット
	int li1CCnt[D_CHAR_KIND];
	memset(li1CCnt, 0, sizeof(li1CCnt));
	for (i = siLen - 1; i >= 0; i--) {
		memcpy(si2CCnt[i], li1CCnt, sizeof(si2CCnt[0]));
		li1CCnt[sc1Str[i]]++;
	}

	// パターン数 - 取得
	long long llPCnt = 0;
	for (i = 0; i < siLen; i++) {
		for (j = i + 1; j < siLen; j++) {
			if (sc1Str[i] == sc1Str[j]) {
				continue;
			}

			// パターン数 - 加算
			int liNum = D_CHAR_SUM - sc1Str[i] - sc1Str[j];
			llPCnt += si2CCnt[j][liNum];

			// パターン数 - 減算
			int liNo = j - i + j;
			if (liNo < siLen) {
				if (sc1Str[liNo] == liNum) {
					llPCnt--;
				}
			}
		}
	}

	// 出力
	sprintf(lc1Buf, "%lld\n", llPCnt);
	fOutLine(lc1Buf);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int h = sc.NextInt();

        int answer = (a + b) * h / 2;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {


    int N;
    Scd(N);

    printf ("%d\n", 180*(N-2) );

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	string s[10];
	int b[10]={},a[10]={};
	rep(i,0,9){
		cin>>s[i]>>b[i]>>a[i];
		cout<<s[i]<<" "<<b[i]+a[i]<<" "<<200*b[i]+300*a[i]<<endl;
	}
}

Measured memory_bytes: 1200
#![allow(unused_macros, unused_imports, dead_code, non_snake_case)]

use std::io;

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

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
            assert!(_it.next().is_none());
        }
    };
}

fn main() {
    from_line!(n:usize);
    let mut ids = Vec::new();
    for _ in 0..n {
        from_line!(v:String);
        ids.push(v);
    }
    let mut state = false;
    from_line!(m:usize);
    for _ in 0..m {
        from_line!(v:String);
        if ids.contains(&&v) {
            if state {
                println!("Closed by {}", &v);
                state = false;
            } else {
                println!("Opened by {}", &v);
                state = true;
            }
        } else {
            println!("Unknown {}", &v);

        }
    }
}



Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define DB double
#define LL long long

#define MST(a,b) memset((a),(b),sizeof(a))
#define MRK() cout<<"Mark"<<endl;
#define WRT(x) cout<<#x<<" = "<<(x)<<endl;

#define MAXN 210000
#define MAXM 410000
#define MOD 998244353
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-5

#define _ 0
using namespace std;

int n;
int a[MAXN][2];

void init()
{
	cin>>n;
	for (int i=0;i<n;i++)
		cin>>a[i][0];
	for (int i=0;i<n;i++)
		cin>>a[i][1];
}

void work()
{
	int ans=INF;
	for (int mask=0;mask<(1<<n);mask++)
	{
		vector<int> tmp;
		bool f=true;
		for (int i=0;i<n;i++)
		{
			f^=(mask>>i)&1;
			tmp.push_back(a[i][(mask>>i)&1]);
		}
		if (!f)
			continue;
		sort(tmp.begin(),tmp.end());
		int cnt=0;
		for (int i=0;i<n;i++)
			for (int j=0;j<n;j++)
				if (a[i][(mask>>i)&1]==tmp[j] && (((i-j)&1)==((mask>>i)&1)))
				{
					cnt++;
					tmp[j]=-i;
					break;
				}
		if (cnt!=n)
			continue;
		int cnt1=0;
		for (int i=0;i<n;i++)
			for (int j=i+1;j<n;j++)
				if (tmp[i]<tmp[j])
					cnt1++;
		ans=min(ans,cnt1);
	}
	if (ans==INF)
		cout<<-1;
	else
		cout<<ans;
}

int main()
{
	init();
	work();
	return ~~(0^_^0);
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a % 2 == 0) {
      if (a % 3 != 0 && a % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long x = scanner.nextLong(), y = scanner.nextLong();
			System.out.println(getDigits(y / x));
		}
	}

	/**
	 * @param l
	 * @return lの2進数の桁数
	 */
	private static int getDigits(long l) {
		int result = 0;
		while (l > 0) {
			l >>= 1;
			result++;
		}
		return result;
	}
}


Measured memory_bytes: 35624
if __name__ == '__main__':
    N = int(input())
    T, A = map(int, input().split())
    H = list(map(int, input().split()))
    diff_min = 10**6
    best = 0
    for i in range(N):
        if diff_min > abs(T - 0.006*H[i] - A):
            diff_min = abs(T - 0.006*H[i] - A)
            best = i + 1
    print(best)

Measured memory_bytes: 3064
from sys import stdin

S = stdin.readline().rstrip()

for i in range(len(S)):
    if i % 2 == 1 and S[i] == 'R':
        print('No')
        exit()
    if i % 2 == 0 and S[i] == 'L':
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 38644
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

bool solve(vector<ll> a, ll n){
	if (a[n] == 1) { return false; }
	if (a[1] == 0) { return false; }
	repn(i, n - 1) { if (a[i] != a[n - i]) { return false; } }
	return true;
}



int main() {

	ll N, A, B;
	cin >> N >> A >> B;

	ll ans = N / (A + B)*A;

	ll a = N - N / (A + B)*(A + B);

	ans += min(a, A);

	cout << ans;

	
	
	system("PAUSE");

}





Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    int rank = 0, ans = 0;
    int x = 10;
    while(1){
        rank++;
        if (x <= n){
            if (rank % 2 == 1){
                //ans += pow(10, rank) - 1;
                //if (rank > 1) ans -= pow(10, rank-1);
                ans += 9 * pow(10, rank-1);
            }
        }
        else{
            if ( rank % 2 == 1){
                ans += n - pow(10,rank-1) + 1;
            }
            break;
        }
        x *= 10;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define     siii(a,b,c)       scanf("%d%d%d",&a,&b,&c)
#define     si(a)             scanf("%d",&a)
#define     sii(a,b)          scanf("%d%d",&a,&b)
#define     sl(a)             scanf("%lld",&a);
#define     sll(a,b)          scanf("%lld%lld",&a,&b);
#define     slll(a,b,c)       scanf("%lld%lld%lld",&a,&b,&c);
#define     sd(a)             scanf("%lf",&a);
#define     sdd(a,b)          scanf("%lf%lf",&a,&b);
#define     pb(a)             push_back(a)
#define     deb(a)            printf("### %d ###\n",a)
#define     mp                make_pair
#define     pf                printf
#define     fl(a, b, c)       for(int a= b ;a<c;a++)
#define     mx                100000 //10^5
#define     fread             freopen("input.txt","r",stdin)
#define     fwrite            freopen("output.txt","w",stdout)
#define     CLR(a,b)          memset(a,b,sizeof(a))
#define     ll                long long
#define     D(x)              cout<<#x" = "<<x<<endl;
#define     sz                10000
#define     bl                printf("\n")
#define     spc               printf(" ")
#define     pCase(a)          printf("Case %d: ",a)
/*
//Number Theory
inline bool dCMP(const long double &a, const long double &b) { return fabsl(a - b) < EPS;}

//Geometry
inline double MintoDeg(double min){return min/60;}
inline double to_Radian(double deg){return deg*PI/180.0;}
inline double to_Degree(double radian){if(radian<0) radian+=2*PI; return radian*180/PI ;}
inline double fixAngle(double A){return A>1 ? 1 : (A<-1 ? -1 : A);}
*/




int main()
{
    //fwrite;
    ll k, s;
    sll(k,s);
    ll ans = 0;
    fl(i,0,k+1)
    {
        fl(j,0,k+1)
        {
            //cout<<i<<" "<<j<<endl;
            if( s- (i+j) <=k && (s-i-j)>=0) ans++;
        }
    }
    cout<<ans<<endl;





    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>

#define MAX_N 1000001

using namespace std;

int n;
int data[MAX_N*2-1];

void init(){
	for(int i=0;i<2*MAX_N-1;i++) data[i]=0;
}

void add(int i,int x){
	//?????????????????????
	i+=n-1;
	data[i]+=x;
	//tree????????????????????´??°????????????.
	while(i>0){
		i=(i-1)/2;
		data[i]=data[i*2+1]+data[i*2+2];
		//printf("data[%d]=%d\n",i,data[i]);
	}
}

//??????[a,b)???????????¨??????, ???????????? k ?????????????????????l,r????????????.
int find(int a,int b,int k,int l,int r){
	//if(a==b) return data[a+n-1];
	if(r<=a || b<=l) return 0;
	if(a<=l && r<=b) return data[k];
	else{
		int vl=find(a,b,k*2+1,l,(l+r)/2);
		int vr=find(a,b,k*2+2,(l+r)/2,r);
		return vl+vr;
	}
}

int main(){
	int q;
	int N;
	int com,x,y;
	scanf("%d %d",&N,&q);
	//if(n%2!=0) n+=1;
	init();
	n=1;
	while(n<N) n*=2; //tree???????????¨????????????2??????
	for(int i=0;i<q;i++){
		scanf("%d %d %d",&com,&x,&y);
		if(com==0){
			x-=1;
			add(x,y);
		}
		else{
			x-=1;
			y-=1;
			if(x==y)
			printf("%d\n",data[x+n-1]);
			else{
				printf("%d\n",find(x,y+1,0,0,n));
			}
		}
	}
}

Measured memory_bytes: 11040
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (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 sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))

int main(void) {
	int n;
	scanf("%d", &n);
	ll sum = 0;
	FOR(i, 1, n + 1) {
		if (i % 3 == 0 || i % 5 == 0) {
			continue;
		}

		sum += (ll)i;
	}

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

Measured memory_bytes: 3724
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
#define mod  100007
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b) { return (long long) a*b%mod;}
inline ll add(ll a, ll b) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
	return ret;
}

static inline void read(ll &result) {
    bool minus = false;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' and ch <= '9') break;
        ch = getchar();
    }
    (ch == '-')? minus = true: result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' or ch > '9') break;
        result = (result<<3)+ (result<<1) + (ch - '0');
    }
    if(minus) result=-result;
}


int main(){
	fastio;
	ll n; cin>>n;
	ll rest = n - 500*(n/500);
	ll ans = 1000*(n/500) + 5*(rest/5);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;


int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    int cur = 0;
    int max = 0;
    for(int i=1;i<n;i++){
        if(v[i-1] >= v[i]){
            cur++;
            max = max < cur ? cur : max;
        }
        else{
            cur = 0;
        }
        //cout<<cur<<" "<<max<<endl;
    }
    cout<<max<<endl;
    return 0;
}

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

using namespace std;

int main(){
	long long a,b,k;
	cin >> a >> b >> k ;
	if(a < k){
	    k = k - a;
		a = 0;
	}else{
		a = a - k;
		cout << a << " " << b;
		return 0;
	}

	if(b < k){
		cout << "0 0";
	}else{
	    b = b - k;
		cout << "0 " << b;
	}
}

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

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

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s; cin >> s;
	vector<vector<int>> v(2, vector<int>(2019,0));
	int ans = 0;
	rep(i,s.size()){
		int k1 = s[i]-'0';
		v[(i + 1)%2][k1]++;
		rep(j, 2019) {
			int k2 = k1 + j * 10;
			k2 = k2 % 2019;
			v[(i + 1)%2][k2] += v[i%2][j];
			v[i % 2][j] = 0;
			//if (v[i % 2][j] > 0) cout << k2 << endl;
		}
		ans += v[(i + 1)%2][0];
	}
	cout << ans << endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> minus;
    vector<int> plus;
    rep(i, N){
        if(A[i] < 0) minus.push_back(A[i]);
        else plus.push_back(A[i]);
    }
    sort(minus.begin(), minus.end());
    sort(plus.begin(), plus.end());
    if(minus.size() == 0){
        int ans = 0;
        for(int i = 1;i < plus.size();i++){
            ans += plus[i];
        }
        ans -= plus[0];
        cout << ans << endl;
        for(int i = 1;i < plus.size()-1;i++){
            cout << plus[0] << " " << plus[i] << endl;
            plus[0] -= plus[i];
        }
        cout << plus[plus.size()-1] << " " << plus[0] << endl;
    }else if(plus.size() == 0){
        int ans = 0;
        for(int i = 0;i < minus.size()-1;i++){
            ans += minus[i];
        }
        ans *= -1;
        ans += minus[minus.size()-1];
        cout << ans << endl;
        int endidx = minus.size() - 1;
        rep(i, endidx){
            cout << minus[endidx] << " " << minus[i] << endl;
            minus[endidx] -= minus[i];
        }
    }else{
        int ans = 0;
        rep(i, minus.size()) ans -= minus[i];
        rep(i, plus.size()) ans += plus[i];
        cout << ans << endl;
        for(int i = 1;i < plus.size();i++){
            cout << minus[0] << " " << plus[i] << endl;
            minus[0] -= plus[i];
        }
        rep(i, minus.size()){
            cout << plus[0] << " " << minus[i] << endl;
            plus[0] -= minus[i];
        }
    }
    return 0;
}


Measured memory_bytes: 4308
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#define T 10000
#define inf 0x7fffffff
using namespace std;
#define int long long
const int mod=998244353;
int dp[3005][3005];
signed main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	dp[a][b]=1;
	for(int i=a; i<=c; i++)
		for(int j=b; j<=d; j++)
		{
			if(i==a&&j==b)
				continue;
			else
				dp[i][j]=(dp[i-1][j]*j%mod+dp[i][j-1]*i%mod-(i-1)*(j-1)*dp[i-1][j-1]%mod+mod)%mod;
		}
	cout<<dp[c][d]<<endl;
	return 0;
}

Measured memory_bytes: 73872
#include <cstdio>
int main(void)
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if((a+b)>(c+d)) printf("Left\n");
	else if((a+b)==(c+d)) printf("Balanced\n");
	else printf("Right\n");
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#define MAX_ELEMENTS 10000
int root[MAX_ELEMENTS];
void init(){
  memset(root, -1, sizeof(root));
}

int find(int x){
  if(root[x] < 0){
    return x;
  }  
  return root[x] = find(root[x]);
}

int same(int x, int y){
  return find(x) == find(y);
}

int size(int x){
  return -root[find(x)];
}

int unite(int x, int y){
  int tmp;
  x = find(x);
  y = find(y);
  if(x == y){
    return 0;
  }
  if(root[y] < root[x]){
    tmp = x;
    x = y;
    y = tmp;
  }
  root[x] += root[y];
  root[y] = x;
  return 1;
}
 
int main(){
  int i,n, q, com, x, y;
  scanf("%d %d", &n, &q);
  init();
  for(i = 0; i < q; ++i){
    scanf("%d %d %d", &com, &x, &y);
    if(com == 0){
      unite(x, y);
    }
    else{
      printf("%d\n", same(x, y));
    }
  }
  return 0;
}

Measured memory_bytes: 644
n, m = [int(x) for x in input().split()]
ab = [[int(x) for x in input().split()] for _ in range(m)]
ab.sort(key=lambda x: x[1])
removed = []
for a, b in ab:
    if not any(a <= x < b for x in removed):
        removed.append(b - 1)
print(len(removed))


Measured memory_bytes: 24276
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>
#include <stdlib.h>
# include <map>

using namespace std;

int main(){
map<string , int> cnt ={{"AC" ,0}, {"WA" ,0}, {"TLE" ,0}, {"RE" ,0}};
int n;
cin >> n;
for(int i = 0 ; i < n ;i++){
    string tmp;
    cin >> tmp;
    cnt[tmp] += 1;
}
cout << "AC" << " x " << cnt["AC"] << endl;
cout << "WA" << " x " << cnt["WA"] << endl;
cout << "TLE" << " x " << cnt["TLE"] << endl;
cout << "RE" << " x " << cnt["RE"] << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b)
        cout << c << endl;
    else if(b == c)
        cout << a << endl;
    else
        cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
constexpr int MAXQUERIES = 20;
#define int long long
// "Vacant"

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

    int n;
    cin >> n;

    int remaining_queries = MAXQUERIES;

    int left, mid, right;
    string left_seat, mid_seat, right_seat;
    left = 0, right = n - 1;

    remaining_queries -= 2;
    cout << left << endl;
    cin >> left_seat;
    cout << right << endl;
    cin >> right_seat;

    if (left_seat == "Vacant" || right_seat == "Vacant") return 0;

    while (remaining_queries > 0) {
        mid = (left + right) / 2;
        remaining_queries--;
        cout << mid << endl;
        cin >> mid_seat;

        if (mid_seat == "Vacant") break;

        if ((mid - left + 1) % 2 == (left_seat != mid_seat)) {
            right = mid;
            right_seat = mid_seat;
        } else {
            left = mid;
            left_seat = mid_seat;
        }
    }

    return 0;
}


Measured memory_bytes: 852
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=100005;
int n,m,s,cnt;
int u[maxn],v[maxn],prve[maxn],prvv[maxn];
bool used[maxn],vis[maxn],vis2[maxn];
vector<pii>edge[maxn],path;

void dfs(int x,int p){
	vis[x]=true;
	rep(i,edge[x].size()){
		pii y=edge[x][i];
		if(y.fst==p||used[y.snd])continue;
		if(y.fst==s){
			assert(path.empty());
			path.pb(y);
			int cur=x;
			while(cur!=s)path.pb(mp(cur,prve[cur])),cur=prvv[cur];
			return;
		}
		if(vis[y.fst])continue;
		prvv[y.fst]=x;
		prve[y.fst]=y.snd;
		dfs(y.fst,x);
		if(!path.empty())return;
	}
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d%d",&n,&m);
	REP(i,m){
		scanf("%d%d",&u[i],&v[i]);
		edge[u[i]].pb(mp(v[i],i));
		edge[v[i]].pb(mp(u[i],i));
	}
	REP(i,n)if(edge[i].size()&1){
		puts("No");
		return 0;
	}
	s=1;dfs(1,0);
	REP(i,n)vis[i]=false;
	rep(i,path.size()){
		vis2[path[i].fst]=true;
		used[path[i].snd]=true;
	}
	cnt=path.size();
	path.clear();
	if(cnt==m){
		puts("No");
		return 0;
	}
	s=0;
	REP(i,n)if(!vis2[i]){
		s=i;
		break;
	}
	assert(s);
	dfs(s,0);
	int c=0;
	rep(i,path.size())if(vis2[path[i].fst])c++;
	if(cnt+path.size()==m&&c<=2)puts("No");
	else puts("Yes");
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 13568
import math
def main():

    N = int(input())
    v2 = math.ceil(N/1.08)
    v1 = math.floor(N/1.08)
    for v in range(v1, v2+1):
        if int(v * 1.08) == N:
            return v
    return ':('


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int d,t,s;
	scanf("%d %d %d",&d,&t,&s);
	if(d<=t*s){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1632
#include<stdio.h>
 
int main(void){
   int p;
   scanf("%d",&p);
   if(p%10==2||p%10==4||p%10==5||p%10==7||p%10==9){
      printf("hon");
   }else if(p%10==0||p%10==1||p%10==6||p%10==8){
      printf("pon");
   }else if(p%10==3){
      printf("bon");
   }
 
   return 0;
}

Measured memory_bytes: 1732
A,B,C=map(int,input().split())
ans = 1
if (A%2 != B%2) and (A%2 == C%2):
  A += 1
  C += 1
elif (A%2 == B%2) and (A%2 != C%2):
  A += 1
  B += 1
elif (A%2 != B%2) and (B%2 == C%2):
  C += 1
  B += 1
else:
  ans = 0
L = [A,B,C]
L.sort()
ans += (L[2]-L[1])//2 + (L[2]-L[0])//2
print( ans )


Measured memory_bytes: 3064