akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		long cou=1;
		for(int i=n;0<n;n--){
			cou=cou*n;
		}
		System.out.println(cou);
	}
}

Measured memory_bytes: 17148
#include<bits/stdc++.h>
using namespace std;
const int N=60;
typedef long long ll;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,a[N],b[N],G[N][N];
int check(ll s) {
    memset(G,0,sizeof(G));
    for(int i=0;i<=50;i++) G[i][i]=1;
    for(int i=0;i<=50;i++)
        for(int j=1;j<=50;j++) if(s>>(j-1)&1) G[i][i%j]=1;
    for(int k=0;k<=50;k++)
        for(int i=0;i<=50;i++)
            for(int j=0;j<=50;j++) G[i][j]|=G[i][k]&G[k][j];
    for(int i=1;i<=n;i++) if(!G[a[i]][b[i]]) return 0;
    return 1;
}
int main() {
    n=gi();
    for(int i=1;i<=n;i++) a[i]=gi();
    for(int i=1;i<=n;i++) b[i]=gi();
    ll ans=(1ll<<51)-1;
    for(int i=50;i>=0;i--)
        if(check(ans^(1ll<<i))) ans^=1ll<<i;
    if(!check(ans)) puts("-1");
    else printf("%lld\n",ans<<1);
    return 0;
}


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

void textIO()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

}



int main()
{
    //textIO();
    fastIO();

    long long a, b , n;
    cin >> a >> b >> n;

    if(n < b){
        cout << ((a*n)/b) - (a*(n/b)) << '\n';
    }
    else{
        cout << ((a*(b-1))/b) - (a*((b-1)/b)) << '\n';
    }




    return 0;
}


Measured memory_bytes: 3588
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
import bisect
# import heapq # priolity-queue
# from time import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

# mod = int(1e9+7)
mod = 998244353
INF = 1<<50

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

def main():
    n,k = readInt()
    l = []
    r = []
    for i in range(k):
        a,b = readInt()
        l.append(a)
        r.append(b)
    dp = [0 for i in range(n+1)]
    dp[1] = 1
    dpsum = [0 for i in range(n+1)]
    dpsum[1] = 1
    for i in range(2,n+1):
        for j in range(k):
            lj = max(1,i - r[j])
            rj = i - l[j]
            if rj<1:
                continue
            dp[i] += dpsum[rj] - dpsum[lj-1]
            dp[i] %= mod
        dpsum[i] = dpsum[i-1] + dp[i]
    print(dp[n])
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 27856
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	vector<int> A(N, 0);
	for (int i = 0; i < N; ++i)
		cin >> A[i];

	int count = 0;
	bool flag = true;
	while (flag)
	{
		flag = false;
		for (int i = N - 1; i > 0; --i)
			if (A[i] < A[i - 1])
				swap(A[i], A[i - 1]), count++, flag = true;
	}

	for (int i = 0; i < N; ++i) {
		cout << A[i];
		i < N - 1 ? cout << " " : cout << endl;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1196
'use strict'
function main(input) {
    const std = input.split('\n')[0].split(' ').map(v => parseInt(v, 10));
    const participants = [...Array(std[0])].fill(std[1] - std[2]);
    let questions = input.split('\n');
    questions.shift();
    questions.forEach(q => participants[q-1]++);
    participants.forEach(v => v > 0 ? console.log("Yes") : console.log("No"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 50708
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	long long n, k;
	cin >> n >> k;
	long long a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = k; i < n; i++) {
		if (a[i] > a[i-k])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 5100
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 65010

/* ?\????1??´1???1??\?????????????????\??°?¨???? */
ll Fairfield(int y,int m,int d){
  if(m<=2){
    y--;
    m+=12;
  }
  
  ll dy = 365LL*(y - 1);
  ll dl = y / 4 - y / 100 + y / 400;
  ll dm = (306*m - 324) / 10;
  return dy + dl + dm + d - 1;
}

/* ?????\?¨???? (0??\?????\ - 6????????\)???*/
int Zeller(int y,int m,int d){
  if(m<=2){
    y--;
    m+=12;
  }
  return (y + y/4 - y/100 + y/400 + (13*m + 8)/5 + d)%7;
}

/* ???????????´ */
bool is_uruu(int y) {
  return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}


void calc(char *s){
  int dc = 0;
  
  for(int i=0;s[i]!='\0';i++){
    dc += s[i]=='.';
  }

  if(dc == 2){
    int y,m,d;
    sscanf(s,"%d.%d.%d",&y,&m,&d);

    ll dif = Fairfield(y, m, d) - Fairfield(2012, 12, 21);

    int ans[5] = {};

    ans[4] = dif%20;
    dif/=20;
    ans[3] = dif%18;
    dif/=18;
    ans[2] = dif%20;
    dif/=20;
    ans[1] = dif%20;
    dif/=20;
    ans[0] = dif%13;

    printf("%d.%d.%d.%d.%d\n",ans[0],ans[1],ans[2],ans[3],ans[4]);

  }else{
    int a,b,c,d,e;
    sscanf(s,"%d.%d.%d.%d.%d",&a,&b,&c,&d,&e);

    ll dif = 0;

    dif = a;
    dif = dif*20 + b;
    dif = dif*20 + c;
    dif = dif*18 + d;
    dif = dif*20 + e;
    
    int y = (int)max((dif/355) - 1,1LL);

    for(int i=y;;i++){
      for(int j=1;j<=12;j++){
        for(int k=1;k<=31;k++){
          if(k==31 && (j==2 || j==4 || j==6 || j==9 || j==11)) continue;
          if((j==2 && k==30) || (j==2 && !is_uruu(i) && k==29)) continue;

          if(dif == Fairfield(i, j, k) - Fairfield(2012, 12, 21)){
            printf("%d.%d.%d\n",i,j,k);
            return;
          }
        }
      }
    }

    assert(false);
  }
}
  

int main(){

  char s[20];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='#') break;
    calc(s);
  }
  
  return 0;
}

Measured memory_bytes: 1200
let rec take_while pred = function
    [] -> []
  | (x::xs) -> if pred x then x :: take_while pred xs else []

let rec scan_n n f v = if n <= 0 then [] else v :: scan_n (n-1) f (f v)

let arr = Array.init 101010 (fun i -> i)
let () = Scanf.scanf "%d" (fun n ->
  Array.init (n+1) (fun i ->
    [6; 9] |> List.iter (fun m ->
      scan_n 20 (( * ) m) 1 |> take_while ((>=) i) |> List.iter (fun j ->
        arr.(i) <- min arr.(i) (arr.(i - j) + 1)))) |> ignore;
  Printf.printf "%d\n" arr.(n))


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

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  vector<vector<char>> gori(h,vector<char>(w));
  rep(i,h){
    rep(j,w){
    cin>>gori[i][j];
    }
  }
  int ans=0;
  rep(i,1<<h){
    rep(j,1<<w){
      int ima=0;
      rep(hi,h)rep(wi,w){
        if(i>>hi&1 || j>>wi&1){
          continue;
        }
           if(gori[hi][wi]=='#'){
            ima++;
           }
      }
      if(ima==k){
        ans++;
      }
    }
  }
cout<<ans<<endl;
  }

Measured memory_bytes: 3580
#include <bits/stdc++.h>
//Fast io
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
//Class shorthands
#define ll long long
#define db long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
//Function Shorthands
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define po pop_back
#define eb emplace_back
//Code Shorthands
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
//Constants
#define hell 1000000007
#define PI acos(-1.0)
using namespace std;

void solve(){
    int d, t, s;
    cin>>d>>t>>s;
    if(d<=s*t) cout<<"Yes\n";
    else cout<<"No\n";
}

int main(){
    io;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,sum=0;
  cin>>n>>m; int arr[m];
  for(int i=0;i<m;i++)
  {
    cin>>arr[i];
     sum+=arr[i];
  }
  if(sum>n) cout<<"-1\n";
  else
  cout<<n-sum<<"\n";
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    set<string> S;

    for (int i = 0; i < n; i++) {
        string command;
        string str;
        cin >> command >> str;
        if (command == "insert") {
            S.insert(str);
            continue;
        }
        if (command == "find") {
            if (S.find(str) != S.end()) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 32136
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

double n;
vector<double> x;
vector<double> y;
vector<int> used;

double solve(int now, double a, vector<int> used){
  if(a == n) return 0;
  double ret = 0;

  for(int i = 0; i < n; i++){
    if(used[i]) continue;
    used[i] = 1;
    ret += sqrt(pow(x[i]-x[now], 2.0) + pow(y[i]-y[now], 2.0));
    ret += solve(i, a+1, used);
    used[i] = 0;
  }
  return ret/double(n-a);
}

int main(){
  cin >> n;
  for(int i = 0;i < n; i++){
    double a,b;
    cin >> a >> b;
    x.push_back(a);
    y.push_back(b);
    used.push_back(0);
  }
  double ret = 0;
  for(int i = 0; i < n; i++){
    used[i] = 1;
    ret += solve(i, 1, used);
    used[i] = 0;
  }
  printf("%.10lf\n", ret/(double)(n));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  string s;
  cin>>s;

  cout<<(s=="ABC"?"ARC":"ABC")<<newl;
  return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

bool pair_parens(string line) {
    stack<char> st;
    REP(i, line.length()) {
        switch (line[i]) {
        case '(':
        case '[':
            st.push(line[i]);
            break;
        case ')':
        case ']':
            if (!st.empty()) {
                char paren = st.top(); st.pop();
                if (paren == '(' && line[i] == ')') {
                } else if (paren == '[' && line[i] == ']') {
                } else {
                    return false;
                }
            } else {
                return false;
            }
            break;
        }
    }
    return st.empty();
}

int main() {
    string line;
    while (1) {
        getline(cin, line);
        if (line == ".") {
            break;
        }

        if (pair_parens(line)) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}

Measured memory_bytes: 1184
package main

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

func main() {
	S := ReadString()
	a := make([]int, len(S)+1)
	for i := 0; i < len(S); i++ {
		if S[i] == '<' {
			a[i+1] = a[i] + 1
		}
	}
	for i := len(S) - 1; i >= 0; i-- {
		if S[i] == '>' {
			v := a[i+1] + 1
			if a[i] <= v {
				a[i] = v
			}
		}
	}
	sum := 0
	for i := 0; i < len(a); i++ {
		sum += a[i]
	}
	fmt.Println(sum)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
char maze[10][10];



int main(){

    int h,w;
    cin>>h>>w;
    
    int cnt=0;
    rep(i,h)rep(k,w){cin>>maze[i][k];
    if(maze[i][k]=='#')cnt++;
    }
    /*
    queue<int>q;
    int dx[2]={0,1};
    int dy[2]={1,0};

    q.push(0);
    q.push(0);
    bool ans=(maze[0][0]=='#');

    while(!q.empty()){
    
        int nowx=q.front();q.pop();
        int nowy=q.front();q.pop();

        if(nowx==w-1 && nowy==h-1)break;

        int cnt=0;

        rep(i,2){
            int nx=nowx+dx[i];
            int ny=nowy+dy[i];

            if(nx>=w||ny>=h)continue;

            if(maze[ny][nx]=='#'){
            cnt++;
            q.push(nx);
            q.push(ny);
            }
        }

        if(cnt!=1){
        ans=false;
        break;
        }
    }

    */
   bool ans=(cnt ==h+w-1);
    if(ans){
        cout<<"Possible"<<endl;
    }
    else{
        cout<<"Impossible"<<endl;
    }

    return 0;

}
/*
2 2
.#
.#

*/


Measured memory_bytes: 256
//by OIerC
//Forca Barcelona!
#include<cstdio>
#include<algorithm>
#define int long long
#define rep(i, a, b) for (register int i=(a); i<=(b); ++i)
#define per(i, a, b) for (register int i=(a); i>=(b); --i)
using namespace std;
const int N=100005, P=998244353;
int a[N], b[N], c[N], n, ans;

inline int read()
{
 	int x=0,f=1;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*f;
}

void redouble(int x)
{
	for (; x; x>>=1)
	{
		if (x&1)
		{
			rep(i, 1, n) c[i]=a[b[i]];
			rep(i, 1, n) a[i]=c[i];
		}
		rep(i, 1, n) c[i]=b[b[i]];
		rep(i, 1, n) b[i]=c[i];
	}
}

signed main()
{
	n=read();
	rep(i, 1, n) a[i]=read(), b[i]=i;
	per(i, n, 1) a[i]-=a[i-1];
	int m=read(), k=read();
	rep(i, 1, m) 
	{
		int x=read();
		swap(b[x], b[x+1]);
	}
	redouble(k);
	rep(i, 1, n) printf("%lld\n", a[i]+=a[i-1]);
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
 
using namespace std;
 
#define x first
typedef pair<int,int> pii;

typedef long long ll;
const int mod = 1000000007;
const int oo = 1e9;
const int base = 27;
const int N = 1001;
const int M = 5001;

int n;
ll a[N];

bool check(ll md){
  for(ll nw = max(0ll,md-n*n);nw <= md ; nw++){
    ll g =0;
    for (int i = 0; i < n; ++i){
      ll rem = max(0ll,nw+a[i]-(n-1));
      ll nd = (rem/(n+1))+(rem%(n+1)!=0);
      g += nd;
    }
    if(g <= nw)return true;
  }
  return false;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i)scanf("%lld",a+i);
  ll lo = 0 , hi = 1e18,best =-1;
  while(lo <= hi){
    ll md = (lo + hi)/2;
    if(check(md)){
      best = md;
      hi = md-1;
    }else{
      lo = md+1;
    }
  }
  cout <<  best << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
ll k;
 
pair<ll,ll> mid(ll sx, ll sy, ll tx, ll ty){
    rep(i,2)rep(j,2){
        ll nx = sx+(2*i-1)*k, ny = ty + (2*j-1)*k;
        if(max(abs(nx-sx),abs(ny-sy))==k&&max(abs(nx-tx),abs(ny-ty))==k){
            return {nx,ny};
        }
    }
    rep(i,2)rep(j,2){
        ll nx = tx+(2*i-1)*k, ny = sy + (2*j-1)*k;
        if(max(abs(nx-sx),abs(ny-sy))==k&&max(abs(nx-tx),abs(ny-ty))==k){
            return {nx,ny};
        }
    }
    assert(false);
}
 
vector<pair<ll,ll>> ans;
void dfs(ll sx,ll sy,ll gx,ll gy){
    if(sx==gx&&sy==gy)return;
    ll d=abs(sx-gx)+abs(sy-gy);
    if(d==k){
        ans.emplace_back(gx,gy);
        return;
    }
    if(2*k<d){
        ll dx = gx-sx, dy = gy-sy;
        if(abs(dx)>=k){
            if(dx>0)sx+=k;
            else sx-=k;
            ans.emplace_back(sx,sy);
            dfs(sx,sy,gx,gy);
        }
        else if(abs(dy)>=k){
            if(dy>0)sy+=k;
            else sy-=k;
            ans.emplace_back(sx,sy);
            dfs(sx,sy,gx,gy);
        }
        else {
            sx=gx;
            if(dy<0)sy+=k-abs(dx);
            else sy-=k-abs(dx);
            ans.emplace_back(sx,sy);
            dfs(sx,sy,gx,gy);
        }
    }
 
    else if(d%2){
        ll dx = gx-sx, dy = gy-sy;
        if(abs(dx)>=k){
            if(dx>0)sx+=k;
            else sx-=k;
            ans.emplace_back(sx,sy);
            dfs(sx,sy,gx,gy);
        }
        else if(abs(dy)>=k){
            if(dy>0)sy+=k;
            else sy-=k;
            ans.emplace_back(sx,sy);
            dfs(sx,sy,gx,gy);
        }
        else {
            sx=gx;
            if(dy<0)sy+=k-abs(dx);
            else sy-=k-abs(dx);
            ans.emplace_back(sx,sy);
            dfs(sx,sy,gx,gy);
        }
    }
 
    else {
        auto p = mid(sx+sy,sx-sy,gx+gy,gx-gy);
        ans.emplace_back((p.first+p.second)/2,(p.first-p.second)/2);
        ans.emplace_back(gx,gy);
    }
}
 
int main(){
    ll x,y;
    cin>>k>>x>>y;
    if((x+y)%2&&k%2==0){
        cout<<-1<<endl;
        return 0;
    }
    dfs(0,0,x,y);
    cout<<ans.size()<<endl;
    for(auto p : ans){
        cout<<p.first<<" "<<p.second<<endl;
    }
    return 0;
}

Measured memory_bytes: 18156
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

pair<ll, ll> f(ll x, ll y)
{
    if (x == 0) return {0, 1};
    if (y == 0) return {1, 0};
    if (x < 0) x *= -1, y *= -1;
    return {x / __gcd(x, y), y / __gcd(x, y)};
}

int ask(int x)
{
    cout << x << endl;
    string s;
    cin >> s;
    if (s == "Vacant") exit(0);
    return s == "Male";
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int A = ask(0);
    int B = ask(n - 1);
    int L = 0, R = n - 1;
    while (L + 2 < R)
    {
        int M = (L + R) / 2;
        if (M % 2 == 1) M++;
        int C = ask(M);
        if (M % 2 == 0 && C == A) L = M;
        else R = M;
    }
    ask(L);
    ask(L + 1);
    ask(R);
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 852
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

// find_by_order(k) returns the iterator to the kth largest element (start from 0)
// order_of_key(k) returns the number of elements in the set which are strictly less than the value k

using namespace std;
using namespace __gnu_pbds;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout << fixed; cout << setprecision(x); cout << y;
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

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

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
// 1, 1, 2, 5, 14, 42, 132, 429, 1430, CATALAN NUMBER

int32_t main()
{
	g_b();
	int x, k, d; cin >> x >> k >> d;
	x = abs(x);
	int ans;
	int jumps = x / d;
	if (jumps > k) ans = x - k * d;
	else {
		ans = x - jumps * d;
		k -= jumps;
		if (k & 1)ans = abs(ans - d);
	} cout << ans;

	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<map>
#define PI 3.141592653589793238
#define INF -1
#define ll long long
#define rep(i,n) for(int (i) = 0;(i)<(n);(i)++)
using namespace std;

void swap(int& a, int& b)
{
	int tmp;
	tmp = a;
	a = b;
	b = tmp;
}

struct UnionFind {
	vector<int> d;
	UnionFind(int n) :d(n, -1) {};

	int root(int x)
	{
		if (d[x] < 0)return x;
		return d[x] = root(d[x]);
	}

	bool Union(int x, int y)
	{
		x = root(x);
		y = root(y);
		if (x == y)return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		//printf("d[%d] = %d, d[%d] = %d\n", x, d[x], y, d[y]);
		d[y] = x;
		return true;
	}
	bool same(int x, int y)
	{
		return root(x) == root(y);
	}
	int size(int x)
	{
		return -d[root(x)];
	}
};

int deg[100005] = { 0 };
vector<int> b[100005];

int main()
{
	int n, m, k;
	int t1, t2, ans;

	cin >> n >> m >> k;
	UnionFind uf(n);

	for (int i = 0; i < m; i++) {
		cin >> t1 >> t2;
		t1--; t2--;
		deg[t1]++;
		deg[t2]++;
		uf.Union(t1, t2);
	}
	for (int i = 0; i < k; i++) {
		cin >> t1 >> t2;
		t1--; t2--;
		b[t1].emplace_back(t2);
		b[t2].emplace_back(t1);
	}

	for (int i = 0; i < n; i++) {
		ans = uf.size(i) -1 - deg[i];
		for (int u : b[i]) {
			if (uf.same(u, i)) ans--;
		}
		printf("%d ", ans);
	}



	return 0;
}

Measured memory_bytes: 6784
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a;
    cin >> b;
    if((a%2 == 0) || (b%2 == 0))
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }
    return 0;
}

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

string str;
int n, ans;

int main(){
	cin >> str >> n;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		if(s.size() < str.size()) continue;
		bool ok = false;
		for(int j = 0; j < s.size(); j++){
			string tmp;
			for(int k = 0; k < str.size(); k++) tmp.push_back(s[(j+k)%s.size()]);
			if(tmp == str){
				ok = true;
				break;
			}
			if(ok) break;
		}
		ans += ok;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <cmath> //これはlogを使うときに必要
#include <vector> //これは配列(vector)を使うときに必要
using namespace std;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> vec;
  for(int i = 1; i <= min(a,b); i++) {
    if(a % i == 0 && b % i == 0) {
      vec.push_back(i);
    }
  }
  int size = vec.size();
  int ans = vec.at(size - k);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define set_zero(a) memset(a,0,sizeof(a));
#define ll long long
#define PI 2 * acos(0.0)
#define MAX 1000000000
#define INF 1000000 
#define M 1000000007
using namespace std;
int main(){
   fast_io
   ll n;
   cin>>n;
   ll a[n];
   for(ll i = 0;i<n;i++){
      cin>>a[i];
   }
   ll x = 1;
   ll ans = 0;
   for(ll i = 0;i<n;i++){
       if(a[i] == x){
          ans++;
          x++;
       }
   }
   if(ans == 0){
      ans = n+1;
   }
   cout<<n-ans<<endl;
   return 0;
}

Measured memory_bytes: 5228
#include "bits/stdc++.h"
using namespace std;

int main() {

	int A, B, M;
	cin >> A >> B >> M;

	vector<int> pri_A(A);
	vector<int> pri_B(B);

	for (int i = 0; i < A; i++)
		cin >> pri_A.at(i);

	for (int i = 0; i < B; i++)
		cin >> pri_B.at(i);

	vector<vector<int>> data(M, vector<int>(3));

	for (int i = 0;i < M; i++)
		cin >> data.at(i).at(0) >> data.at(i).at(1) >> data.at(i).at(2);

	int m = 200000;

	for (int i = 0; i < M; i++)
		m = min(m, pri_A.at(data.at(i).at(0) - 1) + pri_B.at(data.at(i).at(1) - 1) - data.at(i).at(2));

	sort(pri_A.begin(), pri_A.end());
	sort(pri_B.begin(), pri_B.end());


	m = min(m, pri_A.at(0) + pri_B.at(0));


	cout << m;
}


Measured memory_bytes: 8576
n, m = map(int, input().split())
inpath = [0] * n
innode = [[] for i in range(n)]
outnode = [[] for i in range(n)]
dp = [0] * n

for i in range(m):
    x, y = map(lambda z:z-1,map(int, input().split())) # 添え字を1~nから0~n-1に調整
    innode[y].append(x)
    outnode[x].append(y)
    inpath[y] += 1
S = []
L = []

for i in range(n):
    if inpath[i] == 0:
        S.append(i) #流入パスがないノードをSに追加

while S: # Sが空でない場合、続ける
    k = S.pop()
    L.append(k)
    for i in outnode[k]:
        inpath[i] -= 1
        if inpath[i] == 0:
            S.append(i)
 
for i in L:
    if not innode[i]: # 流入する辺がない場合    
        dp[i] = 0
    else:
        for j in innode[i]:
            dp[i] = max(dp[i], dp[j]+1)

print(max(dp))

Measured memory_bytes: 77600
n, m = map(int, input().split())
an = [0]*m

for i in range(m):
#    s = input()
    an[i] = int( input() )
#an[-1] = n

#an.sort()
disjoint = False
for i in range(len(an)-1):
    if an[i] + 1 == an[i+1]:
        disjoint = True


if disjoint:
    print(0)

else:

    mod = 10**9+7
    tab = [0]*(10**5+10)
    tab[0] = 0
    tab[1] = tab[2]= 1

    for i in range(3, len(tab)):
        tab[i] = tab[i-1]+tab[i-2]
#        if i<100:
#            print(tab[i])

    an.append(n)
    prev = 0
    ans = 1
    for a in an:
        index = a-prev + (1 if a == n else 0)
#        print(a,prev,index,tab[index])
        ans *= tab[index]
        ans %= mod
        prev = a+1

    #ans *= tab[n - prev]
    #ans %= 1000000007

    print(ans)



Measured memory_bytes: 462068
import sys
input = sys.stdin.readline
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
ip = [k-q]*(n+1)
for j in a:
  ip[j] += 1
ans = '\n'.join('Yes' if p > 0 else 'No' for p in ip[1:])
print(ans)

Measured memory_bytes: 11308
#include<bits/stdc++.h>
 
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

using namespace std;

int32_t main()
{
	IOS;
	int n, k;
	cin>>n>>k;
	int a[n+1];
	for (int i = 1; i <= n; ++i)
	{
		cin>>a[i];
		/* code */
	}
	std::vector<int> adj[n+1];
	for (int i = 0; i < k; ++i)
	{
		int x, y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int ans=0;
	for (int i = 1; i <= n; ++i)
	{
		int cnt = 0;
		for (int j = 0; j < adj[i].size(); ++j)
		{
			int v = adj[i][j];
			if(a[i] > a[v])
			{
				cnt++;
			}
			/* code */
		}
		if(adj[i].size() == 0)
			ans++;
		else if(adj[i].size() == cnt)
			ans++;
		/* code */
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 10284
X = int(input())

if X%7 == 2 :
  print('sat')
if X%7 == 3:
  print('sun')
if X%7 == 4:
  print('mon')
if X%7 == 5:
  print('tue')
if X%7 == 6 :
  print('wed')
if X%7 == 0:
  print('thu')
if X%7 == 1:
  print('fri')


Measured memory_bytes: 5592
import sys
sys.setrecursionlimit(10**7)    
from collections import deque
input = sys.stdin.readline

seen=[]
#seen=dict()
path=[]

def dfs(g, v,add):
    xx[v]+=add
#    path.append(v)
    seen[v]=True
    for next_v in g[v]:
        if seen[next_v]:
            continue
        dfs(g, next_v,xx[v])
#    path.append(v)

    return

icase=0
if icase==0:
    n,q=map(int,input().split())
#    g = [deque([]) for _ in range(n)]
    g = [set() for _ in range(n)]
    for i in range(n-1):
        ai,bi=map(int,input().split())
#        g[ai-1].append(bi-1)
#        g[bi-1].append(ai-1)
        g[ai-1].add(bi-1)
        g[bi-1].add(ai-1)
    g=tuple(g)
    xx=[0]*n
    for i in range(q):
        pi,xi=map(int,input().split())
        xx[pi-1]=xx[pi-1]+xi
elif icase==3:
    n,q=6,2
    g = [deque([]) for _ in range(n)]
    g[0]=deque([1,2])
    g[1]=deque([0,3,4])
    g[2]=deque([0,5])
    g[3]=deque([1])
    g[4]=deque([1])
    g[5]=deque([2])
    p=[0]*q
    x=[0]*q
    p[0]=0
    x[0]=10    
    p[1]=0
    x[1]=10    
    xx=[0]*n
    for i in range(q):
#        pi,xi=map(int,input().split())
        xx[p[i]]=xx[p[i]]+x[i]
elif icase==1:
    n,q=3,3
    g = [deque([]) for _ in range(n)]
    g[0]=deque([2])
    g[1]=deque([2])
    g[2]=deque([0,1])
    p=[0]*q
    x=[0]*q
    p[0]=1
    x[0]=10    
    p[1]=2
    x[1]=100
    p[2]=0
    x[2]=1    
    xx=[0]*n
    for i in range(q):
#        pi,xi=map(int,input().split())
        xx[p[i]]=xx[p[i]]+x[i]
#ans:1 111 101
elif icase==2:
    n,q=4,3
    g = [deque([]) for _ in range(n)]
    g[0]=deque([1])
    g[1]=deque([0,2,3])
    g[2]=deque([1])
    g[3]=deque([1])
    p=[0]*q
    x=[0]*q
    p[0]=1
    x[0]=10    
    p[1]=0
    x[1]=100
    p[2]=2
    x[2]=1    
    xx=[0]*n
    for i in range(q):
#        pi,xi=map(int,input().split())
        xx[p[i]]=xx[p[i]]+x[i]
#ans:100 110 111 110

#c=[0]*n

seen=[False]*n
#for i in range(n):
#    seen[i]=False
dfs(g,0,0)

#print(path)

'''
seen=[False]*n

c=[0]*n
cpt=0
for pt in path:
    if seen[pt]==False:
        seen[pt]=True
#        print("pt:",pt,"cpt:",cpt,"xx[pt]:",xx[pt],"c[pt]:",c[pt]+cpt+xx[pt])
        cpt=cpt+xx[pt]
        c[pt]=c[pt]+cpt
    else:
        seen[pt]=False
        cpt=cpt-xx[pt]
           
for i in range(n):
    print(c[i],end=" ")
print()
'''

ans=" ".join(map(str,xx[0:]))
print(ans)
    


Measured memory_bytes: 259628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define CloseIO std::ios::sync_with_stdio(false)
const ll N = 8e6+1000;
const ll Mod = 100;
const ll INF = 0x3f3f3f3f3f;
int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int tmp = n/2;
  cout<<a[n/2] - a[n/2-1]<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  string w;
  cin >> w;
  transform(w.begin(), w.end(), w.begin(), ::toupper);
  string s;
  int ans = 0;
  while (cin >> s) {
    if (s == "END_OF_TEXT") { break; }
    transform(s.begin(), s.end(), s.begin(), ::toupper);
    if (s == w) { ++ans; }
  }
  fprintf(stdout, "%d\n", ans);
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    int minus = 0;
    bool zero = true;
    ll mini = LINF, sum = 0;

    rep(i, n) {
        if (v[i] < 0) minus++;
        mini = min(mini, abs(v[i]));
        sum += abs(v[i]);
    }
    ll ans = 0;
    if (minus % 2 == 0) ans = sum;
    else ans = sum - mini * 2;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
#define N 100

int main(){
  int m[N][N];
  int n,u,k,v;
  int i,j;

  scanf("%d",&n);

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

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

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",m[i][j]);
    }
    printf("\n");
  }

  return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



void func(long long N, long long K, std::vector<long long> p){

    SORT(p);

    lli sum=0;
    REP(i,0,K)sum+=p[i];
    cout<<sum<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    func(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 3684
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ASandglass2 {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    ll x, t;
	    in >> x >> t;
	    out << max(x-t, 0LL) << endl;
	}
};


int main() {
	ASandglass2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
	long n;
	long r[200000];
	
	scanf(" %ld", &n);
	for(long i=0; i<n; ++i) scanf(" %ld", &r[i]);
	
	long maxv=-2000000000;
	long minv=r[0];
	for(long i=1; i<n; ++i){
		maxv=max(maxv, r[i]-minv);
		minv=min(minv, r[i]);	
	}
	
	printf("%ld\n", maxv);
}

Measured memory_bytes: 2752
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <climits>

using namespace std;

typedef vector< vector< int > > matrix;
int N,M;

int solve_rec(matrix &G, int u, vector<int> &DP){
	if(DP[u] != -1)
		return DP[u];
	int massimo = 0;
	for(int i=0; i < G[u].size(); i++){
		massimo = max(solve_rec(G,G[u][i],DP) , massimo );
	}
	DP[u] = massimo+1;
	return massimo +1;
}

int solve(matrix &G){
	vector<int> DP(N,-1);
	int ret = -1;
	
	for(int i=0; i < N; i++){
		DP[i] = solve_rec(G,i,DP);
	}
	
	for(int i=0; i < N; i++){
		ret = max(ret,DP[i]);
		//cout << DP[i] << " (" << i << ")  " ;
	}
	
	return ret-1;
}


int main(int argc, char** argv) {
	cin >> N >> M;
	
	matrix G(N, vector<int>() );
	
	for(int i=0;i< M;i++){
		int p,e;
		cin >> p >> e;
		G[p-1].push_back(e-1);
	}
	
	cout << solve(G);	
	return 0;
}

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


  int n;
  cin>>n;
  vector<int> a(n+1);
  vector<int> b(n);
  for(int i=0;i<n+1;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  int64_t ans=0;
  for(int i=0;i<n;i++){
    if((a[i]+a[i+1])<=b[i]){ 
      ans+=a[i]+a[i+1];
      a[i+1]=0;
    }
    else if(a[i]>=b[i]){
      ans+=b[i];
    }
    else {
      a[i+1]-=b[i]-a[i];
      ans+=b[i];
    }
  }
  cout<<ans<<endl;
}
     


Measured memory_bytes: 1024
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i).sort
memo = {}
a.each do |num|
  memo[num] ? memo[num] += 1 : memo[num] = 1
end
count = 0
memo.each do |k,v|
  if (k > v)
    count += v
  elsif (k < v)
    count += v-k
  else
  end
end
puts count

Measured memory_bytes: 26856
#include<iostream>
using namespace std;
int main() {
	long long int s;
	cin >> s;
	long long int x1, x2, x3, y1, y2, y3;
	x1 = y1 = x2 = y2 = x3 = y3 = 0;
	//|x1-x2|*|y1-y3|/2=s/2
	if (s < 1e9) {
	x2 = 1;
	y3 = s;
	}
	else if(s < 1e18){
		x1 = 1;
		y3 = 1e9;
		x2 = s / y3 + 1;
		y2 = s - (x2 - 1) * y3;
	}
	else {
		x1 = 0;
		y3 = 1e9;
		x2 = s / y3;
		y2 = s - x2 * y3;
	}
	
	cout << x1 <<" "<< y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
	return 0;
}

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

#define MIN(a,b) ((a)<(b)?(a):(b))
int getGroup(int x) {

	switch (x) {
	case 1:return 0;
	case 2:return 1;
	case 3:return 0;
	case 4:return 2;
	case 5:return 0;
	case 6:return 2;
	case 7:return 0;
	case 8:return 0;
	case 9:return 2;
	case 10:return 0;
	case 11:return 2;
	case 12:return 0;
	}
}

int main() {
	int x, y;
	cin >> x >> y;
	if (getGroup(x) == getGroup(y)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
from heapq import heappop, heappush

n,m = map(int,input().split())
byte = {}
for i in range(n):
    a,b = map(int,input().split())
    if a > m:
        continue
    if a not in byte:
        byte[a] = []
    byte[a].append(-b)

ans = 0
res = []
for i in range(1, m+1):
    if i in byte:
        for b in byte[i]:
            heappush(res, b)
    if res:
        ans -= heappop(res)
print(ans)


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  while (cin >> n >> k) {
    vector<int> v(n);
    cin >> v;
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    cout << accumulate(v.begin(), v.begin() + k, 0) << endl;
  }
  
  return 0;
}


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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

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

    rep(i,3){
        if(s[i]=='S')a=0;
        else a++;
        b=max(a,b);
    }

    cout << b;
    return 0;
}

Measured memory_bytes: 3620
#%%
n, u, v = map(int, input().split())
u, v = u-1, v-1
reach = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(lambda x: int(x)-1, input().split())
    reach[a].append(b)
    reach[b].append(a)

def x_route(x, reach):
    x_route = [[-1, -1] for _ in range(n)]
    check = [0] * n
    stack = [x]
    check[x] = 1
    x_route[x] = [-1, 0]
    while len(stack) > 0:
        tmp = stack.pop(-1)
        tmp_list = reach[tmp]
        for i in tmp_list:
            if check[i] == 1:
                pass
            else:
                stack.append(i)
                check[i] = 1
                x_route[i] = [tmp, x_route[tmp][1]+1] 
    return x_route

a_route = x_route(v, reach)
t_route = x_route(u, reach)
ans = 0
for i in range(len(a_route)):
    if t_route[i][1] < a_route[i][1]:
        ans = max(ans, a_route[i][1]-1)

print(ans)

Measured memory_bytes: 95904
import java.util.*;
public class Main {
	//0224 start
	//0300 stop
	//2300 restart
	//2323 AC
	int t, num,len;
	String numstr;
	int [] ansarray,work;
	int ans;
	boolean rejected;

	private void dfs(int deep, int index){
		if(index == len-1){
			int res = calc(work);
			if(res <= t && res > ans){
				ans = res;
				ansarray = work.clone();
				rejected= false;
			}
			else if(res == ans){
				rejected = true;
			}
		}

		for(int i = index + 1; i < len; i++){
			work[deep] = i;
			dfs(deep + 1, i);
			work[deep] = -1;
		}
	}


	private int calc(int[] a) {
		int start = -1, i = 0, end = a[i++], sum = 0;
		while(start != len - 1){
			String temp = numstr.substring(start + 1, end + 1);
			sum += Integer.parseInt(temp);
			start = end;
			end = a[i++];
		}
		return sum;
	}


	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			t = sc.nextInt();
			numstr = sc.next();
			if(t == 0 && numstr.equals("0")) break;
			len = numstr.length();
			ansarray = new int[len + 1];
			work = new int[len + 1];
			Arrays.fill(work, -1);
			ans = -1;
			rejected = false;
			dfs(0,-1);
			if(rejected){
				System.out.println("rejected");
			}
			else if(ans == -1){
				System.out.println("error");
			}
			else{
				System.out.print(ans);
				int start = -1, end = ansarray[0];
				StringBuilder sb = new StringBuilder();
//				for(int i = 0; i < ansarray.length - 1; i++){
//					if(ansarray[i] == -1) break;
//					String temp = numstr.substring(start + 1, end + 1);
//					System.out.print(" " + temp);
//					start = end;
//					end = ansarray[i + 1];
//				}
				int ind = 0;
				for(int i = 0; i < len; i++){
					sb.append(numstr.charAt(i));
					if(ansarray[ind] == i && ansarray[ind + 1] != -1 ){
						ind++;
						sb.append(" ");
					}
				}
				System.out.println(" " + sb.toString());
			}
		}
	}

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

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
int N;
long mod=1e9+7,dp[1<<17];
bool out[1<<17];
main()
{
	int M;cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int a;cin>>a;out[a]=1;
	}
	dp[0]=1;
	for(int i=0;i<N;i++)
	{
		if(!out[i+1])(dp[i+1]+=dp[i])%=mod;
		if(!out[i+2])(dp[i+2]+=dp[i])%=mod;
	}
	cout<<dp[N]<<endl;
}


Measured memory_bytes: 1152