akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	vs s(3);
	cin >> s;
	int d = 'A' - 'a';
	cout << char(s[0][0] + d) << char(s[1][0] + d) << char(s[2][0] + d) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        int sum = 0;
        int m = 0;
        for (int i = 0; i < n; i++) {
            sum += Math.abs(m - array[i]);
            m = array[i];
        }    
        sum += Math.abs(m);
        for (int i = 0; i < n; i++) {
            int ans = sum;
            if (i == 0) {
                ans -= Math.abs(array[0]);
                ans -= Math.abs(array[0] - array[1]);
                ans += Math.abs(array[1]);
                System.out.println(ans);
            } else if (i == n - 1) {
                ans -= Math.abs(array[n - 2] - array[n - 1]);
                ans -= Math.abs(array[n - 1]);
                ans += Math.abs(array[n - 2]);
                System.out.println(ans);
            } else {
                ans -= Math.abs(array[i - 1] - array[i]);
                ans -= Math.abs(array[i] - array[i + 1]);
                ans += Math.abs(array[i - 1] - array[i + 1]);
                System.out.println(ans);
            }
        }
    }
}


Measured memory_bytes: 65752
#include<stdio.h>
#include<algorithm>
#include<assert.h>
using namespace std;
typedef long long ll;
const int mod=1000000007;
int mul(int a,int b){return(ll)a*b%mod;}
int ad(int a,int b){return(a+b)%mod;}
void inc(int&a,int b){(a+=b)%=mod;}
int p[500010],rp[500010],s[500010],fac[500010],np[500010],l[500010],sn[500010];
//s[i] = '-1's in 0...i
//np[i] = count x [x<=i,x not in p]
//l[i] = count j [j<i,pj<pi,pj!=-1]
//sn[i]= sum [j<=i,pj!=-1] np[pj]
int tr[500010],n;
int lowbit(int x){return x&-x;}
void modify(int x){
	while(x<=n){
		tr[x]++;
		x+=lowbit(x);
	}
}
int query(int x){
	int s=0;
	while(x){
		s+=tr[x];
		x-=lowbit(x);
	}
	return s;
}
int C2(ll n){return n*(n-1)/2%mod;}
int main(){
	int k,i,ans,tmp,snp;
	scanf("%d",&n);
	k=0;
	for(i=0;i<n;i++){
		np[i]=1;
		rp[i]=l[i]=-1;
	}
	for(i=0;i<n;i++){
		scanf("%d",p+i);
		p[i]--;
		if(p[i]==-1)
			k++;
		else{
			np[p[i]]=0;
			rp[p[i]]=i;
		}
		s[i]=k;
	}
	for(i=0;i<n;i++){
		if(~rp[i]){
			l[rp[i]]=query(rp[i]+1);
			modify(rp[i]+1);
		}
	}
	l[0]=0;
	for(i=1;i<n;i++){
		if(l[i]==-1)l[i]=l[i-1];
	}
	snp=0;
	for(i=0;i<n;i++){
		if(np[i])inc(snp,i);
	}
	for(i=1;i<=n;i++)np[i]+=np[i-1];
	fac[0]=1;
	for(i=1;i<=n;i++)fac[i]=mul(fac[i-1],i);
	for(i=0;i<n;i++){
		if(i)sn[i]=sn[i-1];
		if(~p[i])inc(sn[i],np[p[i]]);
	}
	ans=0;
	for(i=0;i<n;i++){
		if(~p[i]){
			tmp=mul(fac[k],l[i]);
			if(k)inc(tmp,mul(mul(np[p[i]],fac[k-1]),s[i]));
			inc(ans,mul(fac[n-1-i],mul(fac[k],p[i])-tmp));
		}else{
			if(i)
				tmp=mul(fac[k-1],mul(i-s[i-1],np[n])-sn[i]);
			else
				tmp=0;
			if(s[i]>1)inc(tmp,mul(s[i]-1,mul(C2(k),fac[k-2])));
			inc(ans,mul(fac[n-1-i],mul(snp,fac[k-1])-tmp));
		}
	}
	inc(ans,fac[k]);
	printf("%d",ad(ans,mod));
}

Measured memory_bytes: 15744
from heapq import *
def main():
    import sys;input=sys.stdin.readline
    N, Q = map(int, input().split())
    X = []
    for _ in range(N):
        s, t, x = map(int, input().split())
        X.append((2*s-2*x-1, 0, x))
        X.append((2*t-2*x-1, 1, x))
    inf = 10**18
    X.append((-inf, 0, inf))
    X.append((inf, 1, inf))
    X.sort(key=lambda x: x[0])

    j = 0
    ll = []
    vs = set()
    d = dict()
    for _ in range(Q):
        q = int(input())
        while 1:
            u, f, x = X[j]
            if u > 2*q:
                break
            if f:
                if x not in d:
                    d[x] = 0
                d[x] += 1
            else:
                heappush(ll, x)
            j += 1
        while 1:
            x = heappop(ll)
            if x in d and d[x] > 0:
                d[x] -= 1
                continue
            heappush(ll, x)
            if x == inf:
                print(-1)
            else:
                print(x)
            break

if __name__ == '__main__':
    main()


Measured memory_bytes: 127012
N = int(input())
H = list(map(int, input().split()))

Sum = 0
hoge = [0]*len(H)

for i in range(len(H)-1):
    if H[i] >= H[i+1]:
        Sum += 1
        hoge[i+1] = Sum        
    else:
        Sum = 0
        
print(max(hoge))

Measured memory_bytes: 63984
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
const long long LINF = 1LL << 50;
#define int long long

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int k; cin >> k;
	VE d(k); rep(i, k)cin >> d[i];
	for (int i = n; i <= 10 * n; i++) {
		string tmp = to_string(i);
		bool ok = true;
		rep(j, tmp.size()) {
			rep(t, k) {
				if (tmp[j] - '0' == d[t]) {
					ok = false;
				}
			}
		}
		if (ok) {
			cout << tmp << endl; return 0;
		}
	}
	return 0;
}


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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

constexpr lli MOD = 1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;
constexpr int tenfive = 100000;


int main() {
	string w;
	bitset<30> bs(0);
	cin >> w;
	for (int i = 0; i < w.size(); i++) {
		bs[w[i] - 'a'].flip();
	}
	if (bs.none()) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

int main(){
  ll m,k;cin>>m>>k;
  if(k>=(1LL<<m)){
      cout<<-1<<endl;
      return 0;
  }
  if(m==0){
      cout<<0<<" "<<0<<endl;
      return 0;
  }
  if(m==1){
      if(k==0){
	  cout<<"0 0 1 1"<<endl;
      }
      if(k==1){
	  cout<<-1<<endl;
      }
      return 0;
  }
  vector<ll> v;
  for(int i=0;i<(1LL<<m);i++){
      if(i!=k)v.push_back(i);
  }
  vector<ll> ans;
  for(auto t:v)ans.push_back(t);
  ans.push_back(k);
  reverse(v.begin(),v.end());
  for(auto t:v)ans.push_back(t);
  ans.push_back(k);
  for(int i=0;i<ans.size();i++){
      if(i)cout<<" ";
      cout<<ans[i];
  }
  cout<<endl;
  return 0;
}


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

count = 0
flag = 0
while True:
    for i in range(N):
        if A[i] % 2 == 1:
            flag = 1
        else:
            A[i] = A[i] / 2

    if flag == 1:
        break
    else:
        count += 1

print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main(void) {

	int a, b, c, x, y, z, n;

	int R;
	cin >> R;
	cout << 2 * R * 3.1415 << endl;


	return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;

// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

const int INF = 10000000;
int N, M, C, S, G;
int cost[105][105];
int dist[25][105][105];
int fare[25][20005];
int p[25], q[25][55], r[25][55];

void solve() {
    S--, G--;
    // init
    for(int i = 0; i < C; i++) {
        for(int j = 0; j < N; j++) {
            for(int k = 0; k < N; k++) {
                dist[i][j][k] = INF;
            }
        }
    }

    // input
    int _x, _y, _d, _c;
    for(int i = 0; i < M; i++) {
        cin >> _x >> _y >> _d >> _c; _c--; _y--; _x--;
        dist[_c][_x][_y] = dist[_c][_y][_x] = min(dist[_c][_x][_y], _d);
    }
    for(int i = 0; i < C; i++) {
        cin >> p[i];
    }
    for(int i = 0; i < C; i++) {
        for(int j = 0; j < p[i] - 1; j++)  cin >> q[i][j];
        for(int j = 0; j < p[i]; j++)  cin >> r[i][j];
    }

    // wf
    for(int c = 0; c < C; c++) {
        for(int k = 0; k < N; k++) {
            for(int i = 0; i < N; i++) {
                for(int j = 0; j < N; j++) {
                    dist[c][i][j] = min(dist[c][i][j], dist[c][i][k] + dist[c][k][j]);
                }
            }
        }
    }

    // fare
    for(int c = 0; c < C; c++) {
        fare[c][0] = 0; 
        int idx = 0;
        for(int i = 0; i < 20000; i++) {
            if(idx < p[c] - 1 && q[c][idx] == i) idx++;
            fare[c][i + 1] = fare[c][i] + r[c][idx];
        }
    } 

    // cost
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            cost[i][j] = INF;
        }
    }
    for(int c = 0; c < C; c++) {
        for(int i = 0; i < N; i++) {
            for(int j = 0; j< N; j++) {
                if(dist[c][i][j] < INF) cost[i][j] = min(cost[i][j], fare[c][dist[c][i][j]]);
            }
        }
    }
    
    // wf
    for(int k = 0; k < N; k++) {
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    if(cost[S][G] == INF) cout << -1 << endl;
    else cout << cost[S][G] << endl;
}

signed main() {
    while(true) {
        cin >> N >> M >> C >> S >> G;
        if(N == 0 && M == 0 && C == 0 && S == 0 && G == 0) break;
        solve();
    };
    return 0;
}



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

template <class T>
class BinaryIndexedTree {
    int N;
    vector <T> bit;

public:
    BinaryIndexedTree(int n) : N(n), bit(n + 1, 0) {}

    BinaryIndexedTree(vector <T> ary) : N(ary.size()), bit(ary) {
        for (int x = 0; x < N - 1; x++) bit[x + (x & -x)] += bit[x];
    }

    void add(int a, T w) {
        for (++a; a <= N; a += a & -a) bit[a] += w;
    }

    T sum(int d) {
        T ret = 0;
        for (++d; d > 0; d -= d & -d) ret += bit[d];
        return (ret);
    }

    T sum(int x, int y) { return (sum(y) - sum(x - 1)); }
};

int main() {
    int n, q;
    cin >> n >> q;
    BinaryIndexedTree <int> bit(n);
    rep (i, q) {
        int a, b, c;
        cin >> a >> b >> c;
        b--; c -= a;
        if (a) cout << bit.sum(b, c) << endl;
        else   bit.add(b, c);
    }
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b)
        cout<<"0"<<endl;
    else if(a==b&&n==1)
        cout<<"1"<<endl;
    else if(a!=b&&n==1)
        cout<<"0"<<endl;
    else
        cout<<(n - 2)*(b - a)+1<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    int a,x,n,m,ans=0;
    cin>>x>>a;
    if(x<a) cout<<0<<endl;
    else    cout<<10<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
class SuffixArray:
    """
    construct:
        suffix array: O(N(logN)^2)
        lcp array: O(N)
        sparse table: O(NlogN)
    query:
        get_lcp: O(1)
    """
    def __init__(self, s):
        """
        s: str
        """
        self.__s=s
        self.__n=len(s)
        self.__suffix_array()
        self.__lcp_array()
        self.__sparse_table()

    # suffix array
    def __suffix_array(self):
        s=self.__s; n=self.__n
        # initialize
        sa=list(range(n))
        rank=[ord(s[i]) for i in range(n)]
        tmp=[0]*n
        k=1
        cmp_key=lambda i:(rank[i],rank[i+k] if i+k<n else -1)
        # iterate
        while(k<=n):
            sa.sort(key=cmp_key)
            tmp[sa[0]]=0
            for i in range(1,n):
                tmp[sa[i]]=tmp[sa[i-1]]+(cmp_key(sa[i-1])<cmp_key(sa[i]))
            rank=tmp[:]
            k<<=1
        self.__sa=sa
        self.__rank=rank

    # LCP array
    def __lcp_array(self):
        n=self.__n; s=self.__s;
        sa=self.__sa; rank=self.__rank
        lcp=[0]*n
        h=0
        for i in range(n):
            j=sa[rank[i]-1]
            if h > 0: h -= 1
            while j+h<n and i+h<n and s[j+h]==s[i+h]: h+=1
            lcp[rank[i]]=h
        self.__lcp=lcp

    # sparse table (LCPのminをとるindexを持つ)
    def __sparse_table(self):
        n=self.__n
        logn=max(0,(n-1).bit_length())
        table=[[0]*n for _ in range(logn)]
        table[0]=list(range(n))
        # construct
        for i in range(1,logn):
            for k in range(n):
                if k+(1<<(i-1))>=n:
                    table[i][k]=table[i-1][k]
                    continue
                if self.__lcp[table[i-1][k]]<=self.__lcp[table[i-1][k+(1<<(i-1))]]:
                    table[i][k]=table[i-1][k]
                else:
                    table[i][k]=table[i-1][k+(1<<(i-1))]
        self.__table=table

    def get_lcp(self,a,b):
        """
        a,b: int 0<=a,b<n
        return LCP length between s[a:] and s[b:]
        """
        if a==b: return self.__n-a
        l,r=self.__rank[a],self.__rank[b]
        l,r=min(l,r)+1,max(l,r)+1
        if r-l==1: return self.__lcp[l]
        i=(r-l-1).bit_length()-1
        if self.__lcp[self.__table[i][l]]<=self.__lcp[self.__table[i][r-(1<<i)]]:
            return self.__lcp[self.__table[i][l]]
        else:
            return self.__lcp[self.__table[i][r-(1<<i)]]
def resolve():
    n=int(input())
    s=input()
    sa=SuffixArray(s)
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            ans=max(ans,min(sa.get_lcp(i,j),j-i))
    print(ans)
resolve()

Measured memory_bytes: 51164
fun main(args: Array<String>) {
    
    val a = listOf(
            readLine()!!.split(" ").map { it.toInt() },
            readLine()!!.split(" ").map { it.toInt() },
            readLine()!!.split(" ").map { it.toInt() }
    )
    val n = readLine()!!.toInt()
    val b = (1..n).map { readLine()!!.toInt() }
    
/*
    val a = listOf(
            listOf(84, 97, 66),
            listOf(79, 89, 11),
            listOf(61, 59, 7)
    )
 
    val n = 7
 
    val b = listOf(
            89,
            7,
            87,
            79,
            24,
            84,
            30
    )
    */
 
    val card = listOf(
            mutableListOf(false, false, false),
            mutableListOf(false, false, false),
            mutableListOf(false, false, false)
    )
 
    b.forEach { value ->
        val pos = findPos(a, value)
        pos?.let { (x, y) ->
            card[y][x] = true
        }
    }
 
    if (isBingo(card)) {
        println("Yes")
    } else {
        println("No")
    }
}
 
fun findPos(list: List<List<Int>>, findValue: Int): Pair<Int, Int>? {
    list.forEachIndexed { y, xlist ->
        val x = xlist.indexOfFirst { it == findValue }
 
        if (x != -1) {
            return Pair(x, y)
        }
    }
 
    return null
}
 
fun isBingo(card: List<List<Boolean>>): Boolean {
    val length = card.size
 
    // 横のチェック
    card.forEach { xlist ->
        if (xlist.none { !it }) return true
    }
 
    // 縦のチェック
    (0 until length).forEach { x ->
        if ((0 until length).map { y -> card[y][x] }.none { !it }) return true
    }
 
    // 斜めのチェック
    if ((0 until length).map { card[it][it] }.none { !it }) return true
    if ((0 until length).map { card[it][length - 1 - it] }.none { !it }) return true
 
    return false
}

Measured memory_bytes: 39300
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s == "abc") {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (n, r) = input_tuple();
    if n >= 10 {
        println!("{}", r);
    } else {
        println!("{}", r + 100 * (10 - n));
    }
}


Measured memory_bytes: 2044
while gets do
  c = Array.new(13){0}
  $_.chomp.split(',').map(&:to_i).each{|i| c[i-1] += 1}
  str = c.join('')
  c.select!{|v| v!=0}

  res = 'null'
  case c.sort
    when [1,1,1,1,1]
      res = 'straight' if str =~ /1{5}/ || str =~ /10{8}1{4}/
    when [1,4]
      res = 'four card'
    when [2,3]
      res = 'full house'
    when [1,1,3]
      res = 'three card'
    when [1,2,2]
      res = 'two pair'
    when [1,1,1,2]
      res = 'one pair'
  end
  puts res
end

Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    string S;
    cin >> N >> S;
    int l = 0, r = 0;
    for(int i = 0; i < N; i++) {
        if(S[i] == '(') {
            l++;
        } else if(S[i] == ')') {
            if(l > 0) {
                l--;
            } else {
                r++;
            }
        }
    }
    string ans = "";
    for(int i = 0; i < r; i++) {
        ans += '(';
    }
    ans += S;
    for (int i = 0; i < l; i++) {
        ans += ')';
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define translow transform(s.begin(),s.end(),s.begin(),::tolower);
#define transup transform(s.begin(),s.end(),s.begin(),::toupper);
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;
vector<ll>parent,len;

            ll find(ll n)
            {
                if(parent[n]==n)
                    return n;
                return parent[n]=find(parent[n]);
            }


            void add(ll a, ll b)
            {
                a=find(a);
                b=find(b);
                if(a==b)
                    return ;
                if(len[a]<len[b])
                    swap(a,b);
                parent[b]=a;
                len[a]+=len[b];
                return ;
            }
 

 
 
int main() {
				       fast
               ll n,m;
               cin>>n>>m;
               parent.resize(n+1);
               len.resize(n+1);
               for(ll i=1;i<=n;i++)
               {
                parent[i]=i;
                len[i]=1;
               }

               while(m--)
               {

                ll a,b;
                cin>>a>>b;
                add(a,b);
               }
				ll ans=0;
               for(ll i=1;i<=n;i++)
               {
                ans=max(ans,len[find(i)]);
               }
			   cout<<ans<<endl;


                return 0;
            }

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

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

        long n = sc.NextLong();
        long[] a = sc.LongArray();
        a = a.OrderBy(num => num).ToArray();

        long max = a.Max();

        long mid = 0;
        long minDiff = long.MaxValue;

        for (int i = 0; i < n; i++)
        {
            long diff = Math.Abs(max - a[i] * 2);
            if (diff < minDiff)
            {
                mid = a[i];
                minDiff = diff;
            }
        }

        string answer = max + " " + mid;

        Console.Write(answer);
    }

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

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

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

            return _line[_index++];
        }

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

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

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


Measured memory_bytes: 40076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}


ll f[5000001];

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}

/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}

ll C(ll n, ll r, ll MOD)
{

 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
int main()
{
 ll n;
 cin>>n;
 int a[n]; int b[n];
  int c[n];
 for(int i=0;i<n;i++)
 {
     cin>>a[i]>>b[i]>>c[i];
 }
 bool f =false;
 for(int i=0;i<=100;i++)
 {

     for(int j=0;j<=100;j++)
     {

         int k=0;
         while(c[k]==0) k++;
         int h = c[k]+abs(i-a[k])+abs(j-b[k]);
         f=false;
         for(int l=0;l<n;l++)
         {
             if(l!=k)
             {
                 if(max(h-abs(i-a[l])-abs(j-b[l]),0)!=c[l])
                 {
                     f=true;
                     break;
                 }
             }
         }
         if(!f) {   cout<<i<<" "<<j<<" "<<h<<endl;
                break;}
     }
     if(!f)
        break;
 }
}


Measured memory_bytes: 256
void main() {
	auto N = ri;
	alias Pair = Tuple!(int, "score", int, "index");
	Pair[][string] m;
	foreach(i; 0..N) {
		auto ip = readln.chomp.split, S = ip[0], P = ip[1].to!int;
		m[S] ~= Pair(P, i+1);
	}
	foreach(v; m.keys.dup.sort()) {
		auto arr = m[v];
		arr.sort!"a.score > b.score"();
		arr.each!(i => i.index.writeln);
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))


bool comp(pair<ll,ll> &a,pair<ll,ll> &b){
    return a.second>b.second;
    //return a.first*a.second>b.first*b.second;
}

int main(){
    ll ans=0,n,m;
    cin>>n>>m;
    vector< pair<ll,ll> > a;
    for(int i=0;i<n;i++){
        ll v;
        cin >>v;
        a.push_back(make_pair(1,v));
    }
    for(int i=0;i<m;i++){
        ll bb,cc;
        cin>>bb>>cc;
        a.push_back(make_pair(bb,cc));
    }
    sort(a.begin(),a.end(),comp);

    ans=0;
    ll k=0;
    for(int i=0;k<n;i++){
        ans+=a[i].second*(min((n-k),a[i].first));
        k+=a[i].first;
    }
    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 6512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
using System.Linq.Expressions;

static class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

struct P
{
    public string Name;
    public int Time;
    public P(string s ,int time)
    {
        Name = s;
        Time = time;
    }
}

class Magatro
{
    private int N, Q;
    Queue<P> Que = new Queue<P>();
    private void Scan()
    {
        var line = Console.ReadLine().Split(' ');
        N = int.Parse(line[0]);
        Q = int.Parse(line[1]);
        for (int i = 0; i < N; i++)
        {
            line = Console.ReadLine().Split(' ');
            Que.Enqueue(new P(line[0], int.Parse(line[1])));
        }
    }

    public void Solve()
    {
        Scan();
        int t = 0;
        while (Que.Count > 0)
        {
            var p = Que.Dequeue();
            if (p.Time > Q)
            {
                t += Q;
                p.Time -= Q;
                Que.Enqueue(p);
            }
            else
            {
                t += p.Time;
                Console.WriteLine("{0} {1}", p.Name, t);
            }
        }
    }
}

Measured memory_bytes: 15904
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n,d,x;
cin >>n>>d>>x;
int a[110];
for(int i=0 ; i<n ; i++)
cin >>a[i];
int ans=x;
for(int i=0; i<n;i++){
  for(int j=0 ; j*a[i]+1<=d;j++){
    ans++;
  }
}
cout <<ans<<endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INF 1000000000 // 10^9
#define mod 1000000007
#define EPS 0.000000001 //10^-9
#define rep(i,a,b) for((i)=(a);(i)<=(b);(i++))
#define pb push_back 
using namespace std;
typedef long long ll;
class node
{
public:
    int value;
    node *left;
    node *right;
};
class node* newnode(int value)
{

    node* a=(node*)malloc(sizeof(node));
    a->value=value;
    a->left=NULL;
    a->right=NULL;
    return a;
};

ll power(ll x,ll n)
{
    if(x==0 || x==1||n==0)
        return 1;
    if(n==1)
        return x;
    if(n%2==0)
        return (power(((x%mod)*(x%mod))%mod,n/2)%mod);
    else
        return ((x%mod)*(power(x,n-1)%mod)%mod);
}

int main()
{
    ll n,d,i,s=0;
    ll x,y;
    cin>>n>>d;
    while(n--)
    {
        cin>>x>>y;
        if(x*x+y*y<=d*d)
            s++;
    }
    cout<<s;
    
 
}

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;

int getSameNum(int[],int[],int ,int );

int main(){
  int n,q;
  scanf("%d",&n);
  int s[n];
  for(int i=0;i<n;i++) 
    scanf("%d",&s[i]);
  scanf("%d",&q);
  int t[q];
  for(int i=0;i<q;i++)
    scanf("%d",&t[i]);
  sort(t,t+q);
  printf("%d\n",getSameNum(s,t,n,q));
  return 0;
}

int getSameNum(int s[],int t[],int n,int q){
  int cnt=0,mem=0;
  for(int i=0;i<q;i++)
    for(int j=mem;j<n;j++)
      if(t[i]==s[j]){
	cnt++;
	mem=j;
	break;
      }
  return cnt;
}

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

public class Main {

	void solve() {
		int n = in.nextInt();
		for (int a = 1; a <= 3500; a++) {
			for (int b = a; b <= 3500; b++) {
				long num = 4 * a * b - n * b - n * a;
				long denom = 1L * a * b * n;
				if (num > 0 && denom % num == 0) {
					out.println(a + " " + b + " " + (denom / num));
					return;
				}
			}
		}
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

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


Measured memory_bytes: 23508
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef int_fast64_t ll;

template<int N, typename T, T M>
struct ModFact {
    T fact[N+1];
    constexpr ModFact() : fact() {
        fact[0] = 1;
        for (int i=0; i<N; ++i)
            fact[i+1] = (fact[i]*(i+1))%M;
    }
};
 
ModFact<100000, ll, MOD> fact;

ll N, M, ans = 1;
int tmp, cnt = 0;
constexpr ll th = 1LL<<45;
char S[200000];

int main() {
    scanf("%lld\n", &N);
    M = N << 1;
    fread_unlocked(S, 1, M, stdin);
	for(size_t i = 0; i < M;) {
		tmp = (S[i++]=='B') + cnt;
		if(tmp&1) cnt++;
		else {
            ans *= cnt;
            if(ans > th) ans %= MOD;
            if(--cnt < 0) break;
        } 
	}
    ans = cnt == 0 ? ((ans % MOD) * fact.fact[N]) % MOD : 0;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define out(a) printf("%lld",a)
using namespace std;
int n;
int num1,num2;
ll ans=0,l,r;
int a[100000],b[100000],c[100000];
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int find(int x[],int y,int hh)
{
	int l=hh,r=n; int mid;
	while (l<=r) {
      mid=(l+r)>>1;
      if (x[mid]>y) r=mid-1;
      else l=mid+1;
  }
  return l;
}
int main()
{
	n=read();
	for (int i=1;i<=n;i++)
	    a[i]=read();
	for (int i=1;i<=n;i++)
	    b[i]=read();
	for (int i=1;i<=n;i++)
	    c[i]=read();
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	num1=0; num2=1;
	for (int i=1;i<=n;i++) {
	  while(num1<n&&b[i]>a[num1+1])num1++;
		while(num2<=n&&b[i]>=c[num2])num2++;
		ans+=(ll)num1*(ll)(n-num2+1);
	}
    out(ans);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    string s;
    int count=0;
    cin >> s;

    if(s[0]=='1')count++;
    if(s[1]=='1')count++;
    if(s[2]=='1')count++;

    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();

		if ((g * 10 + b) % 4 == 0) {
			System.out.print("YES");
		} else {
			System.out.print("NO");
		}

	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

signed main() {
    ll N, M;
    string S;
    cin >> N;
    vl W(N);
    FOR(i, 0, N) {
        cin >> W[i];
    }
    ll ans = LINF;
    FOR(T, 1, N) {
        ll l = 0, u = 0;
        FOR(i, 0, N) {
            if (i <= T)
                l += W[i];
            else
                u += W[i];
        }
        chmin(ans, abs(u - l));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

public class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int x = in.nextInt();
        out.println(x / 500 * 1000 + x % 500 / 5 * 5);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mod 1000000007
ll t,n,m,i,j,k,l,arr[sz],brr[sz],crr[sz];
vector<ll>v;
int main()
{
      scanf("%lld",&n);
      l=n%1000;
      l=(1000-l)%1000;
      printf("%lld\n",l);
    return 0;
}



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

int t[10][10],a[5];

int check(int k){
	if(k==0)return t[0][a[k]];
	return t[check(k-1)][a[k]];
}

int main(void){
	int cnt=0;
	rep(i,10)rep(j,10)cin>>t[i][j];
	rep(n,10000){
		bool flag=false;
		int d=1000;
		a[0]=n;
		rep(k,4){
			a[k+1]=a[k]%d;
			a[k]/=d;
			d/=10;
		}
		a[4]=check(3);

		/* Altering one single digit */
		rep(k,5){
			int tmp=a[k];
			rep(i,10){
				if(i==tmp)continue;
				a[k]=i;
				if(check(4)==0)flag=true;
			}
			a[k]=tmp;
		}

		/* Transposing two adjacent digits */
		rep(k,4){
			if(a[k]==a[k+1])continue;
			swap(a[k],a[k+1]);
			if(check(4)==0)flag=true;
			swap(a[k],a[k+1]);
		}

		if(flag)cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 3092
#include <iostream>

using namespace std;

int main() {
    int x;
    cin >> x;
    
    if(x == 3) {
        cout << "YES\n"; 
            //\nThe growth of a three-year-old child will be celebrated.\n";
    }
    else if(x == 5) {
        cout << "YES\n";
            //\nThe growth of a five-year-old child will be celebrated.\n";
    }
    else if(x == 7) {
        cout << "YES\n";
            //\nThe growth of a seven-year-old child will be celebrated.\n";
    }
    else cout << "NO\n";
        //See you next year.\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<map>
#include<set>
#define ll long long
//#define double long double
using namespace std;
#define PI  3.1415926535898 
#define eqs 1e-6
const long long max_ = 3000 + 7;
const int mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1e18;
int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
int min(int a, int b) {
	return a < b ? a : b;
}
int max(int a, int b) {
	return a > b ? a : b;
}
int node[5];
int main() {
	node[1] = read(), node[2] = read(), node[3] = read();
	sort(node + 1, node + 4);
	if (node[1] == node[2] && node[1] != node[3]) {
		cout << "Yes"; return 0;
	}
	if (node[3] == node[2] && node[2] != node[1]) {
		cout << "Yes"; return 0;
	}
	cout << "No"; return 0;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin>>n;
  int a;
  long long ans=0;
  map<int,int>m;
  
  for(int i=1;i<=n;i++){
    cin>>a;
    ans+=m[a-i];  

    m[-a-i]++;
  }

  cout<<ans<<endl;

  
  return 0;
}


Measured memory_bytes: 20608
function selectionSort(A,N){
   for(var i=0;i<N;i++){
      var minj=i;
      for(var j=i;j<N;j++){
         if(A[j]<A[minj])minj=j;
      }
      if(A[i]!=A[minj])cnt++;
      var memo=A[i];
      A[i]=A[minj];
      A[minj]=memo;
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
var arr=Arr.shift().split(" ").map(Number);
var cnt=0;
selectionSort(arr,n);
console.log(arr.join(" "));
console.log(cnt);

Measured memory_bytes: 7648
N, Y = map(int, input().split())

flag = False
for i in range(N + 1):  # 1000
    for j in range(N + 1):  # 5000
        k = N - i - j  # 10000
        if 0 <= k <= N and Y == i * 1000 + j * 5000 + k * 10000:
            flag = True
            print(k, j, i)
            break
    if flag:
        break
else:
    print("-1 -1 -1")


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

int main()
{
	int nums[100];
	int len = 0;
	for (int i = 0; ; ++i) {
		int n, x, a = 0;
		std::cin >> n >> x;
		if (n == 0 && x == 0) break;
		for (int j = 1; j < n - 1; ++j) {
			for (int k = j + 1; k < n; ++k) {
				for (int l = k + 1; l < n + 1; ++l) {
					int sum = j + k + l;
					if (sum == x) {
						a++;
					}
				}
			}
		}
		nums[i] = a;
		len++;
		std::cout << nums[i] << std::endl;
	}

	//for (int i = 0; i < len; ++i) {
	//	std::cout << nums[i] << std::endl;
	//}

	return 0;
}


Measured memory_bytes: 3096
N = int(input())
tasks = []
for i in range(N):
    a, b = list(map(int, input().strip().split()))
    tasks.append([a, b])

sorted_tasks = sorted(tasks, key=lambda x:x[1])
finish_time = 0
ans = "Yes"
for t in sorted_tasks:
    finish_time += t[0]
    if(finish_time > t[1]):
        ans = "No"
        break
print(ans)

Measured memory_bytes: 40544