akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int a, b;
int main() {
	cin >> a >> b;
	int c = abs(a), d = abs(b);
	if (c == d) {
		if (a == b)cout << "0" << endl;
		else cout << "1" << endl;
	}
	if (c > d) {
		if (a > 0 && b > 0)cout << c - d + 2 << endl;
		if (a < 0 && b < 0)cout << c - d << endl;
		if (a > 0 && b < 0)cout << c - d + 1 << endl;
		if (a < 0 && b > 0)cout << c - d + 1 << endl;
		if (a > 0 && b == 0)cout << c - d + 1 << endl;
		if (a < 0 && b == 0)cout << c - d << endl;
	}
	if (c < d) {
		if (a > 0 && b > 0)cout << d - c << endl;
		if (a < 0 && b < 0)cout << d - c + 2 << endl;
		if (a > 0 && b < 0)cout << d - c + 1 << endl;
		if (a < 0 && b > 0)cout << d - c + 1 << endl;
		if (a == 0 && b > 0)cout << d - c << endl;
		if (a == 0 && b < 0)cout << d - c + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll v[100002];
int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);
	ll n,m,a,b;
	map<int,int> ma;
	cin>>n>>m;
	int i=1;
	while (n--){
		cin>>v[i];
		ma[i]=0;
		i++;
	}
	while (m--){
		cin>>a>>b;
		if (v[a]>v[b]) 
		{
			ma[b]++;
		}
		if (v[a]<v[b]) {
			ma[a]++;
		}
		if (v[a]==v[b]) {
			ma[a]++;ma[b]++;
		}
	}
	int c=0;
	for (i=1;i<=ma.size();i++){
		if (ma[i]==0) c++;
	}
	cout<<c;
	return 0;
}


Measured memory_bytes: 9140
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#include<list>
#include<set>
#include<bitset>
#include<stack>
#include<cctype>
#define sc(x) scanf("%d",&x);
#define pr(x) cout<<#x<<": "<<x<<" ";
#define prln(x) cout<<#x<<": "<<x<<endl;
#define bug() cout<<"bug: "<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const double eps = 1e-4;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5+7;
const int maxm = 1e6+7;
const double pi = acos(-1.0);

struct Edge{
	int to,next;
	ll w;
}edge[maxn];
int tot,head[maxn];
void addedge(int u,int v,ll w){
	edge[tot].to=v; edge[tot].next=head[u]; edge[tot].w=w; head[u]=tot++;
}
ll dis[maxn];
void dfs(int u,ll d,int pre){
	dis[u]=d;
	for(int i=head[u]; i!=-1; i=edge[i].next){
		int v=edge[i].to;
		if(v==pre)
			continue;
		dfs(v,d+edge[i].w,u);
	}
}
void init(){
	tot=0;
	memset(dis,0,sizeof dis);
	memset(head,-1,sizeof head);
}
int main(){
	init();
	int n; scanf("%d",&n);
	for(int i=1; i<n; i++){
		int u,v; ll w; scanf("%d%d%lld",&u,&v,&w);
		addedge(u,v,w); addedge(v,u,w);
	}
	int q,s; scanf("%d%d",&q,&s);
	dfs(s,0,0);
	while(q--){
		int x,y; scanf("%d%d",&x,&y);
		printf("%lld\n",dis[x]+dis[y]);
	}
	return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	//sort(a.begin(),a.end());
	int n,d;
	cin >> n>>d;
	vector<vector<int>> a(n, vector<int>(d));
	rep(i, n) {
		rep(j, d) cin >> a[i][j];
	}
	int ans = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			int b=0;
			rep(k, d) {
				int c = abs(a[i][k] - a[j][k]);
				b += c * c;
			}
			bool ab = false;
			for (int k = 0; k <= b; k++) {
				if (k * k == b) ab = true;
			}
			if (ab) ans++;
		}
	}
	cout << ans;
	return 0; 
}









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

    int main()
    {
        int k,c=0;
        cin>>k;
        for(int i=1;i<=k;i++)
        {
            for(int j=1;j<=k;j++)
            {
                for(int a=1;a<=k;a++)
                {
                    c+=__gcd(i,__gcd(j,a));
                }
            }
        }
        cout<<c;

          return 0;
    }


Measured memory_bytes: 3676
#include <iostream>
#include <string>
using namespace std;
int main(void) {
	string str;
	cin >> str;
		
		for (int i = 0; i < 4; i++) {
			std::cout << str[i];
		}

		std::cout << ' ';
		for (int i=4; i < 12; i++) {
			std::cout <<  str[i] ;
		}
		std::cout << std::endl;
	return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    vpii cnt;
    cnt.emplace_back(0, 0);
    bool less = true;
    rep(i, sz(s)) {
        if (less && s[i]=='>') {
            less = false;
        }
        else if (!less && s[i]=='<') {
            less = true;
            cnt.emplace_back(0, 0);
        }
        if (s[i] == '<') cnt.back().first++;
        else cnt.back().second++;
    }
    ll ans = 0;
    rep(i, sz(cnt)) {
        if (cnt[i].first >= cnt[i].second) cnt[i].second--;
        else cnt[i].first--;
        int n1 = cnt[i].first, n2 = cnt[i].second;
        ans += (ll)n1 * (n1+1) / 2 + (ll)n2 * (n2+1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5240
#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()
{
    ll a, b, k;
    cin >> a >> b >> k;
    ll r = min(a, k);
    a -= r;
    k -= r;
    r = min(b, k);
    b -= r;
    k -= r;
    printf("%lld %lld\n", a, b);
    return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,a,b;cin>>n>>a>>b&&n|a|b;){
		if(a+b>n+1||a<(n+b-1)/b||b<(n+a-1)/a){
			cout<<-1<<endl;
			continue;
		}
		if(b==1){
			rep(i,n) cout<<i+1<<"\n "[i+1<n];
			continue;
		}
		if(a==1){
			per(i,n) cout<<i+1<<"\n "[i>0];
			continue;
		}

		vi xs(n); iota(all(xs),0);

		// (n-a)個を(b-1)個に分割する
		vi cs={a};
		rep(i,b-1) cs.push_back((n-a+i)/(b-1));

		vi res;
		for(int c:cs){
			res.insert(end(res),end(xs)-c,end(xs));
			rep(_,c) xs.pop_back();
		}
		rep(i,n) cout<<res[i]+1<<"\n "[i+1<n];
	}
}


Measured memory_bytes: 5360
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
// #define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

int f(string s,int t){
    int c=0;
    rep(i,s.size()){
        if(s[i]-'0'-t)c++;
        t^=1;
    }
    return c;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

    string s;
    cin>>s;
    cout<<min(f(s,0),f(s,1))<<endl;
}


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

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        Map<Long, Integer> map = new HashMap<Long, Integer>();
        for (int i = 2 ; i <= 1000000 ; i++) {
            while (n % (long) i ==  0) {
                if (map.containsKey((long)i)) {
                    map.put((long) i, map.get((long)i) + 1);
                } else {
                    map.put((long) i, 1);
                }
                n /= (long) i;
            }

        }
        if (n != 1) {
            map.put(n, 1);
        }

        int count = 0;
        for (java.util.Map.Entry<Long, Integer> entry : map.entrySet()) {
            int val = entry.getValue();
            int c = 1;
            while (val - c >= 0) {
                val -= c;
                count++;
                c++;
            }
        }

        System.out.println(count);
     }

}

Measured memory_bytes: 37644
n=int(input())
s=''
if n==0:
  print('0')
  exit()
while(n!=0):
  m=abs(n)
  if m%2==1:
    n-=1
    n=n//(-2)
    s='1'+s
  else:
    n=n//(-2)
    s='0'+s
print(s)
    

Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element


int A, B;

signed main()
{
	cin >> A >> B;


	for (int i = 0; i < 20000; i++)
	{
		if((int)(i * 0.08) == A && (int)(i * 0.10) == B)
		{
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		for(int i=1;i<=9;i++){
			for(int j=1;j<=9;j++){
				System.out.println(i+"x"+j+"="+(i*j));
			}
		}
	}
}

Measured memory_bytes: 25996
// ------------------------------------
// Date:2018/ 3/ 1
// Problem:ABC 058 ι⊥l a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  bool ok;
  if (b - a == c - b) {
    ok = true;
  } else {
    ok = false;
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}



Measured memory_bytes: 256
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long long int lli;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
  ll n, m;
  cin >> n >> m; 
  loop(i, m){
    ll tmp;
    cin >> tmp;
    n = n-tmp;
  }

  if(n < 0){
    cout << -1 << endl;
  }else{
    cout << n << endl;
  }
}     



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

int main(){
  int N;
  string s;
  cin>>N;
  bool x=0;
  for(int i=0;i<N;i++){
    cin>>s;
    if(s=="Y"){
      x=1;break;
    }
  }
  if(x)cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}

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

int main(){
    int a, b, c;
    scanf("%d%d%d%d", &a, &b, &c);
    if(a+b < c){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, arr[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n);
    map<int, int>m;
    for(int i = 0; i < n; i++)
        m[arr[i]]++;
    int ans = 0;
    for(int i = n - 1; i >= 0; i--)
    {
        int pw = 1;
        while(pw <= arr[i])pw <<= 1;
        int need = pw - arr[i];
        if(need == arr[i])
        {
            if(m[need] >= 2)
            {
                m[need] -= 2;
                ++ans;
            }
        }
        else
        {
            if(m.count(need) && m[need] > 0 && m[arr[i]] > 0)
            {
                m[arr[i]]--;
                m[need]--;
                ++ans;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long llong;
using namespace std;

int main(){
	char c;
	cin>>c;
	
	if(c=='A') cout<<'T'<<endl;
	else if(c=='T') cout<<'A'<<endl;
	else if(c=='C') cout<<'G'<<endl;
	else cout<<'C'<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long int
#define pp pair<int,int>
#define endl "\n"
#define PI 3.14159265
int MAXN = 5000001;
const int mod=1000000007;
const int INF =INT_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}
void initialize(int arr[],int sz[],int n)
{
    for(int i=1;i<=n;i++)
    {
        arr[i]=i;
        sz[i]=1;
    }
}
int root(int i,int arr[])
{
    while(arr[i]!=i)
    {
        arr[i]=arr[arr[i]];
        i=arr[i];
    }
    return i;
}
void union1(int arr[],int sz[],int n,int a,int b)
{
    int roota=root( a,arr);
    int rootb=root( b,arr);
    if(roota==rootb)
    {
        //ans.push_back({a,b});
        return;
    }
    if(sz[roota]>sz[rootb])
    {
        arr[rootb]=roota;
        sz[roota]+=sz[rootb];
        sz[rootb]=-1;
    }
    else
    {
        arr[roota]=rootb;
        sz[rootb]+=sz[roota];
        sz[roota]=-1;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    {
      int n,m;
      cin>>n>>m;
      int arr[n+1];
      int sz[n+1];
      initialize(arr,sz,n);
      for(int i=0;i<m;i++)
      {
          int x,y;
          cin>>x>>y;
          int rootx=root( x,arr);
         int rooty=root( y,arr);
         if(rootx==rooty)continue;
          union1(arr,sz,n,x,y);
      }
      int mx=0;
      for(int i=1;i<=n;i++)
     {
         if(i==arr[i])
           {
               mx=max(mx,sz[i]);
           }
     }
      cout<<mx<<endl;
    }
    return 0;
}


Measured memory_bytes: 6744
S=input()
T=input()

import collections
Sc = collections.Counter(S).most_common()
Tc = collections.Counter(T).most_common()
if len(Sc) != len(Tc):
    print('No')
    exit()
for s,t in zip(Sc,Tc):
    if s[1] != t[1]:
        print('No')
        exit()
di=dict()
for i,c in enumerate(S):
    if not c in di:
        di[c] = T[i]
        continue
    if di[c] != T[i]:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 41884
N = int(input())
An = list(map(int, input().split()))
tt = sum(An)
total = tt
ans = 0
for A in An:
    At = A * (total-A)
#     if v == 1:
#         At = A * (tt-A)
#     else:
#         At = A * (tt-A*v)*v
#     print(A, total, At, ans)
#     md = At % (10**9+7)
    ans = (ans+At) % (10**9+7)
    total -= A
#     print(ans)
print(ans)









Measured memory_bytes: 31608
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

template <typename T>
T gcd(T a, T b) {
	if (a < b) swap(a, b);
		while (b != 0) {
			T tmp = b;
			b = a % b;
			a = tmp;
		}
	return a;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll A, B, C, D; cin >> A >> B >> C >> D;
    ll a = max(A, C)-min(A, C);
    ll b = max(B, D)-min(B, D);
    ll g = gcd<ll>(a, b);
    ll a_ = a/g; ll b_ = b/g;
    ll m = a_+b_-1;
    cout << m*g << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    whole(sort, s);

    string t; cin >> t;
    whole(sort, t, greater<int>());

    cout << (s < t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>

using namespace std;

typedef pair<int,bool> Pair;

int main(){

  string S,temp;
  string MSG = "Good";
  
  cin >> S;

  temp[0] = S[0];
  
  for(int i = 1; i < S.length(); ++i){
  
	if(S[i] == temp[i-1]) MSG = "Bad";
	temp[i] = S[i];

  }
    cout << MSG << endl;

  return 0;

}

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

int main(){

  int n;

  while(cin>>n, n){
    int cnt=0;
    string s[100];
    
    for(int i=0;i<n;i++) cin>>s[i];
    for(int i=1;i<n;i+=2) if(s[i-1][1]==s[i][1]) cnt++;

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

Measured memory_bytes: 3112
import java.util.*
 
fun main(args: Array<String>) {
  var a = readLine()!!.toInt()-1
  var num = readLine()!!.split(" ").map{ it -> it.toFloat() }.toMutableList()
  var counter = 0
  
  num.sort()
  var dp = num[0]

  for (i in 1..a) {
    dp = (dp + num[i]) /2
  }
  println(dp)
}

Measured memory_bytes: 37740
pamox, camo = gets.split.map(&:to_i)
cities = camo.times.map{gets.split.map(&:to_i)}

prefs = Hash.new

index = 0
cities.each do |city|
  prefs[city[0]] = [] if prefs[city[0]] == nil
  prefs[city[0]].push([index, city[1]])
  index += 1
end

res = []

prefs.values.each do |pref|
  pref.sort_by!{|value| value[1]}
end

prefs.each do |prefW|
  count = 1
  prefW[1].each do |city|
    res.push([city[0], prefW[0], count])
    count += 1
  end
end

res.sort_by!{|v| v[0]}

final = []
res.each do |resval|
  final.push(format("%06d", resval[1]) + format("%06d", resval[2]))
end

puts final

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

  string s;
  cin >> s;
  string s1 = s.substr(0, n / 2);
  string s2 = s.substr(n / 2);
  if (s1 == s2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  string s = stin();
  int ans = 0;
  REPS(i,1,n) {
    set<char> first_set;
    REP(first, i) {
      first_set.insert(s[first]);
    }
    set<char> second_set;
    REPS(second, i, n) {
      second_set.insert(s[second]);
    }
    int counter = 0;
    for(auto& itr : first_set) {
      if(second_set.find(itr)!=second_set.end()) ++counter;
    }
    ans = max(ans, counter);
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=105;
//i_am_noob
int n,m,dp[maxn][maxn];
char a[maxn][maxn];

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> m;
	rep(n) rep1(j,m) cin >> a[i][j];
	rep(n) rep1(j,m){
		if(i==0&&j==0) dp[i][j]=(a[i][j]=='#');
		else if(i==0) dp[i][j]=dp[i][j-1]+(a[i][j]=='#'&&a[i][j-1]=='.');
		else if(j==0) dp[i][j]=dp[i-1][j]+(a[i][j]=='#'&&a[i-1][j]=='.');
		else dp[i][j]=min(dp[i-1][j]+(a[i][j]=='#'&&a[i-1][j]=='.'),dp[i][j-1]+(a[i][j]=='#'&&a[i][j-1]=='.'));
	}
	rep(n) rep1(j,m) debug(dp[i][j]);
	print1(dp[n-1][m-1]);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, h, nowh;

int main(){
	cin >> n;
	
	nowh = 0;
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		cin >> h;
		if(h > nowh){ans += h-nowh;}
		nowh = h;
	}
	
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string a;
int l,r;
int x,y;
int main(){
    cin>>a;
    for(int i=0;i<a.size();i++){
        if(a[i]=='C'){
            l=i;
            x=1;
        }
        else if(a[i]=='F'){
            r=i;
            y=1;
        }
    }
    if(l<r&&x==1&&y==1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>
#include <cassert>

using namespace std;

const int MOD = 1000000007;

int main()
{
  int64_t N, K;
  cin >> N >> K;

  int64_t ans = 0;
  
  for (int64_t k=K; k<=N+1; ++k) {
    int64_t tempA = ((N-k+1+N)*(k)/2);
    int64_t tempB = (k*(k-1)/2);
    int64_t temp = 1 + tempA - tempB;

    ans += temp;
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <queue>
using namespace std;
 
#define int long long
#define INF 1001001001
 
int32_t main() {
	
	double L;
	
	cin >> L;
	
	
	double ans = L/3;
	
	ans= ans* ans*ans;
	
	cout << fixed << setprecision(12) << ans << endl;
	
	 
    
    
 	
 	
}

Measured memory_bytes: 3224
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = RD;
	auto B = RD;
	long ans;
	foreach (i; 1..N+1)
	{
		auto str = i.to!string;
		long cnt;
		foreach (c; str)
		{
			cnt += [c].to!long;
		}
		if (cnt >= A && cnt <= B)
		{
			ans += i;
			debug writeln(i);
		}
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 1020
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <functional>
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
// constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  vector<int> a(26,0);
  for(int i=0; i<S.size(); i++){
    a[S[i]-'a']++;
  }
  for(int i=0; i<26; i++){
    if(a[i] == 0){
      cout << char('a'+i) << "\n";
      return 0;
    }
  }
  cout << "None\n";
  return 0;
}

Measured memory_bytes: 3792
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int K = sc.nextInt();
            int X = sc.nextInt();
            int L = X - K + 1;
            for(;L < X + K;L++){
              System.out.print(L + " ");
            }
          }
}

Measured memory_bytes: 22996
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
#define Vmaxn 100010
#define Emaxn 500010
using namespace std;

struct Node
{
    int x,y,val,pre;
};
int g_[Vmaxn];
Node g[Emaxn];

int n,Dmax=0;
int h[Vmaxn],w[Vmaxn],s[Vmaxn],e[Vmaxn];

void dfs(int s,int u){
    h[u]=1;w[u]=s;
    int j=g_[u];
    while(j!=-1)
    {
        int v=g[j].y;
        if(h[v]==0){
            dfs(s+g[j].val,v);
        }
        j=g[j].pre;
    }
}

int main()
{
    int i;

    cin>>n;
    memset(g_,-1,sizeof g_);
    for(i=0;i<2*(n-1);i++)
    {
        cin>>g[i].x>>g[i].y>>g[i].val;
        g[i].pre=g_[g[i].x];
        g_[g[i].x]=i;

        g[i+1].x=g[i].y;g[i+1].y=g[i].x;g[i+1].val=g[i].val;
        g[i+1].pre=g_[g[i+1].x];
        g_[g[i+1].x]=i+1;
        i++;
    }


    memset(h,0,sizeof h);
    memset(w,0,sizeof w);
    dfs(0,0);
    int start=0;
    for(i=0;i<n;i++)
        if(w[i]>Dmax){
            Dmax=w[i];
            start=i;
    }

    Dmax=0;
    int end=0;
    memset(h,0,sizeof h);
    memset(w,0,sizeof w);
    dfs(0,start);
    for(i=0;i<n;i++)
        if(w[i]>Dmax){
            Dmax=w[i];
            end=i;
    }
    for(i=0;i<n;i++)
        s[i]=w[i];


    Dmax=0;
    memset(h,0,sizeof h);
    memset(w,0,sizeof w);
    dfs(0,end);
    for(i=0;i<n;i++)
        e[i]=w[i];

    for(i=0;i<n;i++)
        cout<<max(s[i],e[i])<<endl;
    return 0;
}



Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

const int maxgram = 400;

int main() {
    int N, ma, mb; cin >> N >> ma >> mb;
    vector<int> A(N), B(N), C(N);
    REP(i, 0, N) cin >> A[i] >> B[i] >> C[i];

    vector<vector<int>> dp(maxgram + 1, vector<int>(maxgram + 1, 1 << 30));
    dp[0][0] = 0;
    REP(i, 0, N) {
        for (int j = maxgram; j >= 0; j--) {
            if (j + A[i] > maxgram) continue;
            for (int k = maxgram; k >= 0; k--) {
                if (k + B[i] > maxgram) continue;
                dp[j + A[i]][k + B[i]] = min(dp[j + A[i]][k + B[i]], dp[j][k] + C[i]);
            }
        }
    }

    int ans = 1 << 30;
    REP(i, 1, maxgram + 1) {
        REP(j, 1, maxgram + 1) {
            if (i * mb != j * ma) continue;
            ans = min(ans, dp[i][j]);
        }
    }
    if (ans < (1 << 30)) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 896
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int to[100001], ne[100001], he[100001];
int co[100001];
int saidai;
void dfs(int u, int prev, int c) {
	int k = 1;
	for (int i = he[u]; i; i = ne[i]) {
		if (to[i] != prev) {
			if (k == c) k++;
			co[i] = k;
			chmax(saidai, k);
			dfs(to[i], u, k++);
		}
	}
}

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


	int N = getint();
	int tmp = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		to[tmp] = b;
		ne[tmp] = he[a];
		he[a] = tmp++;
	}

	dfs(1, 0, 0);

	putint(saidai);
	rep1(i, N) putint(co[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

int main()
{
    string S, T;
    cin >> S >> T;
    bool flg = true;
    rep(i, 0, S.size()) {
        if (S[i] != T[i]) {
            flg = false;
        }
    }
    if (flg) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	string S;
	cin >> N >> S;
	
	int nest = 0;
	
	REP(i, S.size()) {
		if (S[i] == ')') {
			nest = max(nest - 1, 0);
		}
		else {
			++nest;
		}
	}
	S += string(nest, ')');
	
	nest = 0;
	for (int i = S.size() - 1; i >= 0; --i) {
		if (S[i] == ')') {
			++nest;
		}
		else {
			nest = max(nest - 1, 0);
		}
	}
	S = string(nest, '(') + S;
	
	cout << S << endl;
	return 0;
}


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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
ll a,b,n;
ll solve(ll x){
    double xb = x/(double)b;

    double A = floor(a * xb);
    double B = floor(xb);

    B = a*B;
    //DEBUG2(A,B);
    return A-B;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>a>>b>>n;

    if(n >= b){
        cout << solve(b-1) << endl;
        return 0;
    }else{
        double xb = n/(double)b;
        double A = floor(a * xb);
        cout << A << endl;
        return 0;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
string s1 = "-"; string s2 = "_";
int dp[3005][3005];
string ans = "";
int calc(int idx1, int idx2){
    if(idx1 <= 0 || idx2 <= 0){
        return dp[idx1][idx2] = 0;
    }
    if(idx1 == 1 && idx2 == 1){
        if(s1[idx1] == s2[idx2]){
            return dp[idx1][idx2] = 1;
        }
        else return dp[idx1][idx2] = 0;
    }
    if(dp[idx1][idx2] != -1){
        return dp[idx1][idx2];
    }
    if(s1[idx1] == s2[idx2]){
        return dp[idx1][idx2] = calc(idx1 - 1, idx2 - 1) + 1;
    }
    return dp[idx1][idx2] = max(calc(idx1 - 1, idx2), calc(idx1, idx2 - 1));

}
int main(){
    FAST
    int t = 1;
    while(t--){
        string a, b;
        cin >> a >> b;
        s1 += a; s2 += b;
        int n = s1.size() - 1;
        int m = s2.size() - 1;
        memset(dp, -1, sizeof(dp));
        int num = calc(n, m);
        string s = "";
        while(n > 0 && m > 0){
            if(s1[n] == s2[m]){
                s += s1[n];
                n--; m--;
            }
            else if(dp[n - 1][m] > dp[n][m - 1]){
                n--;
            }
            else{
                m--;
            }
        }
        reverse(s.begin(), s.end());
        cout << s;
    }
    return 0;
}


Measured memory_bytes: 39160
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    string s;
    cin>>s;
    int n=s.size();
    vector<int> sss(4);
    for(int i=0;i<n;i++){
        if(s[i]=='S'){
            sss[0]++;
        }
        if(s[i]=='N'){
            sss[1]++;
        }
        if(s[i]=='W'){
            sss[2]++;
        }
        if(s[i]=='E'){
            sss[3]++;
        }
    
    }
    if(sss[0]!=0&&sss[1]!=0&&sss[2]!=0&&sss[3]!=0){
        cout<<"Yes"<<endl;
    }
    else if(sss[0]!=0&&sss[1]!=0&&sss[2]==0&&sss[3]==0){
        cout<<"Yes"<<endl;
    }
    else if(sss[0]==0&&sss[1]==0&&sss[2]!=0&&sss[3]!=0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


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

int main() {
  
  int N; cin >> N; int ans = 0;
  
  for (int i = 0; i < N; i++) {
    
    int a; cin >> a;
    
    int count = 0;
    
    while (true) {
      
      if (a % 2 == 0) {
        a /= 2;
        count++;
      }
      
      else break;
      
    }
    
    ans += count;
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int K=0;
    int S=0;
    int ans =0;

    cin >> K;
    cin >> S;

    for(int x=0; x<=K; x++){
        for(int y=0; y<=K; y++){

            if( S-(x+y) <= K && S-(x+y) >= 0){
//                cout << x << " " << y << " " << S-(x+y) << endl;
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*input
8
6
3
1
2
7
4
8
5
*/
#include <bits/stdc++.h>
using namespace std;
int a[200005],n,dp[200005],pos[200005]={};
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;cin>>a[i++]);
	for(int i=n;i>0;--i)
		dp[a[i]] = dp[a[i]+1]+1;
	cout<<n-*max_element(dp+1,dp+1+n);
}

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

string t;

bool is(string s)
{
	for (int i = 0; i < SZ(s) / 2; i++)
	{
		if (s[i] != s[SZ(s) - 1 - i])
			return 0;
	}
	return 1;
}

int main()
{
	cin >> t;
	if (is(t) && is(t.substr(0, SZ(t) / 2)) && is(t.substr(SZ(t) / 2 + 1)))
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256