akhauriyash/Code-Regression huggingface dataset:
from bisect import bisect_left, bisect_right

n, k = map(int, input().split(" "))
x = list(map(int, input().split(" ")))

zero_left = bisect_left(x, 0)
zero_right = bisect_right(x, 0)
m = x[:zero_left]
p = x[zero_right:]
zero_count = zero_right - zero_left
k -= zero_count
if k <= 0:
	print(0)
	exit()

y = m[-k:] + p[:k]
min_time = 1000000000000000000000000
for i in range(len(y)-k+1):
	l, r = y[i], y[i+k-1]
	time = r-l + min(abs(l), abs(r))
	if time < min_time:
		min_time = time

print(min_time)

Measured memory_bytes: 14388
# https://atcoder.jp/contests/abc100/tasks/abc100_d

# もし正の数だけだったら簡単→それぞれの合計値でソートすれば良い
# Nはたかだか1000→N^2でも間に合う

# 突っ込んだときに良くなるものを貪欲に選べばよいのでは？
# だめだ。-3 1 1 1 1とかのときに1が選ばれなくなる
# 正負の仮定を8パターン列挙しておいて、それぞれに貪欲にやる←行けそう

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


N, M = read_ints()
XYZ = read_tuple(N)


def iter_p_adic(p, length):
    '''
    連続して増加するp進数をリストとして返す。lengthはリストの長さ
    return
    ----------
    所望のp進数リストを次々返してくれるiterator
    '''
    from itertools import product
    tmp = [range(p)] * length
    return product(*tmp)


def sort_and_ret_score(p):
    a = [-1, 1]
    XYZ.sort(reverse=True, key=lambda x: (
        a[p[0]] * x[0] + a[p[1]] * x[1] + a[p[2]] * x[2]))  # すべて正だとして仮定した場合の最大値
    tmp = 0
    for x, y, z in XYZ[:M]:
        tmp += a[p[0]] * x + a[p[1]] * y + a[p[2]] * z
    return tmp


ans = 0
for p in iter_p_adic(2, 3):
    ans = max(ans, sort_and_ret_score(p))


print(ans)


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

long long A[100005][40], c[40],a[40];
long long K ;
long long N ;
long long cnt[40];
int main(){
	scanf("%lld%lld",&N,&K);
	long long x ;
	for( int i = 0 ; i < 40 ; i++ ){
		c[i] = (K%2LL) ;
		K = K/2 ;
	}
	for( int i = 0 ; i < N ; i++ ){
		scanf("%lld",&x);
		for( int j = 0 ; j < 40 ; j++ ){
			A[i][j] = x%2LL ;
			x = x / 2 ;
		}
	}
	bool ok = false ;
	for( int i = 39 ; i >= 0 ; i-- ){
		for( int j = 0 ; j < N ; j++ ){
			if( A[j][i] == 1 ) cnt[i]++ ;
		}
		if( cnt[i] >= N-cnt[i] ) a[i] = 0 ;
		else a[i] = 1 ;
		if( !ok ){
			if( c[i] < a[i]) a[i] = 0 ;
			else if( c[i] > a[i] ) ok = true ;
		}
	}
	long long sum = 0 ;
	long long p = 1 ;
	for( int i = 0 ; i < 40 ; i++ ){
		if( a[i] == 0 ){
			sum += (p*cnt[i]);

		}
		else{
			sum += (p*(N-cnt[i]));

		}
		p = p * 2 ;
	}

	printf("%lld\n",sum);

	return 0 ;
}

Measured memory_bytes: 31488
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

bool check(int nums[10])
{
  // always choose the larger side
  int left = 0;
  int right = 0;
  for (int i = 0; i < 10; i++)
  {
    int current = nums[i];
    if (current < left && current < right)
    {
      return false;
    }
    if (current < left)
    {
      right = current;
    }
    else if (current < right)
    {
      left = current;
    }
    else if (left < right)
    {
      right = current;
    }
    else
    {
      left = current;
    }
  }
  return true;
}

int main()
{
  int n;
  int nums[10];
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    // read
    for (int j = 0; j < 10; j++)
    {
      scanf("%d", &nums[j]);
    }
    bool result = check(nums);
    if (result == true)
    {
      printf("YES\n");
    }
    else
    {
      printf("NO\n");
    }
  }
  return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int a;
    string ans;
    cin>>a;
    if(a==25)ans="Christmas";
    else if(a==24)ans="Christmas Eve";
    else if(a==23)ans="Christmas Eve Eve";
    else if(a==22)ans="Christmas Eve Eve Eve";
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n, x, ans;
	while(true){
		cin >> n >> x;
		if(n == 0 && x == 0) return EXIT_SUCCESS;
		ans = 0;
		for(int i = 1; i <= n; i++){
			for(int j = i + 1; j <= n; j++){
				for(int k = j + 1; k <= n; k++){
					if(i + j + k == x) ans++;
				}
			}
		}
		cout << ans << "\n";
	}
}



Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int i, j;
	int a[4], b[4];
	int hit = 0, blow = 0;
	
	while (scanf("%d", &a[0]) != EOF){
		scanf("%d %d %d", &a[1], &a[2], &a[3]);
		scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]);
		
		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if (i == j){
				}
				else if (a[i] == b[j]){
					blow++;
				}
			}
			
			if (a[i] == b[i]){
				hit++;
			}
		}
		printf("%d %d\n", hit, blow);
		hit = 0;
		blow = 0;
	}
	
	return (0);
}

Measured memory_bytes: 596
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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


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

    ll result=0;
    for(ll a=1;a<N;a++){
        result += (N-1)/a;
    }

    cout << result << endl;
}




Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int a, b;
    cin >> a >> b;
    out(a*b - (a+b-1));
}

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

int main(int argc, char const *argv[]) {
    double x1, y1, x2, y2;
    double dx, dy, d;
    cin >> x1 >> y1 >> x2 >> y2;
    dx = x1 - x2;
    dy = y1 - y2;
    d = sqrt(dx * dx + dy * dy);
    cout << fixed << setprecision(10) << d << endl;

    return 0;
}



Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vl;
typedef vector<vector<ll>> vll;
typedef vector<bool> vb;
typedef set<int> si; 
typedef queue<int> qi;
typedef stack<int> sti;
typedef priority_queue<int> pqi;
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
#define maxn 100005
#define Mod 1000000007
const int INF = 2e9;
const ll ML = 4e18;
    
void solve() {
    int x;
    cin >> x;
    if(x >= 30) cout << "Yes\n";
    else cout << "No\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
   
    solve();
   
    /*
    clock_t start,finish;
    start = clock();
    
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<bool> saiteki(100) ;
  vector<int>   saidai(100) ;
  saiteki[0] = false ;
   saidai[0] = 0 ;
  FOR(i,1,100){
    int l = 0 ;
    l = i/10+i%10 ;
    int maxi = 0 ;
    FOR(j,1,i+1){
      int k = 0 ;
      k = j/10 +j%10 ;
      maxi = max(maxi,k) ;
    }
    if(l==maxi){
      saiteki[i] = true ;
    }
    else{
      saiteki[i] = false ;
    }
  }

  FOR(i,1,100){
    for(int j=i;j>=0;j--){
      if(saiteki[j]){
        saidai[i] = j/10+j%10 ;
        break ;
      }
    }
  }  
  
  string s ;
  cin >> s ;
  int n = SZ(s) ;
  
  if(n<=2){
    cout << saidai[stoi(s)] ;
    return 0 ;
  } 
  
  int ans = 9*(n-2) ;
  
  REP(i,n-1){
    int a = stoi(s.substr(i,2)) ;
    if(!saiteki[a]){
      ans += saidai[a] ;
      cout << ans <<endl ;
      return 0 ;
    }
  }
  
  int sum = 0 ;
  REP(i,n){
    sum += s[i] -'0' ;
  }
  cout << sum <<endl ;
      
      
  
  
  return 0 ;
}






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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
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 D;
int N,M;
int d[222222];

signed main(){
    while(cin>>D,D){
    cin>>N>>M;
    for(int i=1;i<N;i++){
        cin>>d[i];
    }
    sort(d,d+N);
    d[N]=D;N++;

    int ans=0;
    while(M--){
        int k;
        cin>>k;
        int u=upper_bound(d,d+N,k)-d;
        ans+=min(d[u]-k,k-d[u-1]);
    }
    cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1960
/*
      author : nishi5451
      created: 12.08.2020 00:18:04
*/

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


int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i,4) if(s[i]=='2') ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3516
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


int N, Q;
char field[200009];
vector<pair<char, bool>> V;

// pos番目のゴーレムは左に抜けられるか
bool canLeft(int n) {
	bool flag = false;
	int pos = n;
	if (n == 0) flag = true;
	for (int i = 0; i < Q && !flag; i++) {
		if (V[i].first == field[pos]) {
			if (V[i].second) pos++;
			else pos--;
		}

		if (pos == 0) flag = true;
		if (pos == N + 1) break;
	}

	return flag;
}

// pos番目のゴーレムは右に抜けられるか
bool canRight(int n) {
	bool flag = false;
	int pos = n;
	if (pos == N+1) flag = true;
	for (int i = 0; i < Q && !flag; i++) {
		if (V[i].first == field[pos]) {
			if (V[i].second) pos++;
			else pos--;
		}

		if (pos == N + 1) flag = true;
		if (pos == 0) break;
	}

	return flag;
}


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

	 cin >> N >> Q;
	for (int i = 1; i <= N; i++) cin >> field[i];

	
	for (int i = 0; i < Q; i++) {
		char c; cin >> c;
		char d; cin >> d;
		bool way = (d == 'R');
		V.push_back(pair<char, bool>(c, way));
	}

	int ans = 0;

	// 0に到達できる最大のposを探す
	int left = 0; int right = N + 1; // left <= 解 < right
	while (left + 1 != right) {
		int mid = (left + right) / 2;
		if (canLeft(mid)) left = mid;
		else right = mid;
	}
	//cout << left << " ";

	ans += left;


	// N+1に到達できる最小のNを探す
	// left < 解 <= right
	right = N + 1;
	while (left + 1 != right) {
		int mid = (left + right) / 2;
		if (canRight(mid)) right = mid;
		else left = mid;
	}
	//cout << right << " ";

	ans += (N - right + 1);

	cout << N-ans << endl;


	return 0;
}

Measured memory_bytes: 1148
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,r=10000000;
	string S;
	cin>>N>>S;
	vector<int>L(N),R(N);
	for(int i=0,t=0;i<N;i++)
	{
		if(S[i]=='W')t++;
		L[i]=t;
	}
	for(int i=N-1,t=0;i>=0;i--)
	{
		if(S[i]=='E')t++;
		R[i]=t;
	}

	for(int i=0;i<N;i++)
	{
		int t=0;
		if(i!=0)t+=L[i-1];
		if(i!=N-1)t+=R[i+1];
		if(t<r)
		{
			r=t;
		}
	}
	cout<<r<<endl;


}

Measured memory_bytes: 3076
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N;
	cin >> N;
	int odd = 0, two = 0, four = 0;
	REP(i, N) {
		int a;
		cin >> a;
		if (a % 4 == 0) four++;
		else if (a % 2 == 0) two++;
		else odd++;
	}
	string res = "No";
	if (odd <= (N + 1) / 2) {
		if (N % 2 && odd == (N + 1) / 2) {
			if (two == 0) res = "Yes";
		}
		else if (odd <= four) res = "Yes";
	}
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
while True:
	v_list = input().split()
	a = int(v_list[0])
	b = int(v_list[2])
	op = v_list[1]
	if op == '?':
		break
	if op == '+':
		print(a+b)
	elif op == '-':
		print(a-b)
	elif op == '*':
		print(a*b)
	else:
		print(a//b)


Measured memory_bytes: 5596
#include<stdio.h>
#define N 200000

int main(){
  int n,i;
  int min,max;
  int R[N];
  scanf("%d",&n);
  for(i= 0;i<n;i++){
    scanf("%d",&R[i]);
  }

  min = R[0];
  max = R[1] - R[0];

  for(i = 1; i< n; i++){
    if(max < R[i] -min){
      max = R[i] - min;
    }
    if(min > R[i]){
      min =R[i];
     }
    }

    printf("%d\n",max);
    return 0;
  }



Measured memory_bytes: 2520
import java.util.Scanner;
class Main {
    static Scanner scan = new Scanner(System.in);
    public static void main(String[] args) {
        int a = scan.nextInt();
        System.out.println(equationOutput(a));
    }

    private static long equationOutput(int a) {

        if(a == 0) {
            return 0;
        }
        long sum = 0;
        if(a != 1) {
            long gp =  (a * ((long)Math.pow(a, 3) - 1)) / (a - 1);
            sum = gp;
        } else {
            sum = a + (long)Math.pow(a, 2) + (long)Math.pow(a, 3);
        }

        return sum;
    }
}


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

int main() {

    int N;
    cin >> N;
  
    long A[N+1];
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    unordered_map<long, vector<long>> groupI, groupJ;
    for (long i = 1; i <= N; i++) {
        groupI[i+A[i]].push_back(i);
     	groupJ[i-A[i]].push_back(i);
    }

    long ans = 0;
    for (auto Is: groupI){
      ans += (Is.second.size()*groupJ[Is.first].size());
    }
    cout << ans << endl;

    return 0;
}


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            var c = a * b % 2;
            string result = "";
            if (c == 0)
            {
                result = "Even";
            }
            else
            {
                result = "Odd";
            }

            WriteLine(result);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 27636
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	S = input()
	T = input()
	T = T[:-1]
	if S == T:
		print("Yes")
	else:
		print("No")
	




if __name__ == '__main__':
	main()

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

void solve(long long N, long long K, vector<long long> A){
	bool f = false;
	for(int i = 0; i < N; ++i) {
		f = f || A[i] >= K;
	}
	if(!f) {
		cout << "IMPOSSIBLE" << endl;
		return;
	}
	long long g = A[0];
	for(int i = 0; i < N; ++i) {
		g = __gcd(g, A[i]);
	}
	for(int i = 0; i < N; ++i) {
		if((A[i] - K) % g == 0) {
			cout << "POSSIBLE" << endl;
			return;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

int main(){	
	long long K;
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	scanf("%lld",&K);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, K, A);
	return 0;
}



Measured memory_bytes: 1792
-- Single variable
main = do
  x <- getLine
  putStrLn . show $ solve x

solve :: String -> Int
solve xs =
  let n0 = length $ filter (\x -> x == '0') xs
      n1 = length $ filter (\x -> x == '1') xs
  in (length xs) - (abs (n0 - n1))


Measured memory_bytes: 7164
package main

import (
	"fmt"
)

func main() {
	var a, ac, wa, tle, re int
	var s string
	fmt.Scan(&a)
	for i := 0; i < a; i++ {
		fmt.Scan(&s)
		if s == "AC" {
			ac += 1
		} else if s == "WA" {
			wa += 1
		} else if s == "TLE" {
			tle += 1
		} else {
			re += 1
		}
	}
	fmt.Println("AC x", ac)
	fmt.Println("WA x", wa)
	fmt.Println("TLE x", tle)
	fmt.Println("RE x", re)
}


Measured memory_bytes: 6320
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
char s[1005],t[1005];
main(){
	while(~scanf("%s%s",s,t)){
		int sl=strlen(s),tl=strlen(t),ans=INF;
		FE(i,0,sl-tl){
			int now=0;
			F(j,0,tl) now+=(s[i+j]!=t[j]);
			ans=min(ans,now);
		}
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 3824
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXD=10+5;
const int MAXG=2e5+5;
int D,G,ans=MAXG;
struct node{int p,c;}s[MAXD];
int main(){
	scanf("%d%d",&D,&G),G/=100;
	for(int i=1;i<=D;i++)
		scanf("%d%d",&s[i].p,&s[i].c),s[i].c/=100;
	for(int i=0;i<(1<<D);i++){
		int count=G,ret=0;
		for(int j=1;j<=D;j++)
			if(i&(1<<(j-1))){
				ret+=s[j].p;
				count-=(s[j].p*j+s[j].c);
			}
		if(ret>ans)continue;
		if(count>0){
			int ter=MAXG;
			for(int j=1;j<=D;j++)
				if((s[j].p-1)*j>=count)
					if(!(i&(1<<(j-1)))){
						int u=(count/j+(count%j>0?1:0));
						ter=min(ter,u);
					}
			ret+=ter;
		}
		ans=min(ans,ret);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    getline(cin,s1);
    getline(cin,s2);
    cout<<s1[0];
    for(register int i=0;i<s1.size()+s2.size()-1;i++)
    {
        if(i%2)
            cout<<s1[i/2+1];
        else
            cout<<s2[i/2];
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
long long n,ans,k;
long long ds(int uke)
{
	int now=0;
	for(int s=uke;s<n;s++)
	{
		if(a[s]!=b[now])break;
		now++;
	}
	return now;
}
int main()
{
    cin>>n>>a>>b;
    ans=n*2;
    for(int s=0;s<n;s++)
    {
    	k=ds(s);
		ans=min(ans,n*2-k);
	}
	cout<<ans<<endl;
    return 0;
}

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

int main() {
	int ticket[4] = {6000,4000,3000,2000};
	int t,n;
	for(int i=0;i<4;++i){
		cin>>t>>n;
		cout<<ticket[t-1]*n<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	nums := scanNums(N)
	sort.Float64s(nums)
	var a float64
	res := nums[0]
	for i := 0; i < N-1; i++ {
		a = res + nums[i+1]
		res = a / 2
	}
	fmt.Println(res)
}

func scanNums(len int) []float64 {
	nums := make([]float64, len)
	var num float64
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums[i] = num
	}
	return nums
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    ll n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>a>>b>>n;

    n = min(b-1,n);

    cout<<(a*n)/b<<"\n";

    return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define R register int 
#define ll long long
#define inf 2147483647
using namespace std;
const int N=500000;
int n,m;ll lcm;
char S[N],T[N];
map<int,char>Q;
int Gcd(R x,R y){return y?Gcd(y,x%y):x;}
int gi(){
    R x=0,k=1;char c=getchar();
    while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')k=-1,c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*k;
}
int main(){
	n=gi(),m=gi(),lcm=1ll*n/Gcd(n,m)*m;
	scanf("%s",S+1),scanf("%s",T+1);
	R p=lcm/n;
	for(R i=1;i<=n;++i)Q[p*(i-1)+1]=S[i];
	p=lcm/m;
	for(R i=1;i<=m;++i){
		if(Q.find(p*(i-1)+1)!=Q.end())
			if(Q[p*(i-1)+1]!=T[i])
				return puts("-1"),0;
	}
	printf("%lld",lcm);
	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string S="";
  for(int i=0;i<N;i++){
    cin>>S;
    if(S=="Y")break;
  }
  if(S=="Y")cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}

Measured memory_bytes: 256
N=int(input())
D=[]
i=1
while(i*i<=N):
    if N%i==0:
        D.append(i)
        D.append(N//i)
    i+=1
ans=N-1
for i in D:
    j=N//i
    ans=min(ans,i+j-2)
print(ans)


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

int a[102][102];
int main(){
	int n, u, k, t;
	scanf("%d", &n);
	for(int i = 0;i < n;i++){
		scanf("%d%d", &u, &k);
		for(int j = 0;j < k;j++){
			scanf("%d", &t);
			a[u][t] = 1;
		}
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j < n;j++)printf("%d ", a[i][j]);
		printf("%d\n", a[i][n]);
	}
	return 0;
}


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



int main() {

    int N;
    cin >> N;
    long long A[100001];
    long long ans = 1;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if (A[i] == 0) 
        {
            ans = 0;
            break;
        }
    }
    if (ans == 0)
    {
        cout << ans << endl;
        return 0;
    }
    else
    {
        for (int i = 0; i < N; i++)
        {
            if (1000000000000000000 / ans < A[i])
            {
                ans = -1;
                break;
            }
            else ans = ans * A[i];

        }
        if (ans > 1000000000000000000)ans = -1;
        cout << ans << endl;
        return 0;
    }
    
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

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

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	string s;
	cin >> s;
	isYes(!(s[0] == s[1] && s[1] == s[2] && s[2] == s[0]));
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
res = n*(10**5)+1
for i in range(2**n-1):
    s = format(i+1, '0'+str(n)+'b')
    und = [0]*m
    mon = 0
    for j in range(n):
        if s[j] == '0':
            continue
        else:
            for c in range(m):
                und[c] += ca[j][c+1]
            mon += ca[j][0]
    if min(und) >= x:
        res = mon if mon < res else res
if res == n*(10**5)+1:
    res = -1
print(res)

Measured memory_bytes: 9236
def main():
    a, b, k = list(map(int, input().split(" ")))

    flag = True
    for _ in range(k):
        if flag:
            if a % 2 != 0:
                a -= 1
            b += a // 2
            a = a // 2
        else:
            if b % 2 != 0:
                b -= 1
            a += b // 2
            b = b // 2

        flag = not flag

    print(a, b)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		String now="A";
		while(sc.hasNext()) {
			String[] str=sc.next().split(",");
			if(now.equals(str[0]))now=str[1];
			else if(now.equals(str[1])) now=str[0];
		}
		ln(now);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
fun main(args: Array<String>) {
    val (N, D) = listOfInt()
    val ans = Math.ceil(N.toFloat() / (D.toFloat() * 2.0 + 1.0)).toInt()
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 37916
from itertools import *
n,*s=open(0).read().split()
u=[[min(accumulate(t,lambda a,b: a+(1 if b=="(" else -1),initial=0)),2*t.count("(")-len(t)] for t in s]
m=0
for c,d in chain(sorted([x for x in u if x[1]>=0])[::-1],sorted([x for x in u if x[1]<0],key=lambda z:z[0]-z[1])):
    if m+c<0:print("No");break
    m+=d
else:print("No" if m else "Yes")

Measured memory_bytes: 119364
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int r=sc.nextInt();
		if(n>=10) {
			System.out.println(r);
		}else {
			System.out.println(r + (100)*(10-n));
		}
		sc.close();
	}
}


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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    ll n, k;
    cin >> n >> k;
    vll a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    map<ll, ll> mp;
    rep(i, n) {
        if (mp.count(a[i]) == 0) {
            mp[a[i]] = b[i];
        } else {
            mp[a[i]] += b[i];
        }
    }

    vector<pair<ll, ll>> v;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        v.emplace_back(make_pair(itr->first, itr->second));
    }

    sort(v.begin(), v.end());

    ll cnt = 0;
    rep(i, v.size()) {
        cnt += v[i].second;

        if (cnt >= k) {
            cout << v[i].first << endl;
            break;
        }
    }
}

Measured memory_bytes: 9812
A = int(input())
B = int(input())
C = int(input())
X = int(input())
Y = 0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if i*500+j*100+k*50 == X:
        Y = Y+1

print(Y)

Measured memory_bytes: 3060
d={1:"AAA",2:"AA",3:"A",4:"B",5:"C",6:"D",7:"E",8:"NA"}
while True:
    try:
        f,t=map(float,raw_input().split())
    except EOFError:
        break
    if f<35.5:d1=1
    elif f<37.5:d1=2
    elif f<40.0:d1=3
    elif f<43.0:d1=4
    elif f<50.0:d1=5
    elif f<55.0:d1=6
    elif f<70.0:d1=7
    else:d1=8

    if t<71.0:d2=1
    elif t<77.0:d2=2
    elif t<83.0:d2=3
    elif t<89.0:d2=4
    elif t<105.0:d2=5
    elif t<116.0:d2=6
    elif t<148.0:d2=7
    else:d2=8

    print d[max(d1,d2)]

Measured memory_bytes: 4292
//#pragma GCC optimize(3)
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;

#define MAXN 100005
#define INF 999999999
int pass[MAXN];

signed main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int n, m, a, b;
	int ans = 0;
	int minn = 1;
	scanf("%d%d", &n, &m);
	int maxx = n;
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &a, &b);
		minn = max(minn, a);
		maxx = min(maxx, b);
	}
	if (minn <= maxx) {
		printf("%d", maxx - minn + 1);
	}
	else {
		printf("0");
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
ok = True
ans = -1000001000
for i in range(n):
    if ans <= h[i] - 1:
        ans = h[i] - 1
    elif ans <= h[i]:
        ans = h[i]
    else:
        ok = False
        break
if ok:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14396
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n, r, l;
  scanf("%d %d %d", &n, &r, &l);
  vector<int> scores(n);
  vector<int> times(n);
  priority_queue<P> que;
  que.push(P(0, 0));
  int btime = 0;
  P top;
  for (int i = 0; i < r; i++) {
    int d, t, x;
    scanf("%d %d %d", &d, &t, &x);
    d--;
    while (true) {
      top = que.top();
      if (scores[-top.second] == top.first) break;
      que.pop();
    }
    times[-top.second] += t - btime;
    btime = t;
    scores[d] += x;
    que.push(P(scores[d], -d));
  }

  while (true) {
    top = que.top();
    if (scores[-top.second] == top.first) break;
    que.pop();
  }
  times[-top.second] += l - btime;
  int res = 0, max = -1;
  for (int i = 0; i < n; i++) {
    if (max < times[i]) {
      max = times[i];
      res = i;
    }
  }
  cout << res + 1 << endl;
}

Measured memory_bytes: 11500
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
//vector<ll> vll;
ll num[ten52];
ll path[ten52];

int main(void)
{
    //double ans=0.0,d,d1,d2;
    //float f,g,h;
    long long int m,n,i,j,k=0,save;
    long long int a,a1,a2,a3,sum;
    string s,s1,s2;
    //char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>n;
    if(n%10==3) cout<<"bon";
    else if(n%10==0||n%10==1||n%10==6||n%10==8)
        cout<<"pon";
    else cout<<"hon";
    return 0;
}





Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main ()
{

long long x;
cin >> x;
long long i,j;
bool flag=false;

for(i=1;i<10;i++)
{
	for(int j=1;j<10;j++)
	{
		if(i*j==x)
		{
			 flag=true;
			 break;
		}
	}
}

  if(flag)
  {
		cout << "Yes" << endl;
  }
  else
  {
		cout << "No"  << endl;
  }

	return 0;
}











Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(int, N);
	in_v(ll, a, N);
	int status = 0, cnt = 0;
	loop(i, N) {
		if (!i) continue;
		if (status == 1) {
			if (a[i - 1] > a[i]) {
				++cnt;
				status = 0;
			}
		} else if (status == -1) {
			if (a[i - 1] < a[i]) {
				++cnt;
				status = 0;
			}
		} else {
			if (a[i - 1] < a[i]) {
				status = 1;
			}else if (a[i - 1] > a[i]) {
				status = -1;
			}
		}
	}
	cout << cnt + 1 << endl;
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<vector<char>> mat(n);
    for (int i = 0; i < n; i++)
    {
        mat[i] = vector<char>(n);
        for (int j = 0; j < n; j++)
            cin >> mat[i][j];
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        bool valid = true;
        for (int r = 0; r < n; r++)
        {
            for (int c = 0; c < n; c++)
            {
                int rr = r;
                int cc = (c - i + n) % n;
                if (mat[r][c] != mat[cc][(rr + i) % n])
                    valid = false;
            }
        }
        if (valid)
            ans += n;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
constexpr int INF = 1 << 30;
constexpr int MOD = 1e9 + 7;

string s;

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

  cin >> s;
  if(s == "Sunny") cout << "Cloudy";
  else if(s=="Cloudy") cout << "Rainy";
  else cout << "Sunny";
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>

using namespace std;
using LL = long long;

constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	a = a + b + c;
	if (a == "110" || a == "001")cout << "Open" << endl;
	else cout << "Close" << endl;
}

Measured memory_bytes: 3120
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sqr(x) (x) * (x)

using namespace std;
using namespace __gnu_pbds;

mt19937_64 gen(time(0));

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//const int inf = 2e9 + 34333;
//const ll mod = 1e9 + 7;
//const int maxn = 40;


signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif
    int n;
    cin >> n;
    map <string, int> mp;
    for(int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';
    return 0;
}


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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

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

#define rep(i, j, k) for (int i = j; i < k; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 60);

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
    int N;
    cin >> N;
    ll ans = 0;
    rep(i, 1, N + 1) {
        if (i % 3 > 0 and i % 5 > 0) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int a[4], b[4];
	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
		int hit = 0;
		int blow = 0;
		rep(i, 4)if (a[i] == b[i])hit++;
		rep(i, 4) if (find(a, a + 4, b[i]) != a + 4)blow++;
		cout << hit << ' ' << blow - hit << endl;
	}
	return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

int main(){
    int n;
    cin >> n;
    if(n %2 == 0){
        cout << n/2 << endl;
    }
    else{
        cout << (n/2)+1 << endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main()
{
char A, B;
int ans = 0;
cin >> A >> B;

if(A == 'D') ans ^= 1;
if(B == 'D') ans ^= 1;

if(ans == 1) cout << 'D' << endl;
else cout << 'H' << endl;
return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var count = 0;
            foreach (var i in Enumerable.Range(1, N).Where(z => z % 2 == 1))
            {
                var total = 0;
                for (var j = 1; j <= i; j+=2)
                {
                    if (i % j == 0) total++;
                }
                if (total == 8) count++;
            }
            Console.WriteLine(count);
        }
    }
}


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

using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;

int B[MAX], T[VMAX + 1];

int slove() {
    int ans = 0;
    bool V[MAX];

    for (int i = 0; i < n; i++) {
        B[i] = A[i];
        V[i] = false;
    }
    sort(B, B + n);
    for (int i = 0; i < n; i++) {
        T[B[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        if (V[i]) continue;

        int cur = i;
        int S = 0;
        int m = VMAX;
        int an = 0;
        while (true) {
            V[cur] = true;
            an++;
            int v = A[cur];
            m = min(m, v);
            S += v;
            cur = T[v];
            if (V[cur]) break;
        }
        ans+=min(S+(an-2)*m,m+S+(an+1)*s);
    }
    return ans;
}

int main() {
    cin >> n;
    s = VMAX;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        s = min(s, A[i]);
    }

    int ans = slove();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
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 dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int A,B;
int main(){
    cin >> A >> B;
    if(A == B) pr("Draw");
    else if((A > B && B != 1) || A == 1) pr("Alice");
    else pr("Bob");
}

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

int a[10];

int main()
{
    int n;
    cin>>n;
    ll fib[n+1];
    fib[0]=2;
    fib[1]=1;
    for(int i=2;i<=n;i++)
        fib[i]=fib[i-1]+fib[i-2];
    cout<<fib[n]<<endl;
}


Measured memory_bytes: 3572
from bisect import bisect_right
from itertools import accumulate

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

a_ac=[0]+list(accumulate(a))
b_ac=[0]+list(accumulate(b))

ans=0
for i in range(n+1):
  remain=k-a_ac[i]
  if remain<0:
    continue
  t_ans=i
  t_ans+=bisect_right(b_ac,remain)-1
  ans=max(ans,t_ans)

print(ans)

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

class Program
{
    void Run()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int r = sc.NextInt();

        Console.WriteLine(n < 10 ? r + 100 * (10 - n) : r);
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }

    static long Lcm(long a, long b)
    {
        long d = Gcd(a, b);
        return a / d * b;
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 13140
use v5.18;
use warnings;
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }


my @s = split //, read_line;
say solve(\@s) ? 'AC' : 'WA';

sub count_c {
  my $s = shift;
  my $c_counter = 0;
  for my $i (2 .. $#$s - 1) {
    my $char = $s->[$i];
    $c_counter ++ if $char eq 'C';
  }
  $c_counter;
}

sub check_lc {
  my ($s, $c_num) = @_;
  my $c_idx;
  for my $i (1 .. $#$s - 1) {
    my $char = $s->[$i];
    $c_idx = $i if $char eq 'C';
  }
  splice @$s, $c_idx, 1;
  shift @$s;
  my $include_lc;
  for my $char (@$s) {
    $include_lc = 1 if $char =~ /[A-Z]/;
  }
  !$include_lc;
}

sub solve {
  my $s = shift;
  my $c_num = count_c($s);
  $s->[0] eq 'A' && $c_num == 1 && check_lc($s, $c_num);
}


Measured memory_bytes: 640