akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
    int m;
    int t=0, h=0;
    char taro[100], hanako[100];
    scanf("%d", &m);

    for(int i=0; i<m; i++){
        scanf("%s %s", &taro, &hanako);
        //printf("%s, %s\n", taro, hanako);

        if(strcmp(taro, hanako) > 0){
            t = t + 3;
        }
        else if(strcmp(taro, hanako) < 0){
            h = h + 3;
        }
        else{
            t = t + 1;
            h = h + 1;
        }
    }

    printf("%d %d\n", t, h);

    return 0;
}


Measured memory_bytes: 2028
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#define REP(i, n) for(int64_t i=0;i<(n);++i)
#define FOR(i, a, b) for(int64_t i=(a);i<(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define IN(x) cin >> (x)
#define OUT(y) cout << (y) << "\n"
#define i64 int64_t
#define str string
#define coar const char
using namespace std;template<class T>T in() { T x; cin >> x; return (x); }
void Main() {

	str S; IN(S);

	if (S == "SUN") OUT('7');
	else if (S == "MON")OUT('6');
	else if (S == "TUE")OUT('5');
	else if (S == "WED")OUT('4');
	else if (S == "THU")OUT('3');
	else if (S == "FRI")OUT('2');
	else if (S == "SAT")OUT('1');
	else;
}
int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;

  cin >> N ;

  vector<int> A(N);

  for(int i=0;i<N;i++) cin >> A.at(i);//入力終了

  vector<int64_t> B(300000,0);

  for(int i=0;i<N;i++) B.at(A.at(i))++;

  int64_t ans=0;

  for(int i=1;i<=N;i++){
      int64_t c=B.at(i)*(B.at(i)-1)/2;
      ans+=c;
  }

  for(int k=0;k<N;k++) cout << ans-B.at(A.at(k))+1 << endl;

}

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

int beki2(int n){
  if(n == 0) return 1;
  return 2*beki2(n-1);
}
int main(){
  string s; cin >> s;
  string ans;
  
  int AB = stoi(s.substr(0,2));
  int CD = stoi(s.substr(2));
  
  if(13 <= AB || AB == 0){
      if(1 <= CD && CD <= 12) ans = "YYMM";
      else if(13 <= CD || CD == 0) ans = "NA";
  }
  else if(13 <= CD || CD == 0){
      if(1 <= AB && AB <= 12) ans = "MMYY";
      else if(13 <= AB || AB == 0) ans = "NA";
  }
  else if(1 <= AB && AB <= 12 && 1 <= CD && CD <= 12) ans = "AMBIGUOUS";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,ans=0;
  cin>>N;
  int M=9999999;
  while(N--)
  {
    int X;
    cin>>X;
    if(X<M)
    {
      ans++;
      M=X;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {

	string s; 
	cin >> s;

	map<char, int> ma;
	for (auto c : s)
		ma[c]++;

	for (auto pa : ma) {
		if (pa.second != 2) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes"<< endl;
	return 0;
}

Measured memory_bytes: 256
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e5+5,INF=1e18;

void solve()
{
    ll a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22)
        cout << "bust";
    else 
        cout << "win";
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
def mod_comb4(n,r,mod=10**9+7):
    if r==1:return n
    elif r==0:return 1
    else:
        num=reduce(lambda x,y:x*y%mod,range(n,n-r,-1))
        den=reduce(lambda x,y:x*y%mod,range(1,r+1))
        return num*pow(den,mod-2,mod)%mod
class mod_comb3:
    def __init__(self,mod=10**9+7,n_max=1):
        self.mod,self.n_max=mod,n_max
        self.fact,self.inv,self.factinv=[1,1],[0,1],[1,1]
        if 1<n_max:setup_table(n_max)
    def comb(self,n,r):
        if r<0 or n<r:return 0
        if self.n_max<n:self.setup_table(n)
        return self.fact[n]*(self.factinv[r]*self.factinv[n-r]%self.mod)%self.mod
    def setup_table(self,t):
        for i in range(self.n_max+1,t+1):
            self.fact.append(self.fact[-1]*i%self.mod)
            self.inv.append(-self.inv[self.mod%i]*(self.mod//i)%self.mod)
            self.factinv.append(self.factinv[-1]*self.inv[-1]%self.mod)
        self.n_max=t

def main():
    n,k=map(int,input().split())
    mod=10**9+7
    m=mod_comb3()
    for i in range(1,k+1):
        #print(mod_comb4(n-k+1,i)*mod_comb4(k-1,i-1)%mod)
        print(m.comb(n-k+1,i)*m.comb(k-1,i-1)%mod) 
if __name__=='__main__':
    main()

Measured memory_bytes: 4056
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	
	vector<vector<int> > a(n, vector<int>(m));
	vector<int> b(m);
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a.at(i).at(j);
		}
	}
	for(int i = 0; i < m; i++){
		cin >> b.at(i);
	}
	
	vector<int> c(n);
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			c.at(i) += a.at(i).at(j) * b.at(j);
		}
	}
	
	for(int i = 0; i < n; i++){
		cout << c.at(i) << endl;
	}
	
}





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

#define MODSIZE 1000000007

ll reppow(ll x,ll n){
  ll rep = 1;

  while(n > 0){
    if(n & 1) rep = (rep*x) % MODSIZE;
    x = x*x % MODSIZE;
    n >>= 1;
  }

  return rep;
}

int main(){
  int x;
  int y;
  int n;
  ll a,b;

  scanf("%d %d", &x, &y);

  if((x + y) % 3 != 0){
    printf("0\n");
    return 0;
  }

  n = (x + y)/3;
  x -= n;
  y -= n;

  if(x < 0 || y < 0){
    printf("0\n");
    return 0;
  }

  a = 1; b = 1;

  int i;

  for(i = 0;i < x;i++){
    a = (a*(x + y - i)) % MODSIZE;
    b = (b*(i + 1)) % MODSIZE;
  }

  b = reppow(b,MODSIZE - 2);

  ll ans;

  ans = (a*b) % MODSIZE;

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

  return 0;
}

Measured memory_bytes: 3832
main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  ds <- getLine :: IO String
  let
    (m, s) = foldl step (1, 0) . (zipWith (==) <$> id <*> tail) $ ds :: (Int, Int)
      where
        step :: (Int, Int) -> Bool -> (Int, Int)
        step (m, s) b | b         = (m, s + 1)
                      | otherwise = (m + 1, s)
  print $ (s + 2 * k) `min` (n - 1)


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

#define Int long long int

int main(){
    int satu[] = {10, 5, 1};
    int n;
    Int y;
    cin >> n >> y;
    y/=1000;
    bool flg = false;
    Int sum = 0;
    int an10,an5,an1;
    for(int i=0;i<=n && satu[0]*i<=y;i++){
        for(int j=0;j<=n-i && satu[0]*i+satu[1]*j<=y;j++){
            sum = satu[0]*i + satu[1]*j + satu[2]*(n-i-j);
            if(sum==y){
                flg=true;
                an10=i;
                an5=j;
                an1=n-i-j;
                break;
            }else if(sum>y)break;
        }
        if(flg)break;
    }

    if(flg)cout << an10 << " " << an5 << " " << an1 << endl;
    else cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int x = A / K;
    int X = (x+1)*K;
    
    if(A == x*K) {
      System.out.println("OK");
    } else if(A<X && X<=B) {
      System.out.println("OK");
    } else {
      System.out.println("NG");
    }
  }
}

Measured memory_bytes: 35812
N = int(input())


def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)


answer = num2alpha(N)
answer = answer.lower()

print(answer)


Measured memory_bytes: 9120
#include <stdio.h>
#include <string.h>

int main()
{
	char a[100];
	int j=0;
	scanf("%s",a);	
	/*if(a=="KIHBR"||a=="AKIHBR"||a=="KIHABR"||a=="KIHBAR"||a=="KIHBRA"||a=="AKIHABR"||a=="AKIHBAR"||a=="AKIHBRA"||a=="KIHABAR"||a=="KIHABRA"||a=="KIHBARA"||a=="AKIHABAR"||a=="AKIHABRA"||a=="KIHABARA"||a=="AKIHABARA")
	{
		printf("YES\n");
	}*/
	if(strcmp(a,"KIHBR")==0||strcmp(a,"AKIHBR")==0||strcmp(a,"KIHABR")==0||strcmp(a,"KIHBAR")==0||strcmp(a,"KIHBRA")==0||strcmp(a,"AKIHABR")==0||strcmp(a,"AKIHBAR")==0||strcmp(a,"AKIHBRA")==0||strcmp(a,"KIHABAR")==0||strcmp(a,"KIHABRA")==0||strcmp(a,"KIHBARA")==0||strcmp(a,"AKIHABAR")==0||strcmp(a,"AKIHABRA")==0||strcmp(a,"KIHABARA")==0||strcmp(a,"AKIHABARA")==0)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;		
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc043/tasks/arc059_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(s):
    ans = [-1, -1]
    if len(s) == 2:
        if s[0] == s[1]:
            return [1, 2]
        else:
            return ans

    for i, s0, s1, s2 in zip(range(1, 10**5+1), s, s[1:], s[2:]):
        if s0 == s1 or s0 == s2 or s1 == s2:
            ans = [i, i+2]
            break
    return ans


def main(args):
    s = input().strip()
    ans = solve(s)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

using namespace std;
const int maxn = 1e3 + 5;
int a[maxn];

int main()
{
    int n, k;
    while (cin >> n >> k) {
        int minn = 0x3fffff;
        int a, b;
        a = 1, b = 0;
        for (int i = 1; i <= n; i++) {
                a *= 2;
            for (int j = i + 1; j <= n; j++)
                b += k;
            minn = min(minn, a + b);
            b = 0;
        }
        cout << minn << endl;
    }
    return 0;
}


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



struct team{
    int num;
    int score;
};

bool comp(team a, team b){
    return a.score < b.score;
}

int main(){

    vector<team> t;
    int n;
    while(1){
        string s; cin >> s;
        if(s == "0,0") break;
        s += ",";
        int a, b;
        string A;
        int idx = 0;
        for(;;idx++){
            if(s[idx] == ',') break;
            else A += s[idx];
        }
        a = stoi(A);
        idx++;
        string B;
        for(;;idx++){
            if(s[idx] == ',') break;
            else B += s[idx];
        }
        b = stoi(B);
        
        team tmp;
        tmp.num = a;
        n = a;
        tmp.score = b;
        t.push_back(tmp);
    }

    vector<team> _t(n);
    for(int i = 0; i < n; i++) _t[i] = t[i];

    sort(t.begin(), t.end(), comp);
    map<int, int> m;

    int j = 2;
    m[t[n - 1].score] = 1;
    for(int i = n - 2; i >= 0; i--){
        if(t[i].score != t[i + 1].score){
            m[t[i].score] = j;
            j++;
        }
    }
    //cout << t[0].score << " " << t[n - 1].score << endl;

    int q;
    while(cin >> q){
        int sc = _t[q - 1].score;
        cout << m[sc] << endl;
    }
    return 0;
}


Measured memory_bytes: 2980
#include <stdio.h>

int main()
{
    int a, b, c, sum;
    scanf("%d %d %d", &a, &b, &c);
    sum = c - (a - b);
    if (sum < 0)
        printf("0\n");
    else
        printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

vector<int> ans[1000];

void solve(int x) {
    puts("Yes");
    int cnt = 1;
    for (int i = 0; i < x; i++) {
        for (int j = i+1; j < x; j++) {
            ans[i].push_back(cnt);
            ans[j].push_back(cnt);
            cnt++;
        }
    }
    cout << x << endl;
    rep(i,x) {
        cout << ans[i].size();
        rep(j,ans[i].size()) {
            cout << " " << ans[i][j];
        }
        cout << endl;
    }
}

int main() {
    int n;
    cin >> n;
    ll x = 2;
    while (true) {
        if (x * (x-1) / 2 > n) {
            puts("No");
            break;
        }
        if (x * (x-1) / 2 == n) {
            solve(x);
            break;
        }
        x++;
    }
}



Measured memory_bytes: 2304
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n, x, y;
	cin >> n >> x >> y;
	int a[2010][2010] = {};
	for(int i=1;i<n;i++)
		for (int j = i + 1; j <= n; j++) {
			a[i][j] = j-i;
		}

	a[x][y] = 1;
	for (int i = 1; i < n; i++) {
		int change = 0;
		for (int j = -i; j <= i; j++) {
			int k = i - abs(j);
			if ((x + j) > 0 && (x + j) <= n && (y + k) <=n) {
				if (a[x + j][y + k] > (a[x][y] + i)) { a[x + j][y + k] = (a[x][y] + i); change = 1; }
			}
			if ((x + j) > 0 && (x + j) <= n && (y - k) > 0 ) {
				if (a[x + j][y - k] > (a[x][y] + i)) { a[x + j][y - k] = (a[x][y] + i); change = 1; }
			}
		}
		if (change == 0)break;
	}

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


	return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll n;
	cin >> n;
	vl a(n);
	rep(i, n) cin >> a[i];
	bool dame = false;
	rep(i, n) {
		if (a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0)) dame = true;
	}
	if (dame) cout << "DENIED" << endl;
	else cout << "APPROVED" << endl;
	return 0;
}


Measured memory_bytes: 3588
n, k, q = map(int, input().split())

p = [k - q] * n

a = []
for _ in range(q):
    a.append(int(input()))

for i in range(q):
    p[a[i]-1] += 1

for i in range(n):
    if p[i] <= 0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 56024
#include<iostream>
using namespace std;
const int N=3e5+2;
const int inf=1e9+7;
int ar[N],sum[N][2];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,min1=0,lef=-inf,rig=inf,mid;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>ar[i];
		sum[i][1]=sum[i-1][1];
		sum[i][0]=sum[i-1][0];
		if(i&1){
			sum[i][1]+=ar[i];
		}
		else{
			sum[i][0]+=ar[i];
		}
	}
	if(!(n&1)){
		cout<<max(sum[n][0],sum[n][1])<<' '<<min(sum[n][0],sum[n][1]);
	}
	else{
		while(lef<rig){
			min1=0;
			mid=(lef+rig+1)/2;
			bool cac=false;
			for(i=2;i<=n;i+=2){
				if(sum[i-1][1]-sum[i-1][0]>=mid+min1){
					if(sum[n][1]-sum[n][0]-(sum[i][1]-sum[i][0])>=mid){
						cac=true;
						break;
					}
					min1=min(min1,sum[i][1]-sum[i][0]);
				}
			}
			if(cac){
				lef=mid;
			}
			else{
				rig=mid-1;
			}
		}
		//cout<<lef<<endl;
		cout<<max(sum[n][1],sum[n][0]+lef)<<' '<<sum[n][0]+sum[n][1]-max(sum[n][1],sum[n][0]+lef);
	}
}

Measured memory_bytes: 3840
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#define _USE_MATH_DEFINES
#include<cmath>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}

ll combination(ll n, ll r) {
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int main() {
	int n;
	cin >> n;
	vector<int>a(n), b(n);
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(all(b));
	int count = 0;
	rep(i, n) {
		if (b[i] != a[i]) {
			count++;
		}
	}
	if (count == 2 or count == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

bool f(int n) {
    int p;
    for(int i = 0; i < 3; i++) {
        // cout << n << endl;
        if(i == 0) {
            p = n % 10;
            n /= 10;
            continue;
        } else {
            if(n % 10 != p) return false;
            n /= 10;
        }
    }
    return true;
}

int main(void){
    int n;
    cin >> n;
    for(int i = 0; i < 1000; i++) {
        if(f(n + i)) {
            cout << n + i;
            break;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Control.Monad.ST
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as M
import qualified Data.Set as S

sol :: Int -> B.ByteString -> [(a, [Int])] -> B.ByteString
sol n s (idx:idxs) =
    if sz < n
        then sol (n-sz) s idxs
        else S.elemAt (n-1) sets
    where
        sz = S.size sets
        sets = foldr (\s set -> S.insert s set) S.empty ss
        ss = concatMap ps $ snd idx
        ps i = take 5 $ drop 1 $ B.inits $ B.drop i s

main = do
    s <- B.getLine
    n <- readLn
    let idx = M.toList $ foldl' (\m (c,i) -> M.insertWith (++) c [i] m) M.empty $ zip (B.unpack s) [0..]
    putStrLn $ B.unpack $ sol n s idx


Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <bits/stdc++.h>
#include <cmath>

using namespace std;

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

    vector<pair<int, int>> land(m);

    for (int i = 0; i < m; i++)
    {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        land[i] = {tmp2, tmp1};
    }

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

    int bridge = 0;
    int count = 0;

    for (int i = 0; i < m; i++)
    {
        if (land[i].second > bridge)
        {
            bridge = land[i].first - 1;
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include<cmath>
#include <limits>
using namespace std;
typedef long long ll;

typedef pair<ll, ll> P;
const int INF = 100000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
const int MOD = 1000000007;


int main() {
	int N,i,j;
	cin >> N;
	vector<ll>H(N);
	REP(i, 0, N) {
		cin >> H[i];
	}
	reverse(H.begin(), H.end());
	for (i = 0; i < N - 1; i++) {
		if (H[i + 1] > H[i]+1) {
			output("No");
			return 0;
		}
		else if (H[i + 1] == H[i]+1) {
			H[i + 1]--;
		}
	}
	output("Yes");
	return 0;
	return 0;
}



Measured memory_bytes: 1024
// AtCoder Beginner Contest - Problem B: Five Dishes (https://atcoder.jp/contests/abc123/tasks/abc123_b)
#include <bits/stdc++.h>

using namespace std;

const int oo { 1000000010 };

int solve(const vector<int> xs)
{
    vector<int> order(5);
    iota(order.begin(), order.end(), 0);

    int ans = oo;

    do {
        int t = 0;

        for (int i = 0; i < 4; ++i)
            t += 10 * ((xs[order[i]] + 9)/10);

        t += xs[order.back()];

        ans = min(ans, t);
    } while (next_permutation(order.begin(), order.end()));

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    vector<int> xs(5);

    for (int i = 0; i < 5; ++i)
        cin >> xs[i];

    auto ans = solve(xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import scala.annotation.tailrec
import scala.io.StdIn._
object Main extends App {
  val n = readInt()
  for (_ ← 0 until n) {
    println(if (isNatural(readLine.trim.map{
      case 'U' ⇒ UpStep
      case 'D' ⇒ DownStep
      case 'L' ⇒ LeftStep
      case 'R' ⇒ RightStep
      case _ ⇒ ???
    }.toList)) "Yes" else "No")
  }
  def isNatural(steps: List[Step]): Boolean = {
    steps match {
      case Nil ⇒ true
      case h::t ⇒ isNatural(t, h, RightFoot) || isNatural(t, h, LeftFoot)
    }
  }
  @tailrec def isNatural(steps: List[Step], prevStep: Step, prevFoot: Foot): Boolean = {
    steps match {
      case Nil ⇒ true
      case h::t if prevStep != h ⇒
        prevFoot match {
          case LeftFoot ⇒ h.isRightOf(prevStep) && isNatural(t, h, RightFoot)
          case RightFoot ⇒ h.isLeftOf(prevStep) && isNatural(t, h, LeftFoot)
        }
      case _ ⇒ false
    }
  }
  sealed trait Foot
  object LeftFoot extends Foot
  object RightFoot extends Foot
  sealed trait Step {
    def isRightOf(that: Step): Boolean = {
      (this, that) match {
        case (RightStep, _) ⇒ true
        case (_, RightStep) ⇒ false
        case (_, LeftStep) ⇒ true
        case (LeftStep, _) ⇒ false
        case _ ⇒ true
      }
    }
    def isLeftOf(that: Step): Boolean = {
      (this, that) match {
        case (LeftStep, _) ⇒ true
        case (_, LeftStep) ⇒ false
        case (_, RightStep) ⇒ true
        case (RightStep, _) ⇒ false
        case _ ⇒ true
      }
    }
  }
  object LeftStep extends Step
  object UpStep extends Step
  object DownStep extends Step
  object RightStep extends Step
}


Measured memory_bytes: 65728
import sys
MOD=10**9+7

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

abi=[0]*61
aze=[0]*61

for item in a:
    j=0
    #print(bin(item))
    while j<61:
        #print(j)
        if item>>j & 1:
            abi[j]+=1
        else:
            aze[j]+=1
        j+=1

        #print(abi)

result=0
i=0
while i<61:
    result+=(2**i)%MOD*abi[i]%MOD*(aze[i])%MOD

    i+=1

#print(abi[:4])

#print(aze[:4])
print(result%MOD)


"""
01
10
11
"""



"""
0001
0010
0011
0100
0101
0110
0111
"""

Measured memory_bytes: 122936
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >>N;
    string S;
    cin >> S;
    int count=0;
    int A=0;
    for(int i=0;i<N;i++){
       if(S.at(i)=='I'){
           A++;
       }
       else{
           A--;
       }
       count=max(count,A);
    }
    cout << count <<endl;
}

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

int main(){
    int N;
    cin >> N;
    bool result = false;
    for (int i=1; i<=9; i++){
        for (int j=1; j<=9; j++){
            if (i*j==N){
                result = true;
                break;
            }
        }
    }
    if (result){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i) = 0; i < (n); i++)

int main(){
  ll n, a, b = 1, c = 2;
  cin >> n;
  rep(i, n) {
    a = b + c;
    c = b;
    b = a;
  }
  cout << c << endl;
}	

Measured memory_bytes: 256
object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val n  = sc.nextLong
	
	def g(n: Long, acc: Long): Long = if (n < 2) acc else g(n / 5, acc + n / 5)
	
	println(if (n % 2 != 0) 0 else g(n / 2, 0))
}

Measured memory_bytes: 27316
import sys
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
ans = 0
a = A[0]
n = 0
if N == 1:
    print(1)
    sys.exit()
for i in range(N):
    if a == A[i]:
        n += 1
    else:
        if n % 2 == 1:
            ans += 1
        n = 1
        a = A[i]
    #print(A[i],"1",n,n%2,ans)
if A[-1] == A[-2] and n % 2 == 1:
    ans += 1
elif A[-1] != A[-2] and n % 2 == 1:
    ans += 1
print(ans)

Measured memory_bytes: 7388
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,K; cin>>N>>K;
	vector<double> p(N);
	for (int i=0; i<N; i++)
		cin>>p[i], p[i]=(1+p[i])/2;
	double ret=0, cur=0;
	for (int i=0; i<K; i++)
		cur+=p[i];
	ret=cur;
	for (int i=K; i<N; i++)
		cur+=p[i], cur-=p[i-K], ret=max(ret,cur);
	cout<<setprecision(10)<<fixed<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
  int n;
  cin>>n;
 string s=to_string(n);
  
  int zbir=0;
  for(int i=0; i<s.size(); i++)
  {
   	zbir+=s[i]-'0'; 
  }
  if(n%zbir==0)
  cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
  
  
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    H, W = MI()
    N = II()
    A = LI()

    q = deque([])
    for i, a in enumerate(A):
        for _ in range(a):
            q.append(i+1)
    # print(q)

    even = False
    for h in range(H):
        tmp = []
        for w in range(W):
            tmp.append(q.popleft())
        if even:
            print(*tmp[::-1])
        else:
            print(*tmp)
        even = not even


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9660
#include <string>
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {

	string A, B, C, S;
	int i, j, k, ans,alen,blen,clen;
	int a = 0, b, c, count = 0;
	bool judge = true;

	cin >> A >> B >> C;

	i = A.size();
	j = B.size();
	k = C.size();

	b = i - 1;
	c = j + b;
	
	S = A + B + C;

	while (judge){
		switch (S[count]) {

		case 'a':
			a++;
			if (a > i-1) {
				cout << 'A' << endl;
				judge = false;
			}
			count = a;
			break;

		case 'b':
			b++;
			if (b > i+j-1) {
				cout << 'B' << endl;
				judge = false;
			}
			count = b;
			break;

		case 'c':
			c++;
			if (c > i+j+k-1) {
				cout << 'C' << endl;
				judge = false;
			}
			count = c;
			break;

		}


	}
	return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
using namespace std;
ll a, b;
int main() {
	scanf("%lld%lld", &a, &b);
	ll ret = min(a, b / 2);
	a -= ret, b -= ret * 2;
	if (b) ret += b / 4;
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
typedef long long ll;
struct CRT {
    vector<pair<ll, ll>> v;
    void add(ll a, ll m) { v.push_back({ a, m }); } // x = a (mod m)

    set<ll> enumpr(ll n) { set<ll> V;
        for (ll i = 2; i*i <= n; i++) while (n%i == 0) V.insert(i), n /= i;
        if (n>1) V.insert(n); return V; }
    ll ext_gcd(ll p, ll q, ll& x, ll& y) {
        if (q == 0) return x = 1, y = 0, p; ll g = ext_gcd(q, p%q, y, x); y -= p / q*x; return g; }
    ll inv(ll p, ll q) { ll xx, yy, g = ext_gcd(p, q, xx, yy); if (xx<0) xx += q, yy -= p; return xx; }

    ll solve(ll mo = 1010101010101LL) {
        string s; int N = v.size(); set<ll> P; vector<int> num;
        rep(i, 0, N) { set<ll> S = enumpr(v[i].second); for(ll r : S) P.insert(r);}
        num = vector<int>(N, 0);
        for(ll r : P) { int y = 0;
            rep(x, 0, N) { num[x] = 1; int j = v[x].second; while (j%r == 0) j /= r, num[x] *= r;
                if (num[y]<num[x]) y = x; }
            rep(x, 0, N) if (x != y) {
                if (v[x].first%num[x] != v[y].first%num[x]) return -1;
                v[x].second /= num[x]; v[x].first %= v[x].second; } }
        vector<pair<ll, ll> > V2;
        rep(x, 0, N) if (v[x].second>1) V2.emplace_back(v[x].second, v[x].first);
        sort(V2.begin(), V2.end()); v = V2; N = v.size();
        rep(y, 0, N) rep(x, 0, y) { ll k = v[y].second - v[x].second; if (k<0) k += v[y].first;
            v[y].second = k*inv(v[x].first, v[y].first) % v[y].first; }
        ll ret = 0; for (int x = N - 1; x >= 0; x--) ret = (ret*v[x].first + v[x].second) % mo;
        return ret;
    }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/







int N, A[101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    int sm = 0;
    rep(i, 0, N) sm += A[i];

    int d = inf, ans = inf;
    rep(i, 0, N) {
        int dd = abs(sm - A[i] * N);
        if (dd < d) {
            d = dd;
            ans = i;
        }
    }
    cout << ans << endl;
}


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

int main(){
    int N,Ma,Mb;
    cin >> N >> Ma >> Mb;
    vector<int> a(N), b(N), c(N);
    rep(i,N) cin >> a[i] >> b[i] >> c[i];
    vector<vector<int> > dp(420, vector<int>(420));
    rep(i,420){
        rep(j,420){
            dp[i][j] = 10000000;
        }
    }
    dp[0][0] = 0;
    rep(i,N){
        for (int j = 400; j >= 0; j--){
            for (int k = 400; k >= 0; k--){
                dp[j + a[i]][k + b[i]] = min(dp[j + a[i]][k + b[i]], dp[j][k] + c[i]);
            }
        }
    }
    int count = 1;
    int ans = 10000000;
    while(true){
        if (count * Ma >= 420 || count * Mb >= 420){
            break;
        }
        else{
            ans = min(ans, dp[count * Ma][count * Mb]);
            count++;
        }
    }
    if (ans == 10000000) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 4312
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[s.size()-1]=='2' || s[s.size()-1]=='4' || s[s.size()-1]=='5' || s[s.size()-1]=='7' || s[s.size()-1]=='9')cout<<"hon";
    if(s[s.size()-1]=='0' || s[s.size()-1]=='1' || s[s.size()-1]=='6' || s[s.size()-1]=='8')cout<<"pon";
    if(s[s.size()-1]=='3') cout<<"bon";
        
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin>>n;
    map<int,int> v1,v2;
    rep(i,n){
        int x;
        cin>>x;
        if(i%2==0) v1[x]++;
        else v2[x]++; 
    }
    int max1 = 0;
    int num1 = 0;
    for(auto u : v1){
        if(u.second>max1){
            max1 = u.second;
            num1 = u.first;
        }
    }
    int max2 = 0;
    int num2 = 0;
    for(auto u : v2){
        if(u.second>max2 && u.first!=num1){
            max2 = u.second;
            num2 = u.first;
        }
    }
    int ans1 = n - max1 - max2;
    max2 = 0;
    num2 = 0;
    for(auto u : v2){
        if(u.second>max2){
            max2 = u.second;
            num2 = u.first;
        }
    }
    max1 = 0;
    num1 = 0;
    for(auto u : v1){
        if(u.second>max1 && num2!=u.first){
            max1 = u.second;
            num1 = u.first;
        }
    }
    int ans2 = n - max1 - max2;
    int ans = min(ans1,ans2);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main(){

  int d;
  cin >> d;
  
  switch(d){
    case 25: cout << "Christmas" <<endl; break;
    case 24: cout << "Christmas Eve" <<endl; break;
    case 23: cout << "Christmas Eve Eve" <<endl; break;
    case 22: cout << "Christmas Eve Eve Eve" <<endl; break;
  
  }
}


Measured memory_bytes: 256
x = int(input())

C=[]
for i in range(10*100) :
    C.append(i**5)

# print( C )

for j in range(len(C)):
    for i in range(len(C)):
        if C[j]-C[i]==x :
            print( j, i )
            exit()
        elif C[j]+C[i]==x :
            print( j, 0-(i) )
            exit()





Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b, m;
	cin>>a>>b>>m;
	int re[a], mi[b];
	for(int i = 0; i < a; ++i) cin>>re[i];
	for(int i = 0; i < b; ++i) cin>>mi[i];
	int mn  =*min_element(re, re + a) + *min_element(mi, mi  +a);
	for(int i = 0; i < m; ++i){
		int x, y, c;cin>>x>>y>>c;
		x--;--y;
		mn = min(mn, re[x] + mi[y] - c);
	}
	cout<<mn<<endl;
	return 0;
}



Measured memory_bytes: 1024
s=int(input())
jon=[]
while True:
    try:
        jon.append(input())
    except:
        break
for i in jon:
    pon=sorted(list(map(int,i.split())),reverse=True)
    if pon[0]**2==pon[1]**2+pon[2]**2:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5720
<?php
 fscanf(STDIN,"%d %d %d",$A,$B,$C);
 fscanf(STDIN,"%d",$K);
if($A>=$B)$d=$A;
else $d=$B;
if($d>=$C){}
else $d=$C;
 
if($A==$d)$all=$B+$C;
if($B==$d)$all=$A+$C;
if($C==$d)$all=$A+$B;
 
for($i=0;$i<$K;$i++){
$d*=2;
}
echo $all+$d;

Measured memory_bytes: 3956
import java.util.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		int n = in.nextInt();

		for(int i = 0; i < n; i++){
			int a = in.nextInt(), b = in.nextInt();
			int c = (a % b == 0 ? b : a % b);
			System.out.println(c);
		}
	}
	
}

// while(in.hasNext()){
		// 	int n = in.nextInt();
		// 	if(n == 0) return;
			
		// }

Measured memory_bytes: 26492
using System;
using System.Linq;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            int[] X = ReadIntArray().OrderByDescending(x => x).ToArray();
            int ans = X[0] * 10 + X[1] + X[2];
            Console.WriteLine(ans);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <functional>


using namespace std;

int e[2001][3];
long long d[1001];
long long d_prev[1001];

int main(){
  int n, m;
  cin >> n >> m;
  for (int i=0;i<=n;i++) {
    d[i] = -1000000000001;
  }
  d[1] = 0;
  for (int i=0;i<m;i++) {
    int a, b, c;
    cin >> a >> b >> c;
    e[i][0] = a;
    e[i][1] = b;
    e[i][2] = c;
  }
  for (int i=0;i<n;i++) {
    for (int j=0;j<m;j++) {
    long long new_d;
      new_d = d[e[j][0]] + e[j][2];
      if (d[e[j][1]] < new_d) {
	d[e[j][1]] = new_d;
      }
    }
  }
  for (int i=0;i<n;i++) {
    for (int j=0;j<m;j++) {
    long long new_d;
      new_d = d[e[j][0]] + e[j][2];
      if (d[e[j][1]] < new_d) {
	d[e[j][1]] = new_d;
	if (e[j][1] == n) {
	  cout << "inf" << endl;
	  return(0);
	}
      }
    }
  }
  cout << d[n] << endl;
  return(0);
}
  


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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
typedef pair<lli, int> pii;


int main()
{
    int n;
    cin >> n;
    lli a[n];
    for(auto &x: a) cin >> x;
    map<lli, lli> mp;
    lli ans = 0;
    for(int i=0; i<n; i++){
        mp[a[i]-i]++;
    }
    for(int i=0; i<n; i++){
        mp[a[i]-i]--;
        lli x = a[i]+i;
        x *= -1LL;
        ans += mp[x];
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 27832
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k;
  cin>>k;
  string s;
  cin>>s;
  int n;
  n=s.size();
  if(k>=n){
    cout<<s<<endl;
  }
  else{
    string p=s.substr(0,k);
    cout<<p<<"..."<<endl;
  }
}

Measured memory_bytes: 3628
fun main(args : Array<String> ) {
  val m:MutableMap<Char, MutableList<Char> > = mutableMapOf()
  m['a'] = readLine()!!.toMutableList()
  m['b'] = readLine()!!.toMutableList()
  m['c'] = readLine()!!.toMutableList()

  var t = 'a'
  while(true) {
    val l = m[t]
    //println(l)
    if( l!!.size == 0) {
      println(t.toString().toUpperCase())
      break
    }
    t = l[0]
    l.removeAt(0)
  }
}


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

typedef long long ll;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> edges(N);
    vector<vector<ll>> dist(N, vector<ll>(3, -1));
    for (int i = 0; i < M; i++)
    {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        edges.at(u).push_back(v);
    }
    int S, T;
    cin >> S >> T;
    queue<pair<int, int>> q;
    S--;
    T--;
    dist.at(S).at(0) = 0;
    q.push(make_pair(S, 0));
    while(!q.empty()){
        int currentNode, currentNodeStep;
        tie(currentNode, currentNodeStep) = q.front();
        q.pop();
        int nextNodeStep = (currentNodeStep + 1) % 3;
        for(int nextNode : edges.at(currentNode))
        {
            if (dist.at(nextNode).at(nextNodeStep) == -1) {
                dist.at(nextNode).at(nextNodeStep) = dist.at(currentNode).at(currentNodeStep) + 1;
                q.push(make_pair(nextNode, nextNodeStep));
            }
        }
    }
    if (dist.at(T).at(0) == -1){
        cout << -1 << endl;
    } else {
        cout << dist.at(T).at(0) / 3 << endl;
    }
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	string s;
	cin >> s;
	if(string(s.begin(), s.begin()+min(4,(int)s.size())) == "YAKI")
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

namespace kp
{
    public class Program
    {
        //static long[,] cmb;
        static int MAX_INT = 1000000007;
        static void Main(string[] args)
        {
            //long N = long.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
            int N = input[0];
            int M = input[1];

            // Mを素因数分解する
            Dictionary<int, int> factor = new Dictionary<int, int>();
            int sum = 1;
            factor.Add(1, 0);
            for (int i = 2; i <= M / 2 + 1;i++ )
            {
                while(M%i == 0)
                {
                    if(factor.ContainsKey(i))
                    {
                        factor[i] += 1;
                        sum++;
                    }
                    else
                    {
                        factor.Add(i, 1);
                        sum++;
                    }
                    M /= i;
                }

                if (M == 1)
                    break;
            }
            if (M > 1)
            {
                factor.Add(M, 1);
                sum++;

            }
            long[,] cmb = new long[sum+N, sum+1];
            // iCjの表を作る
            cmb[0,0] = 1; cmb[1,0] = 1; cmb[1,1] = 1;
            for (int i = 2; i <= sum+N-1; i++ )
            {
                for(int j=0; j<=i && j<=sum; j++)
                {
                    if(j>0)
                    {
                        long a = (cmb[i - 1, j - 1] + cmb[i - 1, j]) % MAX_INT;
                            
                        cmb[i, j] = a;
                    }
                    else
                    {
                        long a = (cmb[i - 1, j]) % MAX_INT;
                        cmb[i, j] = a;
                    }
                }
            }

            long ret = 1;
            // N-1個の仕切りと、f^?の?個の並び替えを掛け合わせる
            foreach(var f in factor.Keys)
            {
                int num = factor[f];
                // sumCnumを掛けていく
                long a = cmb[(num + N - 1), num];
                ret = (ret*a)%MAX_INT;
            }

            Console.WriteLine(ret + "");
        }
    }
}


Measured memory_bytes: 33504
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

int main()
{
    int N;
    cin >> N;
    vector<int> P(N);
    for (auto &Pi : P)
    {
        cin >> Pi;
        --Pi;
    }
    // コーナーケース
    if (N == 1){ cout << 0 << endl; return 0; }
    // 各数字がPの何番目に入っているか調べる
    vector<int> Q(N);
    for (int i = 0; i < N; ++i)
    {
        Q[P[i]] = i;
    }
    // 数字iとi+1について，（iの場所）＜（i+1の場所）ならば
    // これらについては動かす必要がない（間の数を前後に移せばよい）
    // 動かす必要がない連番のうち，最大長のもの l,l+1,...,r-1,rを探す
    // しゃくとり法で探す：O(N)
    int maxLen = 0;
    for (int l = 0; l < N - 1;)
    {
        int r = l;
        for (; r < N - 1; ++r)
        {
            if (Q[r] > Q[r + 1]) break;
        }
        maxLen = max(maxLen, r - l + 1);
        l = r + 1;
    }
    // 0,...,l-1 および r+1,...,N-1 をそれぞれ前後に動かせばよい
    cout << N - maxLen << endl;
}


Measured memory_bytes: 1792
from collections import defaultdict
import sys
input = sys.stdin.readline
N = int(input())

tree_dict = defaultdict(list)
for i in range(N-1):
    u, v, w = list(map(int, input().split()))
    tree_dict[u].append((v, w))
    tree_dict[v].append((u, w))


# 任意の1点を選んで周辺を判定していく
FROM, TO = 0, 1
q = [(TO, FROM)]

paint_dict = defaultdict(int)
# 明示的な代入
paint_dict[TO] = 0

idx = 0
while idx < N:
    # 現在のノード(now)から隣接ノード(to)の白黒を定め，そのノードを探索のqに回す
    now_node, prev_node = q[idx]
    for to_node, w in tree_dict[now_node]:
        if to_node != prev_node:
            if (w + paint_dict[now_node]) % 2 == 0:
                paint_dict[to_node] = 0
            else:
                paint_dict[to_node] = 1
            q.append((to_node, now_node))
    idx += 1
for i in range(N):
    print(paint_dict[i+1])


Measured memory_bytes: 88668