akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<map>
using namespace std;
map<int,int> M;
int max(int a,int b) {return a>b?a:b;}
int main()
{
	int n,x,a=0,b=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&x);
		if(M[x])
		{
			if(x>a&&x>b) {a=b;b=x;}
			else if(x>a) a=x;
			M[x]=0;
		}
		else M[x]=1;
	}
	printf("%lld\n",(long long)a*b);
	return 0;
}

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

int main()
{
	string S;

	cin >> S;

	for (int loop = 0; loop < S.size(); ++loop) {
		for (int loop2 = loop + 1; loop2 < S.size(); ++loop2) {
			if (S.at(loop) == S.at(loop2)) {
				cout << "no" << endl;
				return 0;
			}
		}
	}

	cout << "yes" << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
command, number = deque([]), deque([])

if __name__ == '__main__':
    A = deque([])
    for _ in range(n):
        tmp = input()
        if tmp == 'deleteFirst':
            A.popleft()
        elif tmp == 'deleteLast':
            A.pop()
        else:
            com, num = tmp.split()
            if com == 'insert': 
                A.appendleft(num)
            elif com == 'delete':
                try:
                    A.remove(num)
                except:
                    pass
    print(' '.join(A))


Measured memory_bytes: 69768
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}

	ans := 0
	for i := 0; i < n; i++ {
		if i < n-1 && i+1 == p[i] && i+2 == p[i+1] {
			ans++
			i++
		} else if i+1 == p[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll N = 100005;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

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

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,m;
    cin>>n>>m;
    ll sum=0,A[n];
    rep(i,0,n){
    	cin>>A[i];
    	sum += A[i];
    }
    V v;
    for(ll i=1;i*i<=sum;i++){
    	if(sum%i==0){
    		v.pb(i);
    		v.pb(sum/i);
    	}
    }
    sort(allr(v));
    rep(k,0,v.size()){
    	ll x = v[k];
    	V a;
    	rep(i,0,n){
    		a.pb(A[i]%x);
    	}
    	sort(all(a));
    	ll i=0,j=n-1;
    	ll cnt=0;
    	while(j>i){
    		while(a[i] and j>i){
    			ll b = min(a[i],x-a[j]);
    			a[i] -= b;
    			a[j] += b;
    			cnt += b;
    			if(a[j]==x)	j--;
    		}
    		i++;
    	}
    	if(cnt<=m){
    		cout<<x<<endl;
    		return 0;
    	}
    }
    return 0;
}

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

int main() {
	vector<int> a(5);
	for (int& i : a) {
		cin >> i;
		i = max(40, i);
	}
	cout << accumulate(a.begin(), a.end(), 0) / 5 << endl;
}


Measured memory_bytes: 3084
n = int(input())
a = ["0","1"]
ab = [0] * n
x = [[0] * n for i in range(n)]
y = [[0] * n for i in range(n)]
for i in range(n):
	ab[i] = int(input())
	for j in range(ab[i]):
		x[i][j], y[i][j] = map(int, input().split())
		x[i][j] -= 1

def check(hit):
	for i in range(n):
		if hit[i] == "0":
			continue
		for j in range(ab[i]):
			if y[i][j] == 1 and hit[x[i][j]] == "0":
				return False
			if y[i][j] == 0 and hit[x[i][j]] == "1":
				return False
	return True

ans = []
def dfs(i, s):
	for j in a:
		if len(s) == n:
			#ary.append(s)
			if check(s):
				ans.append(s.count("1"))
			return
		else:
			dfs(i+1,s+j)
dfs(0,"")

print (max(ans))



Measured memory_bytes: 3480
using System;

class Program {
  static void Main(string[] args) {
    int[] a1j, a2j;
    string[] str1, str2;
    int N = int.Parse(Console.ReadLine());
    int res, comp0, comp;
    
    a1j = new int[N];
    a2j = new int[N];

    str1 = Console.ReadLine().Split(' ');
    str2 = Console.ReadLine().Split(' ');

    res = 0;
    for(int i = 0; i < N; ++i) {
      a1j[i] = int.Parse(str1[i]);
      a2j[i] = int.Parse(str2[i]);
      res += a2j[i];
    }

    comp0 = 0;
    for(int i = 1; i < N; ++i) {
      comp0 += a1j[i];
      comp = comp0;
      for(int j = i; j < N; ++j) {
        comp += a2j[j];
      }
      if(res < comp) res = comp;
    }

    Console.WriteLine(res + a1j[0]);
  }
}


Measured memory_bytes: 13140
N = int(input())
H = list(map(int, input().split(' ')))

ret = 0
while True:
    left = -1
    for i, h in enumerate(H):
        if h:
            left = i
            break

    if left == -1:
        break

    right = N
    for i in range(left, N):
        if not H[i]:
            right = i
            break

    v = min(H[left: right])
    ret += v
    for i in range(left, right):
        H[i] -= v


print(ret)


Measured memory_bytes: 38768
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
a = A%10
if a==5 or a==0:
  a = a+0
else:
  a = 10-a
b = B%10
if b==5 or b==0:
  b = b+0
else:
  b = 10-b
c = C%10
if c==5 or c==0:
  c = c+0
else:
  c = 10-c
d = D%10
if d==5 or d==0:
  d = d+0
else:
  d = 10-d
e = E%10
if e==5 or e==0:
  e = e+0
else:
  e = 10-e
remainder = min(a+b+c+d, a+b+c+e, a+b+d+e)
minimalr = min(remainder, a+c+d+e, b+c+d+e)
print(A+B+C+D+E+minimalr)
  

Measured memory_bytes: 9192
#include<stdio.h>
#define N 100
#define INF 100000
  
int main(){
  int i,j,k,l,m[N+1][N+1],n,p[N+1],r;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1], &p[i]);
  }
  
  for(i=1;i<=n;i++){
    m[i][i] = 0;
  }
  
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i+l-1;
      m[i][j] = INF;
      for(k=i;k<j;k++){
    r = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
    if(m[i][j] > r) m[i][j] = r; 
      }
    }
  }
  printf("%d\n",m[i-1][j]);
  return 0;
}

Measured memory_bytes: 636
//18, 08, 2018, 09:05:48 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

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

    scanf("%d", &n);

    int have = 0;
    
    for(int i = 1 ; i <= n ; i+=2){
        int cnt = 0;

        for(int j = 1 ; j <= i ; j++){
            if(i % j == 0){
                cnt++;
            }
        }

        if(cnt == 8){
            have++;
        }
    }

    printf("%d\n", have);

    return 0;
}

Measured memory_bytes: 256
/*  HARD WORK FOREVER PAYS  */
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
typedef pair<int,pair<int,int>> PII;
int main() 
{ 
	turbo();
	int i=0;
	string s;
	cin>>s;
	int j=s.length()-1;
	for(i=0;i<=j;i++){
		if(s[i]=='A'){
			break;
		}
	}
	for(;j>=0;j--){
		if(s[j]=='Z'){
			break;
		}
	}
	cout<<j-i+1<<endl;
    return 0; 
} 

Measured memory_bytes: 720
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int
main()
{
  int N, M;
  cin >> N >> M;
  int A[10000];
  for (int m = 0; m < M; m++)
  {
    cin >> A[m];
  }
  for (int m = 0; m < M && 0 <= N; m++)
  {
    N -= A[m];
  }
  cout << (N < 0 ? -1 : N) << endl;
  return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define INF 1001001001
using namespace std;

int W = 0;
int H = 0;
int people[30][30] = {0};
int table[30][30] = {0};

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

void output() {
  int ans = INF;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ans = min(ans, table[i][j]);
    }
  }
  printf("%d\n", ans);
}

void solve() {
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int total = 0;
      for (int m = 0; m < H; m++) {
        for (int n = 0; n < W; n++) {
          total += people[m][n] * min(abs(i-m), abs(j-n));
        }
      }
      table[i][j] = total;
    }
  }
}

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



Measured memory_bytes: 3216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		int[][] c = new int[3][3];
		for(int i=0; i<3; i++) {
			for(int j=0; j<3; j++) c[i][j] = sc.nextInt();
		}
		for(int a0=-300; a0<=300; a0++) {
			for(int a1=-300; a1<=300; a1++) {
				for(int a2=-300; a2<=300; a2++) {
					if(c[0][0]-a0==c[1][0]-a1&&c[1][0]-a1==c[2][0]-a2) {
						if(c[0][1]-a0==c[1][1]-a1&&c[1][1]-a1==c[2][1]-a2) {
							if(c[0][2]-a0==c[1][2]-a1&&c[1][2]-a1==c[2][2]-a2) {
								System.out.println("Yes");
								return;
							}
						}
					}
				}
			}
		}
		System.out.println("No");
 	}
	
	static void printArray(int[] a) {
		int n=a.length;
		for(int i=0; i<n; i++) {
			if(i==0) System.out.print(a[i]);
			else System.out.print(" "+a[i]);
		}
		System.out.println();
	}

	static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public MyScanner(InputStream s) 
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 23124
from itertools import accumulate
N, C = map(int, input().split())
G = [[0] * (10 ** 5 + 1) for i in range(C)]
for i in range(N):
    s, t, c = map(int, input().split())
    c = c - 1
    G[c][s - 1] += 1
    G[c][t] -= 1

for i in range(C):
    G[i] = list(accumulate(G[i]))

ans = 0
for i in range(10 ** 5 + 1):
    tmp = 0
    for c in range(C):
        tmp += min(1, G[c][i])
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 120664
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  long N;
  cin >> N;

  long ans = N;
  for(long i = 1, l = sqrt(N); i <= l; ++i) {
    if(N % i == 0) {
      ans = min(ans, i + (N / i) - 2);
    }
  }

  cout << ans;

  return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{

	ll N, M;
	cin >> N >> M;
	vec(A); vec(B);
	
	fx(N) {
		vecp(A);
	}
	fx(M) {
		vecp(B)
	}

	ll sumA = 0, sumB = 0;
	fx(N) {
		sumA += (x -(N-1-x)) * A[x];
		if (sumA<0) {
			sumA += -sumA / MOD * MOD + MOD;
		}
		sumA %= MOD;
	}
	fx(M) {
		sumB += (x - (M - 1-x)) * B[x];
		if (sumB < 0) {
			sumB += -sumB / MOD * MOD + MOD;
		}
		sumB %= MOD;
	}
	ce((sumA*sumB)%MOD)
    return 0;
}



Measured memory_bytes: 4320
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#define mod (int)(1e9 + 7)
#define pb push_back
#define ll long long int
using namespace std;
typedef pair<int,int> pii;

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(auto &x : a) cin>>x;
  sort(a.begin(),a.end());

  double m=a[n-1]/2.0;

  int t=0;
  for(auto x: a) if(fabs(m-(double)t) > fabs(m-(double)x)) t=x;
  cout<<a[n-1]<<" "<<(int)t<<endl;
  return 0;
}


Measured memory_bytes: 640
use std::io::stdin;
use std::str::FromStr;

fn main(){
    let n: usize = get_one();
    let mut xs: Vec<u64> = get_vec();
    let ys: Vec<u64> = get_vec();
    let mut zs: Vec<u64> = get_vec();

    xs.sort();
    zs.sort();

    let mut ans = 0;

    for y in ys.iter() {
        let x_ub = upper_bound(&xs, &|x| x < y);
        let z_lb = lower_bound(&zs, &|z| y < z);
        if let (Some(i), Some(j)) = (x_ub, z_lb) {
            ans += (i+1) as i64 * (n as i64 - j as i64);
        }
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

fn upper_bound<T, F>(v: &Vec<T>, f: &F) -> Option<usize>
    where F: Fn(&T) -> bool {
    if v.first().map(f) != Some(true) {
        return None;
    }

    let last_idx = (v.len() as i64 -1) as usize;
    if f(&v[last_idx]) {
        return Some(last_idx);
    }

    return Some(upper_bound(v, f, 0, last_idx));

    fn upper_bound<T, F>(v: &Vec<T>, f: &F, left: usize, right: usize) -> usize 
        where F: Fn(&T) -> bool {
        if left+1 == right {
            return left;
        }
        let m = (left + right) / 2;
        if f(&v[m]) {
            return upper_bound(v, f, m, right);
        } else {
            return upper_bound(v, f, left, m);
        }
    }
}

fn lower_bound<T, F>(v: &Vec<T>, f: &F) -> Option<usize>
    where F: Fn(&T) -> bool {
    if v.last().map(f) != Some(true) {
        return None;
    }

    if let Some(i) = upper_bound(v, &|x| !f(x)) {
        return Some(i + 1);
    } else {
        return Some(0);
    }
}


Measured memory_bytes: 13296
def main():
    N, Q = [int(i) for i in input().split()]
    V = [set() for _ in range(N)]
    for _ in range(N - 1):
        a, b = [int(i) - 1 for i in input().split()]
        V[a].add(b)
        V[b].add(a)
    C = [0] * N
    for _ in range(Q):
        p, x = [int(i) for i in input().split()]
        C[p - 1] += x
    cur = [(0, 0)]
    while cur:
        n, x = cur.pop()
        C[n] = x = C[n] + x
        for c in V[n]:
            V[c].remove(n)
            cur.append((c, x))
    print(' '.join(str(c) for c in C))

main()


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

using namespace std;

const int MAXN = 2001;
int h, w, ans;
char cells[MAXN][MAXN];
int row[MAXN][MAXN],col[MAXN][MAXN];
bool visit[MAXN][MAXN];

int dfs(int y,int x,bool chk,int cnt) {
	if (y < 0 || y >= h || x < 0 || x >= w || visit[y][x]) return cnt;
	if (cells[y][x] == '#') return cnt;

	visit[y][x] = true;

	if (chk) {
		col[y][x] = dfs(y + 1, x, chk, cnt + 1);
		return col[y][x];
	}
	else {
		row[y][x] = dfs(y, x + 1, chk, cnt + 1);
		return row[y][x];
	
	}
}

int main() {

	cin >> h >> w;

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

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (visit[i][j]) continue;
			dfs(i, j, false, 0);
		}
	}

	memset(visit, false, sizeof(visit));

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (visit[i][j]) continue;
			dfs(i, j, true, 0);
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			ans = max(ans, row[i][j] + col[i][j]);
		}
	}

	cout << ans-1 << "\n";

	return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, K;

    cin >> N >> K;

    vector<ll> a(N+1);
    a[0] = 0;
    for(ll i = 1; i < N+1; i++){
        a[i] = a[i-1]+i;
    }

    ll total = 0;
    for(ll i = K; i <= N+1; i++ ){
        ll min = a[i-1];
        ll max = 0;
        if( N-i < 0 ) {
           max = a[N];
        }else{
           max = a[N] - a[N-i];
        }
        //DEBUG("max:%lld, min:%lld, max-min:%lld", max, min, max-min);
        total = (total + (max-min+1))%MOD;
    }

    cout << total << endl;
}


Measured memory_bytes: 4840
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
int za[1001][1001];
using namespace std;
int main(void)
{
	int i,j,d[1001],c[1001],n,m,hirodo,min;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++) scanf("%d",&d[i]);
	for(i=0;i<m;i++) scanf("%d",&c[i]);
	for(i=0;i<=m;i++) {
		for(j=0;j<=n;j++) {
			za[i][j]=2100000000;
		}
	}
	za[0][0]=0;
	for(i=0;i<m;i++) {
		for(j=0;j<=n;j++) {
			if(za[i][j]<za[i+1][j]) za[i+1][j]=za[i][j];
			hirodo=c[i]*d[j];
			if(za[i][j]+hirodo<za[i+1][j+1] && j<=n) za[i+1][j+1]=za[i][j]+hirodo;
		}
	}
	/*for(i=0;i<=m;i++) {
		for(j=0;j<=n;j++) {
			printf("%d          ",za[i][j]);
		}
		printf("\n");
	}*/
	min=2100000000;
	for(i=0;i<=m;i++) if(min>za[i][n]) min=za[i][n];
	printf("%d\n",min);
	return 0;
}

Measured memory_bytes: 4940
g k n s = if n==k then head s else g k (n+1) (tail s) 
f (x:s) c =(if x==c then x else '*'):(if null s then [] else f s c)
main=do
 n<-getLine
 s<-getLine
 k<-readLn
 putStrLn$ f s (g k 1 s)

Measured memory_bytes: 508
#include<stdio.h>
#include<string.h>
int main(void){
	char ball1[100];
	char ball2[100];
	scanf("%s %s",ball1,ball2);
	int num1,num2;
	scanf("%d %d",&num1,&num2);
	char target[100];
	scanf("%s",target);
	if(strcmp(target,ball1)==0){
		num1--;
	}else{
		num2--;
	}
	printf("%d %d\n",num1,num2);
	return 0;
}


Measured memory_bytes: 128
from collections import deque
A = deque(map(str, input()))
B = deque(map(str, input()))
C = deque(map(str, input()))
x = A.popleft()
for _ in range(10000000):
    if x == "a":
        if A:
            x = A.popleft()
        else:
            print("A")
            break
    elif x == "b":
        if B:
            x = B.popleft()
        else:
            print("B")
            break
    else:
        if C:
            x = C.popleft()
        else:
            print("C")
            break

Measured memory_bytes: 9260
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int>a(n);
    int ans=0;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
        if(a[i]%2==1 && i%2==0) ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}

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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    double r;
    cin >> r;
    print(r * 2.0 * M_PI);
    return 0;
}

Measured memory_bytes: 3784
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=105;
const int maxv=1e3+5;

int n,m,sum,ans;
int w[maxn],v[maxn];
int dp[maxn][maxv*maxn];

int main(){
	scanf("%d%d",&n,&m);
	REP(i,1,n) scanf("%d%d",w+i,v+i),sum+=v[i];
	REP(i,0,n) REP(j,0,sum) dp[i][j]=INF;
	dp[0][0]=0;
	REP(i,1,n){
		REP(j,0,sum){
			dp[i][j]=dp[i-1][j];
			if(j>=v[i]) dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
			if(i==n&&dp[i][j]<=m) ans=max(ans,j);
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )

using namespace std;

const int inf = (int)1e9 + 7;
const int N = (int)3e5 + 7;

int n;
int x;
vector <int> v;

main () {
      cin >> n;

      for (int i = 1; i <= n; i ++) {
            cin >> x;
            v.pb(x);
      }
      sort (v.begin(),v.end());

      for (int i = v.size() - 1; i >= 0; i --) {
            int x = (v[i] + 1) / 2;
            int pos = lower_bound(v.begin(),v.end(),x) - v.begin();
            if (pos != 0) {
                  if (v[pos - 1] == 0 || v[pos] == v[i])
                        continue;
                  if (x - v[pos - 1] > v[pos] - x) {
                        cout << v[i] << " " << v[pos] << endl;
                        return 0;
                  }
                  else {
                        cout << v[i] << " " << v[pos - 1] << endl;
                        return 0;
                  }
            }
            else {
                  if (v[pos] == 0 || v[pos] == v[i])
                        continue;
                  cout << v[i] << " " << v[pos] << endl;
                  return 0;
            }
      }
      cout << v[1] << " " << v[0] << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define REP(name, stop) for (ll(name) = 0; (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

constexpr ll N_MAX = 10;
vi A(N_MAX);
constexpr ll Q_MAX = 50;
ll query[Q_MAX][4] = {0};

ll countScore(ll Q) {
    ll score = 0;
    REP(i, Q) {
        ll a_idx = query[i][0];
        ll b_idx = query[i][1];
        ll diff = A[b_idx] - A[a_idx];
        if (diff == query[i][2])
            score += query[i][3];
    }
    return score;
}

ll dfs(ll idx, ll value, ll N, ll M, ll Q) {
    if (idx == N) {
        return countScore(Q);
    }
    ll sc = 0;
    for (ll v = value; v <= M; v++) {
        A[idx] = v;
        sc = max(dfs(idx + 1, v, N, M, Q), sc);
    }
    return sc;
}

int main(void) {
    ll N, M, Q;
    cin >> N >> M >> Q;
    REP(i, Q) {
        cin >> query[i][0] >> query[i][1] >> query[i][2] >> query[i][3];
        query[i][0]--;
        query[i][1]--;
    }
    cout << dfs(0, 1, N, M, Q) << endl;

    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h> 
using namespace std;
typedef long long LL;
LL a[255],ans;
char s[205050];
int main(){
	scanf("%s",s);
	ans = 0;
	for (LL i=0;s[i];i++) {
		ans+=i-a[s[i]];
		a[s[i]]++;
	}
	printf("%lld\n",ans+1);
}
/*
4
aatt
taat
ttaa
atat
atta

a,a,t,t,aa,tt
6
(1+4) * 4 / 2 = 10
10 - 6 = 4



a,b,r,a,c,a,d,a,b,r,a

*/

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  int N = s.size();
  if(s[0] == s.back()) N -= 2;
  else N--;

  if(!(N%2)) cout << "First" << "\n";
  else cout << "Second" << "\n";

  return 0;
}

Measured memory_bytes: 512
s = int(input())

def func(n):
  if n % 2==0:
    return n//2
  else:
    return 3*n+1

a =[]

a.append(s)
while(True):
  am=func(a[-1])
  if am in a:
    print(len(a)+1)
    break
  else:
    a.append(am)
  

Measured memory_bytes: 2940
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	int i,j,n;
	long long a[100010],t1,t2;
	while(~scanf("%d",&n))
	{
		t1=-1;t2=-1;
		for(i=0;i<n;i++)
		{
			scanf("%lld",&a[i]);
		}
		sort(a,a+i);
		for(i=n-2;i>=0;i--)
		{
			if(a[i]==a[i+1]&&t2==-1)
			{
				t2=a[i];
				i--;
			}
			else if(a[i]==a[i+1]&&t1==-1)
			{
				t1=a[i];
				i--;
			}
			else if(t1!=-1&&t2!=-1)
			break;
		}
		//printf("%d %d\n",t1,t2);
		if(t1==-1||t2==-1)
		printf("0\n");
		else printf("%lld\n",t1*t2);
	}
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
    long k, a, b;
    cin >> k >> a >> b;

    long bsk = 1;
    long yen = 0;

    if(b - a <= 2 || k == 1){
        cout << k + 1 << endl;
    }else{
        for(long i = 0; i < k; i++)
        {
            if(yen > 0) {
                yen--;
                bsk += b;
            }else if(bsk >= a && k - i != 1){
                bsk -= a;
                yen++;
            }else{
                bsk++;
            }
        }  
        cout << bsk << endl;
    }
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    string a,b;
    int siza,sizb,i,j;
    int l[3005][3005];
    char sym[3005][3005];
void ok()
{
    siza=a.size();
    sizb=b.size();
    for(i=0;i<siza;i++)
        {
            l[0][i]=0;
            sym[0][i]='e';
        }
    for(i=1;i<sizb;i++)
        {
            l[i][0]=0;
            sym[i][0]='e';
        }
    //0anbh siz 5 <siz 1->4
    for(i=1;i<sizb;i++)
    {
        for(j=1;j<siza;j++)
        {
            if(b[i]==a[j])
            {
                sym[i][j]='(';
                l[i][j]=l[i-1][j-1]+1;
            }
            else if(l[i-1][j]>=l[i][j-1])
            {
                l[i][j]=l[i-1][j];
                sym[i][j]='|';
            }
            else {
                 l[i][j]=l[i][j-1];
                sym[i][j]='-';
            }
        }
    }



    string res="0";
    int k=0,init=siza-1;
    for(i=sizb-1;i>0;i--)
    {
        for(j=init;j>0;j--)
        {
            if(sym[i][j]=='('){
                res=res+a[j];
                init=j-1;
                break;
            }
            else if(sym[i][j]=='|')
            {
                init=j;
                break;
            }
            else init=siza-1;
        }
    }
    int siz=res.size();
    for(i=siz-1;i>0;i--)
        cout<<res[i];
    cout<<endl;


}
int main()
{
//    while(1)
//    {


    cin>>a>>b;
    a="0"+a;
    b="0"+b;
    ok();
//    }
    return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)
#define ALL(v) (v).begin(), (v).end()

int n;
int r[125];
int s[125],p[125],c[125];

bool check(int x,int y,int z){
  vi score(n,0);
  {
    vector<pii> yo(n);
    yo[0] = pii(x,0);
    FOR(i,1,n)yo[i] = pii(s[i],i);
    sort(ALL(yo));
    reverse(ALL(yo));
    int cur = 0;
    REP(i,n){
      if(i>0 && yo[i].first != yo[i-1].first)cur = i;
      score[yo[i].second] += r[cur];
    }
  }
  {
    vector<pii> yo(n);
    yo[0] = pii(y,0);
    FOR(i,1,n)yo[i] = pii(p[i],i);
    sort(ALL(yo));
    reverse(ALL(yo));
    int cur = 0;
    REP(i,n){
      if(i>0 && yo[i].first != yo[i-1].first)cur = i;
      score[yo[i].second] += r[cur];
    }
  }
  {
    vector<pii> yo(n);
    yo[0] = pii(z,0);
    FOR(i,1,n)yo[i] = pii(c[i],i);
    sort(ALL(yo));
    reverse(ALL(yo));
    int cur = 0;
    REP(i,n){
      if(i>0 && yo[i].first != yo[i-1].first)cur = i;
      score[yo[i].second] += r[cur];
    }
  }
  vector<pii> yo(n);
  REP(i,n)yo[i]  = pii(score[i],i);
  sort(ALL(yo));
  reverse(ALL(yo));
  REP(i,8)if(yo[i].second==0)return true;
  if(score[yo[7].second]==score[0])return true;
  return false;
}

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",r+i);
  REP(i,n)scanf("%d%d%d",s+i,p+i,c+i);
  int ans = 1e9;
  FOR(x,1,101){
    if(check(s[0]+x,p[0],c[0]))ans=min(ans,x);
  }
  FOR(x,1,101){
    if(check(s[0],p[0]+x,c[0]))ans=min(ans,x);
  }
  FOR(x,1,101){
    if(check(s[0],p[0],c[0]+x))ans=min(ans,x);
  }
  if(ans == 1e9){
    puts("Saiko");
  }else{
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3240
from itertools import combinations
import numpy as np

n,m,x = map(int, input().split())
q = [np.array(list(map(int, input().split()))) for _ in range(n)]
L=[]
for i in range(1,n+1):
    for j in list(combinations(q,i)):
        S = np.sum(j, axis=0)
        if all([k >= x for k in S[1:]]):
            L.append(S[0])

if len(L) >0:
    print(min(L))
else:
    print(-1)


Measured memory_bytes: 27536
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int P = 1e9+7;
LL f[1000001], v[1000001];
LL rp(LL now, int k)
{
    LL will = 1;
    for (; k; k >>= 1, now *= now, now %= P)
    {
        if (k & 1) will *= now, will %= P;
    }
    return will;
}
LL C(int n, int m)
{
    if(n < m) return 0;
    return f[n] * rp(f[m], P - 2) % P * rp(f[n - m], P - 2) % P;
}
void init()
{
    f[0] = 1; v[0] = 1;
    for (int i = 1; i <= 1000000; i++) //1e6以内的组合数
    {
        f[i] = f[i - 1] * i % P;
    }
}
int main(){
	int x,y;
	scanf("%d%d",&x,&y);
	init();
	if((x+y)%3){puts("0");return 0;}
    int s=(x+y)/3;
    x-=s;
    //printf("x=%d s=%d\n",x,s);
    printf("%lld\n",C(s,x));
	return 0;
}


Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
int main()
{
int i,n,m,cnt=0,ans=0;
cin>>n;
int a[n];
for(i=0;i<n;i++)
    cin>>a[i];
for(i=1;i<n;i++)
{
    if(a[i]<=a[i-1])
        cnt++;
    else
    {
        ans=max(ans,cnt);
        cnt=0;
    }
}
ans=max(ans,cnt);

cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int A[n], B[n];
    int k = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> A[i] >> B[i];
    }
    for(int j = 0; j < n; j++)
    {
        if(A[k] < A[j])
        {
            k = j;
        }
    }
    cout << A[k] + B[k] << endl;



}

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

using namespace std;

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

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

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}

const int N = 600, K = 600, OO = 0x3f3f3f3f;

ll power(ll b, ll p){
    if(p == 0)return 1;
    ll res = power(b,p/2);
    res *= res;
    //res %= modulo;
    if(p & 1)res *= b;
    return res;// % modulo;
}

int main(){
    init();

    int n;  cin >> n;
    ll arr[n];
    for(int i = 0;i < n - 1;i++){
        ll x;  cin >> x;
        if(!i){
            arr[i] = arr[i + 1] = x;
            continue;
        }

        if(arr[i] > x)arr[i] = x;
        arr[i + 1] = x;
    }

    cout << accumulate(arr, arr + n,0ll);
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int N, M;
    vector<int> A;
    cin >> N >> M;
    A.resize(N);

    int sum = 0;
    REP(i, N){
        cin >> A[i];
        sum += A[i];
    }
    SORT(A);
    reverse(A.begin(), A.end());

    REP(i, M) {
        if(A[i] * 4 * M < sum) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register ll
#define maxn 200005
#define mod 1000000003
#define inf 1000000007
namespace lib
{
	using namespace std;
	
	
	class fastio
	{
		private:
			#define _NUMLEN 111
			char _num[_NUMLEN],_ch;
			int _f,_head;
			bool _useSTD;
		public:
			inline void ioSTD()
			{
				_useSTD=1;
				ios::sync_with_stdio(false);
				cin.tie(0),cout.tie(0);
			}
			inline void gc(char & _c)
			{
				if(_useSTD)cin>>_c;
				else _c=getchar();
			}
			inline void pc(char _c)
			{
				if(_useSTD)cout<<_c;
				else putchar(_c);
			}
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_x=0;
					while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch);
					while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch);
					_f&&(_x=-_x,_f=0);
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_T _k;
					if(_x==0) {pc('0'),pc(' ');return *this;}
					if(_x<0) pc('-'),_x=-_x;
					while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
					while(_head>0) pc(_num[_head]),--_head;
					pc(' ');
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator >> (_T & _x) {cin>>_x;return *this;}
			template<typename _T> inline fastio & operator << (_T _x) {cout<<_x;return *this;}
			#define endln pc('\n')
		fastio() {_f=0,_head=0,_useSTD=0,_ch=' ';}
	}io;
	
	
	inline void fileio(string _r,string _w)
	{
		if(_r[0]!='-')freopen(_r.c_str(),"r",stdin);
		if(_w[0]!='-')freopen(_w.c_str(),"w",stdout);
	}
}using namespace lib;

signed main()
{
//	fileio("tt.in","tt.out");
//	io.ioSTD();
	int n,a,now=0;
	io-n;
	for(rgi i=1;i<=n;++i)
	{
		io-a;
		if(a==now+1)++now;
	}
	if(now)io+(n-now);
	else io+(-1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int a, b;
    cin >> a >> b;
    if (a * b % 2 == 0) OUT("Even")
    else OUT("Odd")

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<sstream>
#include<string.h>
using namespace std;
int z[100005];
void Qsort(int arr[], int low, int high) {
    if (high <= low) return;
    int i = low;
    int j = high + 1;
    int key = arr[low];
    while (true)
    {
        while (arr[++i] < key)
            if (i == high)
                break;
        while (arr[--j] > key)
            if (j == low)
                break;
        if (i >= j) break;
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
    int temp = arr[low];
    arr[low] = arr[j];
    arr[j] = temp;
    Qsort(arr, low, j - 1);
    Qsort(arr, j + 1, high);
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int n, i, j;
    while (cin >> n)
    {
        for (i = 1;i <= n;i++)
            cin >> z[i];
        Qsort(z, 1, n);
        n /= 2;
        if (z[n] == z[n + 1])
            cout << 0 << '\n';
        else cout << (z[n + 1] - z[n]) << '\n';
    }
}

Measured memory_bytes: 640
n = int(raw_input())
R = list()
max = -10000000000
min =  10000000000

for i in range(n):
    R.append(int(raw_input()))

    if max < R[i] - min:
        max = R[i] - min

    if min > R[i]:
        min = R[i]
print max
    
    

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};



int main(){

  int n,b;
  cin >> n >> b;
  if(n > 12){
    cout << b << endl;
  }else if(n > 5){
    cout << b/2 << endl;
  }else{
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>    
#include <vector>       
#include <set>
#include <utility>  
#include <cstring>
#include <stdio.h>
#include <limits.h>
#include <queue>
#include <algorithm> 
#define MAX_DOUBLE  40000000000.0 
#include <math.h> 
#include <unistd.h>

using namespace std;

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

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


double res[301][301][301];

int main(){
	
	for(int i = 0; i<=300; i++){
		for(int j = 0; j<=300; j++){
			for(int k = 0; k<=300; k++){
//				cout<<i<<" "<<j<<" "<<k<<endl;
				double sum = i + j + k;
								
				if(i == 0 && j == 0 && k == 1){
					res[i][j][k] = 1;
					continue;
				}				
								
				if(i > 0){
					res[i][j][k] += double(i)/sum*res[i-1][j+1][k];
				}
				
				if(j > 0){
					res[i][j][k] += double(j)/sum*res[i][j-1][k+1];
				}
				
				if(k > 0){
					res[i][j][k] += double(k)/sum*res[i][j][k-1]*sum/(sum-1);
				}
				
				res[i][j][k] +=1;
			}
		}
	}
	
	int n;
	cin>>n;
	
	int a = 0;
	int b = 0;
	int c = 0;
	
	for(int i = 0; i<n; i++){
		int t;
		cin>>t;
		if(t==1) a++;
		if(t==2) b++;
		if(t==3) c++;
	}
	
	cout.precision(17);
	cout<<res[c][b][a];
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

template<class T>
T read() {
    T x{};
    cin >> x;
    return x;
}

template<class T>
vector<T> read(int N){
    vector<T> x(N);
    for(int i = 0; i < N; ++i){
        cin >> x[i];
    }
    return x;
}

template<class T>
void write(const T &x){ cout << x << endl; }

void write(double x) { printf("%.15f\n", x); }

int main(){
    auto N = read<ll>();
    auto K = read<ll>();
    auto A = read<ll>(N);
    auto F = read<ll>(N);
    
    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<>());
    
    ll ans_max = 1e13;
    ll ans_min = 0;
    
    auto can_eat = [&](auto ans){
        auto Ktmp = K;
        for(ll i = 0; i < N; ++i){
            auto Kuse = max(0LL, (ll)ceil(A[i] - (double)ans / F[i]));
            if(Ktmp < Kuse) return false;
            Ktmp -= Kuse;
        }
        return true;
    };
    
    while(ans_min  < ans_max){
        ll ans = (ans_min + ans_max) / 2;
        auto eatable = can_eat(ans);
        if(eatable){
            ans_max = ans;
        }else{
            ans_min = ans + 1;
        }
    }
    write(ans_max);
    
}



Measured memory_bytes: 3328
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
#define rep(x, n) for (int x = 1; x <= n; ++x)
#define zrp(x, n) for (int x = n; x > 0; --x)
#define FOR(x, l, r) for (char x = l; x <= r; ++x)
char s[400];
int cnt[400], tot[400];
int n;

int main()
{
	for (char i = 'a'; i <= 'z'; ++i)
		tot[i] = 500;
	scanf("%d", &n);
	rep(i, n)
	{
		scanf("%s", s + 1);
		int l = strlen(s + 1);
		FOR(j, 'a', 'z') cnt[j] = 0;
		rep(k, l) cnt[s[k]]++;
		FOR(j, 'a', 'z') tot[j] = min(tot[j], cnt[j]);
	}
	
	FOR(j, 'a', 'z') rep(i, tot[j])
		printf("%c", j);
	puts("");
	return 0;
}


Measured memory_bytes: 256
N = int(input())
s = list(map(str, input().split()))
type = 0
flag = {'P':0,'W':0,'G':0,'Y':0}
for i in range(N):
	if(flag[s[i]] == 0):
		flag[s[i]]+=1
		type+=1
if(type==3):
	print("Three")
else:
	print("Four")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

vector<int> graph[100000];
enum color_e{
  NONE,
  BLACK,
  WHITE
};

color_e C[100000];

int main(){
  int N;
  cin >> N;
  for(int i=0;i<N-1;++i){
    int a,b;
    cin >> a >> b;
    graph[a-1].push_back(b-1);
    graph[b-1].push_back(a-1);
  }
  C[0] = BLACK;
  C[N-1] = WHITE;

  queue<int> qb,qw;
  qb.push(0);
  qw.push(N-1);

  while((!qb.empty())||(!qw.empty())){
    int qbnum = qb.size();
    int i=0;
    while(!qb.empty()&&i<qbnum){
      auto ub = qb.front();qb.pop();

      for(auto vb:graph[ub]){
        if(C[vb]==NONE){
          qb.push(vb);
          C[vb] = BLACK;
        }
      }
      ++i;
    }

    int qwnum = qw.size();
    i = 0;
    while(!qw.empty()&&i<qwnum){
      auto uw = qw.front();qw.pop();

      for(auto vw:graph[uw]){
        if(C[vw]==NONE){
          qw.push(vw);
          C[vw] = WHITE;
        }
      }
      ++i;
    }
  }
  
  int black_num = 0;
  int white_num = 0;
  for(int i=0;i<N;++i){
    if(C[i] == BLACK) black_num++;
    else if(C[i] == WHITE) white_num++;
  }
  
  // cout << black_num << " " << white_num << endl;
  if(black_num>white_num){
    cout << "Fennec" << endl;
  }else{
    cout << "Snuke" << endl;
  }
  return 0;
}




Measured memory_bytes: 6272
using System;

namespace abc167_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            if(s == t.Substring(0, s.Length))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 25852
#include <iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d)
	{
		cout<<"Left"<<endl;
	}
	else if(a+b<c+d)
	{
		cout<<"Right"<<endl;
	}
	else
	{
		cout<<"Balanced"<<endl;
	}
	return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 500000;
using namespace std;

int main(void){
  bool used[100];
  int n, G[100][100], p[100];
  cin >> n;
  for(int i=0; i < 100; i++){
    used[i] = false;
    for(int j=0; j < 100; j++){
      G[i][j] = INF;
    }
  }
  for(int i=0; i < n; i++){
    int vtmp, k;cin >> vtmp >> k;
    for(int j=0; j < k; j++){
      int v, c; cin >> v >> c;
      G[vtmp][v] = c;   
    }
  }

  int d[100];
  for(int i=0; i < n; i++){
    d[i] = INF;
  }
  d[0] = 0;

  while(1){
    int mind = INF;
    int minind = -1;
    for(int j=0; j < n; j++){
      if(used[j] == false && d[j] < mind){
        mind = d[j]; minind = j;
      }
    }
    if(minind == -1) break;
    used[minind] = true;
    for(int j=0; j < n; j++){
      if(used[j] == false && G[minind][j] != INF){
        if(d[minind] + G[minind][j] < d[j]){
          d[j] = d[minind] + G[minind][j];
          p[j] = minind;
        }
      }
    }
  }
  for(int i=0; i < n; i++){
    cout << i << " " << d[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1200
n=gets.to_i
ab=(1..n).map{gets.split.map(&:to_i)}.group_by{|x|x.last}
t=0
ab.keys.sort.each{|i| 
  d=ab[i].inject(0){|s,j|s+j[0]}
  puts "No" or exit if d>i-t
  t+=d
  }
puts "Yes"

Measured memory_bytes: 45020