akhauriyash/Code-Regression huggingface dataset:
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let dist [x1;y1] [x2;y2] =
    abs (x1 - x2) ** 2.0 + abs (y1 - y2) ** 2.0
    |> sqrt

let distAll ps =
    List.pairwise ps
    |> List.fold (fun s (p1, p2) -> s + dist p1 p2) 0.0

let rec insertions x = function
        | []             -> [[x]]
        | (y :: ys) as l -> (x::l)::(List.map (fun x -> y::x) (insertions x ys))

let rec permutations = function
    | []      -> seq [ [] ]
    | x :: xs -> Seq.concat (Seq.map (insertions x) (permutations xs))

[<EntryPoint>]
let main _ =
    let N = read int
    let XYS = List.init N (fun _ -> reads float)

    let pss = permutations XYS |> List.ofSeq

    let ans =
        List.fold (fun s ps -> s + distAll ps) 0.0 pss

    let k = List.fold ( * ) 1 [1 .. N]

    // eprintfn "*%A" pss
    // eprintfn "*%A" ans
    // eprintfn "*%A" k

    printfn "%.7f" (ans / float k)
    0

Measured memory_bytes: 28720
from operator import itemgetter
import sys
sys.setrecursionlimit(1000000)

def dfs(n,team):
    li[n-1] = team
    for i in grp[n-1]:
        if(li[i[0]-1]==-1):
            dfs(i[0],(team+i[1])%2)



N = int(input())
li = [-1]*N
uvw = [[int(x) for x in input().split()]for _ in range(N-1)]
uvw.sort(key=itemgetter(0))
grp = [[]for _ in range(N)]
for i in uvw:
    grp[i[0]-1].append([i[1],i[2]])
    grp[i[1]-1].append([i[0],i[2]])
dfs(1,0)
for i in li:
    print(i)


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

int main()
{
    int n; cin >> n;
    string ans;
    if (n == 0) {
        ans = "0";
    } else {
        ans = "";
        while (n != 0) {
            if (n % 2 == 0) {
                ans = "0" + ans;
            } else {
                ans = "1" + ans;
                n--;
            }
            n /= -2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(register int (i)=0;(i)<(x);++(i))
inline int getint(){
	int x=0,p=1;char c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//ruogu
const int N=190;
int n,m,pre[N][N],dpr[N][N][N],dpd[N][N][N],tmr[N][N][N],tmd[N][N][N];
char s[N][N];
//
inline int get(int sx,int sy,int ex,int ey){
    return pre[ex+1][ey+1]-pre[ex+1][sy]-pre[sx][ey+1]+pre[sx][sy];
}
inline bool isok(int sx,int sy,int ex,int ey){
    int tmp=get(sx,sy,ex,ey);
    return tmp==0||tmp==(ex-sx+1)*(ey-sy+1);
}
int main(){
    n=getint();m=getint();
    rep(i,n)scanf("%s",s[i]);
    rep(i,n)rep(j,m){
        if(s[i][j]=='#')pre[i+1][j+1]=1;
        pre[i+1][j+1]+=pre[i+1][j]+pre[i][j+1]-pre[i][j];
    }
    rep(i,n)rep(j,m){
        for(int k=i;k<n;k++){
            int lb=j-1,rb=m;
            while(rb-lb>1){
                int mid=(lb+rb)>>1;
                if(isok(i,j,k,mid))lb=mid;
                else rb=mid;
            }
            dpr[i][j][k]=lb;
        }
        for(int k=j;k<m;k++){
            int lb=i-1,rb=n;
            while(rb-lb>1){
                int mid=(lb+rb)>>1;
                if(isok(i,j,mid,k))lb=mid;
                else rb=mid;
            }
            dpd[i][j][k]=lb;
        }
    }
    int res=0;
    while(1){
        if(dpr[0][0][n-1]==m-1)return !printf("%d\n",res);
        ++res;
        rep(i,n)rep(j,m){
            for(int k=i;k<n;k++)tmr[i][j][k]=max(dpr[i][dpr[i][j][k]+1][k],dpr[i][j][k]);
            for(int k=j;k<m;k++)tmd[i][j][k]=max(dpd[dpd[i][j][k]+1][j][k],dpd[i][j][k]);
        }
        rep(i,n)rep(j,m){
            int p=m-1;
            for(int k=i;k<n;k++){
                while(p>tmr[i][j][k]&&tmd[i][j][p]<k)--p;
                dpr[i][j][k]=p;
            }
            p=n-1;
            for(int k=j;k<m;k++){
                while(p>tmd[i][j][k]&&tmr[i][j][p]<k)--p;
                dpd[i][j][k]=p;
            }
        }
    }
	return 0;
}



Measured memory_bytes: 106880
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	string s;
	vector <ll> r(n);
	vector <ll> g(n);
	vector <ll> b(n);
	cin >> s;
	if (s[n-1] == 'R'){
		r[n-1] = 1;
	}
	else if (s[n-1] == 'G'){
		g[n-1] = 1;
	}
	else {
		b[n-1] = 1;
	}
	for (int z=n-2;z>=0;z--){
		r[z] = r[z+1];
		g[z] = g[z+1];
		b[z] = b[z+1];
		if (s[z] == 'R'){
			r[z]++;
		}
		else if (s[z] == 'G'){
			g[z]++;
		}
		else {
			b[z]++;
		}
	}
	ll ans = 0;
	for (int z=0;z<n;z++){
		for (int x=z+1;x<n;x++){
			if ((s[z] == 'R' && s[x] == 'G') || (s[x] == 'R' && s[z] == 'G')) {
				ans += b[x];
				if (x+x-z < n && s[x+x-z] == 'B') ans--;
			}
			else if ((s[z] == 'R' && s[x] == 'B') || (s[x] == 'R' && s[z] == 'B')){
				ans += g[x];
				if (x+x-z < n &&s[x+x-z] == 'G') ans--;
			}
			else if ((s[z] == 'G' && s[x] == 'B') || (s[x] == 'G' && s[z] == 'B')){
				ans += r[x];
				if (x+x-z < n &&s[x+x-z] == 'R') ans--;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<vector<int>> A(N,vector<int>(N));
    
    ll ans=0;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin>>A[i][j];
        }
    }
    
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            ans+=min(A[i][j],A[j][i]);
        }
    }
    
    cout<<ans<<endl;
}




Measured memory_bytes: 3264
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
  a, b = map(lambda x: int(x)-1, input().split())
  G[a].append(b)

for v in G[0]:
  if N-1 in G[v]:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")


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

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int[] c = new int[3];

	static int solve() {
		int ret = 0;
		int min = Math.min(c[0], Math.min(c[1], c[2]));
		for (int i = 0; i <= Math.min(3, min); ++i) {
			int count = (c[0] - i) / 3 + (c[1] - i) / 3 + (c[2] - i) / 3 + i;
			ret = Math.max(ret, count);
		}
		return ret;
	}

	public static void main(String[] args) throws Exception {
		while (true) {
			Arrays.fill(c, 0);
			c[0] += sc.nextInt();
			c[1] += sc.nextInt();
			c[2] += sc.nextInt();
			c[0] += sc.nextInt();
			c[1] += sc.nextInt();
			c[2] += sc.nextInt();
			if (c[0] + c[1] + c[2] == 0) break;
			System.out.println(solve());
		}
	}

}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
#define maxn 2005
int a[maxn];
bitset<3000000> dp;
void solve(){
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    int sum = 0;
    dp[0] = 1;
    rep(i, n){
        dp |= dp << a[i];
        sum += a[i];
    }
    int k = (sum + 1) / 2;
    while(dp[k] == 0) k++;
    cout << k << endl;
}

int main(int argc, char const *argv[]) {
    solve();
    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define size_of(a) (int)a.size()

int calc(vector< int >& s, vector< char >& op) {
	int cur = s[0], j = 1;
	
	for_(i,0,size_of(op)) {
		if (op[i] == '+') cur += s[j++];
		else cur *= s[j++];
	}
	
	return cur;
}

int main() {
	string s; int r;
	cin >> s >> r;
	
	vector< int > s1, s2;;
	vector< char > op1, op2;
	bool mul = false;
	
	for_(i,0,size_of(s)) {
		if (i & 1) {
			if (s[i] == '*') mul = true;
			else op1.push_back(s[i]), mul = false;
			op2.push_back(s[i]);
		} else {
			if (mul) s1[size_of(s1) - 1] *= s[i] - '0';
			else s1.push_back(s[i] - '0');
			s2.push_back(s[i] - '0');
		}
	}
	
	int c1 = calc(s1, op1), c2 = calc(s2, op2);
	bool f1 = (c1 == r), f2 = (c2 == r);
	
	if (f1 && f2) cout << "U" << endl;
	else if (f1) cout << "M" << endl;
	else if (f2) cout << "L" << endl;
	else cout << "I" << endl;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	if (B == min({A, B, C}) || B == max({A, B, C}))
	{
		if (K%2 == 0)
			cout << A - B << endl;
		else
			cout << B - A << endl;
	}
	else if (K%2 == 0)
		cout << A - B << endl;
	else
		cout << C - B << endl;
}



Measured memory_bytes: 256
def main():
    import heapq
    inf = 10**16
    n, m, s = map(int, input().split())
    uvab = [list(map(int, input().split())) for _ in [0]*m]
    cd = [list(map(int, input().split())) for _ in [0]*n]
    g = [[] for _ in [0]*n]
    [g[a-1].append([b-1, c, d]) for a, b, c, d in uvab]
    [g[b-1].append([a-1, c, d]) for a, b, c, d in uvab]
    vertex = [[inf]*2501 for _ in [0]*n]
    h = [(0, 0, min(s, 2500))]  # 時刻、位置、所持金
    heapq.heapify(h)
    while h:
        t, p, money = heapq.heappop(h)
        if vertex[p][money] != inf:
            continue
        vertex[p][money] = t
        newmoney = min(money+cd[p][0], 2500)
        if vertex[p][newmoney] == inf:
            heapq.heappush(h, (t+cd[p][1], p, newmoney))
        for a, b, c in g[p]:  # 行き先、運賃、時間
            if money < b:
                continue
            if vertex[a][money-b] != inf:
                continue
            heapq.heappush(h, (t+c, a, money-b))
    for i in vertex[1:]:
        print(min(i))


main()


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

int main() {
    int x,y,count=0; cin>>x>>y;
    if(x==1) count+=300000;
    else if(x==2) count+=200000;
    else if(x==3) count+=100000;
    if(y==1) count+=300000;
    else if(y==2) count+=200000;
    else if(y==3) count+=100000;
    if(x==1  && y==1)
    count+=400000;

    cout<<count<<endl;
    return 0;
}

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

#define int long long 
#define dou  double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int n,m,k,i,j,x;
	cin >> n >> m >> k;
	vector<int> a(n+1),b(m+1);
	a[0]=0; b[0]=0;
	for(i=0;i<n;i++)
	{
		cin >> x;
		a[i+1]= a[i]+x;
	}
	for(i=0;i<m;i++)
	{
		cin >> x;
		b[i+1]= b[i]+x;
	}
	int ans=INT_MIN;

	for(i=0;i<=n;i++)
	{
		if(a[i]>k)
			break;
		x = k-a[i];
		j = upper_bound(b.begin(),b.end(),x)-b.begin()-1;
		ans = max(i+j,ans);
	}
	cout << ans << endl;
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
}

Measured memory_bytes: 6312
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

    string a;
    cin >> a;

    cout << (a == "ARC" ? "ABC" : "ARC");
}

Measured memory_bytes: 3600
#!/usr/bin/env python3
import sys


def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"):

    CSF = list(zip(C,S,F))

    for i in range(N-1):
        t = 0
        for j in range(i,N-1):
            c,s,f = CSF[j]
            if t <= s:
                t = s
            elif t % f == 0:
                pass
            else:
                t = t + f - (t % f)
            t += c
        print(t)
    print(0)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int()] * (N-1)  # type: "List[int]" 
    S = [int()] * (N-1)  # type: "List[int]" 
    F = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        C[i] = int(next(tokens))
        S[i] = int(next(tokens))
        F[i] = int(next(tokens))
    solve(N, C, S, F)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import Data.List

data S = Up | Down | Other deriving (Eq)

countBandT :: Ord a => S -> [a] -> ([a],[a])
countBandT _ [] = ([],[])
countBandT status [a] | status == Up   = ([], [a])
                      | status == Down = ([], []) 
                      | otherwise = ([],[a])
countBandT Other (a:b:ls) | a < b = ((fst $ countBandT Up (b:ls)), snd $ countBandT Up (b:ls))
                          | a > b = ((fst $ countBandT Down (b:ls)), (a : (snd $ countBandT Down (b:ls))))
                          | otherwise = countBandT Other (b:ls)
countBandT status (a:b:ls) | status == Down && a < b = ((a : (fst $ countBandT Up (b:ls))), snd $ countBandT Up (b:ls))
                           | status == Up && a > b   = ((fst $ countBandT Down (b:ls)), (a : (snd $ countBandT Down (b:ls))))
                           | otherwise = countBandT status (b:ls)

water :: Int -> Int -> ([Int],[Int]) -> Int
water _ _ ([],[]) = 0
water count n (bs,ts) = n + (water (count+1) (n+(fst $ numOf count bs)-(fst $ numOf count ts)) (snd $ numOf count bs, snd $ numOf count ts))

numOf0 :: Int -> Int -> [Int] -> (Int,[Int])
numOf0 c _ [] = (c,[])
numOf0 c n (x:xs) | n == x    = numOf0 (c+1) n xs
                  | otherwise = (c,(x:xs))

numOf = numOf0 0

main :: IO ()
main = do
  n <- read <$> getLine :: IO Int
  hs <- map read.words <$> getLine :: IO [Int]
  let bt = countBandT Other hs
  putStrLn $ show $ (water 0 1 (sort $ fst bt, sort $ snd bt)) - 1


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void){
    int x1, x2, y1, y2;
    int x3, x4, y3, y4;
    int dx, dy;
    
    cin >> x1 >> y1 >> x2 >> y2;
    
    dx = abs(x1 - x2);
    dy = abs(y1 - y2);
    
    // cout << dx << " " << dy << endl;
    
    if(x2 >= x1 && y2 >= y1){
        x3 = x2 - dy;
        y3 = y2 + dx;
        x4 = x1 - dy;
        y4 = y1 + dx;
    }
    else if(x2 < x1 && y2 >= y1){
        x3 = x2 - dy;
        y3 = y2 - dx;
        x4 = x1 - dy;
        y4 = y1 - dx;
    }
    else if(x2 >= x1 && y2 < y1){
        x3 = x2 + dy;
        y3 = y2 + dx;
        x4 = x1 + dy;
        y4 = y1 + dx;
    }
    else{
        x3 = x2 + dy;
        y3 = y2 - dx;
        x4 = x1 + dy;
        y4 = y1 - dx;
    }
    
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
XYZ = [list(map(int, input().split())) for _ in range(m)]

uf = uf = UnionFind(n)

for x, y, z in XYZ:
  x -= 1
  y -= 1
  uf.union(x, y)
  
print(uf.group_count())

Measured memory_bytes: 31832
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
using pii = pair<int, int>;

#define rep(i,k,n) for(int i=(k); i != int(n); ++i)
#define sz(x) x.size()
#define all(x) x.begin(), x.end()

#define dbg(x) cout << #x << '=' << x << '\n'
#define dbg2(x, y) cout << #x << '=' << x << ' ' << #y << '=' << y << '\n' 

#define input() (*istream_iterator<int>(cin))
#define strin() (*istream_iterator<string>(cin))
#define output(x) cout << x << '\n' 

int main(){
    ios::sync_with_stdio(false);
    int k = input();
    string str = strin();
    if(sz(str) > k){
        str.resize(k);
        cout << str << "..." << "\n";
    }
    else cout << str << "\n";
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
using namespace std;

const int MOD=1e9+7;

bool is_possible(vector<int> row){
	vector<int> numbers(row.size(),0);
	//for (int i: numbers) printf("%d",i);
	for (int i: row){
		if (numbers[i/2] == 0) numbers[i/2]+=1;
		else if (numbers[i/2] == 1 && i != 0) numbers[i/2]+=1;
		else if (numbers[i/2] == 2) return false;
		else return false;

	}
	
	return true;
}
int main(){
    
    int n;
    scanf("%d",&n);
	vector<int> row(n);
	for (int&k : row){
		scanf("%d",&k);
	}
	if (is_possible(row)){
		long long result = 1;
		for (int i=0; i<n/2;i++){
			result=2*result%MOD;
		}
		
		printf("\n%lld",result);
	}
	else printf("\n%d",0);
    return 0;
}


Measured memory_bytes: 1408
n, k = map(int, input().split())

m_list = []

for i in range(n):
  m_tuple = tuple(map(int, input().split()))
  m_list.append(m_tuple)

num = m_list[0][0]

m_list.sort(key=lambda tup:tup[0])

for a, b in m_list:
  if b >= k:
    num = a
    break
  else:
    k -= b

print(num)


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

void main_()
{
    string A, B;
    cin >> A >> B;
    if (A.size() > B.size()) {
        cout << "GREATER\n";
        return;
    }
    if (A.size() < B.size()) {
        cout << "LESS\n";
        return;
    }
    if (A > B) {
        cout << "GREATER\n";
        return;
    }
    if (B > A) {
        cout << "LESS\n";
        return;
    }

    cout << "EQUAL\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  string s;
  int k;
  cin >> s >> k;
  REP(i, k) {
    if (s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << "1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

class Combination_Mod{
    public:
        Combination_Mod(long long MAX, long long MOD) : fact(MAX + 1), inv(MAX + 1), finv(MAX + 1), MAX(MAX + 1), MOD(MOD){
            init();
        }

        void init(){
            fact[0] = fact[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for(long long i = 2; i < MAX; ++i){
                fact[i] = fact[i - 1] * i % MOD;
                inv[i] = MOD - inv[MOD % i] *  (MOD / i) % MOD;
                finv[i] = finv[i - 1] * inv[i] % MOD;
            }
        }

        long long value(long long n, long long r){
            if(n < r || n < 0 || r < 0) return 0;
            return fact[n] * (finv[r] * finv[n - r] % MOD) % MOD;
        }

    private:
        vector<long long> fact;
        vector<long long> inv;
        vector<long long> finv;
        const long long MAX;
        const long long MOD;
};

ll N, K;
ll A[100010];

signed main(){
    cin >> N >> K;
    map<ll, ll> mp;
    REP(i, N){
        cin >> A[i];
        mp[A[i]]++;
    }
    Combination_Mod cm(200000, MOD);
    ll sum = 0, ans = 0;
    for(auto p : mp){
        ans = (ans + p.first * (cm.value(sum + p.second, K) - cm.value(sum, K)) % MOD) % MOD;
        ans = (ans + MOD - p.first * (cm.value(N - sum, K) - cm.value(N - sum - p.second, K)) % MOD) % MOD;
        sum += p.second;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 11520
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    N = makeInt(input_string[0])
    t = makeMultiInteger(input_string[1])
    c = 0
    for i in range(N):
        if i == 0:
            c += 1
            continue
        elif t[i] >= max(t[:i]):
            c += 1
    return c


def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long int Int;

char src[100][100];
char dst[200][100];

int main(void)
{
    int h,w;

    cin>>h>>w;
    for(int i = 0;i < h;i++) {
	string s;
	cin>>s;
	for(int j = 0;j < w;j++) {
	    src[i][j] = s[j];
	}
    }

    for(int i = 0;i < h;i++) {
	for(int j = 0;j < w;j++) {
	    dst[2*i][j] = src[i][j];
	    dst[2*i+1][j] = src[i][j];
	}
    }

    for(int i = 0;i < 2*h;i++) {
	for(int j = 0;j < w;j++) {
	    cout<<dst[i][j];
	}
	cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	char i[1200],j=0;
	while(1){
		scanf("%c",&i[j]);
		if(i[j]=='\n'){
			break;
		}
		if(i[j]<=90&&65<=i[j]){
			printf("%c",i[j]+32);
		}
		else if(97<=i[j]&&i[j]<=122){
			printf("%c",i[j]-32);
		}
		else{
			printf("%c",i[j]);
		}
		j++;
	}
	printf("\n");
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  int ans = 753;
  for (int i = 0; i < S.size()-2; i++) {
      int x = 100*(S.at(i)-'0')+10*(S.at(i+1)-'0')+S.at(i+2)-'0';
      ans = min(ans, abs(x-753));
  }
  
  cout << ans << endl;

}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  int s=0;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    s += a[i];
  }
  int k=0;
  for(int i=0; i<n; i++) {
    if(a[i]*4*m>=s) k++;
  }
  if(k >= m){
    cout << "Yes" << endl;
  } else {
   cout << "No" << endl;
  }
 
 
}

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

int main(){
	int n, m, z[200], xx, yy;
	string x, y, out;
	while (cin >> n) {
		if (n == 0) { break; }
		for (int i = 0; i < 200; i++) {
			z[i] = i;
		}
		out = "";
		for (int i = 0; i < n; i++) {
			cin >> x >> y;
			xx = x[0];
			yy = y[0];
			z[xx] = yy;
		}
		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> x;
			n = x[0];
			out += z[n];
		}
		cout << out << endl;
	}
	return 0;
}

Measured memory_bytes: 3308
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

int main() {
  int N, K;
  while (cin >> N >> K) {
    vector<char> D(10);
    for (int i : range(K)) {
      int d; cin >> d;
      D[d] = 1;
    }

    for (int res = N; ; ++res) {
      stringstream ss;
      ss << res;
      string s = ss.str();
      bool bad = 0;
      for (int i : range(s.size())) {
        if (D[s[i] - '0']) bad = 1;
      }
      if (!bad) {
        cout << s << endl;
        break;
      }
    }
  }
}



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

using namespace std;

int brute(int argc, char *argv[]) {
   return 0;
}

int tests(int argc, char *argv[]) {
   return 0;
}

int n, p;
vector<long long> a;

long long solve(vector<long long> b){
   long long res = 0;
   for(int i = 1; i < n; ++i){
      if(b[i] + b[i - 1] >= p){
         long long diff = (b[i] + b[i - 1] - p);
         res += diff;
         if(b[i] >= diff) b[i] -= diff;
         else{
            b[i] = 0;
            b[i - 1] -= (diff - b[i]);
         }
      }
   }
   return res;
}

int _main(int argc, char *argv[]) {
   cin >> n >> p;
   int x;
   for(int i = 0; i < n; ++i){
      scanf("%d", &x);
      a.push_back(x);
   }
   vector<long long> b = a;
   long long res = solve(b);
   b = a;
   reverse(b.begin(), b.end());
   res = min(res, solve(b));
   cout << res << endl;
   return 0;
}

int main(int argc, char *argv[]){
   if(argc >= 2 && argv[1][0] == '1') {
      brute(argc, argv);
   } else if(argc >= 2 && argv[1][0] == '2') {
      tests(argc, argv);
   } else {
      _main(argc, argv);
   }
   return 0;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    int sum = 0;
    if (n < k) {
        sum += x * n;
    } else {
        sum += x * k + y * (n - k);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
n, a = map(int, input().split())
x = list(map(int, input().split()))
x = list(map(lambda i: i-a, x))
dp = {0: 1}

for i in x:
  for k,v in list(dp.items()):
    dp[i+k]=dp.get(i+k,0)+v
print(dp[0]-1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main() {
  int x,a;
  cin >> x>>a;
if(x<a)cout <<0;
 else
   cout << 10;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
// using ll = boost::multiprecision::int128_t;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;


int main() {
  cout << "? " << ll(1e+10) << "\n" << flush;
  char c; cin >> c;

  // N = 10^k の場合
  if (c == 'Y') {
    int i = 1;
    ll n = 10;
    for (; i < 11; ++i) {
      cout << "? " << (n-1) << "\n" << flush;
      char c; cin >> c;
      if (c == 'Y') {
        cout << "! " << (n/10) << "\n" << flush;
        return 0;
      }
      n *= 10;
    }
  }

  // 以下 N = 10^k でない場合
  // N の桁数を調べて d とする
  int d = 0;
  ll n = 1;
  for (; d < 10; ++d) {
    cout << "? " << n << "\n" << flush;
    char c; cin >> c;
    if (c == 'N') break;
    n *= 10;
  }

  ll ng = 1;
  rep(i, d) ng *= 10;
  ll ok = ng * 10 - 1;
  while (abs(ok-ng) > 1) {
    ll md = (ok+ng)/2;
    cout << "? " << md << "\n" << flush;
    char c; cin >> c;
    if (c == 'Y') ok = md;
    else ng = md;
  }
  ll ans = ok / 10;
  cout << "! " << ans << "\n" << flush;
  return 0;
}


Measured memory_bytes: 596
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    // input
    static String s;

    /**
     * input
     */
    static void input(){
        Scanner sc = new Scanner(System.in);
        s = sc.next();
        sc.close();
    }
 
    /**
     * solver
     */
    static void solve(){
        int ans = 0;

        int n = s.length();

        // minimum cost to convert substring s(0:i) -> ...0101
        int[] a = new int[n];

        // minimum cost to convert substring s(0:i) -> ...1010
        int[] b = new int[n];

        // init
        if (s.charAt(0) == '0'){
            a[0] = 1;
            b[0] = 0;
        } else {
            a[0] = 0;
            b[0] = 1;
        }

        // recursion
        for(int i=1;i<n;i++){
            if (s.charAt(i) == '0') {
                a[i] = 1 + b[i-1];
                b[i] = a[i-1];
            } else {
                a[i] = b[i-1];
                b[i] = 1 + a[i-1];
            }
        }

        ans = Math.min(a[n-1], b[n-1]);

        System.out.println(ans);
    }

    public static void main(String args[]) {

        input();

        solve();
    }
}


Measured memory_bytes: 27900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int k;
  string s;
  cin >> k >> s;

  if (s.size() <= k) {
    cout << s << endl;
    return 0;
  } else {
    for (int i = 0; i < k; i++) {
      cout << s[i];
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3468
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
ll mol=1e9+7;
ll q_pow(ll n,ll t)
{
    ll res=1;
    while(t)
    {
        if(t%2) res=(res*n)%mol;
        n=(n*n)%mol;
        t/=2;
    }
    return res;
}
void exgcd(ll a,ll b,ll &x,ll &y)
{
    if(b==0) x=1,y=0;
    else exgcd(b,a%b,y,x),y-=x*(a/b);
}
ll inv(ll a)
{
    ll x,y;
    exgcd(a,mol,x,y);
    return (x%mol+mol)%mol;
}
ll c(ll n,ll r)
{
    if(n-r<r) r=n-r;
    ll ans=1,num=1;
    for(int i=0;i<r;i++) ans=(ans*(n-i))%mol;
    for(int i=1;i<=r;i++) num=(num*i)%mol;
    return (ans*inv(num))%mol;
}
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<(q_pow(2,n)-1-c(n,a)-c(n,b)+3*mol)%mol<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    string s;
    cin >> s;
     int ans=0; int cnt=0;
    for(int i=0; i<s.size(); i++){
        if(s.at(i)=='A' || s.at(i)=='T' || s.at(i)== 'C'|| s.at(i) == 'G') cnt++;
        else{ 
            ans = max(ans,cnt);
            cnt = 0;
    }
}
ans = max(ans,cnt);
cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

bool check(string s) {
  int l = s.length() ;
  if (s == s.substr(0, l/2) + s.substr(0, l/2)) return true;
  else return false;
}

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

  for (int i = 2; i < s.length(); i+=2) {
    string t = s.substr(0, s.length()-i);
    if (check(t)) {
      cout << t.length() << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{   
	double N,fz;
	fz=0;
	cin>>N;
	for(int t=1;t<=N;t++)
	{
		if(t%2!=0)
		fz+=1.0;
	}
	cout<<fz/N;
	return 0;  		
}	

Measured memory_bytes: 256
while 1:
    m, f, r = map(int, input().split())
    if m+f+r == -3:break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50 or (m + f >= 30 and r >= 50):
        print("C")
    elif m + f >= 30:
        print("D")
    else:
        print("F")


Measured memory_bytes: 5596
n=int(input())
txylist=[[0,0,0]]
for i in range(n):
    txy=list(map(int,input().split(" ")))
    txylist+=[txy]
for i in range(n):
    p=False
    t0,x0,y0=txylist[i]
    t1,x1,y1=txylist[i+1]
    t,x,y=t1-t0,x1-x0,y1-y0
    tt=abs(x)+abs(y)
    legs=t-tt
    if legs>=0 and legs%2==0:
        p=True
    else:
        print("No")
        break
if p==True:
    print("Yes")

Measured memory_bytes: 27036
#include <iostream>
using namespace std;
int main(void){
    char S[4];
    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        cin >> S[i];
        if (S[i] == 'o') cnt++;
    }
    cout << 700 + 100 * cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if((abs(A - B) <= D && abs(B - C) <= D) || abs(A - C) <= D) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

using namespace std;

int RegNum;//登録者数
int RegATK[20];//登録者戦闘力
int RegATKAll;//登録者戦闘力合計
int PartyATK[2];//パーティー戦闘力

int GetMinATK(int n,int PAATK){
	if (n == 0)return abs(RegATKAll - (2 * PAATK));
	return min(GetMinATK(n - 1, PAATK + RegATK[n]), GetMinATK(n - 1, PAATK));
}

int main(){

	while (1){
		//変数初期化
		PartyATK[0] = 0; PartyATK[1] = 0;
		RegATKAll = 0;

		cin >> RegNum;//登録者数代入
		if (RegNum == 0)break;//0ならbreak
		for (int i = 0; i < RegNum; ++i){//戦闘力代入
			cin >> RegATK[i];
			RegATKAll += RegATK[i];
		}

		cout << GetMinATK(RegNum-1, 0) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import collections
N = int(input())
def pf(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c = collections.Counter(pf(N))
ans = 0
for i in c.keys():
    for j in range(1,40):
        if j*(j+1)/2 <= c[i] < (j+1)*(j+2)/2:
            ans += j
print(ans)

Measured memory_bytes: 9376
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void) {
  char alphabet;
  scanf("%c", &alphabet);
  if (65 <= (int) alphabet && (int) alphabet <= 90) {
    printf("A\n");
  } else if (97 <= (int) alphabet && (int) alphabet <= 122) {
    printf("a\n");
  }

  return 0;
}


Measured memory_bytes: 1592
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int a,b;
   cin>>a>>b;
   if(a>b)cout<<a*2-1<<endl;
   if(a==b)cout<<a*2<<endl;
   if(a<b)cout<<b*2-1<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }




int main(int argc, char* argv[])
{
	for (;;) {
		ll X, Y;
		cin >> X >> Y;
		if (cin.fail()) break;
		int result = 0;
		while (Y >= X) { Y >>= 1; result++; }
		cout << result << endl;
	}

	return 0;
}


Measured memory_bytes: 256
export default solve;

// main
function main(lines) {
  console.log(solve(lines));
}

// solver
function solve(lines: string[]): string {
  const { N, D } = parseLines(lines);
  return Math.ceil(Number(N) / (Number(D) * 2 + 1)).toString();
}

// helpers
function parseLines(lines: string[]) {
  const [N, D] = lines[0].split(' ');

  const obj = { N, D };
  debug(obj);
  return obj;
}

// general helpers
function debug(message?: any, ...optionalParams: any[]) {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
}

// reader
if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}


Measured memory_bytes: 7500
// यथा चतुर्भिः कनकं परीक्ष्यते निघर्षणच्छेदनतापताडनैः।
// तथा चतुर्भिः पुरुषः परीक्ष्यते त्यागेन शीलेन गुणेन कर्मणा॥
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define mapii std::map<int,int>
#define mpaci std::map<char,int>
#define umapii std::unordered_map<int,int>
#define umapci std::unordered_map<char,int>
#define seti std::set<int>
#define useti std::unordered_set<int>
#define qi std::queue<int>
#define qc std::queue<char>
#define sti std::stack<int>
#define stc std::stack<char>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
#define all(x) x.begin(),x.end() 
#define printv(v) for(auto x: v){ cout<< x << " ";}
#define pi 3.14159265358979323846
#define setprc(x) setprecision(x)
void file(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
bool sortdesk(const pair<int,int> &a, const pair<int,int> &b){return a.ff>b.ff;}
bool sortdesv(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;}
bool sortascv(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasck(const pair<int,int> &a, const pair<int,int> &b){return a.ff<b.ff;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
int gcd(int a, int b){if (b == 0){return a;} return gcd(b, a % b);}
int cntdiv(int n){int cnt=0;for(int i=1;i<=sqrt(n);++i){if(n%i==0){if(n/i==i)++cnt;else{cnt = cnt + 2;}}}return cnt;}
lld posnegmod(lld x,lld mod){return (x%mod+mod)%mod;}
// cout<<fixed<<setprecision(20)
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
// const int maxi = 1e6+10;
// vector<int> v[maxi];
// vector<long long> a(maxi,0);
// void dfs(int x){
//     if(a[x]){return;}
//     a[x]=1;
//     for(int i=0;i<v[x].size();++i){
//         dfs(v[x][i]);
//     }
// }

void test_case(){
    map<string,int> mp;
    mp["AC"]=0;mp["WA"]=0;mp["RE"]=0;mp["TLE"]=0;
    int n;
    cin>>n;
    fors(i,n){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"];
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
        test_case();
    }
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<ll> a(n), x(n, 0); //降水量:2x
  rep(i,n) {
    cin >> a[i];
    if (i % 2 == 0) x[0] += a[i];
    else x[0] -= a[i];
  }
  x[0] /= 2;
  cout << x[0]*2 << " ";
  for (int i = 1; i < n; ++i) {
    x[i] = a[i-1] - x[i-1];
    cout << x[i]*2 << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2944
p=2019
s,a,d,z=reversed(input()),0,0,[0]*p
for i,j in enumerate(s):
	d=(d+(int(j)*pow(10,i,p)))%p
	z[d]+=1
r=z[0]
for i in range(p):
	r+=z[i]*(z[i]-1)//2
print(r)

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

int main(){
	double n,k,t;
	double ma=0,ans=0;
	vector <double> p;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>t;
		p.push_back((t+1)/2);
	}
	for(int i=0;i<k;i++){
		ma+=p[i];
	}
	ans=ma;
	for(int i=k;i<n;i++){
		ma+=p[i]-p[i-k];
		ans=max(ans,ma);
	}
	cout<<setprecision(10)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3444
#include <cstdio>
#define MAX 246913

int main( void ){
	int n;
	int counter;
	int a[ MAX ] = {0};
	
	for( int i = 2; i <= MAX; i++ ){
		if( a[ i ] ){ continue; }
		for( int j = i * 2; j <= MAX; j += i ){
			a[ j ] = 1;
		}
	}
	
	while(1){
		scanf( "%d", &n ); 
		if(!n){break;}
		counter = 0;
		for( int i = n + 1; i <= 2 * n; i++ ){
			counter += (! a[ i ]);
		}
		printf( "%d\n", counter );
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()
#define  unsigned long ul
#define  long long ll

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3])
    cout << "Bad";
  else
    cout << "Good";
  cout << endl;
  return 0;
}


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

long int find(long int x)
{
  if(x == 1)
  return 1;
  else
  return 1 + 2*find(x/2);
}

int main() {
  long int H;
  cin>>H;
  if(H==1)
  {
    cout<<"1";
    return 0;
  }
  else
  {
    cout<<1 + 2*find(H/2);
  }
  

return 0;
}

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

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

    cout <<  100* ((10 - n/100)) + 10* (10 - (n % 100)/10) + (10 - (n % 100) % 10);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 MOD=1e9+7;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a;
    while(b){
        if(b&1) (n*=A)%=modint::MOD;
        (A*=A)%=modint::MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,a;
    in>>n;
    int r{},b{},g{},c;
    modint ans{1};
    fr(i,n){
        in>>a;
        c=0;
        if(r==a) ++c;
        if(b==a) ++c;
        if(g==a) ++c;
        ans*=c;
        if(r==a){
            ++r;
            continue;
        }
        if(b==a){
            ++b;
            continue;
        }
        if(g==a){
            ++g;
            continue;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256