akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

int main(void){
    // Your code here!
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    Sort(a);
    ll ans = 0;
    vector<ll> s(n+1);
    s[0] = 0;
    rep(i,n) s[i+1] = s[i] + a[i];
    rep(i,n-1){
        ll cnt = s[n] - s[i+1];
        cnt %= MOD;
        ans += a[i] % MOD * cnt;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6416
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint 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)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18, MAX_N = 200000;
typedef pair<plint, lint> pa;

lint N, arr[100000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		cin >> arr[i];
	}
	lint L = 2, R = 2;
	if (arr[N - 1] != 2) {
		cout << -1 << endl;
		return 0;
	}
	IREP(i, N) {
		if (R / arr[i] == L / arr[i] && L%arr[i] != 0) {
			cout << -1 << endl;
			return 0;
		}
		else {
			L = ((L-1) / arr[i] + 1) * arr[i];
			R = (R / arr[i]) * arr[i] + arr[i] - 1;
		}
	}

	cout << L << " " << R << endl;
}


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

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < w + 2; i++)
		cout << "#";
	cout << endl;
	for (int i = 0; i < h; i++)
	{
		string a;
		cin >> a;
		cout << "#" << a << "#" << endl;
	}
	for (int i = 0; i < w + 2; i++)
		cout << "#";
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint 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)
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }

long double N, M, D;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> M >> D;
	if(D == 0) {
		cout << setprecision(20) << (M - 1) / N << endl;
	}
	else
	{
		cout << setprecision(20) << 2 * (N - D)*(M-1) / N / N << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
int cnt[26];
main(){
    string s;
    cin >> s;
    for(char c:s){
        cnt[c-'a']++;
    }
    for(int i = 0;i < 26;i++){
        if(cnt[i] == 0){
            printf("%c\n",i+'a');
            return 0;
        }

    }
    cout << "None" << endl;
}

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

#define int long long

using namespace std;

const int maxn = 200005;
map<int,int> dp[maxn];
int a[maxn];
int n;

int recur(int pos, int took) {
    if (dp[pos].count(took) != 0) return dp[pos][took];
    if (took == n/2) return 0;
    if (pos >= n) return -1e18;
    int rem = ceil((double)(n-pos)/2);
    if (took+rem < n/2) return -1e18;
    int res = max(recur(pos+1, took), recur(pos+2, took+1)+a[pos]);
    dp[pos][took] = res;
    return res;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    int res = recur(0,0);
    cout << res << '\n';
}
/*

 */

Measured memory_bytes: 44344
K = int(input())
A = list(map(int,input().split()))
I = [[-1,-1] for _ in range(K+1)]
I[K] = [2,2]
fg = True
for i in range(K-1,-1,-1):
    #consider range I[i]
    left = A[i]*((I[i+1][0]+A[i]-1)//A[i]) 
    I[i][0] = max(A[i],left)
    I[i][1] = A[i]*(I[i+1][1]//A[i] + 1) -1
    #print(i,*I[i])
    if(I[i][0] > I[i][1]):
        fg = False
        break
if(not fg):
    print(-1)
else:
    print(*I[0])

Measured memory_bytes: 27876
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAXs
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

int main(){
  int h,w; cin >> h >> w;
  vector<vector<char>> a(h,vector<char>(w));
  bool ans = true;
  rep(i,h) rep(j,w) cin >> a.at(i).at(j);

  int max;
  for(int i = w-1;i>=0;i--){
    if(a.at(0).at(i)=='#'){
      max = i;
      break;
    }
  }
  for(int i=1;i<h;i++){
    int min;
    rep(j,w){
      if(a.at(i).at(j)=='#'){
        min = j;
        break;
      }
    }

    if(min<max){
      ans = false;
      break;
    }

    for(int j=w-1;j>=0;j--){
      if(a.at(i).at(j)=='#'){
        max = j;
        break;
      }
    }
  }

  if(ans) puts("Possible");
  else puts("Impossible");
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  int N; cin >> N;
  string S; cin >> S;
  string &a = S;
  int R=0,G=0,B=0;
  for(int m=0;m<N;m++){
    if(a[m]=='R') R++;
    if(a[m]=='G') G++;
    if(a[m]=='B') B++;
  }
  ll ans = 0;
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N;j++){
      if(a[i]!='B'&&a[j]!='B'&&a[i]!=a[j]){
          ans+=B;
          if((i+j)%2==0&&a[(i+j)/2]=='B')ans--;
          if(2*j-i<N&&a[2*j-i]=='B')ans--;
          if(2*i-j>=0&&a[2*i-j]=='B')ans--;
      }
      if(a[i]!='G'&&a[j]!='G'&&a[i]!=a[j]){
          ans+=G;
          if((i+j)%2==0&&a[(i+j)/2]=='G')ans--;
          if(2*j-i<N&&a[2*j-i]=='G')ans--;
          if(2*i-j>=0&&a[2*i-j]=='G')ans--;
      }
      if(a[i]!='R'&&a[j]!='R'&&a[i]!=a[j]){
          ans+=R;
          if((i+j)%2==0&&a[(i+j)/2]=='R')ans--;
          if(2*j-i<N&&a[2*j-i]=='R')ans--;
          if(2*i-j>=0&&a[2*i-j]=='R')ans--;
      }
      }
    }
  cout << ans/3 <<endl;
  return 0;
}

Measured memory_bytes: 3644
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n;
    ll ans=0;
    Ff(i,1,n+1)
    {
        if(i%3!=0 && i%5!=0)
        {
            ans+=i;
        }
    }
    cout<<ans;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10696
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int A[20010];
int a[4] = {1, 1, 2, 2};

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    if (N == 3) {
        cout << "2 5 63" << endl;
        return 0;
    }
    if (N == 4) {
        cout << "2 5 20 63" << endl;
        return 0;
    }
    int sum = 2;
    A[0] = 2;
    rep(i, N - 1) {
        A[i + 1] = A[i] + a[i % 4];
        sum = (sum + A[i + 1]) % 6;
    }
    A[N - 1] += (6 - sum) % 6;
    if (A[N - 1] % 6 == 1 || A[N - 1] % 6 == 5) {
        A[N - 1]--;
        A[N - 2]++;
    }
    rep(i, N) {
        if (i != 0) cout << " ";
        cout << A[i];
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if((a < b)&&(b < c)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26384
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
ll MOD=1000000007;

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

  vector<bitset<21>> a(N,0);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      int t;
      cin >> t;
      if(t==1) a[i].set(j);
    }
  } 

  vector<ll> r(1<<N);

  r[0]=1;

  for(int i=1;i<=N;i++){
    for(int j=1;j<(1<<N);j++){
      if(__builtin_popcount(j)!=i) continue;
      for(int k=0;k<N;k++){
        if(a[i-1].test(k) && ((j>>k)&1)){
          r[j]+=r[j^(1<<k)];
          r[j]%=MOD;
        }
      }
      //cout << r[i][j] << " ";
    }
    //cout << endl;
  }

  cout << (r[(1<<N)-1]+MOD)%MOD << endl;
  return 0;
}


Measured memory_bytes: 16768
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 数値
		int l = sc.nextInt();

		double ll = l;

		double a = 0.0;
		double b = 0.0;
		double c = 0.0;

		//				if (l % 3 == 2) {
		//					a = l / 3.0;
		//					b = l / 3.0 + 2.0 / 3;
		//					c = l / 3 + 1;
		//				}
		//				if (l % 3 == 1) {
		//					a = l / 3;
		//					b = l / 3;
		//					c = l / 3 + 1;
		//				}
		//				if (l % 3 == 0) {
		//					a = b = c = l / 3;
		//				}

		out(BigDecimal.valueOf(ll * ll * ll / 27.0).toPlainString());

	}

	/*
	 * 以下メソッド集
	 */

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

}


Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
	double xa1,xa2,ya1,ya2,xb1,xb2,yb1,yb2;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&xa1,&ya1,&xa2,&ya2,&xb1,&yb1,&xb2,&yb2)!=EOF){
		if(xa1>xb2||ya1>yb2||xb1>xa2||yb1>ya2){
			printf("NO\n");
		}else{
			printf("YES\n");
		}
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll n;
	string s;
	cin>>n>>s;

	ll ans=0;

	rep(i,10)rep(j,10)rep(k,10){
		int flag=0;
		rep(l,n){
			if(flag==0&&s[l]-'0'==i)flag=1;
			else if(flag==1&&s[l]-'0'==j)flag=2;
			else if(flag==2&&s[l]-'0'==k){
				// cout<<i<<j<<k<<endl;
				ans++;
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i<=b;i++)
#define fore(i,a) for(auto &i:a)


using namespace std;
typedef long long ll;

typedef pair<int, int> pint;

//右端が早い方を優先するコンパレーター
bool cmp(pint a, pint b) { return a.second < b.second; }


int main() {

	int N, M;
	cin >> N >> M;
	
	//区間を左右のペアで管理する
	vector<pint> A(M);

	for (int i = 0; i < M; ++i)cin >> A[i].first >> A[i].second;
	
	//右端の早い順でソート
	sort(A.begin(), A.end(), cmp);

	int res = 0;
	int endtime = 0;

	for (int i = 0; i < M; i++) {

		//貫く時刻を決めて、それより遅い左端がでてきたら
		//右端を更新して、カウンタを増やす。
		if (A[i].first >= endtime) {
			endtime = A[i].second;
			++res;
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-18 10:58:05
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    int ans;
    for (ans = 1; 2*ans <= n; ans *= 2) {}

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int a, b, x;
  cin >> a >> b >> x;
  if (x <= (a * a * b + 0.0) / 2) {
    double h = (x + 0.0) / (b * a);
    h *= 2;
    double m = atan(h / b);
    m /= 3.14159265358979;
    m *= 180;
    m = 90 - m;
    cout << fixed << setprecision(16);
    cout << m << endl;
  }
  else {
    double h = ((b * a * a - x) * 2 + 0.0) / (a * a);
    double m = atan(a / h);
    m /= 3.14159265358979;
    m *= 180;
    m = 90 - m;
    cout << fixed << setprecision(16);
    cout << m << endl;
  } 
}

Measured memory_bytes: 4072
#include<bits/stdc++.h>
using namespace std;
#define long long long
#define A(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
void _read();
const long inf = 3e15 + 11;

int main () { _read(); 

      int n;
      cin >> n;
      vector<int> v(n+1);
      vector<long> p(n+1);
      vector<vector<long>> dp(n+1,vector<long>(n+1,inf));
      for( int i = 1; i <= n; ++i) {
            cin >> v[i];
            p[i] = p[i-1] + v[i];
            dp[i][i] = 0;
      }
      for( int len = 2; len <= n; ++len) {
            for( int i = 1, j = i + len - 1; j <= n; ++j, ++i) {
                  long x = p[j] - p[i-1];
                  for( int k = i; k < j; ++k) {
                        dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]+x);
                  }
            }
      }
      cout << dp[1][n] << '\n';
      return 0;
};

void _read() {
      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
}


Measured memory_bytes: 4456
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        rep(i, n){
            int d, inp[105];
            cin >> d;
            rep(i, d){
                cin >> inp[i];
            }
            int high = 0, low = 2 << 24;
            rep(i, d - 1){
                if(inp[i] - inp[i + 1] > 0)
                    high = max(high, inp[i] - inp[i + 1]);
                else
                    low = min(low, inp[i] - inp[i + 1]);
            }
            if(low == 2 << 24) low = 0;
            cout << -1*low << ' ' << high << endl;
        }
    }
}

Measured memory_bytes: 1160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String[] s = in.nextStringArray(n);

            for (int i = 0; i < n; i++) {
                if (s[i].charAt(0) == 'Y') {
                    out.println("Four");
                    return;
                }
            }

            out.println("Three");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public String[] nextStringArray(int n) {
            String[] res = new String[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextString();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

int main()
{
    int total[27];
    for (int i = 0; i <= 26; i++) total[i] = 1000000;

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;

        int tmp[27] = {};
        for (int i = 0; i < (int)s.size(); i++) tmp[s[i] - 'a']++;
        for (int i = 0; i <= 26; i++) total[i] = min(total[i], tmp[i]);
    }

    for (int i = 0; i <= 26; i++) {
        for (int j = 1; j <= total[i]; j++) {
            printf("%c", i + 'a');
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		int cnt = 1;
		while(N>=K){
			N = N/K;
			cnt++;
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 21972
import sys
from heapq import heappush, heappop


I = sys.stdin.readlines()
N, Q = map(int, I[0].split())
P = []
for i in range(1, N + 1):
    s, t, x = map(int, I[i].split())
    P.append((s - x, t - 1 - x, x))
P.sort()


q = []
cur = 0
ans = [-1] * Q
for i in range(N + 1, N + Q + 1):
    d = int(I[i])
    while cur < N and P[cur][0] <= d:
        s, t, x = P[cur]
        heappush(q, (x, t))
        cur += 1
    while q and q[0][1] < d:
        heappop(q)
    if q:
        ans[i - N - 1] = q[0][0]

print(*ans, sep='\n')


Measured memory_bytes: 135644
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;
int main() {
	int a, p;
	cin >> a >> p;
	p += a * 3;
	cout << p / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>

typedef long long ll;

using namespace std;

int main(){
    int n, z = 0;
    string s;
    map<string, int> ans;
    cin >> n >> s;

    for (int i = 0; i <= 9; i++){
        for (int j = 0; j <= 9; j++){
            for (int k = 0; k <= 9; k++){
                int pos1 = s.find_first_of(to_string(i));
                if(pos1 == string::npos) continue;
                string s2 = s.substr(pos1 + 1, s.size() - pos1);
                int pos2 = s2.find_first_of(to_string(j));
                if(pos2 == string::npos) continue;
                string s3 = s2.substr(pos2 + 1, s2.size() - pos2);
                int pos3 = s3.find_first_of(to_string(k));
                if(pos3 == string::npos) continue;

                string pass = to_string(i) + to_string(j) + to_string(k);
                z++;
            }
        }
    }

    cout << z << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int n,m;
vector < pair < int , int > > E[100005];
int mark[100005];
int V;
 
int dfs( int u ,int c){
	if ( mark[u] != -1 ) return 0;
  	mark[u] = c;
  V++;
  	int white = 0;
  	for ( pair < int , int > e : E[u] ){
    	int v = e.first, z = e.second;
      	if ( z & 1 ) white += dfs(v,c);
    }
  	for ( pair < int , int > e : E[u] ){
    	int v = e.first, z = e.second;
      if ( z % 2 == 0 ) {
      	white += dfs(v,c^1) + (mark[v] == -1 );
      }
    }
  return white;
}
 
int main(){
  memset(mark,-1,sizeof(mark));
  scanf("%d%d",&n,&m);
  for ( int i = 0; i < m; i++ ){
  	int x,y,z;
    scanf("%d%d%d",&x,&y,&z);
    E[x].push_back(make_pair(y,z));
    E[y].push_back(make_pair(x,z));
  }
  
  int ans = 0;
  for ( int i = 1; i <= n; i++ ){
  	if ( mark[i] == -1 ){
    	V = 0;
      	int white = dfs(i,0) + 1;
     	ans += white;
    }
  }
  
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first               // For pairs
#define ss second              // For pairs
#define sz(a) int((a).size())  // Function to determine size of any container
#define pb push_back           // Pushback to vector
#define mp make_pair           // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)  //traversing macro
#define lp(it, it1, it2) for (auto it = it1; it < it2; it++)                              //loop
#define present(c, x) (c.find(x) != c.end())
using namespace std;
using namespace std::chrono;
typedef vector<ll> vi;            // Vector of long long
typedef vector<vi> vvi;           // Vector of vi
typedef vector<pair<ll, ll>> ii;  // Vector of pairs
typedef vector<ii> vii;           // Vector of ii
int main() {
    // auto start = high_resolution_clock: :now();
    ll n, k;
    cin >> n >> k;
    vi h(n), dp(n);
    lp(i, 0, n) {
        cin >> h[i];
    }
    dp[1] = abs(h[1] - h[0]);
    lp(i, 2, n) {
        ll temp = 1e9;
        lp(j, 1, min(k + 1, (ll)(i + 1))) {
            temp = min(dp[i - j] + abs(h[i] - h[i - j]), temp);
        }
        dp[i] = temp;
    }
    cout << dp[n - 1] << "\n";
    // auto stop = high_resolution_clock: :now();
    // auto duration = duration_cast<microseconds>(stop - start);
    // cerr << duration.count() / 1000000;
    return 0;
}


Measured memory_bytes: 1792
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, k = input_a
a = input_a

a.sort!

sum = 0
k.times do |i|
  sum += a[i]
end
puts sum


Measured memory_bytes: 14304
# coding: utf-8
N=int(input())
A=list(map(int,input().split()))
L=[0]*(N+1)
L[0]=0
for i in range(N):#累積和
    L[i+1]=L[i]+A[i]
#print(L)

L.sort()
cnt=1
ans=0
#print(L)

for i in range(1,N+1):
    #print(cnt,ans)
    if L[i]==L[i-1]:
        cnt+=1
    else:
        if cnt>1:
            ans+=cnt*(cnt-1)//2
            cnt=1
if cnt>1:
    ans+=cnt*(cnt-1)//2
print(ans)

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef map<int,int> mapii;
typedef map<int,bool> mapib;
typedef map<char,int> mapci;

#define small 1e-9
#define big5 1000000005
#define big7 1000000007
#define big 1000000
#define pi 3.1415926

#define inp(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define cum(arr,n,cumm) cumm[0]=0;for(int i=0;i<n;i++)cumm[i+1]=cumm[i]+arr[i];
#define bsdk ios_base::sync_with_stdio(false);cin.tie(NULL);
#define disp(arr) for(auto i:arr)cout<<i<<" ";cout<<"\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define m1 cout<<"-1\n"
#define nl <<endl
#define hs cout<<"#"

#define fori(a, b, c) for (a = (b); (a) <= (c); ++(a))
#define ford(a, b, c) for (a = (b); (a) >= (c); --(a))
#define rep(i,n) fori(i,0,n-1)
#define rep1(i,n) fori(i,1,n)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define ub upper_bound
#define lb lower_bound
#define allv(v) v.begin(), v.end()
#define sorti(v) sort(allv(v))
bool isprime[big+1];
vector<int> primes;
void makesieve()
{
    ll i,j;
    rep(i,1000001)
        isprime[i]=false;
    isprime[2]=true;
    for(i=3;i<=big;i+=2)
        isprime[i]=true;
    for(i=3;i<=big;i+=2)
    {
        if(isprime[i])
            for(j=i*i;j<=big;j+=i)
            isprime[j]=false;
    }
    rep(i,big+1)
    {
        if(isprime[i])
            primes.pb(i);
    }
}
ll poww(ll n,ll m){
    if(m==0)return 1;
    if(m==1)return n;
    ll ans = poww(n,m/2);
    if(m%2==1) return (ans*ans)*n;
    else return (ans*ans);
}
int dp[100001];
int reach(int n,int arr[])
{
    if(n==1)
        return 0;
    if(n==2)
        return abs(arr[0]-arr[1]);
    if(dp[n]!=-1)
        return dp[n];
    int ans;
    int a=reach(n-1,arr)+abs(arr[n-1]-arr[n-2]);
    int b=reach(n-2,arr)+abs(arr[n-1]-arr[n-3]);
    ans=min(a,b);
    dp[n]=ans;
    return ans;
}
void solve()
{
    int n,i;
    cin>>n;
    int arr[n];
    inp(arr,n);
    fill(dp,dp+100002,-1);
    cout<<reach(n,arr);
}
int main()
{
    bsdk
    int t;
    //cin>>t;
    t=1;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define root sqrtl
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;
    ll mod=hell;
 ll pr( ll x , ll y)
{
    ll ans=1;
    if(y==0) return ans;
    while(y>1)
    {
        if(y&1) ans*=x;
        x*=x;
        y/=2;
        x%=mod;
        ans%=mod;
    }
    ans*=x;
    ans%=mod;
    return ans;
}
ll fact( ll n)
{
    ll ans=1,i;
    rep(i,1,n+1)
    {
        ans*=i;
        ans%=mod;
    }
    return ans;
}
ll in(ll x) { return  pr(x,mod-2);}
 
bool prime[1000500];
vector < ll > v;
void pre()
{
    int n=1000000,i,j,p;
    memset(prime,true,sizeof(prime));
    prime[0]=prime[1]=false;
    for(i=2;i*i<=n;i++)
    {
        if(prime[i])
        {
            for(p=2*i;p<=n;p+=i) prime[p]=false;
        }
    }
  rep(i,0,1000000) if(prime[i]) v.pb(i);
 
}
 
ll inv(ll n)
{
    return pr(n,mod-2);
}
 
 
 
void solve( )
{
 ll i,j=1,k,n,m=0,f,s1=0,x=1e13,c=1,y=0,a=0,b=0,d,p;
 string s;
 cin>>s; char ch='7';
 if(s[0]==ch or s[1]==ch or s[2]==ch) cout<<"Yes";
 else cout<<"No";
 
 
}
    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
        solve();
    }

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n, k;
    cin >> n >> k;
    long long a = n % k;
    long long b = k - a;
    long long answer = min(a, b);
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
class UnionFind:

  def __init__(self, n):
    self.n = n

    # parentsの値を木の高さ判定につかっている
    # rankやsizeをつかって木の高さ判定をすることは一般的に多いが、もっとスマートな形
    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]: # parentsの値を木の高さ判定につかっている
      x, y = y, x

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

  def size(self, x):
    return -self.parents[self.find(x)]

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

    print(1 if x == y else 0)

  
n, q = map(int, input().split())
uf = UnionFind(n)

for i in range(q):
  com, x, y = map(int, input().split())

  if com == 0:
    uf.union(x, y)
  else:
    uf.same(x, y)


Measured memory_bytes: 5728
h,w = map(int,input().split())
ch,cw = map(int,input().split())
ch -= 1
cw -= 1
dh,dw = map(int,input().split())
dh -= 1
dw -= 1
s = [input() for _ in range(h)]

def newv(y,x):
  return y*w+x

e = [[] for _ in range(h*w)]
for y in range(h):
  for x in range(w):
    if s[y][x] == '#':
      continue
    for dy in range(-2,3):
      for dx in range(-2,3):
        if not(0 <= y+dy < h) or not(0 <= x+dx < w):
          continue
        if dy == 0 and dx == 0:
          continue
        if abs(dy)+abs(dx) == 1:
          if s[y+dy][x+dx] == '.':
            e[newv(y,x)].append((newv(y+dy,x+dx),0))
        else:
          if s[y+dy][x+dx] == '.':
            e[newv(y,x)].append((newv(y+dy,x+dx),1))

from heapq import heappop, heappush
INF = float('inf')
def dijkstra(s,n,g): # sからの最短距離 頂点数n g[v]=[(u1,w1),(u2,w2)....]:vからuへの有向辺があり、重みw
  que = []
  d = [INF for _ in range(n)]
  d[s] = 0
  heappush(que,(0,s))
  while len(que) > 0:
    p = heappop(que)
    v = p[1]
    if d[v] < p[0]:
      continue
    for u,w in g[v]:
      if d[u] > d[v]+w:
        d[u] = d[v]+w
        heappush(que,(d[u],u))
  return d

ans = dijkstra(newv(ch,cw),h*w,e)[newv(dh,dw)]
print(ans if ans != INF else -1)


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

ll calc(ll n){
    return n*(n+1)/2;
}

int main() {
    ll ans = 0;
    ll n;
    cin >> n;
    for (ll i = 1; i <= n; i++)ans += i*calc(n/i);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int N;
ll A[310][310], dp[310][310], ans;
bool dontuse[310][310];

void warshall_floyd() {
	repi(i, 0, N) {
		repi(j, 0, N) {
			repi(k, 0, N) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
				if (dp[i][j] == dp[i][k] + dp[k][j] && i!=k && k!=j && j!=i) dontuse[i][j] = true;
			}
		}
	}
}

int main() {
	rd(N);
	repi(i, 0, N) {
		repi(j, 0, N) {
			ll temp;
			rd(temp);
			A[i][j] = dp[i][j] = temp;
		}
	}

	warshall_floyd();

	repi(i, 0, N) {
		repi(j, 0, N) {
			if (A[i][j] != dp[i][j]) {
				wrln(-1);
				return 0;
			}
			if (!dontuse[i][j]) ans += dp[i][j];
		}
	}

	wrln(ans / 2);

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
  
  long int a[100][100]={0},b[100][100]={0},c[100][100]={0},n,m,l,i,j,k;
  cin >> n >> m >> l;
  for(i=0;i<n;i++)for(j=0;j<m;j++)cin >> a[i][j];
  for(j=0;j<m;j++)for(k=0;k<l;k++)cin >> b[j][k];
  for(i=0;i<n;i++)for(j=0;j<m;j++)for(k=0;k<l;k++){
    c[i][k]+=a[i][j]*b[j][k];
  }
  for(i=0;i<n;i++){
    for(k=0;k<l;k++){
      if(k!=l-1)cout << c[i][k] << " ";
      else cout << c[i][k] << endl;}
  }

}

Measured memory_bytes: 1404
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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; }

int inf=1E9;

int main(){
    int N;
    cin>> N;
    vector<int> a(N), b(N);

    rep(i,N){
        cin >> a[i] >> b[i];
    }

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

    if(N%2==1){
        cout << b[(N-1)/2] - a[(N-1)/2] +1 << endl;
    }
    else{
        cout << ((b[N/2]+b[N/2-1]) - (a[N/2]+a[N/2-1])) + 1 << endl;
    }
        
    return 0;
}


Measured memory_bytes: 4764
#include <iostream>
using namespace std;
int main(void){
   int m,f,r;

   while(1){
       cin >> m >> f >> r;

       if(m == -1 && f == -1 && r == -1){
           break;
       }
       else if(m == -1 || f == -1){
           cout << "F";
       }
       else if(m + f >= 80){
           cout << "A";
       }
       else if(m + f >= 65 && m + f < 80){
           cout << "B";
       }
       else if(m + f >= 50 && m + f < 65){
           cout << "C";
       }
       else if(m + f >= 30 && m + f < 50 && r >= 50){
           cout << "C";
       }
       else if(m + f >= 30 && m + f <= 50){
           cout << "D";
       }
       else{
           cout << "F";
       }
       cout << endl;
   }
}


Measured memory_bytes: 3080
from fractions import gcd
from math import floor, sqrt

a, b = [int(x) for x in input().split()]
c = gcd(a, b)

d_list = [1]
d = 2
stop = floor(sqrt(c))
while True:
    temp, mod = divmod(c, d)
    if mod == 0:
        d_list.append(d)
        c = temp
        stop = floor(sqrt(c))
    else:
        d += 1
    
    if stop < d:
        d_list.append(c)
        break

ans = len(set(d_list))
print(ans)

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

int main(){
  int X,Y,A,B,C;cin >> X >> Y >> A >> B >> C;
  vector<ll> P(A);
  vector<ll> Q(B);
  vector<ll> R(C);
  for(int i=0;i<A;i++){
    cin >> P[i];
  }
  for(int i=0;i<B;i++){
    cin >> Q[i];
  }
  for(int i=0;i<C;i++){
    cin >> R[i];
  }
  sort(P.begin(),P.end());
  reverse(P.begin(),P.end());
  sort(Q.begin(),Q.end());
  reverse(Q.begin(),Q.end());
  for(int i=0;i<X;i++){
    R.push_back(P[i]);
  }
  for(int i=0;i<Y;i++){
    R.push_back(Q[i]);
  }
  sort(R.begin(),R.end());
  reverse(R.begin(),R.end());
  ll sum = 0;
  for(int i=0;i<X+Y;i++){
    sum += R[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 7796
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int d,n;
int main()
{
	cin>>d>>n;
	if (d==0)
	{
		if (n==100)
		   cout<<101<<endl;
		else
		   cout<<n<<endl;
	}
	else if (d==1)
	{
		if (n==100)
		   cout<<101*100<<endl;
		else
		   cout<<n*100<<endl;
	}
	else if (d==2)
	{
		if (n==100)
		   cout<<101*10000<<endl;
		else
		   cout<<n*10000<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
  int N; cin >> N;
  vector<Pi> ba(N),cd(N);
  rep(i,N){
    cin >> ba[i].second >> ba[i].first;
  }
  rep(i,N){
    cin >> cd[i].first >> cd[i].second;
  }
  sort(ba.begin(),ba.end(),greater<Pi>());
  sort(cd.begin(),cd.end());

  int ans = 0;
  vector<int> used(N,-1);
  rep(i,N){
    rep(j,N){
      if(used[j] == -1){
        if(ba[j].second < cd[i].first && ba[j].first < cd[i].second){
          ans++;
          used[j] = 1;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL x,y,z;
  cin >> x >> y >> z;
  cout << x+y+z - max(x,max(y,z)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define Max 2000000
 
int heap,A[Max+1];
void MaxHeap(int x){
  int left,right,maxx;
  left=2*x;
  right=2*x+1;
  if(left<=heap&&A[left]>A[x])maxx=left;
  else maxx=x;
  if(right<=heap&&A[right]>A[maxx])maxx=right;
 
  if(maxx !=x){
    swap(&A[x],&A[maxx]);
    MaxHeap(maxx);
  }
}
 
void swap(int *a,int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}

int main(){
  int i;
  scanf("%d",&heap);
  for( i=1;i<=heap;i++)
    scanf("%d",&A[i]);
  for( i=heap/2;i>=1;i--)MaxHeap(i);
  for( i=1;i<=heap;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
 
  return 0;
}

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

using namespace std;

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

    int a[10][10];//a[i][j]は首位がiで末位がjの数の個数
    memset(a, 0, sizeof(a));
    for (int i = 1; i <= n; ++i) {
        int t = i;
        while (t >= 10) t /= 10;
        a[t][i % 10]++;
    }

    int ans = 0;
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            ans += a[i][j] * a[j][i];
        }
    }

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



Measured memory_bytes: 256
from copy import copy
from time import time
import random
t0 = time()
import math
import sys
input = sys.stdin.readline
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
now = time()
lim = 1.85
T = 300
cnt = 0
while now-t0<lim:
    cnt += 1
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    na[x-1] = na[y-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    now = time()
    if cnt%100 == 0:
        T = 300+(-298)*(now-t0)/lim
    p = pow(math.e,-abs(ns-score)/T)
    if ns > score or random.random() < p:
        ans = na
        score = ns
for a in ans:
    print(a)

Measured memory_bytes: 87928
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;
int dp[5000];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max( max(a*c, a*d), max(b*c, b*d) ) << endl;


return 0;
}
///....


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

string S,T,U;
int A,B;

int main()
{
    cin>>S>>T>>A>>B>>U;
    if (S==U) cout<<A-1<<' '<<B<<endl;
    if (T==U) cout<<A<<' '<<B-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

//ll mod = 1000000007;
ll mod = 998244353;

signed main()
{
    string s,t;
    cin>>s>>t;
    vector<int> ss(26);
    vector<int> tt(26);
    rep(i,s.size()){
        ss[s[i] - 'a']++;
        tt[t[i] - 'a']++;
    }
    sort(all(ss));
    sort(all(tt));
    rep(i,ss.size()){
        if(ss[i]!=tt[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3872
MOD = 10 ** 9 + 7
def factorial(x)
  f = 1
  (1..x).each do |i|
    f = f * i % MOD
  end
  return f
end

n, m = gets.split.map(&:to_i)
if n == m
  puts factorial(n) ** 2 * 2 % MOD
elsif (n - m).abs >= 2
  puts 0
else
  n, m = m, n if n < m
  puts factorial(m) ** 2 * n % MOD
end


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

int main() {
  string s;
  long long k;
  cin >> s >> k;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
    if (k - 1 <= i) {
      cout << 1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if(a*b > c*d){
			System.out.println(a*b);
		} else{
			System.out.println(c*d);
		}
	}
}

Measured memory_bytes: 21716
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-24 18:55:13
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

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

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int a, b, c; cin >> a >> b >> c;

  // a < c < b
  // a > c > b

  if ((a < c && c < b) || (a > c && c > b)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256