akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n;cin>>n;
    vector <int> a(n); vector <int> b(n); vector<int> c(n-1);
    rep(i,n)cin>>a[i];rep(i,n)cin>>b[i];rep(i,n-1)cin>>c[i];
    int ans = 0; rep(i,n)ans+=b[i];
    rep(i,n-1)if(a[i] - a[i+1] == -1)ans+=c[a[i]-1];
    cout<<ans<<endl;return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	private void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int H = sc.nextInt();
		final int W = sc.nextInt();
		int cnt = 0;
		for (int i=0; i< N; i++) {
			int Ai = sc.nextInt();
			int Bi = sc.nextInt();
			if(Ai>=H && Bi>=W) {
				cnt++;
			}			
		}
		System.out.println(cnt);
		sc.close();
	}

}


Measured memory_bytes: 25940
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<stack>
#include<string>


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


using namespace std;



int main(){
  stack <int>is;
  int a,b,x;
  string s;
  while(cin >> s){
    if(s[0] == '+'){
        a = is.top();is.pop();
        b = is.top();is.pop();
        is.push(a+b);
      }
    else if(s[0] == '-'){
        a = is.top(); is.pop();
        b = is.top(); is.pop();
        is.push(b-a);
      }
  else if(s[0] == '*'){
      a = is.top();is.pop();
      b = is.top();is.pop();
      is.push(a*b);
    }
  else{
    is.push(atoi(s.c_str()));
  }
  }

  printf("%d\n",is.top());

  return 0;
}

Measured memory_bytes: 3304
#include <iomanip>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define test()             int x;cin >> x;while(x--)
using namespace std;
double inf = 5.00;
double dp[3000][3000][2],p[3000];
int n;
double rec(int i,int hc,bool op){
	if(i==n-1){
		if(op == 0)
			hc++;
		if(hc > n-hc){
			if(op==0)
			   return p[i];
			return 1-p[i];
		}
		else
			return 0.0;
	}
    if(dp[i][hc][op]!=inf)
		return dp[i][hc][op];
	double ans = 0.0;
	ans += rec(i+1,hc+!op,0)+rec(i+1,hc+!op,1);
	if(op==0){
		ans *= p[i];
	}
	else
		ans *= (1-p[i]);
	dp[i][hc][op] = ans;
	return ans;
}
int32_t main(){

	
	FASTIO;
	cin >> n;
	REP(i,0,n){
		cin >> p[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++){
			dp[i][j][0] = 5.00;
			dp[i][j][1] = 5.00;
		}
	}
	double ans = rec(0,0,0) + rec(0,0,1);
	cout << setprecision(11) << ans << endl;
    return 0;

}

Measured memory_bytes: 141056
/**
*    created: 11.07.2020 00:14:15
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    string s; cin >> s;
    int r = s.size();
    bool ok = true;
    while(true) {
        if (r == 0) break;
        else if (r <= 4) {ok = false; break;}
        else {
            if (r >= 7 and s.substr(r-7,7) == "dreamer") {r -= 7; continue;}
            if (r >= 6 and s.substr(r-6,6) == "eraser") {r -= 6; continue;}
            if (s.substr(r-5,5) == "dream" || s.substr(r-5,5) == "erase") {r -= 5; continue;}
            ok = false;
            break;
        }
    }
    if (ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3748
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 
ll mpow(ll a, ll b){
	if(a==0) return 0;
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}
 
ll mpow(ll a, ll b, ll p){
	if(a==0) return 0;
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
 
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}

mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
 
ll range(ll l, ll r){
	return l + mt()%(r-l+1);
}
 
ll rev(ll v){
	return mpow(v,MOD-2);
}

void solve(){
	ll a,b,v,w,t;
	cin >> a >> v >> b >> w >> t;
	if(abs(a-b)<=(v-w)*t) cout << "YES" << ln;
	else cout << "NO" << ln;
}
 
int main()
{
	fast_cin();
    ll t=1;
    // cin >> t;
    forn(i,t) {
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    }
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int main() {
    int verdicts[4];

    for(int i = 0; i < 4; i++) {
        verdicts[i] = 0;
    }

    int n;
    cin>>n;

    string tCases[n];

    for(int i = 0; i < n; i++) {
        cin>>tCases[i];
        if(tCases[i].compare("AC") == 0) {
            verdicts[0]++;
        }
        else if(tCases[i].compare("WA") == 0) {
            verdicts[1]++;
        }
        else if(tCases[i].compare("TLE") == 0) {
            verdicts[2]++;
        }
        else if(tCases[i].compare("RE") == 0) {
            verdicts[3]++;
        }
    }

    cout<<"AC x "<<verdicts[0]<<endl;
    cout<<"WA x "<<verdicts[1]<<endl;
    cout<<"TLE x "<<verdicts[2]<<endl;
    cout<<"RE x "<<verdicts[3]<<endl;

}

Measured memory_bytes: 6724
N,M=map(int, input().split())
S=[]
for i in range(N):
    a,b=map(int, input().split())
    S.append((a,b))

C=[]
for i in range(M):
    c,d=map(int, input().split())
    C.append((c,d,i+1))
#print(C)
for s in S:
    a,b=s
    now=0
    dis=10**9

    for t in C:
        c,d,n=t
        D=abs(c-a)+abs(d-b)
        
        if D<dis:
            dis=D
            now=n
    print(now)

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

char arr[1100][1100];
LL int dp[1100][1100];

int main(){
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++)cin >> arr[i][j];
    }
    dp[1][1] = 1;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(i == 1 && j == 1)continue;
            if(arr[i-1][j-1] == '#')dp[i][j] = 0;
            else dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
            //cout << dp[i][j] << " ";
        }
        //cout << endl;
    }

    cout << dp[h][w] << endl;
    return 0;
}


Measured memory_bytes: 10752
Row = int(input())
flag = True
List = []
for i in range (Row):
  List.append(input())
s_l = set(List)
if len(List) != len(s_l):
  print("No")
else:
  for i in range(Row-1):
    n = len(List[i])-1
    if List[i][n] != List[i+1][0]:
      flag = False
  if flag:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 9152
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<ll> seq(n), a(n);
    for(int i = 0; i< n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    if(n == 2){
        cout << abs(a[0]-a[1]) << endl;
        return 0;
    }else{
        ll rem = n-2;
        if(rem % 2 == 0){
            for(int i = 0; i < rem/2; i++){
                ans += 2*a[n-1-i];
            }
            for(int i = 0; i< rem/2; i++){
                ans -= 2*a[0+i];
            }
            ans += a[n/2];
            ans -= a[n/2 -1];
            cout << ans << endl;
        }else{
            for(int i = 0; i < (n+1)/2; i++){
                if(i == ((n+1)/2) -1 || i == ((n+1)/2) -2){
                    ans += a[n-1-i];
                }else{
                    ans += 2*a[n-1-i];
                }
            }
            for(int i = 0; i < (n-1)/2; i++){
                ans -= 2*a[0 + i];
            }
            ll ans2 = 0;
            for(int i = 0; i < (n-1)/2; i++){
                ans2 += 2*a[n-1-i];
            }
            for(int i = 0; i< (n+1)/2; i++){
                if(i == (n+1)/2 -1 || i == (n+1)/2 -2){
                    ans2 -= a[0+i];
                }else{
                    ans2 -= 2*a[0+i];
                }
            }
            ans = max(ans, ans2);
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4828
//
// Created on 2020/04/04.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z;

}


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

int main() {
  
  int x,a;
  cin >> x >> a;
  if(x < a){
    cout << 0 << endl;
  }
  else{
    cout << 10 << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n,k;
	string s;
	cin >> n >> k >> s;
	rep(i,n){
		if(i%2 == 0){
			if(s[i] == 'A' && i < k){
				s[i] = 'B';
				k --;
			}
		}
		if(i%2 == 1){
			if(s[i] == 'B' && i < k){
				s[i] = 'A';
				k --;
			}
		}
	}
	if(k > n){
		k -= n;
		string ret = "";
		rep(i,n){
			if((n-1-i)%2 == 0)ret += 'A';
			else ret += 'B';
		}
		if(ret[0] == 'A' && k%2 == 1){
			ret[0] = 'B';
		}
		cout << ret << endl;
		return 0;
	}
	/*if(s[0] == 'A'){
		s[0] = 'B';
		k --;
	}*/
	string ret = "";
	rep(i,n){
		if(i+k<n){
			if(s[i+k] == 'A'){
				if(k%2 == 0)ret += 'A';
				else ret += 'B';
			}
			else {
				if(k%2 == 0)ret += 'B';
				else ret += 'A';
			}
		}
		else if((n-1-i)%2 == 0)ret += 'A';
		else ret += 'B';
	}
	cout << ret << endl;
}



Measured memory_bytes: 904
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, B: "List[int]"):
    exists = []
    # fill
    for b in B:
        for i, row in enumerate(A):
            for j, col in enumerate(row):
                if b == col:
                    exists.append((i, j))
    bingo_pattern = (
        ((0, 0), (0, 1), (0, 2),),
        ((1, 0), (1, 1), (1, 2),),
        ((2, 0), (2, 1), (2, 2),),
        ((0, 0), (1, 0), (2, 0),),
        ((0, 1), (1, 1), (2, 1),),
        ((0, 2), (1, 2), (2, 2),),
        ((0, 0), (1, 1), (2, 2),),
        ((2, 0), (1, 1), (0, 2),),
    )
    for bingo in bingo_pattern:
        ok = 0
        for pair in bingo:
            if pair in exists:
                ok += 1
            if ok == 3:
                print(YES)
                return

    print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = [
        [int(next(tokens)) for _ in range(3)] for _ in range(3)
    ]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
x,k,d=[int(x) for x in input().split()]
x=abs(x)

ans=0
if x<=k*d:
    cnt=x//d
    rst=k-cnt
    ans=x-cnt*d
    if rst%2==1:
        ans-=d
else:
    ans=x-(k*d)
print(abs(ans))


Measured memory_bytes: 9132
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int a[1000][1000];
bool vis[1000][1000];
int n;
ll res;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>a[i][j];
	for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(k!=j&&k!=i&&i!=j){
        if(a[i][j]==a[i][k]+a[k][j]) vis[i][j]=1;
        if(a[i][j]>a[i][k]+a[k][j]){
            cout<<"-1"<<'\n';
            return 0;
        }
    }
    for(int i=0;i<n;i++)
    	for(int j=0;j<n;j++)
    		if(!vis[i][j])res+=a[i][j];
    cout<<res/2;
	return 0;
}


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


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string str1;
	string str2;

	cin >> str1;
	cin >> str2;
	int m = str1.size();
	int n = str2.size();
	int** arr = new int * [m+1];
	for (int i = 0; i <= m; i++) {
		int* temp = new int[n+1];
		arr[i] = temp;
	}

	for (int i = 0; i <= m; i++) {
		arr[i][0] = 0;
		
	}
	for (int i = 0; i <= n; i++) {
		arr[0][i] = 0;
}

	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (str1.at(i-1) == str2.at(j-1)) {
				arr[i][j] = 1 + arr[i - 1][j - 1];
			}
			else {
				int x = arr[i - 1][j];
				int y = arr[i][j - 1];
				if (x > y) {
					arr[i][j] = arr[i - 1][j];
				}
				else {
					arr[i][j] = arr[i][j - 1];
				}
			}
		}
	}
	string str = "";
	
	int i = m;
	int j = n;
	while (i > 0 && j > 0) {

		if (arr[i][j] == arr[i][j - 1]) {
			j--;
		}
		else if (arr[i][j] == arr[i - 1][j]) {
			i--;
		}
		else {
			str = str1[i - 1] + str;
		
			i--;
			j--;
		}

	}
	cout << str << endl;
	
}

Measured memory_bytes: 35456
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define irep(i,a,b) for(int i=int(a);i>=int(b);i--)
using ll = long long;
using namespace std;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
//sort(a, a + N, greater<ll>())   // descend
//sort(a, a+N)                    //  ascend

/**
void comb(vector<vector <long long int > > &v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
/*main内でnCn~nC0 生成 **
vector<vector<long long int> > v(n + 1, vector<long long int>(n + 1, 0));
comb(v);
*/

int main() {
	ll n;
	ll a[110000];
	cin >> n;
	rep(i, 0, n) cin >> a[i];
	ll b[110000];
	ll c[110000];
	ll p = 0;
	sort(a, a + n);
	b[0] = a[0];
	rep(i, 0, n-1) {
		if (a[i] == a[i + 1]) c[p]++;
		else {
			p=p+1;
			b[p] = a[i + 1];
		}
	}
	ll ans = 0;
	rep(i, 0, p+1) {
		if ((c[i] + 1) < b[i]) ans += (c[i] + 1);
		else ans += abs((c[i]+1) - b[i]);
	}
	if (n == 1&&a[0]==1) cout << 0;
	if (n == 1 && a[0] != 1) cout << 1;
	if(n>1) cout << ans;
	//rep(i, 0, p + 1) cout << a[i] << "-" << b[i] << "-" << c[i] << endl;
}


Measured memory_bytes: 2816
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void search(int);
void dfs();

int main(){
  int u,v,k,i,j;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++) M[i][j] = 0;
  }

  for(i = 0; i < n; i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}

void search(int u){
  int v;

  color[u] = GRAY;
  d[u] = ++tt;
  for(v = 0; v < n; v++){
    if(M[u][v] ==0) continue;
    if(color[v] == WHITE){
      search(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int u;
  for(u = 0; u < n; u++) color[u] = WHITE;
  tt = 0;

  for(u = 0; u < n; u++){
    if(color[u] == WHITE) search(u);
  }
  for(u = 0; u < n; u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}
      



Measured memory_bytes: 2100
import java.util.Scanner;
import java.util.Arrays;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                int numN = scan.nextInt();
                int numM = scan.nextInt();
                int[][] Like = new int[numN][numM];
                int sum = 0;
                int tmp[] = new int[numM];

                for (int i=0; i<numN; i++) {
                    int numK = scan.nextInt();
                    
                    for ( int j=0; j<numK; j++ ) {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    }
                }
                for (int z=0; z<numM; z++) {
                    if ( tmp[z] >= numN ) {
                        sum++;
                    }
                }
                
                System.out.println( sum );
                scan.close();
        }
}


Measured memory_bytes: 24148
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        HashMap<String,Long> map =  new HashMap<>();
        
        for(int i = 0; i < a; i++){
            String s = sc.next();
            char[] c = s.toCharArray();
            Arrays.sort(c);
            s = new String(c);
            if(map.containsKey(s)){
                long l = map.get(s) + 1;
                map.put(s, l);
            }else{
                map.put(s, (long)1);
            }
        }

        long count = 0;
        for(Long l: map.values()){
            count = count + (l * (l -1) / 2);
        }
        
        System.out.print(count);
    }
}

Measured memory_bytes: 53520
import os
import sys
from io import BytesIO, IOBase
# from collections import defaultdict as dd
# from collections import deque as dq
# import itertools as it
# from math import sqrt, log, log2
# from fractions import Fraction

def main():
    t = 1
    for _ in range(t):
        # n = int(input)
        r, g, b = map(int, input().split())
        k = int(input())
        #nums = list(map(int, input().split()))
        while g <= r and k:
            g <<= 1
            k -= 1
        while b <= g and k:
            b <<= 1
            k -= 1
        
        if k == 0 and (b<=r or g<=r or b<=g):
            print('No')
        else:
            print('Yes')
            
        # b>g>r
        # if b>g>r:
        #     print('Yes')
        # else:
        # elif g>r:
        #     while b <= g and k:
        #         b <<= 1
        #         k -= 1
            
        #     if k == 0 and b<= g:
        #         print('No')
        #     else:
        #         print('Yes')

        # elif b > r:
        #     while g <= r and k:
        #         g <<= 1
        #         k -= 1
            
        #     if k == 0 and g<= r:
        #         print('No')
        #     elif g >= b:
        #         print('No')
        #     else:
        #         print('Yes')
        
        # else:





        




































# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion
 
if __name__ == "__main__":
    main()

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

int mod=1000000007;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int Gcd(int x,int y)              //最大公約数
{
  int large = max(x,y);
  int small = min(x,y);

  while(small!=0){
      int amari =large%small;

      large = small;

      small = amari;  
  }
  return large;
}


//メイン関数--------------------------------------------



int main(){

int x;
cin>>x;
if(x==0){
    cout<<1<<endl;
}
else{
    cout<<0<<endl;
}


}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

vint dx = {1,0,-1,0};
vint dy = {0,1,0,-1};

int main() {
    int h, w; cin >> h >> w;
    vector<string> field(h);
    rep(i,h) cin >> field[i];
    bool ans = true;
    rep(i,h)rep(j,w) {
        if (field[i][j] == '#') {
            bool ok = false;
            rep(k,4) {
                int x = j+dx[k]; int y = i+dy[k];
                if (0 <= x && x < w && 0 <= y && y < h) {
                    if (field[y][x] == '#') ok = true;
                }
            }
            if (!ok) ans = false;
        }
    }
    printf(ans?"Yes\n":"No\n");
}

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main() {
	ll n;cin>>n;
	cout<<n*(n-1)/2;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
vector<int> a[100001];
bool d[100001];
int h[100001];
int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		if (h[x] == h[y]) {
			d[x] = true; d[y] = true;
		}
		if (h[x] < h[y]) {
			d[x] = true;
		}
		else d[y] = true;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!d[i]) {
			ans += 1;
		}
	}
	cout << ans << '\n';
	




}

Measured memory_bytes: 8780
package main

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Many Medians
	var N int
	fmt.Scanf("%d", &N)

	sc.Split(bufio.ScanWords)
	X := make([]int, N)
	Y := make([]int, N)
	for i := 0; i < N; i++ {
		X[i] = nextInt()
		Y[i] = X[i]
	}

	sort.Sort(sort.IntSlice(Y))
	ans := make(map[int]int, N)
	for i := 0; i < N; i++ {
		if i < N/2 {
			ans[Y[i]] = Y[N/2]
		} else {
			ans[Y[i]] = Y[(N/2)-1]
		}
	}

	for i := 0; i < N; i++ {
		fmt.Println(ans[X[i]])
	}

}


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

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

    string s;
    cin >> s;
    long long k;
    cin >> k;

    int n = s.size();
    for(long long i = 0; i < min(k, (long long)s.size()); i++){
        if(s[i] == '1');
        else{
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << '1' << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if(a[0]==5 && a[1]==5 && a[2]==7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a,b=map(int, input().split())
s=str(input())
b=b-1
slist=list(s)
if slist[b]=="A":
  slist[b]="a"
if slist[b]=="B":
  slist[b]="b"
if slist[b]=="C":
  slist[b]="c"
s="".join(slist)
print(s)

Measured memory_bytes: 9152
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, cc: usize,
        d: [[i64; cc]; cc],
        c: [[Usize1; n]; n],
    }

    let mut rems = vec![vec![0; n]; n];
    for y in 0..n {
        for x in 0..n {
            rems[y][x] = (x + y) % 3;
        }
    }
    
    let mut costs = vec![vec![0; 3]; cc];
    for next_color in 0..cc {
        for y in 0..n {
            for x in 0..n {
                let now_color = c[y][x];
                let rem = rems[y][x];
                costs[next_color][rem] += d[now_color][next_color];
            }
        }
    }


    let mut ans = 1i64<<50;
    for colors in (0..cc).permutations(3) {
        let mut res = 0;
        for rem in 0..3 {
            res += costs[colors[rem]][rem];
        }
        ans = min(ans, res);
    }
    println!("{}", ans);
}


Measured memory_bytes: 6808
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	int n;
	cin >> n;
	if (n % 1000 == 0) cout << 0 << endl;
	else cout << 1000 - n % 1000 << endl;
	return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int mod=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

int n,look;
string s1,s2;
ll ans;
bool virt;
void process(){
	while(look<n){
		if(s1[look]==s2[look]){
			if(virt)ans*=2;
			look++;
			virt=true;
		}else{
			if(virt)ans*=2;
			else ans*=3;
			virt=false;
			look+=2;
		}
		ans%=inf;
	}
}

int main(){
	cin>>n>>s1>>s2;
	if(s1[0]==s2[0]){
		virt=true;
		ans=3;
		look=1;
		process();
	}else{
		virt=false;
		ans=6;
		look=2;
		process();
	}
	print(ans);
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		try {
	   		BufferedReader br = createBufferedReader();
	        String line = br.readLine();
	        final int N = Integer.parseInt(line);
	       	System.out.println(method(N));
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
	}

	private static int method(final int n) {
		return n * n * n;
	}

	// 以下問題問わずに共通部分
	// 標準入力の BufferedReader を返す.
	private static BufferedReader createBufferedReader() {
		InputStreamReader isr =new InputStreamReader(System.in);
	   	return new BufferedReader(isr);
	}
}


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

main(){
  int n,k,q,i,p;
  int a[100000],point[100000];
  string s[100000];
  cin >> n >> k >> q;
  for(i=0;i<q;i++) cin >> a[i];
  
  for(i=0;i<q;i++){
    p = a[i]-1;
    point[p] += 1;
  }
  
  for(i=0;i<n;i++){
    if(k-q+point[i] <= 0){
      s[i] = "No";
    }else{
      s[i] = "Yes";
    }
  }
  
  for(i=0;i<n;i++) cout << s[i] << endl;

}

Measured memory_bytes: 6912
#include<iostream>
#include<algorithm>
#include<cstring>
#include<numeric>
#include<vector>
using namespace std;

#define int long long

#ifdef lioraju
	#define ndbg(x) 
#else
	#define ndbg(x) x
#endif

const int mxsz = 1e5 + 5;

int v[mxsz];

int dp[mxsz];
bool vis[mxsz];

int K;
int d(int n)
{
	if (!n) return 0;
	if (vis[n]) return dp[n];
	
	vis[n] = 1;
	int mnn = 2e9;
	for (int i=n-1;i>=n-K && i>=0; i--)
		mnn = min(mnn, d(i)+abs(v[i]-v[n]));
	
	return dp[n] = mnn;
}

signed main()
{
	ndbg( ios::sync_with_stdio(0); cin.tie(0); );
	int n, k; cin>>n>>k, K = k;
	for (int i=0;i<n;i++)
		cin>>v[i];
	
	cout<<d(n-1)<<'\n';
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  
   
   int S,W;
   cin>>S>>W;
   if(W >= S)
   {
     cout<<"unsafe"<<endl;
   }
   else
   {
     cout<<"safe"<<endl;
   }
   
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
#include <numeric>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;



int main(void)
{
    long long n;
    cin >> n;
    long long m;
    cin >> m;
    REP(i,4)
    {
        long long temp;
        cin >> temp;
        if(temp < m) m = temp;
    }
    cout << (n+m-1)/m + 4 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 4e3 + 5;
int n , cntR[N] , cntG[N] , cntB[N];
ll ans;
string s;
int main() {
    abdelrahman010
    cin >> n >> s;
    for(int i = 0;i < n;i++) {
        cntG[i] = (s[i] == 'G');
        cntR[i] = (s[i] == 'R');
        cntB[i] = (s[i] == 'B');
        if(i) {
            cntR[i] += cntR[i - 1];
            cntG[i] += cntG[i - 1];
            cntB[i] += cntB[i - 1];
        }
    }
    for(int i = 0;i < n;i++)
        for(int j = i + 1;j < n;j++)
            if(s[i] != s[j]) {
                if((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R'))
                    ans += cntG[n - 1] - cntG[j - 1] - (s[j + (j - i)] == 'G');
                else if((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R'))
                    ans += cntB[n - 1] - cntB[j - 1] - (s[j + (j - i)] == 'B');
                else if((s[i] == 'B' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'B'))
                    ans += cntR[n - 1] - cntR[j - 1] - (s[j + (j - i)] == 'R');
            }
    cout << ans;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<int> x(n + 1, 1);
  int a;
  for(int i = 0; i < m; i++){
    cin >> a;
    x.at(a) = 0;
  }
  
  x.at(1) *= x.at(0);
  for(int i = 2; i <= n; i++){
    x.at(i) *= x.at(i - 1) + x.at(i - 2);
    x.at(i) %= (int) 1e9 + 7;
  }
  
  cout << x.at(n) << "\n";
}

Measured memory_bytes: 640
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	pp := modPascal(n + 1 + k)
	for i := 1; i <= k; i++ {
		if n-k+1 < 0 || n-k+1 < i {
			fmt.Fprintln(writer, 0)
			continue
		}
		fmt.Fprintln(writer, pp[k-1][i-1].mul(pp[n-k+1][i]))
	}
}
func modPascal(n int) [][]mint {
	pp := make([][]mint, n+1)
	p := make([]mint, n+1)
	for i := 0; i < n+1; i++ {
		p[i] = 1
		for j := i - 1; j > 0; j-- {
			p[j].addAs(p[j-1])
		}
		pp[i] = make([]mint, i+1)
		copy(pp[i], p[:i+1])
	}
	return pp
}

type mint int

func (mt mint) mod() mint {
	m := mint(1e9 + 7)
	mt %= m
	if mt < 0 {
		return mt + m
	}
	return mt
}
func (mt mint) inv() mint {
	var m, y mint
	m.subAs(2)
	dbl := mt
	y = 1
	for i := 0; i < 31; i++ {
		if m%2 == 1 {
			y.mulAs(dbl)
		}
		m >>= 1
		dbl.mulAs(dbl)
	}
	return y
}
func (mt mint) add(x mint) mint {
	return (mt + x).mod()
}
func (mt mint) sub(x mint) mint {
	return (mt - x).mod()
}
func (mt mint) mul(x mint) mint {
	return (mt * x).mod()
}
func (mt mint) div(x mint) mint {
	return mt.mul(x.inv())
}
func (mt *mint) addAs(x mint) *mint {
	*mt = mt.add(x)
	return mt
}
func (mt *mint) subAs(x mint) *mint {
	*mt = mt.sub(x)
	return mt
}
func (mt *mint) mulAs(x mint) *mint {
	*mt = mt.mul(x)
	return mt
}
func (mt *mint) divAs(x mint) *mint {
	*mt = mt.div(x)
	return mt
}


Measured memory_bytes: 70656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
using namespace std;

int main() {
    int num;
    vector<int> v;
    int k;
    
    for(int i = 0; i < 3; i++){
        cin >> num;
        v.push_back(num);
    }
    
    cin >> k;
    sort(v.begin(),v.end());
    
    for(int i = 0; i < k; i++){
        v[2] *= 2;
    }
    
    int ans = v[0] + v[1] + v[2];
    
    cout << ans << endl;
}


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

string s;
ll ans, ct;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s;
	int n = s.length();
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'B') {
			ct++;
			ans -= i;
		}
	}
	for (int i = n-1; i >= n-ct; --i) {
		ans += i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 720
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <regex>
#include <algorithm>
#include <typeinfo>
#include <cstdlib>

int stdinInt(void)
{
  int num;
  std::cin >> num;
  return(num);
}

std::vector<int> stdinIntVec(std::string symbol)
{
  /* declaration */
  std::string input;
  std::regex sep(symbol);
  std::vector<std::string> svec;
  std::vector<int> ivec;

  /* input */
  std::getline(std::cin >> std::ws, input);
  auto ite = std::sregex_token_iterator(input.begin(), input.end(), sep, -1);
  auto end = std::sregex_token_iterator();

  /* separate string and convert to integer */
  while(ite!=end) svec.push_back(*ite++);
  for(int i=0; i<svec.size(); i++) ivec.push_back(std::stoi(svec[i]));

  return(ivec);
}

int main(void)
{
  /* declaration */
  int num;
  std::vector<int> ivec;
  int modsum;

  /* input */
  num  = stdinInt();
  ivec = stdinIntVec(" ");

  /* calculate problem */
  for(int i=0; i<num; i++)
    modsum += ivec[i];
  modsum -= num;

  /* print */
  std::cout << modsum << std::endl;

  return(0);
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptor/reversed.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

std::int64_t gcd(std::int64_t x, std::int64_t y)
{
	if (y < x)
	{
		return gcd(y, x);
	}
	else if (x == 0)
	{
		return y;
	}
	else
	{
		return gcd(y % x, x);
	}
}

void Main()
{
	std::int64_t A, B, C, D;
	std::cin >> A >> B >> C >> D;
	auto G = C * D / gcd(C, D);
	--A;
	auto a = A - (A / C) - (A / D) + (A / G);
	auto b = B - (B / C) - (B / D) + (B / G);
	std::cout << b - a << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 2005
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, m, k, a, b, ans;
string s;
map<char, int> MP;
int main() {
	io(); cin >> s;
	rep(i, 0, 2) MP[s[i]]++;
	if (MP.size() > 1) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A,B,C;
int getX(int x){
	return (A*x+B)%C;
}
int main(){
	int n,x,y;
	while(cin>>n>>A>>B>>C>>x,n){
		int cnt=0;bool g=false,m=false;
		for(int i=0;i<n;i++){
			cin>>y;
			if(cnt==0 && x==y && !m){
				m=true;
				continue;
			}
			while(1){
				x=getX(x);
				cnt++;
				if(x==y)break;
				if(cnt>10000){
					g=true;
					break;
				}
			}
		}
		if(g||cnt>10000)cout<<-1<<endl;
		else cout<<cnt<<endl;
	}
}

Measured memory_bytes: 1160
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, K = sc.nextLong

  var sum :Long = 0
  if (K == 0) {
    println(N * N)
    sys.exit
  }

  for (b <- K + 1 to N) {
    val x = N % b
    if (x >= K) {
      sum += (b - K) * (N / b) + x + 1 - K
    } else {
      sum += (b - K) * (N / b)
    }
  }

  println(sum)
}

Measured memory_bytes: 32164
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
 
    const DA = arg.slice(1, (M * 2) + 1);
    
    let map = {};
    
    
    for(let i in DA) {
        if(i % 2 !== 0) {
            let A = DA[i].split(" ").map(n=>parseInt(n));
            
            for(let j=0; j<A.length; j++) {

                if(!map[A[j]]) {
                    map[A[j]] = 1;
                } else {
                    map[A[j]]++;
                }
            }
        }
    }
    
    //console.log(JSON.stringify(map));
    console.log(N - Object.keys(map).length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29888
n,h=map(int,input().split())
ab=[]
ans=0
for i in range(n):
  aa,bb=map(int,input().split())
  ab.append([aa,bb])

ab.sort(key=lambda x: x[0],reverse=True)
katana=ab[0][0]
ab.sort(key=lambda x: x[1],reverse=True)
cnt=0
# print(ab)
for a,b in ab:
  if b>katana:
    cnt+=1

for i in range(cnt):
  if h<=0:break
  h-=ab[i][1]
  ans+=1
if h>0:
  ans+=(h-1)//katana+1
print(ans)



Measured memory_bytes: 21192
fun main(argv: Array<String>) {
  val list: MutableList<Int> = mutableListOf()

  loop@ while (true) {
    val inputs = readLine()!!.split(' ')
    val a  = inputs[0].toInt()
    val op = inputs[1]
    val b  = inputs[2].toInt()
    val res = when (op) {
      "+"  -> a+b
      "-"  -> a-b
      "*"  -> a*b
      "/"  -> a/b
      else -> break@loop
    }
    list.add(res)
  }

  for (i in list.indices) {
    println("${list[i]}")
  }
}



Measured memory_bytes: 32132