akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b := intScanner(), intScanner()
	h := intScanner()
	fmt.Println((a + b) * h / 2)
}


Measured memory_bytes: 1776
#include <stdio.h>
int main(int argc, const char * argv[]){
    int i, dice[6] = {0}, q, up, front;
    for( i = 0 ; i < 6 ; i++ ) {
        scanf("%d", &dice[i]);
    }
    scanf("%d",&q);
    for( i = 0 ; i < q ; i++) {
        scanf("%d %d",&up,&front);
        if((up == dice[5] && front == dice[4])||(up == dice[4] && front == dice[0])||(up == dice[0] && front == dice[1])||(up == dice[1] && front == dice[5])){
            printf("%d\n",dice[2]);
        }
        else if((up == dice[0] && front == dice[2])||(up == dice[2] && front == dice[5])||(up == dice[5] && front == dice[3])||(up == dice[3] && front == dice[0])){
            printf("%d\n",dice[4]);
        }
        else if((up == dice[5] && front == dice[1])||(up == dice[1] && front == dice[0])||(up == dice[0] && front == dice[4])||(up == dice[4] && front == dice[5])){
            printf("%d\n",dice[3]);
        }
        else if((up == dice[0] && front == dice[3])||(up == dice[3] && front == dice[5])||(up == dice[5] && front == dice[2])||(up == dice[2] && front == dice[0])){
            printf("%d\n",dice[1]);
        }
        else if((up == dice[2] && front == dice[1])||(up == dice[1] && front == dice[3])||(up == dice[3] && front == dice[4])||(up == dice[4] && front == dice[2])){
            printf("%d\n",dice[5]);
        }
        else{
            printf("%d\n",dice[0]);
        }
    }
    return 0;
}

Measured memory_bytes: 596
import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    d = list(map(int, input().split()))

    ruiseki = list(itertools.accumulate(d))
    ans = 0
    for i in range(N - 1):
        ans += d[i] * (ruiseki[N - 1] - ruiseki[i])

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

import sys
from bisect import bisect_right
from operator import itemgetter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class BIT2:
    """ 区間加算BIT(区間加算・区間合計取得) """

    def __init__(self, N):
        # 添字0が使えないので、内部的には全て1-indexedとして扱う
        N += 1
        self.N = N
        self.data0 = [0] * N
        self.data1 = [0] * N

    def _add(self, data, k, x):
        k += 1
        while k < self.N:
            data[k] += x
            k += k & -k

    def _get(self, data, k):
        k += 1
        s = 0
        while k:
            s += data[k]
            k -= k & -k
        return s

    def add(self, l, r, x):
        """ 区間[l,r)に値xを追加 """

        self._add(self.data0, l, -x*(l-1))
        self._add(self.data0, r, x*(r-1))
        self._add(self.data1, l, x)
        self._add(self.data1, r, -x)

    def query(self, l, r):
        """ 区間[l,r)の和を取得 """

        return self._get(self.data1, r-1) * (r-1) + self._get(self.data0, r-1) \
             - self._get(self.data1, l-1) * (l-1) - self._get(self.data0, l-1)

N, D, K = MAP()

XH = []
for i in range(N):
    x, h = MAP()
    XH.append((x, h))

XH.sort(key=itemgetter(0))
X, _ = zip(*XH)
D = D * 2

bit = BIT2(N)
ans = 0
for i, (x, h) in enumerate(XH):
    h -= bit.query(i, i+1) * K
    if h <= 0:
        continue
    cnt = ceil(h, K)
    idx = bisect_right(X, x+D) - 1
    bit.add(i, idx+1, cnt)
    ans += cnt
print(ans)


Measured memory_bytes: 104256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
from collections import Counter
c = Counter(As)

ans = 0
for num, c in c.most_common():
    if c>num:
        ans += c-num
    elif c<num:
        ans += c

print(ans)

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

int main() {
	// your code goes here
	int n, m; cin >> n;
	
	while(n > 0) {
		m = n % 10;
		if(m == 9) {
			cout << "Yes" << endl;
			return 0;
		}
		n /= 10;
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;

int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;
	string a = s+t;
	for (int i = 0; i < n; i++) {
		bool h = true;
		for (int j = 0; j < n-i; j++) {
			if (s[i+j] != t[j]) {
				h = false;
			}
		}
		if (h) {
			a = s.substr(0, i)+t;
			break;
		}
	}
	cout << a.size() << endl;
	return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
maps = []
alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(h):
    maps.append(list(map(str,input().split())))
for i in range(h):
    for j in range(w):
        if maps[i][j] == "snuke":
            print(alphabet[j]+str(i+1))
            exit()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(A * B % 2 == 0 ? "No" : "Yes");
		sc.close();
	}
}

Measured memory_bytes: 21716
N, M = map(int, input().split())
A = [1] * (N + 1)
ans = [0] * (N + 1)
ans[0] = 1
for _ in range(M):
    A[int(input())] = 0
for i in range(1, N + 1):
    ans[i] = (ans[i - 2] * A[i - 2] + ans[i - 1] * A[i - 1]) % 1000000007

print(ans[N])


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

const int N=51;
int a[N],b[N],n;
int p[N],q;
bool c[N][N];
void Init(){memset(c,0,sizeof c);}
void inc(int x){
	for(int i=0;i<N;++i)
		c[i][i%x]=1;
}
bool chk(){
	int i,j,k;
	for(i=0;i<N;++i)c[i][i]=1;
	for(k=0;k<N;++k)
		for(i=0;i<N;++i)
			for(j=0;j<N;++j)
				c[i][j]|=(c[i][k]&&c[k][j]);
	for(i=0;i<n;++i)
		if(!c[a[i]][b[i]])
			return 0;
	return 1;
}
int main(){
#ifdef flukehn
	freopen("g.in","r",stdin);
#endif
	cin>>n;
	int i,j;
	for(i=0;i<n;++i)
		cin>>a[i];
	for(i=0;i<n;++i)
		cin>>b[i];
	Init();
	for(i=1;i<N;++i)
		inc(i);
	if(!chk()){
		puts("-1");
		return 0;
	}
	for(i=49;i;--i){
		Init();
		for(j=i-1;j;--j)
			inc(j);
		for(j=0;j<q;++j)
			inc(p[j]);
		if(!chk())
			p[q++]=i;
	}
	long long an=0;
	for(i=0;i<q;++i)
		an+=1LL<<p[i];
	printf("%lld\n",an);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main(void)
{
    int N;

    cin >> N;

    if(N%10 == 3){
        cout << "bon" << endl;
    }else if(N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>

using namespace std;

int main(){
    int i,j,k,l;
    int n;
    int d5a=0,d7a=0,d5b=0,d7b=0,d7c=0;
    int stg=0;
    int ok=0,ans,first;
    while(1){
        cin >> n;
        if(n==0) break;
        string str[n];
        for(i=0;i<n;i++){
            cin >> str[i];
        }
        first = 0;
        for(i=0;i<n;i++){
            //i番目から始める
            stg = 0;
            int tmp=0;
            for(j=i;j<n;j++){
                if(first==0){
                    if(stg==0){
                        tmp += str[j].size();
                        if(tmp==5){
                            stg = 1;
                            tmp = 0;
                        } 
                    }else if(stg==1){
                        tmp += str[j].size();
                        if(tmp==7){
                            stg = 2;
                            tmp = 0;
                        }
                    }else if(stg==2){
                        tmp += str[j].size();
                        if(tmp==5){
                            stg = 3;
                            tmp = 0;
                        }
                    }else if(stg==3){
                        tmp += str[j].size();
                        if(tmp==7){
                            stg = 4;
                            tmp = 0;
                        }
                    }else if(stg==4){
                        tmp += str[j].size();
                        if(tmp==7){
                            stg = 5;
                            tmp = 0;
                        }
                    }
                    // cout << tmp << " " << endl; 
                     
                }
                
            }
            if(stg==5&&first==0){
                    first = 1;  
                    cout << i+1 << endl;  
            }
        }
    }   
}




Measured memory_bytes: 3164
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll b1[1 << 19], b2[1 << 19]; int n,m;
void add(int a, int b, ll w) {
	for (int i = a; i < m+1; i |= i + 1)b1[i] += -a * w;
	for (int i = b; i < m+1; i |= i + 1)b1[i] += b * w;
	for (int i = a; i < m+1; i |= i + 1)b2[i] += w;
	for (int i = b; i < m+1; i |= i + 1)b2[i] += -w;
}
ll sum(int a) {
	ll ret = 0;
	for (int i = a - 1; i >= 0; i = (i &(i + 1)) - 1)ret += b1[i];
	for (int i = a - 1; i >= 0; i = (i &(i + 1)) - 1)ret += a*b2[i];
	return ret;
}
struct miyage { int from, to; };
bool comp(miyage a, miyage b) {
	if (a.to - a.from < b.to - b.from)return true;
	else return false;
}
miyage x[300000];
int main() {
	cin >> n >> m;
	rep(i, n) {
		int l, r; cin >> l >> r;
		x[i] = { l,r };
	}
	sort(x, x + n, comp);
	int now = 0;
	int cnt = n;
	rep1(i, m) {
		int out = cnt;
		for (int j = 0; j <= m; j+=i) {
			out += sum(j + 1) - sum(j);
		}
		cout << out << endl;
		while (now < n&&x[now].to - x[now].from + 1 <= i) {
			add(x[now].from, x[now].to+1, 1);
			now++; cnt--;
		}
	}
	return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define cl clear
#define in insert
#define er erase
#define S second
#define F first
#define endl "\n" 
#define all(v) (v).begin(), (v).end()
#define getbit(x, i) ((x >> i)&1)
#define sz(v) (v).size()
#define fr(i, a, b, d) for(ll i = a; i < b; i+= d)
#define frr(i, a, b, d) for(ll i = a; i >= b; i -= d)
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define pll pair < ll, ll >
#define pii pair < int, int >
#define trace1(x)                cerr << #x << ": " << x << "\n";
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << "\n";
using namespace std;
const ll N = 100005;
const ll M = 1e9 + 7;
int main(){
	int n;
	cin >> n;
	vector < int > v(n);
	for(int i = 0; i < n; i++) cin >> v[i];
	sort(all(v));
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			int z = v[i] + v[j];
			int idx = lower_bound(all(v), z) - v.begin();
			idx--;
			ans += idx-j;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e15 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

const int mex = 1e5 + 0;
vector <int> dig[15];
vector <int> v;

void give(int d){
  for(auto i : dig[d-1]){
    int a = i%10;
    int x = a, y = a-1, z = a+1;
    dig[d].pb(i*10 + x);
    if(y >= 0){
      dig[d].pb(i*10 + y);
    } 
    if(z <= 9){
      dig[d].pb(i*10 + z);
    }
  }
  for(auto i : dig[d]) v.pb(i);
}

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt", "w", stdout);
  // #endif
  
  for(int i = 1; i <= 9; i++){
    dig[1].pb(i); v.pb(i);
  }
  
  int d = 2;
  while(sz(v) <= mex){
    give(d); d++;
  }
  sort(all(v));
  int k; cin >> k;
  cout << v[k-1] << '\n';
}



Measured memory_bytes: 4080
import java.util.*;
import java.io.*;

public class Main {
    private static final int MOD = 1000000007, MAX = 2000000;
    private static final long[] fact = new long[MAX + 1];

    public static void main(String[] args) throws IOException {
        final long[] pow = new long[MAX + 1];
        pow[0] = 1;
        fact[0] = 1;
        for (int i = 1; i <= MAX; ++i) {
            pow[i] = (pow[i - 1] * 25) % MOD;
            fact[i] = (fact[i - 1] * i) % MOD;
        }

        final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int k = Integer.parseInt(br.readLine());
        String s = br.readLine();

        int n = s.length(), total = n + k;
        long res = pow(26, total);

        for (int i = 0; i < n; ++i) {
            res -= choose(total, i) * pow[total - i];
            res %= MOD;
            if (res < 0) {
                res += MOD;
            }
        }

        bw.write(Long.toString(res));
        bw.newLine();
        bw.close();
        br.close();
    }

    private static long pow(int base, int exponent) {
        long res = 1, extra = base;

        while (exponent > 0) {
            if ((exponent & 1) == 1) {
                res *= extra;
                res %= MOD;
            }
            extra *= extra;
            extra %= MOD;
            exponent >>= 1;
        }

        return res;
    }

    private static long choose(int n, int r) {
        return fact[n] * modInverse((int)fact[r], MOD) % MOD * modInverse((int)fact[n - r], MOD) % MOD;
    }

    private static int modInverse(int a, int m)
    {
        int m0 = m;
        int y = 0, x = 1;

        if (m == 1)
            return 0;

        while (a > 1)
        {
            int q = a / m;

            int t = m;

            m = a % m;
            a = t;
            t = y;

            y = x - q * y;
            x = t;
        }

        if (x < 0)
            x += m0;

        return x;
    }
}


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

int main(){
  int k;
  cin >> k;  
  int n;
  cin >> n;
  vector<int> a(n);  
  vector<int> s(n);
  
  for(int i = 0;i<n;i++){
    cin >> a.at(i);
  }  
  s.at(0) = a.at(n-1)-a.at(0);  
  for(int i=1;i<n;i++){
    s.at(i) = k - a.at(i) + a.at(i-1);
  }  
  /*for(int i=0;i<n;i++){
    cout << s.at(i) << endl;
  }*/  
  sort(s.begin(),s.end());  
  cout << s.at(0) << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B, T;
    cin >> A >> B >> T;
    int ans = 0;
    rep(t, 1, T + 1)
    {
        if (t % A == 0)
        {
            ans += B;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
n = int(input())
ans = 0
for m in range(1, n+1):
	if m%2 != 1:
		continue
	cnt = 0
	for k in range(1,m+1):
		if m%k == 0:
			cnt += 1
		if cnt>8:
			break
	if cnt == 8:
		# print(m)
		ans += 1

print(ans)

Measured memory_bytes: 3060
n = int(input())
s = input()

ans = 0
for i in range(1, n):
    cnt = 0
    for j in range(n-i):
        if s[i+j] == s[j]:
            cnt += 1
        else:
            ans = max(ans, min(cnt, i))
            cnt = 0

        if cnt >= i:
            break
    ans = max(ans, min(cnt, i))

print(ans)


Measured memory_bytes: 41692
n=int(input())
a=[0]*(10**5)
for x in range(1,101):
	for y in range(1,101):
		for z in range(1,101):
			a[x**2+y**2+z**2+x*y+y*z+z*x]+=1
for i in range(1,n+1):
	print(a[i])

Measured memory_bytes: 9872
#include <bits/stdc++.h>
using namespace std;
enum class Walked { wa, un };
struct Pos {
public:
    int x, y, rank;
    Pos(int x, int y, int rank) : x(x), y(y), rank(rank) {};
};
int dx[4] = { 0, 0, 1, -1 };
int dy[4] = { 1, -1, 0, 0 };

void solve() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> game(H, vector<char>(W));
    int init_black = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> game[i][j];
            if (game[i][j] == '#') init_black++;
        }
    }
    vector<vector<Walked>> walked(H, vector<Walked>(W, Walked::un));
    queue<Pos> q;
    q.push(Pos(0, 0, 0));
    int x = -1;
    while (!q.empty()) {
        Pos pos = q.front();
        q.pop();
        if (game[pos.y][pos.x] == '#') continue;
        if (walked[pos.y][pos.x] == Walked::wa) continue;
        walked[pos.y][pos.x] = Walked::wa;
        if (pos.x == W - 1 && pos.y == H - 1) {
            x = pos.rank;
            break;
        }
        for (int i = 0; i < 4; ++i) {
            int nx = pos.x + dx[i];
            int ny = pos.y + dy[i];
            if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
            q.push(Pos(nx, ny, pos.rank + 1));
        }
    }
    if (x == -1) cout << -1 << endl;
    else {
        int all = H * W;
        int colors = all - init_black - x - 1;
        cout << colors << endl;
    }
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))

L = sorted(L)

ans = 0

while len(L) :
    if len(L) == 1 :
        ans += L[0]
        L.pop(0)
    else :
        ans += L.pop(0)
        L.pop(0)

print(ans)


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

int main() {
  vector<int> cnt(3,0);
  while(true) {
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(),v.end());
    if(v[2] >= v[0]+v[1])
       break;
    if(v[2]*v[2] > v[0]*v[0] + v[1]*v[1])
      cnt[2]++;
    else if(v[2]*v[2] == v[0]*v[0] + v[1]*v[1])
      cnt[1]++;
    else
      cnt[0]++;
  }
  cout << cnt[0] + cnt[1] + cnt[2] << " " << cnt[1] << " " << cnt[0] << " " << cnt[2] << endl;
}


Measured memory_bytes: 3140
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll N;
    cin >> N;
    ll a[110];
    rep(i,0,N) cin >> a[i];
    ll ans = 0;
    rep(i,0,N){
        if((i+1) % 2 == 1 && a[i] % 2 == 1) ans++;
    }
    print(ans);

    

}

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

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <iterator>
#include <sstream>
#include <bits/stdc++.h>

using ll = long long;
using namespace std;
#define modmod 1000000007

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n) for(int i=k;i<n;i++)

std::vector<std::string> split(const std::string &str, char sep)
{
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

ll nCr(ll n, ll r){
    if(r > n/2){
        r = n - r;
    }
    ll bunbo = 1;
    ll bunshi = 1;
    for(int i = 1; i <= r; i++){
        bunshi = bunshi * (r-i+1);
        bunbo = bunbo * i;
    }
    return bunshi/bunbo;
}

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

    ll A = 0;
    int m = S.size() - 1;

    for(int i = 0; i < (1 << m); i++){
        ll sum = 0;
        ll pr = 0;
        for(int j = 0; j < S.size(); j++){
            pr *= 10LL;
            pr += S[j] - '0';
            if(j == S.size()-1){
                sum += pr;
                break;
            }
            if((i>>j) & 1){
                sum += pr;
                pr = 0;
            }
        }
        A += sum;
    }

    //cout << A << endl;
    printf("%lld\n",A);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i]>>b[i];

  using P = pair<Int, Int>;
  vector<P> vp;
  for(Int i=0;i<n;i++) vp.emplace_back(a[i]+b[i],i);

  sort(vp.rbegin(),vp.rend());
  Int ans=0;
  for(Int i=0;i<n;i++){
    if(~i&1) ans+=a[vp[i].second];
    else ans-=b[vp[i].second];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3956
# -*- coding: utf-8 -*-
# Vacation

'''
3
10 40 70
20 50 80
30 60 90
'''

N = int(input())

dp = [[None] * 3 for _ in range(N)]
dp[0] = list(map(int, input().split()))
# print(dp)

for i in range(1, N):
    data = list(map(int, input().split()))
    # print(data)

    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + data[0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + data[1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + data[2]

# print(dp)
print(max(dp[N-1]))

Measured memory_bytes: 22772
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
        }

        System.out.println(solve(N, A, B) ? YES : NO);
    }

    private static boolean solve(int N, int[] A, int[] B) {
        Job[] job = new Job[N];
        for (int i=0; i<N; i++) {
            job[i] = new Job(A[i], B[i]);
        }

        Arrays.sort(job, Comparator.comparingInt(t -> t.B));

        int time = 0;
        for (int i=0; i<N; i++) {
            if (time <= job[i].B - job[i].A) {
                time += job[i].A;
            } else {
                return false;
            }
        }

        return true;
    }

    public static class Job {
        public int A;
        public int B;
        public Job(int a, int b) {
            this.A = a;
            this.B = b;
        }
    }
}

Measured memory_bytes: 103040
import java.util.*;

public class Main {
  public static void main(String[] args) { 
    Scanner in = new Scanner(System.in);
    int[] ip = new int[5];
    int count = 0;
    int sur = 10;
    int a;
    for (int i = 0; i < 5; i++) {
      a = in.nextInt();
      if (a % 10 < sur && a % 10 != 0) sur = a % 10;
      if (a % 10 != 0) count++;
      ip[i] = a / 10;
    }
    a = (count - 1) * 10 + sur;
    for (int n : ip) {
      a += n * 10;
    }
    System.out.println(a);
  }
}

Measured memory_bytes: 21716
N, K = map(int, input().split())
S = input()

first = now = S[0]

count = [] # 逆立ち、直立している人がそれぞれ何人連続しているか
c = 0
for s in S:
  if s == now:
    c += 1
  else:
    count.append(c)
    c = 1
    now = s

count.append(c)

l = len(count)
if first == '0':
  up_group = -(-l//2) # 直立しているグループ数
else:
  up_group = l//2

if up_group <= K: # 直立している人全員を逆立ちに変えられる
  print(N)
  quit()


if first == '0':
  ans = sum(count[:2*K])
  s = ans
  idx1 = 0
  idx2 = 2*K
  while idx2 < l:
    if idx1 == 0:
      s = s - count[0] + sum(count[idx2:idx2+2])
      idx1 += 1
    else:    
      s = s - sum(count[idx1:idx1+2]) + sum(count[idx2:idx2+2])
      idx1 += 2
    
    idx2 += 2
    ans = max(ans, s)
  
  print(ans)
else:
  ans = sum(count[:2*K+1])
  s = ans
  idx1 = 1
  idx2 = 2*K+1
  while idx2 < l:
    if idx1 == 1:
      s = s - sum(count[:2]) + sum(count[idx2:idx2+2])
      idx1 += 1
    else:
      s = s - sum(count[idx1:idx1+2]) + sum(count[idx2:idx2+2])
      idx1 += 2
    
    idx2 += 2
    ans = max(ans, s)
  
  print(ans)

Measured memory_bytes: 4724
#include<stdio.h>
#include<string.h>
int main()
{
    char s[12];
    scanf("%s",s);
    int i,c,d;
    i=c=d=0;
    while(s[i]!='\0')
    {
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
        {
            c++;
        }
        else
        {
            c=0;
        }
        if(c>d)
        {
            d=c;
        }
        i++;
    }
    printf("%d\n",d);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	string a,b,c;
	cin >> a >> b >> c;
	
	transform(a.begin(),a.end(),a.begin(),::toupper);
	transform(b.begin(),b.end(),b.begin(),::toupper);
	transform(c.begin(),c.end(),c.begin(),::toupper);
	cout << a[0] << b[0] << c[0] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n;  cin >> n;
    map<string,ll> ana;
    ll ans = 0;

    for(int i=0;i<n;i++){
        string s; cin >> s;
        sort(ALL(s));
        ana[s]++;
    }

    for(auto itr=ana.begin();itr!=ana.end();itr++){
        ans += itr->second * (itr->second -1) /2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11388
n = int(input())
t = [0] * (n+1)
x = [0] * (n+1)
y = [0] * (n+1)
for i in range(1, n+1):
    t[i], x[i], y[i] = map(int, input().split())

can = 1

for i in range(1, n+1):
    tm = t[i] - t[i-1]
    xm = abs(x[i] - x[i-1])
    ym = abs(y[i] - y[i-1])
    if((tm < xm+ym) or ((tm-xm+ym)%2)):
        can = 0
        break;

print("Yes" if can else "No")


Measured memory_bytes: 11636
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll n, x;
  cin >> n >> x;

  ll d = 0;
  ll ans = 1;
  REP(i, n) {
    ll l;
    cin >> l;
    d += l;
    if (d > x) {
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i];
  int cnt = 0;
  for(int i = 0; i < n; i++) {
    if(i+1 == a[a[i]-1]) cnt++;
  }
  cout << cnt/2 << endl;

  return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

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

  string s;
  cin >> s;
  int ans = 0;
  rep(i, 0, (int)s.size()/2) {
    if (s[i] != s[s.size()-1-i]) ans++;
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;

		Console.WriteLine("{0}",s[0]-s[1]+1);
	}
}
public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 11220
n=gets.to_i
a = gets.chomp.split.map(&:to_f)
ave = a.inject(:+) / n

m = Float::INFINITY
ans = 0
a.each_with_index do |v, i|
    if (v - ave).abs < m 
        m = (v - ave).abs
        ans = i
    end
end
puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,q,a,b,c,d;

int sz;
ll all[400010],part[400010];
int get_size(int n);
int build(int n);
int _range_add(int a,int b,int x,int k,int l,int r);
int range_add(int a,int b,int x);
ll _get(int a,int b,int k,int l,int r);
ll get(int a,int b); //[a,b)

int main(){
	cin >> n >> q; build(n);
	REP(i,0,q){
		cin >> a >> b >> c;
		if(a==0){cin >> d; range_add(b-1,c,d);}
		else if(a==1) cout << get(b-1,c) << endl;
	}
	
	return 0;
}

int get_size(int n){
	int res=0;
	while(n) n=n>>1,res++;

	return (1<<res);
}

int build(int n){
	sz=get_size(n);
	REP(i,0,2*sz) all[i]=0;
	REP(i,0,2*sz) part[i]=0;
	return 0;
}

int _range_add(int a,int b,int x,int k,int l,int r){
	if(a<=l&&r<=b) all[k]+=x;
	else if(l<b&&a<r){
		part[k]+=(min(b,r)-max(a,l))*x;
		_range_add(a,b,x,2*k+1,l,(l+r)>>1);
		_range_add(a,b,x,2*k+2,(l+r)>>1,r);
	}
	
	return 0;
}

int range_add(int a,int b,int x){
	return _range_add(a,b,x,0,0,sz);
}

ll _get(int a,int b,int k,int l,int r){
	if(b<=l||r<=a) return 0;
	if(a<=l&&r<=b) return all[k]*(r-l)+part[k];
	ll res=(min(b,r)-max(a,l))*all[k];
	res+=_get(a,b,k*2+1,l,(l+r)>>1);
	res+=_get(a,b,k*2+2,(l+r)>>1,r);
	
	return res;
}	

ll get(int a,int b){
	return _get(a,b,0,0,sz);
}

Measured memory_bytes: 7184
#include <iostream>
#include <algorithm>

using namespace std;

int solve(int A, int B, int C, int K)
{
	int ans = A + B + C;
	for (int a = 0; a <= K; ++a) {
		for (int b = 0; a + b <= K; ++b) {
			for (int c = 0; a + b + c <= K; ++c) {
				int tmp = (A << a) + (B << b) + (C << c);
				ans = max(ans, tmp);
			}
		}
	}
	return ans;
}

int main()
{
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	cout << solve(A, B, C, K) << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
    long long a, b, c, t;
    std::cin >> a >> b >> c;
    t = c - a - b;
    if(t <= 0){
        std::cout << "No" << std::endl;
        return 0;
    }
    if(4*a*b < t*t){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define var long long int
using namespace std;
var wt[1000005];
var val[1000005];
vector<pair<var,var>>vec;

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
signed main() {
	var n , w;
	var a,b;
	cin >> n >> w;
	var dp[n+1][w+1];
	for(var i=0;i<n;i++){
		cin>>wt[i]>>val[i];
		vec.push_back(make_pair(wt[i],val[i]));
	}
	sort(vec.begin(),vec.end(),sortbysec);
	for(int i=0;i<vec.size();i++){
		wt[i] = vec[i].first;
		val[i] = vec[i].second;
	}
//	cout << endl;
//	for(int i=0;i<n;i++){
//		cout << wt[i] <<" "<<val[i] << endl;
//	}

	for(int i=0;i<=n;i++){
		for(int j=0;j<=w;j++){
			
			if(i ==0 || j ==0){
				dp[i][j] = 0;
			}
			else if(wt[i-1] <= j){		
				dp[i][j] = max(val[i-1] + dp[i-1][j-wt[i-1]],dp[i-1][j]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
			
		}
	}
	
	cout << dp[n][w];
	return 0;
}

Measured memory_bytes: 82368
#include <iostream>
#include <string.h>
using namespace std;

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


    for(int i = 0; i < t.size(); ++i) {
        if(s == t) {
            cout << "Yes\n";
            return 0;
        }

        s = s.back() + s;

        s.pop_back();
    }

    cout << "No";


    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

// Range Sum Query
class SegmentTree{
public:
    int n;
    vector<ll> node;

    SegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void add(int x, ll val){
        x += (n - 1);
        node[x] += val;
        while(0 < x){
            x = (x - 1) / 2;
            node[x] = node[2*x+1] + node[2*x+2];
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0) r = n;
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];

        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);

        return vl + vr;
    }
};

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

    ll n, k; cin>>n>>k;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    vector<ll> b(n+1, 0);
    ll asum = 0;
    for(int i=0; i<n; i++){
        asum += a[i];
        b[i+1] = asum - k * (i + 1);
    }

    vector<ll> c = b;
    sort(all(c));

    int id = 0;
    map<ll, ll> b2id;
    for(int i=0; i<=n; i++){
        if(b2id.find(c[i]) == b2id.end()){
            b2id[c[i]] = id++;
        }
    }

    for(int i=0; i<=n; i++){
        b[i] = b2id[b[i]];
    }

    SegmentTree seg(vector<ll>(n+1, 0));
    ll ans = 0;
    for(int i=n; i>=0; i--){
        ans += seg.getsum(b[i], n + 1);
        seg.add(b[i], 1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 22400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}

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


Measured memory_bytes: 3624
s = input()

for i in range(len(s)):
    if s[i] == 'A':
        start = i
        break

for i in range(len(s)):
    if s[len(s) - i - 1] == 'Z':
        end = len(s) - i
        break

if end > start:
    print(end - start)
else:
    print(0)

Measured memory_bytes: 3516
def divisor(n):
    i = 1
    res = []
    for i in range(1, int(n**.5) + 1):
        if n%i == 0:
            res.append(i)
            if n//i not in res:
                res.append(n//i)
    res.sort()
    return res

def main():
    n, m = map(int, input().split())
    md = divisor(m)
    ans = 0
    for i in md:
        if (m - n*i)%i == 0 and (m - n*i) >= 0:
            ans = i
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int N;

int main()
{
  cin >> N;

  cout << (int)(ceil(log(N) / log(3))) << endl;

  return 0;
}

Measured memory_bytes: 1200
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;

void main(){
	auto z=readln.split.to!(int[]),a=z[0],b=z[1];
	if(a%3==0||b%3==0||(a+b)%3==0)writeln("Possible");
	else writeln("Impossible");
}

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

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	vector<ll>A(100001, 0);
	ll N, K;
	cin >> N >> K;
	vector<ll>a(N), b(N);
	for (int i = 0; i < N; i++){
		cin >> a[i] >> b[i];
		A[a[i]] += b[i];
	}
	int cnt = 0;
	for (int i = 1; i < 1000001; i++)
	{
		if (K <= A[i]) {
			cout << i << endl;
			return 0;
		}
		K -= A[i];
	}

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
typedef long long ll;
vector<pair<pair<double,double>,double> > V;
double dist(double x1, double y1, double x2, double y2 ){
return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
bool vis[1005];
double xt,yt,xs,ys;
int n;
double dij(){
    priority_queue<pair<double,pair<int,int> > >Q;
    Q.push({0.0,{-1,0}});
    double ans=1e18;
    while(Q.size()){
        auto cur = Q.top();
        Q.pop();
        if(vis[cur.S.S])continue;
        if(cur.S.S==n+1) return abs(cur.F);
        vis[cur.S.S]=true;
        int j=cur.S.S;
        for(int i = 1; i <= n+1; i++) {
            if(i == j)continue;
            double di=max(0.0,dist(V[j].F.F,V[j].F.S,V[i].F.F,V[i].F.S)-V[i].S-V[j].S);
            Q.push({cur.F - di,{j,i}});
        }
    }
}
int main(){
    cin >> xs >> ys >>xt >> yt;
    cin >> n;
    V.resize(n+1);
    V[0]={{xs,ys},0.0};
    for(int i= 1 ;i <= n;i++)
        cin >>V[i].F.F>>V[i].F.S >>V[i].S;
    V.push_back({{xt,yt},0.0});
    cout<<fixed<<setprecision(9)<<dij()<<endl;

    return 0;
}


Measured memory_bytes: 16764
package main

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

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

var ans int

func main() {
	sc.Split(bufio.ScanWords)
	a := make([]int, 9)
	for i := 0; i < 9; i++ {
		a[i], _ = strconv.Atoi(stringLineScan())
	}
	n, _ := strconv.Atoi(stringLineScan())
	t := make([]bool, 9)
	for i := 0; i < n; i++ {
		b, _ := strconv.Atoi(stringLineScan())
		for j := 0; j < 9; j++ {
			if a[j] == b {
				t[j] = true
			}
		}
	}
	if t[0] == true && t[1] == true && t[2] == true {
		fmt.Println("Yes")
	} else if t[3] == true && t[4] == true && t[5] == true {
		fmt.Println("Yes")
	} else if t[6] == true && t[7] == true && t[8] == true {
		fmt.Println("Yes")
	} else if t[0] == true && t[3] == true && t[6] == true {
		fmt.Println("Yes")
	} else if t[1] == true && t[4] == true && t[7] == true {
		fmt.Println("Yes")
	} else if t[2] == true && t[5] == true && t[8] == true {
		fmt.Println("Yes")
	} else if t[0] == true && t[4] == true && t[8] == true {
		fmt.Println("Yes")
	} else if t[2] == true && t[4] == true && t[6] == true {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

// ====================================================================

int main() {
  string s;
  cin >> s;
  if (s == "A") {
    cout << "T" << endl;
  } else if (s == "T") {
    cout << "A" << endl;
  } else if (s == "C") {
    cout << "G" << endl;
  } else if (s == "G") {
    cout << "C" << endl;
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int N, Ma, Mb;
int A[123], B[123], C[123];
int memo[45][1234][1234];

int dp(int i, int a, int b) {
	if (a && b && a * Mb == b * Ma) return 0;
	if (i == -1) return 1123456789;
	if (memo[i][a][b]) return memo[i][a][b];
	return memo[i][a][b] = min(dp(i - 1, a, b), dp(i - 1, a + A[i], b + B[i]) + C[i]);
}

int main() {

	scanf("%d%d%d", &N, &Ma, &Mb);

	rep(i, N) scanf("%d%d%d", &A[i], &B[i], &C[i]);

	int ans = dp(N - 1, 0, 0);
	if (ans >= 1123456789) {
		printf("-1\n");
	}
	else {
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 107776