akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int used[10];
int rec(int n, int s, int x) {
  // cout << n << " " << s << endl;
  if (n==0) {
    if (s==0)
      return 1;
    else
      return 0;
  }
  int ret = 0;
  for(int i=x;i<10;i++) {
    if (used[i] == 0 && s-i>=0) {
      used[i] = 1;
      ret += rec(n-1, s-i, i+1);
      used[i] = 0;
    }
  }
  return ret;
}

int main() {
  int n, s;
  while(cin>>n>>s,n+s) {
    if (s>50||n>10) {
      cout << 0 << endl;
      continue;
    }
    memset(used,0,sizeof(used));
    cout << rec(n,s,0) << endl;
  }
}

Measured memory_bytes: 0
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

a,b = MI()

# for i in range(b+1):
#     e = bin(i)[2:]
#     f = e.zfill(10)
#     print(f)

b += 1

k = 43
ls = [0]*k
for i in range(k):
    t = 2**(i+1)
    cb = (t//2)*(b//t) + max( 0, (b%t)-(t//2) )
    ca = (t//2)*(a//t) + max( 0, (a%t)-(t//2) )
    c = cb - ca
    # print(cb,ca,c)
    if c%2==0:
        ls[i] = 0
    else:
        ls[i] = 1    
# print(ls)

ans = 0
for i in range(k):
    ans += ls[i]*(2**i)
print(ans)

Measured memory_bytes: 38384
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int, S: int):
    cur = N
    ret = []
    while cur - M > 0:
        found = False
        t = -1
        for i in range(M, 0, -1):
            if S[cur - i] == '0':
                t = i
                break
        if t > 0:
            cur -= t
            ret.append(t)
        else:
            print(-1)
            return
    ret.append(cur)
    ret.reverse()
    ret = ' '.join([str(r) for r in ret])
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    S = next(tokens)  # type: int
    solve(N, M, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10740
<?php

    $data = explode(" ", trim(fgets(STDIN)));
    $q = $data[0];
    $h = $data[1];
    $s = $data[2];
    $d = $data[3];
    $n = trim(fgets(STDIN));
    
    $x = $q * 4;
    if($x > $h * 2) $x = $h * 2;
    if($x > $s) $x = $s;
    
    $ans = 0;
    if($d<$x*2){
        $ans = (int)floor($n / 2) * $d;
        if($n%2==1) $ans += $x;
    } else $ans = $x * $n;
    
    echo (int)$ans;
    
?>

Measured memory_bytes: 4856
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

bool test(int a, int b, int c) {
    if(c - a>= 2) {
        return false;
    }
    return true;
}

void main(){
    auto s = readln().chomp();
    auto n = [0, 0, 0];
    foreach(si; s) {
        n[si - 'a']++;
    }
    n.sort();
    writeln(test(n[0], n[1], n[2]) ? "YES":"NO");
}



Measured memory_bytes: 508
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
#define lc (h<<1)
#define rc (h<<1)+1
#define lson lc,l,mid
#define rson rc,mid+1,r
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=500+10;
int n,m,r,c;
int a[maxn][maxn];

inline void file() {
	freopen("AGC016C.in","r",stdin);
	freopen("AGC016C.out","w",stdout);
}

int main() {
//	file();
	scanf("%d%d%d%d",&n,&m,&r,&c);
	if (n%r==0 && m%c==0) {
		puts("No"); return 0;
	}
	int sum=0;
	For (i,1,n) {
		For (j,1,m) {
			if (i%r==0 && j%c==0) a[i][j]=-(r*c-1)*1000-1;
			else a[i][j]=1000;
			sum+=a[i][j];
		}
	}
	if (sum<=0) puts("No");
	else {
		puts("Yes");
		For (i,1,n) {
			For (j,1,m) printf("%d ",a[i][j]); cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2560
import sys

inf = 1<<30

def solve():
    while 1:
        e = int(sys.stdin.readline().rstrip())

        if e == 0:
            return

        ans = inf

        for z in range(int(e**(1/3)) + 10):
            rest = e - z**3

            if rest < 0:
                break
                
            y = int((rest)**0.5)
            x = rest - y**2

            ans = min(ans, x + y + z)

        print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 8208
while True:
    h,w = map(int,input().split())
    if h==0 and w==0:
        break
    
    for i in range(h):
        for k in range(w):
            if (i+k)%2 == 0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


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

// vector<int> dp(100000, 1e9);

int main()
{
    // string S,T,U;
    string N;
    bool flg = true;
    cin >> N;
    rep(i,3){
        if(N[i]=='7')
            flg = false;
    }
if(flg)
    printf("No");
else
    printf("Yes");

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

int n;
int l[1001], r[1001];
int res = 0;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
	for (int i = 0; i < n; i++) res += r[i] - l[i] + 1;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n,A[50];

int solve(int i,int m){
	if(m==0){
		return 1;
	}
	if(i>=n){
		return 0;
	}
	int res=solve(i+1,m)||solve(i+1,m-A[i]);
	return res;
}

int main(void){
	int q,f;
	int m;
	scanf("%d",&n);
	for(f=0;f<n;f++){
		scanf("%d",&A[f]);
	}
	scanf("%d",&q);
	for(f=0;f<q;f++){
		scanf("%d",&m);
		if(solve(0,m)){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
	return 0;
}



Measured memory_bytes: 2052
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const int MAX_N = 500;

// trains[i][j] means the number of trains which starts from i (=L) to j (=R)
vector<vector<int>> trains;

vector<vector<int>> acc;

int main(void) {
    int N, M, Q;
    cin >> N >> M >> Q;

    trains.resize(N + 1, vector<int>(N + 1, 0));
    for (int i = 0; i < M; i++) {
        int L, R;
        cin >> L >> R;
        trains[L][R]++;
    }

    acc.resize(N + 1, vector<int>(N + 1, 0));
    for (int l = 1; l <= N; l++) {
        for (int r = l; r <= N; r++) {
            acc[l][r] = acc[l][r - 1] + trains[l][r];
        }
    }
    for (int l = 1; l <= N; l++) {
        for (int r = 1; r <= N; r++) {
            acc[l][r] += acc[l - 1][r];
        }
    }

    // for (int l = 0; l <= N; l++) {
    //     for (int r = 0; r <= N; r++) {
    //         cout << acc[l][r] << " ";
    //     }
    //     cout << endl;
    // }

    for (int i = 0; i < Q; i++) {
        int p, q;
        cin >> p >> q;
        // printf("[%d, %d]\n", p, q);
        p--;

        cout << acc[q][q] - acc[p][q] - acc[q][p] + acc[p][p] << endl;
    }

    return 0;
}


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

void fnInput(vector<string>& rvsBlue, vector<string>& rvsRed)
{
  int nBluelSiz;
  cin >> nBluelSiz;

  rvsBlue.resize(nBluelSiz);
  for (string& rsBlue : rvsBlue)
    cin >> rsBlue;

  int nRedSiz;
  cin >> nRedSiz;

  rvsRed.resize(nRedSiz);
  for (string& rsRed : rvsRed)
    cin >> rsRed;
}

int fnPointCount(const vector<string>& cnrvsBlue, 
                 const vector<string>& cnrvsRed  )
{
  map<string, int> mpCounter;

  for (string sBlue : cnrvsBlue)
    mpCounter[sBlue]++;

  for (string sRed : cnrvsRed)
    mpCounter[sRed]--;

  vector<int> vnNum;
  for (pair<const string, int> PCounter : mpCounter)
    vnNum.push_back(PCounter.second);

  auto itNum = max_element(begin(vnNum), end(vnNum));
  int nMaxCnt = max(0, *itNum);

  return nMaxCnt;
}

int main()
{
  vector<string> vsBlue;
  vector<string> vsRed;

  fnInput(vsBlue, vsRed);
  cout << fnPointCount(vsBlue, vsRed) << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


def inp(): return int(sys.stdin.readline())


def inpl(): return list(map(int, sys.stdin.readline().split()))


def inpl_str(): return list(sys.stdin.readline().split())


N, M = inpl()
print((N+M)*(N+M-1)//2 - N*M)


Measured memory_bytes: 4076
#include<bits/stdc++.h>
using namespace std;
const int N=188;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int d[2][N][N][N],n,m,sum[N][N];
char s[N][N];

bool same(int x1,int x2,int y1,int y2) {
	int tmp=sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
	return tmp==0||tmp==(x2-x1+1)*(y2-y1+1);
}

int main() {
	cin>>n>>m;
	for(int i=1;i<=n;i++) {
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;j++) sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(s[i][j]=='#');
	}
	if(same(1,n,1,m)) return cout<<0,0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			for(int k=j;k<=m;k++) {
				int l=i-1,r=n;
				while(l<r) {
					int mid=(l+r+1)>>1;
					if(same(i,mid,j,k)) l=mid;
					else r=mid-1;
				}
				d[0][i][j][k]=l;
			}
	for(int dep=1;;dep++) {
		int now=dep&1,pre=now^1;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++) {
				int p=j;
				for(int k=j;k<=m;k++) {
					if(d[pre][i][j][k]==n) d[now][i][j][k]=n;
					else {
						d[now][i][j][k]=d[pre][d[pre][i][j][k]+1][j][k];
						while(p<k&&d[pre][i][j][p]>d[pre][i][p+1][k]) ++p;
						if(j^k) {
							if(j<p) d[now][i][j][k]=max(d[now][i][j][k],min(d[pre][i][j][p-1],d[pre][i][p][k]));
							d[now][i][j][k]=max(d[now][i][j][k],min(d[pre][i][j][p],d[pre][i][p+1][k]));
						}
					}
				}
			}
		if(d[now][1][1][m]==n) return cout<<dep,0;
	}
	return 0;
}


Measured memory_bytes: 51968
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include<stack>
#include <cmath>
#include<bits/stdc++.h>
#include<math.h>
#include<iomanip>
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;

int main(){
    int n,m; cin >> n >> m;
    int a[m];
    vector<int> o(n+1,true);

    for(int i=0;i<m;i++){
        cin >> a[i];
        o[a[i]] = false;
    }
    vector<ll> dp(n+1);
    dp[0]=1;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=min(n,i+2);j++){
            if(o[j]){
                dp[j] += dp[i];
                dp[j] %= 1000000007;
            }
        }
    }
    cout << dp[n] <<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
    int w, h;
	int x, y;
	int r;
	int i;
	
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	
	if(x - r < 0){
		printf("No\n");
	}
	else if(y + r > h){
		printf("No\n");
	}
	else if(x + r > w){
		printf("No\n");
	}
	else if(y - r < 0){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(20)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

int fact[1000000], revfact[1000000];

int powmod(int a, int p){
  int res = 1, tmp = a;
  while(p != 0){
    if(p % 2)
      res = (res*tmp) % MOD;
    tmp = (tmp*tmp) % MOD;
    p /= 2;
  }
  return res;
}

void factmod(){
  fact[0] = revfact[0] = 1;
  for(int i = 1; i < 1000000; i++){
    fact[i] = (fact[i-1] * i) % MOD;
    revfact[i] = (revfact[i-1] * powmod(i, MOD-2)) % MOD;
  }
}

int nCrmod(int n, int r){ // nCr % MOD
  return (((fact[n] * revfact[r]) % MOD) * revfact[n-r]) % MOD;
}

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

  int X, Y; cin >> X >> Y;
  factmod();
  if((X+Y) % 3 != 0){
    cout << 0 << endl; return 0;
  }
  int cnt = (X+Y) / 3;
  int ans = 0;
  REP(a, cnt+1){
    int x = a + 2*(cnt-a), y = 2*a + (cnt-a);
    if(x == X and y == Y){
      ans += nCrmod(cnt, a);
      ans %= MOD;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 15872
n = int(input())
a = list(map(int,input().split()))
count = 0
for _ in range(10**6):
  for i in range(n):
    if a[i] % 2 == 0:
      a[i] = a[i]//2
      count += 1
    else:
      break
print(count//n)

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll sum = 0;
	string s;
	cin >> s;
	vector<int> v(s.length()+2);
	for (int i = 0; i < s.length() ; i++) {
		if (s.substr(i, 1) == "<") {
			v[i+1]=max(v[i+1],v[i]+1);
		}
	}
	for (int i = s.length(); i >=0 ; i--) {
		if (s.substr(i, 1) == ">") {
			v[i]=max(v[i],v[i+1]+1);
		}
	}
	for (int i = 0; i < s.length()+1; i++) {
		sum+=v[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 2844
#include<stdio.h>

int main(void){
  int A,B,C,K;
  
  scanf("%d %d %d %d",&A,&B,&C,&K);
  
  if(K<=A)
    printf("%d",K);
  
  else if(A<K && K<=A+B)
    printf("%d",A);
  
  else
    printf("%d",A*2+B-K);
  
  return 0;
  
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
const int M = 110;

int a[2][M], dp[2][M];

int main() {
	int n; scanf("%d", &n);
	for(int i = 0; i < 2; i ++) 
		for(int j = 0; j < n; j ++) 
			scanf("%d", &a[i][j]);
	dp[0][0] = a[0][0];
	for(int i = 0; i < 2; i ++) {
		for(int j = 0; j < n; j ++) {
			if(i) dp[i][j] = std::max(dp[i][j], dp[i-1][j] + a[i][j]);
			if(j) dp[i][j] = std::max(dp[i][j], dp[i][j-1] + a[i][j]);
		}
	}
	printf("%d\n", dp[1][n-1]);
}


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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 100100;
int n;
ll a[N];
ll b[N];

ll add(ll mod, ll a) {
	if (a % mod == 0)
		return 0;
	return mod - a % mod;
}

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	cin >> n;
	forn(i, n) {
		cin >> a[i] >> b[i];
	}	
	ll cur = 0;
	ford(i, n) {
		cur += add(b[i], a[i] + cur);
	}
	cout << cur << endl;
	return 0;	
}


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

int main() {
    int n; cin >> n;
    double sum = 0;

    for (int i = 0; i < n; i++) {
        double a; cin >> a;
        sum += 1 / a;
    }

    cout << 1 / sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w,n,r,c;
	cin>>h>>w>>n>>r>>c;
	string s,t;
	cin>>s>>t;
	bool safe=true;
	int cr,cc;
	cr=r;cc=c;
	rep(i,n){
		if(s[i]=='U')cr--;
		if(cr==0)safe=false;
		if(t[i]=='D'&&cr<h)cr++;
	}
	cr=r;cc=c;
	rep(i,n){
		if(s[i]=='D')cr++;
		if(cr==h+1)safe=false;
		if(t[i]=='U'&&r>1)cr--;
	}
	cr=r;cc=c;
	rep(i,n){
		if(s[i]=='L')cc--;
		if(cc==0)safe=false;
		if(t[i]=='R'&&cc<w)cc++;
	}
	cr=r;cc=c;
	rep(i,n){
		if(s[i]=='R')cc++;
		if(cc==w+1)safe=false;
		if(t[i]=='L'&&cc>1)cc--;
	}
	YN(safe);
}


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

int main() {
    string x;
    cin >> x;

    if (x >= "a" && x <= "z") {
        cout << "a";
    } else if (x >= "A" && x <= "Z") {
        cout << "A";
    } else {
        cout << "wrong input";
    }
    return 0;
}

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


template<typename T,bool directed>
struct Fordfulkerson{
  struct edge{
    ll to,cap,rev;
    edge(){}
    edge(ll to,ll cap,ll rev):to(to),cap(cap),rev(rev){}
  };

  vector<vector<edge> > G;
  vector<ll> used;

  Fordfulkerson(){}
  Fordfulkerson(ll n):G(n),used(n){}

  void add_edge(ll from,ll to,T cap){
    G[from].emplace_back(to,cap,G[to].size());
    G[to].emplace_back(from,directed?0:cap,G[from].size()-1);
  }

  T dfs(ll v,ll t,T f){
    if(v==t) return f;
    used[v]=true;
    for(ll i=0;i<(ll)G[v].size();i++){
      edge &e = G[v][i];
      if(!used[e.to]&&e.cap>0){
        T d=dfs(e.to,t,min(f,e.cap));
        if(d>0){
          e.cap-=d;
          G[e.to][e.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }

  ll flow(ll s,ll t,T lim){
    T fl=0;
    while(1){
      fill(used.begin(),used.end(),0);
      T f=dfs(s,t,lim);
      if(f==0) break;
      fl+=f;
      lim-=f;
    }
    return fl;
  }

  ll flow(ll s,ll t){
    return flow(s,t,numeric_limits<T>::max()/2);
  }

};

int main() {
  ll v,e;
  cin >> v >> e;
  Fordfulkerson<ll, true> G(v);//宣言
  for(ll i=0;i<e;i++) {
    ll f,t,c;
    cin >> f >> t >> c;
    G.add_edge(f,t,c);//辺の追加
  }
  cout << G.flow(0,v-1) << endl;//最大流計算
}


Measured memory_bytes: 3208
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	LL N, K;
	cin >> N >> K;
	if (K == 0) {
		cout << N * N << endl;
		return;
	}
	LL ans = 0;
	for (LL b = K + 1; b <= N; ++b) {
		LL ter = N / b;
		ans += (b - K) * ter;

		LL res = (N%b) - K + 1;
		if (res > 0) {
			ans += res;
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
import math
def A():
    N, M = map(int, input().split())
    if N == 1 == M:
        print(0)
        return
    ans = 0
    if N > 1:
        ans += math.factorial(N)//(2*(math.factorial(N-2)))
    if M > 1:
        ans += math.factorial(M)//(2*(math.factorial(M-2)))
    print(ans)

A()

Measured memory_bytes: 3060
N,C = map(int,input().split())

x = [0]*N
v = [0]*N

for i in range(N):
    x[i],v[i] = map(int,input().split())

lcal = [0] * N
lmax = [0] * N
rcal = [0] * N
rmax = [0] * N

rcal[0] = v[0]-x[0]
rmax[0] = rcal[0]
for i in range(1,N):
    rcal[i] = rcal[i-1] + v[i] - x[i] + x[i-1]
    rmax[i] = max(rmax[i-1],rcal[i])

lcal[0] = v[N-1] - (C - x[N-1])
lmax[0] = lcal[0]

for i in range(1,N):
    lcal[i] = lcal[i-1] + v[N-i-1] + x[N-i-1] -x[N-i]
    lmax[i] = max(lmax[i-1],lcal[i])

#print(rmax)
#print(lmax)

ans = 0

for i in range(N-1):
    ans = max(ans,rcal[i],rcal[i]+lmax[N-i-2]-x[i])
    #print(i,ans)

ans = max(ans,rcal[N-1])

for i in range(N-1):
    ans = max(ans,lcal[i],lcal[i]+rmax[N-i-2]-(C-x[N-i-1]))
    #print(i,ans)

ans = max(ans,lcal[N-1])



print(ans)

Measured memory_bytes: 21940
#include <bits/stdc++.h>
#define int long long
const int MOD = 1e9 + 7;
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 55;

int n, k;

void matrix_multiply(vector<vector<int>>& a, vector<vector<int>>& b)
{
    int len = a.size();
    vector<vector<int>> res(len, vector<int>(len, 0));
    for(int i = 0; i < len; i++)
        for(int k = 0; k < len; k++)
            for(int j = 0; j < len; j++)
            {
                res[i][j] += a[i][k] * b[k][j];
                res[i][j] %= MOD;
            }
    for(int i = 0; i < len; i++)
        for(int j = 0; j < len; j++)
            a[i][j] = res[i][j];
}

int solve(int k, vector<vector<int>>& a)
{
    k--;
    int len = a.size();
    vector<vector<int>> mult(len, vector<int>(len, 0));
    for(int i = 0; i < len; i++)
        for(int j = 0; j < len; j++)
            mult[i][j] = a[i][j];
    while(k > 0)
    {
        if(k & 1)
            matrix_multiply(a, mult);
        matrix_multiply(mult, mult);
        k /= 2;
    }
    int ans = 0;
    for(int i = 0; i < len; i++)
        for(int j = 0; j < len; j++)
        {
            ans += a[i][j];
            ans %= MOD;
        }
    return ans;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    vector<vector<int>> a(n, vector<int>(n, 0));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> a[i][j];
    cout << solve(k, a) << "\n";
    return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;
struct point{int x, y;};
int main (void) {
    while (1) {
        int N;
        cin >> N;
        if (N == 0) break;
        vector<int> n(N);
        vector<int> d(N);
        for (int i = 0; i < N-1; i++) {
            cin >> n[i] >> d[i];
        }
        int xmin =0,xmax = 0;
        int ymin = 0,ymax = 0;
        vector<point> v;
        point a;
        a.x = 0;
        a.y = 0;
        v.push_back(a);
        for(int i=0; i< N-1; i++){
            point b;
            int num = n[i];
            int dir = d[i];
            b.x = v[num].x;
            b.y = v[num].y;
            if(dir == 0){
                b.x--;
            }
            else if(dir == 1){
                b.y++;
            }
            else if(dir == 2){
                b.x++;
            }
            else{
                b.y--;
            }
            v.push_back(b);
            xmin = min(xmin, b.x);
            xmax = max(xmax, b.x);
            ymin = min(ymin, b.y);
            ymax = max(ymax, b.y);
        }

        cout << (xmax - xmin + 1) << " " << (ymax - ymin + 1) << endl;


    }
}


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

using namespace std;

int main(){
	#ifdef EVAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int N,X;
	cin >> N >> X;
	vector <int> v(N);
	for(int i = 0; i < N; i++){
		cin >> v[i];
	}
	int ans = 1;
	long long int cur = 0;
	for(int i = 0; i < N; i++){
		cur += v[i];
		if(cur <= X){
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIGN(x) (((x)>0)?1:(((x)<0)?-1:0))
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;
#define vv(t) vector< t > 
#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))
template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long N, long long K, std::vector<long long> a);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int cnt=0;
    REP(i, 1000){
        int tmp = i;
        int k = 0;
        bool flg = true;
        REP(j, 3){
            char c = (tmp % 10) + '0';
            while(k<N){
                if(c==S[k]){
                    break;
                }
                k++;
            }
            if(k == N){
                flg = false;
                break;
            }
            k++;
            tmp /= 10;
        }
        if(flg){
            cnt++;
        }
    }
    cout << cnt << el;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  cout << v[n - 1] - v[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main()
{
    long long n;
    cin >> n;
    if (n == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    long long num = n;
    map<long long, long long> dic;
    for(long long i = 2; i * i <= n; ++i)
    {
        long long r = num % i;
        while (r == 0)
        {
            ++dic[i];
            num = num / i;
            r = num % i;
        }
    }
    if (num != 1)
    {
        ++dic[num];
    }
    
    if (dic.empty())
    {
        cout << 1 << endl;
        return 0;
    }
    long long ans = 0;
    for (const auto& e : dic)
    {
        long long cnt = 0;
        long long ex = e.second;
        long long i = 1;
        while(ex > 0)
        {
            ex -= i;
            if (ex < 0) break;
            ++cnt;
            ++i;
        }
        ans += cnt;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
int main(){
    ll N, M, K;
    cin >> N >> M;
    vl ans(M + 1);
    for(int i = 0; i <= M; i++){
        ans.at(i) = 0;
    }
    ll a = 0;
    for(int i = 0; i < N; i++){
        cin >> K;
        for(int i = 0; i < K; i++){
            cin >> a;
            ans.at(a)++;
        }
    }
    ll all = 0;
    for(int i = 0; i <= M; i++){
        if(ans.at(i) == N){
            all++;
        }
    }
    cout << all << endl;
    return 0;
}

Measured memory_bytes: 256
import math

data = input().split()

t = int(data[0])
a = int(data[1])
n = int(data[2])

for i in range(1,n+1):
    if i % 2 == 1 or i == 1:
        if t % 2 == 1:
            t  = t - 1
            t =  t /2
            a = a + t
        else:
            t =  t /2
            a = a + t
    else:
        if a % 2 == 1:
            a  = a - 1
            a =  a / 2 
            t = a + t
        else:
            a =  a / 2
            t = a + t
    
    ans = [str(math.floor(t)),str(math.floor(a))]
print(" ".join(ans))
    

Measured memory_bytes: 3064
from heapq import *

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

# 0 <= i <= N
# left_Nth_max_sum[i] == sum( sorted(As[:N+i], reverse=True)[:N] )
# right_Nth_min_sum[i] == sum( sorted(As[N+i:])[:N] )

left_Nth_max_sum = [0] * (N+1)
lpq = As[:N] # left priority queue
heapify(lpq)
left_Nth_max_sum[0] = sum(lpq)
for i in range(N):
    popped_A = heappushpop(lpq, As[N+i])
    left_Nth_max_sum[i+1] = left_Nth_max_sum[i] + As[N+i] - popped_A

right_Nth_min_sum = [0] * (N+1)
rpq = [-A for A in As[2*N:]]
heapify(rpq)
right_Nth_min_sum[N] = -sum(rpq)
for i in range(N-1, -1, -1):
    popped_A = -heappushpop(rpq, -As[N+i])
    right_Nth_min_sum[i] = right_Nth_min_sum[i+1] + As[N+i] - popped_A

"""
for i in range(N+1):
    assert left_Nth_max_sum[i] == sum( sorted(As[:N+i], reverse=True)[:N] )
    assert right_Nth_min_sum[i] == sum( sorted(As[N+i:])[:N] )
"""

print(max( (left_Nth_max_sum[i] - right_Nth_min_sum[i] for i in range(N+1)) ))

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

#ifdef YUCHIKIDEBUG
  #define dump(x)  cerr << #x << " = " << (x) << endl;
  #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#else
  #define dump(x) ;
  #define debug(x) ;
#endif // YUCHIKIDEBUG

#define int long long
#define pb push_back

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _repr(i,n) repir(i,n,0)
#define repir(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define repr(...) _overload3(__VA_ARGS__,repir,_repr,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define CINV(x,n) rep(temporary_index,n){int x##temp; cin >> x##temp; x.push_back(x##temp);}
#define REV(x) reverse(all(x))
#define SORT(x) sort(all(x))
#define PUTS(x) cout<<(x)<<endl;

inline int sqr(int x) { return x * x; }
inline int sqrti(int x) { return (int)sqrt(x); }

const long long MAXN = 1e6;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

#define put PUTS

signed main(){
    int N; cin >> N;
    vector<int> As, Bs, Cs;
    CINV(As, N); CINV(Bs, N); CINV(Cs, N);
    SORT(As); SORT(Bs); SORT(Cs);
  
    int i = 0;
    vector<int> bCounts;
    for(auto B : Bs)
    {
      while (As[i] < B && i < N) i++;
      bCounts.pb(i);
    }

    int ans = 0;
    int j = 0;
    int bSum = 0;
    for(auto C : Cs)
    {
      while (Bs[j] < C && j < N) {
        bSum += bCounts[j];
        j++;
      }
      ans += bSum;
    }

    put(ans);
    return 0;
}


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

using namespace std;

int n, a, b;

int main (){
	scanf("%d%d%d", &n, &a, &b);
	
	
	if((b - a) % 2 == 0){
		printf("Alice\n");
	}else{
		printf("Borys\n");
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		if (k%2 == 1) System.out.println((k/2)*(k/2+1));
		else System.out.println((k/2)*(k/2));

	}



}

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


int main() {
    int N;
  cin >> N;
    long long Ans = 0;

    for(int i = 0; i < N+1; i++){
        if(i%3 == 0 || i%5 == 0) continue;
        Ans += i;
    } 

    cout << Ans << endl;



}

Measured memory_bytes: 3616
n, y = map(int, input().split())

for a in range(0, n+1):
    for b in range(0, n-a+1):
        if 10000 * a + 5000 * b + 1000 * (n-(a+b)) == y:
            print(a, b, n-(a+b))
            exit()

print("-1 -1 -1")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    string S;  cin >> S;

    int ans = 0;
    while(true){
        //cout << S << endl;
        if(S.length()==1) break;

        if(S.front() == S.back()){
            if(S.length() == 2) break;
            else S = S.substr(1, S.length()-2);
        }else if(S.front()=='x'){
            S = S + "x";
            ans++;
        }else if(S.back() == 'x'){
            S = "x" + S;
            ans++;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN= 1e5 + 10;

int f[MAXN],n;
ll m;
int q;

int find(int x)
{
    int t = x;
    while (f[x] != x) x = f[x];
    while (f[t] != t)
    {
        int tmp = f[t];
        f[t] = x;
        t = tmp;
    }
    return x;
}

void insert(int x,int y)
{

    int fx = find(x),fy = find(y);
    if (fx != fy)
    {
        f[fx] = fy;
    }
}

struct node{
    int u,v;
}opt[MAXN];

int num[MAXN],check[MAXN];

int main()
{
    scanf("%d%lld%d",&n,&m,&q);
    for (int i = 0;i<n;i++) f[i] = i;
    int len = 0;
    for (int i = 1,u,v,c;i<=q;i++)
    {
        scanf("%d%d%d",&u,&v,&c);
        num[u] = num[v] = 1;
        if (c == 0) insert(u,v);
        else
        {
            opt[++len].u = u;
            opt[len].v = v;
        }
    }
    
    for (int i = 1;i<=len;i++)
    {
        int fx = find(opt[i].u),fy = find(opt[i].v);
        if (fx == fy)
        {
            cout<<"No";
            return 0;
        }
    }
    ll cnt = 0;
    for (int i = 0;i<n;i++) if (f[i] == i) cnt++;
    ll minn,maxn;
    if (len == 0)
    {
        minn = cnt - 1;
        maxn = (cnt - 1) * cnt / 2;
    }
    else
    {
        minn = max((ll)3,cnt);
        maxn = (cnt - 1) * cnt / 2;
    }    
    m -= (n - cnt);
    //cout<<cnt<<' '<<minn<<' '<<maxn<<'\n';
    if (minn <= m && m <= maxn) printf("Yes");
    else cout<<"No";
    return 0;
}


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

#define M (60)
#define H (3600)

int main()
{
	int h, m, s;
	
	while (cin >> h >> m >> s, h != -1, m != -1, s != -1){
		int t = 120 * 60;
		
		t -= (h * 3600 + m * 60 + s);
		
		printf("%02d:%02d:%02d\n", t / H, t % H / M, t % M);
		t *= 3;
		printf("%02d:%02d:%02d\n", t / H, t % H / M, t % M);
	}
	
	return (0);
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1e9 + 7;

int main2() {
  ll N = nextLong();

  ll ans = 1;
  REP(i, N) ans = (ans * 10) % MOD;

  ll a = 1;
  REP(i, N) a = (a * 9) % MOD;
  ans -= 2 * a;

  ll b = 1;
  REP(i, N) b = (b * 8) % MOD;
  ans += b;
  ans = (ans % MOD + MOD) % MOD;

  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3716
import java.util.*;

public class Main {
    static public void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int firsta = sc.nextInt();
        int prea = firsta, maxdis = 0, nowa = 0;

        for (int i = 0; i < n - 1; i++) {
            nowa = sc.nextInt();
            maxdis = Math.max(maxdis, nowa - prea);
            prea = nowa;
        }

        maxdis = Math.max(maxdis, firsta + k - nowa);

        System.out.println(k - maxdis);

    }
}

Measured memory_bytes: 63236
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    //freopen("A.txt","r",stdin);
    //freopen("A.txt","w",stdout);
    ios_base::sync_with_stdio(0);

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int s1=a+b;
    int s2=c+d;
    if(s1>s2)
    {
        cout<<"Left"<<endl;
    }

    if(s1<s2)
    {
        cout<<"Right"<<endl;
    }
    if(s1==s2)
    {
        cout<<"Balanced"<<endl;
    }
}




Measured memory_bytes: 256
# ABC074-B
N = int(input())
K = int(input())
x = list(map(int, input().split()))
ans = 0
for i in range(N):
    if x[i] <= K / 2:
        ans += x[i] * 2
    else:
        ans += (K - x[i]) * 2
        
print(ans)        

Measured memory_bytes: 3060
/*author - Ashutosh Chitranshi*/
#include<bits/stdc++.h>
using namespace std;
#pragma GCC push_options
#pragma GCC optimize ("unroll-loops")
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define pow2(x) ((x)*(x))
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define mp make_pair
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vi > vvi;
typedef vector< vl > vvl;
typedef pair< int,int > ii;
typedef pair< ll,ll> pll;
typedef map< ll,ll> mll;
typedef map< int,int> mii;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    ll dist = abs(a-b);
    if(a == b)
    {
    	cout << "YES\n";
    	exit(0);
    }
    if(w >= v)
    {
    	cout << "NO\n";
    	exit(0);
    }
    ll time = ceil(1.0*dist/(v-w));
    if(time <= t)
    {
    	cout << "YES\n";
    }
    else
    {
    	cout << "NO\n";
    }
    return 0;
}

Measured memory_bytes: 3756
#[allow(unused_imports)]
use std::cmp::Reverse;

#[allow(unused_imports)]
use proconio::{fastout, input, marker::Chars};

#[allow(unused_imports)]
use itertools::Itertools;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        p: [f64; n],
    }

    let mut dp = vec![vec![0.0; n + 1]; n + 1];
    dp[0][0] = 1.0;
    for i in 0..n {
        for j in 0..=i {
            dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
            dp[i + 1][j + 1] += dp[i][j] * p[i];
        }
    }
    println!("{:.10}", dp[n][n / 2 + 1..].iter().sum::<f64>());
}


Measured memory_bytes: 72476
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;

int main() {
  string t;
  cin >> t;
  ll score = 0;
  rep(i, t.size()) {
    if (t[i] == '?') t[i] = 'D';
  }
  //置き換え
  // rep(i, t.size() - 1) {  // 0~n-1
  //   if (t[i] == 'P' && t[i + 1] == 'D') score++;
  //   if (t[i] == 'D') score++;
  // }
  cout << t;
  return 0;
}


Measured memory_bytes: 3756
N = int(input())
s = [input() for i in range(N)]
minAB = 0
AB = [0, 0]
count = 0
for i, x in enumerate(s):
    minAB += x.count("AB")
    if x[-1] == "A":
        AB[0] += 1
    if x[0] == "B":
        AB[1] += 1
        if x[-1] == "A":
            count += 1
if count != max(AB) or count == 0:
    print(minAB + min(AB))
else:
    print(minAB + min(AB)-1)


Measured memory_bytes: 3700
// 2011/11/21 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){

	int n;
	cin >> n;

	if(n==0)
		break;

	int m = 1000-n;

	int sum = 0;

	sum += m/500;
	m %= 500;

	sum += m/100;
	m %= 100;

	sum += m/50;
	m %= 50;

	sum += m/10;
	m %= 10;

	sum += m/5;
	m %= 5;

	sum += m;

	cout << sum << endl;

	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
 
int main(int argc, char* argv[])
{
    long d, n;
    scanf("%ld %ld", &d, &n);

    long m = (n<100)? n: (n+1);
    while(d>0) {
        m *= 100;
        d--;
    }
    printf("%d\n", m);
 
    return 0;
}

Measured memory_bytes: 128
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    kk = 1
    for i in a:
        if i == kk:
            kk += 1
        else:
            ans += 1
    print(-1 if ans == n else ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 100624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder
{
    public class ABC_102_C
    {
        public static void Main()
        {
            var str = Console.ReadLine().Split(' ');
            var a = int.Parse(str[0]);
            var b = int.Parse(str[1]);
            var result = 0;
            
            for (int i =a;i<=b;i++){
                var s = i % 10;
                var t = i / 10000 % 10;
                var u = i / 1000 % 10;
                var v = i / 10%10;
                if(s==t&&u==v)    
                {
                    result++;
                }
            }
            Console.WriteLine(result);
            Console.Read();
        }
    }
}

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

int main(void)
{
    int n;
    cin >> n;
    if(n<10)
        cout << n << endl;
    else if(n<100)
        cout << 9 << endl;
    else if(n<1000)
        cout << n - 100 + 1 + 9 << endl;
    else if(n<10000)
        cout << 909 << endl;
    else if(n<100000)
        cout << n-10000+1+909 << endl;
        else
            cout << 90909 << endl;
        return 0;
}

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

int main() {
  int N;
  cin >> N;
  int d[N];

  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  
  sort(d, d+N, greater<int>());

  int count = 1;
  
  for (int i = 1; i < N; i++) {
    if (d[i] >= d[i-1]) {
      continue;
    }
    count++;
  } 
  cout << count << endl;

}

Measured memory_bytes: 256