akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <queue>

using namespace std;

//long long
struct node {
	long long v , f , c;
	node *next , *rev;
} pool[1200000*3] , *g[12000] , *from[12000];
long long top;
long long n;
long long rx[1200] , ry[1200] , rc[1200];
long long bx[1200] , by[1200] , bc[1200];
long long dis[12000] , vis[12000];
long long s , t;
void add ( long long u , long long v , long long f , long long c ) {
	node *tmp1 = &pool[++top] , *tmp2 = &pool[++top];
	//9printf ( "%lld %lld %lld %lld\n" , u , v , f , c );
	tmp1 -> v = v; tmp1 -> f = f; tmp1 -> c = c; tmp1 -> next = g[u]; g[u] = tmp1; tmp1 -> rev = tmp2;
	tmp2 -> v = u; tmp2 -> f = 0; tmp2 -> c = -c; tmp2 -> next = g[v]; g[v] = tmp2; tmp2 -> rev = tmp1;
}
bool spfa () {
	long long i , k;
	queue < long long > q;
	for ( i = 1 ; i <= t ; i++ ) {
		dis[i] = -2147483647777777ll;
		vis[i] = 0;
	}
	dis[s] = 0; vis[s] = 1;
	q.push ( s );
	while ( q.size () ) {
		k = q.front (); q.pop ();
		vis[k] = 0;
		for ( node *j = g[k] ; j ; j = j -> next ) {
			//printf ( "%lld %lld\n" , j -> f , j -> c );
			if ( j -> f && dis[j->v] < dis[k] + j -> c ) {
				dis[j->v] = dis[k] + j -> c;
				from[j->v] = j;
				if ( !vis[j->v] ) q.push ( j -> v );
				vis[j->v] = 1;
			}
		}
	}
	if ( dis[t] != -2147483647777777ll ) return true;
	return false;
}
long long find () {
	long long i , minn = 2147483647777777ll;
	for ( i = t ; i != s ; i = from[i] -> rev -> v ) minn = min ( minn , from[i] -> f );
	for ( i = t ; i != s ; i = from[i] -> rev -> v ) {
		from[i] -> f -= minn;
		from[i] -> rev -> f += minn;
	}
	return dis[t] * minn;
}
void dinic () {
	long long ans = 0;
	while ( spfa () == true ) ans += find ();
	printf ( "%lld\n" , ans );
}
void work () {
	int i;
	scanf ( "%lld" , &n );
	for ( i = 1 ; i <= n ; i++ ) {
		scanf ( "%lld%lld%lld" , &rx[i] , &ry[i] , &rc[i] );
	}
	for ( i = 1 ; i <= n ; i++ ) {
		scanf ( "%lld%lld%lld" , &bx[i] , &by[i] , &bc[i] );
	}
	for ( i = 1 ; i <= n ; i++ ) {
		add ( 1 , 1 + i , rc[i] , 0 );
		add ( 1 + n + 4 + i , 1 + n + 4 + n + 1 , bc[i] , 0 );
		add ( 1 + i , 1 + n + 1 , 10 , - rx[i] - ry[i] );
		add ( 1 + i , 1 + n + 2 , 10 , - rx[i] + ry[i] );
		add ( 1 + i , 1 + n + 3 , 10 , + rx[i] - ry[i] );
		add ( 1 + i , 1 + n + 4 , 10 , + rx[i] + ry[i] );
		add ( 1 + n + 1 , 1 + n + 4 + i , 10 , + bx[i] + by[i] );
		add ( 1 + n + 2 , 1 + n + 4 + i , 10 , + bx[i] - by[i] );
		add ( 1 + n + 3 , 1 + n + 4 + i , 10 , - bx[i] + by[i] );
		add ( 1 + n + 4 , 1 + n + 4 + i , 10 , - bx[i] - by[i] );
	}
	s = 1; t = 1 + n + 4 + n + 1;
	dinic ();
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 1152
from collections import deque

S = input()

ans = 0
Q = deque(S)
while len(Q) >= 2:
    left, right = Q[0], Q[-1]

    if left == right:
        Q.popleft()
        Q.pop()
    elif left == 'x':
        Q.popleft()
        ans += 1
    elif right == 'x':
        Q.pop()
        ans += 1
    else:
        print(-1)
        quit()

print(ans)

Measured memory_bytes: 4212
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    long long n,ans,x;
    cin >> n;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            x=i;
        }
    }
    cout << x+(n/x)-2;

}

Measured memory_bytes: 256
import java.util.*;
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 D = sc.nextInt();
  if( A+B > C+D ){System.out.println("Left");}
  else if( A+B == C+D ){System.out.println("Balanced");}
  else{System.out.println("Right");}
}
}

Measured memory_bytes: 23636
def main():
    n, q = map(int, input().split())
    s = input()
    p = prepare(s)
    for _ in range(q):
        l, r = map(int, input().split())
        print(query(p, l, r))

def prepare(s):
    p = [0]
    for i in range(len(s) - 1):
        if s[i:].startswith('AC'):
            p.append(p[-1] + 1)
        else:
            p.append(p[-1])
    return p

def query(p, l, r):
    return p[r - 1] - p[l - 1]

main()


Measured memory_bytes: 6124
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  s.pop_back();
  if(s.size() % 2 == 1) s.pop_back();
  while(1){
    string fr = s.substr(0, s.size()/2);
    string re = s.substr(s.size()/2);
    if(fr == re){
      cout << 2*fr.size() << endl;
      return 0;
    }
    s.pop_back();
    s.pop_back();
  }
  return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
ll dp[2][4];
int now = 0;
int t[3];
ll p2[32];

int main() {
	string s;
	cin >> s;
	int res = 0;
	for (size_t i = 2; i < s.size(); i += 2)
	{
		if (s.substr(0, i / 2) == s.substr(i / 2, i / 2)) res = i;
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 384
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

l = [a1, a2, a3, b1, b2, b3]

res = [sum([1 for _ in l if _ == __]) for __ in [1,2,3,4]]

if 3 in res:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 3060
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int t, d, l;
    while(cin >> t >> d >> l) {
        if(t == 0 && d == 0 && l == 0) break;
        vector<int> x(t);
        rep(i, t) {
            cin >> x[i];
        }
        int ans = 0;
        int now = 0;
        rep(i, t) {
            if(x[i] >= l) now = d;
            else {
                -- now;
            }
            if(i != t - 1) {
                if(now > 0) ++ ans;
            }
        }
        cout << ans << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


Measured memory_bytes: 3556
#数値の入力
# スペース区切りの入力
N, A, B = map(int, input().split())


q = N // (A+B)  #Nを(A+B)で割った時の商
mod = N % (A+B) #Nを(A+B)で割った時の余り

if (mod >= A):  
    ans = (q * A) + A
    print(ans)

elif (mod < A):
    ans = (q*A) + mod
    print(ans)

Measured memory_bytes: 3060
K = input()



list = [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(list[int(K) -1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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; }
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int a,b;
    cin >> a >> b;
    ll ans = 0;
    rep(i,max(a,b)) ans += pow(10,i)*min(a,b);
    PRINT(ans);
}


Measured memory_bytes: 384
import sys

N, K= map(int, input().split())
S = input()

ones_list = S.split('0')
zeros_list = S.split('1')

ones = []
if S[0] == '0':
    ones.append(0)
for k in range(len(ones_list)):
    if ones_list[k] != '':
        ones.append(len(ones_list[k]))
if S[-1] == '0':
    ones.append(0)

zeros = []
for k in range(len(zeros_list)):
    if zeros_list[k] != '':
        zeros.append(len(zeros_list[k]))

if K >= len(zeros):
    print(len(S))
    sys.exit()

result = []
maximum = 0
for k in range(K):
    maximum += ones[k]
    maximum += zeros[k]
maximum += ones[K]
result.append(maximum)


for j in range(len(ones) - K - 1):
    maximum += zeros[K+j] + ones[K+1+j] - ones[j] - zeros[j]
    result.append(maximum)
print(max(result))

Measured memory_bytes: 6368
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// -----------------------------------------------------------------------------
// main
// -----------------------------------------------------------------------------
fn main(){
    input!{
        s: chars,
        k: usize
    }
    let mut ans = '1';
    for i in 0..k{
        if s[i]!='1'{
            ans = s[i];
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
const int maxn=2e5+100;
int k;
bool vis[maxn];
 
int main()
{
    //freopen("1.txt","r",stdin);
    while (scanf("%d",&k)!=EOF)
    {
        memset(vis,0,sizeof(vis));
        deque<P> q;
        q.push_front(make_pair(1,1));
        while (!q.empty())
        {
            auto t=q.front(); q.pop_front();
            if (vis[t.first]) continue;
            vis[t.first]=1;
            if (t.first==0)
            {
                printf("%d\n",t.second);
                break;
            }
            q.push_front(make_pair(t.first*10%k,t.second));
            q.push_back(make_pair((t.first+1)%k,t.second+1));
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
using namespace std;

int main()
{
    int a,b;
    while(cin>>a>>b){
        cout<<(a-1)*(b-1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
import numpy as np

# [Pythonで文字列を置換（replace, translate, re\.sub, re\.subn） \| note\.nkmk\.me](https://note.nkmk.me/python-str-replace-translate-re-sub/)
S = input().strip().translate(str.maketrans({'o': '1', 'x': '0'}))
ss = [int(c) for c in S ]

wins = np.sum(ss)

if 15 - len(ss) + wins >= 8 :
    print('YES')
else:
    print('NO')

Measured memory_bytes: 14420
def f(e):
 a=list(tuple(map(int,input().split())) for _ in range(int(e)))
 s,t=a[0]
 b={tuple(map(int,input().split())) for _ in range(int(input()))}
 for x,y in b:
  for u,v in a[1:]:
   if(x+u-s,y+v-t)not in b:break
  else:return print(x-s,y-t)
for e in iter(input,'0'):f(e)


Measured memory_bytes: 5900
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            string s = ReadLine();
            WriteLine(s.Substring(0,s.Length-8));
        }
    }
}


Measured memory_bytes: 11092
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }
    vi v(3);
    ll ans=1LL;
    rep(i, n) {
        ll c=0LL;
        int j_;
        rep(j, 3) {
            if(v[j]==a[i]) {
                ++c;
                j_ = j;
            }
        }
        v[j_]++;
        ans *= c;
        ans %= mod;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y,z,a,hp;
	cin>>x;
	y=x/500;
	z=x%500;
	a=z/5;
	hp=y*1000+a*5;
	cout<<hp;
	return 0;
}

Measured memory_bytes: 256
import Text.Printf

factorize' :: Int -> [Int]
factorize' 1 = []
factorize' n = loop n divs
  where
    divs = 2 : 3 : (concat [[x, x + 2] | x <- [5, 11 ..]])
    loop n ps@(p : ps')
      | p * p > n    = [n]
      | rem n p == 0 = p : loop (div n p) ps
      | otherwise    = loop n ps'

main :: IO ()
main = do
  n <- readLn
  let a = unwords $ map show $ factorize' n
  printf "%d: %s\n" n a



Measured memory_bytes: 4136
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let h_w = lines.next().unwrap().unwrap();
    let mut h_w = h_w.split_whitespace();
    let h = h_w.next().unwrap().parse::<usize>().unwrap();
    let w = h_w.next().unwrap().parse::<usize>().unwrap();

    let mut a_b = vec![vec![0; w + 1]; h + 1];

    for i in 0..h {
        let a_row = lines.next().unwrap().unwrap();
        let mut a_row = a_row.split_whitespace();
        for j in 0..w {
            let a = a_row.next().unwrap().parse::<i32>().unwrap();
            a_b[i][j] = a;
        }
    }

    for i in 0..h {
        let b_row = lines.next().unwrap().unwrap();
        let mut b_row = b_row.split_whitespace();
        for j in 0..w {
            let b = b_row.next().unwrap().parse::<i32>().unwrap();
            a_b[i][j] = (a_b[i][j] - b).abs();
        }
    }

    let k_len = (h + w) * 80;
    let mut dp = vec![vec![vec![false; k_len]; w + 1]; h + 1];
    dp[0][0][a_b[0][0] as usize] = true;
    for i in 0..h {
        for j in 0..w {
            for k in 0..k_len {
                if dp[i][j][k] {
                    let k = k as i32;
                    let val_1 = k + a_b[i + 1][j];
                    let val_2 = (k - a_b[i + 1][j]).abs();
                    dp[i + 1][j][val_1 as usize] = true;
                    dp[i + 1][j][val_2 as usize] = true;
                    let val_3 = k + a_b[i][j + 1];
                    let val_4 = (k - a_b[i][j + 1]).abs();
                    dp[i][j + 1][val_3 as usize] = true;
                    dp[i][j + 1][val_4 as usize] = true;
                }
            }
        }
    }
    let ans = (0..k_len).filter(|&k| dp[h - 1][w - 1][k]).min().unwrap();

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


Measured memory_bytes: 98684
def func(x):
  if ord(x) - ord('a') >= 0:
    print('a')
  else:
    print('A')


def main():
  letter = input()
  func(letter)
  # for x in ['A', 'Z', 'a', 'z']:
  #   func(x)


if __name__ == '__main__':
  main()

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


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

    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    vector<int> T(N, 0);
    for (int i = 1; i < N; i++) {
        T[i] += T[i - 1];
        if (S[i - 1] == 'A' && S[i] == 'C') T[i]++;
    }

    int l, r;
    rep(_, Q) {
        cin >> l >> r;
        cout << T[r - 1] - T[l - 1] << '\n';
    }

    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,n) for(int i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;

int main() {

    int n, m;
    cin >> n >> m;

    priority_queue<int> que;

    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        que.push(a);
    }

    for(int i = 0; i < m; i++){
        int tmp = que.top();
        tmp = tmp / 2;
        que.pop();
        que.push(tmp);
    }
    
    ll ans = 0;
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }

    cout << ans << endl;

    

}


Measured memory_bytes: 892
n, l = map(int, input().split())

ans_dif = float('inf')
ans = 0

for i in range(n):
  dif = abs(l+i)
  if dif < ans_dif:
    ans_dif = dif
    ans = n*l+n*(n+1)/2-n-(l+i)
print(int(ans))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Numerics;

namespace abc174_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var K = CIn.ReadInt();

      var a = 0;


      for (int i = 1; i <= 1000000; i++)
      {
        a = a % K * 10 + 7;

        if (a % K == 0)
        {
          Console.WriteLine(i);
          return;
        }

      }

      Console.WriteLine(-1);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 27824
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000007
# define INF 9223372036854775806
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
int main() {
	ll ans = 0, counter = 0, maxi = -1, mini = INF, pass = 0, sum = 0;
	//new
	string str;
	cin >> str;
	if (str == "SUN") cout << 7 << endl;
	if (str =="MON") cout << 6 << endl;
	if (str == "TUE") cout << 5 << endl;
	if (str == "WED") cout << 4 << endl;
	if (str == "THU") cout << 3 << endl;
	if (str == "FRI") cout << 2 << endl;
	if (str == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
inp = input()
n = int(inp)
inp = input()
split_inp = inp.split()
# if n % 3 != 0:
#     print("No")
#     exit()
# 数字を3つのグループに分けていく．
# 3種類以上の数字があればno
numbers = {}
for str_number in split_inp:
    int_number = int(str_number)
    if int_number not in numbers:
        numbers[int_number] = 1
    else:
        numbers[int_number] += 1
    if len(numbers) > 3:
        print("No")
        exit()
# 二つのグループに分かれていれば数の大きいほうを分割する必要がある
if len(numbers) == 2:
    number_values = [i for i in numbers.values()]
    max_number = max(number_values[0], number_values[1])
    small_number = min(number_values[0], number_values[1])
    if small_number * 2 != max_number:
        print("No")
        exit()
    n_list = []
    for item in numbers.items():
        if item[1] == small_number:
            n_list.append(item[0])
        else:
            n_list.append(item[0])
            n_list.append(item[0])
elif len(numbers) == 3:
    # 均等に3当分されている
    number_list = [i for i in numbers.values()]
    if number_list[0] != number_list[1] or number_list[1] != number_list[2]:
        print("No")
        exit()
    n_list = [i for i in numbers.keys()]
else:
    number_key = [i for i in numbers.keys()]
    for key in number_key:
        if key != 0:
            print("No")
            exit()
    print("Yes")
    exit()


def number_count(k1, k2, k3, count_n):
    count = 0
    if k1 == count_n:
        count += 1
    if k2 == count_n:
        count += 1
    if k3 == count_n:
        count += 1
    return count


# ビット列に同時に直す.下の桁から見ていき，0,1,1になっていなければno

n1 = int(n_list[0])
n2 = int(n_list[1])
n3 = int(n_list[2])
while n1 != 0 or n2 != 0 or n3 != 0:
    # 一番下の桁を取り出す
    c1 = n1 % 2
    c2 = n2 % 2
    c3 = n3 % 2
    n1 = n1 // 2
    n2 = n2 // 2
    n3 = n3 // 2
    # 1,1,0の組み合わせでなければno
    count1 = number_count(c1, c2, c3, 1)
    count0 = number_count(c1, c2, c3, 0)
    if (count1 != 2 or count0 != 1) and count0 != 3:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 11140
#include <bits/stdc++.h>
using namespace std;
using ll   = long long;
const ll mod = 1e9+7;

void solve(){
    int n,w, max_val=0;cin>>n>>w;
    vector<vector<ll>> a(n, vector<ll>(2));
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1];
        max_val += a[i][1];
    }
    vector<ll> dp(max_val+1, mod);
    dp[0]=0;
    for(int i=0;i<n;i++){
        vector<ll> newDp(max_val+1, mod);
        newDp[0]=0;
        for(int val=0;val<=max_val;val++){
            if(a[i][1]>val){
                newDp[val] = dp[val];
            }else newDp[val] = min(dp[val], dp[val-a[i][1]] + a[i][0]);
        }
        dp = newDp;
    }
    ll ans=0;
    for(int i=0;i<=max_val;i++){
        if(dp[i]<=w)ans = max(ans, (ll)i);
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r",stdin);
        freopen("output1.txt", "w", stdout);
    #endif
    int t;
    t=1;
    // cin>>t;

    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 4776
N, l = int(input()), []
for i in range(N):
    line = [x for x in input().split()]
    l.append([line[0], int(line[1]), i])

l.sort(key = lambda x: x[0])
tmp_list, tmp_string = [[l[0][1], l[0][2]]], l[0][0]
for i in range(1, N):
    if tmp_string == l[i][0]:
        tmp_list.append([l[i][1], l[i][2]])
    else:
        tmp_list.sort(key = lambda x: x[0], reverse = True)
        for x in tmp_list:
            print(x[1]+1)
        tmp_string = l[i][0]
        tmp_list = [[l[i][1], l[i][2]]]

tmp_list.sort(key = lambda x: x[0], reverse = True)
for x in tmp_list:
    print(x[1]+1)


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

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

    int n, d;
    cin >> n >> d;
    int D[n][d];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> D[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            int c = 0;
            for(int k = 0; k < d; k++){
                int t =  D[i][k] - D[j][k];
                c += t * t;
            }
            int r = sqrt(c);
            if(r * r == c){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int x[100000], w[100000], y[100000];
int main() {
	int n, l, t; scanf("%d%d%d", &n, &l, &t);
	rep(i, n) {
		scanf("%d%d", &x[i], &w[i]);
		if (w[i] == 1)y[i] = (x[i] + t) % l;
		else {
			if (x[i] >= t)y[i] = x[i] - t;
			else y[i] = (l - (t - x[i]) % l) % l;
		}
	}
	int X = y[0], cnt = 0;
	for (int i = 1; i < n; i++) {
		if (w[0] == 1 && w[i] == 2) {
			double d = (x[i] - x[0]) / 2.;
			if (t >= d)(cnt += (t - d) * 2 / l + 1) %= n;
		}
		if (w[0] == 2 && w[i] == 1) {
			double d = (l - (x[i] - x[0])) / 2.;
			if (t > d)(cnt += ((t - d) * 2 - 1) / l + 1) %= n;
		}
	}
	if (w[0] == 2)cnt = (n - cnt) % n;
	sort(y, y + n);
	int a = (upper_bound(y, y + n, X) - y - 1 + n - cnt) % n;
	rep(i, n)printf("%d\n", y[(i + a) % n]);
}

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


int main(){
  int n;
  cin >> n;
  ll ans=0;
  string s[n];
  rep(i,n){cin >> s[i];}
  map<string,ll> p;
  rep(i,n){
    sort(s[i].begin(),s[i].end());
    p[s[i]]++;
    if(p[s[i]]>1)ans+=p[s[i]]-1;
    }
  cout << ans << endl;
}

Measured memory_bytes: 18176
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 25 18:20:35 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
N, K = map(int,input().split())
A = list(map(int,input().split()))

dp = [i <= K for i in range(K + A[-1]+1)]
for i in range(K, -1, -1):
    for a in A:
        if dp[a+i]:
            dp[i] = False
            break

#    print(i, dp[i],A+i,dp[A+i])
#print(dp)

if dp[0]:
    ans = 'Second'
else:
    ans = 'First'
print(ans)

Measured memory_bytes: 47540
#include <bits/stdc++.h>
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
using namespace std;

int main(){
  int n, m;
  int x, ans;
  scanf("%d %d",&n,&m);

  ans=n;
  REP(int,i,0,m){
      scanf("%d",&x);
      ans -= x;
  }
  
  if(ans>=0){
      printf("%d",ans);
  }else{
      printf("%d",-1);
  }
}

Measured memory_bytes: 3828
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, K;
	cin >> N >> M >> K;
	REP(i, N+1){
		REP(j, M+1){
			int ret = (N-i)*j+(M-j)*i;
			if(ret == K){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

}


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

int main(){
  string s;cin>>s;
  int k;cin>>k;
  vector<ll> vec;
  char pre='*';
  ll count=1LL;
  int n=int(s.size());
  s += '+';
  for(int i=0;i<=n;i++){
  	char c=s[i];
    if(c!=pre){
      if(pre!='*')vec.push_back(count);
      count=1LL;
    }else{
      count++;
    }
    pre = c;
  }
  // for(auto &e: vec)cout<<e<<endl;
  ll ans=0LL;
  if(vec.size()==1){
    ans = vec[0]*k/2;
    // cout<<vec[0]<<" "<<k<<endl;
  }else if(s[0]==s[n-1]){
  	for(int i=1;i<vec.size()-1;i++){
      ans += vec[i]/2;
    }
    ans *= ll(k);
    ll a=vec[0], b=vec[vec.size()-1];
    ans += a/2 + b/2;
    ans += (a+b)/2*(k-1);
  }else{
  	for(auto &e: vec){
      ans += e/2;
    }
    ans *= ll(k);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
using namespace std;

int main(void){
        int i;
        int h1, h2, a1, a2;
        
        scanf("%d%d%d%d", &h1, &a1, &h2, &a2);
        while(h1>0 || h2>0){
                h2 -= a1;
                if(h2 <= 0){
                        printf("Yes\n");
                        return 0;
                }
                h1 -= a2;
                if(h1 <= 0){
                        printf("No\n");
                        return 0;
                }
        }
        return 0;
}



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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
  int l, r;
  cin >> l >> r;
  if (r - l + 1 >= 2019) {
    cout << "0\n";
  } else {
    int best = INT_MAX;
    for (int i = l; i <= r; ++i) {
      for (int j = i + 1; j <= r; ++j) {
        int curr = (1LL * i * j) % 2019;
        best = min(best, curr);
      }
    }
    cout << best << "\n";
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  test_case();
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
num_list = list(map(int, input().split()))

# ans = np.prod(num_list)
ans = num_list[0]
for i in range(1, N):
    if ans > 10**18:
        break
    ans *= num_list[i]


if 0  in num_list:
    print(0)
elif ans > 10**18:
    print("-1")
else:
    print(ans)

Measured memory_bytes: 39876
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(){
	double n;
	cin >> n;
	int a = n / 2.0;
	double par = 1.0 - a / n;
	printf("%.16f", par);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int N;
    cin>>N;
    
    bool f=false;
    for(int i=0;i<=N;i+=7){
        if((N-i)%4==0){
            f=true;
            break;
        }
    }
    
    cout<<(f?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
loop{
  a,op,b = STDIN.gets.split
  case op
  when "+"
    puts a.to_i+b.to_i
  when "-"
    puts a.to_i-b.to_i
  when "*"
    puts a.to_i*b.to_i
  when "/"
    puts a.to_i/b.to_i
  when "?"
    break
  end
}

Measured memory_bytes: 8656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,z,w;cin >> n >> z >> w;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	if(n==1) cout << abs(a[0]-w) << endl;
	else cout << max(abs(a[n-2]-a[n-1]),abs(a[n-1]-w)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define per(i,a,b) for(int i=(a);i>=(int)(b);i--)
const int mod = 1e9+7;
const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
int main()
{
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n;
    cin>>n;
    ll ans=0,sum=0;
    rep(i,1,n) {
        ll x;
        cin>>x;
        ans=(ans+sum*x)%mod;
        sum=(sum+x)%mod;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 3636
li = list(map(int,input().split()))
nx = [0,0,0]
ans = 0
if all(x&1 == 0 for x in li) and li[0] == li[1] == li[2]:
    print(-1)
else:
    while 1:
        if(li[0]%2!=0 or li[1]%2!=0 or li[2]%2!=0):
            break
        nx[0] = (li[1] + li[2])/2
        nx[1] = (li[0] + li[2])/2
        nx[2] = (li[0] + li[1])/2
        li = nx.copy()
        ans += 1
    print(ans)



    



Measured memory_bytes: 9172
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n;
        while ((n = scan.nextInt()) != 0) {
            int t[] = new int[n];

            for (int i = 0; i < n; i++) {
                t[i] = scan.nextInt();
            }

            int best = -100000000;

            for (int l = 0; l < n; l++) {
                int sum = 0;
                for (int r = l; r < n; r++) {
                    sum += t[r];
                    if (best < sum) {
                        best = sum;
                    }
                }
            }

            System.out.println(best);

        }
    }
}



Measured memory_bytes: 34620
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#pragma gcc target ("avx2")
#pragma gcc optimization ("Ofast")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int d;
	scanf("%d", &d);
	rep(i, d)printf("%d\n", 1);

	Please AC;
}

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


int main() {
  string S;
  cin >> S;
  
  if (S == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define DB(x)            cout << '>' << #x << ':' << x << endl;
#define DB2(x,y) 	     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define rep(i,a,b)       for (ll i = a; i < b; i++)
#define repr(i,a,b)      for (ll i = a; i >= b; i--)
#define pb               push_back
#define F                first
#define S                second
#define mp               make_pair
#define MOD              1000000007
#define MAX              1e9
#define MIN              -1e9
#define vec(i)           vector<i>
#define PLL           	 pair<ll,ll>
#define mem(a,v)         memset(a,v,sizeof(a))
#define pf               printf
#define sc               scanf
#define _s               "%s"
#define _d               "%d"
#define _ll              "%lld"
#define _c               "%c"
#define FAST_IO          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define min(a,b)         (a)>(b)?(b):(a)
#define max(a,b)         (a)>(b)?(a):(b)
#define all(c) 		     c.begin(),c.end()
typedef long long ll;
using namespace std;
int main()
{
	ll a=-1,b=-1;
	string s;
	cin>>s;
	rep(i,0,s.length())
	{
		if(i==0)
			continue;
		if(s[i]==s[i-1])
		{
			a=i,b=i+1;
			break;
		}
		if(i>1&&s[i]==s[i-2])
		{
			a=i-1,b=i+1;
			break;	
		}
	}
	cout<<a<<" "<<b;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,m;
    cin >> n >> m;
    if(m==1){
        cout << "1 2" << endl;
        return 0;
    }

    int i1 = 1;
    int i2 = m + 2;
    for(int diff = m;diff >= 1;diff--){
        cout << i1 << " " << i1 + diff << endl;
        i1++;
        swap(i1,i2);
    }
}


Measured memory_bytes: 3640
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
using namespace std;

int main() {
	int n;
	while (cin >> n&&n != 0) {
		vector<pair<long long, long long>> result;
		long long id, m1, s1, m2, s2, m3, s3, m4, s4;
		for (int i = 0; i < n; i++) {
			cin >> id >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
			result.emplace_back((m1 + m2 + m3 + m4) * 60 + s1 + s2 + s3 + s4, id);
		}
		sort(result.begin(), result.end());
		cout << result[0].second << endl;
		cout << result[1].second << endl;
		cout << result[n - 2].second << endl;
	}
}

Measured memory_bytes: 3112
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	string s ; cin >> s ;
	string sub = "KIHBR" ;
	int pos = 0 ;
	for(int i=0;i<s.size();i++){
		if(pos!=5&&s.at(i)==sub.at(pos)) pos++ ;
	}
	if(pos!=5){
		cout << "NO" << endl ;
		return 0 ;
	}
	sub = "AKIHABARA" ;
	pos = 0 ;
	for(int i=0;i<9;i++){
		if(sub.at(i)==s.at(pos)) pos++ ;
		if(pos==s.size()){
			cout << "YES" << endl ;
			return 0 ;
		}
	}
	cout << "NO" << endl ;
}


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

const long long MOD = 1000000007;

int main() {
    long long n, m, result = 0;
    cin >> n >> m;
    long long x[n], y[m];
    for (long long i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (long long i = 0; i < m; i++) {
        cin >> y[i];
    }
    long long left = 0, right = 0;
    for (long long i = 1, prefix = y[0]; i < m; i++) {
        left = (left + MOD - prefix + i * y[i]) % MOD;
        prefix = (prefix + y[i]) % MOD;
    }
    for (long long i = 1, prefix = x[0]; i < n; i++) {
        right = (right + MOD - prefix + i * x[i]) % MOD;
        prefix = (prefix + x[i]) % MOD;
    }
    cout << (left * right) % MOD;
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
//const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;//<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };



class UnionFind {
public:
	int n;
	vi par; //親
	vi ran; //木の深さ
	vi num; //要素数

	UnionFind(int _n) {
		n = _n;
		par.resize(n); ran.resize(n); num.resize(n);
		for (int i = 0; i < n; i++) {
			par[i] = i; ran[i] = 0; num[i] = 1;
		}
	}

	//木の根を求める
	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	//xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x); y = find(y);
		int numsum = num[x] + num[y];
		if (x == y) {
			return;
		}
		if (ran[x]<ran[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (ran[x] == ran[y]) {
				ran[x]++;
			}
		}
		num[x] = num[y] = numsum;
	}

	//xとyが同じ集合に属するか否か
	bool same(int x, int y) {
		return find(x) == find(y);
	}

};


int main() {
	int n, m;
	cin >> n >> m;
	vi p(n);
	rep(i, n) {
		cin >> p[i];
	}
	UnionFind uf(n);
	vi x(m), y(m);
	rep(i, m) {
		cin >> x[i] >> y[i];
		x[i]--; y[i]--;
		uf.unite(x[i], y[i]);
	}
	map<int, int> idx2idx;
	int cnt = 0;
	vi roots(n);
	vector<set<int> > sets;
	rep(i, n) {
		int root = uf.find(i);
		if (idx2idx[root] == 0) {
			idx2idx[root] = ++cnt;
			sets.push_back(set<int>());
		}
		roots[i] = idx2idx[root];
		sets[roots[i] - 1].insert(i);
	}
	int ans = 0;
	rep(i, n) {
		int root = roots[i];
		if (sets[root - 1].count(p[i] - 1)) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 17708
get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]

import math

a, b, x = gets()
# a, b, x = 2, 2, 4
# a, b, x = 12, 21, 10
# a, b, x = 3, 1, 8

p = math.pi / 180
v = a * a * b

over = False

if x > v / 2:
    x = v - x
    over = True

if over:
    atan = x * 2.0 / a / a / a
    alpha = math.atan(atan) / p
    print alpha
else:
    atan = x * 2.0 / a / b / b
    alpha = math.atan(atan) / p
    print 90 - alpha


Measured memory_bytes: 2692
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
exp = [0] * (N+1)
for i in range(2, N+1):
    cur = i
    for p in range(2, i+1):
        while cur % p == 0:
            exp[p] += 1
            cur //= p

def num(x):
    '''冪乗がx-1以上の数を返す'''
    return len(list(filter(lambda y: y >= x-1, exp)))

answer = num(75) + num(25) * (num(3)-1) + num(15) * (num(5)-1)\
        + num(5) * (num(5)-1) * (num(3)-2) // 2
print(answer)


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(v) (v).begin(), (v).end()
#define sp cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    int n, d;
    cin >> n >> d;

    if (n % (2 * d + 1) == 0)
        cout << n / (2 * d + 1) << endl;
    else
        cout << n / (2 * d + 1) + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=0
for i in range(n-k+1):
    if i==0:
        xe=sum(p[0:k])
    else:
        xe=xe-p[i-1]+p[i+k-1]
    a=max(a,xe)
print((k+a)/2)

Measured memory_bytes: 25060