akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**6)
def search(arr, num, i):
  nxt = arr[num]
  if(nxt == 1):
    return i
  elif(i >= len(arr)):
    return -1
  else:
    return search(arr, nxt, i+1)

n = int(input())
a = [ int(input()) - 1 for _ in range(n)]
print(search(a, 0, 1))


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	x=15;
	FOR(i,5) {
		cin>>y;
		x-=y;
	}
	cout<<x<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3620
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]

for Cx in range(101):
    for Cy in range(101):
        criteria = -1
        ax, ay, ah = 0, 0, 0
        cnt = 0
        for x, y, h in xyh:
            if h == 0:
                continue
            H = h + abs(x - Cx) + abs(y - Cy)
            if H == criteria or criteria == -1:
                criteria = H
                ax, ay, ah = x, y, h
                cnt += 1
                continue
            else:
                break
        else:
            if cnt == 1:
                print(ax, ay, ah)
                exit()
            else:
                print(Cx, Cy, criteria)


Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, x;
	cin >> n >> x;
	
	cout << n - x + 1 << endl;
	
	return 0;
}


Measured memory_bytes: 256
/*  
     author : masaow    
     g++ : 17.3.20  
*/        
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set ; 
const int SIZE = 1e5+7 ;  
const int MOD = 1e9 +7 ; 
const int INF = 2e9+7 ;
/*  
    time : 07 : 31    
    date : 09...02...2020
*/ 
 
int tests(){
  int a[4] ;
  int i ; 
  forn(i,0,3)
  cin >> a[i] ;
  sort(a,a+3) ;
  if((a[0] == a[1] && a[1] != a[2] )|| (a[0] != a[1] && a[1] == a[2]) ) 
    cout << "Yes\n" ;
  else 
    cout << "No\n" ; 
  return 0 ; 
}
int main(){
    I__O ;  
    int cases = 1 ; 
    // cin >> cases;  
    while(cases--) 
      tests(); 
  return 0 ;
}
// web dev simplified
// LearnCode.Academy
/*
 g++ subminnnt.cpp -Wall -Wextra -pedantic
 -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal
 -Wconversion -Wlogical-op -Wshift-overflow=2
 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG
 -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address 
 -fsanitize=undefined -fno-sanitize-recover -fstack-protec    
*/         
         
  

Measured memory_bytes: 256
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=1e9+7;
const int MAXN=2e5+9;
const double eps=1e-8;
const long double pi=3.1415926535897932384626433832795;
const long double e=2.71828182845904523536028747135266;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;
    while(t--){
        int n,k;
        cin >> n >> k;
        if(n==1){
            if(!k) cout << "0 0 1 1" << endl;
            else cout << -1 << endl;
        }
        else if(k>=(1<<n)) cout << -1 << endl;
        else {
            for(int i=0;i<(1<<n);i++){
                if(i!=k) cout << i << " ";
            }
            cout << k << " ";
            for (int i=1<<n;i--;){
                if(i!=k) cout << i << " ";
            }
            cout << k << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1792
N, M = map(int, input().split())

L = [[] for _ in range(N+1)]
for i in range(M):
    a, b = map(int, input().split())
    L[a].append(b)
    L[b].append(a)

from collections import deque

def bfs(Que, Dist, L, Root):    
    while Que:
        x = Que.popleft()
        d = Dist[x]
        
        for l in L[x]:
            new_x = l
            if Dist[new_x] == -1:
                Dist[new_x] = d + 1
                Root[new_x] = x
                Que.append(new_x)
    return Dist, Root
    
Que = deque()
Dist = [-1 for _ in range(N+1)]
Root = [-1 for _ in range(N+1)]

Que.append(1)
Dist[1] = 0
Dist, Root = bfs(Que, Dist, L, Root)

More0 = [r > 0 for r in Root[2:]] 
Is1 = [r == 1 for r in Root[2:]]

if all(More0) and any(Is1):
    print('Yes')
    print('\n'.join(map(str, Root[2:])))
else:
    print('No')


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

int main(){
	int a, b;
	 cin >> a >> b;
	 int x;
	 
	 if (b<10){
	  x = a*10 + b;
	 } 
	else if (10 <= b && b < 100){
		x = a*100 + b;
	}
	else{
		x = a*1000 + b;
	}	
	int y = sqrt(x);
	
	if (x == y*y){
	cout << "Yes" << endl;
	}
	else{
	cout << "No" << endl;
	}
}


Measured memory_bytes: 256
'''
https://beta.atcoder.jp/contests/abc065/submissions/1375280
'''

def f(x, d):
    ret = 1
    for i in range(1, x + 1):
        ret *= i
        if ret >= d:
            ret %= d
    return ret

nm = list(map(int, input().split()))
nm = sorted(nm)

div = (10 ** 9 + 7)

ans = 0
if nm[0] == nm[1]:
    ans = 2 * f(nm[0], div) ** 2 % div
elif nm[1] - nm[0] == 1:
    f0 = f(nm[0], div)
    ans = (f0 * ((nm[1] * f0) % div)) % div
print(ans)

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

int main(){
	string s;
	priority_queue<int> pq;
	while(cin>>s,s!="end"){
		if(s[0]=='i'){
			int k;
			cin >> k;
			pq.push(k);
		}else{
			cout << pq.top() << endl; 
			pq.pop();
		}
	}
}



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

int main(){
  int n;cin>>n;
  string ans;
  if(n%10==3) ans="bon";
  else if(n%10==0||n%10==1||n%10==6||n%10==8) ans="pon";
  else ans="hon";

  cout<<ans;
}

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

int c()
{
    long long a;
    long double b;
    std::cin >> a >> b;

    long double ans = b * a;
    std::cout << (long long)ans << std::endl;
    
    return 0;
}

int main(int argc, const char * argv[])
{
    c();
    return 0;
}

Measured memory_bytes: 3720
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

fn main() {
    input! {
    n: usize,
    a: [usize; n]
    }
    let mut cul_2a = vec![0; 2 * n + 1];
    for i in 0..2 * n {
        cul_2a[i + 1] = a[i * 2 % n] + cul_2a[i];
    }
    for i in (0..(n / 2 + 1) * n).step_by(n / 2 + 1) {
        let k = i % n;
        let p = cul_2a[k + n / 2 + 1] - cul_2a[k];
        let m = cul_2a[k + n] - cul_2a[k + n / 2 + 1];
        print!("{} ", p - m);
    }
}


Measured memory_bytes: 5308
#include <iostream>

using namespace std;

int n;
int table[15][15];
bool used[100005];

int digit(int x)
{
  int a[5];
  for(int i = 3; i >= 0; i--){
    a[i] = x % 10;
    x /= 10;
  }
  int ret = 0;
  for(int i = 0; i < 4; i++){
    ret = table[ret][a[i]];
  }
  return ret;
}

int calc(int x){
  return table[digit(x/10)][x%10];
}

int trans(int x, int i)
{
  int a[5];
  for(int j = 4; j >= 0; j--){
    a[j] = x % 10;
    x /= 10;
  }
  swap(a[i], a[i+1]);

  int ret = 0;
  for(int j = 0; j < 5; j++){
    ret *= 10;
    ret += a[j];
  }
  return ret;
}

int change(int x, int I, int J)
{
  int a[5];
  for(int i = 4; i >= 0; i--){
    a[i] = x % 10;
    x /= 10;
  }
  if(a[I] == J) return -1;
  a[I] = J;

  int ret = 0;
  for(int i = 0; i < 5; i++){
    ret *= 10;
    ret += a[i];
  }
  return ret;
}

int main(void)
{
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> table[i][j];
    }
  }

  int ans = 0;
  for(int i = 0; i < 10000; i++){
    int d = digit(i);
    int id = i * 10 + d;

    bool flag = false;
    for(int j = 0; j < 4; j++){
      int t = trans(id, j);
      if(id != t && calc(t) == 0) flag = true;
    }
    for(int j = 0; j < 5; j++){
      for(int k = 0; k < 10; k++){
        int c = change(id, j, k);
        if(c != -1 && calc(c) == 0) flag = true;
      }
    }
    if(flag) ans++;
  }

  /*for(int i = 0; i < 10000; i++){
    int d = digit(i);
    int id = i * 10 + d;
    used[id] = false;
  }*/
  /*for(int i = 0; i < 100000; i++){
    if(used[i]) cout << calc(i) << endl;
    if(used[i] && calc(i) == 0){
      ans++;
    }
  }*/


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



Measured memory_bytes: 3132
/*input
4
WWRR
*/

#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>




#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define fill(a)  memset(a, 0, sizeof (a))
#define mp make_pair
#define pb push_back
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pdd pair<double, double>
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define forstl(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.f<<" , "<<it.s<<endl;} cerr<<endl
#define PI           3.14159265358979323846

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define pdd pair<double, double>
#define in(v,n) vll v(n);rep(i,n) cin>>v[i]


using namespace std;


int main(){
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    int T;
	// cout<<std::fixed<<std::setprecision(35);
	// cin>>T;while(T--)
	{
		ll t,n,i,j,x,y,m,l,d,k;
		cin>>n;
		string s;
		cin>>s;
		i=0,j=n-1;
		ll cn=0;
		while(i<j){
			while(i<j&&s[i]=='R') i++;
			while(i<j&&s[j]=='W') j--;
			if(i<j){
				i++;
				j--;
				cn++;
			}
		}
		cout<<cn<<endl;
	}
}

Measured memory_bytes: 3740
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}
void check(long long a,long long b,long long c,long long d){
    long long same=a;
    a = a-b;
    while(same != a && a >= 0){
        cout << a << endl ;
        if(a <= c){
            a += d;
            if(a == same){
                cout << "Yes" << endl;
                return;
            }
        }
        a = a-b ;
    }

    if(a<0)
        cout << "No" << endl;
    return;
}


int main(int argc, const char * argv[]) {
    
    // source code
    int n,m;
    cin >> n >> m;
    int food[m];
    int a[n][m];
    int k[n];
    rep(i,n){
        cin >> k[i];
        rep(j,k[i]){
            cin >>a[i][j];
        }
    }

int cnt =0;
    rep(i,m){
    int check = 0;
        rep(j,n){
            rep(l,k[j])
                if(a[j][l] == i+1) check +=1;
        }
        if(check == n)
            cnt +=1;
    }


    cout << cnt <<endl;

}

Measured memory_bytes: 256
//061 A - Between Two Integers 2017/05/13

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

int main(){
    int a , b , c;
    cin >> a >> b >> c;
    cout  << ( (c >= a && c <= b) ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
void bubbleSort(int num[], int N);
void swap(int& x, int& y);
void showArray(int num[], int N);
 
int main()
{
    int n;
    cin >> n;
    int *num = new int[n];
    for(int i = 0; i < n; i++)
        cin >> num[i];
    bubbleSort(num, n);
    return 0;
}
 
void bubbleSort(int num[], int N)
{
    int irekae = 0;
    for(int i = 1; i < N; i++)
        for(int j = 0; j < N-i; j++)
            if(num[j] > num[j+1])
            {
                swap(num[j], num[j+1]);
                irekae++;
            }
    showArray(num, N);
    cout << irekae << endl;
}
 
void swap(int& x, int& y)
{
    int temp = x;
    x = y;
    y = temp;
}
 
void showArray(int num[], int N)
{
    cout << num[0];
    for(int i = 1; i < N; i++)
        cout << ' ' << num[i];
    cout << endl;
}

Measured memory_bytes: 1192
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();

	int mae = 1e9;
	int kotae = 0;
	rep(i, N) {
		int p = getint();

		if (mae > p) {
			kotae++;
			mae = p;
		}
	}
	printf("%d\n", kotae);


	Would you please return 0;
}

Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())
X = 0
Y = 0
YY = 0
Z = 0
s = 60*H+M

a = 0.5*s
b = (6*s)%360

c = abs(a-b)

if(c<= 180):
    X = c
else:
    X = 360-c

sin = math.sin(math.radians(X))

cos = math.cos(math.radians(X))


if (X == 90):
    Y = A
    Z = B**2+Y**2
    print(math.sqrt(Z))
elif(X ==180):
    print(A+B)
else:
    Y = A*sin
    YY = B-A*cos
    Z = YY**2 + Y**2
    print(math.sqrt(Z))

Measured memory_bytes: 9552
/* 
 * Project: AtCoder Beginners Contest 148 A - Round One
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/30
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
using namespace std;

int a, b;

void solve() {

    int answer = 6 - a - b;
    printf("%d\n", answer);
}

int main() {

    scanf("%d", &a);
    scanf("%d", &b);

    solve();

}

Measured memory_bytes: 3224
#include <iostream>
#include <cstdio>

using namespace std;

int mx, n;
int x;
string s;

int main()
{
    cin>>n>>s;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'D') x--;
        else
        {
            x++;
            mx = max(mx, x);
        }
    }
    printf("%d", mx);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{
	int l = 0, m = 0, n = 0, cash = 0, ans = 0;
	cin >> l;
	while (l){
		for (int i = 1; i <= 12; i++){
			cin >> m >> n;
			cash += m - n;
			if (cash >= l){
				ans = i;
				break;
			}
		}
		if (ans){
			for (int i = ans + 1; i <= 12; i++){
				cin >> m >> n;
			}
			cout << ans << endl;
		} else{
			cout << "NA" << endl;
		}
		m = n = cash = ans = 0;
		cin >> l;
	}
	return 0;
}

Measured memory_bytes: 1160
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n;
	cin>>n;
	vi a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vi m(n);
	int f = 1;
	for(int i=0;i<n;i++) {
			m[0] += f*a[i];
			f *= -1;
	}
	m[n-1] = 2*a[n-1] - m[0];
	for(int i=n-2;i>0;i--) {
			m[i] = 2*a[i] - m[i+1];
	}
	for(int i=0;i<n;i++) {
			cout<<m[i]<<" ";
	}
	return 0;
}





Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	string W;
	cin >> W;
	string T;
	int count = 0;
	while(true) {
		cin >> T;
		if (T == "END_OF_TEXT") {
			break;
		}
		transform(T.begin(), T.end(), T.begin(), ::tolower);
		if (W == T) {
			count++;
		}
	}
	cout << count << "\n";
	return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int t,n,k,set[100000],tmp,sum,a;
  cin >> t;
  for(int i=0;i<t;i++){
    sum=0;
    for(int j=0;j<100000;j++){
      set[j]=0;
    }
    cin >> n >> k;
    for(int j=0,b=0;j<n;j++){
      cin >> a;
      if(j!=0){
	set[j-1]=a-b;
	sum+=set[j-1];
      }
      b=a;
    }
    sort(set,set+n-1,greater<int>());
    for(int j=0;j<k-1;j++){
      sum-=set[j];
    }
    cout << sum << endl;
  }
}

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

typedef long long int llint;

unsigned int min(unsigned int A,unsigned int B){
	if(A<B){
		return A;
	}else{
		return B;
	}
}

int main(){
	int N,K;
	cin >> N >> K;

	vector<int> P;
	P.push_back(0);
	for(int i=0;i<N;i++){
		int p;
		cin >> p;
		P.push_back(p);
	}

	int dp[N+1][K+1];//dp[i][j]=i番目までj個選んだ時の最小の金額
	dp[0][0]=0;
	for(int i=1;i<=K;i++){
		dp[0][i]=0x0FFFFFFF;
	}
	for(int i=1;i<=N;i++){
		dp[i][0]=0;
		for(int k=1;k<=K;k++){
			dp[i][k]=min(dp[i-1][k-1]+P[i],dp[i-1][k]);
		}
	}

/*
	for(int i=0;i<=N;i++){
		for(int k=0;k<=K;k++){
			clog << dp[i][k] << " ";
		}
		clog << endl;
	}
	*/

	cout << dp[N][K] << endl;
	return 0;
}


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

# define ll long long 
# define VI vector<int>
# define VLL vector<ll>
# define PII pair<int,int> 
#define mp make_pair
#define pb push_back
# define PI acos(-1)
# define double long double
const int MxN = 10005 ; 
# define FOR(i,a,b) for(int i = a ; i < b ; ++i)
# define RFOR(i,a,b) for(int i = a ; i >= b ; --i)

/* VARIABLES */
int h,w ; 
char a[50][50] ;
int ans[50][50] ;
int blacks=0;  
bool vis[50][50] ; 
/* END OF VARIABLES */

bool isvalid(int x,int y) {
	if(x < 0 || x >= h || y < 0 || y >= w)
		return false ;
	return true ; 
}

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

	cin >> h >> w ;  
 
	FOR(i,0,h) {
		FOR(j,0,w){
			cin >> a[i][j] ; 
			if(a[i][j] == '#')
				blacks++;
		}
	}
	memset(ans,1e8,sizeof(ans)) ; 
	vis[0][0] = true ; 
	list<PII> q ; 
	q.push_back({0,0}) ; 
	int cnt = 0 ; 
	ans[0][0] = 0 ; 
	while(!q.empty()) {
		PII u = q.front() ; 
		q.pop_front() ; 
		for(int dx : {-1,0,1,0}) {
			for(int dy : {-1,0,0,1}) {
				if(abs(dx) == abs(dy))
					continue ; 
				int new_x = u.first + dx ; 
				int new_y = u.second + dy ; 
				if(isvalid(new_x, new_y) && !vis[new_x][new_y] && a[new_x][new_y] == '.') {
					vis[new_x][new_y] = true ; 
					ans[new_x][new_y] =  1 + ans[u.first][u.second];
					if(new_x == h-1  && new_y == w-1) {
						cout << h*w - blacks - ans[h-1][w-1] - 1 ;
						return 0 ;
					} 
					q.push_back({new_x,new_y}) ; 
				}
			}
		}
	}
	cout << -1 ; 
	return 0 ; 
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : x)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    string s;
    cin >> s;
    int a[4];
    rep(i, 4) {
        a[i] = s[i] - '0';
    }
    char t[3];
    int n = 0;
    rep(i, 2) {
        rep(j, 2) {
            rep(k, 2) {
                if(i == 0) {
                    n += a[0] + a[1];
                    t[0] = '+';
                } else {
                    n += a[0] - a[1];
                    t[0] = '-';
                }
                if(j == 0) {
                    n += a[2];
                    t[1] = '+';
                } else {
                    n -= a[2];
                    t[1] = '-';
                }
                if(k == 0) {
                    n += a[3];
                    t[2] = '+';
                } else {
                    n -= a[3];
                    t[2] = '-';
                }
                if(n == 7) {
                    cout << s[0] << t[0] << s[1] << t[1] << s[2] << t[2] << s[3] << "=7";
                    return 0;
                }
                n = 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])
        return self.p[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)
        if u == v:
            return False
        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0
            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1
        return True

    def count(self, x):
        return self.size[self.root(x)]

N, M = map(int, input().split())
uf = UnionFind(N+1)
ans = N-1
for _ in range(M):
    a, b = map(int, input().split())
    ans -= uf.unite(a, b)
print(ans)


Measured memory_bytes: 14416
#include<bits/stdc++.h>
#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 ALP_NUM = 26;
const int INF = 1001001001;

int main() {
    int d;
    cin >> d;
    vector<int> C(ALP_NUM);
    rep(i, ALP_NUM) cin >> C[i];
    vector<vector<int>> S(d, vector<int>(ALP_NUM));
    rep(i, d) rep(j, ALP_NUM) cin >> S[i][j];
    vector<int> T;
    vector<set<int>> schedules(ALP_NUM);
    rep(i, ALP_NUM) schedules[i].insert(-1);
    

    auto get_score = [&](vector<int> A, int n) {
        int res = 0;
        vector<int> D(ALP_NUM, -1);
        n = min(d, n);
        rep(i, n) {
            int t = A[i];
            if (t >= 0) {
                res += S[i][t];
                D[t] = i;
            }
            rep(j, ALP_NUM) {
                res -= (i-D[j]) * C[j];
            }
        }
        return res;
    };

    auto change = [&](int nd, int nt) {
        int pt = T[nd];
        int res = S[nd][nt] - S[nd][pt];

        auto it_l = schedules[pt].lower_bound(nd);
        auto it_r = schedules[pt].upper_bound(nd);
        --it_l;
        int pt_ld = *it_l;
        int pt_rd;
        if (it_r != schedules[pt].end()) pt_rd = *it_r;
        else pt_rd = d;
        res -= C[pt] * (nd-pt_ld) * (pt_rd-nd);

        it_l = schedules[nt].lower_bound(nd);
        it_r = schedules[nt].upper_bound(nd);
        --it_l;
        int nt_ld = *it_l;
        int nt_rd;
        if (it_r != schedules[nt].end()) nt_rd = *it_r;
        else nt_rd = d;
        res += C[nt] * (nd-nt_ld) * (nt_rd-nd);

        return res;
    };

    int max_score = -INF;
    rep(k, 26) {
        vector<int> T_(d, -1);
        rep(i, d) {
            int max_score_ = -INF;
            int tmp = 0;
            T_[i] = 0;
            rep(j, ALP_NUM) {
                T_[i] = j;
                int score = get_score(T_, i+1+k);
                if (score > max_score_) {
                    max_score_ = score;
                    tmp = j;
                }
            }
            T_[i] = tmp;
        }
        int score = get_score(T_, d);
        if (max_score < score) {
            max_score = score;
            T = T_;
        }
    }
    

    rep(i, d) {
        cout << T[i]+1 << endl;
    }

    //cout << get_score(T, d) << endl;

    return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
   int a,b,c;
   cin >> a >> b >> c;
   cout << a*b/2 << endl;
   return 0;
   
}



Measured memory_bytes: 256
// 2011/03/29 Tazoe

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	while(true){
		int x;
		cin >> x;
		int h;
		cin >> h;
		if(x==0&&h==0)
			break;

		double S1 = (double)(x*x);
		double S2 = (double)x*sqrt((double)(x*x+4*h*h));

		cout.precision(6);
		cout << fixed << S1+S2 << endl;
	}

	return 0;
}

Measured memory_bytes: 0
N = int(input())
S = list(map(str, input().split()))

candy_list = ['P', 'W', 'G', 'Y']
answer = 0
for i in range(4):
    if candy_list[i] in S:
        answer += 1

if answer == 3:
    print('Three')
if answer == 4:
    print('Four')

Measured memory_bytes: 9140
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
struct poi{ll sum,pos;}a[200010];
ll n,k,ans,cnt,tree[200010],lisan[200010];
void read(ll &k)
{
    k=0;int f=1;char c=getchar();
    while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
    while(c<='9'&&c>='0')k=k*10+c-'0',c=getchar();
    k*=f;
}
bool cmp(poi a,poi b){return a.sum<b.sum;}
int lowbit(int x){return x&-x;}
void add(int x,int delta)
{
    for(int i=x;i<=cnt;i+=lowbit(i))
        tree[i]+=delta;
}
int sum(int x)
{
    int s=0;
    for(int i=x;i>=1;i-=lowbit(i))
        s+=tree[i];
    return s;
}
int main()
{
    read(n);read(k);
    for(int i=1;i<=n;i++)read(a[i].sum),a[i].sum-=k;
    for(int i=1;i<=n;i++)a[i].sum+=a[i-1].sum,a[i].pos=i;
    sort(a,a+1+n,cmp);
    for(int i=0;i<=n;i++)
    {
        if(a[i].sum!=a[i-1].sum||i==0)cnt++;
        lisan[a[i].pos]=cnt;
    }
    for(int i=n;i>=0;i--)
    {
        ans+=n-i-sum(lisan[i]-1);
        add(lisan[i],1);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 6528
import java.util.*;
import java.lang.*;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        String[] values = scanner.nextLine().split(" ");
        int N = Integer.parseInt(values[0]);
        int D = Integer.parseInt(values[1]);
        List<List<Integer>> list = new ArrayList();

        for (int i = 0; i < N; i++) {
            String[] points = scanner.nextLine().split(" ");
            List<Integer> pointList = new ArrayList();

            for (int j = 0; j < D; j++) {
                pointList.add(Integer.parseInt(points[j]));
            }

            list.add(pointList);
        }

        int answer = 0;

        for (int i = 0; i < N - 1; i++) {

            List<Integer> current = list.get(i);
        

            for (int j = i + 1; j < N; j++) {

                List<Integer> target = list.get(j);

                double sum = 0;
                for (int k = 0; k < D; k++) {
                    double pow = (target.get(k) - current.get(k)) * (target.get(k) - current.get(k));
                    sum = sum + pow;

                }

                double distance = Math.sqrt(sum);
        

                int x = (int) distance;
                if ((x - distance) == 0.0) {
                    answer++;
                }
            }

        }

        System.out.println(answer);

        scanner.close();

    }

}

Measured memory_bytes: 21972
# https://atcoder.jp/contests/abc158/tasks/abc158_a
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    s = input()
    if s == 'AAA' or s == 'BBB':
        print('No')
    else:
        print('Yes')
    return 

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, W: "List[int]"):
    s2 = sum(W)
    s1 = 0
    m = s2
    for Wi in W[:-1]:
        s1 += Wi
        s2 -= Wi
        m = min(m, abs(s1 - s2))
    print(m)


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
    W = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, W)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
 
 int cnt_digits(ll N){
 int digits=0;

 while(N>0){
 N/=10;
 digits++;
 }

 return digits;
 }

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

 int ans=cnt_digits(N); // 1*N=N max(cnt_digits(1),cnt_digits(N))=cnt_digits(N)

 for(ll A=1LL;A*A<=N;++A){
 if(N%A!=0) continue;
 const ll B=N/A;

 const int cur=max(cnt_digits(A),cnt_digits(B));

 if(ans>cur){
 ans=cur;
 }
 }

 cout << ans << endl;
}

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

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

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

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

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n>>k;
    rep(i,n)cin>>a[i];
    for(int bit=0;bit<(1<<(n));bit++){
        //ll b[20];
        cnt=0;
        map<ll,ll> mp;
        rep(i,n){
            if(bit&(1<<i)){
            cnt++;
            mp[i]=1;
            if(cnt==k)break;
            }
        }
        if(cnt!=k)continue;
        //Cout("aa");
        //sort(b,b+cnt);
        ll gen=0;
        rep(i,n){
            if(mp[i]==0){
                //cout<<" a " << i <<"\n";
                gen=max(gen,a[i]-1);
            }
            else{
                //cout<<i<<" ";
            if(gen<a[i])gen=a[i]-1;
            else sum+=(gen-a[i])+1;
            gen++;
            }
        }
        //cout<<"\n";
        ans=min(ans,sum);
        //Cout(sum);
        sum=0;
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
l1 = list(range(1,n+1))
for i in range(k):
    d = input()
    l2 = list(map(int,input().split()))
    for num in l2:
        if num in l1:
        	l1.remove(num)
print(len(l1))

Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
string s;
cin >> s;
cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		int sum = 0;
		sum += Math.min(n, k) * x;
		sum += Math.max(n - k, 0) * y;
		System.out.println(sum);
	}

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


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A, B; cin >> A >> B;
    vector<ll> kouyaku;
    set<ll> yaku_A;
    ll ulim = sqrt(A)+1;
    for(int i = 1; i <= ulim; i++){
        if(A % i == 0){
            yaku_A.insert(i);
            yaku_A.insert(A/i);
        }
    }
    for(auto s: yaku_A){
        if(B % s == 0) kouyaku.push_back(s);
    }

    vector<ll> ans;
    ans.push_back(1);

    for(int i = 1; i < kouyaku.size(); i++){
        bool ok = true;
        for(int j = 0; j < ans.size(); j++){
            if(__gcd(kouyaku[i], ans[j]) != 1) ok = false;
        }
        if(ok) ans.push_back(kouyaku[i]); 
    }
    //rep(i, kouyaku.size()) cout << kouyaku[i] << " "; cout << endl;
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 640
n = int(input())
a = input().split()
a = [int(m) for m in a]
dic = {}
dic2 = {}
for i in range(n + 1):
    dic[a[i]] = 0
    dic2[a[i]] = []
f = 0
s = 0
for i in range(n + 1):
    dic[a[i]] += 1
    dic2[a[i]].append(i)
    if dic[a[i]] == 2:
        f = dic2[a[i]][0]
        s = i
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
mod = 10**9+7 #出力の制限
N = n + 1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
 
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
 
 
for k in range(1,n + 2):
    if k == 1:
        print(n)
    else:
        if f + n - s +1>= k:
            if (cmb(n + 1, k, mod) - cmb(f + n - s, k-1, mod)) >= 0:
                print(cmb(n + 1, k, mod) - cmb(f + n - s, k-1, mod))
            else:
                print(cmb(n + 1, k, mod) - cmb(f + n - s, k-1, mod) + mod)
        else:
            print(cmb(n + 1, k, mod))

Measured memory_bytes: 48892
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  vector<int> v(5);
  for (int i = 0; i < 5; i++) {
    cin >> v[i];
  }
  int k;
  cin >> k;
  if (v[4] - v[0] > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
dp = [int(i) for i in input().split()]

for i in range(n-1):
    a, b, c = map(int, input().split())
    dp = [max(dp[1], dp[2]) + a, max(dp[0], dp[2]) + b, max(dp[0], dp[1]) + c]
    
print(max(dp))

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

int main() {
    string S; cin >> S;
    int r = 0, b = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '1') b++;
        else r++;
    }

    cout << 2*min(r, b) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int MOD=998244353;
int n,S,a[3004];
long long dp[3004][3004];
int main(){
	cin>>n>>S;
	for(int i=1;i<=n;i++)cin>>a[i];
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=S;j++){
			if(j+a[i]<=S)dp[i][j+a[i]]+=dp[i-1][j],dp[i][j+a[i]]%=MOD;
			dp[i][j]+=dp[i-1][j]*2,dp[i][j]%=MOD;
		}
	}
	cout<<dp[n][S];
}

Measured memory_bytes: 73956
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

bool sndsort(plint p1, plint p2){
    if(p1.snd == p2.snd){
        return p1.fst > p2.fst;
    }
    return p1.snd < p2.snd;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<plint> p(n);
    REP(i, n){
        cin >> p[i].fst >> p[i].snd;
    }
    sort(ALL(p), sndsort);
    lint task_time = 0;
    lint lim = 0;
    bool isValid = true;
    REP(i, n){
        lim = p[i].snd;
        task_time += p[i].fst;
        //debugpair(task_time, lim);
        if(task_time > lim){
            isValid = false;
        }
    }
    if(isValid){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

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

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

    cin>>s;
    if(s=="keyence")Cout("YES");
    else{
    rep(i,Size(s)){
        rrep(j,i,Size(s)){
            string co;
            rep(k,i)co+=s[k];
            rrep(k,j+1,Size(s))co+=s[k];
            if(co=="keyence"){
                Cout("YES");
                return 0;
            }
        }
    }
    Cout("NO");
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

string query(int x)
{
	printf("%d\n", x);
	fflush(stdout);

	string res;
	cin >> res;

	return res;
}

int main()
{
	int n;
	scanf("%d", &n);

	string zero = query(0);

	int lo = 0, hi = n - 1;

	while (lo <= hi)
	{
		int mid = (lo + hi) / 2;
		string mval = query(mid);

		if (mval == "Vacant")
			return 0;

		if (mid % 2 == 0)
		{
			if (mval == zero)
				lo = mid + 1;
			else
				hi = mid - 1;
		}
		else
		{
			if (mval != zero)
				lo = mid + 1;
			else
				hi = mid - 1;
		}
	}

	return 0;
}

Measured memory_bytes: 852
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    while True:
        n, x = map(int, readline().split())
        if n==0 and x==0:
            break
        else:
            count = 0
            for i in range(1,n-1):
                for j in range(i+1,n):
                    k = x-i-j
                    if j<k<=n:
                        count += 1
            print(count)





if __name__ == '__main__':
    main()



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

int main(){
    int N, M, ans = 0;
    int tmp = 0;
    string a;
    vector<string> s, t;
    cin >> N;
    for(int i = 0 ; i < N; i++){
        cin >> a;
        s.push_back(a); 
    } 
    cin >> M;
    for(int i = 0 ; i < M; i++){
        cin >> a;
        t.push_back(a); 
    } 

    for(int i = 0 ; i < N; i++){
        tmp = 1;
        for(int j = 0 ; j < M; j++){
            if(s[i] == t[j]) tmp--;
        }
        for(int j = 0 ; j < N; j++){
            if(i != j && s[i] == s[j]) tmp++;
        }
        if(ans < tmp) ans = tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
ll fact[200005],fact_inverse[200005];
const ll mod=1e9+7;
ll gcd(ll a,ll b){
if(b==0)return a;
else return gcd(b,a%b);
}
ll power(ll x,ll y,ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(ll a,ll mod)
{ ll ans= power(a, mod-2, mod);
return ans;
}
ll ncr(ll n,ll r){
    if(r==0 || n==r)return 1;
ll ans=fact[n];
ans=ans*fact_inverse[r];
ans%=mod;
ans=(ans+mod)%mod;
ans=ans*fact_inverse[n-r];
ans=ans%mod;
ans=(ans+mod)%mod;
return ans;
}
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
   ll n,k;
   cin>>n>>k;
   ++n;
   ll ans=0;
   for(ll i=n;i>=k;i--){
    ll x=i*(i-1)/2;
    x%=mod;
    ll y=n*(n-1)/2;
    y%=mod;
    ll z=n-i;
    z*=(n-i-1);
    z/=2;
    z=max(0ll,z);
    y-=z;
    y=y-x+1;
    y%=mod;
    ans+=y;
    ans%=mod;
   }
   ans=(ans+mod)%mod;
   cout<<ans<<endl;
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll tot = b - a + 1;
    tot -= b / c;
    tot += (a - 1) / c;
    tot -= b / d;
    tot += (a - 1) / d;
    ll LCM = c * d / __gcd(c, d);
    tot += b / LCM;
    tot -= (a - 1) / LCM;
    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 3636