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

int ok1[2010], ok2[2010], ok3[2010];

bool check(string &a, int p1, string &b, int p2) {
    while (p1 < a.size() && p2 < b.size()) {
        if (a[p1] != b[p2] && a[p1] != '?' && b[p2] != '?') return 0;
        p1++, p2++;
    }
    return 1;
}

int solve(string a, string b, string c) {
    for (int i = 0; i <= a.size(); i++) {
        ok1[i] = check(a, i, b, 0);
    }
    for (int i = 0; i <= b.size(); i++) {
        ok2[i] = check(b, i, c, 0);
    }
    for (int i = 0; i <= a.size(); i++) {
        ok3[i] = check(a, i, c, 0);
    }
    int ans = 0x3f3f3f3f;
    for (int i = 0; i <= a.size(); i++) {
        for (int j = 0; j <= b.size() || i + j <= a.size(); j++) {
            if (ok1[i] && (j > b.size() || ok2[j]) && (i + j > a.size() || ok3[i + j])) {
                ans = min(ans, (int)max(a.size(), max(i + b.size(), i + j + c.size())));
            }
        }
    }
    return ans;
}

int main () {
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    sort(s, s + 3);
    int ans = 0x3f3f3f3f;
    do {
        ans = min(ans, solve(s[0], s[1], s[2]));
    } while (next_permutation(s, s + 3));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var d = new int[n];
        for (int i = 0; i < n; i++)
        {
            d[i] = int.Parse(Console.ReadLine());
        }

        var max_i = 0;
        var sum = 0;
        for (int i = 0; i < n; i++)
        {
            sum += d[i];
            if (d[max_i] < d[i])
            {
                max_i = i;
            }
        }

        var ans = sum - d[max_i] + d[max_i] / 2;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define N 111111
#define sz size()
#define pf push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

typedef long long ll;

using namespace std;
ll n;

ll gcd(ll x, ll y){
    ll t;
    while(1){
        t=x%y;
        if(t==0) return y;
        x=y;y=t;
    }
}

int main(void){
    ll i,j,x,y;
    ll a,b,c;

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

    if(a%b==0){
        printf("-1");
        return 0;
    }
    printf("%lld",a);
    return 0;

    if(b%a==0){
        printf("%lld",a);
        return 0;
    }

    x=gcd(a,b);
    x=(a/x)*y;

    for(i=1;;i++){
        if(a*i>x){
            printf("-1");
            return 0;
        }
        if((a*i)%b==0) continue;
        printf("%lld",a*i);
        break;

    }

return 0;

}






Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=1e6+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const double eps=1e-8;
const double pi=acos(-1);
int n,m;
template<class T>
inline void read(T &x)
{
    char c;
    x=1;
    while((c=getchar())<'0'||c>'9')
        if(c=='-')
            x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9')
        res=res*10+c-'0';
    x*=res;
}
int main()
{
    char c;
    scanf("%c",&c);
    cout<<(char)(c+1)<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

signed main() {
	
	int n, d;
	cin >> n >> d;
	vector<vector<int>> pos(n, vector<int>(d));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> pos[i][j];
		}
	}
	int cnt = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			int s = 0;
			for (int k = 0; k < d; k++) {
				int t = pos[i][k] - pos[j][k];
				s += t * t;
			}
			if (sqrt((double)s) - (int)sqrt((double)s) == 0.0)
				cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
int n,x,t,a[200010];
int main(){
	scanf("%d%d",&n,&x);
	if(x==1||x==n*2-1) return puts("No"),0;
	puts("Yes");
	rep(i,1,x-2) a[++t]=i;
	rep(i,x+2,n*2-1) a[++t]=i;
	rep(i,1,n-2) printf("%d ",a[i]);
	printf("%d %d %d ",x-1,x,x+1);
	rep(i,n-1,t) printf("%d ",a[i]);
	return 0;
}

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

#define M 1000000007
#define FOR(i, s, n) for (ll i = (s); i < (n); ++i)
#define FORALL(i, n) for (ll i = 0; i < (n); ++i)
#define MOD 1000000007
#define ff first
#define ss second
#define pll pair<long long, long long>
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(false)
#define countbits(x) __builtin_popcount(x)
#define pb(x) push_back((x))
#define vll vector<ll>
#define all(x) x.begin(),x.end()
#define print(x) cout << x << endl
#define debug print("reaching\n")
#define mll map<ll,ll>
#define lsb(i) i&(-i)
#define printv(x) \
	FORALL(i, x.size()) \
	{ \
		cout << x[i] << ' '; \
	} \
	cout << endl \
;
#define printm(m) \
	for(auto i: m){\
		cout<<i.ff<<' '<<i.ss<<endl; \
	}\
;
// vector<map<ll,ll>> m(2);
long long binpow(long long a, long long b) {
	if(b<=0) return 1;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}



template <typename T>
T extGcd(T a, T b, T &x, T &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	else
	{
		int g = extGcd(b, a % b, y, x);
		y -= a / b * x;
		return g;
	}
}

template <typename T>
T modInv(T a, T m)
{
	T x, y;
	extGcd(a, m, x, y);
	return (x % m + m) % m;
}


int main()
{
	fast;
	// cin.tie(0);
	// cout.tie(0);
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

	int t=1;
	// cin>>t;
	ll tot=t;
	while(t--){
		ll d,t,s;
		cin>>d>>t>>s;
		if(t * s < d){
			print("No");
		}
		else print("Yes");
	}
	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
char t[1 << 18], d[1 << 18];

int n, q; string s;
int sta(int x) {
	rep(i, q) {
		if (s[x] == t[i]) {
			if (d[i] == 'L')x--;
			else x++;
		}
		if (x < 0)return 1;
		else if (x >= n)return 2;
	}
	return 0;
}
void solve() {
	cin >> n >> q >> s;
	rep(i, q) {
		cin >> t[i] >> d[i];
	}
	int le = -1, ri = n;
	while (ri - le > 1) {
		int mid = (le + ri) / 2;
		if (sta(mid) == 1)le = mid;
		else ri = mid;
	}
	int cle = -1, cri = n;
	while (cri - cle > 1) {
		int mid = (cle + cri) / 2;
		if (sta(mid) == 2)cri = mid;
		else cle = mid;
	}
	int ans = cle - ri + 1;
	if (ans < 0)ans = 0;
	cout << ans << endl;
}
int main() {
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 1028
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#define MAX 100
using namespace std;
vector<int> zhongxu,qianxu;
struct node{int key;node *p,*l,*r;};
node *root,*NIL;

void insert(int num){
	node *y=NIL;node *x=root;node *z;
	z=(node *)malloc(sizeof(node ));
	while(x!=NIL){
		y=x;
		if(num<x->key){x=(*x).l;}
		else {x=x->r;}
	}
	z->key=num;z->l=NIL;z->r=NIL;z->p=y;
	if(y==NIL){
		root=z;
	}else if(num>y->key){
		y->r=z;
	}else{y->l=z;}
}
void zhong(node *u){
	if(u->l!=NIL) zhong(u->l);
	cout<<" "<<u->key;
	if(u->r!=NIL) zhong(u->r);
	return ;
}
void qian(node *u){
	cout<<" "<<u->key;
	if(u->l!=NIL) qian(u->l);
	if(u->r!=NIL) qian(u->r);
	return;
}
void print(node *u){
	zhong(u);cout<<endl;
	qian(u);cout<<endl;return;
}
int main(){
	int cnt;int num;
	scanf("%d",&cnt);
	char order[10];
	vector<int> ::iterator it;
	for(int i=0;i<cnt;i++){
		scanf("%s",&order);
		if(order[0]=='i') {
		scanf("%d",&num);insert(num);
		}
		else if(order[0]=='p') {print(root);
		}
	}
}


Measured memory_bytes: 26552
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
#define input(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = (ll)1e19;

int r[100], l[100];
int a, b;

#define MAX 9223372036854775807
/*********************** */

int main() {
	ll n;cin >> n;
	vi a(n+1),b(n);
	ll sum = 0;
	for(int i = 0;i < n+1;i++)cin >> a[i];
	for(int i = 0;i < n+1;i++) sum += a[i];
	for(int i = 0;i < n;i++)cin >> b[i];
	
	if(a[0] <= b[0]){
		b[0] -= a[0]; a[0] = 0;
	}else{
		a[0] -= b[0]; b[0] = 0;
	}
	for(int i = 1;i < n+1;i++){
		if(b[i-1] >= a[i]){
			b[i-1] -= a[i];a[i] = 0;
		}else{
			a[i] -= b[i-1]; b[i-1] = 0;
			if(i == n) break;
			if(b[i] >= a[i]){
				b[i] -= a[i];a[i] = 0;
			}else{
				a[i] -= b[i]; b[i] = 0;
			}
		}
	}
	ll res = 0;
	for(int i = 0;i < n+1;i++){
		res+=a[i];
	}
	cout << sum - res << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
	int p,q,r;
	int a,b,c;
	int min;
	setvbuf(stdout,NULL,_IONBF,0);
		scanf("%d %d %d",&p,&q,&r);
		fflush(0);
		a=p+q;
		b=r+q;
		c=p+r;

		min=a;
		if(b<min) min=b;
		if(c<min) min =c;

		printf("%d\n",min);
		return 0;
}

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


public class Main {
	 static FastReader sc=null;
	

	public static void main(String[] args) {
	    sc=new FastReader();
	    int n=sc.nextInt();
	    int m=sc.nextInt();
	    graph g=new graph(n);
	    for(int i=0;i<m;i++) {
	    	int v=sc.nextInt()-1;
	    	int w=sc.nextInt()-1;
	    	g.addEdge(v, w);
	    }
	    g.Connected();
	    System.out.println(g.count-1);
	   
		
	}
	
	static class graph{
		int v;
		List<Set<Integer>> adj;
		boolean marked[];
		int count;
		int distTo[];
		graph(int v){
			this.v=v;
			adj=new ArrayList<>();
			marked=new boolean[v];
			distTo=new int[v];
			for(int i=0;i<v;i++) {
				Set<Integer> al=new HashSet<>();
				adj.add(i,al);
			}
		}
		public void Connected() {
			for(int i=0;i<v;i++) {
				if(!marked[i]) {
					dfs(i);
					count++;
				}
			}
		}
		public void addEdge(int v,int w) {
			if(v==w)return;
			adj.get(v).add(w);
			adj.get(w).add(v);
			
		}
		public void dfs(int v) {
			marked[v]=true;
			for(int w:adj.get(v)) {
				if(!marked[w])dfs(w);
			}
		}
		public void bfs(int s) {
			ArrayDeque<Integer> bfs=new ArrayDeque<>();
			bfs.add(s);
			while(!bfs.isEmpty()) {
				int v=bfs.remove();
				marked[v]=true;
				for(int w:adj.get(v)) {
					if(!marked[w]) {
						distTo[w]=distTo[v]+1;
						bfs.add(w);
					}
				}
				
			}
			
			
		}
	}
	static int[] readArray(int n) {
		int a[]=new int [n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		return a;
	}
	
	
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 

}


Measured memory_bytes: 83508
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int A,B;

int main() {

	scanf("%d%d", &A,&B);



	printf("%d\n", max(0, A - B - B));

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

int main() {

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

    if (n == 1) {
        printf("Hello World");
    } else {
        int a, b;
        scanf("%d %d", &a, &b);
        printf("%d\n", a+b);
   
    }

    return 0;

}


Measured memory_bytes: 128
import numpy as np
N, M, C = [int(_) for _ in input().split()]
B = np.array([int(_) for _ in input().split()] + [C])
A = np.array([[int(_) for _ in input().split()] + [1] for _0 in range(N)])
scores = A.dot(B)
print(scores[scores>0].size)

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

using namespace std;
#define ll long long
const int N=1e6+5,mod=1e9+7;
bool vis[N];
vector<int> adj[N];
int cur[N],a[N];
void LCM(int x)
{
    int t=x;
    for(auto p:adj[x])
    {
        int cnt=0;
        while(t%p==0)
        {
            cnt++;
            t/=p;
        }
        cur[p]=max(cur[p],cnt);
    }
}
ll fp(ll b,ll p)
{
    if(p==0) return 1;
    ll t=fp(b,p/2);
    if(p%2==0) return t*t%mod;
    return t*t%mod*b%mod;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    for(int i=2;i<N;i++)
    {
        if(vis[i]) continue;
        for(int j=i;j<N;j+=i){
            vis[j]=1;
            adj[j].push_back(i);
        }
    }
    int n;cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        LCM(a[i]);
    }
    ll lcm=1;
    for(int i=0;i<N;i++)
        lcm=lcm*fp(i,cur[i])%mod;
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=lcm*fp(a[i],mod-2)%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 62464
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  ll h,w;
  cin>>h>>w;
  if(w!=1&&h!=1){
  if(w%2==0){
     cout<<h*w/2<<endl;
}
  if(w%2==1&&h%2==0){
     cout<<h*w/2<<endl;
}
  if(w%2==1&&h%2==1){
     cout<<h/2*w+w/2+1<<endl;
}
  }
     if(w==1||h==1){
        cout<<1<<endl;
     }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] a = new int[n]; int [] b = new int [n]; int [] c = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt(); b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        int [][] dp = new int[n][3];
        dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
        for (int i = 1; i < n; i++) {
            dp[i][0] = Math.max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
            dp[i][1] = Math.max(dp[i-1][0] + b[i], dp[i-1][2] + b[i]);
            dp[i][2] = Math.max(dp[i-1][1] + c[i], dp[i-1][0] + c[i]);
        }
        System.out.println(Math.max(Math.max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]));
    }


}

Measured memory_bytes: 61112
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string a, b, c;
 	cin >> a >> b >> c;
	cout << a[0] << b[1] << c[2] << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n, a, b;
  scanf("%d%d%d",&n,&a,&b);
  int ans = n;
  rep(i,n) {
    int t;
    scanf("%d",&t);
    if (a <= t && t < b) ans--;
  }
  cout<<ans<<endl;
  return 0;
}







Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	int n, m, x[100000];
	int i,len[100000],al,lim,ans=0;
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		cin >> x[i];
	}
	sort(x, &x[m]);

	al = x[m] - x[0];
	for (i = 0; i < m-1; i++) {
		len[i] = x[i + 1] - x[i];
	}

	sort(len,&len[m-1]);
	for (i = m - 2 - (n - 1); i >= 0; i--) {
		//cout << len[i] << endl;
		ans += len[i];
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

long long k,a[100005],n1[100005],n2[100005];

int main()
{
    cin >> k;
    for (int i = 1; i <= k; i++)
        cin >> a[i];
    n1[k+1]=2, n2[k+1]=2;
    for (int i = k; i >= 1; i--)
    {
        if (n1[i+1]%a[i]!=0) n1[i+1]+=a[i]-n1[i+1]%a[i];
        n2[i+1]-=n2[i+1]%a[i];
        if (n1[i+1]<=n2[i+1]) n1[i]=n1[i+1], n2[i]=n2[i+1]+a[i]-1;
        else
        {
            cout << -1;
            return 0;
        }
    }
    cout << n1[1] << ' ' << n2[1];
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>h(N);
	rep(i, N) in >> h[i];

	LL ans = 0;
	h.push_back(0);
	++N;
	while (true)
	{
		bool flag = false, land = false;
		rep(i, N)
		{
			if (h[i] == 0 && land)
			{
				++ans;
				land = false;
			}
			if (h[i] > 0)
			{
				flag = true;
				land = true;
				--h[i];
			}
		}
		if (!flag) break;
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define prime 1000000007
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int n;
    cin >> n;
    vector<int> Graph[n];
    rep(i, n) {
        int k;
        cin >> k >> k;
        rep(j, k) {
            int a;
            cin >> a;
            Graph[i].push_back(a - 1);
        }
    }

    vector<int> dist(n, -1);
    dist[0] = 0;
    queue<int> Q;
    Q.push(0);
    while(!Q.empty()) {
        int now = Q.front();
        Q.pop();
        for(auto x : Graph[now]) {
            if(dist[x] != -1) continue;
            dist[x] = dist[now] + 1;
            Q.push(x);
        }
    }
    rep(i, n) cout << i + 1 << ' ' << dist[i] << endl;
}



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

typedef long long ll;

int N;
ll E,T;
ll X[100010];
ll dp[100010] = {0};
int id = 0;
ll INF = 1001001001001001;
ll MIN;

int main()
{
    scanf("%d%lld%lld",&N,&E,&T);

    MIN = INF;
    for(int i = 1; i <= N; i++)
    {
        scanf("%lld",X + i);
        while(id != i && (X[i] - X[id + 1]) * 2 >= T)
        {
            MIN = min(MIN,dp[id] - X[id + 1] * 2);
            id++;
        }
        dp[i] = MIN + X[i] * 2;
        if(id != i)dp[i] = min(dp[i],dp[id] + T);
    }
    printf("%lld\n",dp[N] + E);
    return 0;
}


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

int main(int argc, char** argv)
{
	int n, cnt = 0;
	scanf("%d", &n);
	for(int i=0; i<n; i++)
	{
		int x;
		scanf("%d", &x);
		if(i % 2 == 0 && x % 2 == 1)
			cnt ++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 1732
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
#include<stdio.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int i = 0;
    int cards[4][13];
    int j,k,l,m;
    for(j = 0; j<4; j++){
        for(k = 0; k <13; k++){
            cards[j][k] = 0;
        }
    }
    for(i = 0;i<n;i++){
        string mark;
        int number;
        cin >> mark >> number;
        if (mark == "S"){
            cards[0][number-1] = 1;
        } else if (mark == "H"){
            cards[1][number-1] = 1;
        } else if (mark == "C"){
            cards[2][number-1] = 1;
        } else{
            cards[3][number-1] = 1;
        }
    }
    for(l = 0; l<4; l++){
        for(m = 0; m <13; m++){
            if (cards[l][m] == 0){
                if (l == 0) {
                    cout << "S" << " " << m + 1 << endl;
                } else if (l == 1) {
                    cout << "H" << " " << m + 1 << endl;
                } else if (l == 2) {
                    cout << "C" << " " << m + 1 << endl;
                } else if (l == 3) {
                    cout << "D" << " " << m + 1 << endl;
                }
            }
        }
    }
    return 0;

}



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

using namespace std;

#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static llong MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

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

    int n;
    cin >> n;
    vector<int> X(n), Y(n);
    rep(i, n) cin >> X[i] >> Y[i];

    map<pair<int, int>, int> M;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i == j) continue;
            int dx = X[j] - X[i], dy = Y[j] - Y[i];
          if(dx==0&&dy==0)continue;
            ++M[{dx, dy}];
        }
    }

    int max_cnt = 0;
    stl_rep(itr, M) {
        max_cnt = max(max_cnt, itr->second);
    }

    cout << n - max_cnt << endl;
    
    return 0;
}


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

using namespace std;
#define ll long long int

ll N;
vector<ll> A;
vector<int> visited;
ll K;
int main(){
    cin>>N;
    cin>>K;
    for(int i=0;i<N;i++){
        ll aaa;
        cin>>aaa;
        A.push_back(aaa);
        visited.push_back(-1);
    }
    int current=1;
    int loop=0;
    bool isloop=false;
    //int loopstartpos=0;
    int loopstart=0;
    for(int i=0;i<K;i++){
        visited[current-1]=i;
        current=A[current-1];
        if(visited[current-1]>0){
            isloop=true;
            loopstart=visited[current-1];
            loop=i-visited[current-1]+1;
            break;
        }
    }
    if(isloop){
        for(int i=0;i<(K-loopstart)%loop;i++){
            current=A[current-1];
        }
    }
    cout<<current;
}

Measured memory_bytes: 6752
#include <stdio.h>

int N = 0;
int L[201];



int main(){
	scanf("%d", &N);
	for (int i = 0; i < 2 * N; i++){
		scanf("%d", &L[i]);
	}
	int temp;
	for (int i = 0; i < 2 * N; i++){
		for (int j = 0; j < 2 * N - 1; j++){
			if (L[j] < L[j + 1]){
				temp = L[j];
				L[j] = L[j + 1];
				L[j + 1] = temp;
			}
		}
	}
	int answer = 0;
	for (int i = 0; i < N; i++){
		answer += L[i*2 + 1];
	}

	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
data = [i for i in [int(i) for i in input().split()] if i % 2 == 0]
flag = 'APPROVED'
for i in data:
  if i % 3 != 0 and i % 5 != 0:
    flag = 'DENIED'
    break
print(flag)
    

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

int main()
{
    string s;cin>>s;
    int ch[26]={0};
    for(int i=0;i<4;i++)
    {
        ch[s[i]-'A']+=1;
    }
    int c=0;
    for(int i=0;i<26;i++)
    {
        if(ch[i]==2) c++;
    }
    if(c==2) cout<<"Yes";
    else cout<<"No";



    return 0;

}


Measured memory_bytes: 256
z[2002],*a=z,*b=z+1001,m,i,j,t;
main(n){for(;scanf("%d",&n),i=n;printf("%d\n",m)){
		for(memset(a,m=0,4004);i--;){
			for(j=scanf(" ");j++<n;)
				m=fmax(m,b[j]=getchar()-'*'?1+fmin(fmin(b[j-1],a[j-1]),a[j]):0);
			t=a;a=b;b=t;
		}
	}
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))

pairs = []
low = None
if a[0] < a[1]:
	low = a[0]

for i in range(1, n):
	if a[i-1] > a[i]:
		if low is not None:
			pairs.append((low, a[i-1]))
			low = a[i]
	if a[i-1] < a[i]:
		if low is None:
			low = a[i-1]
if low is not None and low < a[n-1]:
	pairs.append((low, a[n-1]))

yen = 1000
for (l, h) in pairs:
	size = yen // l
	yen -= size * l
	yen += size * h
print(yen)

Measured memory_bytes: 61920
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using std::cin;
using std::cout;
typedef long long ll;
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e6 + 5;
int prime[Maxn], cnt, ans;
bool P[Maxn];
ll A, B;
ll gcd(ll x, ll y)
{
	ll z = x % y;
	while (z)
	{
		x = y;
		y = z;
		z = x % y;
	}
	return y;
}
int main()
{
	for (int i = 2; i <= 1000000; i++)
	{
		if (!P[i])
			prime[++cnt] = i;
		for (int j = 1; j <= cnt && i * prime[j] <= 1000000; j++)
		{
			P[i * prime[j]] = true;
			if (i % prime[j] == 0)
				break;
		}
	}
	rg ll x;
	cin >> A >> B;
	x =gcd(A, B);
	for (int i = 1; i <= cnt && x != 1; i++)
		if (x % prime[i] == 0)
		{
			ans++;
			while (x % prime[i] == 0)
				x /= prime[i];
		}
	if (x != 1)
		ans++;
	cout << ans + 1 << '\n';
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define paypal ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli long long int
using namespace std;

int main()
{
	lli n;
	cin>>n;
	lli arr[n][3],dp[n][3]={};
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			cin>>arr[i][j];
			
	for(int i=0;i<3;i++)dp[0][i]=arr[0][i];
	
	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(arr[i][0]+dp[i-1][1],arr[i][0]+dp[i-1][2]);
		dp[i][1]=max(arr[i][1]+dp[i-1][0],arr[i][1]+dp[i-1][2]);
		dp[i][2]=max(arr[i][2]+dp[i-1][0],arr[i][2]+dp[i-1][1]);
	}
	
	/*for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)cout<<dp[i][j]<<" ";
		cout<<"\n";
	}
	cout<<"############################\n";*/
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll  INFL = 1e18;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll H, W; cin >> H >> W;
    ll ans = INF;
    vl piece(3);
    REPS(h, H-1)
    {
        piece[0] = h*W;
        piece[1] = (H-h)/2 * W;
        piece[2] = H*W-(piece[0]+piece[1]);
        ans = min(ans, *max_element(ALL(piece))-*min_element(ALL(piece)));

        piece[1] = (H-h)*(W/2);
        piece[2] = H*W-(piece[0]+piece[1]);
        ans = min(ans, *max_element(ALL(piece))-*min_element(ALL(piece)));
    }
    swap(H, W);
    REPS(h, H-1)
    {
        piece[0] = h*W;
        piece[1] = (H-h)/2 * W;
        piece[2] = H*W-(piece[0]+piece[1]);
        ans = min(ans, *max_element(ALL(piece))-*min_element(ALL(piece)));

        piece[1] = (H-h)*(W/2);
        piece[2] = H*W-(piece[0]+piece[1]);
        ans = min(ans, *max_element(ALL(piece))-*min_element(ALL(piece)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll s;
    cin>>s>>c;
    if(s*2>=c){
      sum=c/2;
      cout<<sum<<endl;
    }else{
      sum=s;
      c-=s*2;
      sum+=c/4;
      
      cout<<sum<<endl;
      
    }
    return 0;
}


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

#define ll long long

int n,m;
int L,R,D;
vector<pair<int,int> >mp[100100];
int dis[100100];
bool vis[100100];
int flag;

void dfs(int u,int pre)
{
    if(!flag) return;
     int sz=mp[u].size();
     pair<int,int>tmp;
     for(int i=0;i<sz;++i)
     {
        tmp=mp[u][i];
        if(vis[tmp.first])
        {
            if(dis[u]!=dis[tmp.first]-tmp.second)
            {
                flag=0;return;
            }
        }
        else
        {
            vis[tmp.first]=1;
            dis[tmp.first]=dis[u]+tmp.second;
            dfs(tmp.first,u);
        }
     }
}

int main(int argc, char const *argv[])
{
    /* code */
    scanf("%d %d",&n,&m);
    for(int i=1;i<=m;++i)
    {
        scanf("%d %d %d",&L,&R,&D);
        mp[R].push_back(make_pair(L,D));
        mp[L].push_back(make_pair(R,-D));
    }
    flag=1;
    for(int i=1;i<=n;++i) if(!vis[i])
    {
        vis[i]=1;
        dfs(i,-1);
    }
    if(flag) puts("Yes");else puts("No");
    return 0;
}

Measured memory_bytes: 12032
#include"bits/stdc++.h"

using namespace std;

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

	if (B - A <= 0) {
		cout << "delicious";
	}
	else if (B - A <= X) {
		cout << "safe";
	}
	else {
		cout << "dangerous";
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
result = 1
if n > 2:
    h = -1
    for i in range(n-1):
        if a[i]!=a[i+1]:
            c = a[i]<a[i+1]
            if h<0:
                h = c
            else:
                if h==c:
                    continue
                else:
                    h = -1
                    result += 1
print(result)

Measured memory_bytes: 62704
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <typeinfo>
#include <functional>
#include <iomanip>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;

typedef int Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

ll N, M;
ll A[100000], B[100000];
bool rootf[100000];

bool tansazumi[100000];
int srcnum[100000];

pair<Weight, Edges> minimumSpanningTree(const Graph &g, int r = 0) {
	int n = g.size();
	Edges T;
	Weight total = 0;

	vector<bool> visited(n);
	priority_queue<Edge> Q;
	Q.push(Edge(-1, r, 0));
	while (!Q.empty()) {
		Edge e = Q.top(); Q.pop();
		if (visited[e.dst]) continue;
		T.push_back(e);
		total += e.weight;
		visited[e.dst] = true;
		for (auto f = g[e.dst].begin(); f != g[e.dst].end(); f++)
		{
			if (!visited[f->dst]) Q.push(*f);
		}
	}
	return pair<Weight, Edges>(total, T);
}
int main()
{
	cin >> N >> M;

	Graph graph;
	graph.resize(N);
	int root;
	memset(rootf, false, sizeof(rootf));
	memset(srcnum, 0, sizeof(srcnum));

	for (int i = 0; i < N + M - 1; i++)
	{
		cin >> A[i] >> B[i];
		Edge edge(A[i] - 1, B[i] - 1, 1);
		
		graph.at(A[i] - 1).push_back(edge);
		graph.at(B[i] - 1).push_back(edge);
		rootf[B[i] - 1] = true;
		srcnum[B[i] - 1]++;
	}

	for (int i = 0; i < N; i++)
	{
		if (rootf[i] == false)
		{
			root = i;
		}
		tansazumi[i] = false;
	}

	//ルートから子の解決
	queue<int> que;
	que.push(root);
	tansazumi[root] = true;
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		for (int i = 0; i < graph.at(now).size(); i++)
		{
			int dst = graph.at(now).at(i).dst;

			if (srcnum[dst] <= 1)
				continue;

			// 複数あるならtansakuzumiの指されている奴は消す.
			for (int j = 0; j < graph.at(dst).size(); j++)
			{
				if (tansazumi[graph.at(dst).at(j).src] == true)
				{
					// 削除だといろいろめんどいので.
					graph.at(dst).at(j).src = -1;
					graph.at(now).at(i).dst = -1;
					srcnum[dst]--;
				}
			}
		}

		for (int i = 0; i < graph.at(now).size(); i++)
		{
			if (graph.at(now).at(i).src == now && graph.at(now).at(i).dst != -1)
			{
				tansazumi[graph.at(now).at(i).dst] = true;
				que.push(graph.at(now).at(i).dst);
			}
		}
	}
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < graph.at(i).size(); j++)
		{
			if (i == root)
			{
				cout << 0 << endl;
				break;
			}
			else if (graph.at(i).at(j).src != -1 && graph.at(i).at(j).src != i)
			{
				cout << graph.at(i).at(j).src + 1<< endl;
				break;
			}
		}

	}


	return 0;
}

Measured memory_bytes: 10036
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int d = sc.nextInt();
		Map<Integer, Obj> map = new HashMap<Integer, Obj>();
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int k = sc.nextInt();
				Obj o = new Obj();
				o.x = i;
				o.y = j;
				map.put(k, o);
			}
		}
		int n = h * w;
		int[] sum = new int[n + 1];
		for (int i = d + 1; i < n + 1; i++) {
			sum[i] = sum[i - d] + calc(map.get(i), map.get(i - d));
		}

		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			System.out.println(sum[r] - sum[l]);
		}
		sc.close();
	}

	static class Obj {
		int x, y;
	}

	static int calc(Obj o1, Obj o2) {
		return Math.abs(o1.x - o2.x) + Math.abs(o1.y - o2.y);
	}
}


Measured memory_bytes: 100040
n, yen = map(int, input().split())
for x in range(n+1):
  for y in range(n+1-x):
    if 10000*x + 5000*y + 1000*(n-(x+y)) == yen:
      print(x, y, n-(x+y))
      exit()
print("-1 -1 -1")
      


Measured memory_bytes: 9156
//2017-7-28 21:13
//2017-7-28 21:38
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;

struct node{
	LL a, b, c;
	bool operator <(const node &A) const{
		return (a-b) < A.a - A.b;
	}
}box[MaxN + 5];

int n, x, y, z;
LL tot, ans;
priority_queue<LL, vector<LL>, greater<LL> > q;
LL lef[MaxN + 5];

int main(){
	scanf("%d %d %d", &x, &y, &z);
	n = x + y + z;
	for(int i = 1; i <= n; i++){
		scanf("%lld %lld %lld", &box[i].a, &box[i].b, &box[i].c);
		tot += box[i].c;
	}
	sort(box + 1, box + 1 + n);
	LL ans = 0, sum = 0;
	for(int i = 1; i <= y; i++){
		sum += box[i].b - box[i].c;
		q.push(box[i].b - box[i].c);
	}
	for(int i = y + 1; i <= n - x + 1; i++){
		lef[i] = sum;
		sum += box[i].b - box[i].c;
		q.push(box[i].b - box[i].c);
		sum -= q.top();
		q.pop();
	}
	while(!q.empty()) q.pop(); sum = 0;
	for(int i = n; i > n - x; i--){
		sum += box[i].a - box[i].c;
		q.push(box[i].a - box[i].c);
	}
	for(int i = n - x; i >= y; i--){
		ans = max(ans, tot + lef[i + 1] + sum);
		sum += box[i].a - box[i].c;
		q.push(box[i].a - box[i].c);
		sum -= q.top();
		q.pop();
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
#define LL long long

const int maxn=2e5+10;

int n,reach[maxn],deep[maxn<<1],high[maxn],low[maxn];
int tote=1,TO[maxn<<1],NEXT[maxn<<1],FIR[maxn];
bool col[maxn],exist[maxn],black[maxn<<1];
LL Ans=1;

void addedge(int u,int v)
{
	TO[++tote]=v;
	NEXT[tote]=FIR[u];
	FIR[u]=tote;
}

void dfs1(int u,int f)
{
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p];
		if (v==f) continue;
		dfs1(v,u);
		reach[u]=max(reach[u],reach[v]+1);
		deep[p]=reach[v]+1;
	}
}

void dfs2(int u,int f)
{
	int mx=0,se=0;
	for (int p=FIR[u];p;p=NEXT[p])
		if (mx<deep[p]) se=mx,mx=deep[p];
		else if (se<deep[p]) se=deep[p];
	high[u]=min(mx-1,se+1);
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p];
		if (v==f) continue;
		deep[p^1]=deep[p]==mx?se+1:mx+1;
		dfs2(v,u);
	}
}

void dfs3(int u,int f)
{
	if (col[u]) low[u]=0,exist[u]=1;
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p];
		if (v==f) continue;
		dfs3(v,u);
		exist[u]|=exist[v];
		black[p]=exist[v];
	}
}

void dfs4(int u,int f)
{
	int pos1=0,pos2=0;
	for (int p=FIR[u];p;p=NEXT[p])
		if (black[p])
		{
			if (pos1) pos2=p;
			else pos1=p;
			low[u]=min(low[u],deep[p]);
		}
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p];
		if (v==f) continue;
		black[p^1]=col[u]||(pos1&&p!=pos1)||(pos2&&p!=pos2);
		dfs4(v,u);
	}
}

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i,u,v;
	scanf("%d",&n);
	for (i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		addedge(u,v);
		addedge(v,u);
	}
	for (i=1;i<=n;i++)
	{
		char c=getchar();
		while (c!='0'&&c!='1') c=getchar();
		col[i]=c=='1';
	}
	memset(high,0,sizeof(high));
	memset(low,0x3f3f3f3f,sizeof(low));
	dfs1(1,0);
	dfs2(1,0);
	dfs3(1,0);
	dfs4(1,0);
	for (i=1;i<=n;i++)
		if (low[i]<=high[i]) Ans+=high[i]-low[i]+1;
	printf("%lld\n",Ans);
}


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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  string A; cin>>A;
  TorF(isupper(A[0]), "A", "a");
  return 0;
}


Measured memory_bytes: 3048
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

K,T=get_i
A=get_i.sort!{|x,y| y<=>x}
if T==1
    puts A[0]-1
else
    puts max(A[0]-(A.inject(:+)-A[0])-1,0)
end

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

int main() {
  string s;

  cin >> s;
  int sum = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'o') {
      sum++;
    }
  }
  
  cout << 700 + sum * 100 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i=0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    int S1 =0;
    int S2 = 0;
    for( int i =  0; i < n; i++) {
      S1 += a[i]*a[i];
    }
    for(int i = 0; i< n;i++) {
      S2 += a[i];
    }
    System.out.println(((S2)*(S2)-S1)/2);
    
    
    
    
    
  }
}


Measured memory_bytes: 23508
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

const int MAXN = 4e3 + 7;
const ll HA = 998244353;

ll fac[MAXN], inv[MAXN], f[MAXN];
int n, k;

ll C(int n, int m) {
	return (n < m || m < 0) ? 0 : fac[n] * inv[m] % HA * inv[n - m] % HA;
}

ll fp(ll a, ll b = HA - 2) {
	ll r = 1;
	while (b) {
		if (b & 1) r = r * a % HA;
		b >>= 1, a = a * a % HA;
	}
	return r;
}

void init() {
	inv[0] = fac[0] = f[0] = 1;
	rep(i, 1, 4000) fac[i] = fac[i - 1] * i % HA, f[i] = f[i - 1] * 2 % HA;
	inv[4000] = fp(fac[4000]);
	per(i, 3999, 1) inv[i] = inv[i + 1] * (i + 1) % HA;
}

ll calc(int x, int y, int z) {
	ll ret = 0;
	rep(i, 0, std::min(x, z)) ret = (ret + C(x, i) * f[i] % HA * C(z + y - 1, i + y - 1) % HA) % HA;
	return ret;
}

int main() {
	init();
	scanf("%d %d", &k, &n);
	int cnt;
	ll ans;
	rep(i, 2, 2 * k) {
		cnt = 0;
		rep(j, 1, k) if (i - j >= 1 && i - j <= k) cnt++;
		if (i & 1) ans = calc(cnt / 2, k - cnt, n);
		else ans = (calc((cnt - 1) / 2, k - cnt, n) + calc((cnt - 1) / 2, k - cnt, n - 1)) % HA;
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 384