akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    int N, K;
    cin >> N >> K;

    int limit = (N - 2) * (N - 1) / 2;

    if (K > limit) {
        cout << -1 << '\n';
        return 0;
    }

    
    int rem = limit - K;
    cout << N - 1 + rem << '\n';

    for (int i = 2; i <= N; ++i) {
        cout << 1 << ' ' << i << '\n';
    }
    
    for (int i = 2; i <= N - 1; ++i) {
        for (int j = i + 1; j <= N; ++j) {
            if (rem == 0) {
                return 0;
            }
            cout << i << ' ' << j << '\n';
            rem--;
        }    
    }

    return 0;
}


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


int main(){
    int x,y,z;
    cin >> x >> y >> z;
    if (x%(y+z) < z) cout << x/(y+z)-1 << endl;
    else cout << x/(y+z) << endl;  

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int C[200][200];
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        string S;
        cin >> S;
        for (int j = 0; j < N; ++j) {
            if (S[j] == '1') {
                C[i][j] = 1;
            }
        }
    }
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            if (k == i) continue;
            for (int j = 0; j < N; j++) {
                if (k == j || i == j) continue;
                if (C[i][k] == 0 || C[k][j] == 0) continue;
                if (C[i][j] == 0) {
                    C[i][j] = C[i][k]+C[k][j];
                } else if (C[i][j] % 2 != (C[i][k]+C[k][j])%2) {
                    printf("%d\n", -1);
                    return 0;
                } else if (C[i][j] == 1) {
                    continue;
                } else if (C[i][j] > C[i][k]+C[k][j]) {
                        C[i][j] = C[i][k]+C[k][j];
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            ans = max(ans, C[i][j]);
        }
    }
    printf("%d\n", ans+1);
    return 0;
}


Measured memory_bytes: 384
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n;
vector<int> v, V;
vector<int> ans;
int fb[33];
bool used[30011];
int main()
{
	cin>>n;
	for (int i=2; i<=30000; i++)
	{
		if (i%2==0||i%3==0||i%5==0)
		{
			if (i==2||i==3||i==25) continue;
			v.PB(i);
		}
	}
	for (int i=0; i<v.size(); i++)
	{
		if (!fb[v[i]%30])
		{
			fb[v[i]%30] = v[i];
			used[i] = 1;
		}
		else V.PB(v[i]);
	}
	ans.PB(2);
	ans.PB(3);
	ans.PB(25);
	if (n>3)
	{
		n -= 4;
		while (true)
		{
			ll sum = 30;
			random_shuffle(V.begin(), V.end());
			for (int i=0; i<n; i++)
			{
				sum += V[i];
			}
			int lst = fb[(30-sum%30)%30];
			if (lst!=0)
			{
				for (int i=0; i<n; i++) ans.PB(V[i]);
				ans.PB(lst);
				break;
			}
		}
	}
	for (auto x:ans) puti(x);
	return 0;
}


Measured memory_bytes: 768
a = [int(i) for i in input().split()]
diff = a[1]-1
taste = []
for i in range(1,a[0]+1):
    taste.append(diff+i)

all_t = sum(taste)
lists=[]
tmp = []
for i in range(a[0]):
    tmp = taste[:]
    del taste[i]
    lists.append(abs(all_t - sum(taste)))
    taste.clear()
    taste = tmp
    
del taste[lists.index(min(lists))]
print(sum(taste))

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>

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

using namespace std;

vector<int> bfs(const vector<vector<int>>& t, int si, int sj, int h, int w) {
  queue<tuple<int,int,int>> q;
  q.push(make_tuple(si,sj,t[si][sj]));
  vector<vector<int>> mc(h,vector<int>(w,1000000000));
  mc[si][sj] = t[si][sj];
  while(!q.empty()){
    int i,j,c;
    tie(i,j,c) = q.front();q.pop();
    if (c > mc[i][j]) continue;
    int di[]={1,0,-1,0};
    int dj[]={0,1,0,-1};
    REP(k,4){
      int ni=i+di[k];
      int nj=j+dj[k];
      if(ni<0||ni>=h||nj<0||nj>=w)continue;
      if(mc[ni][nj] > max(t[ni][nj], mc[i][j])) {
        mc[ni][nj] = max(t[ni][nj], mc[i][j]);
        q.push(make_tuple(ni,nj,mc[ni][nj]));
      }
    }
  }
  vector<int> ans;
  REP(i,h)REP(j,w)ans.push_back(mc[i][j]);
  return ans;
}

int main() {
  while(1){
    int r;
    cin>>r;
    if(!r)break;
    int w[2],h[2],x[2],y[2];
    vector<vector<vector<int>>> t(2);
    vector<vector<int>> ans(2);
    REP(i,2){
      cin>>w[i]>>h[i]>>x[i]>>y[i];
      --x[i];--y[i];
      t[i] = vector<vector<int>>(h[i],vector<int>(w[i]));
      REP(j,h[i])
        REP(k,w[i])
          cin>>t[i][j][k];
      ans[i] = bfs(t[i],y[i],x[i],h[i],w[i]);
    }
    REP(i,2)
      sort(begin(ans[i]),end(ans[i]));
    int mn = 1000000000;
    if (w[0]*h[0] >= r)
      mn = min(mn, ans[0][r-1]);
    if (w[1]*h[1] >= r)
      mn = min(mn, ans[1][r-1]);
    REP(i,min(r-1,w[1]*h[1])){
      int l1 = ans[1][i];
      int l2 = ans[0][r-i-2];
      mn = min(l1 + l2, mn);
    }
    cout << mn << endl;
  }
  return 0;
}

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

int main() {
    int N,M,X,Y;
    cin>>N>>M>>X>>Y;
    vector<int>datax(N);
    vector<int>datay(M);
    for(int i=0;i<N;i++){
        cin>>datax.at(i);
        }  
    for(int i=0;i<M;i++){
        cin>>datay.at(i);   
    }
    sort(datax.begin(),datax.end());
    reverse(datax.begin(),datax.end());
    sort(datay.begin(),datay.end());

    int mxx=max(datax.at(0),X);
    int miny=min(datay.at(0),Y);
    if(mxx+1<=miny){
        cout<<"No War"<<endl;
    }
    else cout <<"War"<<endl;
}


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

// Shortening code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

// Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)

ll INF = 1e9 + 5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // Your code
    int n;
    cin >> n;
    vi a(n);
    REP(i, 0, n)
    {
        cin >> a[i];
    }

    vi dp(n + 1, INF);
    dp[0] = 0;

    REP(i, 0, n)
    {
        if (i + 1 < n)
        {
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i + 1] - a[i]));
        }
        if (i + 2 < n)
        {
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i + 2] - a[i]));
        }
    }
    cout << dp[n - 1];

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    if(N%2 == 1){
        cout << "No" << endl;
    }else{
        if(S.substr(0,N/2) == S.substr(N/2,N)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
using namespace std;
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a,b,c >=1 && a,b,c <=100){
        if((b-a) == (c-b)){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }

   return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      int N = in.nextInt();
      for (int i = 0; i < N; i++) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        
        if (a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b) {
          out.println("YES");
        } else {
          out.println("NO");
        }
      }
        
      
//      End solve()
    }
//    End Solution
}


  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}


  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

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

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr <<">>>>>>"<< #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif


int main()
{
	
	long long n,an=1;
	cin>>n;
	n++;
	while(--n)an=(an*n)%1000000007;
	cout<<an<<endl;
}



Measured memory_bytes: 3572
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

double solve(vector<pair<double, string>>& v) {
  double BTC = 380000.0;
  double sum{};
  for (auto e : v) {
    double x = e.first;
    string u = e.second;
    if (u == "BTC") {
      x *= BTC;
    }
    // cout << u << endl;
    sum += x;
  }
  return sum;
}

int main() {
  int n;
  vector<pair<double, string>> v;
  cin >> n;
  REP(i, n) {
    double d;
    string s;
    cin >> d >> s;
    v.emplace_back(d, s);
  }
  cout << solve(v) << endl;
}


Measured memory_bytes: 256
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();

    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    line.trim()
        .split_whitespace()
        .map(|x| x.parse::<T>())
        .collect::<Result<Vec<T>, _>>()
        .map_err(|_| format!("{}", "parse error"))
}

fn main() {
    let n = read_parameters::<usize>().unwrap();
    let n = n[0];
    let mut xs = read_parameters::<isize>().unwrap();

    for i in 1..n {
        print_result(&xs);
        let key = xs[i];
        let mut j: isize = i as isize - 1;
        while j >= 0 && xs[j as usize] > key {
            xs.swap((j + 1) as usize, j as usize);
            j -= 1;
        }
        xs[(j + 1) as usize] = key;
    }
    print_result(&xs);
}

fn print_result(x: &Vec<isize>) {
    for i in 0..x.len() - 1 {
        print!("{} ", x[i]);
    }
    println!("{}", x[x.len() - 1]);
}



Measured memory_bytes: 5032
#include<bits/stdc++.h>
#define INF 9003372036854775807LL
#define mod 998244353
#define fixed fixed<<setprecision(12)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii=pair<int, int > ;
lol a[300010];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  lol n,m,k,r,x,y;
  cin >>n;
  for(int i=0;i<n-1;i++){
    cin >>m;
    a[m]++;
  }
  for(int i=1;i<=n;i++){
    cout <<a[i]<<'\n';
  }
  return (0);
}


Measured memory_bytes: 5180
import java.util.*;
import java.lang.*;
public class Main{
    public static int calc(int arr[][],int n,int dp[][]){

        for(int i=0;i<n;i++){
            for(int j=0;j<3;j++){
                if(i==0)dp[i][j]=arr[i][j];
                else if(j==0){
                    dp[i][j]=Math.max(Math.max(dp[i][j],dp[i-1][j+1]+arr[i][j]),dp[i-1][j+2]+arr[i][j]);
                }
                else if(j==1){
                    dp[i][j]=Math.max(Math.max(dp[i][j],dp[i-1][j+1]+arr[i][j]),dp[i-1][j-1]+arr[i][j]);
                }
                else if(j==2){
                    dp[i][j]=Math.max(Math.max(dp[i][j],dp[i-1][j-1]+arr[i][j]),dp[i-1][j-2]+arr[i][j]);
                }
                
            }
        }

        return Math.max(Math.max(dp[n-1][2],dp[n-1][0]),dp[n-1][1]);

    }

    public static void main(String[] args){
        int n;
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        int arr[][]=new int[n][3];
        for(int i=0;i<n;i++){
            for(int j=0;j<3;j++){
                arr[i][j]=sc.nextInt();
            }
        }
        int dp[][]=new int[n][3];
        int res=calc(arr,n,dp);
        System.out.println(res);
    }
    
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n; scan(n);
      puts(n / 10 == 9 or n % 10 == 9 ? "Yes" : "No");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




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

/*                        [Template]                        */
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define let auto
#define of :
#define all(y) y.begin(), y.end()
#define present( x, y ) x.find( y ) != x.end()
#define _matrix(T) vector<vector<T>>
template<class T>
auto matrix( int r, int c, T v ){
	return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
int mod = (int)1e9 + 7 ;

/************************************************************/

auto accumulate( vector<int> &a, int &n ){
	vector<int> prefix( n, 0 ) ;
	prefix[0] = a[0] % mod ;
	for( int i = 1 ; i < n ; i++ ){
		(prefix[i] = prefix[i-1] + a[i]) %= mod ;
	}
	return prefix ;
} 
int sum( vector<int> &a, int f, int t ){
	return (( a[t] - (( f == 0 ) ? 0 : a[f-1]) ) + mod) % mod ;
}


signed main(){
	int n ; cin >> n ;
	vector<int> a(n) ;
	for( int i = 0 ; i < n ; i++ ) cin >> a[i] ;
	int ans = 0 ;
	let prefix = accumulate( a, n ) ;
	// for( let p of prefix ) cout << p << " " ; cout << endl;
	for( int i = 0 ; i < n - 1 ; i++ ){
		// cout << sum( prefix, i + 1, n - 1 ) << endl ;
		ans += ( a[i] * sum( prefix, i + 1, n - 1 ) ) ;
		ans %= mod ;
	}
	cout << ans ;	
	return 0 ;
}

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


int main()
{
    int n;
    cin>>n;
    double p=(1.0)/2;
    double q=(n+1)*1.0/(2*n);
    if(n%2==0)
    cout<<p;
    else
    cout<<q;
    
    return 0;
}

Measured memory_bytes: 256
MOD = 10**9 + 7
def solve(n, a, b):
    v = []
    for i in range(n):
        v.append((a[i], 1))
        v.append((b[i], -1))
    v = sorted(v, key=lambda _:_[0])
    ans, cnt = 1, 0
    for _, t in v:
        if (cnt != 0) and (cnt * t < 0):
            ans = (ans * abs(cnt)) % MOD
        cnt += t
    return ans

n = int(input())
a = [int(input()) for i in range(n)]
b = [int(input()) for i in range(n)]
print(solve(n, a, b))

Measured memory_bytes: 30264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int len = S.length();
    VI ans(len);
    VI rcnt(len), lcnt(len);
    VI rpos(len), lpos(len);

    int suc = 0;
    int memo = -1;
    for(int i = len-1; i >= 0; i--){
        if(S[i] == 'L'){
            suc = 0;
            memo = i;
        }
        else{
            rcnt[i] = suc;
            rpos[i] = memo;
            suc++;
        }
    }
    suc = 0;
    memo = -1;
    REP(i,len){
        if(S[i] == 'R'){
            suc = 0;
            memo = i;
        }
        else{
            lcnt[i] = suc;
            lpos[i] = memo;
            suc++;
        }
    }

    REP(i,len){
        if(S[i] == 'R'){
            if(rcnt[i]%2 == 0){
                ans[rpos[i]-1]++;
            }
            else{
                ans[rpos[i]]++;
            }
        }
        else{
            if(lcnt[i]%2 == 0){
                ans[lpos[i]+1]++;
            }
            else{
                ans[lpos[i]]++;
            }
        }
    }
    REP(i,len){
        cout << ans[i] << " ";
    }
    cout << endl;

}


Measured memory_bytes: 2640
#include<iostream>
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
	int l=2*x;
	int r=l*2;
	//cout<<l<<r;
	int flag=0;
	for(int i=l;i<=r;)
	
	{
	if(y==i)
	{
		flag=1;
		break;
	}
	i=i+2;	
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3096
N=int(input())
c=[[0 for i in range(10)] for j in range(10)]

for n in range(1,N+1):
  i=int(str(n)[0])
  j=int(str(n)[-1])
  c[i][j]+=1

ans=0
for i in range(10):
  for j in range(10):
    ans+=c[i][j]*c[j][i]
print(ans)
    

Measured memory_bytes: 9064
# coding: utf-8
# Your code here!
s1=int(input())
s2=int(input())
s3=int(input())
s4=int(input())
s5=int(input())
s6=int(input())
s7=int(input())
s8=int(input())
s9=int(input())
s10=int(input())

print(sum((s1,s2,s3,s4,s5,s6,s7,s8,s9,s10)))


Measured memory_bytes: 5592
//A	Don't be late

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

int main() {
    int D,T,S;
    double A;
    cin >> D >> T >> S;
    A = double(D) / double(S);
    //cout << A << endl;

    
      if (A <= T) cout << "Yes" << endl;
      else cout << "No" << endl;
}


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

vector<ll> distances;
vector<vector<pll>> edges;
ll INF = 1e16;

bool dfs(int node)
{
    for (auto edge : edges.at(node))
    {
        ll nextNode, distance;
        tie(nextNode, distance) = edge;
        if (distances.at(nextNode) != INF && distances.at(nextNode) - distances.at(node) != distance)
        {
            return false;
        }
        if (distances.at(nextNode) == INF)
        {
            distances.at(nextNode) = distances.at(node) + distance;
            if (!dfs(nextNode))
            {
                return false;
            }
        }
    }
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    edges = vector<vector<pll>>(N + 1, vector<pll>());
    for (int i = 0; i < M; i++)
    {
        ll L, R, D;
        cin >> L >> R >> D;
        edges.at(L).emplace_back(R, D);
        edges.at(R).emplace_back(L, D * -1);
    }
    distances = vector<ll>(N + 1, INF);
    string answer = "Yes";
    for (int i = 1; i <= N; i++)
    {
        if (distances.at(i) == INF)
        {
            distances.at(i) = 0;
            if (!dfs(i))
            {
                answer = "No";
                break;
            }
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 16512
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 21 21:03:27 2020

@author: NEC-PCuser
"""

N = int(input())

c = ""

alpha_list = [chr(i) for i in range(97, 97+26)]
moji_up_list = []

a = 1
b = 1
while a <= N:
    moji_up_list.append(a)
    b *= 26
    a += b
    
N -= moji_up_list[len(moji_up_list) - 1]

j = 26 ** (len(moji_up_list) - 1)
for i in range(len(moji_up_list)):
    c += alpha_list[N // j]
    N = N % j
    j = j // 26

print(c)    


Measured memory_bytes: 9216
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<string>
#define ll long long
const int N=2e5+10;
using namespace std;
//const int f[26] = {2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,0,7,7,8,8,8,9,9,9,0};                         //26个字母对应的数字
ll p[N];
map<ll,ll>m;
//p[i]+p[j]==j-i;(j>=i)
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
        m[i-p[i]]++;
    }
    ll sum=0;
    for(int i=1;i<=n;i++)
        sum+=m[i+p[i]];
    cout<<sum<<endl;
    return 0;
}


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

struct Node{int x,y;}a[101],b[101];
bool bian[101][101],used[101];int p[101],n;
bool dfs(int now)
{
    for(int i=1;i<=n;i++)
    {
        if(bian[now][i]&&!used[i])
        {
            used[i]=true;
            if(!p[i]||dfs(p[i]))
            {
                p[i]=now;
                return true;
            }
        }
    }
    return false;
}
int main()
{
	int i,s=0,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d%d",&a[i].x,&a[i].y);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d",&b[i].x,&b[i].y);
		for(j=1;j<=n;j++)
			if(b[i].x>a[j].x&&b[i].y>a[j].y)
				bian[i][j]=1;
	}
	for(i=1;i<=n;i++)
	{
		memset(used,0,sizeof(used));
		if(dfs(i))	s++;
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define forr(x,n) for(int x = 0; x < n; ++x)
#define pr pair<int,int>
#define ll long long int
const ll mod=998244353;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    int ans=(n*(n-1))/2+(m*(m-1))/2;
    cout<<ans;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    x, y, z = map(int, readline().split())

    print(x * y // 2)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
n,k=map(int,input().split())
d=set(list(map(int,input().split())))

def checkIfOk(num):
  while True:
    if num%10 in d:
      return False
    else:
      num=num//10
    if num==0:
      return True

while True:
  if checkIfOk(n):
    print(n)
    break
  n+=1


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  int min=10000;
  cin >> s;
  for(int i=0;i<s.size()-2;i++){
    int j=abs((s.at(i)-48)*100+(s.at(i+1)-48)*10+(s.at(i+2)-48)-753);
    if(j<min)
      min = j;
  }
  cout << min;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int ans = 0;
    rep(i, 4)
    {
        char c; cin >> c;
        if (c == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <iostream>
#include <climits>
using namespace std;
int main() {
  int k; string s; cin >> k >> s;
  if(s.size() <= k) cout << s << endl;
  else{
    for(int i=0; i<k; i++) cout << s.at(i);
    cout << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
S = list(input())
for i, s in enumerate(S):
    # iは0から
    if i % 2 == 0:
        if s == 'L':
            ans = 'No'
            break
    if i % 2 == 1:
        if s == 'R':
            ans = 'No'
            break
else:
    ans = 'Yes'
print(ans)

Measured memory_bytes: 3060
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main() {

	fast();
  long long n;
  cin>>n;
  int q = sqrt(n);
  for(long long i=q; i>0; i--) {
  	if(n%i == 0) {
      cout<<(i-1+(n/i-1));
      break;
    }
  }
}

Measured memory_bytes: 256
n, m = map(int, input().split())
mini, maxi = map(int, input().split())

for i in range(m-1):
  l, r = map(int, input().split())
  if mini < l:
    mini = l
  if maxi > r:
    maxi = r
    
if maxi-mini+1 < 0:
  print(0)
else:
  print(maxi-mini+1)



Measured memory_bytes: 3060
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
#define MAXN 100000

long long h,w,ans[10];
int n,x[MAXN+5],y[MAXN+5];
map<pair<int,int>,int>Map;

void Updata(int x,int y) {
	if(x<3||x>h||y<3||y>w) return ;
	int cnt=0;
	for(int i=-2;i<=0;i++)
		for(int j=-2;j<=0;j++)
			cnt+=Map[make_pair(x+i,y+j)];
	ans[cnt]++;
}
int main() {
	scanf("%lld %lld %d",&h,&w,&n);
	ans[0]=(h-2)*(w-2);
	for(int i=1;i<=n;i++) {
		scanf("%d %d",&x[i],&y[i]);
		Map[make_pair(x[i],y[i])]++;
	}
	for(int i=1;i<=n;i++)
		for(int j=0;j<=2;j++)
			for(int k=0;k<=2;k++)
				Updata(x[i]+j,y[i]+k);
	for(int i=1;i<=9;i++)
		ans[i]/=i,ans[0]-=ans[i];
	for(int i=0;i<=9;i++)
		printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 157312
import collections

N,K,Q = map(int,input().split())

P = [K-Q]*N

S = [int(input()) for _ in range(Q)]

cnt=collections.Counter(S)

for k,v in cnt.items():
  P[k-1] = P[k-1] + v
  
for i in P:
  if i > 0:
    print('Yes')
  else:
    print('No')
  

Measured memory_bytes: 13884
#include<iostream>
using namespace std;
int main(){
  int ans=0,i,m=0,n,h[100010];
  cin >> n;
  for(i=0;i<n;i++){
    cin >> h[i];
  }
  for(i=1;i<n;i++){
  	if(h[i-1]>=h[i]){
  		m++;
  	}
  	else{
      ans=max(ans,m);
      m=0;
    }
  }
  ans=max(ans,m);
  cout << ans << endl;
  return 0;
}

    

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

using namespace std;

#define ll long long
#define all(x) (x).begin(),(x).end()
#define desc greater<int>()
#define pb(x) push_back(x)
ll gcd(ll a, ll b) { return (!a)?b:gcd(b%a,a);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
void pArr(int arr[], int s);
void pVec(vector<int> v);
bool isPrime(int x);
int binarySearch(int arr[], int l, int r, int x);
int vBinarySearch(vector<ll> v, int l, int r, ll x);
int nChoosek( int n, int k );
int mod=1e9+7;

void solve(){
    int n;
    cin >> n;
    if (n%1000==0){
        cout << 0 << endl;
    }
    else{
        cout << 1000-n%1000 << endl;
    }
}


int main(){
/*
    string temp;
    int t;
    cin >> t;
    getline(cin, temp);
    while (t--){
        solve();
    }
*/
    solve();
    return 0;
}


void pArr(int arr[], int s){
    for (int i=0;i<s;i++){
        cout << arr[i] << " ";
    }
    cout << endl;
}
void pVec(vector<int> v){
    for (int i=0;i<v.size();i++){
        cout << v.at(i) << " ";
    }
    cout << endl;
}
bool isPrime(int x){
    if (x==1){
        return false;
    }
    if(x==2){
        return true;
    }
    for (int i=2;i<=(int)(pow(x,0.5));i++){
        if (x%i==0){
            return false;
        }
    }
    return true;
}

int vBinarySearch(vector<ll> v, int l, int r, ll x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;
        if (v.at(m) == x)
            return m;
        if (v.at(m) < x)
            l = m + 1;
        else
            r = m - 1;
    }
    //bigger
    return r+1;
}

int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;
        if (arr[m] == x)
            return m;
        if (arr[m] < x)
            l = m + 1;
        else
            r = m - 1;
    }
    //smaller
    return r;
}

int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}


Measured memory_bytes: 3680
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> mochi(n);
    for(int i=0; i<n; i++){
        cin >> mochi[i];
    }
    sort(mochi.begin(),mochi.end());
    reverse(mochi.begin(),mochi.end());
    int count=1;
    for(int i=1; i<n; i++){
        if(mochi[i]<mochi[i-1])count++;
    }
    cout << count << 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)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<ll, ll>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};


int main()
{
  string s;
  int d;
  cin >> s >> d;
  int n = s.size();
  mint dp[n+1][2][d];
  rep(i, n+1) rep(j, 2) rep(k, d) dp[i][j][k] = 0;
  dp[0][0][0] = 1;
  rep(i, n) {
    int x = s[i]-'0';
    rep(j, 2) {
      rep(k, d) {
        rep(t, (j?10:x+1)) dp[i+1][j || t < x][(k+t)%d] += dp[i][j][k];
      }
    }
  }
  mint ans = dp[n][0][0]+dp[n][1][0];
  --ans;
  cout << ans.x << endl;
}

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

using namespace std;

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

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define lp(i, a, b) for (int i=a; i<(b); i++)
#define lpd(i,a,b) for (int i = (b)-1; i >= a; i--)
	
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;

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

    const int mod = 1e9 + 7;
    int n;
    cin>>n;

    int dp[n+1][4][4][4];
    memset(dp, 0, sizeof(dp));

    lp(j, 0, 4){
        lp(k, 0, 4){
            lp(l, 0, 4){
                string sj = to_string(j);
                string sk = to_string(k);
                string s = to_string(l);
                s = s + sk + sj;
                if (s!="021" && s!="012" && s!="201")
                    dp[3][l][k][j] = 1;
            }
        }
    }

    lp(i, 4, n+1){
        lp(j, 0, 4){
            lp(k, 0, 4){
                lp(l, 0, 4){
                    lp(m, 0, 4){
                        string sj = to_string(j);
                        string sk = to_string(k);
                        string sl = to_string(l);
                        string sm = to_string(m);
                        string s = sl + sk + sj;
                        string s1 = sm + sl + sj;
                        string s2 = sm + sk + sj;

                        if (s=="021" || s=="012" || s=="201") continue;
                        if (s1=="021" || s2=="021") continue;
                        
                        dp[i][l][k][j] += dp[i-1][m][l][k];
                        dp[i][l][k][j] %= mod;
                    }
                }
            }
        }
    }
    
    int sum = 0;
    lp(j, 0, 4){
        lp(k, 0, 4){
            lp(l, 0, 4){
                sum += dp[n][j][k][l];
                sum %= mod;
            }
        }
    }

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map &:to_i
a = Array.new; b = Array.new
m.times {
  aa, bb = gets.split.map &:to_i
  b.push(bb) if aa == 1
  a.push(aa) if bb == n
}
puts ((a & b).count > 0 ? 'POSSIBLE' : 'IMPOSSIBLE')


Measured memory_bytes: 9852
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
using namespace std;
typedef long long ll;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    if ((B - A) % 2 == 1)
        cout << "Borys" << endl;
    else
        cout << "Alice" << endl;
}

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

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

  vector<int64_t> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }
  sort(data.begin(), data.end(), greater<int64_t>());

  int64_t ans= data.at(0);
  for(int cnt=1; cnt< N-1; cnt++){
    ans+= data.at((cnt+1)/2);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4844
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define A 10
#define B 6
#define C 5
#define O 0

struct node {
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};

struct node *root;
struct node *NIL;

void insert (int);
void inorder(struct node *);
void preorder(struct node *);

int main(){

  int n,i,x;
  char *com,*comI="insert",*comP="print";
  
  com = (char*)malloc(A*sizeof(char));  
  
  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s", com);
    if(strncmp(com,comI,B)==O){
      scanf("%d",&x);
      insert(x);
    }
    else if(strncmp(com,comP,C)==O){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){

  struct node *y = NIL;
  struct node *x = root;
  struct node *z;

  z = (struct node *)malloc(sizeof(struct node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x-> key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y -> right = z;
    }
  }
}

void inorder(struct node *u){
  if(u == NIL){
    return;
  }
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(struct node *u){
  if(u == NIL){
    return;
  }
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}




Measured memory_bytes: 25160
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int n; cin >> n;
		if (n == 0) break;
		vector<string> f(n);
		for (int i = 0; i < n; i++) cin >> f[i];
		int cnt = 0;
		for (int i = 0; i + 1 < n; i++)
			if (f[i][1] == f[i + 1][1]) cnt++;
		cout << cnt << endl;
	}
}

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

int main() {
    std::vector<int> a {111,222,333,444,555,666,777,888,999};
    int n;
    std::cin >> n;
    std::cout << *std::lower_bound(a.begin(), a.end(), n) << std::endl;
    return 0;
}

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

using namespace std;
#define ll long long

const int N=1e6+100;

ll ma=1e18;


ll dp[3030][3030][4];
ll a[3030][3030];
void solve()
{
    int r,c,k;
    cin>>r>>c>>k;
    for(int i=1;i<=k;i++){
        int x,b,cc;
        cin>>x>>b>>cc;
        a[x][b]=cc;
    }

    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++){
            for(int rr=0;rr<=3;rr++){
                dp[i][j][0]=max(dp[i][j][0],max(dp[i-1][j][rr],dp[i][j-1][0]));
            }

            for(int rr=0;rr<=3;rr++){
                dp[i][j][1]=max(max(dp[i-1][j][rr]+a[i][j],dp[i][j][1]),max(dp[i][j-1][0]+a[i][j],dp[i][j-1][1]));
            }
            dp[i][j][2]=max(dp[i][j-1][1]+a[i][j],dp[i][j-1][2]);
            dp[i][j][3]=max(dp[i][j-1][2]+a[i][j],dp[i][j-1][3]);
        }
    }
    ll ans=0;
   // cout<<dp[3][3][0]<<endl;
    for(int i=0;i<=3;i++){
        ans=max(ans,dp[r][c][i]);
    }
    cout<<ans<<endl;
}
int main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 358744
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[202],s=0,t=0;
	cin>>n;
	for (int i=1;i<=2*n;i++)
	cin>>a[i];
	for (int i=1;i<=2*n-1;i++)
	for (int j=i+1;j<=n*2;j++)
	{
		if (a[i]<a[j])
		{
			t=a[i];a[i]=a[j];a[j]=t;
		}
	}
	for (int i=1;i<=2*n;i=i+2)
	{
		if (a[i]<a[i+1])
		s=s+a[i];
		else s=s+a[i+1];
	}
	cout<<s;
	return 0;
}

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



int main(){
	
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	int ans= 0;
	sort(a.begin(), a.end());
	

	int cnt=1, num = a[0];
	for(int i = 1; i < n; i++)
	{	
		if(num != a[i]){
			if(cnt < num) ans+= cnt;
			else if(cnt > num) ans+=cnt-num;
			num = a[i];
			cnt=1;
		}else
		{
			cnt++;
		}
		
	}
	
	if(a[n-1] < cnt) ans += cnt-num;
	else if(a[n-1] > cnt) ans += cnt;
	
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stdio.h>
#include <math.h>
using namespace std;

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

int main() {
	int N;
	cin >> N;
	vector<int> D;
	int tmp;
	for (int i = 0; i < N; ++i){
		cin >> tmp;
		D.push_back(tmp);
	}
	sort(D.begin(), D.end());
	cout << D.at(N / 2) - D.at(N / 2 - 1) << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main(){
    string s;
    int K;
    cin >> s >> K;
    string a="";
    set<string> st;
    for(int i=0;i<s.length() && i<5;i++){
        for(int j=0;j<s.length()-i;j++){
            a = "";
            for(int k=0;k<i+1 ;k++){
                a += s[j+k];
            }
            //cout << a << endl;
            st.insert(a);
        }
    }
    auto iter=st.begin();
    for(int i=0;i<K-1;i++)iter++;

    cout << *iter << endl;
}


Measured memory_bytes: 1664