akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string s; ll k; cin >> s >> k;
    k--;    // （0-Based）
    char c; // 先頭から順に見ていき、1以外の数字が出現したときの数字
    ll idx; // 1以外が出現したときの文字数目（0-Based）

    // 1以外の数字が最初に出現する位置を探索
    rep(i, s.size()){
        if(s[i] != '1'){
            c = s[i];
            idx = i;
            break;
        }
    }

    // 指定位置が1の場所かどうか
    if(k < idx) cout << "1" << endl;
    else cout << c << endl;
}

Measured memory_bytes: 256
import math

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

r = max(As)

if K == 0:
  print(r)
  exit()
  
l = 1

while l < r:
  mid = (r + l)//2
  cnt = 0
  for a in As:
    cnt += math.ceil(a/mid) - 1
  if cnt <= K:
    r = mid
  else:
    l = mid + 1
  
print(r)

Measured memory_bytes: 104504
S = input()
cand = set()
for i in range(2 ** 4):
    target = list("AKIHABARA".replace("A", "*"))
    if i & (1 << 0):
        target[0] = "A"
    if i & (1 << 1):
        target[4] = "A"
    if i & (1 << 2):
        target[-3] = "A"
    if i & (1 << 3):
        target[-1] = "A"
    t = "".join(target)
    t = t.replace("*", "")
    cand.add(t)
if S in cand:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
sa = input()
sb = input()
sc = input()

lensa = len(sa)
lensb = len(sb)
lensc = len(sc)

now = "a"

while True:
    if now =="a":
        if len(sa) == 0:
            print("A")
            break
        
        now = sa[:1]
        sa = sa[1:]
    
    elif now == "b":
        if len(sb) == 0:
            print("B")
            break
        
        now = sb[:1]
        sb = sb[1:]
        
    elif now == "c":
        if len(sc) == 0:
            print("C")
            break
        
        now = sc[:1]
        sc = sc[1:]
        

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef std::numeric_limits< double > dbl;
struct Dice
{
   int d[6];
   void roll(char c){
       if(c == 'S'){
           int b = d[0];
           d[0] = d[4];
           d[4] = d[5];
           d[5] = d[1];
           d[1] = b;

       }else if(c == 'N'){
           int b = d[0];
           d[0] = d[1];
           d[1] = d[5];
           d[5] = d[4];
           d[4] = b;
       }else if(c == 'W'){
           int b = d[0];
           d[0] = d[2];
           d[2] = d[5];
           d[5] = d[3];
           d[3] = b;
       }else{
           int b = d[0];
           d[0] = d[3];
           d[3] = d[5];
           d[5] = d[2];
           d[2] = b;
       }
   }

   int top(){
       return d[0];
   }
};

int main()
{
   Dice dd;
   int b;
   for(int i=0; i<6 ;i++){
       cin >> b;
       dd.d[i] =b;
   }
   string str;
   cin >> str;
   for(int i=0; i<str.size() ;i++) dd.roll(str[i]);

   cout << dd.top() << endl;
   return 0;
}


Measured memory_bytes: 3168
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = map(int, readline().split())
    h = list(map(int, readline().split()))

    is_good = [True] * n

    for _ in range(m):
        a, b = map(int, readline().split())
        h_a, h_b = h[a - 1], h[b - 1]
        if h_a >= h_b:
            is_good[b - 1] = False
        if h_b >= h_a:
            is_good[a - 1] = False

    print(is_good.count(True))


if __name__ == '__main__':
    main()

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

int main(){
  ll n,ans=109000;
  cin >> n;
  for(ll i=1;i*i<=n;i++){
    ll j = n/i;
    if(i*j!=n)continue;
    ans = min(ans,(ll)to_string(j).size());
  }
  cout << ans << endl;
}


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

namespace AtCoder
{
    class Program
    {
        private static long mod = 1000000007;
        static void Main(string[] args)
        {
            //var n = long.Parse(ReadLine());
            var line = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();

            WriteLine(Min(line[0] + line[1], Min(line[0] + line[2], line[1] + line[2])));
        }
    }
}


Measured memory_bytes: 28188
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<ll>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 998244353
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000


int main(void) {
	int n; cin >> n;
	vint a(n+1);
	for (int i = 1; i <= n;i++) {

		for (int j=1; i*j <= n; j++) {
			a[i*j]++;
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n;i++) {
		ans += a[i] * i;
	}
	cout << ans << endl;

	return 0;
}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll N; cin >> N;
    if(N%2==1){
        cout << 0 << endl;
        return 0;
    }
    ll ans=0;
    ll tmp=10;
    while(N/tmp){
        ans+=N/tmp;
        tmp*=5;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.InputMismatchException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		try {
			int a = sc.nextInt();
			int b = sc.nextInt();

			int area = a * b;
			int perimeter = (a + b) * 2;

			System.out.println(area + " " + perimeter);
		} catch(InputMismatchException ex) {
			ex.printStackTrace();
		} finally {
			sc.close();
		}
	}
}



Measured memory_bytes: 26116
#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; }
//------------------------------------------------------------------------------
bool dpX[2700][16010];
bool dpY[2700][16010];
//------------------------------------------------------------------------------
void _main()
{
    string s;
    int x, y;
    cin >> s >> x >> y;
    vector<int> xx, yy;
    int cnt = 0;
    int i = 0;
    for (const char c : s)
    {
        if (c == 'F')
        {
            ++cnt;
        }
        else
        {
            if (cnt > 0)
            {
                (i == 0 ? xx : yy).push_back(cnt);
            }
            cnt = 0;
            i = 1 - i;
        }
    }
    if (cnt > 0)
    {
        (i == 0 ? xx : yy).push_back(cnt);
    }

    dpX[0][0 + 8000] = true;
    dpY[0][0 + 8000] = true;

    rep(i, 0, xx.size())
    {
        for (int j = -8000; j <= 8000; ++j)
        {
            if (dpX[i][j + 8000])
            {
                dpX[i + 1][j + xx[i] + 8000] = true;
                if (i == 0 && s[0] != 'T') continue;
                dpX[i + 1][j - xx[i] + 8000] = true;
            }
        }
    }

    rep(i, 0, yy.size())
    {
        for (int j = -8000; j <= 8000; ++j)
        {
            if (dpY[i][j + 8000])
            {
                dpY[i + 1][j + yy[i] + 8000] = true;
                dpY[i + 1][j - yy[i] + 8000] = true;
            }
        }
    }

    if (dpX[xx.size()][x + 8000] && dpY[yy.size()][y + 8000])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 64256
#include<stdio.h>

int selectionSort(int *a, int n) 
{
	int i, j, minj, temp;
	int count = 0;
	
	for(i=0;i<n;i++) {
		minj = i;
		for(j=i+1;j<n;j++) {
			if(a[j] < a[minj]) {
			    minj = j;
			}
		}
		if(i != minj) {
			temp = a[i];
			a[i] = a[minj];
			a[minj] = temp;
			count++;
		}
	}
	
	return count;
}

void print_array(int *a, int n) 
{
	int i;
	for(i=0;i<n;i++) {
		if(i > 0) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
}

int main(void) 
{
	int n, a[100], i, count;
	
	scanf("%d", &n);
	for(i=0;i<n;i++) {
		scanf("%d", &a[i]);
	}
	
	count = selectionSort(a, n);
	print_array(a, n);
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
//イントとダブルが入り乱れるときはどちらかに統一しよう。

int max(int x,int y){
  if(x>y) return x;
  return y;
}

int min(int x,int y){
  if(x<y) return x;
  return y;
}

int sumofdigits(int n){
  int sum=0;
  while(n>0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n;
  int a[110];
  cin >> n;
  for(int i=0; i <n ; ++i)cin >> a[i];
  sort(a,a+n,greater<int>());
  int alice=0,bob=0;
  for(int i=0;i<n; ++i){
    if(i%2==0)alice +=a[i];
    else bob+=a[i];
  }
  cout << alice -bob << endl;
}


Measured memory_bytes: 256
s = int(input())
MOD=10**9+7

factorial = [1]
inverse = [1]
for i in range(1, s+2):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))

def combi(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD

if s<3:
    print(0)
    exit()
else:
    ans=0
    for i in range(s//3):
        ans+=factorial[i+s-3*i-3] * inverse[i] * inverse[s-3*i-3] %MOD
        ans%=MOD
    print(ans)


Measured memory_bytes: 9160
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

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


//main関数
int main() {
	int N;
	int ans[4] = {0};
	char c;
	char s[3];
	scanf("%d",&N);
	for(int i = 0; i < N ; i++){
		scanf("%s", &s);
		if(s[0] == 'A')ans[0]++;
		else if(s[0] == 'W')ans[1]++;
		else if(s[0] == 'T')ans[2]++;
		else ans[3]++;
		scanf("%c", &c);
	} 
	printf("AC x %d\n", ans[0]);
	printf("WA x %d\n", ans[1]);
	printf("TLE x %d\n", ans[2]);
	printf("RE x %d\n", ans[3]);
	return 0;
}


Measured memory_bytes: 1724
import java.util.Scanner;
import java.util.ArrayList;
        
public class Main {

    public static void main(String[] args) {
        
        ArrayList<String> task = new ArrayList<>();
        Scanner scanner = new Scanner(System.in);
        int number = Integer.valueOf(scanner.nextLine());
        
        for(int i = 0; i < number; i++) {
            String whatTask = scanner.nextLine();
            task.add(whatTask);
        }
        
        int count1 = 0;
        int count2 = 0;
        int count3 = 0;
        int count4 = 0;
        
        for(int i = 0; i < task.size(); i++) {
            if(task.get(i).equals("AC")) {
                count1++;
            }
            
            if(task.get(i).equals("WA")) {
                count2++;
            }
            
            if(task.get(i).equals("TLE")) {
                count3++;
            }
            
            if(task.get(i).equals("RE")) {
                count4++;
            }
        }
        
        System.out.println("AC x " + count1);
        System.out.println("WA x " + count2);
        System.out.println("TLE x " + count3);
        System.out.println("RE x " + count4);
        
        
        
    }
}

Measured memory_bytes: 65212
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
long long combi(long long n, long long k) {
	if (n == k || k == 0)
		return 1;
	else {
		return combi(n - 1, k - 1) + combi(n - 1, k);
	}
}
int main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> a(q);
	REP(i, q) {
		cin >> a[i];
	}
	vector<int> b(n,0);
	REP(i, q) {
		b[a[i] - 1]++;
	}
	REP(i, n) {
		if (b[i] + k > q) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;
}

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

int mod_pow(long long int a, long long int e, int p){
    long long int res = 1;
    for(;e>0;e>>=1){
        if(e&1)res=(res*a)%p;
        a=(a*a)%p;
    }
    return (int)res;
}

int fact(int n, int p){
    static int F[1000001];
    if(F[n]) return F[n];
    else{
        F[0]=1;
        for(long long int i=1;i<=1000000;i++){
            F[i]=i*F[i-1]%p;
        }
        return F[n];
    }

    long long int res=1;
    while(n){
        res*=n;
        if(res>p)res%=p;
        if(res==0)return 0;
        n--;
    }
    return (int)res;
}

int mod_fact(int n,int p,int &e){
    static int F[1000001];
    if(F[n]) return F[n];
    e=0;
    if(n==0)return 1;
    long long int res=mod_fact(n/p,p,e);
    e+=n/p;
    if(n/p%2!=0) return F[n]=res*(p-fact(n%p,p))%p;
    return F[n]=res*fact(n%p,p)%p;
}

int mod_comb(int n, int k,int p){
    if(n<0||k<0||n<k)return 0;
    int e1,e2,e3;
    long long int a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
    //if(e1>e2+e3)return 0;
    //return (a1*mod_inverse(a2*a3%p,p))%p;
    return a1*mod_pow(a2*a3%p,p-2,p)%p;
}

int main(){
    int64_t N,M,K;
    cin>>N>>M>>K;
    int64_t sum=0;
    int64_t mod=1000000007;
    for(int i=2;i<=M;i++){
        int64_t s=N*N%mod;
        (s*=M-i+1)%=mod;
        (s*=i-1)%=mod;
        (sum+=s)%=mod;
    }
    for(int i=2;i<=N;i++){
        int64_t s=M*M%mod;
        (s*=N-i+1)%=mod;
        (s*=i-1)%=mod;
        (sum+=s)%=mod;
    }
    (sum*=mod_comb(N*M-2,K-2,mod))%=mod;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int toMinute(int h, int m){
    return h*60+m;
}

int toIndex(int h, int m){
    int minute = toMinute(h, m);
    if(660 <= minute && minute <= 899){
        return 0;
    }else if(1080 <= minute && minute <= 1259){
        return 1;
    }else if(1260 <= minute && minute <= 1559){
        return 2;
    }
    return -1;
}

int main(){
    // printf("%d, %d\n", toMinute(11, 0), toMinute(14, 59)); => 660, 899(lunch)
    // printf("%d, %d\n", toMinute(18, 0), toMinute(20, 59)); => 1080, 1259(dinner)
    // printf("%d, %d\n", toMinute(21, 0), toMinute(25, 59)); => 1260, 1559(midnight)

    int N;
    while(std::cin >> N, N){
        int RN[3], RON[3];
        std::fill(RN, RN+3, 0);
        std::fill(RON, RON+3, 0);

        REP(i, N){
            int h, m1, m2;
            scanf("%d%*c%d %d", &h, &m1, &m2);

            if(h <= 1){h += 24;}
            if(m1 > m2){m2 += 60;}

            int index = toIndex(h, m1);
            if(index == -1){continue;}

            RN[index]++;
            if(m2 - m1 <= 8){RON[index]++;}
        }

        std::string time[3] = {"lunch", "dinner", "midnight"};
        REP(i, 3){
            if(RN[i] > 0){
                std::cout << time[i] << " " << (100 * RON[i] / RN[i]) << std::endl;
            }else{
                std::cout << time[i] << " no guest" << std::endl;
            }
        }
    }
}

Measured memory_bytes: 1256
# 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>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstdlib>
using namespace std;

#define Rep(i,l,r) for (int i = (l); i <= (r); ++ i)
#define RepD(i,r,l) for (int i = (r); i >= (l); -- i)
#define RepG(i,x) for (int i = hd[x]; i; i = e[i].nxt)

typedef long long ll;

const int N = 2e5+5;

int n, a[N], pre[N][29], pos[N];

int main() {
	ll ans = 0;
	scanf ("%d", &n);
	Rep(i,1,n) scanf ("%d", &a[i]);
	Rep(j,0,20) {
		int lst = 0;
		Rep(i,1,n) {
			pre[i][j] = lst;
			if ((a[i]>>j)&1) lst = i, pos[i] = max (pos[i], pre[i][j]);
			else pos[i] = max (pos[i], pre[pre[i][j]][j]);
		}
	}
	Rep(i,1,n) ans += i-pos[i];
	printf ("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 24448
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 20 + 47;

int A[MAX][MAX];
int B[MAX][MAX];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m;
	cin >> n >> m;
	FOR(i, 0, n)
	{
		string s;
		cin >> s;
		FOR(j, 0, SZ(s)) A[i][j] = s[j] == '#';
	}
	
	int len = n + m - 2;
	FOR(mask, 0, 1 << len)
	{
		FOR(i, 0, n) FOR(j, 0, m) B[i][j] = A[i][j];

		int x = 0, y = 0;
		FOR(k, 0, len + 1)
		{
			if (x >= n || y >= m) break;
			if (B[x][y] == 0) break;
			
			B[x][y] = 0;
			if (mask & (1 << k))
			{
				y++;
				continue;
			}

			x++;
		}

		int cnt = 0;
		FOR(i, 0, n)
		{
			FOR(j, 0, m)
			{
				if (B[i][j]) cnt++;
			}
		}

		if (cnt == 0)
		{
			cout << "Possible" << endl;
			return 0;
		}
	}

	cout << "Impossible" << endl;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n;
	cin >> n;
	vector<int> op(n);
	vector<int> cl(n);
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		op[l]++;
		cl[r]++;
	}	
	int bl = 0;
	int c = 0;
	for (int i = 0; i < n; i++) {
		bl += op[i];
		c += (bl == m);
		bl -= cl[i];
	}
	cout << c << endl;
}


Measured memory_bytes: 1024
package main
import (
  // "bufio"
  // "os"
  "strconv"
  // "strings"
  "fmt"
  // "math"
  // "sort"
)

// 行単位で読み込む場合
// var sc = bufio.NewScanner(os.Stdin)

func main() {
  var S string
  fmt.Scan(&S)

  ans := 999

  for i := 0; i < len(S) - 2; i++ {
    str := S[i:i+3]
    num, _ := strconv.Atoi(str)
    num -= 753
    if num < 0 {
      num *= -1
    }
    if num < ans {
      ans = num
    }
  }

  fmt.Println(ans)

}

Measured memory_bytes: 512
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,re1=0,h,w,count=0;
    string s;
    cin>>a>>b;
    cout<<((a+b)%2==0 ? (a+b)/2 : (a+b)/2+1)<<'\n';
    return(0);
}

Measured memory_bytes: 256
h, w = (int(i) for i in input().split())
a = [input() for i in range(h)]
for i in range(h+2):
    for j in range(w+2):
        if i == 0 or i == h+1 or j == 0 or j == w+1:
            print("#",end="")
        else:
            print(a[i-1][j-1],end="")
    print()

Measured memory_bytes: 42584
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s;
    rep(i,Size(s)-1){
        if(s[i]==s[i+1]){
            Cout("Bad");
            return 0;
        }
    }
    Cout("Good");
    return 0;
}


Measured memory_bytes: 256
N=int(input())
b=list(map(int,input().split()))
flag=True
a=list()
for j in reversed(range(0,N)):
  if flag==False:
    break
  flag=False
  for i in reversed(range(0,j+1)):
    if b[i]==i+1:
      a.append(i+1)
      del b[i]
      flag=True
      break
if len(a)!=N:
  print(-1)
else:
  for i in reversed(range(0,N)):
    print(a[i])

Measured memory_bytes: 3064
n = int(input())
v = list(map(int, input().split()))

from collections import Counter

def minus(lis):
    if len(set(lis))==1:
        return lis[0], 0, 10**9
    c = Counter(lis)
    f_key = max(c, key=c.get)
    second,first = sorted(c.values())[-2:]
    return f_key,len(lis)-first,len(lis)-second

def solve(n,v):
    if len(set(v))==1:
        return n//2
    Odd = [v[i] for i in range(n) if i%2==1]
    Even = [v[i] for i in range(n) if i%2==0]
    odd_key, odd_f,odd_s = minus(Odd)
    # print(odd_key, odd_f,odd_s)
    even_key, even_f,even_s = minus(Even)
    if odd_key == even_key:
        return min(odd_f+even_s,even_f+odd_s)
    # print(odd,even)
    return odd_f + even_f
print(solve(n,v))

Measured memory_bytes: 16100
import math
Q = int(input())
for _ in range(Q):
    A, B = list(map(int, input().split()))

    div = A * B
    ca = int(math.sqrt(div))
    if ca == A:
        ca += 1
    result = ca - 1
    if A <= ca:
        result -= 1
    cand = float("inf")
    while True:
        if ca == A:
            ca += 1
        cb = min(div // ca, cand)
        if cb * ca == div:
            cb -= 1
        if cb == B:
            cb -= 1
        if cb == cand:
            result += cb - 1
            if B <= cand:
                result -= 1
            break
        cand = cb
        result += 1
        # print(ca, cand, result)
        ca += 1
        if cb == 1 or ca == 1:
            if B <= cand:
                result -= 1
            break
    print(result)


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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int K = (int)(1e5) + 1;

  int N; cin >> N;
  vector<int> S(K);
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    S.at(a)++;
  }
  int even = 0;
  int odd = 0;
  for (int i = 0; i < K; i++) {
    if (S.at(i) == 0) continue;
    else if (S.at(i) % 2 == 0) even++;
    else odd++;
  }
  int ans = even % 2 == 0 ? odd + even : odd + even - 1;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 640
def main():
    import sys
    input = sys.stdin.readline
    
    N,K = map(int,input().split())
    BMAP = [[0]*(2*K) for j in range(2*K)]
    WMAP = [[0]*(2*K) for j in range(2*K)]
    
    for i in range(N):
        x,y,c = input().split()
        x = int(x)%(2*K)
        y = int(y)%(2*K)
        if c == "B":
            BMAP[y][x] += 1
        else:
            WMAP[y][x] += 1
    
    import copy
    Bruiseki =  copy.deepcopy(BMAP)
    Wruiseki =  copy.deepcopy(WMAP)
    
    for i in range(2*K):
        for j in range(1,2*K):
            Bruiseki[i][j] += Bruiseki[i][j-1]
            Wruiseki[i][j] += Wruiseki[i][j-1]
    
    for i in range(2*K):
        for j in range(1,2*K):
            Bruiseki[j][i] += Bruiseki[j-1][i]
            Wruiseki[j][i] += Wruiseki[j-1][i]
    
    ans = 0
    for i in range(K):
        for j in range(K):
            Bone = Bruiseki[i][j]
            Btwo = Bruiseki[i][j+K] - Bone
            Bthree = Bruiseki[i][2*K-1] - Bruiseki[i][j+K]
            Bfour = Bruiseki[i+K][j] - Bone
            Bfive = Bruiseki[i+K][j+K] - Bone - Btwo - Bfour
            Bsix = Bruiseki[i+K][2*K-1] - Bruiseki[i+K][j+K] - Bthree
            Bseven =  Bruiseki[2*K-1][j] - Bruiseki[i+K][j]
            Beight = Bruiseki[2*K-1][j+K] - Bruiseki[i+K][j+K] - Bseven
            Bnine = Bruiseki[2*K-1][2*K-1] - Bruiseki[2*K-1][j+K] - Bthree - Bsix
            
            Wone = Wruiseki[i][j]
            Wtwo = Wruiseki[i][j+K] - Wone
            Wthree = Wruiseki[i][2*K-1] - Wruiseki[i][j+K]
            Wfour = Wruiseki[i+K][j] - Wone
            Wfive = Wruiseki[i+K][j+K] - Wone - Wtwo - Wfour
            Wsix = Wruiseki[i+K][2*K-1] - Wruiseki[i+K][j+K] - Wthree
            Wseven =  Wruiseki[2*K-1][j] - Wruiseki[i+K][j]
            Weight = Wruiseki[2*K-1][j+K] - Wruiseki[i+K][j+K] - Wseven
            Wnine = Wruiseki[2*K-1][2*K-1] - Wruiseki[2*K-1][j+K] - Wthree - Wsix
            
            tmp1 = Wone+Wthree+Wfive+Wseven+Wnine + Btwo+Bfour+Bsix+Beight
            tmp2 = Bone+Bthree+Bfive+Bseven+Bnine + Wtwo+Wfour+Wsix+Weight
            
            if tmp1 > ans:
                ans = tmp1
            if tmp2 > ans:
                ans = tmp2
            
    print(ans)

    
    
main()

Measured memory_bytes: 166024
using System;

namespace Sample1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int a = int.Parse(input.Split(' ')[0]);
            int b = int.Parse(input.Split(' ')[1]);
            int c = int.Parse(input.Split(' ')[2]);
            int answer = 0;
            for(int i = a; i <= b; i += 1)
            {
                if(c % i == 0)
                {
                    answer += 1;
                }
            }
            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 9100
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a < b) {
            if (b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else if (a < c) {
                System.out.printf("%d %d %d\n", a, c, b);
            } else {
                System.out.printf("%d %d %d\n", c, a, b);
            }
        } else {
            if (a < c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else if (b < c) {
                System.out.printf("%d %d %d\n", b, c, a);
            } else {
                System.out.printf("%d %d %d\n", c, b, a);
            }
        }
    }
}



Measured memory_bytes: 26432
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
   int n;
   cin>>n;
   
   vector<int> a(10,0);

   rep(i,n){
      int x;
      cin>>x;
      if(x>=3200){
         a[8]++;
         continue;
      }
      a[x/400]++;
   }

   int a1=0,a2=0,a3=0;

   rep(i,8){
      if(a[i]!=0) {
         a1++;
         a2++;
      }
      if(a[i]==0){
         a3++;
      }
   }
  if(a[8]>0){
     if(a1==0) a1++;
     a2+=a[8];
  }

   cout<<a1<<" "<<a2;




   
return 0;
}



Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; // trick to explore an implicit 2D grid
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; // S,SE,E,NE,N,NW,W,SW neighbors  //GO FOR EVEN FOR 4 moves

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL POW(LL x, LL y)
{
    LL ans = 1;
    LL base = x;
    while (y)
    {
        if (y & 1)
        {
            ans *= base;
        }
        base = base * base;
        y = y >> 1;
    }
    return ans;
}

int main()
{
    fastinput;
    LL n,i,j,k,t,temp,tc;
    cin>>n>>k;
    vector<LL> v(n+1);
    v[0]=1;
    for(i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    for(i=k+1;i<=n;i++)
    {
        LL a1=i-k;
        if(v[a1]<v[i])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
        
    }

    return 0;
}


Measured memory_bytes: 4788
import java.util.*;
public class Main {
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();

		int res = 0;

		res += (K >= A) ? A : K;
		K -= A;
		if(K > 0) {
			K-= B;
		}
		if(K > 0) {
			res -= (K >= C) ? C : K;
		}
		System.out.println(res);
	}
}

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

int N, A, B, C, l[8], ans = 1e9;

void dfs(int cur, int a, int b, int c, int sum) {
    if (cur == N) {
        if (min({a, b, c}) > 0) {
            ans = min(ans, abs(a - A) + abs(b - B) + abs(c - C) + sum - 30);
        }
        return;
    }
    dfs(cur + 1, a, b, c, sum);
    dfs(cur + 1, a + l[cur], b, c, sum + 10);
    dfs(cur + 1, a, b + l[cur], c, sum + 10);
    dfs(cur + 1, a, b, c + l[cur], sum + 10);
}

int main() {
    cin >> N >> A >> B >> C;
    rep(i, N) cin >> l[i];
    dfs(0, 0, 0, 0, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int max_element(vector<int> cnt){
    int max = cnt[0];
    //int idx = 0;
    for(int i = 0; i < cnt.size();i++){
        if(max < cnt[i]){
            max = cnt[i];
            //idx = i;
        }
    }
    return max;
}
int min_element(vector<int> cnt){
    int min = cnt[0];
    //int idx = 0;
    for(int i = 0; i < cnt.size();i++){
        if(min > cnt[i]){
            min = cnt[i];
            //idx = i;
        }
    }
    return min;
}
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0;i < N; i++){
        cin >> A[i];
    }
    int max = max_element(A);
    int min = min_element(A);
    cout << (max - min) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    // dpで解く
    // dp[i円] = i円を達成するのに最小の枚数
    // dp[i+x] = dp[i-x] + 1; という漸化式

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

    vector<int> dp(n+10010, INF), coin(m);
    rep(i, m) cin >> coin[i];

    dp[0] = 0;

    rep(i, n) rep(j, m) {
        int val = coin[j];
        dp[i+val] = min(dp[i+val], dp[i]+1);
    }

    cout << dp[n] << endl;
}


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

mon = 0
for i in range(N):
    if A[i] >= B[i]:
        mon += B[i]
    else:
        mon += A[i]
        res = B[i] - A[i]
        if A[i + 1] >= res:
            A[i + 1] = A[i + 1] - res
            mon += res
        else:
            mon += A[i + 1]
            A[i + 1] = 0
    # print(mon)

print(mon)


Measured memory_bytes: 19156
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n;
    cin >> n;
    ll d[n];
    rep(i,n)cin >> d[i];
    sort(d, d+n);
    ll sum[100005];
    ll cur=0;
    rep(i,100005){
        // DEBUG{cout << i << endl;}
        while(d[cur]<i&&cur<n)cur++;
        sum[i]=cur;
    }
    ll res=0;
    rep(i,100005){
        if(sum[i]==sum[100004]-sum[i])res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1920
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    string s; cin >> s;
    int count[3] = {0,0,0};
    for(char c: s) count[c - 'a']++;
    sort(count, count + 3);
    if(count[2] - count[0] > 1) cout << "NO" << ln;
    else cout << "YES" << ln;
}


Measured memory_bytes: 512
#include <stdio.h>

void Do(int N){
  int i, K;
  char S[N];
  scanf("%s", S);
  scanf("%d", &K);
  for(i = 0;i < N;i++) if(S[i] != S[K-1]) S[i] = '*';
  printf("%s\n", S);
}

int main(void){
  int N;
  scanf("%d", &N);
  Do(N);
  return 0;
}


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

#define int long long

#define endl '\n'
#define pb push_back
#define pi acos(-1)
#define fi first
#define se second
#define si signed
#define sc(x) scanf("%lld",&(x));
#define  P pair<int,int>
int A[200005];
vector<P> v;

int n,k;
int x,y;

bool check1(int a)
{
    int _ = n - y;
    int t = y;
    int ans = 0;
    for(int i=0;i<x;i++){
        while(A[i]*A[_]>a){
            _++;
            t--;
            if(t==0)break;
        }
        ans+=t;

        if(ans>=k)return true;
        if(t==0)break;
    }
    return false;
}
void work1()
{
    int l = -1e18, r = -1;

    while(l+1<r){
        int mid = (l+r)/2;
        if(check1(mid)){
             r = mid;
        }else{
             l = mid+1;
        }
    }
    if(check1(l)){
        cout<<l<<'\n';
    }else cout<<r<<'\n';

    return ;
}
bool check3(int p)
{
    int ans = 0;
    int i = x-1,t = 0 , _ = x;
    for(;i >= 0;i--){
        while(A[i]*A[t] > p){
            t++;
            _--;
            if(_==0)break;
        }
        ans += _;
        if(A[i]*A[i]<=p)ans--;
        if(ans>= k)return true;
        if(_==0)break;
    }
    i = n - y, t = n - 1, _ = y;
     for(;i < n;i++){
        while(A[i]*A[t] > p){
            t--;
            _--;
            if(_==0)break;
        }
        ans += _;
        if(A[i]*A[i]<=p)ans--;
        if(ans>= k)return true;
        if(_ == 0)break;
    }
    return false;
}
void work2()
{
    k *= 2;

    int l = 1,r = 1e18;
    while(l+1<r){
        int mid = (l+r)/2;
        if(check3(mid)){
            r = mid;
        }else l = mid+1;
    }
    int ans =0;
    if(check3(l))ans = l;
    else ans = r;
    cout<<ans<<'\n';
}
signed main()
{
    sc(n)sc(k)
    int a = 0, b = 0, c = 0;
    for(int i=0;i<n;i++){
        sc(A[i])
        if(A[i]<0)b++,x++;
        else if(A[i]>0)c++,y++;
    }
    sort(A,A+n);
    a = ((b-1)*b)/2+ ((c-1)*c)/2;
    b = b*c;
    c = (n*(n-1))/2-a-b;
    //cout<<a<<' '<<b<<' '<<c;
    if(k > b&&k <= b+c){
        cout<<0<<'\n';
    }else if(k <= b){//<0
        work1();
    }else{//>0
        k -= b+c;

        work2();
    }
}
/**
4 1
-1 -2 2 4

5 6
-2 -3 -4 5 6

10 5
5 4 3 2 -1 0 0 0 0 0
**/


Measured memory_bytes: 1792
#include <vector>
#include <queue>
#include <iostream>
#define endl '\n'
using namespace std;
int n, m, a, b;
const int sz=1e5+1;
const int big=1*(1e5);
vector<int> g[sz];
int prv[sz],costs[sz];
bool visited[sz];
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;
queue<int> ans;

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

    cin >> n >> m;
    fill(costs,costs+sz,big);
    while (m--)
    {
        cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    pq.push(make_pair(0,1));
    while(!pq.empty()){
        auto currP=pq.top();
        pq.pop();
        int curr=currP.second;
        int cost=currP.first;
        if(visited[curr]) continue;
        visited[curr]=1;

        for(int c:g[curr]){
            if(!visited[c] && costs[c]>cost+1){
                costs[c]=cost+1;
                pq.push(make_pair(costs[c],c));
                prv[c]=curr;
            }
        }
    }
    for(int i=2;i<n+1;++i){
        if(costs[i]==big){
            cout<<"No"<<endl;
            return 0;
        }
        ans.push(prv[i]);
    }
    cout<<"Yes"<<endl;
    while(!ans.empty()){
        cout<<ans.front()<<endl;
        ans.pop();
    }
    return 0;
}


Measured memory_bytes: 11420
N = int(input())
A = [0] + list(map(int, input().split()))

X = [0] * (N+1)

S = 0
for i in range(1, N+1):
    S += A[i]

X[1] = S
for i in range(2, N+1, 2):
    X[1] -= 2 * A[i]

for i in range(2, N+1):
    X[i] = 2 * A[i-1] - X[i-1]

print(' '.join(map(str, X[1:])))


Measured memory_bytes: 85860
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();

        List<string> list = new List<string>();

        string before = sc.Next();
        list.Add(before);

        bool ok = true;
        for (int i = 0; i < n - 1; i++)
        {
            string after = sc.Next();

            if (before.Last() != after.First())
            {
                ok = false;
                break;
            }

            if (list.Contains(after))
            {
                ok = false;
                break;
            }
            list.Add(after);

            before = after;
        }

        string answer = ok ? "Yes" : "No";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13152
/**
 *    author:  tourist
 *    created: 11.03.2018 16:45:40       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  int x = 0;
  while (tt--) {
    int A, k;
    cin >> A >> k;
    while (A % k != 0) {
      int step = A / k + 1;
      int rm = A % k;
      A -= max(1, rm / step) * step;
    }
    x ^= (A / k);
  }
  cout << (x ? "Takahashi" : "Aoki") << endl;
  return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(10)]
o=[list(map(int,input().split())) for _ in range(h)]

for k in range(10):
  for i in range(10):
    for j in range(10):
      if l[i][j]>l[i][k]+l[k][j]:
        l[i][j]=l[i][k]+l[k][j]

v=[[l[j][1] if j>=0 else 0 for j in i] for i in o]
print(sum(map(sum,v)))

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define X first
#define Y second
using namespace std;

int main(){
	vector<vector<int> > table(31, vector<int>(0, 0));
	map<int, int> key;
	int num, ac;
	while(scanf("%d,%d", &num, &ac)){
		if(num==0&&ac==0)break;
		table[ac].push_back(num);
		key[num] = ac;
	}
	int n;
	while(cin >> n){
		if(cin.eof()) break;
		int count = 0;
		for(int i = 30; i >= key[n]; i--){
			if(table[i].size()) count++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1268
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
#define int long long
const int N=3e5+5;

int n;
int a[N];
int ans,sum;

bool check(int x){
    //printf("check(%lld)\n",x);
    int pos=0;//a[0]=0
    for(int i=2;i<=n+1;i+=2){
        if(a[i-1]-a[pos]<=x)if(a[i]>a[pos])pos=i;//BUG#1:没判大小关系
    }
    //printf("pos=%lld\n",pos);
    return a[n]-a[pos]<=x;
}
signed main(){
    scanf("%lld",&n);
    FOR(i,1,n)scanf("%lld",&a[i]),sum+=a[i];
    int c[2]={0,0};
    FOR(i,1,n)c[i&1]+=a[i];
    if(c[0]<c[1])swap(c[0],c[1]);
    if(n%2==0){
        printf("%lld %lld\n",c[0],c[1]);
        return 0;
    }
    for(int i=1;i<=n;i+=2)a[i]=-a[i];
    //FOR(i,1,n)printf("%lld%c",a[i]," \n"[i==n]);
    for(int i=2;i<=n;i+=2)ans+=a[i];
    FOR(i,2,n+1)a[i]+=a[i-1];
    int l=-1e9,r=1e9,mid;
    while(l<r)mid=floor((l+r+0.0)/2),check(mid)?r=mid:l=mid+1;
    //printf("ans=%lld\n",ans);
    ans-=l;
    if(ans>c[0])printf("%lld %lld\n",ans,sum-ans);
    else printf("%lld %lld\n",c[0],c[1]);
    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    int h,w;
    cin>>h>>w;
    vector<string>b(h);
    rep(i,0,h){
        cin>>b.at(i);
    }
    int c=0;
    rep(i,0,h){
        rep(j,0,w){
            if(b.at(i).at(j)=='.')c++;
        }
    }
    vector<int>dx={0,0,1,-1};
    vector<int>dy={1,-1,0,0};
    queue<pii>q;
    q.push({0,0});
    vector<vector<int>>v(h,vector<int>(w,-1));
    v.at(0).at(0)=0;
    while(!q.empty()){
        int y=q.front().first;
        int x=q.front().second;
        q.pop();
        rep(i,0,4){
            int ny=y+dy.at(i);
            int nx=x+dx.at(i);
            if(ny<0 or h<=ny or nx<0 or w<=nx)continue;
            else if(b.at(ny).at(nx)=='#')continue;
            else if (v.at(ny).at(nx)!=-1)continue;
            v.at(ny).at(nx)=v.at(y).at(x)+1;
            q.push({ny,nx});
        }
    }
    if(v.at(h-1).at(w-1)==-1){
        cout<<"-1"<<endl;
        return 0;
    }
    cout<<c-(v.at(h-1).at(w-1)+1)<<endl;
    return 0;
}

Measured memory_bytes: 256
/*input
500000000000 500000000000 1000000000000

*/
#include<bits/stdc++.h>
#define ull         unsigned long long
#define ll             long long
#define M             1000000007
#define pb             push_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()    
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp             make_pair
#define lb             lower_bound
#define ub            upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)    for(ll int i=0;i<n;i++) a[i]=0;
#define F            first
#define S            second
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

bool DEBUG = 0;

void solve()
{
    //initialize();
    ll a,b,k;cin>>a>>b>>k;
    if (k <= a)
    {
        cout<<(a-k)<<" "<<b<<"\n";
    }
    else if (k <= (a+b))
    {
        cout<<0<<" "<<(a+b - k)<<"\n";
    }
    else
    {
        cout<<0<<" "<<0<<"\n";
    }
}


int main(void)
{
    ios
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3640