akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

# ユニオンファインド
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x



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


n=int(input())
a= [list(map(int, input().split())) for i in range(n)]
b=[]
a.sort()
# aの各点に通し番号を振る
for i in range(n):
    a[i].append(i)

# 繋ぐ点の候補は上下左右の４つ
# 左右に繋ぐ辺を追加
for i in range(n-1):
    b.append([a[i][2], a[i + 1][2], a[i + 1][0] - a[i][0]])

a.sort(key=lambda x:x[1])
# 上下に繋ぐ辺を追加
for i in range(n-1):
    b.append([a[i][2], a[i + 1][2], a[i + 1][1] - a[i][1]])

b.sort(key=lambda x:x[2])

uf=UnionFind(n)
ans=0
cnt=0
# クラスカル法
for x,y,z in b:
    if not uf.same(x,y):
        uf.union(x,y)
        cnt+=1
        ans+=z
        if cnt==n-1:
            break
print(ans)


Measured memory_bytes: 126888
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

struct UnionFind {
  vector<int> data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return (false);
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if (data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

int N, M;
UnionFind uf(101010);

signed main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    uf.unite(x, y);
  }

  vector<int> v;
  for (int i = 0; i < N; i++) {
    v.push_back(uf.find(i));
  }

  sort(ALL(v));
  UNIQUE(v);

  cout << v.size() << endl;

  return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    char s[5];
    std::cin >> s;
    sort(s,s+4);
    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int X = in.nextInt();
        int A = in.nextInt();
        int B = in.nextInt();

        in.close();
        if(Math.abs(X - A) < Math.abs(X - B)){
        	System.out.println("A");
        }
        else System.out.println("B");
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define A printf("%02d:%02d:%02d\n",a/e,a/d%d,a%d);
main(){int h,m,s,a,d=60,e=d*d;for(;scanf("%d%d%d",&h,&m,&s),~h;){a=e*2-h*e-m*d-s;A a*=3;A}}

Measured memory_bytes: 3160
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
    string s;
  cin>>s;
  if (s[1]=='R')
    cout<<"ABC"<<endl;
  else
    cout<<"ARC"<<endl;
    
}

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

class DisjointSet {
    
    public:
        vector<int> rank, p;
        
        DisjointSet() {}
        DisjointSet(int size) {
            
            rank.resize(size, 0);
            
            p.resize(size, 0);
            
            for (int i = 0; i < size; i ++) {
                
                makeSet(i);
                
            }
            
        }
        
        void makeSet(int x){
            
            p[x] = x;
            
            rank[x] = 0;
            
        }
        
        bool same(int x, int y) {
            
            return findSet(x) == findSet(y);
            
        }
        
        void unite(int x, int y) {
            
            link(findSet(x), findSet(y));
            
        }
        
        void link(int x, int y) {
            
            if (rank[x] > rank[y]) {
                
                p[y] = x;
                
            } else {
                
                p[x] = y;
                
                if (rank[x] == rank[y]) {
                    
                    rank[y] ++;
                    
                }
                
            }
            
        }
        
        int findSet(int x) {
            
            if (x != p[x]) {
                
                p[x] = findSet(p[x]);
                
            }
            
            return p[x];
            
        }
        
};

int main() {
    
    int n, a, b, q, t;
    
    cin >> n >> q;
    
    DisjointSet ds = DisjointSet(n);
    
    for (int i = 0; i < q; i ++) {
        
        cin >> t >> a >> b;
        
        if(t == 0) {
            
            ds.unite(a, b);
            
        } else if(t == 1) {
            
            if (ds.same(a, b)) {
                
                cout << 1 << endl;
                
            } else {
                
                cout << 0 << endl;
                
            }
            
        }
        
    }
    
    return 0;
    
}


Measured memory_bytes: 3176
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
	char str[2000000]			= {};
	int S[10000]				= {};
	int T[500]					= {};
	int n						= 0;
	int q						= 0;
	int i						= 0;
	int j						= i;
	int k                       = 0;
	int num						= 0;
	fgets( str, 256, stdin );
	n = atoi(str);
	fgets( str, 2000000, stdin );
	
	while ( num < n ) {
		j = i;
		for ( i = 0; str[i] != ' ' && str[i] != '\r'; i++ ) {
		}
		str[i] = '\0';
		S[num] = atoi(&str[j]);
		for ( k = 0; k < num; k++ ) {
		    if ( S[num] == S[k] ) {
		        S[num] = -1;
		    }
		}
		num++;
		i++;
	}
	
	
	fgets( str, 256, stdin );
	q = atoi(str);
	fgets( str, 20000, stdin );
	i = 0;
	num = 0;
	while ( num < q ) {
		j = i;
		for ( i = 0; str[i] != ' ' && str[i] != '\r'; i++ ) {
		}
		str[i] = '\0';
		T[num] = atoi(&str[j]);
		num++;
		i++;
	}
	
	num = 0;
	
	for ( i = 0; i < n; i++ ) {
		for ( j = 0; j < q; j++ ) {
			if ( S[i] == T[j] ) {
				num++;
			}
		}
	}
	
	printf("%d\n", num);
	
	return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

int main()
{
  lint k, n;
  cin >> k >> n;
  std::vector<lint> a(n);
  REP(i,n) cin >> a[i];

  //std::vector<lint> dist(n);
  //dist[0] = a[0] + (k-a[n-1]);
  //lint max = dist[0];
  lint max = a[0] + (k-a[n-1]);
  FOR(i,1,n){
    //dist[i] = a[i] - a[i-1];
    //if(dist[i] > max) max = dist[i];
    if(a[i] - a[i-1] > max) max = a[i] - a[i-1];
  }

  cout << k-max << "\n";

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int maxn = 605;
double dp[maxn];
int n, m;
vector<int> g[maxn];
int nxt[maxn];
void gao(int x) {
	dp[n] = 0;
	for(int i = n - 1; i >= 0; i--) {
		int cnt = 0;
		double tmp = 0;
		for(int j : g[i]) {
			if(i == x && j == nxt[i] && g[i].size() >= 2) continue;
			cnt++;
			tmp += dp[j];
		}
		dp[i] = 1.0 + tmp / (double)cnt;
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		g[x].push_back(y);
	}
	gao(-1);
//	for(int i = 1; i <= n; i++) 
//		printf("%.6f ", dp[i]); puts(""); 
	for(int i = 1; i <= n; i++) {
		int idx = 0;
		for(int j : g[i]) {
			if(!idx || dp[j] > dp[idx]) idx = j;
		}
		nxt[i] = idx;
	}
	double ans = 1e9;
	for(int i = n - 1; i >= 1; i--) {
		gao(i);
		ans = min(ans, dp[1]);
	}
	printf("%.10f\n", ans);
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    double i,n,p,ans=0;
    scanf("%lf %lf",&n,&p);
    if(n==1)ans=p;
    else if(n>=40 || n>=p)ans=1;
    else if(n==2){
        for(i=1; i<=1000000; i++){
            if(fmod(p,pow(i,2))==0)ans=i;
        }
    }
    else for(i=1; i<=10000; i++){
        if(fmod(p,pow(i,n))==0)ans=i;
    }
    printf("%.0lf",ans);
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		int[] T = new int[N];
		sc.fill(T);
		Arrays.sort(T);

		int count = 0;
		int prev = T[0];
		int sum = 1;
		for (int i = 1; i < T.length; i++) {
			if (T[i] - prev > K || sum >= C) {
				debug("Departure: ", i, count, sum);
				count++;
				sum = 0;

				prev = T[i];
			}

			sum++;
		}

		System.out.println(count + 1);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 28652
#include <stdio.h>

int main() {
  int N,M;
  scanf("%d %d",&N,&M);
  int A[M];
  for(int i=0;i<M;i++) {
    scanf("%d",&A[i]);
  }
  for(int i=0;i<M;i++) {
    N-=A[i];
  }
  if(N<0) {
    printf("%d",-1);
  }else {
    printf("%d",N);
  }
  return 0;
}

Measured memory_bytes: 1736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int n=scn.nextInt();
		int w =scn.nextInt();
		if(w>=n){
			System.out.println("unsafe");
		}else{
			System.out.println("safe");
		}

	}

}

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

long long int gcd (long long int a, long long int b) {
	if (b == 0) {
		return a;
	} else {
		return gcd((long long int)max(a%b, b), (long long int)min(a%b, b));
	}
}

long long int lcm (long long int a, long long int b) {
	long long int c = a * b / gcd(a, b);
	return c;
}

int main() {
	long long int a1, m1, a2, m2, a3, m3;
	while (cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3) {
		if (a1 == 0 && m1 == 0 && a2 == 0 && m2 == 0 && a3 == 0 && m3 == 0) {
			break;
		} 
		long long int x, y, z;
		x = y = z = 1;
		long long int counter = 1;
		long long int counter2 = 1;
		long long int counter3 = 1;
		x = (a1 * x) % m1;
		y = (a2 * y) % m2;
		z = (a3 * z) % m3;
		while (x != 1) {
			x = (a1 * x) % m1;
			counter++;
		} 
		while (y != 1) {
			y = (a2 * y) % m2;
			counter2++;
		}
		while (z != 1) {
			z = (a3 * z) % m3;
			counter3++;
		}
		cout << lcm(counter, lcm(counter2, counter3)) << endl;
	}
	return 0; 
}

Measured memory_bytes: 1156
import sys
import math
import numpy as np
import functools
import operator
import collections
import itertools
N=int(input())
S = []
for _ in range(N):
    S.append(input())
print("AC" ,"x", S.count("AC"))
print("WA" ,"x", S.count("WA"))
print("TLE" ,"x", S.count("TLE"))
print("RE" ,"x", S.count("RE"))

Measured memory_bytes: 34096
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

int main()
{
    string S;
    cin >> S;

    if (S.size() == 1) {
        cout << 0 << endl;
        return 0;
    }

    int c0 = count(S.cbegin(), S.cend(), '0');
    int c1 = count(S.cbegin(), S.cend(), '1');
    if (c0 == 0 || c1 == 0) {
        cout << S.size() / 2 << endl;
        return 0;
    }

    int r0 = 0;
    int r1 = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == '0') {
            if (i % 2 == 0) {
                r0++;
            } else {
                r1++;
            }
        } else {
            if (i % 2 == 0) {
                r1++;
            } else {
                r0++;
            }
        }
    }

    cout << min(r0, r1) << endl;

    return 0;
}

Measured memory_bytes: 512
# 文字列の入力
S = gets.chomp

ans = 0

len = S.length

for i in 0..S.length - 1 do
  if S[i] == "+"
    ans += 1
  end
  if S[i] == "-"
    ans -= 1
  end  
end
# 出力
print(ans)



Measured memory_bytes: 3836
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 300010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define mp make_pair
#define pi acos(-1.0)
#define eps 1e-6
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
const ll mod = 1e9 + 7;
ll n, k, ans, a[SIZE];
ll b[SIZE], inv[SIZE];
ll C(ll n, ll m) {
	return b[n] * inv[m] % mod * inv[n - m] % mod;
}

ll qpow(ll a, ll b, ll mod) { //快速幂 a ^ b % mod
	ll ans = 1;
	while (b) {
		if (b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}

int main() {
	
	io(); cin >> n >> k;
	b[1] = inv[1] = inv[0] = b[0] = 1;
	rep(i, 2, 100000) b[i] = b[i - 1] * i % mod;
	rep(i, 2, 100000) inv[i] = qpow(b[i], mod - 2ll, mod);
	rep(i, 1, n) cin >> a[i];
	sort(a + 1, a + 1 + n);
	rep(i, k, n) {
		ans = (ans + a[i] * C(i - 1ll, k - 1ll) % mod + mod) % mod;
	}
	rep(i, 1, (n - k + 1)) {
		ans = (ans - a[i] * C(n - i, k - 1ll) % mod + mod) % mod;
	}
	cout << ans;
}

Measured memory_bytes: 5120
a, b, c, d, e, f = map(int, input().split())
w = []
s = []
for i in range(f // (100 * a) + 1):
  for j in range((f - 100 * a * i) // (100 * b) + 1):
    if 100 * a * i + 100 * b * j <= f:
      w.append(100 * a * i + 100 * b * j)
for i in range(f // c + 1):
  for j in range((f - c * i) // d + 1):
    if c * i + d * j <= f:
      s.append(c * i + d * j)
w.sort()
s.sort()
ans = (100 * a, 0)
l = 0
for i in w:
  for j in range(l, len(s)):
    if i + s[j] > f:
      break
    if s[j] > i // 100 * e:
      break
    l = j
    if ans[1] * i < s[j] * ans[0]:
      ans = (i, s[j])
print(ans[0] + ans[1], ans[1])


Measured memory_bytes: 13384
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define all(x) (x.begin(),x.end())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define endl "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define sz(a) (int)a.size()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define Q(x) for(int i=0;i<x;i++)
#define show(x) for(auto i:x)cout<<i<<" ";cout<<endl;

using namespace std;
const ll mod = 1e9 + 7;
const int nax = 2e5 + 9;
int par[nax];
int root(int v) {
	if (par[v] < 0) {
		return v;
	}
	else {
		return root(par[v]);
	}
}
void merge (int x, int y) {
	x = root(x);
	y = root(y);
	if (x == y) {
		return;
	}
	//following code for implementing union by rank
	if (par[x] > par[y]) { // implies x is the smaller grp as par's are -ve
		par[y] += par[x];
		par[x] = y;
	}
	else {
		par[x] += par[y];
		par[y] = x;
	}
	//deb(par[x]); deb(par[y]);
}
int main() {

	memset(par, -1, sizeof par);
	int n, m;
	cin >> n >> m;
	rep(i, 0, m) {
		int x, y;
		cin >> x >> y;
		merge(x, y);
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		ans = min(ans, par[i]);
	}
	cout << -ans;
	return 0;
}


Measured memory_bytes: 4408
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    int s[3]={a,b,c};
    sort(s,s+3);
    cout<<s[1]+s[0]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int dp[505][505];
vector<int> en[505];

int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    for (int i = 0; i < m; ++i)
    {
        int l, r;
        cin >> l >> r;
        en[l].push_back(r);
    }
    for (int i = 1; i <= n; ++i)
    {
        vector<int> red(n + 1);
        int cnt = 0;
        for (int j = i; j <= n; ++j)
        {
            for (int x : en[j])
                red[x]++;
            cnt += red[j];
            dp[i][j] = cnt;
            //cnt -= red[j];
        }
    }
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        cout << dp[l][r] << '\n';
    }
}


Measured memory_bytes: 3200
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	int a;
	cin >> a;
	if (a < 1200) {
		puts("ABC");
		return 0;
	}
	else {
		puts("ARC");
	}
	return 0;
}

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

#define rep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll MOD = 1e9+7;

int main(){

    ll N,ans = 0;
    ll s = 0;
    cin >> N;
    vector<int> A(N,0);

    rep(i,0,N){
        cin >> A[i];
    }

    sort(A.begin(),A.end());

    rep(i,0,N){
        if ((s*2) >= A[i]){
            s += A[i];
            ans += 1;
        }else{
            s += A[i];
            ans = 1;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rev(i,a,b) for(int (i)=(b)-1;(i)>=(a);(i)--)
using namespace std;

int main(void){
	int N;
	int read[1000];
	int write[1000];
	bool dp[1001];
	while (true){
		cin >> N;
		if (N == 0)
			return(0);

		rep(i, 0, N)
			cin >> read[i] >> write[i];

		int read_sum = 0;
		int read_max = 0;
		int max_index = 0;
		rep(i, 0, N){
			if (read[i] > read_max)
				read_max = read[max_index = i];
			read_sum += read[i];
		}
		read_sum -= read_max;

		int write_sum = 0;
		rep(i, 0, N)
			write_sum += write[i];

		int all_sum = read_max + read_sum + write_sum;
		int wait_space = read_max - read_sum;
		if (wait_space <= 0)
			cout << all_sum << endl;
		else{
			rep(i, 0, wait_space + 1)
				dp[i] = false;
			dp[0] = true;
			rep(i, 0, N)
			if (i!=max_index)
				rev(j, write[i], wait_space + 1)
			if (dp[j - write[i]])
				dp[j] = true;

			rev(i, 0, wait_space + 1)
			if (dp[i]){
				cout << ((wait_space)-i) + all_sum<<endl;
				break;
			}

		}
	}
}

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

public class Main {
    static long mod = (long) 1e9 + 7;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt(); int m = sc.nextInt();
        int [] s = new int[n + 1];
        int [] t = new int[m + 1];
        for (int i = 1; i <= n; i++) s[i] = sc.nextInt();
        for (int i = 1; i <= m; i++) t[i] = sc.nextInt();
        long [][] dp = new long[n + 1][m + 1];
        dp[0][0] = 1;
        for (int i = 1; i <= n; i++) dp[i][0] = 1;
        for (int i = 1; i <= m; i++) dp[0][i] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (s[i] == t[j]) {
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
                } else {
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1]) % mod;
                }
                if (dp[i][j] < 0) dp[i][j] += mod;
            }
        }
        out.println(dp[n][m]);
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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: 65940
#include <cstdio>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>
using namespace std;
const int max_n = 100000+5;
long long n, W,L,P,c;

long long  v[3*max_n],w[max_n],m[max_n],A[max_n],spf[max_n],co[max_n];  
typedef pair<long, long> pii; 
pii p[max_n];
pii bb[max_n];
struct Cmp {
  bool operator()(const pii &a, const pii &b) {
    return a.second > b.second;
  }
};
void solve(){
    priority_queue<long> ba;
    priority_queue<long, vector<long>, greater<long> > fo;
    vector<long long >  s(2*n+1, 0);
    for(int i=0 ; i<n ; i++){
        s[i+1] = s[i] + v[i];
        fo.push(v[i]);
    }
    for(int i=n ; i<2*n ; i++){
        long long mi = fo.top();
        if(mi < v[i]){
            s[i+1] = s[i] + v[i] - mi;
            fo.pop();
            fo.push(v[i]);
        }else{
            s[i+1] = s[i];
        }
    }
    vector<long long> T(2*n+1);
    for(int i=0 ; i<n ; i++){
        T[i+1] = T[i] + v[3*n -i -1];
        ba.push(v[3*n-i-1]);
    }
    for(int i=n ; i<2*n ; i++){
        long long ma = ba.top();
        if(v[3*n-i-1]<ma){
            T[i+1] = T[i] - ma + v[3*n-i-1];
            ba.pop();
            ba.push(v[3*n-i-1]);
        }else{
            T[i+1] = T[i];
        }
    }
    long long res = -(1LL<<60);
    for(int i=n ; i<=2*n ; i++){
        res = max(res, s[i] - T[3*n -i]);
    }

    cout << res << endl;
}
int main(){
    cin >> n;
    for(int i=0 ; i<n*3 ; i++){
        cin >> v[i];
    }
    solve();
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  
  for (int i = 0; i < N; i++) {
    int r, l;
    cin >> r >> l;
    
    ans += l - r + 1;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

// 入力受付用の変数
#define BUF 200002
char str[BUF];

// 入力された値
#define DIV 1000000007
#define LIM_N 100001
int N, M;
int A[LIM_N];

int broken[LIM_N];
int step[LIM_N];

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d", &N, &M);

	for (size_t i = 0; i < M; i++) {
		scanf("%d", &A[i]);
	}
}

int get_step(int i) {
	if (N < i) {
		return 0;
	}

	if (broken[i]) {
		step[i] = 0;
	}

	if (step[i] == -1) {
		int step1 = get_step(i+1);
		int step2 = get_step(i+2);
		step[i] = step1 + step2;
		step[i] %= DIV;
	}

	return step[i];
}

void solve() {
	for (int i = 0; i < M; i++) {
		broken[A[i]] = 1;
	}

	for (int i = 0; i < N; i++) {
		step[i] = -1;
	}
	step[N] = 1;

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

	// for (size_t i = 0; i <= N; i++) {
	// 	printf("%2d ", i);
	// }
	// printf("\n");
	// for (size_t i = 0; i <= N; i++) {
	// 	printf("%2d ", step[i]);
	// }
	// printf("\n");

	printf("%d\n", step[0]);
}

int main(void) {
	receive_input();

	solve();

	return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>

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

  if(x==y){
    printf("%d\n",x);
    return 0;
  }else if(x>y){
    n=y;
  }else{
    n=x;
  }
  
  for(d=n/2;d>0;d--){
    if(x%d==0&&y%d==0){
      printf("%d\n",d);
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 2140
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    a = min(A[i], B[i])
    ans += a
    B[i] -= a
    b = min(A[i + 1], B[i])
    A[i + 1] -= b
    ans += b
print(ans)


Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int a[12][12];
int c[12];
int INF = 1001001001;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  rep(i, n) {
    cin >> c[i];
    rep(j, m) {
      cin >> a[i][j];
    }
  }

  int ans = INF;

  rep(i, 1 <<n ) {
  int cost = 0;
  vector<int> s(m);
    rep(j, n) {
      if(i >> j & 1) {
        cost += c[j];
        rep(k, m) s[k] += a[j][k];
      }
    }
    bool ok = true;
    rep(j, m) 
      if(s[j] < x )  ok = false;
    if(ok) ans = min(ans, cost);
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}

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

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

ll mod=1e9+7;

using namespace std;


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

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

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
    cout << a << "\n";
}

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

    ll p,q,r;
    cin >> p >> q >> r;

    cout << min<ll>(min<ll>(p+r,r+q),p+q) << endl;
     
	return 0;
}


Measured memory_bytes: 256
import queue
import copy
import math
from collections import deque

h = int(input())

if h == 0:
    print(0)
    exit(0)

if h == 1:
    print(1)
    exit(0)

depth = math.log2(h)


waru = 0
target = h
while True:
    d, m = divmod(target, 2)
    target = d
    waru += 1
    if target == 1:
        break
    else:
        continue

d, m = divmod(h, 2)

ans = 0
for i in range(0, waru + 1):
    ans += 2**i

print(ans)

Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i] = A[i];
  }
  sort(B.begin(),B.end());
  int max = B[N - 1];
  int semimax = B[N - 2];
  for (int i = 0; i < N; i++) {
    int ans = 0;
    if (A[i] == max) {
      ans = semimax;
    }
    else {
      ans = max;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<fstream>
#include<limits.h>
#include<algorithm>
#include<string>
#include<vector>
#include<unordered_map>
#include<cmath>
#include<queue>

using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    k=min(n-1,k);
    vector<int> a(n),dp(n);
    for (int i=0; i<n ;i++)
    {
        cin>>a[i];
        dp[i]=INT_MAX;
    }
    if(n<=1)cout<<0<<endl;
    
    dp[0]=0;
    for(int i=1;i<=k;i++)
    dp[i]=abs(a[i]-a[0]);
    for(int i=k+1;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
        dp[i]=min(dp[i],abs(a[i]-a[i-j])+dp[i-j]);
        }
        //cout<<i<<dp[i]<<endl;
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<String> list = new ArrayList<String>();
		int i = 0;
		String hoge = sc.next();
		list.add(hoge);
		for(i = 1; i < n; i++){
			String w = sc.next();
			hoge = hoge.substring(hoge.length()-1,hoge.length());
			String hoge2 = w.substring(0,1);
			if(!hoge.equals(hoge2)){
				break;
			}else if(list.indexOf(w) > -1){
				break;
			}else{
				list.add(w);
				hoge = w;
			}
		}
		System.out.print(i == n?"Yes":"No");
	}
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define int ll
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<int(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    RG ll x=0;char f=0;RG char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL double readdb(){
    RG double x=0,p=0.1;RG char f=0,c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=x*10+(c^48);
    if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);puts("");}
IL void writeln(ll x,char c,ll y){write(x);pc(c);writeln(y);}
IL void writeln(ll x,char c,ll y,char d,ll z){write(x);pc(c);write(y);pc(d);writeln(z);}
#undef gc
#undef pc
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define y1 ____y1
#define hash __hash
#define union _union
const int maxn = 15050;
int a[1505][1500],fa[maxn],f[maxn];
int z[maxn];
bitset<10010> qaq;
vector<int> V;
int find(int x){
	return x==fa[x]?x:fa[x]=find(fa[x]);
}
int n,k,m;
signed main(){
	n = rd(),m = rd();
	Rep(i,1,m){
		int x = rd(),y = rd();
		a[x][y] = true;
		a[y][x] = true;
	}
	Rep(i,1,2*n) fa[i] = i;
	Rep(i,1,n){
		Rep(j,i+1,n){
			if(!a[i][j]){
				//i和j不是一个集合 
				fa[find(i)] = find(j+n);
				fa[find(i+n)] = find(j);
			}
		}
	}
	Rep(i,1,n){
		if(find(i)==find(i+n)){
			puts("-1");
			return 0;
		}
	}
	mem(f,0);
	Rep(i,1,n) f[find(i)]++,f[find(i+n)]--;
	for (int i=1;i<=n;i++)
		if (find(i)==i)z[++*z]=abs(f[i]);
	qaq[n]=1;
	Rep(i,1,*z) qaq=(qaq<<z[i])|(qaq>>z[i]);
	Rep(i,0,n)if (qaq[i+n]){
		int xx=(n-i)/2,yy=xx+i;
		writeln(xx*(xx-1)/2+yy*(yy-1)/2);
		return 0;
	}puts("-1");
	return 0;
}


Measured memory_bytes: 9984
#include <ctype.h>
#include <stdio.h>
#include <string.h>

#include <queue>

using namespace std;

char map[1000][1000];
bool visited[1000][1000];
int W, H, N;
int startR, startC;
int targetR[10];
int targetC[10];

int dr[4] = {-1, 1, 0, 0};
int dc[4] = {0, 0, -1, 1};

int getMinTime() {
  int time = 0;
  int curR = startR;
  int curC = startC;
  for (int i = 0; i < N; ++i) {
    memset(visited, false, sizeof(visited));
    queue<int> q;
    q.push((curR << 16) | curC);
    visited[curR][curC] = true;
    while (!visited[targetR[i]][targetC[i]]) {
      time++;
      int count = q.size();
      while (count-- > 0) {
        int node = q.front();
        q.pop();
        int r = node >> 16;
        int c = node & 0xffff;
        for (int j = 0; j < 4; ++j) {
          int nr = r + dr[j];
          int nc = c + dc[j];
          if (nr >= 0 && nr < H && nc >= 0 && nc < W && !visited[nr][nc] && map[nr][nc] != 'X') {
            visited[nr][nc] = true;
            q.push((nr << 16) | nc);
          }
        }
      }
    }
    curR = targetR[i];
    curC = targetC[i];
  }
  return time;
}

int main() {
  //freopen("Cheese.in", "r", stdin);
  while (scanf("%d%d%d", &H, &W, &N) == 3 && W != 0 && H != 0 && N != 0) {
    for (int r = 0; r < H; ++r) {
      for (int c = 0; c < W; ++c) {
        char ch;
        do {
          ch = getchar();
        } while (isspace(ch));
        if (ch == 'S') {
          startR = r;
          startC = c;
        } else if (isdigit(ch)) {
          int index = ch - '0' - 1;
          targetR[index] = r;
          targetC[index] = c;
        }
        map[r][c] = ch;
      }
    }
    int result = getMinTime();
    printf("%d\n", result);
  }
  return 0;
}

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

int main() 
{ 
	int n;
	cin>>n;
	map<int,int>mp;
	for(int i=0;i<n-1;i++){
	    int x;
	    cin>>x;
	    mp[x]++;
	}
    for(int i=1;i<=n;i++){
	    cout<<mp[i]<<"\n";
	}
} 


Measured memory_bytes: 13008
#include<iostream>
using namespace std;
#define MAX 10000000

bool P[MAX + 1];

void eratos(){
    for ( int i = 0; i <= MAX; i++ ) P[i] = true;
    P[0] = P[1] = false;
    for ( int i = 2; i*i <= MAX; i++ ){
	if ( P[i] )
	    for ( int j = 2; i*j <= MAX; j++ ) P[i*j] = false;
    }
}

int getQuads(int n){
    for ( int i = n; i >= 13; i--)
	if ( P[i] && P[i-2] && P[i-6] && P[i-8] ) return i;
}

int main(void){
    eratos();
    int n;
    while( cin >> n && n ) cout << getQuads(n) << endl;

    return 0;
}

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

using namespace std;

struct Shop {
    string str;
    int score;
    int idx;
};

bool f(const Shop& a,const Shop& b)
{
    if(a.str==b.str) return a.score>b.score;
    return a.str<b.str;
}

int main()
{
    vector<Shop> v;
    int n;
    cin>>n;

    for(int i=1;i<=n;i++){
        Shop s;
        cin>>s.str>>s.score;
        s.idx=i;

        v.push_back(s);
    }
    sort(v.begin(),v.end(),f);

    for(int i=0;i<n;i++){
        printf("%d\n",v[i].idx);
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n*2-n%2;i++){
        char c;
        scanf("%c",&c);
        if(c==' ') continue;
        if(c=='Y'){
            printf("Four");
            return 0;
        }
    }
    printf("Three");
    return 0;
}


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

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

	vector<vector<int> > vec(M);

	for (int i = 0; i < M; ++i) {
		int k; 
		cin >> k;
		vec[i].resize(k);
		for (int j = 0; j < k; ++j) {
			cin >> vec[i][j];
			--vec[i][j];
		}
	}

	vector<int> p(M);
	for (int i = 0; i < M; ++i) cin >> p[i];

	int ans = 0;
	for (int i = 0; i < (1 << N); ++i) {
		bool ok = true;
		for (int j = 0; j < M; ++j) {
			int c = 0;
			for (int id : vec[j]) {
				if ((i >> id) & 1) {
					++c;
				}
			}
			c %= 2;
			if (c != p[j]) {
				ok = false;
			}
		}
		if (ok) {
			++ans;
		}
	}

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

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template<class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template<class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

//IN
void IN() {}
template<class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

//OUTS
template<size_t> struct int_{};
template<class Tuple, size_t Pos>
ostream& print_tuple(ostream& out, const Tuple& t, int_<Pos>) {
  out << get<tuple_size<Tuple>::value-Pos>(t) << " ";
  return print_tuple(out, t, int_<Pos-1>());
}

template <class Tuple>
ostream& print_tuple(ostream& out, const Tuple& t, int_<1>) {
  return out << get<tuple_size<Tuple>::value-1>(t);
}

template<class... Args>
ostream& operator<<(ostream& out, const tuple<Args...>& t) {
  return print_tuple(out, t, int_<sizeof...(Args)>());
}

#define OUTS(...) cout << make_tuple(__VA_ARGS__) << "\n";

//OUTL
void OUTL() {}
template<class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

//OUTN
void OUTN() {}
template<class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  VAR(int, sx, sy, tx, ty);
  OUTN(string(tx-sx, 'R'), string(ty-sy, 'U'), string(tx-sx, 'L'), string(ty-sy, 'D'));
  OUTN('D', string(tx-sx+1, 'R'), string(ty-sy+1, 'U'), 'L');
  OUTN('U', string(tx-sx+1, 'L'), string(ty-sy+1, 'D'), 'R');
  OUTL("");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mod=100000;
int N,M,S;
int dp[2001][3001];
int dpsum[2001][3001];
//int dp1[2009][3009];
int main()
{
while(true){
	scanf("%d%d%d",&N,&M,&S);
	if(N==0&&M==0&&S==0)break;
	for(int i=0;i<=M;i++){
		for(int j=0;j<=S;j++){
			dp[i][j]=0;dpsum[i][j]=0;
		}
	}
	dp[0][0]=1;
	for(int i=1;i<=N*N;i++){
		for(int j=i-1;j<=M;j++){
			int xx=S;
			for(int k=i+1;k<=N*N;k++){
				xx-=(j+k-i-1);
			}
			for(int k=i*(i-1)/2;k<=xx;k++){
				if(j!=0){
					dpsum[j][k]=dpsum[j-1][k]+dp[j][k];
					if(dpsum[j][k]>=mod)dpsum[j][k]-=mod;
				}
				else{
					dpsum[j][k]=dp[j][k];
				}
				/*
				if(j+k+1<=S){
					dp1[j+1][j+k+1]=dpsum[j][k];
				}*/
				//dp1[l][k+l]
				/*
				if(dp[j][k]==0)continue;
				for(int l=j+1;l<=M;l++){
				
					if(k+l<=S){
						dp1[l][k+l]+=dp[j][k];
						if(dp1[l][k+l]>=mod)dp1[l][k+l]-=mod;
					}
				}*/
			}
		}
		for(int j=0;j<=M;j++){
			for(int k=j;k<=S;k++){
				dp[j][k]=0;
			}
		}
		for(int j=0;j<=M;j++){
			for(int k=0;k<=S-j-1;k++){
				dp[j+1][j+k+1]=dpsum[j][k];dpsum[j][k]=0;
				
			}
		}
		/*
		for(int j=0;j<=M;j++){
			for(int k=0;k<=S;k++){
				if(dp[j][k]!=0)printf("%d %d %d:%d\n",i,j,k,dp[j][k]);
			}
		}*/
	}
	int ans=0;
	for(int j=1;j<=M;j++){
		//printf("")
		ans+=dp[j][S];ans%=mod;
	}
	printf("%d\n",ans);
}
	return 0;
}

Measured memory_bytes: 50040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    int n;
    string s;
    cin>>n>>s;
    int cnt=0;
    rep(i,n-2){
       if (s.substr(i,3)=="ABC" ) cnt++;
    }
    cout << cnt;
}

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

int main(){
    int H, W;
    cin >> H >> W;

    vector<vector<char>> a(H, vector<char>(W));

    rep(i,H){
        rep(j,W){
            cin >> a.at(i).at(j);
        }
    }

    rep(i,H){
        // i行目はすべて白か？
        int counter_w = 0;
        rep(j,W){
            if(a.at(i).at(j) == '.'){
                counter_w++;
            }
        }
        if (counter_w == W){
            a.erase(a.begin() + i);
            H--;
            i = -1;
        }
    }

    rep(j,W){
        // j列目はすべて白か？
        int counter_w = 0;
        rep(i,H){
            if(a.at(i).at(j) == '.'){
                counter_w++;
            }
        }
        
        if (counter_w == H){
            // j列目を削除
            rep(ri,H){
                a.at(ri).erase(a.at(ri).begin() + j);
            }
            j = -1;
            W--;
        }
    }

    rep(i,H){
        rep(j,W){
            cout << a.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int x;

int main()
{
	cin>>x;
	for(int i = x; i > 0 ; i--)
	{
		if(sqrt(i) - (int)sqrt(i) == 0)
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;


int main(){
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  reverse(a, a + n);
  long long answer = 1, min_distance = a[0];
  if (a[0] % 2 == 0){
    long long mid = a[0] / 2;
    while(abs(a[answer] - mid) < min_distance){
      min_distance = a[answer] - mid;
      answer++;
    }
  }
  else{
    long long mid1 = (a[0] - 1) / 2, mid2 = (a[0] + 1) / 2;
    while ((min(abs(a[answer] - mid1), abs(a[answer] - mid2))) < min_distance){
      min_distance = min(abs(a[answer] - mid1), abs(a[answer] - mid2));
      answer++;
    }
  }
  cout << a[0] << " " << a[answer - 1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std ;
int main()
{
    int A , B , C ;
    cin >> A >> B >> C ;
    if (A >= -100 && C <=100)
    {
        if (A == B)
            cout << C ;


        if (B == C)
            cout << A ;

        if (A == C)
            cout << B ;

    }




}

Measured memory_bytes: 256
flag = False
mini = 124
time = 0
for _ in range(5):
    A = int(input())
    if A%10 == 0:
        time += A
    else:
        time += A - A%10 + 10
        mini = min(A%10, mini)
        flag = True
if flag:
    time += mini - 10
print(time)

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;

    cout << min({a+b, b+c, c+a}) << endl;
    return 0;
}


Measured memory_bytes: 256
function Main(input){
    var data = input.split(" ");
    for(var i = 0; i < 3; i++){
        data[i] = parseInt(data[i]);
    }
    
    if(data[0] + data[1] < data[2] || data[0] > data[2]){
        console.log("NO");
        return;
    }
    
    console.log("YES");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const int INF = 1e9;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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


int main(void){
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  vector<ll> L(N);
  REP(i, N) {cin >> L[i];}

  vector<ll>::iterator position; 
  sort(L.begin(), L.end());

  ll ans = 0;
  FOR(i, 0, N-2){
    FOR(j, i+1, N-1){
      ll tmp;
      ll idx;
      ll val;
      val = L[i] + L[j];
      if (val > L[N-1]){
        tmp = N -j - 1;
      }
      else{
      position = lower_bound(L.begin(), L.end(), val);
      idx = distance(L.begin(), position);
      tmp = idx - j - 1;
      }

      ans += tmp;
    }
    }

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



Measured memory_bytes: 256