akhauriyash/Code-Regression huggingface dataset:
//    ######     ######    ######     ######
//    ######    ######     ######    ######
//    ######   ######      ######   ######
//    ######  ######       ######  ######
//    ############         ############
//    ############         ############
//    ######  ######       ######  ######
//    ######   ######      ######   ######
//    ######    ######     ######    ###### 
//    ######     ######    ######     ######
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second
#define mii           map<int,int>
#define msi           map<string,int >
#define mis           map<int,string>
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define f(i,n)            for(int  i=0;i<n;i++)
#define all(v)        v.begin(),v.end()
//#define sort(v)       sort(all(v))
#define sm(v)           accumulate(v.begin(),v.end(),0)
#define pii           pair<int ,int >
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAX           1000000
#define pi            3.1415926536
using namespace std;

signed main()
{
            ios_base::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            #ifndef ONLINE_JUDGE
            //freopen("input.txt","r",stdin);
           // freopen("output.txt","w",stdout);
            #endif
            int t=1;
           // cin>>t;
            while(t--)
            {
                int a,b,c=0,s=1;
               cin>>a>>b;
               while(s<b)
               {
                    s=s+a-1;
                    c++;
               }
               cout<<c;

}}


Measured memory_bytes: 256
n,k=map(int,input().split())
s=[list(map(int,input().split()))for i in range(n)]
p=0
for i in range(31):
    c=1
    if i!=0:
        if k|(2**i)==k:
            k-=2**i
            k=k|(2**i-1)
        else:
            c=0
    if c:
        q=0
        for j,h in s:
            if k|j==k:
                q+=h
        p=max(p,q)
print(p)

Measured memory_bytes: 29428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void caul(vector<vector<int>> &graph,int now,vector<ll> &add,vector<bool> &done){
    int size = graph[now].size();
  	done.at(now) = true;
        for(int i = 0;i < size;i++){
          	int next = graph[now][i];
            //cout << now <<" " << next << endl;
          	if(done.at(next) == true)continue;
            add[next] += add[now];
            caul(graph,next,add,done);
        }
  return;
}
int main(){
  	ll n,q;
    cin >> n >> q;
    vector<vector<int>> graph(n,vector<int>());
    for(int i = 0;i < n-1;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        graph.at(a).push_back(b);
        graph.at(b).push_back(a);
    }
  	vector<bool> done(n,false);
    vector<ll> add(n,0);
    for(int i = 0;i < q;i++){
        int p,x;
        cin >> p >> x;
        p--;
        add[p] += x;
    }
    int now = 0;
    caul(graph,0,add,done);
  	for(int i = 0;i < n;i++){
      cout << add[i] << endl;
    }
}

Measured memory_bytes: 30592
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
string s;
int main(){
	cin>>s;
	for(int i=1;i<=3;i++){
		if(s[i]==s[i-1]){
			puts("Bad");
			return 0;
		}
	}
	puts("Good");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define N 1000000
// #define N 200
int main()
{
    int n;
    vector<int> p, q;
    int k=1;
    while(1){
        int a = k*(k+1)*(k+2)/6;
        if(a>N) break;
        p.push_back(a);
        if(a&1) q.push_back(a);
        k++;
    }
    
    vector<int> dp(N+1), dq(N+1);
    rep(i, N+1){
        dp[i] = i;
        dq[i] = i;
    }
    FOR(i, 1, p.size()){
        // prvec(dp);
        FOR(j, p[i], N+1){
            chmin(dp[j],dp[j-p[i]] + 1);
        }
        // pr(dp[40]);
    }
    
    FOR(i, 1, q.size()){
        FOR(j, q[i], N+1){
            chmin(dq[j], dq[j-q[i]] + 1);
        }
    }
    // prvec(p);
    while(cin >> n){
        if(n==0) break;
        printf("%d %d\n", dp[n], dq[n]);
    }
    return 0;}


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

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

  int ans = 0;
  rep(i, N) {
    ll X, Y;
    cin >> X >> Y;
    if (X * X + Y * Y <= D * D) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define int             long long int
#define pb              push_back
#define se              second
#define mp              make_pair
#define fi              first
#define del(a,vec)      vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v)   binary_search(f,l,v)
#define iter(a,b)       vector<int>::iterator a,b
#define lower(v,num)    lower_bound (v.begin(), v.end(), num);
#define upper(v,num)    upper_bound (v.begin(), v.end(), num); 
#define removecopy(a)   unique(a.begin(), a.end()); 
#define vi              vector<int> 
#define pi              pair<int,int>    
#define vpi             vector<pi>      
#define mlbb            ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)    
int mod =1000000007;
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    int pow (int x, int n,int mod) {//calculate x^n
    if (n == 0) return 1;

    int res = pow (x, n / 2,mod);

    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;

    return res;
    }
    int _gcd(int a,int b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};
using namespace Rahul;
int32_t main()
{
        
    mlbb;
    
    int a,b;
    cin>>a>>b;
    if(a==b)cout<<"Yes\n";
    else cout<<"No\n";
    
    
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PRINT(c) cout<<(c)<<endl

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 1000000;

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

  int p, q;
  while(cin>>p>>q, p){
	VS vs(p), target(q);
	REP(i,p) cin >> vs[i];
	REP(i,q) cin >> target[i];
	int cnt[16][3];
	int cnt2[16][3];
	VI in(p, 0);
	fill((int*)cnt, (int*)cnt+16*3, 0);
	fill((int*)cnt2, (int*)cnt2+16*3, 0);
	REP(i,p){
	  string& line = vs[i];
	  if(i > 0)
		REP(j,3)
		  cnt[i][j] = cnt[i-1][j];
	  int j;
	  for(j=0;j<SZ(line);++j)
		if(line[j] != '.') break;
		else ++in[i];
	  for(;j<SZ(line);++j)
		switch(line[j]){
		case '(': ++cnt[i][0]; break;
		case ')': --cnt[i][0]; break;
		case '{': ++cnt[i][1]; break;
		case '}': --cnt[i][1]; break;
		case '[': ++cnt[i][2]; break;
		case ']': --cnt[i][2]; break;
		}
	}
	REP(i,q){
	  string& line = target[i];
	  if(i > 0)
		REP(j,3)
		  cnt2[i][j] = cnt2[i-1][j];
	  for(int j=0;j<SZ(line);++j)
		switch(line[j]){
		case '(': ++cnt2[i][0]; break;
		case ')': --cnt2[i][0]; break;
		case '{': ++cnt2[i][1]; break;
		case '}': --cnt2[i][1]; break;
		case '[': ++cnt2[i][2]; break;
		case ']': --cnt2[i][2]; break;
		}
	}

	int tmp[3];
	VI ans(q, INF);
	FOR(r,1,21){
	  tmp[0] = r;
	  FOR(c,1,21){
		tmp[1] = c;
		FOR(s,1,21){
		  tmp[2] = s;
		  bool ok = true;
		  FOR(k,1,p){
			int ind = 0;
			REP(j,3)
			  ind += tmp[j]*cnt[k-1][j];
			if(in[k] != ind){
			  ok = false;
			  break;
			}
		  }

		  if(ok){
			ans[0] = 0;
			FOR(i,1,q){
			  int ind = 0;
			  REP(j,3)
				ind += tmp[j]*cnt2[i-1][j];
			  if(ans[i] == INF || ans[i] == ind)
				ans[i] = ind;
			  else
				ans[i] = -1;
			}
		  }
		}
	  }
	}
	REP(i,q) if(ans[i] == INF) ans[i] = -1;
	cout << ans[0];
	REP(i,q-1) cout << " " << ans[i+1];
	cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pp;

ll a[100001][3];
ll dp[100001][3];int n;

ll f(int i,int e)
{
	
	
    if(i==n)
    {
        return 0;
    }
    
	if(e!=-1&&dp[i][e]!=-1)
	return dp[i][e];
    
    ll res=0;
    
    if(e!=0)
    res=max(res,a[i][0]+f(i+1,0));
    
    if(e!=1)
    res=max(res,a[i][1]+f(i+1,1));
    
    if(e!=2)
	res=max(res,a[i][2]+f(i+1,2));
    
    if(e!=-1)
    dp[i][e]=res;
    return res;
}

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


    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
        dp[i][0]=-1;
        dp[i][1]=-1;
        dp[i][2]=-1;
    }
    
    cout<<f(0,-1)<<"\n";

}


Measured memory_bytes: 11264
#include<iostream>
#include<algorithm>
#include<map>
 using namespace std;
 typedef long long ll;
 const int maxn=2e5+10;
 map<ll,ll> m;
 ll a[maxn];
 int main()
 {
 	int n;
 	ll ans=0,ret;
 	scanf("%d",&n);
 	for(int i=1;i<=n;i++){
 		scanf("%lld",&a[i]);
 		m[a[i]]++;
	 } 
	for(map<ll,ll> ::iterator it=m.begin();it!=m.end();it++){
		ll se=it->second;
		ans+=(se-1)*se/2;
	}
	for(int i=1;i<=n;i++){
		ll num=m[a[i]];
		ret=ans+(num-1)*(num-2)/2-num*(num-1)/2;
		cout<<ret<<endl;	
	}
	return 0;
 }

Measured memory_bytes: 11008
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, n)
        cin >> p[i];

    bool ok = false;
    REP(i, n){
        REP(j, n){
            vector<int> tmp(p);
            swap(tmp[i], tmp[j]);
            if(is_sorted(tmp.begin(), tmp.end()))
                ok = true;
        }
    }

    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
typedef long long int ll;
using namespace std;
std::vector<int> yaku(101, 0);

int aaa(int a){
  int num=0;
  ranges(ii, 2, 101){
    if(yaku[ii]>=a-1) num+=1;
  }
  return num;
}

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  ll temp, ans=0;
  ranges(i, 1, N+1){
    temp = i;
    ranges(j, 2, N+1){
      while(temp % j == 0){
        yaku[j]++;
        temp /= j;
      }
    }
  }
  ans = aaa(75) + aaa(25) * (aaa(3) - 1) + aaa(15) * (aaa(5) - 1) +(aaa(5) * (aaa(5)-1) * (aaa(3) - 2)/2);
  std::cout << ans << '\n';
  return 0;
}


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

int main() {
  int n,k; cin >> n >> k;
  vector<long long> a(n);
  vector<long long> score;
  for(int i = 0; i < n; i++)
    cin >> a.at(i);

  for(int i = 0; i < n - k; i++){
    //cout << a.at(i) << " " << a.at(i + k) << endl;
    if(a.at(i) < a.at(i + k))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  } 
   
}



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

int main ()
{
	char a, b;
	cin >> a >> b;
	if (a == 'H' && b== 'H') {
		cout << "H" << endl;
	} else if (a=='H' && b=='D')
		cout << 'D' << endl;
	else if (a == 'D' && b == 'D')
		cout << 'H' << endl;
	else if (a == 'D' && b == 'H')
		cout << 'D' << endl;
	else assert(false);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int H,W,K; cin >> H >> W >> K;
    vector<string> grid(H);
    rep(i,H) cin >> grid[i];

    int ans = INF;
    rep(bit,1<<(H - 1)) {
        vector<int> choco(H,0);
        choco[0] = 1;
        int cnt = 1;
        rep(i,H - 1) {
            if ((bit>>i)&1) {choco[i + 1] = 1; ++ cnt;}
        }
        vector<int> count(cnt,0);
        int ret = cnt - 1;
        bool judge = true;

        rep(i,W) {
            int now = 0;
            vector<int> recent(cnt,0);
            bool flag = true;
            rep(j,H) {
                if (j > 0 && choco[j] == 1) ++now;
                if (grid[j][i] == '1') recent[now] ++;
                if (count[now] + recent[now] > K) {
                    flag = false;
                }
            }
            if (!flag) {
                ++ret;
                rep(j,cnt) {
                    count[j] = recent[j];
                    if (count[j] > K) {
                        ret = INF;
                        judge = false;
                        break;
                    }
                }
            }
            else {
                rep(j,cnt) {
                    count[j] += recent[j];
                }
            }
            if (!judge) break;
        }
        ans = min(ans,ret);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define endl "\n"

using namespace std;

long long n, x, cost[4010], i[4010], ile, tab[4010], sum, mini[2010][2010], inf = 1000000000, ans;
int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>n>>x;
	inf *= inf;
	for( int a = 1; a <= n; a++ )cin>>tab[a];
	for( int a = 1; a <= n; a++ )tab[n+a] = tab[a];
	for( int a = 1; a <= n; a++ )for( int b = 0; b < n; b++ )mini[a][b] = inf;
	ans = inf;
	for( int a = 1; a <= n; a++ )
	{
		mini[a][0] = tab[a];
		for( int b = 1; b < n; b++ )
		{
			mini[a][b] = min( mini[a][b-1], tab[a+n-b] ); 
		}
	}
	for( int a = 0; a < n; a++ )
	{	
		sum = 0;
		for( int b = 1; b <= n; b++ )
		{
			sum += mini[b][a];
		}	
		ans = min( ans, sum + a*x );
	}
	cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,m,u,v,s,t;
  cin >> n >> m;
  vector<vector<int>> adj(n),adj3(n);
  for(int i = 0; i < m; ++i){
    cin >> u >> v;
    adj[u-1].push_back(v-1);
  }
  cin >> s >> t;
  --s;
  --t;
  int ans = 0;
  vector<vector<bool>> vu(3,vector<bool>(n));
  vu[0][s] = true;
  queue<pair<int,int>> q;
  q.emplace(s,0);
  while(!q.empty()){
    auto p = q.front();
    q.pop();
    if(p.first == t and p.second%3 == 0){
      cout << p.second/3;
      return 0;
    }
    int nt = p.second+1,nt3 = nt%3;
    for(int i : adj[p.first]){
      if(!vu[nt3][i]){
        vu[nt3][i] = true;
        q.emplace(make_pair(i,nt));
      }
    }
  }
  cout << -1;
  return 0;
}

Measured memory_bytes: 8064
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
    
      	String str = sc.next();
            
      	if(!str.substring(str.length() - 1).equals("s")) {
        	System.out.println(str + "s");
        } else {
        	System.out.println(str + "es");        	
        }
    }
}

Measured memory_bytes: 38476
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> A >> B;
  cout << (A-1)*(B-1) << endl;


}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int sumDigCnt = k / 2;
		int oddDigCnt = k - sumDigCnt;
		System.out.println(sumDigCnt*oddDigCnt);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;
int main(){
    int N;
    cin >>N;
    int a,b,c;
    a=N%10;
    b=(N/10)%10;
    c=(N/100)%10;
    if((a == 7)||(b==7)||(c ==7)) cout<<"Yes"<<endl;
    else cout << "No"<<endl;
}

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

using namespace std;

class UnionFind
{
public:
    int link[100010], rnk[100010], weight[100010];
    void init ()
    {
        for (int i=0; i<100010; i++)
        {
            link[i]=i;
            rnk[i]=1;
            weight[i]=0;
        }
    }
    int Find (int x)//find parent of x
    {
        if (link[x]==x) return x;
        int r=Find(link[x]);
        weight[x]+=weight[link[x]];
        link[x]=r;
        return r;
    }
    int wght (int x)
    {
        int r=Find(x);
        return weight[x];
    }
    int diff (int x, int y) { return wght(y)-wght(x); }
    bool same (int x, int y)//tell x and y are in the same set
    {
        return Find(x)==Find(y);
    }
    void unite (int x, int y, int w)
    {
        if (same(x, y)) return;
        w=w+wght(x)-wght(y);
        x=Find(x);
        y=Find(y);
        if (rnk[x]<rnk[y]) { swap(x, y); w=-w; }
        if (rnk[x]==rnk[y]) rnk[x]++;
        link[y]=x;
        weight[y]=w;
    }
};

int main()
{
    UnionFind U;
    U.init();
    int n, m, l, r, d;
    bool ans=true;
    cin>>n>>m;
    for (int i=0; i<m; i++)
    {
        cin>>l>>r>>d;
        if (U.same(l, r))
        {
            if (U.diff(l, r)!=d) ans=false;
        }
        else U.unite(l, r, d);
    }
    if (ans) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 1408
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	
	n := scanInt()
	x := scanInt()

	l := make([]int, n)
	for i := 0; i < n; i++ {
		l[i] = scanInt()
	}

	d := 0
	ans := 1
	for i := 0; i < n; i++ {
		t := d+l[i]
		if t > x {
			break
		}

		ans++
		d = t
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
def solve():
    from sys import stdin
    f_i = stdin
    
    H, W = map(int, f_i.readline().split())
    A = tuple(tuple(map(int, f_i.readline().split())) for i in range(H))
    B = tuple(tuple(map(int, f_i.readline().split())) for i in range(H))
    
    dp1 = [0] * W
    bit_width = 80 * (H + W - 2)
    dp1[0] = 1 << (bit_width)
    for A_i, B_i in zip(A, B):
        dp2 = [0] * W
        
        diff = abs(A_i[0] - B_i[0])
        dp2[0] = (dp1[0] << diff) | (dp1[0] >> diff)
        
        for j, t in enumerate(zip(A_i[1:], B_i[1:]), start=1):
            A_ij, B_ij = t
            diff = abs(A_ij - B_ij)
            b = dp1[j] | dp2[j-1]
            dp2[j] = (b << diff) | (b >> diff)
        
        dp1 = dp2
    
    b = bin(dp2[-1])
    b = b[-bit_width-1:]
    print(b.index('1'))
 
solve()

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

int n, k;

int main()
{
    cin >> n >> k;
    int a = n / k;
    int b = (n + k / 2) / k;
    ll res = 0;
    if(k % 2 == 0)
    {
        res = pow(a, 3) + pow(b, 3);
    }
    else
    {
        res =  pow(a, 3);
    }
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
#include <string>
#include <float.h>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

// Q1
int main()
{
	long M1, D1, M2, D2;
	int nRet = 0;
	cin >> M1 >> D1 >> M2 >> D2;

	if(1 == D2)
		nRet = 1;
	cout << nRet;
	return 0;
}


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

using namespace std;

const int N = 1e6 + 7;
int  n , m;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
     //freopen("in.in" , "r" , stdin) ;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int t;
        cin >> t;
        n -= t;
    }
    cout << (n<0?-1:n);
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  
  if (x1 == 0) cout << 1;
  else if (x2 == 0) cout << 2;
  else if (x3 == 0) cout << 3;
  else if (x4 == 0) cout << 4;
  else if (x5 == 0) cout << 5;
  
  return 0;
}

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

using ll = long long;

ll A, B, K;

void solve(){
    ll tmp_A = A;
    A = max(0LL, A - K);
    if(A == 0LL) {
        K -= tmp_A;
        B = max(0LL, B - K);
    }
    cout << A << " " << B;
}
int main(){
    cin >> A >> B >> K;
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  private static final int IROHA = 17;
  public static void main(String[] args) {
    try (Scanner scan = new Scanner(System.in)) {
      String input = scan.nextLine();
      String[] arr = input.split("\\s");
      String result = "YES";
      try {
        int sum = 0;
        for (String s: arr) {
          if (s.matches("^[57]$")) {
            sum += Integer.parseInt(s);
          } else {
            result = "NO";
          }
        }
        if (sum != IROHA) {
          result = "NO";
        }
      } catch (NumberFormatException e) {
        result = "NO";
        throw e;
      }
      System.out.println(result);
        
    }
  }
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e5 + 9, M = 2e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    int x;  cin >> x;
    if(x < 1200)    cout << "ABC";
    else cout << "ARC";
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int cnt = 0;
            for(int i = 0; i < N-2; i++)
            {
                if(S.Substring(i, 3) == "ABC")
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main()
{
  long long int a,b,x;
  cin>>a>>b>>x;
  if(a!=0) cout<< b/x-(a-1)/x <<endl;
  if(a==0) cout<< b/x +1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int a,b,k;
  cin >> k;
  cin >> a >> b;
  if(b < k) cout <<"NG"<< endl;
  else{
    bool flag = false;
    for(int i = a; i <= b; i++){
      if(i % k == 0){
        flag = true;
        break;
      }
    }
    if(flag) cout << "OK" << endl;
    else cout << "NG" << endl;
  }
}

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

int main()
{
    int k,x;
    cin>>k>>x;
    int sum = 0;
    for(int i=0;i<k;i++)
    {
        sum += 500;
    }
    if(sum >= x)
    {
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

int main(){
    int n, m;
    int a, b;
    bool ans = false;
    cin >> n >> m;
    vector<bool> vis(n+1, false);

    for (int i = 0; i < m; i++){
        cin >> a >> b;

        if (a == 1){
            if (vis[b]  == true) {
                ans = true;
            }
            else {
                vis[b] = true;
            }
        }
        else if (b == n) {
            if (vis[a]  == true) {
                ans = true;
            }
            else {
                vis[a] = true;
            }
        }
    }

    if (!ans) cout << "IM";
    cout << "POSSIBLE" << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	int n; cin>>n; map<int,int> m;
	int arr[n]; for(int i = 0; i < n; i++) { cin>>arr[i]; m[arr[i]]++;}
	int ans = n;
	for(int i = 0; i < n; i++){
		int need = arr[i];
		for(int j = 1; j*j <= arr[i]; j++){
			if(arr[i]%j == 0){
				int a = j, b = arr[i]/j;
				int co_a = m[a]; int co_b = m[b];
				if(arr[i] == a) co_a--;
				if(arr[i] == b) co_b--;
				if(co_a || co_b) { ans--; break; }
			}
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 33252
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
using namespace std;

typedef long long ll;

int main()
{
    int n,m,k,a,check[31] = {};
    cin >> n >> m;
    FOR(i,0,n)
    {
        cin >> k;
        FOR(j,0,k)
        {
            cin >> a;
            check[a]++;
        }
    }
    int cnt = 0;
    FOR(i,1,m+1)
    {
        if(check[i]==n)
            cnt++;
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int n,d[100],i,j,sum;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&d[i]);
	sum=0;
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			sum+=d[i]*d[j];
		}
	}
	printf("%d\n",sum);
	return 0;
}


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

int main(){
  
  int n;
  cin >>n;
  vector<int> l(n);
  for(int i=0; i<n; i++) cin >> l[i];
  
  sort(l.begin(),l.end());
  
  int count=0;
  for(int i=0; i<n; i++){
  	for(int j=i+1; j<n; j++){
    	for(int k=j+1; k<n; k++){
        	if(l[i]+l[j]>l[k]) count++;
        }
    }
  }
  

  cout << count << endl;
}

Measured memory_bytes: 256
W,H,N = map(int, input().split(' '))
ls = []
for i in range(N):
  ls.append(input())
  
WA,WZ,HA,HZ = 0,W,0,H
 
for str_ in ls:
  x,y,a = map(int,str_.split(' '))
  
  if a == 1 and WA < x:
    WA = x
  elif a == 2 and WZ > x:
    WZ = x
  elif a == 3 and HA < y:
    HA = y
  elif a == 4 and HZ > y:
    HZ = y
 
if (w := WZ-WA) > 0 and (h := HZ-HA) > 0:
  print(int(w*h))
else:
  print(0)

Measured memory_bytes: 9100
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

int main() {
	int a = 753;
	int res = INF;

	string s;
	cin >> s;

	for (int i = 2; i < s.size(); i++) {
		string p = "";
		p += s[i - 2];
		p += s[i - 1];
		p += s[i];
		res = min(res, abs(stoi(p) - a));
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define fi first
#define se second
#define mp make_pair
#define pb push_back
int32_t main(){
    
    
   unordered_map< string,int>cn;
   string s1,s2;
   cin>>s1>>s2;
   int a,b;
   cin>>a>>b;
   
   cn[s1]=a;
   cn[s2]=b;
   
   string s;
   cin>>s;
   cn[s]--;
   
   cout<<cn[s1]<<" "<<cn[s2]<<endl;
   
   
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
  
  string str, com;
  int q, a, b;
  string p;

  cin >> str;
  cin >> q;

  for ( int i = 0; i < q; i++ )
    {
      cin >> com;
      if ( com == "print" )
        {
          cin >> a >> b;
          cout << str.substr(a, b-a+1) << endl;
        }
      else if ( com == "reverse" )
        {
          cin >> a >> b;
          reverse(str.begin() + a, str.begin() + b + 1);
        }
      else if ( com == "replace" )
        {
          cin >> a >> b >> p;
          for ( int j = 0; j < b - a + 1; j++ )
            {
              str[a+j] = p[j];
            }
        }
    }
  
  return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int64 a(int32 l){
    if(l == 0)return 1;
    return a(l-1) * 2 + 3;
}

int64 f(int32 l, int64 x){
    if(l == 0 && x == 1)return 1;
    if(x <= 1)return 0;
    if(2 <= x && x <= a(l-1) + 1){
        return f(l-1, x - 1);
    }
    if(x == a(l-1) + 2){
        return f(l-1, x-2) + 1;
    }
    if(a(l-1) + 3 <= x && x <= a(l-1) * 2 + 2){
        return f(l-1,a(l-1)) + f(l-1, x - a(l-1) - 2) + 1;
    }
    if(x == a(l)){
        return f(l-1,a(l-1)) * 2 + 1;
    }
    return -1;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    int64 x;
    cin >> n >> x;
    ANS(f(n, x));
    return 0;
}

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

typedef long long int LL;
typedef unsigned long long uLL;
const int inf = (int)1e9;
const LL INF = (LL)2e18;
const int N = 100005;
const int mod = 1000000007;
const double eps = 1e-8;
const double pi = acos( -1.0 );

#define all( V )         V.begin(), V.end()
#define Unique( a )      sort( all(a) ), a.erase( unique( all(a) ), a.end() )

vector < string > V;

int main( int argc, char const *argv[] ) {
    string s;
    int k;
    cin >> s >> k;
    for( int i = 0; i < s.size(); i++ ) {
        string ret = "";
        for( int j = i; j < s.size(); j++ ) {
            ret += s[j];
            if( ret.size() > k ) break;
            V.push_back( ret );
        }
    }
    Unique( V );
    cout << V[k-1] << endl;
    //for( auto x : V ) cout << x << " ";
    return 0;
}








Measured memory_bytes: 1660
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = True
show_flg = False

def main():
    H = I()
    ans = 0
    c = 0
    h = H

    while h >= 1:
        c += 1
        h = h // 2

    for i in range(c):
        ans += 2 ** i

    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//setpresition

int main(){
    int n;
    cin >> n;
    cout << n/2+n%2 << endl;
}

Measured memory_bytes: 256
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
MAX=a1[0]+sum(a2)
sum_=a1[0]+sum(a2)
for i in range(1,n):
    sum_+=a1[i]-a2[i-1]
    MAX=max(MAX,sum_)
print(MAX)

Measured memory_bytes: 3064
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int main()
{
	int n,a[200]={0},f=0;
	cin>>n;
	for (int i=0;i<n;i++){
		char c;
		cin>>c;
		if (c=='Y') f=1;
	}
	if (f==0)
		cout<<"Three";
	else
		cout<<"Four";
	return 0;
}

Measured memory_bytes: 256
import heapq
Q = int(input())

heapL, heapR = [], []
s = 0
x = None
for i in range(Q):
    q = list(map(int, input().split()))
    if len(q) == 1:
        print(x, s)
    else:
        _, a, b = q
        s += b
        if not heapL:
            heapq.heappush(heapL, -a)
        elif not heapR:
            s += abs(a + heapL[0])
            heapq.heappush(heapR, -heapq.heappushpop(heapL, -a))
        else:
            if len(heapL) > len(heapR):
                s += abs(a + heapL[0])
                heapq.heappush(heapR, -heapq.heappushpop(heapL, -a))
            else:
                heapq.heappush(heapL, -heapq.heappushpop(heapR, a))
                s += abs(a + heapL[0])
        x = -heapL[0]


Measured memory_bytes: 11160
#include<stdio.h>
int main()
{
	int a,b,c,d,i,k=0,n,m;
	scanf("%d%d%d",&a,&b,&c);
	for(i=1;i<=a;i++)
	{
		n=0;
		m=i;
		while(m!=0)
		{
			d=m%10;
			n+=d;
			m/=10; 
		}
		if(n>=b&&n<=c)
		{
			k+=i;
		}
	}
	printf("%d",k);
	return 0;
}

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

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    int n; cin >> n;
    int d; cin >> d;
    vector <vector <int>> ps;
    REP(i, n){
        vector <int> p;
        REP(j, d){
            int s; cin >> s;
            p.push_back(s);
        }
        ps.push_back(p);
    }
    set <int> squares;
    REP(i, 150){
        squares.insert(pow(i, 2));
    }
    int ans = 0;
    REP(i, n){
        for(int j=0; j<i; j++){
            int sq_dist = 0;
            REP(k, d){
                sq_dist += pow(ps[i][k] - ps[j][k], 2);
            }
            if (squares.find(sq_dist) != squares.end()){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
inline int read(){
	int x=0,w=1;
	char ch=0;
	while (ch<'0' || ch>'9'){
		ch=getchar();
		if (ch=='-') w=-1;	
	}
	while (ch<='9' && ch>='0'){
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*w;
}
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,a[N],cnt1,cnt2;
int main(){
	n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	sort(a+1,a+n+1);
	if (a[n]>=a[1]+2){
		printf("No\n");
		return 0;
	}
	if (a[n]==a[1]){
		if (a[n]<=(n/2) || a[n]==n-1) printf("Yes\n");
		else printf("No\n");
		return 0;
	}
	for (int i=1;i<=n;++i)
		if (a[i]==a[1]) ++cnt1;
		else ++cnt2;
	if (cnt2==1 || cnt1+1>a[n] || cnt1+(cnt2/2)<a[n])
		printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 640
n = int(input())
h = list(map(int,input().split()))
ans = 0
for j in range(max(h),0,-1):
    renzokucnt = 0
    for i in range(n):
        if renzokucnt == 0 and h[i] == j:
            renzokucnt = 1
            h[i] -= 1
        elif renzokucnt >0 and h[i] == j:
            renzokucnt+=1
            h[i] -=1
        elif renzokucnt >0 and h[i] != j:
            ans+= 1
            renzokucnt = 0

            
    if renzokucnt >0:ans+= 1
    
        
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

    set<int> st;
    int x,y=0;
    REP(i,N){
        int a; cin>>a;
        if(a<3200) st.insert(a/400);
        else y++;
    }
    x=st.size();

    cout<<max(1LL,x)<<' '<<x+y<<endl;
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

for i in range(50000):
    if((i+1)*(1.08)//1 == n):
        print(i+1)
        exit()
else:
    print(":(")



Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,N;
  cin >> N >> K;
  vector<long> S(N+1);
  S.at(0)=0;
  for(int i=1; i<=N; i++){
    int p;
  	cin >> p;
    S.at(i)=S.at(i-1)+p;
  }
  long m=0;
  for(int i=K; i<=N; i++){
    m=max(m,S.at(i)-S.at(i-K));
  }
  cout<<fixed<<setprecision(10);
  cout<<(m+K)/2.0 << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
  constexpr int N = 1000000;

  bool is_not_prime[N] = { true, true };
  bool is_prime[N] = {};
  for( int i=2; i<N; ++i ) {
    if ( is_not_prime[i] )
      continue;

    is_prime[i] = true;

    for( int j=i; j<N; j+=i ) {
      is_not_prime[j] = true;
    }
  }


  int a, d, n;
  while( cin >> a >> d >> n ) {
    if ( a == 0 && d == 0 && n == 0 )
      break;

    int val = 0;
    for( int i=0, index=0; index<n; ++i ) {
      val = a + i * d;
      if ( is_prime[val] )
        ++index;
    }

    cout << val << endl;
  }
}

Measured memory_bytes: 3120
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <fstream>

using namespace std;

ifstream fin("../data.txt");

int w, h, n, x, y, a, x1, x2, y1, y2;

int main() {

  cin >> w >> h >> n;
  x1 = y1 = 0, x2 = w, y2 = h;
  while (n--) {
    cin >> x >> y >> a;
    switch (a) {
      case 1:
        x1 = max(x, x1);
        break;
      case 2:
        x2 = min(x, x2);
        break;
      case 3:
        y1 = max(y, y1);
        break;
      case 4:
        y2 = min(y, y2);
        break;
      default: break;
    }
  }
  if (x2 - x1 <= 0 || y2 - y1 <= 0) cout << 0;
  else cout << (x2 - x1) * (y2 - y1);
  return 0;
}


Measured memory_bytes: 3604