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

using namespace std;
#define endl "\n"
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> pii;
int n, k;
const int N = 1e5 + 5;
ll f[N], res;

ll expo(ll a, ll b) {
    if  (b == 0) return 1;
    if (a == 0) return 0;
    ll temp = expo(a, b / 2);
    temp = (temp * temp) % MOD;
    if (b & 1) temp = (temp * a) % MOD;
    return temp;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k;
    for (int i = k; i >= 1; --i) {
        f[i] = expo(k / i, n);// f[i] = g[i]: so gcd la boi cua i
        for (int j = 2; j <= k / i; ++j)
            f[i] -= f[j * i];
        f[i] %= MOD;
        if (f[i] < 0) f[i] += MOD;
        res = (res + (f[i] * i)) % MOD;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;
using PII = pair<ll, ll>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())
#define MP make_pair

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

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

    // input
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a!=c){
      p(1);
    }else{
      p(0);
    }
    
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)

S_int = int(S, 2)

count_b = 0
black_ff = [str(i % 2) for i in range(N)]
for i, d in enumerate(black_ff):
    if S[i] != d: count_b += 1

count_w = 0
white_ff = ["0" if i % 2 == 1 else "1" for i in range(N)]
for i, d in enumerate(white_ff):
    if S[i] != d: count_w += 1
        
print(min(count_b, count_w))

Measured memory_bytes: 10364
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int m = max({A, B, C});
    while(K) {
        m *= 2;
        K--;
    }
    cout << A+B+C+m-max({A, B, C}) << endl;
    return 0;
}


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

using namespace std;
void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
    if (rest == 0) {
        f(indexes);
    } else {
        if (s < 0) return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes[rest - 1] = s;
        recursive_comb(indexes, s - 1, rest - 1, f);
    }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
    int indexes[k];
    recursive_comb(indexes, n - 1, k, f);
}

int main() {
    long long int n, cnt = 0;
    cin >> n;
    vector<long long int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    foreach_comb(n, 3, [&](int *indexes) {
        if(vec.at(indexes[0]) != vec.at(indexes[1]) && vec.at(indexes[2]) != vec.at(indexes[1]) && vec.at(indexes[2]) != vec.at(indexes[0])){
            if(abs(vec.at(indexes[1]) - vec.at(indexes[2])) < vec.at(indexes[0])){
                if(vec.at(indexes[0]) < (vec.at(indexes[1]) + vec.at(indexes[2]))){
                    cnt++;
                }
            }
        }

    });
    cout << cnt << endl;
    return 0;
}


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

int main() {
    string s, t;
    cin >> s;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != t[i]) {
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3836
#include<cstdio>
using namespace std;
#define N 1050
#define K 36
char as[N][K];
int p[N][2],n,is1,is2;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&p[i][0],&p[i][1]);p[i][0]*=-1,p[i][1]*=-1;
		if((p[i][0]+p[i][1])&1)is1=1;
		else is2=1;
	}
	if(is1&&is2){printf("-1\n");return 0;}
	if(is1)
	{
		printf("31\n");
		for(int i=0;i<=30;i++)printf("%d ",1<<i);
		printf("\n");
		for(int i=0;i<30;i++)
		{
			int le=1<<i;
			for(int j=1;j<=n;j++)
			{
				if(p[j][0]>>i&1)
				{
					if(p[j][1]>>i&2)
					{
						int tp1=p[j][0]+le;
						if(tp1>>i&2)p[j][0]-=le,as[j][i]='L';
						else p[j][0]+=le,as[j][i]='R';
					}
					else
					{
						int tp2=p[j][0]-le;
						if(tp2>>i&2)p[j][0]-=le,as[j][i]='L';
						else p[j][0]+=le,as[j][i]='R';
					}
				}
				else
				{
					if(p[j][0]>>i&2)
					{
						int tp1=p[j][1]+le;
						if(tp1>>i&2)p[j][1]-=le,as[j][i]='D';
						else p[j][1]+=le,as[j][i]='U';
					}
					else
					{
						int tp2=p[j][1]-le;
						if(tp2>>i&2)p[j][1]-=le,as[j][i]='D';
						else p[j][1]+=le,as[j][i]='U';
					}
				}
			}
			for(int i=1;i<=n;i++)
			if(p[i][1])as[i][30]=p[i][1]>0?'D':'U';else as[i][30]=p[i][0]>0?'L':'R';
		}
		for(int i=1;i<=n;i++)printf("%s\n",as[i]);
	}
	else
	{
		printf("32\n1 ");
		for(int i=0;i<=30;i++)printf("%d ",1<<i);
		printf("\n");
		for(int i=1;i<=n;i++)p[i][0]--,as[i][0]='L';
		for(int i=0;i<30;i++)
		{
			int le=1<<i;
			for(int j=1;j<=n;j++)
			{
				if(p[j][0]>>i&1)
				{
					if(p[j][1]>>i&2)
					{
						int tp1=p[j][0]+le;
						if(tp1>>i&2)p[j][0]-=le,as[j][i+1]='L';
						else p[j][0]+=le,as[j][i+1]='R';
					}
					else
					{
						int tp2=p[j][0]-le;
						if(tp2>>i&2)p[j][0]-=le,as[j][i+1]='L';
						else p[j][0]+=le,as[j][i+1]='R';
					}
				}
				else
				{
					if(p[j][0]>>i&2)
					{
						int tp1=p[j][1]+le;
						if(tp1>>i&2)p[j][1]-=le,as[j][i+1]='D';
						else p[j][1]+=le,as[j][i+1]='U';
					}
					else
					{
						int tp2=p[j][1]-le;
						if(tp2>>i&2)p[j][1]-=le,as[j][i+1]='D';
						else p[j][1]+=le,as[j][i+1]='U';
					}
				}
			}
			for(int i=1;i<=n;i++)if(p[i][1])as[i][31]=p[i][1]>0?'D':'U';else as[i][31]=p[i][0]>0?'L':'R';
		}
		for(int i=1;i<=n;i++)printf("%s\n",as[i]);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int main(){
    string S;
    cin >> S;
    
    size_t size = S.length();
    
    int cutting[size];
    
    int i =0;
    for(i=0;i<size-2;i++){
        cutting[i] = stoi(S.substr(i,3));
    }
    int ans = __INT_MAX__;
    
    for(i=0;i<size;i++){
        int sa = fabs(753-cutting[i]);
        
        ans = min(sa,ans);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		char[] c = s.toCharArray();
		int[] num = new int[c.length];
		for(int i=0;i<c.length;i++){
			num[i] = Character.getNumericValue(c[i]);
		}
		for(int i=0;i<8;i++){
			String bin = Integer.toBinaryString(i);
			int sum = num[0];
			if(bin.length() == 1){
				bin = "00" + bin;
			}else if(bin.length() == 2){
				bin = "0" + bin;
			}
			char[] cstr = bin.toCharArray();
			for(int j=0;j<3;j++){
				if(cstr[j]== '0'){
					cstr[j] = '+';
					sum += num[j+1];
				}else{
					cstr[j] = '-';
					sum -= num[j+1];
				}
			}
			if(sum == 7){
				System.out.println(String.valueOf(num[0]) + cstr[0] + String.valueOf(num[1]) + cstr[1] + String.valueOf(num[2]) + cstr[2] + String.valueOf(num[3]) + "=7");
				return ;
			}
		}

	}

}

class Combination {
	char a;
	char b;
	char c;

	public char getA(){
		return a;
	}

	public void setA(char a){
		this.a = a;
	}

	public char getB(){
		return b;
	}

	public void setB(char b){
		this.b = b;
	}

	public char getC(){
		return c;
	}

	public void setC(char c){
		this.c = c;
	}
}


Measured memory_bytes: 23764
k, x = (int(i) for i in input().split())

max = 1000000
min = -1000000
ans_list = []

if x-k+1 < min:
    bottom = min
else:
    bottom = x-k+1

if x+k-1 > max:
    head = max
else:
    head = x+k-1


for number in range(bottom, head+1):
    ans_list.append(number)

print(*ans_list)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

#define vcitr vector<int>::iterator
#define vcsitr vector<string>::iterator
#define mapcitr map<char, int>::iterator
#define mapsitr map<string, int>::iterator

typedef long long ll;

int iINF = 2147483647;
ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

string day[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
int len[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
	int x, y;
	
	while (cin >> x >> y) {
		if (x==0 && y==0) break;
		
		int ans = 3;
		for_(i, 0, x) {
			int l = len[i];
			
			if (i==x-1) {
				l = y-1;
			}
			
			for_(j, 0, l) {
				ans++; ans %= 7;
			}
		}
		cout << day[ans] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define Pi 3.1415926535
#define MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}

void change(int& a, int& b){
    if(a>b) swap(a,b);
}

int solve(){
    int n,x,y; cin >> n >> x >> y;
    --x, --y;
    vector<vint> dist(n,vint(n,-1));
    vector<vint> g(n,vint(0));
     rep(i,n-1){
        g.at(i).pb(i+1);
        g.at(i+1).pb(i);
    }
    g.at(x).pb(y);
    g.at(y).pb(x);

     for(int i = 0; i < n; ++i){
        queue<int> search;
        dist[i][i] = 0;
        search.push(i);
        while(!search.empty()){
            int v = search.front();
            search.pop();
            for(auto nv : g[v]){
                if(dist[i][nv] != -1) continue;
                else{
                    dist[i][nv] = dist[i][v] + 1;
                    search.push(nv);
                }
            }
        }
    }

    vint ans(n,0);
    for(int i; i < n; ++i){
        for(int j =i+1; j < n; ++j){
            if(dist.at(i).at(j) < n){
               ++ans.at(dist.at(i).at(j));
            }  
        }
    }
    repp(i,n-1){
        cout << ans.at(i) << endl;
    }

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


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




int main(){
    int n;
    int m;
    cin >> n >> m;
    int ans=0;
    vector <vector <int>> h(n);
    int a,b;
    rep(i,m){
        cin >> a >> b;
        --a;
        --b;
        h[a].push_back(b);
        h[b].push_back(a);
    }

    vector <int> t(n,0);
    queue <int> ba;
    queue <vector <int>> tu;
    t[0]=1;
    ba.push(0);
    tu.push(t);
    int nu;
    int l;
    int ma=1;
    queue <int> maq;
    maq.push(ma);

    while(ba.size()!=0){
        nu=ba.front();
        ba.pop();
        t=tu.front();
        tu.pop();
        l=h[nu].size();
        ma=maq.front();
        maq.pop();
        //cout << nu << " " << ma << endl;
        if(ma==n){
            ++ans;
        }
        else{
        rep(j,l){
            if(t[h[nu][j]]==0){
                t[h[nu][j]]=1;
                ba.push(h[nu][j]);
                tu.push(t);
                t[h[nu][j]]=0;
                maq.push(ma+1);

            }
        }
        }
    }

    cout << ans << endl;
    


    

    return 0;
}

Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
int main(){
set<int>s;
int N,num;
cin>>N;
for(int i=0;i<N;i++){
    cin>>num;
    s.insert(num);
}
int cnt=0;
for(int x:s){
  cnt++;
}
cout<<cnt;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	int count = 0;
	for (int i = 1; i < n - 1; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1]) count++;
		else if (p[i + 1] < p[i] && p[i] < p[i - 1]) count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<climits>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
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; } }
using namespace std;

int main(void) {
	int s;
	cin >> s;

	int upper_half = s / 100;
	int lower_half = upper_half == 0 ? s % 100 : s % (s / 100 * 100);

	if (upper_half <= 12 && upper_half >= 1 && lower_half >= 1 && lower_half <= 12) {
		cout << "AMBIGUOUS" << endl;
	}
	else if(upper_half <= 12 && upper_half >= 1){
		cout << "MMYY" << endl;
	}
	else if (lower_half >= 1 && lower_half <= 12) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA" << endl;
	}
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 15.12.2019 11:24:13       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = abs(a - c);
  int y = abs(b - d);
  cout << x + y - __gcd(x, y) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
ll n,k;
int main(){
	n=read(),k=read();
	n%=k;
	cout<<min(n,k-n)<<endl;
//	getchar();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

vector<ll> m(1001,0);

int main(){

    ll n; cin >> n;
    ll pos = ((n%2 == 0)?1:0);
    ll ans = 1;

    vector<ll> a(n),m(n+1,0);

    rep(i,n){
        cin >> a[i];
        m[a[i]] ++;
    }

    while(pos < n){

        if(pos == 0){
            if(m[pos] != 1) {
                cout << 0;
                return 0;
            }
        }else if(m[pos] != 2){
            cout << 0;
            return 0;
        }

        pos += 2;
    }

    rep(i,n/2){
        ans *= 2;
        ans %= MOD;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 4816
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int h, w;
  cin >> h >> w;
  vector<string> mp(h);
  for(int i = 0; i < w; ++i)
  {
    cin >> mp[i];
  }

  for(int y = 0; y < h; ++y)
  {
    for(int x = 0; x < w; ++x)
    {
      if (mp[y][x] == '#')
      {
        if (y >= 1 && mp[y - 1][x] == '#') continue;
        if (x >= 1 && mp[y][x - 1] == '#') continue;
        if (y + 1 < h && mp[y + 1][x] == '#') continue;
        if (x + 1 < w && mp[y][x + 1] == '#') continue;
        cout << "No";
        return;
      }
    }
  }
  cout << "Yes";
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3612
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,ans,vis[55],jk[55],q[55],top;
struct Node{
	ll x;
	ll y;
}a[55],h[100005];
int check(int x){
	if(vis[x])return 0;
	vis[x]=1;
	while(jk[x]!=0){
		x=q[x];
		if(vis[x])return 0;
		vis[x]=1;
	}
	return 1;
}
int main(){
	in(n);
	ans=n;
	for(int i=1;i<=n;i++){
		in(a[i].x);
		in(a[i].y);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i!=j){
				h[++top].x=a[i].x-a[j].x;
				h[top].y=a[i].y-a[j].y;
			}
		}
	}
	for(int c=1;c<=top;c++){
		ll i=h[c].x;
		ll j=h[c].y;
		if(i==0&&j==0)continue;
		int sum=0;
		memset(vis,0,sizeof(vis));
		memset(jk,0,sizeof(jk));
		for(int k=1;k<=n;k++){
			ll x=a[k].x-i,y=a[k].y-j;
			int flag=0;
			for(int g=1;g<=n;g++){
				if(a[g].x==x&&a[g].y==y){
					flag=g;
					break;
				}
			}
			if(flag==0)continue;
			q[k]=flag;
			jk[k]=1;
		}
		for(int k=1;k<=n;k++)sum+=check(k);
		ans=min(ans,sum);
	}
	printf("%d\n",ans);
	return 0;
}

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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
const ll P =  1000000007;
ll factorial(ll n){
   ll ans = 1;
   for(int i = n;i>=1;i--){
     ans *= i;
     ans %= P;
   }
   return ans;
}
using Graph = vector<vector<int>>;

ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}

int main(){
  int H,A;
  cin >> H >> A;
  cout << (H+A-1)/A << endl;
 }


Measured memory_bytes: 256
using System;

namespace AOJ.ITP
{
    public class Print_A_Frame
    {
        public static void Main()
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                int h = int.Parse(input[0]);
                int w = int.Parse(input[1]);
                if (h <= 0 || w <= 0) { break; }

                // 上の辺・下の辺
                string frame = new string('#', w);
                // 真ん中
                string mid = "#" + new string('.', w - 2) + "#";

                Console.WriteLine(frame);
                for (int i = 0; i < h - 2; i++) { Console.WriteLine(mid); }
                Console.WriteLine(frame);

                Console.WriteLine();
            }
        }
    }
}

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

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int> ans(N - 1);
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      int r = min(j - i, min(abs(X - 1 - i) + 1 + abs(Y - 1 - j), abs(Y - 1 - i) + 1 + abs(X - 1 - j)));
      //cout << r << endl;
      ans.at(r - 1)++;
    }
  }
  for (int i = 0; i < N - 1; i++) {
    cout << ans.at(i) << endl;
  }
}

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

#define    int               long long int
 #define    bp(x)         __builtin_popcount(x)
#define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
#define  mod  1000000007
#define  endl  "\n"
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int32_t main()
{
    fast
    string s,a="s",b="es";
    cin>>s;
    int n=sz(s);
    
    if(s[n-1]=='s') cout<<s<<b;
    else cout<<s<<a;
    
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;

vector <ll> sword;

void solve(void){
    int N; ll H;
    cin >> N >> H;
    sword.resize(N);
    ll attack = -1LL;
    rep(N, i) {
        ll A;
        scanf("%lld %lld\n", &A, &sword[i]);
        attack = max(A, attack);
    }
    sort(all(sword));
    ll cnt = 0LL;
    repr(N, i) {
        if (attack >= sword[i]) break;
        cnt++;
        H -= sword[i];
        if (H <= 0) {
            cout << cnt << endl;
            return;
        }
    }
    cnt += (H-1LL)/attack + 1LL;
    cout << cnt << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define double long double
int a[100001];
int main() {
	int n;
	cin>>n;
	double a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	double dp[n][n+1];
	dp[0][0]=1-a[0];
	for(int i=0;i<n;i++)
	{
		for(int h=0;h<n+1;h++)
		{
			if(h==0){
				if(i>0)
					dp[i][h]=dp[i-1][h]*(1.0-a[i]);
			}
			else if(h==1 && i==0)
				dp[i][h]=a[i];
			else
				if(h-1>i)dp[i][h]=0;
				else
					dp[i][h]=dp[i-1][h-1]*a[i]+dp[i-1][h]*(1.0-a[i]);
		}
	}
	double ans=0;
	int x=n/2;
	for(int i=x+1;i<=n;i++)
		ans=ans+dp[n-1][i];
	cout<<setprecision(10)<<fixed;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 140928
int main(){
int W,H,x,y,r;
scanf("%d %d %d %d %d\n",&W,&H,&x,&y,&r);
if (x>=r && y>=r && W-x>=r && H-y>=r) {printf("Yes\n");}
else {printf("No\n");}
return 0;
}

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

template<class T> void print(vector<T> &vec) {
    for(int i = 0; i < (int)vec.size(); ++i) {
        if(i) cout << " ";
        cout << vec[i];
    }
    cout << "\n";
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    vector<vector<int>> visited(N, vector<int>(N));
    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
    }
    function<void(int, int)> dfs = [&](int cur, int s) {
        visited[s][cur] = 1;
        for(auto &to : G[cur]) {
            if(!visited[s][to]) dfs(to, s);
        }
    };
    rep(i, 0, N) dfs(i, i);
    vector<vector<int>> ans(N);
    rep(i, 0, N) rep(j, 0, N) {
        if(visited[i][j] && visited[j][i]) ans[i].push_back(j + 1);
    }
    rep(i, 0, N) print(ans[i]);
    return 0;
}



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

long long const MOD = 1000000007;

long long powmod(long long x, long long n) {
    long long ret = 1;
    while(n > 0) {
        if(n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

int N;
vector<vector<int>> G;
long long res = 0;

int dfs(int v, int p) {
    int xe = 1;
    for(int to : G[v]) {
        if(to == p) continue;
        xe += dfs(to, v);
    }
    if(p != -1) res = (res + (powmod(2LL, xe) - 1) * (powmod(2LL, N - xe) - 1) % MOD) % MOD;
    return xe;
}

int main() {
    cin >> N;
    G.assign(N, vector<int>());
    for(int i=1; i<N; ++i) {
        int a, b; cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(0, -1);
    res = (res - 1 + powmod(2LL, N) - N * powmod(2LL, N - 1)) % MOD;
    res = (res + MOD) % MOD;
    res = res * powmod(powmod(2LL, N), MOD - 2) % MOD;
    cout << res << endl;
}

Measured memory_bytes: 17920
#include<iostream>
#include<cmath>
using namespace std;
int vis[10];
int a[10];
int n;
int cnt=0;
int b[10];
int c[10];
int x,y;
void dfs(int cur){
	if(cur==n){
		cnt++;
	//	cout<<cnt<<endl;
	int B=1,C=1;
		for(int i=0;i<cur;i++){
			if(a[i]!=b[i])
				B=0;
			if(a[i]!=c[i])
				C=0;
		}
	if(B)
		x=cnt;
	if(C)
		y=cnt;
	//	cout<<endl;
		return;
	}
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			vis[i]=1;
			a[cur]=i;
			dfs(cur+1);
			vis[i]=0;
		}
	}
	return ;
}
int main(){
	
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<n;i++)
		cin>>c[i];
	dfs(0);
	cout<<abs(x-y)<<endl;
	return 0;
}

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

#define ll long long

#define pii pair < int, int >
#define pll pair < ll, ll >

#define vi vector < int >
#define vs vector < string >

#define pb push_back

using namespace std;

const int N = 2e5 + 5;
const int maxn = 1e6 + 5;

bool chk[maxn], vis[maxn];
int cnt[maxn];

int main()
{
    int n;

    cin >> n;

    vi a;

    for(int i = 0; i < n; i++){
        int x;

        cin >> x;

        a.pb(x);
        cnt[x]++;
    }

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

    int mx = a.back();
    int b[mx + 5];

    memset(b, 0, sizeof(b));

    for(int i = 0; i < n; i++){
        if(b[a[i]] > 1) continue;

        for(int j = a[i]; j <= mx; j += a[i]) b[j]++;
    }

    int ans = 0;

    for(int i = 0; i < n; i++){
        if(b[a[i]] == 1) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11796
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(ll i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1e9+7;

const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

//********************************template END****************************************//

void solve(void){

	int N, K;
	cin >> N >> K;
	vecll xs(N);
	rep(N, i) {cin >> xs[i];}

	ll ans = INF;
	rep(N-K+1, i)
	{
		if (xs[i] * xs[i+K-1] >= 0)
		{
			ans = min(ans, max(abs(xs[i]), abs(xs[i+K-1])));
		}
		else
		{
			ans = min(ans, min(abs(xs[i]), abs(xs[i+K-1])) + abs(xs[i]) + abs(xs[i+K-1]));
		}
	}


	cout << ans << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 1024
s = str(input())
MOD = 2019
m = 0
digit = 1
mods = [1] + [0] * 2018
for a in s[::-1]:
    m = (m + digit * int(a)) % MOD
    mods[m] += 1
    digit = digit * 10 % MOD
ans = 0
for x in mods:
    ans += x * (x - 1) // 2
print(ans)

Measured memory_bytes: 9356
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,pk,res=0;
     cin>>t;
     pk=t/500;
     res=pk*1000;
     t=t-pk*500;
     res+=(5*(t/5));
     cout<<res<<endl;

}




Measured memory_bytes: 256
object Main {
  def Print(x:Int,y:Boolean){
    var char=y
    for(i<-1 to x){
      if(char){
        print("#")
        char=false
      }
      else{
        print(".")
        char=true
      }
    }
    println()
  }
  def main(args:Array[String]){
    val sc=new java.util.Scanner(System.in)
    var tmp=false  
      while(true){
       val h,w=sc.nextInt
       var check=true
       if(tmp) println()
       if(h==0&&w==0) return
       for(i<-1 to h){
         Print(w,check)
         if(check) check=false
         else check=true
       }
       tmp=true
     }
  }
}

Measured memory_bytes: 50436
#include<iostream>
#include<algorithm>
using namespace std;
int main(int argc, char const *argv[]){
int N;
cin >> N;
int A[N];
for (int i = 0; i < N; ++i) cin >> A[i];
sort(A, A+N);
int alice=0;
int bob=0;
for(int j=0;j<N;++j){
    if(j%2==0)alice+=A[N-1-j];
    if(j%2==1)bob+=A[N-1-j];   
}
cout << alice-bob <<endl; 
}

Measured memory_bytes: 256
import java.lang.Math

fun main(args: Array<String>)
{
    val mod = 1000000007L

    val (n, k) = readInts()
    val a = readIntArr()

    var t0 = 0L
    var t = 0L
    for (i in 0 until n) {
        for (j in 0 until n) {
            t0 += if (i < j && a[i] > a[j]) 1L else 0L
            t += if (a[i] > a[j]) 1L else 0L
        }
    }
    t0 %= mod
    t %= mod

    val kl = k.toLong()
    // val ans = (kl * t0 + (kl * kl - kl) * t / 2L) % mod
    val ans = ((kl * t0) % mod + (((kl * kl - kl) / 2L) % mod)* t) % mod
    println(ans)

}

fun readInts(): List<Int> = readLine()!!.split(" ").map(String::toInt)
fun readLongs(): List<Long> = readLine()!!.split(" ").map(String::toLong)

fun readIntArr(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray()
fun readLongArr(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray()

fun readIntArrS(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArray()
fun readLongArrS(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArray()

fun readIntArrSD(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArrayDescending()
fun readLongArrSD(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArrayDescending()

fun readString() = readLine()!!


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

int main()
{int n,k;
cin>>n>>k;
long long arr[n+10],cntr=0;
for(int i=0;i<n;i++)
{
    cin>>arr[i];
}
sort(arr,arr+n,greater<long long>());
for(int i=k;i<n;i++)
{if(k>=n)
{cout<<0;
break;}
else
    cntr+=arr[i];
}
cout<<cntr;

    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n;
	cin >> n;
	vector<P> ba(n);
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b;
		ba[i] = P(b,a);
	}

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

	ll now = 0;
	for(int i = 0;i < n;i++){
		if(now + ba[i].second <= ba[i].first){
			now += ba[i].second;
		}
		else{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}


Measured memory_bytes: 1792
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


    EXPLAINATION BELOW->
    Game+dp 2
    some what like LCS
    And obviously Greedy approach of always choosing largest fails
    Check out testcase 
    6
    4 2 9 3 1 5
    it leads to 5 +2 +3 - 4 + 9 + 1;
    whereas actually 5 + 1 + 9 - 4 + 2 +3 
   
*/
//
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
int n;
int A[3005];
ll dp_XY[3005][3005];
void solve()
{
    int i,j,interval;cin>>n;
    fo(i,0,n)cin>>A[i],dp_XY[i][i]=A[i];
    
    for(interval=1;interval<=n-1;interval++)
    {
        i=0;j=interval;
        while(j<n)
        {
          dp_XY[i][j]=max(A[i]-dp_XY[i+1][j],A[j]-dp_XY[i][j-1]);
          i++;j++;
        }
    }
    cout<<dp_XY[0][n-1]<<"\n";
   
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 70016
def fact(n)
  return 1 if n <= 1
  (1..n).inject{|r, n| r * n % (10**9+7)}
end

def _p(n, r)
  fact(n)/fact(n-r)
end

def c(n, r)
  _p(n, r)/fact(r)
end

def f(n, m)
  return 0 if (n - m).abs > 1

  dog = _p(n, n)
  ape = _p(m, m)
  if n == m
    (dog * ape) * 2
  else
    dog * ape
  end
end

N, M = gets.split.take(2).map(&:to_i)
p f(N, M) % (10**9+7)


Measured memory_bytes: 1788
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string A, B, C, ans; cin >> A >> B >> C;
    char nx;
    int Ai, Bi, Ci, As, Bs, Cs;
    Ai = Bi = Ci = 0;
    As = A.size() - 1;
    Bs = B.size() - 1;
    Cs = C.size() - 1;
    nx = A[Ai];
    Ai++;
    while(true)
    {
        if (nx == 'a')
        {
            if (Ai > As)
            {
                ans = "A";
                break;
            }
            nx = A[Ai];
            Ai++;
        }
        else if (nx == 'b')
        {
            if (Bi > Bs)
            {
                ans = "B";
                break;
            }
            nx = B[Bi];
            Bi++;
        }
        else
        {
            if (Ci > Cs)
            {
                ans = "C";
                break;
            }
            nx = C[Ci];
            Ci++;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by hwzheng on 2016/12/13.
 */
public class Main {
    public static void main(String[] a) {
        Scanner scanner = new Scanner(System.in);
        int[] heights = new int[10];
        for (int i = 0; i < 10; i++){
            heights[i] = scanner.nextInt();
        }
        Arrays.sort(heights);
        for (int i = 0;i <3; i++){
            System.out.println(heights[9-i]);
        }
    }
}

Measured memory_bytes: 26292
n,m,q = gets.split.map(&:to_i)

a = []
b = []
c = []
d = []

q.times{
	x,y,z,w = gets.split.map(&:to_i)
	a.push(x-1)
	b.push(y-1)
	c.push(z)
	d.push(w)
}

ans = 0

(1..m).to_a.repeated_combination(n).to_a.each{|v|
	x=0
	(0...q).each{ |i|
		if v[b[i]] - v[a[i]] == c[i]
			x+=d[i]
		end
	}
	ans = x if x>ans
}

puts ans

Measured memory_bytes: 32604
private fun readInt(): Int {
    return readLine()!!.toInt()
}

private fun readTextArray(): List<String> {
    return readLine()!!.split(" ")
}

fun main(args: Array<String>) {
    val N = readInt()
    val S = readTextArray()

    for(s in S) {
        if(s == "Y") {
            print("Four")
            return
        }
    }

    print("Three")
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,m;
    cin>>n>>m;
    unordered_set<ll> r;
    r.insert(1);
    vl c(n,1);
    rep(i,m){
        ll x,y;
        cin>>x>>y;
        c[y-1]++;
        c[x-1]--;
        if(r.count(x)){
            r.insert(y);
            if(!c[x-1])r.erase(x);
        }
    }
    cout<<Size(r)<<endl;
}

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 <= i; i--)
#define FOR(i, from, to)                                                       \
  for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to)                                               \
  for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

#define MOD (ll)1000000007

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll left = 4 * a * b;
  ll right = (c - (a + b)) * (c - (a + b));
  if (left < right && a + b < c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    ll a[n], ans = 0;
    map<ll, ll>mp;
    for(int i = 0;i < n;++i)
    {
        cin >> a[i];
        ++mp[i - a[i]];
    }
    for(int i = 0;i < n;++i)
    {
        --mp[i - a[i]];
        if(mp.find(i + a[i]) != mp.end())
            ans += mp[i + a[i]];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 16768
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

template<class T,int N=100000>
class Stack {
private:
    int ary[N];
    int top;
public:
    Stack() : top(0){}
    void push(T x) {
        ary[++top]=x;
    }
    T pop() {
        return ary[top--];
    }
    bool is_empty() {
        return top==0;
    }
    bool is_full() {
        return top >= N;
    }
    void dump() {
        rep(i,top+1) if(i) cout<<(i==1?"":" ")<<ary[i];
        cout<<endl;
    }
};

int main() {
    string s;
    Stack<int> st;
    while(cin>>s) {
        if(s=="+") {
            int a = st.pop();
            int b = st.pop();
            st.push(a+b);
        }
        else if(s=="-") {
            int a = st.pop();
            int b = st.pop();
            st.push(b-a);
        }
        else if(s=="*") {
            int a = st.pop();
            int b = st.pop();
            st.push(a*b);
        }
        else {
            st.push(atoi(s.c_str()));
        }
    }
    cout<<st.pop()<<endl;

    return 0;
}

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

string RenR[50],LinR[50];
bool memo[50][50][50][50];
string ans;
int h,w;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

class S{
public:
    int rx,ry,lx,ly;
    S(int lx,int ly,int rx,int ry):lx(lx),ly(ly),rx(rx),ry(ry){}
}; 

int main()
{
  int ri,rj,li,lj;
  while(1){
    cin>>w>>h;
    if(w+h==0)break;

    for(int i=0;i<50;i++){
      for(int j=0;j<50;j++){
	for(int k=0;k<50;k++){
	  for(int l=0;l<50;l++)memo[i][j][k][l]=false;
	}
      }
    }

    for(int i=0;i<h;i++){
      cin>>LinR[i];
      for(int j=0;j<w;j++){
	if(LinR[i][j]=='L'){
	  li=i;lj=j;
	  break;
	}
      }
      cin>>RenR[i];
      for(int j=0;j<w;j++){
	if(RenR[i][j]=='R'){
	  ri=i;rj=j;
	  break;
	}
      }
    }
    queue<S> Q;
    Q.push(S(lj,li,rj,ri));
    ans="No";
    while(!Q.empty()){
      S s=Q.front();Q.pop();
      if(RenR[s.ry][s.rx]=='%' && LinR[s.ly][s.lx]=='%'){
        ans="Yes";
	break;
      }
      if(RenR[s.ry][s.rx]=='%' || LinR[s.ly][s.lx]=='%')continue;
      if(memo[s.lx][s.ly][s.rx][s.ry])continue;
      memo[s.lx][s.ly][s.rx][s.ry]=true;

      for(int k=0;k<4;k++){
	int rx=s.rx+dx[k],ry=s.ry-dy[k];
        if(rx<0 || ry<0 || rx>=w || ry>=h){
	  rx=s.rx;
	  ry=s.ry;
	}
        if(RenR[ry][rx]=='#'){
	  rx=s.rx;
	  ry=s.ry;
	}
	int lx=s.lx+dx[(k+2)%4],ly=s.ly+dy[(k+2)%4];
        if(lx<0 || ly<0 || lx>=w || ly>=h){
	  lx=s.lx;
	  ly=s.ly;
	}
	if(LinR[ly][lx]=='#'){
	  lx=s.lx;
	  ly=s.ly;
	}
	Q.push(S(lx,ly,rx,ry));
      }
    }
    cout<<ans<<endl;	
  }
  return 0;
}

Measured memory_bytes: 10896
#include <stdio.h>

int main()
{
    int a;
    int b;
    int c;

    scanf("%d %d %d", &a, &b, &c);

    if (a < b && b < c)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1796