akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#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> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//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 fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	string s ; cin >> s ;
	cout << (s=="ABC"?"ARC":"ABC") << endl ;
}


Measured memory_bytes: 3628
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = list(input())
# s = list(map(int, s))
from itertools import product
num = len(s)-1
bits = product([0, 1], repeat=num)
L = []
for x in bits:
    l = []
    r = [s[0]]
    for i in range(len(x)):
        if x[i] == 0:
            r.append(s[i+1])
        if x[i] == 1:
            l.append(r)
            r = []
            r.append(s[i+1])
    l.append(r)
    L.append(l)
# print(L)
ans = 0
for equ in L:
    # print(equ)
    for y in equ:
        # print(y)
        ans += int("".join(y))
print(ans)


    



Measured memory_bytes: 5448
def f(S, i):
    if i == len(S)-1:
        return S
    else:
        s = S[:i+1] + '+' + S[i+1:]
        return f(s, i+2) + '+' + f(S, i+1)

if __name__ == '__main__':
    S = input()
    print( eval(f(S, 0)) )

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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string o,e; cin >> o >> e;
  for(int i = 0; i < min(e.size(),o.size());i++) cout << o[i] << e[i];
  for(int i = o.size(); i < e.size(); i++) cout << e[i];
  for(int i = e.size(); i < o.size(); i++) cout << o[i];
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
n = int(input())
al = list(map(int,input().split()))

from collections import defaultdict
dic = defaultdict(int)

for a in al:
    dic[a] += 1


a = [k for k, v in dic.items() if v >= 2]
b = [k for k, v in dic.items() if v >= 4]
a = sorted(a + b)

if len(a) < 2:
    print(0)
    import sys
    sys.exit()
print(a[-1] * a[-2])

Measured memory_bytes: 69144
#![allow(non_snake_case)]

#[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)*} }; }
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)*} };}
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") }; }

fn main() {
    input!{
        K: usize,
    }
    println!("{}", K / 2 * (K / 2 + K % 2));
}


Measured memory_bytes: 4352
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n, m, q, l, r int

	fmt.Sscan(getNextLine(scanner), &n, &m, &q)
	counter := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		counter[i] = make([]int, n+1)
	}
	for i := 0; i < m; i++ {
		fmt.Sscan(getNextLine(scanner), &l, &r)
		counter[l][r]++
	}
	for i := 1; i <= n; i++ {
		for j := 1; j <= n; j++ {
			counter[i][j] += counter[i][j-1]
		}
	}
	for i := 1; i <= n; i++ {
		for j := 1; j <= n; j++ {
			counter[i][j] += counter[i-1][j]
		}
	}
	for i := 0; i < q; i++ {
		fmt.Sscan(getNextLine(scanner), &l, &r)
		fmt.Println(counter[r][r] - counter[l-1][r] - counter[r][l-1] + counter[l-1][l-1])
	}
}


Measured memory_bytes: 6144
def c_sum_of_gcd_of_tuples_easy():
    from math import gcd
    K = int(input())

    ans = 0
    for a in range(1, K + 1):
        for b in range(1, K + 1):
            for c in range(1, K + 1):
                ans += gcd(gcd(a, b), c)
    return ans

print(c_sum_of_gcd_of_tuples_easy())

Measured memory_bytes: 67804
#include <bits/stdc++.h>
#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,b,a) for(int i=(b);i>=(a);i--)
#define len(a) int((a).size())
using namespace std;
using LL = long long;
using PII = pair<int, int>;

int main() {
    int n;
    scanf("%d", &n);
    if (n == 1) return !printf("1\n");
    LL x = 2, y = 1;
    LL now;
    FI(i,2,n) {
        now = x + y;
        x = y;
        y = now;
    }
    printf("%lld\n", now);
}

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

int main()
{
    vector<int> v(500);
    int x;
    cin>>x;
    v[x]++;
    cin>>x;
    v[x]++;
    cin>>x;
    v[x]++;
    if(v[5]==2&&v[7]==1) cout <<"YES";
    else cout <<"NO";
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

bool check(vector<int> d){
	int pre =d[1]-d[0];
	//cout <<pre<<endl;
	for(int i =2;i <d.size();i++){
		int diff =d[i]-d[i-1];
		if(pre!=diff){
			return false;
		}
	}
	return true;
}

int main(){
	int n;
	while(cin>>n,n){
		vector<int> data;
		for(int i =0;i <n+1;i++){
			int x;
			cin>>x;
			data.push_back(x);
		}
		bool ok =false;
		for(int i =0;i < n+1&&!ok;i++){
			vector<int> tmp=data;
			tmp.erase(tmp.begin()+i);
			if(check(tmp)){
				cout <<data[i]<<endl;
				ok =true;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1224
#include "stdio.h"
int main(int argc, char const *argv[]) {

  int n,k,min,len;
  scanf("%d %d",&n,&k );
  int a[n];
  for(int i=0; i<n; i++){
    scanf("%d",&a[i] );
  }
  min=a[0];
  for(int j=0; j<n; j++){
    if(a[j]<min) min=a[j];
  }
  int count=1;
  len=n-k;
  while (len>0) {
    len=len-(k-1);
    count++;
  }

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

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,k,q,a[100010],b[100010];
    cin>>n>>k>>q;
    rep(i,n) a[i]=k-q;
    rep(i,q){
        ll p;
        cin>>p;
        p--;
        a[p]++;
    }
    rep(i,n){
        if(a[i]>0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main(){
  string s;
  cin>>s;
  rep(i,s.size())s[i]=s[i]-'0';
  int min=1000;
  rep(i,s.size()-2){
    if(abs(s[i]*100+s[i+1]*10+s[i+2]-753)<min)min=abs(s[i]*100+s[i+1]*10+s[i+2]-753);
  }
  cout << min <<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private int count;
	private int[] a;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			int nico = Integer.parseInt(in.readLine());
			String[] se = in.readLine().split(" ");
			
			a = new int[nico];
			for (int i = 0; i < nico; i++) {
				a[i] = Integer.parseInt(se[i]);
			}
			
			mergeSort(0, nico);
			
			System.out.print(a[0]);
			for (int i = 1; i < nico; i++) {
				System.out.print(" " + a[i]);
			}
			System.out.println();
			System.out.println(count);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void merge(int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		
		int[] l = new int[n1];
		int[] r = new int[n2];

		for (int i = 0; i < n1; i++) {
			l[i] = a[left + i];
		}
		
		for (int i = 0; i < n2; i++) {
			r[i] = a[mid + i];
		}
		
		int i = 0;
		int j = 0;
		for (int k = left; k < right; k++) {
			count++;

			if (i == n1) {
				a[k] = r[j];
				j++;
				continue;
			}
			if (j == n2) {
				a[k] = l[i];
				i++;
				continue;
			}
			
			if (l[i] <= r[j]) {
				a[k] = l[i];
				i++;
			} else {
				a[k] = r[j];
				j++;
			}
		}
	}
	
	public void mergeSort(int left, int right) {
		if ((left + 1) < right) {
			int mid = (left + right) / 2;
			mergeSort(left, mid);
			mergeSort(mid, right);
			merge(left, mid, right);
		}
	}
}

Measured memory_bytes: 158232
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;
long long m, ans;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	if (n == 3) {
		cout << "2\n";
		cout << "1 3\n";
		cout << "2 3\n";
		return 0;
	}
	int tmp = n;
	if (tmp % 2) tmp--;
	m = tmp * 1LL * (tmp - 2) / 2;
	ans = m;
	if (n % 2) {
		ans += tmp;
	}
	cout << ans << "\n";
	for (int i = 1; i < tmp; i++) {
		for (int j = i + 1; j <= tmp; j++) {
			if (i + j == 1 + tmp) continue;
			cout << i << " " << j << "\n";
		}
	}
	if (n % 2) {
		for (int i = 1; i <= tmp; i++) {
			cout << i << " " << n << "\n";
		}
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
MOD = 10**9+7

d = defaultdict(lambda:0)
for n in range(2,N+1):
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1

ans = 1
for v in d.values():
    ans *= (v+1)
print(ans % MOD)


Measured memory_bytes: 3444
n=int(input())
a=list(map(int,input().split()))
a.sort()

l,r=0,n-1
while r-l!=1:
  t=(l+r)//2
  if a[t]>0:
    r=t
  else:
    l=t
if r==n-1:
  print(-sum(a[:-1])+a[-1])
  t=a[-1]
  for i in a[:-1]:
    print(t,i)
    t-=i
else:
  print(-a[0]+sum(map(abs,a[1:-1]))+a[-1])
  for i in a[r:-1]:
    print(a[0],i)
    a[0]-=i
  for i in a[:r]:
    print(a[-1],i)
    a[-1]-=i
  
    

Measured memory_bytes: 86700
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(sa[i]);
		}
		br.close();

		long xor = 0;
		for (int i = 2; i < n; i++) {
			xor ^= a[i];
		}

		long sum = a[0] + a[1];
		sum -= xor;
		if (sum % 2 == 1) {
			System.out.println(-1);
			return;
		}
		sum /= 2;
		if ((sum & xor) != 0 || sum > a[0]) {
			System.out.println(-1);
			return;
		}

		long b = sum;
		for (int i = 41; i >= 0; i--) {
			if ((xor >> i & 1) == 1) {
				if (b + (1L << i) <= a[0]) {
					b += (1L << i);
				}
			}
		}
		if (b == 0) {
			System.out.println(-1);
		} else {
			System.out.println(a[0] - b);
		}
	}
}


Measured memory_bytes: 32824
N = int(input())
S = input()
stock = None
slime = 0

for n in range(N):
    if n == 0:
        stock = S[n]
        slime += 1
    else:
        if stock == S[n]:
            stock = S[n]
        else:
            stock = S[n]
            slime += 1

print(slime)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define rg register long long
#define inf 21474899993647
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define ll long long
#define maxn 100005
#define endl "\n"
#define   N 6000
const double eps=1e-8;
using namespace std;
inline ll read()
{
    char ch=getchar();
    ll s=0,w=1;
    while(ch<48||ch>57)
    {
        if(ch=='-')
            w=-1;
        ch=getchar();
    }
    while(ch>=48&&ch<=57)
    {
        s=(s<<1)+(s<<3)+(ch^48);
        ch=getchar();
    }
    return s*w;
}
inline void write(ll x)
{
    if(x<0)
        putchar('-'),x=-x;
    if(x>9)
        write(x/10);
    putchar(x%10+48);
}

int main()
{
   ll a;
   string s;
   cin>>a>>s;
   if(a>=3200)cout<<s<<endl;
   else cout<<"red"<<endl;
    return 0;
}


Measured memory_bytes: 256
N = map(int, input())
a = list(map(int, input().split()))
all_set = set(range(1, 10000))

use_set = list(set(all_set - set(a)))

count = 0
for i in range(len(a)-1):
    if a[i] == a[i+1]:
        a[i+1] = use_set[0]
        use_set = use_set[1:]
        count += 1
    
print(count)

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



int main() {
int A, B;
cin >> A >> B;
if (A>0 && B>0) cout << "Positive" << endl;
else if((A >= 0 && B <= 0) || (B >= 0 && A <= 0)) cout << "Zero" << endl;
else{
int sa = 0-(A-B+1);
if(sa % 2 == 0) cout << "Positive" << endl;
else cout << "Negative" << endl;




}



}

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

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

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

int main(){
    ll a,b;
    cin>>a>>b;
    ll ans;
    if(a>=b) ans=lcm(a,b);
    else ans=lcm(b,a);
    cout<<ans<<endl;
}

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

int main(){
  int t;
  string PRE[20]={
    "yotta","zetta","exa","peta","tera","giga","mega","kilo","hecto","deca",
    "deci","centi","milli","micro","nano","pico","femto","ato","zepto","yocto"
  };
  int B[20]={
    24,21,18,15,12,9,6,3,2,1,
    -1,-2,-3,-6,-9,-12,-15,-18,-21,-24
  };

  //  for( int i=0;i<20;i++ )   cout << PRE[i] << " " << B[i] << endl;
  string num,pre,unit;
  int b;
  cin >> t;
  while( t-- ){
    cin >> num >> unit; pre="";
    b=0;
    for( int i=0;i<20;i++ ){
      if( unit==PRE[i] ){
	pre=unit; cin>> unit; b=B[i]; break;
      }
    }

    if( num[0]=='0' ){ // num<1 : 小数
      unsigned int i=0;
      //      cout << num << " b="<< b << endl;
      for( ; i<num.length() && num[i]!='.';i++,b-- );
      for( i++;i<num.length() && num[i]=='0' ; i++,b-- );
      string buf = ".";
      if( i+1 < num.length() ) buf = buf + num.substr(i+1);
      else buf = "";
      num = num[i] + buf;
      //      cout << num << " b=" << b <<  endl;
    }else{ // num>0
      //      cout << num<<" b=" << b << endl;
      unsigned int i = num.find(".");
      string b1 = num, b2="";
      if( i!=string::npos ){
	b1 = num.substr(0,i );
	b2 = num.substr( i+1 );
      }
      b += b1.length()-1;
      b1 = b1.substr(0,1) + "." + b1.substr(1);
      num = b1+b2;
      //      cout << num << " b=" << b << endl;
    }
    cout << num << " * 10^" << b << " "<< unit << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
int sum[17];

int main() {
    std::string num;
    std::cin >> num;
    int maxn = 0, len = num.size();
    sum[0] = num[0] - '0';
    for (int i = 0; i < len; i++) {
        if (i != 0) sum[i] = sum[i - 1] + num[i] - '0';
        if (num[i] != '0') {
            maxn = std::max(maxn, sum[i] - 1 + (len - i - 1) * 9);
        }
    }
    std::cout << std::max(maxn, sum[len - 1]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int N,D,X;

    cin >> N >> D >> X;

    int sum = X;

    for(int i = 0; i < N; i++){
        int a;
        cin >> a;

        int j = 0;
        sum++;
        while(a*j+1 <= D-a){
            sum++;
            j++;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n;
	while (cin >> n, n) {
		string s; cin >> s;
		while (n--) {
			string t;
			int i(0);
			while (i < s.length()) {
				int x(1);
				for (int j = i + 1; j < s.length() && s[i] == s[j]; j++) {
					x++;
				}
				t += to_string(x) + s[i];
				i += x;
			}
			s = t;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3324
from fractions import gcd

N = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
res = 0
for x in a:
  l = x * l // gcd(x, l)
l %= mod
for x in a:
  res += l * pow(x, mod - 2, mod)
  res %= mod
print(res)


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N);
  SCIN(S);

  int num = 0;
  while (num < N && S[num] == ')') {
    num++;
  }
  // debug(num);

  string ans = string(num, '(');
  // debug(ans);
  int l = 0;
  int tmp = 0;
  FOR(i, num, N) {
    if (S[i] == '(') {
      tmp++;
    } else {
      if (tmp > 0) {
	tmp--;
      } else {
	l++;
      }
    }
  }
  ans += string(l, '(');
  ans += S;
  ans += string(tmp, ')');
  
  cout << ans << endl;
  
  
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

vector< int > graph[55];
void bfs( int l, int r );
bool visit[55];

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

    int n, m;
    cin >> n >> m;
    vector< P > edge;
    for( int i = 0; i < m; ++i ) {
        int a, b;
        cin >> a >> b;
        graph[a].pb( b );
        graph[b].pb( a );
        edge.pb( MP( a, b ) );

    }

    int res = 0;
    for( int i = 0; i < edge.size(); ++i ) {
        bfs( edge[i].F, edge[i].S );
        bool flg = true;
        for( int j = 1; j <= n; ++j ) {
            if( !visit[j] ) {
                flg = false;

            } else {
                visit[j] = false;

            }
        }
        if( !flg ) {
            ++res;

        }

    }
    cout << res << endl;
    return 0;
}

void bfs( int l, int r ) {
    queue< int > q;
    q.push( l );
    visit[l] = true;
    while( !q.empty() ) {
        int p = q.front(); q.pop();
        for( int i = 0; i < graph[p].size(); ++i ) {
            if( ( p != l || graph[p][i] != r ) && ( p != r || graph[p][i] != l ) ) {
                if( !visit[graph[p][i]] ) {
                    q.push( graph[p][i] );
                    visit[graph[p][i]] = true;

                }

            }
        }
    }
}



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


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

using namespace std;

int main()
{
    int n, flag = 0;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a+n);
    for(int i = 0; i < n; i++)
        if(a[i] == a[i-1])
            flag++;


    cout << n - flag << endl;
    return 0;
}


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

int main(){
  int N; cin >> N;
  int count = 0;
  for(int i=1; i<=N; ++i){
    string s = to_string(i);
    if(s.size() % 2 == 1) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<map>
using namespace std;
main()
{
	map<string , long long int >m;
	long long int n;
	cin >> n;
	 long long int i;
	 for(i=0;i<n;i++)
	 {
	 	string s;
	 	cin >> s;
	 	m[s]++;
	 }
	 cout << m.size();
		return 0;
}

Measured memory_bytes: 19200
#include <stdio.h>
int main(void){
	char s[4];
	scanf("%s",s);
	int x = s[2]-'0'+ 10*(s[1]-'0')+100*(s[0]-'0');
	int ans = 111*(s[0]-'0');
	int temp = s[0]-'0';
	if(ans<x){
		printf("%d",111*(temp+1));
	}else{
		printf("%d",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;
int memo[100];
int f(int n) {
   if (memo[n] != 0) return memo[n];
   if (n == 0 || n == 1) return 1;
   return memo[n] = f(n - 1) + f(n - 2);
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n;
   cin >> n;
   int ans = f(n);
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 3168
N,M = map(int,input().split())
A = []
for i in range(N):
    KA = list(map(int,input().split()))
    A.append(KA[1:])

ans = A[0]
for i in range(1,N):
    t = []
    for a in A[i]:
        if a in ans:
            t.append(a)
    ans = t

print(len(ans))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

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

  if(n%2 == 0) cout << n/2 << "\n";
  else cout << n/2 + 1 << "\n";
  return 0;
}


Measured memory_bytes: 256
/** author: __nishad__ **/

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


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define pi 3.14159265358979323
#define endl "\n"


int main()
{
    IOS;

    ll i, a, b, num1=1, num2=1, value;
    vector<tuple<int, int, int>> fibo;

    cin>>a>>b;
    ll dif= b-a;

    while(num2 <=999){
        ll sum = 0;

        for(i=1; i<=num2; i++){
            sum = sum + i;
        }

        fibo.pb(make_tuple( num1, sum, num2));
        num2++;
        num1 = sum;
    }

    for(i=0; i<=999; i++){
        if(dif == get<2>(fibo[i])){
            cout<<get<0>(fibo[i]) - a;
            return 0;
        }

    }


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using Graph = vector<vector<ll>>;
pair<int,int> posix;
double dist(pair<int,int> posix1, pair<int,int> posix2){
  ll x2 = pow(posix1.first - posix2.first,2);
  ll y2 = pow(posix1.second - posix2.second,2);
  return pow(x2 + y2, 0.5);
}

int main(){
  int n;cin>>n;
  vector<pair<int,int>> posix(n);
  //cout << "a";
  for (auto &&i : posix)
  {
    cin >> i.first >> i.second;
  }
  //cout << "b";
  vector<int> root(n);
  for (int i = 0; i < n; i++)
  {
    root.at(i) = i;
  }
  //cout << "c";
  
  double sum = 0;
  int cnt = 0;
  do
  {
    double tmpdist = 0;
    for (int i = 0; i < n - 1; i++)
    {
      int from = root.at(i);
      int to   = root.at(i + 1);
      tmpdist += dist(posix.at(from),posix.at(to));
    }
    sum += tmpdist;
    cnt++;
  } while (next_permutation(root.begin(),root.end()));
  
  
  cout << fixed << setprecision(10) << sum / (double)cnt << endl;
}

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

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

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;

int main() {
    int m, f, b; cin >> m >> f >> b;
    if(m + f < b) {
        cout << "NA" << endl;
    } else {
        cout << max(0, b - m) << endl;
    }
}


Measured memory_bytes: 3084
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<cstdlib> //int,long longなどの絶対値 abs(num)
#include<cmath> // doubleなどの絶対値 abs(num)
#define rep(i,n) for(int i = 0;i<(int)(n);i++);//llで統一するのであればlong longが良い
using namespace std;
using ll = long long;
const ll INF = 100100100100100;
ll keta(ll x) {
    if(x==0) return 1;//0の場合は一桁
	ll sum = 0;
	while (x) {
		x /= 10;
		sum++;
	}
	return sum;
}
int main() {
	ll S;
	cin >> S;
	ll size = keta(S);//0に初期化しなくてOK
	ll ans = 0;
	ll now = 0;
	vector<ll> num(size);//入力された数字を１つずつ配列に入れる
	for (int i = 0; i < size; i++) {
		num[size - 1 - i] = S % 10;
		S /= 10;
	}
	for (int i = 0; i < (1 << (size-1)); i++) {
		bitset<9> s(i);{//０の時は+は無し１の時は+とする
			for (int j = 0; j < size - 1; j++) {
				now = now*10+num[j];//now = 12で、num[j] = 5だったら、125
				if (s.test(j)) {//１の場合
					ans += now;
					now = 0;
				}
			}
            now = now*10+num[size-1];//最後の桁の処理
            ans += now;
            now = 0;
		}
	}
	cout << ans << endl;//endlは少々時間がかかる "\n"推奨
}
// B I T S E T H A J I M E T E S I T T A

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

int main(){
    int N;
    int A[111111];
    int g;
    int i;
    cin >> N;
    for(i=0;i<=N-1;i++)
        cin >> A[i];
    g = A[0];
    for(i=0;i<=N-1;i++)
        g = __gcd(g,A[i]);
    cout << g << endl;
    
}


Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

#define MOD (1000000007)

int main(int argc, char **argv) {
	int n;
	cin >> n;
	map<int, int> cnt;
	FOR(i, 1, n + 1) {
		int a = i, b = 2;
		for (; a > 1; ++b) for (; a % b == 0; a /= b) {
			++cnt[b];
		}
	}
	ll res = 1;
	for (auto it = cnt.begin(); it != cnt.end(); ++it) {
		res = (res * (it->second + 1)) % MOD;
	}
	cout << res << endl;
	return 0;
}


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



int main(){
	
	int n,m;
	while(cin>>n>>m,n){
		int data[11]={0};
		for(int i=0;i<n;i++){
			int d,p;
			cin>>d>>p;
			data[p]+=d;
		}
		int ans=0;
		for(int i=10;i>0;i--){
			if(data[i]<=m){
				m-=data[i];
				data[i]=0;
			}else{
				data[i]-=m;
				m=0;
			}
			ans+=(data[i]*i);
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1160
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim T As Long = 1
        Dim A As Long = 1

        For i As Integer = 0 To N - 1
            Dim Ti As Integer = NextInt()
            Dim Ai As Integer = NextInt()
            Dim k As Long = Math.Max(1 + (T - 1) \ Ti, 1 + (A - 1) \ Ai)
            T = Ti * k
            A = Ai * k
        Next

        WriteLine(T + A)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


Measured memory_bytes: 19920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n;cin >> n;
    vi l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());
    int sum = accumulate(l.begin(), l.end()-1,0);
    if(sum > l[n-1]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N=int(input())
C=[0]*(10**6+1)
n=[i for i in range(50)]
n[0]=1
for i in range(40):
    n[i+1]+=(n[i]+1)
for i in range(2,int(N**0.5)+1):
    if N%i==0:
        while N%i==0:
            C[i]+=1
            N//=i
res=0
for c in C:
    if c>0:
        for i in range(50):
            if c<n[i]:
                res+=i
                break
print(res+1 if N>1 else res)

Measured memory_bytes: 16720
import sys
import math

def q60(t, x, y, n):
    for i in range(1, n+1):
        s = t[i] - t[i - 1]
        k = abs(x[i] - x[i - 1])
        l = abs(y[i] - y[i - 1])
        p = k + l
        #print(k)
        #print(l)
        #print(s)
        if not s % p == 0:
            print('No')
            return
    print('Yes')

N = int(input())

t = []
x = []
y = []
for i in range(N):
    a, b, c = [int(i) for i in input().split()]
    t.append(a)
    x.append(b)
    y.append(c)

t.insert(0, 0)
x.insert(0, 0)
y.insert(0, 0)
q60(t, x, y ,N)

Measured memory_bytes: 11772
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
    for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/

pair<int, int> v[100000];

int main()
{
    FASTIO
//     ///*
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("out.txt", "w", stdout);
//     freopen("error.txt", "w", stderr);
// #endif
// //*/
    int T;
    //scanf("%d", &T);
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n;
        cin >> n;

        for (int i = 0; i < n; i++) {
            cin >> v[i].first;
            v[i].second = i + 1;
        }
        sort(v, v + n);
        for (int i = 0; i < n; i++)
            cout << v[i].second << " ";
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <map>
#include <set>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define mod 1000000007
using namespace std;

int main()
{
    //freopen("1.txt", "r", stdin);
    int n; cin >> n;
    vector<int> v(n, 0);
    int flag = 0;
    int ret = 1;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        if (i == 0) continue;
        if (flag == 1) {
            if (v[i] < v[i - 1]) {
                flag = 0;
                ++ret;
            }
        } else if (flag == -1) {
            if (v[i] > v[i - 1]) {
                flag = 0;
                ++ret;
            }
        } else {
            if (v[i] > v[i - 1]) flag = 1;
            else if (v[i] < v[i - 1]) flag = -1;
        }
    }
    cout << ret << '\n';
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int d[100][100];
typedef pair<int, int>pii;
typedef pair<pii, int>pi3;
int x[1000];
int main()
{
	int num, way;
	scanf("%d%d", &num, &way);
	for (int i = 0; i < num; i++)for (int j = 0; j < num; j++)d[i][j] = 1000000000;
	for (int i = 0; i < num; i++)d[i][i] = 0;
	vector<pi3>v;
	for (int i = 0; i < way; i++)
	{
		int za, zb, zc;
		scanf("%d%d%d", &za, &zb, &zc);
		za--, zb--;
		d[za][zb] = d[zb][za] = zc;
		v.push_back(make_pair(make_pair(za, zb), zc));
	}
	for (int i = 0; i < num; i++)for (int j = 0; j < num; j++)for (int k = 0; k < num; k++)d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
	int r = 0;
	for (int i = 0; i < way; i++)
	{
		int s = v[i].first.first, t = v[i].first.second;
		int q = v[i].second;
		bool f = false;
		for (int j = 0; j < num; j++)if (d[j][s] + q == d[j][t] || d[j][t] + q == d[j][s])f = true;
		if (!f)r++;
	}
	printf("%d\n", r);
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;
/*
map<pair<int, int>, bool> memo;

bool dfs(int x, int y) {
  if (x == 0 && y == 0) return 0;
  if (memo.find({x, y}) != memo.end()) return memo[{x, y}];
  bool& ret = memo[{x, y}];
  ret = 0;
  if (x > 0 && y > 0) ret = !dfs(x - 1, y - 1);
  if (x > 0) ret = ret || !dfs(x - 1, y);
  if (y > 0) ret = ret || !dfs(x, y - 1);
  return ret;
}
*/

int main() {
  int N; cin >> N;
  vector<int> a(N); cin >> a;
  bool second = 1;
  rep(i, N) second = second && a[i] % 2 == 0;
  cout << (second ? "second\n" : "first\n");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<long> A(N + 1);
  vector<long> B(N);
  for(int i = 0; i < N + 1; i++) cin >> A.at(i);
  for(int i = 0; i < N; i++) cin >> B.at(i);
  
  long cnt = 0;
  
  for(int i = 0; i < N; i++) {
    if(A.at(i) >= B.at(i)) {
      cnt += B.at(i);
      A.at(i) -= B.at(i);
      B.at(i) = 0;
    }
    else if(A.at(i) + A.at(i + 1) <= B.at(i)) {
      cnt += (A.at(i) + A.at(i + 1));
      B.at(i) -= (A.at(i) + A.at(i + 1));
      A.at(i) = 0;
      A.at(i + 1) = 0;
    }
    else if(A.at(i) + A.at(i + 1) > B.at(i)) {
      cnt += B.at(i);
      A.at(i + 1) -= (B.at(i) - A.at(i));
      A.at(i) = 0;
      B.at(i) = 0;
    }
  }
  
  cout << cnt << endl;
    
}

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


int main(){
    int N,Q;
    cin >> N >> Q;
    
    string s;
    cin >> s;
    
    //vector<int> AC;
    //AC.push_back(0);
    int ac=0;
    int count=0;
    vector<int> AC_count(N,0);
    
    for(int i=0; i< s.size()-1; i++){
        if(s[i]=='A' && s[i+1]=='C'){
            count++;
        }
        AC_count[i+1] = count;
    }
    

    int i,r;
    //int ans_count;
    rep(z,Q){
        cin >> i >> r;
        cout << AC_count[r-1] - AC_count[i-1] << endl;
    }
    
    /*
    for(int x: AC_count){
        cout << x << " ";
    }
    */
    /*
    int num = s.find("AC"); 
    //cout << num << endl;
    
    while(num != string::npos){
        
        num = s.find("AC");
        AC.push_back(num + count + 1);
        
        s = s.substr(num + 2);
        count += num + 2;
        ac++;
        num = s.find("AC");
        
        //cout << num << endl;
        //cout << s << endl;
        //cout << "while1" << endl;
        
        
    }
    
    vector<int> AC_count(N,0);
    //int ans_count=0;
    for(int x: AC){
        for(int i=0; i<=N; i++){
            if(i >= x){
                AC_count[i]++;
            }
        }
    }
    */
    
    /*
    int i,r;
    int ans_count;
    rep(z,Q){
        cin >> i >> r;
        ans_count = 0;
        for(int x:AC){
            if(i<=x && x <= r-1){
                ans_count++;
            }
        }
        cout << ans_count << endl;
    }
    */
    
    
    
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int INF = 1e9;
ll dp[105][100005];
int main() {
	int n, W;
	cin >> n >> W;
	vector<int>w(n), v(n);
	rep(i, n)cin >> w[i] >> v[i];
	dp[0][0] = 0;
	rep(i, n+1) {
		if (i == 0)continue;
		rep(j, W+1) {
			if (j < w[i-1])dp[i][j] = dp[i - 1][j];
			else {
				dp[i][j] = max(dp[i - 1][j - w[i-1]] + v[i-1], dp[i - 1][j]);
			}
			//cout << j << endl;
		}
		
	}
	//rep(i, 9)cout << dp[n - 1][i] << endl;
	cout << dp[n][W];
	return 0;
}

Measured memory_bytes: 81660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 ll n,W;
 cin>>n>>W;
 ll w[n],v[n];
 ll sum=0;
 for(ll i=0;i<n;i++) {cin>>w[i]>>v[i];sum+=v[i];}
 ll dp[n+1][sum+1];
 ll INF=1e18;
 for(ll i=0;i<=sum;i++) dp[0][i]=INF;
 dp[0][0]=0;
 for(ll i=1;i<=n;i++){
  for(ll j=0;j<=sum;j++){
   if(j>=v[i-1]) dp[i][j]=min(dp[i-1][j-v[i-1]]+w[i-1],dp[i-1][j]);
   else dp[i][j]=dp[i-1][j];
  }
 }
 ll ans=0;
 for(ll i=0;i<=sum;i++){
  if(dp[n][i]<=W&&i>ans) ans=i;
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 79104
#include <cstdlib>
#include <cstdio>

const int N_MAX = 200000;
int N, K;
int A[N_MAX];

void up_heap(int arr[], int i)
{
    int j = (i - 1) / 2;
    int tmp = arr[i];
    if (i == 0) return;
    if (arr[i] <= arr[j]) return;
    arr[i] = arr[j];
    arr[j] = tmp;
    up_heap(arr, j);
}

void down_heap(int arr[], int i)
{
    int j = 0, k = j * 2 + 1;
    int tmp = arr[0];
    arr[0] = arr[i];
    arr[i] = tmp;
    while(k <= i - 1) {
        k = j * 2 + 1;
        if (k + 1 <= i - 1)
            k = arr[k] >= arr[k + 1] ? k : k + 1;
        if (arr[j] >= arr[k]) return;
        tmp = arr[j];
        arr[j] = arr[k];
        arr[k] = tmp;
        j = k;
        k = j * 2 + 1;
    }
}

void sort(int arr[], int n)
{
    for (int i = 0; i < n; i++)
        up_heap(arr, i);
    for (int i = n - 1; i >= 0; i--)
        down_heap(arr, i);
}

int main()
{
    int num[N_MAX];
    int sum = 0;
    if (scanf("%d%d", &N, &K) < 2) exit(1);
    for (int i = 0; i < N; i++) {
        if (scanf("%d", &A[i]) < 1) exit(1);
        A[i]--;
        num[i] = 0;
    }
    for (int i = 0; i < N; i++)
        num[A[i]]++;
    sort(num, N);
    for (int k = 0; k < K; k++)
        sum += num[N - k - 1];
    printf("%d\n", N - sum);
    
    
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt","r",stdin);
#define mp(x,y) make_pair(x,y)
#define pii pair<int,int>
void read(int &val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int INF = 0x3f3f3f3f;
const int maxn=1e6+7;
const int mod=1e9+7;
typedef long long LL;

int n,m;
char s[maxn];
vector<int>pos1,pos2;
int main(){
//    op;
    read(n);
    scanf("%s",s+1);
    int ans=0;
    fo(i,1,n){
        if(s[i]=='W') pos1.push_back(i);
        else pos2.push_back(i);
    }

    int cnt1 = 0,cnt2 = pos2.size()-1;
    int sz1 = pos1.size(),sz2 = pos2.size()-1;
    while(cnt1<sz1&&cnt2>=0){
        if(pos1[cnt1]<pos2[cnt2]){
            ans++;cnt1++;cnt2--;
        }
        else break;
    }
    printf("%d\n",ans);


    return 0;
}

Measured memory_bytes: 4824