akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = input()
ans = 0


def create_table(pattern):
    table = [0 for _ in range(len(pattern))]
    j = 0
    for i in range(1, len(pattern)):
        if pattern[i] == pattern[j]:
            j += 1
            table[i] = j
        else:
            table[i] = j
            j = 0
    return table


def hoge_search(string, pattern):
    table = create_table(pattern)
    i = j = 0
    ret = 0
    while i < len(string):
        if (string[i] == pattern[j]) and (i-j >= j):
            i += 1
            j += 1
            if i-j >= j-1:
                ret = max(j, ret)
        elif j == 0:
            i += 1
        else:
            j = table[j]  # ここのループがダメな時がある?
    return ret

def z_algorithm(S):
    N = len(S)
    Z_arr = [0] * N
    Z_arr[0] = N
    i = 1
    j = 0
    while i < N:
        while i+j < N and S[j] == S[i+j]:
            j += 1
        Z_arr[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < N and k + Z_arr[k] < j:
            Z_arr[i+k] = Z_arr[k]
            k += 1
        i += k
        j -= k
    return Z_arr

ans = 0
for i in range(N):
    res = z_algorithm(S[i:])
    for j, z in enumerate(res):
        if j  >= z:
            ans = max(ans, z)
print(ans)


Measured memory_bytes: 79496
main = do
  k <- readLn
  let d = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
  print $ d !! (k-1)

Measured memory_bytes: 508
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  
  vector<ll> A;
  REP(i,N){
    ll a;
    cin>>a;
    A.PB(a);
  }
  SORT(A);
  
  ll sum=A.at(0),t=0LL;
  for(int i=1; i<N; ++i){
    if(sum*2<A.at(i)) t=i;
    sum+=A.at(i);
  }
  
  co(N-t);
  return 0;
}

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

int main() {
  int s = 0 ;
  cin >> s ;
  int s1 = s / 100 ;
  int s2 = (s - 100 * s1 ) / 10 ;
  int s3 = (s - 100 * s1 - 10 * s2 ) ;

  cout << s1 + s2 + s3 << endl ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD
#define MODSUB(SUB_X,SUB_Y)  ((SUB_X-SUB_Y)+MOD)%MOD
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y)
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
vector<int>adj[MAX];
int du[MAX],dv[MAX],x,y,ans,tot,vis[MAX];
void bfs(int src,int d[])
{
    tot++;
    vis[src] = tot;
    queue <int> q;
    q.push(src);
    while(!q.empty())
    {
        int parent = q.front();
        q.pop();
        for(int i=0;i<adj[parent].size();i++)
        {
            int child = adj[parent][i];
            if(vis[child]!=tot)
            {
                vis[child]=tot;
                d[child]=d[parent]+1;
                q.push(child);
            }
        }
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n>>x>>y;
    for(int i=0; i<n-1; i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    bfs(x,du);
    bfs(y,dv);
    for(int i=1;i<=n;i++){
       // cout<<du[i]<<" "<<dv[i]<<endl;
        if(du[i]<dv[i])
            ans=max(ans,dv[i]);
    }
    cout<<ans-1<<endl;


    return 0;
}


Measured memory_bytes: 31512
#include <iostream>

using namespace std;

int main () {
	int k, a, b;
    cin >> k >> a >> b;
    if (k <= b) {
    	if (b - a >= k) {
        	cout << "OK" << endl;
            return 0;
        }
        if (k >= a) {
        	cout << "OK" << endl;
            return 0;
        }
        for (int i = a; i <= b; i++) {
        	if (i % k == 0) {
        		cout << "OK" << endl;
            	return 0;
            }
        }
    }
    cout << "NG" << endl;
    
	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> B(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        B[i] = A[i];
    }
    sort( A.begin(), A.end() );
    long long a = A[N/2-1];
    long long b = A[N/2];

    for ( int i = 0; i < N; i++ ) {
        if ( a >= B[i] ) { cout << b << endl; }
        else { cout << a << endl; }
    }


    return 0;
}

Measured memory_bytes: 5376
N = int(input())
AB = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: x[1]-x[0])
cur = 0
aki = 0
if sum([a for a, b in AB]) <= max([b for a, b in AB]):
    for a, b in AB:
        if cur <= b-a:
            aki += (b-a)-cur
            cur += (b-a)-cur+a
        else:
            if aki >= a:
                aki -= a
            else:
                a -= aki
                if cur + a > b:
                    print('No')
                    exit()
    print('Yes')
else:
    print('No')


Measured memory_bytes: 102952
#include<stdio.h>
#include<string.h>
typedef struct{int h,r;}P;
int max(int a,int b){return a>b?a:b;}
int main(void)
{
  P t[201]={0},tt;
  int l[201];
  int n,m,i,j,p,res;
  for(;;){
    scanf("%d",&n);if(!n)break;
    for(i=1;i<=n;i++)scanf("%d%d",&t[i].h,&t[i].r);
    scanf("%d",&m);
    for(i=1;i<=m;i++)scanf("%d%d",&t[i+n].h,&t[i+n].r);
    res=l[0]=0;//memset(l,0,sizeof(l));
    for(i=n+m;i>1;i--)
      for(j=1;j<i;j++)
	if(t[j].h>t[j+1].h)tt=t[j],t[j]=t[j+1],t[j+1]=tt;
    for(i=1;i<=n+m;i++){p=0;
      for(j=0;j<=i-1;j++)if(t[j].h<t[i].h&&t[j].r<t[i].r&&l[j]>l[p])p=j;
      l[i]=l[p]+1;res=max(res,l[i]);
    }
    printf("%d\n",res);
  }
  return 0;
}

Measured memory_bytes: 0
n=int(input())
a=[int(i) for i in input().split()]

h=sum(a)/n
ans=0
an=0
k=abs(h-a[0])

for i in range(n):
    if k>abs(h-a[i]):
        k=abs(h-a[i])
        ans=i
        
print(ans)
        

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		int temp;
		int temp2;
		//AとB
		temp = A;
		A = B;
		B = temp;
		
		//AとC
		temp2 = A;
		A = C;
		C = temp2;
		
		System.out.println(A + " " + B + " " + C);
	}

}


Measured memory_bytes: 21972
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanInt64() int64 {
	scanner.Scan()
	a, err := strconv.ParseInt(scanner.Text(), 10, 64)
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := scanInt64()
	a := scanInt64()
	b := scanInt64()
	if n < a+b {
		if n < a {
			fmt.Println(n)
		} else {
			fmt.Println(a)
		}
	} else {
		x := n / (a + b)
		y := n - x*(a+b)
		if y > a {
			fmt.Println(x*a + a)
		} else {
			fmt.Println(x*a + y)
		}
	}
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    int x,y,z;
    cin>>x>>y>>z;
    if(x==5 && y==7 && z==5) cout<<"YES\n";
    else if(x==7 && y==5 && z==5) cout<<"YES\n";
    else if(x==5 && y==5 && z==7) cout<<"YES\n";
    else
        cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 256
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(BigInt,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  a,b,c,k=pM(split(readline()))
  if abs(a-b)>10^18
    println("Unfair")
  elseif k%2==0
    println(a-b)
  else
    println(b-a)
  end
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


Measured memory_bytes: 112896
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        a: usize,
        b: usize,
    }

    let mut cnt = 0;
    for i in a..b+1 {
        let num = i.to_string();
        let mut n1: Vec<char> = Vec::new();
        for j in num.as_str().chars() {
            n1.push(j);            
        }
        n1.reverse();
        let num1: String = n1.iter().collect();
        if num==num1 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2316
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

t = input()
b = input()

if (t[0]==b[2] and t[1]==b[1] and t[2]==b[0]):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 8820
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;
int main() {
	ll N, M;
	cin >> N >> M;
	vector<bool> stairs(N + 1, true);
	for (size_t i = 0; i < M; i++)
	{
		ll ai;
		cin >> ai;
		stairs[ai] = false;
	}

	vector<ll> RES(N + 1);
	RES[0] = 1;
	RES[1] = stairs[1] ? RES[0] : 0;
	RES[2] = stairs[2] ? RES[0] + RES[1] : 0;

	for (ll i = 3; i <= N; i++)
	{
		RES[i] = stairs[i] ? (RES[i - 1] + RES[i - 2]) % MOD : 0;
	}
	cout << RES[N] << endl;
}

Measured memory_bytes: 1024
L = list(map(int, input().split()))
R,O = L[0],L[1]
 
S = O + (R-1)
I = O - (R-1)
 
L = [i for i in range(I,S+1) if i <= 100000 and i >= -100000]
if len(L) == 0:
  print(O[0])

for i in L:
	print(i)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 1000000007;

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

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}


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

  int a,b,c,k;
  cin >> a >> b >> c >> k;
  while(a >= b){
    k--;
    b *= 2;
  }
  while(b >= c){
    k--;
    c *= 2;
  }

  if(k < 0)cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3648
from operator import itemgetter
import sys
def main():
    input = sys.stdin.readline
    n, m = map(int, input().split())
    a_b = [list(map(int, input().split())) for i in range(m)]
    a_b.sort(key=itemgetter(1))
    end = a_b[0][1]-2
    ans = 1 
    for i in range(m):
        if a_b[i][0]-1 > end:
            end = a_b[i][1]-2
            ans += 1
    print(ans)
if __name__ == "__main__":
    main()

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int n;
int pairNum(int i)
{
    int ret;
    if(n%2==0)
    {
        ret = n-i+1;
    }
    else
    {
        ret = n-i;
    }
    return ret;
}

int main(){
    cin>>n;
    vector<int> a,b;
    for(int i = 1; i <= n; i++)
    {
        for(int j = i+1; j <= n; j++)
        {
            if(j!=pairNum(i))
            {
                a.push_back(i);
                b.push_back(j);
            }
        }
    }
    cout<< a.size()<<endl;
    for(int i = 0; i < a.size(); i++)
    {
        cout<<a[i]<<" "<<b[i]<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,ans=0,x=0; cin >> N;
  string S; cin >> S;
  for(int i=0; i<N; i++) {
    if(S[i]=='I') x++;
    else x--;
    ans = max(ans,x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
/* Coached by rainboy */
#include <stdio.h>

#define INF 0x3f3f3f3f
#define N 100
#define M 10

int count(int n) {
	return n == 0 ? 0 : count(n & n - 1) + 1;
}

int main() {
	static int bb[N], pp[N][M + 1];
	int n, i, j, b, ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		b = 0;
		for (j = 0; j < M; j++) {
			int f;

			scanf("%d", &f);
			if (f)
				b |= 1 << j;
		}
		bb[i] = b;
	}
	for (i = 0; i < n; i++)
		for (j = 0; j <= M; j++)
			scanf("%d", &pp[i][j]);
	ans = -INF;
	for (b = 1; b < 1 << M; b++) {
		int sum = 0;

		for (i = 0; i < n; i++)
			sum += pp[i][count(bb[i] & b)];
		if (ans < sum)
			ans = sum;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
N=int(input())
A, B=map(int, input().split())
P=list(map(int, input().split()))

ls_1=[]
ls_2=[]
ls_3=[]

for i in range(N):
	if P[i]<=A:
		ls_1.append(P[i])
	elif A+1<=P[i]<=B:
		ls_2.append(P[i])
	else:
		ls_3.append(P[i])

m=min(min(len(ls_1), len(ls_2)),len(ls_3))
print(m)

Measured memory_bytes: 3064
N = int(input())

jp = float(0)
bi = float(0)

for n in range(0,N):
  inp = input().split()
  x = float(inp[0])
  u = str(inp[1])

  if u == "JPY":
    jp += x
  elif u == "BTC":
    bi += x

print(float(jp + (bi*380000.0)))


Measured memory_bytes: 3060
N,M=map(int,input().split())
alist=list(map(int,input().split()))

border=sum(alist)/(4*M)
cnt=0
for a in alist:
  if a>=border:
    cnt+=1
    
#print(border)
#print(cnt)
if cnt>=M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>

#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int main(){

  long long min=1000000,max=-1000000,sum=0;
  int n=0,m=0,i=0;

  cin >>n;

  for(i=0;i<n;i++){
    cin >>m;
    if(min>m) min=m;
    if(max<m) max=m;
    sum=sum+m;
  }

  cout <<min <<" " <<max <<" " <<sum <<endl;

  return 0;
}

Measured memory_bytes: 1164
n,k,*l=map(int,open(0).read().split())
s=sum(l)
L=[]
for i in range(1,30000):L+=[i,s//i]*(s%i<1)
L.sort()
for d in L[::-1]:
 a=sorted([m%d for m in l])
 if sum(a[:n-sum(a)//d])<=k:print(d);exit()

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

'''

'''

n = int(input())
a = sorted(map(int, input().split()))
largest = a[-1]
#largest = arr[-1]
div = [1] * (largest+1)
count = 0
arr = []
# remove duplicates
for i, v in enumerate(a):
    if i < (n-1) and a[i+1] == v:
        div[v] = 0
    else:
        arr.append(v)

for num in arr:
    if div[num]:
        count += 1

    for d in range(num, largest+1, num):
        div[d] = 0

print(count)
    


Measured memory_bytes: 106416
def main():
    n = int(input())
    a = list(map(int, input().split(' ')))
    c = 0
    flag = 1
    while flag:
        flag = 0
        j = 0
        for i in range(n-1, j, -1):
            if a[i] < a[i-1]:
                a[i], a[i-1] = a[i-1], a[i]
                c += 1
                flag = 1
        j -= 1
    print(' '.join(map(str, a)))
    print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5600
#include<iostream>
using namespace std;
struct UnionFind{
  int parent[100005];
  
  UnionFind(int n){
    for(int i=0;i<=n;i++){
      parent[i]=i;
    }
    return;
  }

  int root(int a){
    if(parent[a]==a){
      return(a);
    }
    return(parent[a]=root(parent[a]));
  }

  void unite(int a,int b){
    a=root(a);
    b=root(b);
    parent[b]=a;
    return;
  }
    
};

int main(){
  int n,m;
  bool check[100005]={false};
  
  cin>>n>>m;
  UnionFind UF(n);  

  for(int i=0;i<m;i++){
    int a,b;
    int x;
    cin>>a>>b;
    cin>>x;
    UF.unite(a,b);
  }
  
  for(int i=1;i<=n;i++){
    check[UF.root(i)]=true;
  }
  
  int cnt=0;
  for(int i=1;i<=n;i++){
    if(check[i]==true){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 768
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>

#define	pb			push_back
#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

typedef	vector<int>	vi;

const double EPS=1e-9;

int main(){
	static bool er[100000]={};	er[0]=er[1]=true;
	rep(i,400) if(!er[i]) for(int j=i*i;j<100000;j+=i) er[j]=true;

	vi pr;
	rep(i,100000) if(!er[i]) pr.pb(i);

	for(int m,a,b;scanf("%d%d%d",&m,&a,&b),m;){
		int popt=2,qopt=2;
		rep(i,pr.size()){
			int p=pr[i];
			if(p*p>m)	continue;
			int q=*(upper_bound(pr.begin()+i,pr.end(),min(b*p/a,m/p))-1);
			if(popt*qopt<p*q)	popt=p,qopt=q;
		}
		printf("%d %d\n",popt,qopt);
	}

	return 0;
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  string s,ans;
  lvector v_(n,0);
  vector<lvector> v(26,v_);
  rep(i,n) {
    cin>>s;
    ll l=s.length();
    rep(j,l) v[s[j]-'a'][i]+=1;
  }
  char c='a';
  rep(i,26) {
    lvector x=v[i];
    ll num=*min_element(x.begin(),x.end());
    rep(j,num) ans+=c;
    c++;
  }
  print(ans);
  return 0;
}

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

int main(){
    int n, min, ans = 0;
    cin >> n;
    min = n + 1;
    vector<int> p(n);
    for(auto&& a: p)
    {
        cin >> a;
    }
    for(auto&& a: p)
    {
        if (a < min)
        {
            ans++;
            min = a;
        }
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
/*#pragma GCC optimize ("O3","unroll-loops")
#pragma GCC target ("avx")*/
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,a,b;

main(){
	cin>>n>>a>>b;
	dump(min(a,b),max(0ll,a+b-n));
}


Measured memory_bytes: 256
n, m = map(int, input().split())
L=[set() for i in range(n)]
for i in range(m):
    a, b =  map(int, input().split())
    L[a-1] |= {b}
    L[b-1] |= {a}
Y = {range(1, n+1)}
Z = [0]*(n-1) 
S = {1}
X = {1}
while len(S) != n:
    X_next = set()
    for j in X:
        R = L[j-1]-S
        S |= R
        X_next |= R
        for k in R:
            Z[k-2] += j
    X = X_next
    continue
else:
    print("Yes")
    print('\n'.join(map(str, Z)))

Measured memory_bytes: 69680
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define ff first
#define ss second
#include "string"

int32_t main(){
	int n,m;
	cin>>n>>m;
	string s;
	cin>>s;
	if(s[0] == '1' or s[n] == '1'){
		cout<<-1<<endl;
		return 0;
	}

	int a[n+1];
	memset(a,-1,sizeof a);
	queue<int>q;
	q.push(0);
	a[0]=0;
	for(int i=1;i<=n;i++){
		while(!q.empty() && i-q.front()>m)
			q.pop();
		if(s[i] == '0' && !q.empty()){
			a[i] = q.front();
			q.push(i);
		}
	}
	if(a[n] == -1){
		cout<<-1<<endl;
		return 0;
	}
	vector<int>ans;
	int cur = n;
	while(cur!=0){
		ans.push_back(cur);
		cur = a[cur];
	}
	ans.push_back(0);
	reverse(ans.begin(),ans.end());
	for(int i=1;i<ans.size();i++)
		cout<<ans[i]-ans[i-1]<<" ";
}

Measured memory_bytes: 1528
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
	int k, a, b;
	cin >> k >> a >> b;
	long long ans = 1;
	if(a < b && k >= (2 / (b - a) + 1) * a - 1){
		ans = (2 / (b - a) + 1) * a;
		k -= (2 / (b - a) + 1) * a - 1;
		if(k % 2 == 1){
			k--; ans++;
		}
	}else{
		ans += k;
		k = 0;
	}
	ans = max(ans + k, ans + (long long)k / 2 * (b - a));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, u32, u64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let (n, m): (u64, u64) = read();

    let mut best = 0;
    for i in 1..m+1 {
        if i * i > m {
            break;
        }
        if m % i == 0 {
            if i >= n {
                best = max(best, m/i);
            }
            if m/i >= n {
                best = max(best, i);
            }
        }
    }
    println!("{}", best);
}


Measured memory_bytes: 4352
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    N,M = sorted(LI())
    if abs(N-M) > 1:
        return 0
    nr = 1
    for i in range(2,N+1):
        nr *= i
        nr %= mod
    if N == M:
        nr = nr * nr
        nr %= mod
        nr *= 2
        nr %= mod
        r = nr
    else:
        mr = nr * M
        mr %= mod
        r = nr * mr
        r %= mod

    return r

print(main())








Measured memory_bytes: 7752
import Data.List (unfoldr)

main :: IO ()
main = do
  n <- read <$> getLine
  bs <- map read . words <$> getLine
  let
    bis = zip bs [1 ..]
    bs' = reverse . unfoldr next $ bis
  if length bs' < n then print (-1) else mapM_ print bs'
  
f :: [(Int, Int)] -> (Maybe Int, [(Int, Int)])
f = foldr step (Nothing, [])
  where
    step (bi, i) (Nothing, xs) | bi == i = (Just bi, map (fmap pred) xs)
    step bi (t, xs) = (t, bi : xs)

next :: [(Int, Int)] -> Maybe (Int, [(Int, Int)])
next xs = case f xs of
  (Nothing, _) -> Nothing
  (Just x, xs') -> Just (x, xs')


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

using namespace std;

int main() {
    long long n,k;
    long double ans;
    ans = 0.0;
    cin >> n >> k;
    for (long long i=1; i<=n; i++) {
        long double tmp = 1.0/n;
        int sum = i;
        while( sum < k ) {
            sum *=2.0;
            tmp /=2.0;
        }
        ans += tmp;
    }
    // cout << ans << endl;
    printf("%.12Lf\n", ans);
}


Measured memory_bytes: 256
require 'prime'
n = gets.chomp
a = gets.chomp.split(" ").map(&:to_i)

h = Hash.new(0)

a.each do |i|
  Prime.prime_division(i).each do |n, e|
    h[n] = e if h[n] < e
  end
end

m = 1
h.each do |n, e|
  m *= (n**e)
end

m -= 1

puts a.map{|i| m % i}.inject(:+)

Measured memory_bytes: 18812
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
    const [N, K] = input.split(' ').map(Number)

    let count = 0;
    let s = 0
    let e = 0
    for (let j = 0; j < K; j++) {
        s += j
    }
    for (let j = N + 1 - K; j <= N; j++) {
        e += j
    }
    count += e - s + 1
    for (let k = K + 1; k <= N +  1; k++) {
        s += (k - 1)
        e += N + 1 - k
        count += e - s + 1
    }
    console.log(count % 1000000007)

})(input)


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

typedef long long int ll;
char str[110];

int main()
{
	ll k;
	scanf("%lld",&k);
	scanf("%s",str);
	if(strlen(str)>k)
	{
		for(ll i=0;i<k;i++)
			printf("%c",str[i]);
		printf("...\n");
	}
	else
	{
		for(ll i=0;i<strlen(str);i++)
			printf("%c",str[i]);
		printf("\n");
	}

}



Measured memory_bytes: 3760
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<unordered_set>
#include<map>
#include<utility>
#include<string>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define int   long long
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define LM LONG_MAX
#define LS LONG_MIN
#define cfM 998244353
#define ccM 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define inf 10000000000000000
#define sp setprecision(9)
int max(int b,int a)
{if(b>a)return b;else return a;}
int min(int b,int a)
{if(b<a)return b;else return a;}
int ab(int b)
{if(b<0) return (-1*b);else return(b);}
void print(vector<int>&v)
{
	for(int i=0;i<v.size();i++)
		cout<<v[i]<<" ";
	cout<<endl;
}
int32_t main()
{
	//CHECK IF NEGATIVE INPUT UNSIGNED->SIGNED
	int n,k;
    cin>>n>>k;
    vector<int> a(n),dp(n,inf);
    for (int i=0; i<n ;i++)
    {
        cin>>a[i];
    }
    if(n<=1)cout<<0<<endl;
    dp[0]=0;
    dp[1]=ab(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        //dp[i]=min(ab(a[i]-a[i-1])+dp[i-1],ab(a[i]-a[i-2])+dp[i-2]);
        //cout<<i<<dp[i]<<endl;
        for(int j=1;j<=k;j++)
        {
        	if(i-j<0)
        		continue;
        	//cout<<dp[i-j]+ab(a[i]-a[j]);
        	dp[i]=min(dp[i],dp[i-j]+ab(a[i]-a[i-j]));
        }

    }
    //print(dp);
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
  int r,c,i,j,ans=0;
  scanf("%d %d",&r,&c);
  int hyo[r+1][c+1];
  for(i=0;i<=r;i++)hyo[i][c]=0;
  for(j=0;j<=c;j++)hyo[r][j]=0;
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      scanf("%d",&hyo[i][j]);
    }
  }
  //yoko
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      hyo[i][c]+=hyo[i][j];
    }
  }
  //tate
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      hyo[r][j]+=hyo[i][j];
    }
  }
  //gokei
  for(i=0;i<r;i++){
    ans+=hyo[i][c];
  }
  //print
  hyo[r][c]=ans;
  for(i=0;i<=r;i++){
    for(j=0;j<=c;j++){
      if(j==c)printf("%d\n",hyo[i][j]);
      else printf("%d ",hyo[i][j]);
    }
  }
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int a, b;
bool judge = true;

int main() {

	cin >> a >> b;

	rep (i, 2000) {
		double tmp1, tmp2;
		tmp1 = i * 0.08;
		tmp2 = i * 0.1;
		int x, y;
		x = tmp1;
		y = tmp2;
		if (x == a && y == b) {
			cout << i << endl;
			judge = false;
			break;
		}
	}

	if (judge)cout << "-1" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, temp, ans = 0;
  vector<int> A;
  
  cin >> N;
  
  vector<int> Afrag(N - 1, 0);
  
  for(int i = 0; i < N; i++){
    cin >> temp;
    A.push_back(temp);
    if(i != 0){
      if(temp == A.at(i - 1) + 1){
      	Afrag.at(temp - 2) = 1;
      }
    }
    
  }
  
  for(int i = 0; i < N; i++){
    cin >> temp;
    ans += temp;
  }
  
  for(int i = 0; i < N - 1; i++){
    cin >> temp;
    if(Afrag.at(i) == 1){
    	ans += temp;
    }
  }
  
  cout << ans << endl;
  
}

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

int comb(int x){
	int a;
	a = x * (x - 1)/2;
  	return a;
}

int main(){
	int m,n;
	cin >> n >> m;
	cout << comb(n) + comb(m)<<endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

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

    int N;
    cin >> N;

    ll c[10][10];
    memset(c, 0, sizeof(c));

    for (int i = 1; i <= N; i++) {
        int digits = 0;
        int i_co = i;
        while (i_co > 0) {
            i_co /= 10;
            ++digits;
        }

        int base = 1;
        for (int i = 0; i < digits - 1; i++) {
            base *= 10;
        }

        int to = i / base;
        int bo = i % 10;

        ++c[to][bo];
    }

    ll ans = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            ans += c[i][j] * c[j][i];
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int n;
  int base[3];
  int out, score;
  
  std::string event;
  std::cin >> n;
  for(int i=0; i<n; i++){
    base[0] = 0;
    base[1] = 0;
    base[2] = 0;
    out = 0;
    score = 0;
    while(out!=3){
      std::cin >> event;
      if(event=="HIT"){
        if(base[2]>=1){
          base[2]--;
          score++;
        }
        if(base[1]>=1){
          base[1]--;
          base[2]++;
        }
        if(base[0]>=1){
          base[0]--;
          base[1]++;
        }
        base[0]++;
      }else if(event=="HOMERUN"){
        score++;
        score += base[2];
        base[2] = 0;
        score += base[1];
        base[1] = 0;
        score += base[0];
        base[0] = 0;
      }else{
        out++; 
      }
    }
    std::cout << score << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 3156
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int k, a, b, i;
	scanf("%d", &k);
	scanf("%d %d", &a, &b);
	
	
	for(i=1; i<=b*k; i++){
		if(i*k>=a && i*k<=b){ printf("OK"); return 0; }
		else if(i*k>b) break;
	}
	
	printf("NG");
	 
	return 0;
}

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

long long com(long long n, int k)
{
	if (n<k)
	{
		return 0LL;
	}
	if (k==1)
	{
		return n;
	}
	else if (k==2)
	{
		return n*(n-1LL)/2LL;
	}
	else if (k==3)
	{
		return n*(n-1LL)*(n-2LL)/6LL;
	}
}

int main(int argc, char const *argv[])
{
	string n;
	int k;
	cin>>n>>k;
	long long ans=0LL;
	if (k==1)
	{
		ans+=(long long)9*(n.size()-1);
		ans+=(long long)n[0]-'0';
	}
	else if (k==2)
	{
		ans+=(long long)9*9*com(n.size()-1,k);
		ans+=(long long)(n[0]-'0'-1)*9*(n.size()-1);
		for (int i = 1; i < n.size(); ++i)
		{
			if (n[i]!='0')
			{
				ans+=(long long)9*(n.size()-i-1);
				ans+=(long long)n[i]-'0';
				break;
			}
		}
	}
	else if (k==3)
	{
		ans+=(long long)9*9*9*com(n.size()-1,k);
		ans+=(long long)(n[0]-'0'-1)*9*9*com(n.size()-1,2);
		for (int i = 1; i < n.size(); ++i)
		{
			if (n[i]!='0')
			{
				ans+=(long long)9*9*com(n.size()-i-1,2);
				ans+=(long long)(n[i]-'0'-1)*9*(n.size()-i-1);
				for (int j = i+1; j < n.size(); ++j)
				{
					if (n[j]!='0')
					{
						ans+=(long long)9*(n.size()-j-1);
						ans+=(long long)n[j]-'0';
						break;
					}
				}
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
package main
 
import (
    "fmt"
)
 
func main() {
  	var a,b int
   	fmt.Scan(&a,&b)
		
		if (a+b)%2 == 0{
			fmt.Println((a+b)/2)
		}else{
			fmt.Println("IMPOSSIBLE")
		}
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

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

int main(void){
    int date;
    cin >> date;
    int f = date/100;
    int s = date%100;
    if((1 <= f && f <= 12) && !(1 <= s && s <= 12)) cout << "MMYY" << endl;
    else if(!(1 <= f && f <= 12) && (1 <= s && s <= 12)) cout << "YYMM" << endl;
    else if((1 <= f && f <= 12) && (1 <= s && s <= 12)) cout << "AMBIGUOUS" << endl;
    else cout << "NA" << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int N;
ll a[2 * 100010];
ll b[2 * 100010];
const ll INF = 1 << 29;

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

    cin >> N;
    ll sum = 0;
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        sum += a[i];
    }
    
    b[0] = a[0];
    for(int i = 1; i < N; ++i){
        b[i] = a[i] + b[i - 1];
    }

    ll ans = abs(b[0] - (sum - b[0]));
    for(int i = 1; i < N - 1; ++i){
        ans = min(ans, abs(b[i] - (sum - b[i])));
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

vector<ll> A, B, C;


int main(void){
    ll N;
    cin >> N;
    A.resize(N); for(auto& i : A) cin >> i;
    B.resize(N); for(auto& i : B) cin >> i;
    C.resize(N); for(auto& i : C) cin >> i;
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    ll ans = 0;
    for(int i=0;i<B.size();i++){
        ll ab = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        ll bc = C.end() - upper_bound(C.begin(), C.end(), B[i]);
        ans += ab * bc;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var strs = str.Split(' ');
            var a = int.Parse(strs[0]);
            var b = int.Parse(strs[1]);
            var k = int.Parse(strs[2]);

            var num = 0;
            for (int i = 100; i >= 1; i--)
            {
                if (a % i == 0 && b % i == 0)
                {
                    num++;

                    if (num == k)
                    {
                        Console.WriteLine(i);
                        return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Slimes
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            Slime slime = new Slime();

            // 結果出力
            Console.WriteLine(slime.Count(N, S).ToString());
        }
    }

    class Slime
    {
        public int Count(int member, string colorlist)
        {
            string beforeMoji = "";
            int slimeCnt = 1;

            for (int cnt = 0; cnt < member; cnt++)
            {
                if (cnt == 0)
                {
                    beforeMoji = colorlist.Substring(cnt, 1);
                    continue;
                }

                if (beforeMoji != colorlist.Substring(cnt, 1))
                {
                    slimeCnt++;
                    beforeMoji = colorlist.Substring(cnt, 1);
                }
            }

            return slimeCnt;
        }
    }
}


Measured memory_bytes: 15164
import qualified Data.List as List

main :: IO ()
main = do
  n <- readLn
  as <- map read . words <$> getLine
  print $ solve n as


solve :: Integer -> [Integer] -> Integer
solve n as =
  if ok as
  then mod (2^(div n 2)) 1000000007
  else 0
  where
    ok as =
      let
        as' = map (\s -> (head s, length s)) . List.group . List.sort $ as
      in
        case head as' of
          (0, 1) ->
            (all (\(_, x) -> x == 2) $ tail as') &&
            [0,2..n-1] == map fst as'
          (0, _) -> False
          _ ->
            (all (\(_, x) -> x == 2) $ tail as') &&
            [1,3..n] == map fst as'


Measured memory_bytes: 31100
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    long double inp; cin >> inp;
    cout << 2.0 * M_PI * inp << endl;
}

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

using namespace std;
int main(){
  int n,x;
  cin >> n;
  long long int k;
  cin >> k;
  
  vector<int> v;
  v.push_back(0);
  for(int i=0;i<n;i++){
    cin >> x;v.push_back(x);
  }
  
  vector<bool> vis(n+1,false);

  int j=1;
  long long int temp = k;
  while(vis[j]==false){
  	temp--;
  	if(temp==0){
  		cout << v[j] << endl;
  		return 0;
  	}
    vis[j] = true;
    j = v[j];
  }

  int xx=1;
  while(xx != j){
  	k--;
  	xx = v[xx];
  }

  int countt=0;
  vector<int> result;
  vector<bool> vis1(n+1,false);
  

  while(vis1[j] == false){
  	result.push_back(j);
  	countt++;
  	vis1[j]=true;
  	j=v[j];
  }

  cout << result[k%countt] << endl;
  return 0;
}

Measured memory_bytes: 4916
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#define RAND(min,max) (rand()%(max-min)+min)
#define DEBUG(void) {printf("\n%d\n",deb);num_debug++;}
char num_debug = 0;

int main(void) {
	srand((unsigned)time(NULL));
	
	char name[20];

	scanf("%s", name);
	for (int i = 0; i < 3; i++)
		printf("%c", name[i]);

	return 0;
}

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

int main() {
    
    int n;
    int p[200010];
    int min = 1000000;
    int ans = 0;
    
    cin >> n;
    rep(i, n) cin >> p[i];
    
    ans = p[0];
    min = p[0];
    rep(i, n){
        //cout << ans << endl;
        if(p[i] < min - 1) ans = ans - (min - p[i] - 1);
        if(p[i] < min) min = p[i];
    }
    
    cout << ans << endl;
    
    return 0;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  
  long long i, N, Ninzu;
  cin >> N;
  map<long long, long long> toukou;
  
  for(i = 0; i < N; i++){
    
    cin >> Ninzu;
    toukou[Ninzu - 1] = i;
  }
  
  for(i = 0; i < N; i++){
    
    cout << toukou[i] + 1 << " "; 
  }
  
  return 0;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
#define N 200005
#define LL long long
#define inf 0x3f3f3f3f3f3f3f3fLL
#define pr pair<int,int>
#define mp(x,y) make_pair(x,y)
using namespace std;

int read(){
	char c=getchar();
	int t=0,f=1;
	while(c>'9'||c<'0') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') t=t*10+c-'0',c=getchar();
	return t*f;
}

int n,m,K,mn=2,tp,l[N],r[N],a[N],b[N];
LL tmp,sum,L[N],R[N],dp[N],st[N],ans=inf;
LL dec(LL x,LL y){return (x-y<0)?(x-y+K):(x-y);}

struct Segment_Tree{
	int mn[N<<2];
	void build(int x,int L,int R){
		mn[x]=n+1;
		if(L==R) return;
		int mid=(L+R)>>1;
		build(x<<1,L,mid),build(x<<1|1,mid+1,R);
	}
	void modify(int x,int L,int R,int l,int r,int v){
		if(v>=mn[x]) return;
		if(L==l&&R==r) return (void)(mn[x]=v);
		int mid=(L+R)>>1;
		if(r<=mid) modify(x<<1,L,mid,l,r,v);
		else if(l>mid) modify(x<<1|1,mid+1,R,l,r,v);
		else modify(x<<1,L,mid,l,mid,v),modify(x<<1|1,mid+1,R,mid+1,r,v);
	}
	int query(int x,int L,int R,int po){
		int mid=(L+R)>>1,ret=mn[x];
		if(L==R) return ret;
		if(po<=mid) ret=min(ret,query(x<<1,L,mid,po));
		else ret=min(ret,query(x<<1|1,mid+1,R,po));
		return ret;
	}
}T;

int main(){
	n=read(),K=read();
	for(int i=1;i<=n;i++){
		a[i]=read(),b[i]=read(),mn=min(mn,b[i]);
		tmp=sum,sum=dec(sum,(a[i]<<1)%K);
		if(b[i]==1){
			if((a[i]<<1)>K){puts("-1");return 0;}
			L[i]=tmp,R[i]=sum;
		}
		else L[i]=0,R[i]=K-1;
		st[++tp]=L[i],st[++tp]=R[i];
	}
	sort(st+1,st+tp+1),m=unique(st+1,st+tp+1)-st-1;
	for(int i=1;i<=n;i++){
		l[i]=lower_bound(st+1,st+m+1,L[i])-st;
		r[i]=lower_bound(st+1,st+m+1,R[i])-st;
	}
	T.build(1,1,m);
	for(int i=n;i;i--){
		int po=T.query(1,1,m,l[i]);
		if(po!=n+1) dp[i]=dp[po]+dec(L[po],L[i]);
		if(l[i]<=r[i]){
			if(r[i]<m) T.modify(1,1,m,r[i]+1,m,i);
			if(l[i]>1) T.modify(1,1,m,1,l[i]-1,i);
		}
		else if(r[i]+1<l[i]) T.modify(1,1,m,r[i]+1,l[i]-1,i);
	}
	for(int i=1;i<=m;i++){
		int po=T.query(1,1,m,i);
		ans=(po==n+1)?0:min(ans,dp[po]+dec(L[po],st[i]));
	}
	for(int i=1;i<=n;i++) ans+=a[i]<<1;
	printf("%lld\n",ans);
}

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

int main() {
  int n,m; cin >> n >> m;
  vector<int64_t> high(n);
  for(int i=0; i<n; i++) cin >> high[i];
  vector<int> ANS(n);
  for(int i=0; i<m; i++) {
    int a,b; cin >> a >> b;
    if(high[a-1] < high[b-1]) ANS[a-1] = 1;
    else if(high[a-1] > high[b-1]) ANS[b-1] = 1;
    else if(high[a-1] == high[b-1]) {
      ANS[a-1] = 1;
      ANS[b-1] = 1;
    }
  }
  int ans=0;
  for(int i : ANS) if(i == 0) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 4564
'use strict';

const receive = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .split(/\s/);

const main = input => {
  const [A, B, ...rest] = input.map(x => Number(x));
  const ans = A <= 8 && B <= 8 ? 'Yay!' : ':(';
  console.log(ans);
};

main(receive);

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  map<string, int> mp;
  mp["SUN"] = 7;
  mp["SAT"] = 1;
  mp["FRI"] = 2;
  mp["THU"] = 3;
  mp["WED"] = 4;
  mp["TUE"] = 5;
  mp["MON"] = 6;


  string s; cin >> s;
  cout << mp[s] << endl;
  
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{
    static int GCM(int n, int m)
    {
        if (Math.Min(n, m) == 0)
            return Math.Max(n, m);
        if (Math.Max(n, m) % Math.Min(n, m) == 0)
            return Math.Min(n, m);
        return GCM(Math.Max(n, m) - Math.Min(n, m), Math.Min(n, m));
    }
    static void Main()
    {
        int[] a;
        int n, k;
        a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        n = a[0];
        k = a[1];
        a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int m = a.Max();
        int gcm = a[0];
        for (int i = 0; i < n; i++)
            gcm = GCM(gcm, a[i]);
        if (k % gcm == 0 && k <= m)
        {
            Console.WriteLine("POSSIBLE");
            Environment.Exit(0);
        }
        Console.WriteLine("IMPOSSIBLE");
    }
}

Measured memory_bytes: 27360