akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------
#define bitrep(i, n)     for(ll i=0; i<(ll) (1<<(n)); i++)
#define bis(i, j)        i & (1<<j)

int main(void) {
  ll n, k;
  cin >> n >> k;
  arrll(a,n);

  ll ans=1e18;
  bitrep(i,n){
    int ct=0;
    vecb seen(n, false);
    rep(j,n){
      if(bis(i,j)){
        seen[j] = true;
        ct++;
      }
    }
    if(ct<k){continue;}
    //prtall(v);
    ll max_height=0;
    ll tmp=0;
    rep(j,n){
      if(seen[j]){
        if(max_height+1>a[j])
        tmp += max(0ll, max_height + 1 - a[j]);
        max_height=max(a[j], max_height+1);
      } else {
        chmax(max_height, a[j]);
      }
    }

    chmin(ans, tmp);
  }

  prt(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

const int NMAX = 50;
ll a[NMAX+1], p[NMAX+1];

ll rec(int N, ll X) {
  if (N == 0) return 1;
  if (X == 1) return 0;
  else if (X <= 1 + a[N-1]) return rec(N-1, X-1);
  else if (X == 2 + a[N-1]) return p[N-1] + 1;
  else if (X <= 2 + 2*a[N-1]) return p[N-1] + 1 + rec(N-1, X-2-a[N-1]);
  else return 2*p[N-1] + 1;
}

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

  a[0] = 1;
  p[0] = 1;
  for (int i = 1; i <= n; ++i) {
    a[i] = 2*a[i-1] + 3;
    p[i] = 2*p[i-1] + 1;
  }

  cout << rec(n, x) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int n,sum=0;
  cin >> n;
  vi l(n);
  rep(i,0,n){
    cin >> l[i];
  }
  sort(all(l));
  rep(i,0,n-1){
    sum+= l[i];
  }
  if(sum>l[n-1]){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<unistd.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define ST first
#define ND second
#define ll long long
#define ld long double
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;
using namespace __gnu_pbds;
 
// replace ll  with pair if multiset needed
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set secik;
 
const ll  INF = 1e9 + 9;
const ll  MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;
 
// secik.insert({x, t++});
// secik.erase(secik.lower_bound({x,-1}));
// *secik.find_by_order(x)).first << "\n";
// secik.order_of_key(x)
 
//random_device device;
//mt19937 gener(device());
//uniform_int_distribution<ll > gen(0,n-1);
//gen(gener); // generate random number



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

	int x; cin >> x;
	cout << !x;


















	
	return 0;
 
}

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

#define llint long long int

using namespace std;

int main()
{
    int N;

    cin >> N;

    int ans = 0;

    for (int A = 1; A <= N; A++)
    {
        for (int B = 1; B <= N; B++)
        {
            if (A * B >= N)
            {
                break;
            }
            ans++;
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n = 0;
    cin >> n;
    cout << (float) 2 * 3.1415926535 * n << endl;

    return 0;
}

Measured memory_bytes: 3804
S = list(input())

odd0, odd1 = 0, 0
even0, even1 = 0, 0
for i, s in enumerate(S):
    if i % 2 == 0:
        if s == "0":
            even0 += 1
        else:
            even1 += 1
    else:
        if s == "0":
            odd0 += 1
        else:
            odd1 += 1
print(min(even0+odd1, even1+odd0))





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

using namespace std;
const long mod = 1000000007;
typedef long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) string s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;


int main() {
  int2(n,m);
  lint dp[n+1];
  repi(n+1){
    dp[i]=1;
  }
  
  dp[0]=1;
  dp[1]=1;
  repi(m){
    int1(a);
    dp[a]=0;
  }
  for (int i=2; i <=n; ++i) {
    if(dp[i]==0){
      continue;
    }
    dp[i]=((dp[i-1]%mod)+(dp[i-2]%mod))%mod;
  }
  prln(dp[n]);

}


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

int main() {
  string S;
  cin >> S;
  int N = S.size();

  // 全体
  for (int i = 0; i < N; i++) {
    if (S[i] != S[N - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  // 前半,後半
  int center = (N - 1) / 2;
  for (int i = 0; i < center; i++) {
    if (S[i] != S[center - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
    if (S[center + 1 + i] != S[N - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
n = int(input())
t = list(map(int,input().split()))
sumt = sum(t)
m = int(input())
l = []
for i in range(m):
    p, x = map(int,input().split())
    a = sum(t)+x-t[p-1]
    l.append(a)
for j in l:
    print(j)

Measured memory_bytes: 3064
import math

list_input = list(map(int, input().split()))
a = list_input[0]
b = list_input[1]
hour = list_input[2]
minute = list_input[3]

# cos(theta) 計算
hour_angle = 2 * math.pi * (hour / 12) + math.pi / 6 * (minute / 60)  # 時針は1時間に
minute_angle = math.pi / 30 * minute  # 秒針は1分間に math.pi/30 度動く
target_angle = abs(hour_angle - minute_angle)

if target_angle > math.pi:
    target_angle = 2 * math.pi - target_angle

target_length = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(target_angle))
print(target_length)


Measured memory_bytes: 62680
import math

n , m =map(int,input().split())
mod = 1000000007

if abs(m-n)>= 2 :
    print(0)
elif abs(m-n) == 0:
    print(int(math.factorial(m)%mod)*int(math.factorial(n)%mod)*2%mod)
else:
    print(int(math.factorial(m)%mod)*int(math.factorial(n)%mod)%mod)

Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



int main() {
	int n;
	scanf("%d", &n);
	vector<int> in(n);
	for(int & x : in) scanf("%d", &x);
	typedef long long ll;
	ll low = 2, high = 2;
	for(int i = n - 1; i >= 0; --i) {
		int sizes = in[i];
		ll one = low / sizes * sizes;
		if(one < low) one += sizes;
		
		ll two = high / sizes * sizes;
		if(one > two) {
			puts("-1");
			return 0;
		}
		high = two + sizes - 1;
		low = one;
	}
	printf("%lld %lld\n", low, high);
}


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

#define fi first
#define se second

const int N = 100100;

using namespace std;

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        string s;
        cin >> s;

        long long res = 0, A = 0, B = 0, C = 0;
        vector < int > a, v;
        for(int i = 0; i < s.size(); i++){
                if(!v.empty() && v.back() == 1 && s[i] == '1'){
                        v.pop_back();
                        C += 1;
                } else{
                        v.push_back(s[i] - '0');
                }
                if(i % 2 == 0){
                        res += s[i] - '0';
                }
                A += s[i] - '0';
                B += 1 - (s[i] - '0');
        }
        for(int i = 1; i < A; i++){
                res += (i + 1) / 2;
        }

        res += 1ll * C * B;

        a.push_back(0);
        for(int x: v){
                if(x == 0){
                        a.back() += 1;
                } else{
                        a.push_back(0);
                }
        }
        int m = a.size() - 1;
        long long S = a[0];
        for(int i = 1; i <= m; i++){
                if((S + i) % 2){
                        res += S / 2;
                } else{
                        res += (S + 1) / 2;
                }
                res += 1ll * i * a[i];
                S += a[i];
        }

        cout << res << "\n";
}


Measured memory_bytes: 4972
N,M=map(int, input().split())
A=[input() for i in range(N)]
B=[input() for i in range(M)]
a=0
for i in range(N-M+1):
    for j in range(N-M+1):
        for k in range(M):
            if A[j+k][i:i+M]!=B[k]:
                break
        else:
            a=1
print("Yes" if a else "No")

Measured memory_bytes: 3064
import sys
from collections import deque

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

n = I()
A = LI()
q = I()
m = LI()
ans = 0
partial_sum = set()
for i in range(2 ** n):
    bit = [i>>j&1 for j in range(n)]
    partial_sum.add(sum(A[k]*bit[k] for k in range(n)))
for x in m:
    print('yes' if x in partial_sum else 'no')



Measured memory_bytes: 6052
n = int(input())
ans=[]
def sosu(x):
    for i in range(2,x):
        if x % i ==0:
            return False
    return True

for i in range(11,55555,5):
    if sosu(i) and i % 5 ==1:
        ans.append(i)
        if len(ans) >= n:
            break

print(' '.join([str(s) for s in ans]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 2e5+7;
int b[maxn],a[maxn],bits[50],cnt[maxn],tot=0;
map<int,int>exist;
int vis[maxn];
int main()
{
    int n;scanf("%d",&n);
    for (int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        exist[a[i]]++;
    }
    sort(a,a+n);
    b[++tot]=a[0];
    cnt[tot]++;
    for (int i=1;i<n;i++)
    {
        if (a[i]!=a[i-1]) b[++tot]=a[i];
        cnt[tot]++;
    }
    bits[0]=1;
    for (int i=1;i<=40;i++) bits[i]=bits[i-1]*2;

    int ans=0;
    for (int ii=32;ii>=1;ii--)
    {
        int now=bits[ii];
        for (int i=n-1;i>=0;i--)
        {
            int k=lower_bound(b+1,b+1+tot,a[i])-b;
            if (cnt[k]<=0) continue;
            int pos=lower_bound(b+1,b+1+tot,now-a[i])-b;
            if (b[pos]==now-a[i] && cnt[pos]>0)
            {
                if ((k==pos && cnt[pos]>1) || (k!=pos && cnt[pos]>0))
                {
                    ans++;
                    cnt[pos]--;
                    cnt[k]--;
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 13952
import math

line = input().rstrip()
N = int(line)
line = input().rstrip()
line = line.split(' ')
mult = 1

numbers = []
for i in range(N):
    numbers.append(int(line[i]))
numbers.sort()

if numbers[0] == 0:
    mult = 0
else:
    for A in numbers:
        if math.log10(mult) + math.log10(A) > 18.0:
            mult = -1
            break
        mult = mult * A
        if mult > 10**18:
            mult = -1
            break

print(mult)


Measured memory_bytes: 83188
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int days = sc.nextInt();
            int work = sc.nextInt();
            int sum = 0;
            for(int i = 0; i < work; i++){
              int j = sc.nextInt();
              sum += j;
            }
            if(days - sum < 0){
              System.out.println(-1);
            } else {
              System.out.println(days - sum);
            }
            }
}

Measured memory_bytes: 46276
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=(n);i<(N);i++)
#define RREP(i,n,N) for(ll i=(N-1);i>=(n);i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(), (v).end()
#define MCP(a,b) memcpy(b,a, sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;
const ll inf =1e18;

ll n, nmin, nmax;
ll P[210];
int main(){
    while(cin>>n>>nmin>>nmax, n!=0){
        REP(i, 0, n) cin>>P[i];

        ll gap=0;
        ll ans;
        sort(P, P+n);
        reverse(P, P+n);

        REP(i, nmin, nmax+1){
            ll d=P[i-1]-P[i];
            if(gap<=d){
                gap=d;
                ans=i;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
  
    bool flag = false;
    rep(i, 30)
    {
      rep(j, 15)
      {
        if(n == 4 * i + 7 * j)
        {
          flag = true;
        }
      }
    }
  
    if (flag)
    {
      printf("Yes");
    }
    else
    {
      printf("No");
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
	int m, n;
	while(scanf("%d %d", &m, &n))
	{
		if(m == 0 && n == 0)
		{
			break;
		}
		for(int i = 0; i < n; i++)
		{
			printf("#");
		}
		printf("\n");
		for(int j = 0; j < m - 2; j++)
		{
			printf("#");
			for(int i = 0; i < n - 2; i++)
			{
				printf(".");
			}
			printf("#");
			printf("\n");
		}
			for(int i = 0; i < n; i++)
		{
			printf("#");
		}
		printf("\n\n");
	}	
		
	
	return 0; 
} 


Measured memory_bytes: 2596
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(long long (i)=0;(i)<(n);(i)++)
#define ll long long
#define pr_qu priority_queue
#define vec(name,size,common) vector<ll> (name)((size),(common))
 
 
 
 
 
int main(){
  set <int> a;

int n;
cin>>n;
int b;
  for(int i=0;i<n;i++){
    cin>>b;
    a.insert(b);
  }

  cout<<a.size()<<endl;
}

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

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define debug(x) cout << #x <<" = " << x << endl
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first  <<" " << v[i].second << endl;
#define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = 1000000000;

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

const int N = 100001;
ll n,x,a[N];
int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> x;
	forn(i,n) cin >> a[i];
	
	ll ans = 0;
	
	for(int i = 0; i < n - 1; i++){
		ll sum = a[i] + a[i + 1];
		if (sum > x){
			ll d = sum - x;
			if (a[i + 1] - d >= 0){
				ans += (d);
				a[i + 1] -= d;
			}
			else {
				a[i + 1] = 0;
				ans += d;
			}	
		}
	}
	cout << ans << endl;
  	return 0;
}

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

using namespace std;

#define MAX 100005
vector<int> adj[MAX];
int d[MAX];
int dp[MAX];
int ans = 0;

void dfs(int u)
{
    dp[u] = 0;
    for(int i=0; i<adj[u].size(); i++){
        int v = adj[u][i];
        if(dp[v] == -1) dfs(v);
        dp[u] = max(dp[u], 1+dp[v]);
    }
    ans = max(ans, dp[u]);
}

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
    for(int i=0; i<m; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        adj[u].push_back(v);
        d[v]++;
    }
    memset(dp, -1, sizeof dp);
    for(int i=1; i<=n; i++){
        if(d[i] == 0) dfs(i);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 11136
#include<cstdio>;
int main() {
	int a[2];
	for (int i = 0; i < 2; ++i) {
  		scanf("%d", &a[i]);
	}
	int b = a[0]-2*a[1];
  	if(b>0){
		printf("%d",b);
  	}else{
    	printf("%d",0);
  	}
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
const int Max = 3e5 + 5;
const int Mod = 1e9 + 7;

int main()
{
	GO;
	string a, b, c;
	cin >> a >> b;
	int x, y;
	cin >> x >> y;
	cin >> c;
	cout << x - (c == a) << ' ' << y - (b == c) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
        int H,W;
        while(true){
            scanf("%d %d",&H,&W);
            if(H==0 && W==0){
                break;
            }
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    printf("#");
                }
                putchar('\n');
            }
            putchar('\n');
        }
        return 0;
    
}



Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, a, b, c, d;
    cin >> n;
    a = n / 1000;
    b = (n - 1000 * a) / 100;
    c = (n - 1000 * a - 100 * b) / 10;
    d = n - 1000 * a - 100 * b - 10 * c;
    if ((a == b && b == c) || (b == c && c == d))
        cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    var x = sc.nextInt()
    val a = (1..n).map { sc.nextInt() }.sorted()
    var ans = 0
    for (i in 0 until n) {
        x -= a[i]
        if (x < 0) {
            break
        }
        if (x == 0) {
            ans++
            break
        }
        if (i == n - 1) {
            break
        }
        ans++
    }
    println(ans)
}

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

using namespace std;
typedef pair<int, int> pii;

int di[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dj[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int cnt[1010][1010];

int main(void) {
  int h, w;
  cin >> h >> w;

  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }

  queue<pii> que[2];
  for (int i = 1; i < h - 1; i++) {
    for (int j = 1; j < w - 1; j++) {
      for (int k = 0; k < 8; k++) {
        int ni = i + di[k], nj = j + dj[k];
        if (s[ni][nj] != '.') continue;
        cnt[i][j]++;
      }
      if (s[i][j] == '.') continue;
      if (cnt[i][j] < s[i][j] - '0') continue;
      que[0].push(pii(i, j));
    }
  }

  int ans = 0;
  bool turn = false;
  while (!que[turn].empty()) {
    while (!que[turn].empty()) {
      pii v = que[turn].front();
      que[turn].pop();
      int i = v.first, j = v.second;
      for (int k = 0; k < 8; k++) {
        int ni = i + di[k], nj = j + dj[k];
        cnt[ni][nj]++;
        if (s[ni][nj] == '.') continue;
        if (cnt[ni][nj] == s[ni][nj] - '0') {
          que[!turn].push(pii(ni, nj));
        }
      }
    }
    ans++;
    turn = !turn;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7976
#include <bits/stdc++.h>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr << #x <<": "<<(x)<<endl
#define debug2(x,y) cerr << #x <<": "<< (x) <<", "<< #y <<": "<< (y) << endl
#define answer(x) cout << (x) <<endl
#define answer_fixed(x, p) cout << fixed << setprecision(p) << (x) << endl
using namespace std;
int main() {
  int N;
  cin >> N;
  double ans = 0;
  REP(i, N) {
    double x;
    cin >> x;
    string u;
    cin >> u;
    ans += x * (u == "JPY" ? 1 : 380000.0);
  }
  answer(ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -mod;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 1.05;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		puts(p); l[p] = i;
	}
}

Measured memory_bytes: 3720
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin>>s;
    if((s[0]=='7')|| (s[1]=='7') || (s[2]=='7'))
    {
         cout<<"Yes";
    }
    else{
         cout<<"No";
    }
    return 0;
}


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

int main() {
    string S ,T;
    cin >> S >> T;
    bool ans = false;
    for (int i = 0; i < S.size(); i++) {
        if (S == T) {
            ans = true;
            break;
        }
        S = S.back() + S.substr(0, S.size() - 1);
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}


int mmin = 1000000;
int n, k;

void solve(int now, int i){
    if(i == n){
        mmin = min(mmin, now);
        return;
    }
    solve(now*2, i+1);
    solve(now+k, i+1);
    return;
}

int main() {
    std::ios::sync_with_stdio(false);
    cin >> n >> k;
    solve(1, 0);
    cout << mmin << endl;
    return 0;
}


Measured memory_bytes: 256
#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;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int cnt_0 = 0;
    int cnt_1 = 0;
    for (auto c : s) {
        if (c == '1')
            cnt_1++;
        else
            cnt_0++;
    }

    int ans = n;
    for (ans = n; ans * 2 > n; ans--) {
        if (cnt_0 == 0 || cnt_1 == 0)
            break;

        int idx1 = n - ans;
        int idx2 = ans - 1;
        if (s[idx1] == '0')
            cnt_0--;
        else
            cnt_1--;
        if (s[idx2] == '0')
            cnt_0--;
        else
            cnt_1--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    a = LI()
    if sum(a) == 0:
        print("Yes")
        return
    if n%3 != 0:
        print("No")
        return
    d = defaultdict(lambda : 0)
    for i in a:
        d[i] += 1
    if len(list(d.items())) == 2:
        if d[0] == n//3:
            print("Yes")
            return
        else:
            print("No")
            return
    k = 0
    for i,j in d.items():
        k ^= i
        if j != n//3:
            print("No")
            return
    if not k:
        print("Yes")
        return
    print("No")
    return

#B
def B():
    n,m = LI()
    ans = []
    d = [0]*(n+1)
    for i in range(m):
        a,b = LI()
        ans.append([a,b])
        d[a] ^= 1
    for i in range(m):
        a,b = ans[i]
        if d[a]:
            ans[i] = [b,a]
            d[a] ^= 1
            d[b] ^= 1
    if sum(d):
        print(-1)
    else:
        for i in ans:
            print(*i)
    return

#C
def C():
    n = I()
    p = [(1<<i) for i in range(100)]
    if n in p:
        print("No")
        quit()
    if n+1 in p:
        print("Yes")
        for i in range(1,2*n):
            print(i,i+1)
        quit()
    ans = []
    for i in range(1,3):
        ans.append((i,i+1))
    ans.append((3,n+1))
    for i in range(1,3):
        ans.append((i+n,i+n+1))
    u = 1
    d = 1
    for i in range(2,n//2+n%2):
        ans.append((u,2*i))
        ans.append((d,2*i+1))
        ans.append((2*i,2*i+n+1))
        ans.append((2*i+1,2*i+n))
        u = 2*i+n+1
        d = 2*i+n

    if n%2:
        print("Yes")
        for i,j in ans:
            print(i,j)
    else:
        ans.append((n-1,n))
        for i in range(n):
            if p[i]&n:
                break
        ans.append((p[i+1]-2,2*n))
        print("Yes")
        for i,j in ans:
            print(i,j)
    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 59120
//
// Created by 李青坪 on 2018/10/16.
//

#include "cstdio"
using namespace std;
#define MAXN 100000
#define NIL -1


struct Node{
    int parent;
    int left;
    int right;
};
Node tree[MAXN];
int depth[MAXN];


void getDepth(int node, int dep){
    depth[node] = dep;
    if (tree[node].right != NIL) getDepth(tree[node].right, dep);
    if (tree[node].left != NIL) getDepth(tree[node].left, dep+1);
}

void printTree(int n, int root){
    getDepth(root, 0);
    for (int i = 0; i < n; ++i) {
        printf("node %d: parent = %d, depth = %d, ", i, tree[i].parent, depth[i]);
        if (depth[i] == 0){
            int iter = tree[i].left;
            if (iter == NIL) {
                printf("root, []\n");
                continue;
            }
            printf("root, [%d", iter);
            while(tree[iter].right != NIL){
                iter = tree[iter].right;
                printf(", %d", iter);
            }
            printf("]");
        }else if(tree[i].left != NIL){
            int iter = tree[i].left;
            printf("internal node, [%d", iter);
            while(tree[iter].right != NIL){
                iter = tree[iter].right;
                printf(", %d", iter);
            }
            printf("]");
        }
        else {
            printf("leaf, []");
        }
        printf("\n");
    }
}
int main(){
    int n;
    scanf("%d", &n);
    for (int l = 0; l < n; ++l) {
        tree[l].parent = NIL;
        tree[l].left = NIL;
        tree[l].right = NIL;
    }
    for (int i = 0; i < n; ++i) {
        int node_id, degree;
        scanf("%d %d", &node_id, &degree);
        if (degree == 0){
            tree[node_id].left = NIL;
            continue;
        }
        int children[degree+1];
        for (int k = 0; k < degree+1; ++k) {
            children[k] = NIL;
        }
        for (int j = 0; j < degree; ++j) {
            scanf("%d", &children[j]);
            tree[children[j]].parent = node_id;
        }
        tree[node_id].left = children[0];
        for (int j = 0; j < degree; ++j) {
            tree[children[j]].right = children[j+1];
        }
    }
    int root;
    for (int l = 0; l < n; ++l) {
        if (tree[l].parent == NIL) {
            root = l;
            break;
        }
    }
    printTree(n, root);
}
/*
13
0 3 1 4 10
1 2 2 3
2 0
3 0
4 3 5 6 7
5 0
6 0
7 2 8 9
8 0
9 0
10 2 11 12
11 0
12 0
 */


Measured memory_bytes: 7264
fun main(args: Array<String>) {
    abc044b()
}

fun abc044b() {
    val w = readLine()!!

    val answer = w.groupBy { it }.map { it.value.size }
        .all { it % 2 == 0 }.let { if (it) "Yes" else "No" }

    println(answer)
}


Measured memory_bytes: 33464
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
vector<int> G[200000];
bool s[200000], g[200000];
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (a > b) swap(a, b);
		if (a == 0) s[b] = 1;
		if (b == N - 1) g[a] = 1;
	}
	for (int i = 0; i < N; i++) {
		if (s[i] && g[i]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 5376
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>

#define rep(i,x,y) for (int i=x;i<=y;i++)
#define dep(i,y,x) for (int i=y;i>=x;i--)
#define sz(x) (int)(x.size())

using namespace std;

typedef long long LL;   
typedef unsigned long long uLL;

const int maxn=200000+7;

struct Edge{
    int x,y;LL val;
} E[maxn*4];

int n,Esize,F[maxn],ux[maxn],uy[maxn],pos[maxn];
LL x[maxn],y[maxn];

bool cmpx(int a,int b) {return x[a]<x[b];}
bool cmpy(int a,int b) {return y[a]<y[b];}
bool cmp(Edge a,Edge b) {return a.val<b.val;}

int find(int k) {return (F[k]==k)?(k):(F[k]=find(F[k]));}

LL Kruskal()
{
    LL ans=0;int fx,fy;
    rep(i,1,Esize)
    {
        fx=find(E[i].x),fy=find(E[i].y);
        if (fx==fy) continue;

        ans+=E[i].val;
        F[fx]=fy;
    }
    return ans;
}

int main()
{
    scanf("%d",&n);
    rep(i,1,n) scanf("%lld%lld",&x[i],&y[i]);

    rep(i,1,n) ux[i]=i,uy[i]=i;

    sort(ux+1,ux+n+1,cmpx); 
    sort(uy+1,uy+n+1,cmpy);

    rep(i,1,n) pos[uy[i]]=i;
    rep(i,1,n*2) F[i]=i;
    rep(i,1,n) F[pos[ux[i]]+n]=i;

    rep(i,1,n-1) E[++Esize]=(Edge){i,i+1,x[ux[i+1]]-x[ux[i]]};
    rep(i,1,n-1) E[++Esize]=(Edge){i+n,i+n+1,y[uy[i+1]]-y[uy[i]]};

    sort(E+1,E+Esize+1,cmp);

    printf("%lld\n",Kruskal());

    // system("pause");
    return 0;
}


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

string S;

char evens[3] = {'L', 'U', 'D'}; 
char odds[3] = {'R', 'U', 'D'};

int main() {
    cin >> S;

    bool f = __GCC_ATOMIC_TEST_AND_SET_TRUEVAL;
    for (int i = 0; i < S.length(); i++) {
        if (i % 2 == 0) {

            if (S[i] != 'R' && S[i] != 'U' && S[i] != 'D') {
                f = false;
                break;
            }

        }
        else {
            if (S[i] != 'L' && S[i] != 'U' && S[i] != 'D') {
                f = false;
                break;
            }
        }
    }

    cout << (f ? "Yes" : "No") << endl;


    

    return 0;
}


Measured memory_bytes: 256
# after YouTube explanation
require 'set'
h,w,m = gets.strip.split.map(&:to_i)
hs = Array.new(h,0)
ws = Array.new(w,0)
s = Set.new
m.times do
  x,y = gets.strip.split.map{|e| e.to_i - 1}
  hs[x] += 1
  ws[y] += 1
  s.add [x,y]
end
hx = hs.max
wx = ws.max
is = []
js = []
ans = hx + wx
h.times {|i| is.push i if hx == hs[i]}
w.times {|j| js.push j if wx == ws[j]}
is.each {|i| js.each {|j|
  next if s.include?([i,j])
  p ans
  exit
}}
p ans - 1


Measured memory_bytes: 54712
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 410;
const ll inf = 1e18 + 10;

ll a[N], sum[N][N], dp[N][N];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i ++)
        cin >> a[i];
    for (int i = 1; i <= n; i ++)
        for (int j = i; j <= n; j ++)
            sum[i][j] = sum[i][j - 1] + a[j];
    for (int len = 2; len <= n; len ++)
    {
        for (int l = 1, r = l + len - 1; r <= n; l ++, r ++)
        {
            ll miN = inf;
            for (int k = l; k < r; k ++)
                miN = min(miN, dp[l][k] + dp[k + 1][r]);
            dp[l][r] = miN + sum[l][r];
        }
    }
    cout << dp[1][n];
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <cstdlib>
using namespace std;
using std::swap;
int main()
{
	int n, t, a, h, p;
	int m = 1000000000;
	cin >> n;
	cin >> t >> a;
	a *= 1000;
	for (int i = 0; i < n; ++i) {
		cin >> h;
		h = (t - h * 0.006) * 1000;
		if (m > abs(a - h)) {
			m = abs(a - h);
			p = i + 1;
		}
	}
	cout << p << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll min(ll a, ll b){
    if (a<b) return a;
    return b;
}
int main(){
    ll tar;
    cin>>tar;
    ll a, b, c, d, e;
    cin>>a>>b>>c>>d>>e;
    ll mini=1e9;
    mini=min(a, b);
    mini=min(mini, c);
    mini=min(mini, d);
    mini=min(mini, e);
    ll ans=0;
    ans=tar/mini;
    if (tar%mini!=0) ans++;
    int num=0;
    num+=tar/mini;
    if (tar%mini!=0) num++;
    ans+=4;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> graph[100001];
int dp[100001];

int solve(int src){
    if(dp[src]!=-1){
        return dp[src];
    }

    bool leaf = true;
    int bestChild = 0;
    for(int c: graph[src]){
        leaf = 0;
        bestChild = max(bestChild,solve(c));
    }
    return dp[src] = leaf ? 0 : 1 + bestChild;
}

int main() 
{
    int n,m;
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<m;i++){
        int s,e;
        cin>>s>>e;
        graph[s].push_back(e);
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        ans = max(ans,solve(i));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if (a < b && b < c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}



Measured memory_bytes: 26388
// abc059.a

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++) 

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	double a, b;
	cin >> a >> b;
	if (a > b) {
		cout << "GREATER" << endl;
	} else if (a < b) {
		cout << "LESS" << endl;
	} else {
		cout << "EQUAL" << endl;
	}
}

Measured memory_bytes: 256
// Garg's Code
#include <bits/stdc++.h>
#include <string.h>
using namespace std;

#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define rf(i,x,n) for(ll i = x; i >= x; i--)
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll MAX = LLONG_MAX, MOD = 1000000007, MODA = 1e9 - 1;
const ll MIN = LLONG_MIN;
const long double PI = 3.1415926535;
const ll N = 100009;

int main()
{
  fast();

  ll t=1;
  //cin >> t;
  while(t--)
  {
    ll n, k;
    cin >> n >> k;
    ll arr[n];
    f(i,0,n)
      cin >> arr[i];
    long double brr[n];  
    f(i,0,n)
    {
      brr[i] = ((arr[i]+1)*(1.0))/(2.0);
      //cout << brr[i] << " ";
    }
    //cout << endl;
    long double ans = -1, sum = 0;
    ll ptr = 0, init = 0;
    f(i,0,n)
    {
      sum += brr[i];
      ptr++;
      if(ptr >= k)
      {
        ans = max(ans, sum);
        sum -= brr[init];
        ptr--;
        init++;
      }
    }
    cout << fixed << setprecision(8) << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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 const INF = 1001001001;


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

int N; cin >> N;
vi a(N); rep(i,N) cin >> a[i];

vi c;
c.push_back(a[0]);

rrep(i,N-1) {
    int key = a[i];
    int l = -1; // 常に満たさない
    int r = SZ(c); // 常に満たす
    while(r - l > 1) {
        int mid = (l + r) / 2;
        if(c[mid] < key) r = mid;
        else l = mid;
    }
    if(r == SZ(c)) c.push_back(key);
    else c[r] = key;
}
cout << SZ(c) << endl;
return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, K;cin>>N>>K;
  string S;cin>>S;
  if(S[K-1]=='A') S[K-1]='a';
  if(S[K-1]=='B') S[K-1]='b';
  if(S[K-1]=='C') S[K-1]='c';
  cout << S << endl;
  return 0;
}

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

int main() {
    int N,X;
    cin >> N >> X;
    vector<int> m(N);
    for (int i=0;i<N;i++){
        cin >> m.at(i);
        X -= m.at(i);
    }
    vector<int>::iterator minIter = min_element(m.begin(), m.end());
    size_t minIndex = distance(m.begin(), minIter);
    int min = m.at(minIndex);
    cout << N + X/min << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
long long int mod = 1000000007;
int main()
{
  int a,b;
  cin>>a>>b;
  if(b>=a)
  {
    cout<<"unsafe\n";
  }
  else
  {
    cout<<"safe\n";
  }
  return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+5,mod=998244353;
const int W=(long long)1e18%mod;
int ksm(int b,int n){
	int res=1;
	while(n){
		if(n&1) res=res*b%mod;
		b=b*b%mod; n>>=1;
	}
	return res;
}
int n;
struct graph{
	vector<int> e[N];
	int sg[N],val[N],mx;
	int SG(int u){
		if(sg[u]!=-1) return sg[u];
		map<int,bool> fl;
		for(int i=0;i<e[u].size();++i)
			fl[SG(e[u][i])]=1;
     	do{
          ++sg[u];
        }while(fl.count(sg[u]));
		return sg[u];
	}
	void solve(){
		int m,u,v;
		cin>>m;
		for(int i=1;i<=m;++i){
			cin>>u>>v;
			if(u>v) swap(u,v);
			e[u].push_back(v);
		}
		for(int i=1;i<=n;++i) sg[i]=-1;
		for(int i=1;i<=n;++i)
			if(sg[i]==-1) SG(i);
		for(int i=1;i<=n;++i)
			mx=max(mx,sg[i]),
			val[sg[i]]+=ksm(W,i),val[sg[i]]%=mod;
	//	for(int i=1;i<=n;++i)
		//	cout<<i<<" "<<sg[i]<<endl;
	}
}g0,g1,g2;
signed main(){
//	cout<<W<<endl;
	cin>>n;
	g0.solve();g1.solve();g2.solve();
	int ans=0;
	for(int i=0;i<=g0.mx;++i)
		for(int j=0;j<=g1.mx;++j)
			ans+=g0.val[i]*g1.val[j]%mod*g2.val[i^j]%mod,ans%=mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 18836
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int maxn = 1000005;
int n;
int a[maxn];
int cnt;
vector<int> G;
void InsertSort(int g) {
  for (int i = g; i < n; i++) {
    int temp = a[i];
    int loc = i - g;
    while (loc >= 0 && a[loc] > temp) {
      a[loc + g] = a[loc];
      loc -= g;
      cnt++;
    }
    a[loc + g] = temp;
  }
}
void ShellSort() {
  int h = 1;
  while (h <= n) {
    G.push_back(h);
    h = 3 * h + 1;
  }
  for (int i = G.size() - 1; i >= 0; i--) {
    InsertSort(G[i]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  cnt = 0;
  ShellSort();
  printf("%d\n", G.size());
  for (int i = G.size() - 1; i >= 0; i--)
    printf("%d%c", G[i], i == 0 ? '\n' : ' ');
  printf("%d\n", cnt);
  for (int i = 0; i < n; i++) printf("%d\n", a[i]);
  return 0;
}


Measured memory_bytes: 7080
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        int n,i,j;
        n=input.nextInt();
        int[] a=new int[n];
        for(i=0; i<n; i++){
            a[i]=input.nextInt();
        }
        for(j=n-1; j>=0; j--){
            System.out.print(a[j]);
            if(j!=0) 
            System.out.print(" ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 26380
var
 n,i,k,a,b,c:longint;
begin
 readln(n);
 readln(k);
 c:=1;
 for i:=1 to n do
  begin
   a:=c*2;
   b:=c+k;
   if a>b then c:=b
          else c:=a;
  end;
  writeln(c);
end.

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

double const pi = 3.1415926535;
int const mod = 1000000007;
int const inf = 2147483647;

int yesno(bool f, string yes, string no) {
	if (f)cout << yes << endl;
	else cout << no << endl;
	return 0;
}

int printint(int n) {
	cout << n << endl;
	return 0;
}

int prints(string s) {
	cout << s << endl;
	return 0;
}

int main() {

	int n;
	bool flag = false;
	string a[101];
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] == "Y")flag = true;
	}
	if (flag)cout << "Four" << endl;
	else cout << "Three" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

int main() {
    char c; cin >> c;
    int i = c; ++i;
    char c2 = i;
    cout << c2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAX = 100000;

int main(){
    int K;
    string S;

    cin >> K >> S;

    if(S.size() <= K){
        cout << S << endl;
    }
    else{
        S.erase(K);
        S += "...";
        cout << S << endl;
    }

    return 0;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<int> p(n), q(n), J1(n), J2(n);
  rep (i, n) cin >> p[i];
  rep (i, n) cin >> q[i];

  rep (i, n) J1[i] = i + 1;
  rep (i, n) J2[i] = i + 1;

  int cnt1 = 0, cnt2 = 0;

  do {
    bool ok = true;
    cnt1++;
    rep (i, n) if (p[i] != J1[i]) ok = false;
    if (ok) break;
  } while (next_permutation(J1.begin(), J1.end()));

  do {
    bool ok = true;
    cnt2++;
    rep (i, n) if (q[i] != J2[i]) ok = false;
    if (ok) break;
  } while (next_permutation(J2.begin(), J2.end()));
 
  cout << abs(cnt1 - cnt2) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
  int N, M, i, j; cin >> N >> M;
  pint zahyo[N], point[M];
  rep(i, N) cin >> zahyo[i].first >> zahyo[i].second;
  rep(i, M) cin >> point[i].first >> point[i].second;
  rep(i, N){
    int minj = 1;
    int mini = 10000000000;
    rep(j, M){
      int temp = abs(zahyo[i].first - point[j].first) + abs(zahyo[i].second - point[j].second);
      if(mini > temp){
        mini = temp;
        minj = j+1;
      }
    }
    cout << minj << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    main.show(main.solve());
  }

  int n;
  long a[];
  int ans;
  
  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      n = sc.nextInt();
      a = new long[n];
      for (int i = 0; i < n; i++) a[i] = sc.nextLong();
      Arrays.sort(a);
    } finally {
      sc.close();
    }
  }
  
  int solve() {
    int cnt = 1;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (i == n - 1 || a[i] != a[i+1]) {
        if (cnt % 2 == 1) ans++;
        cnt = 1;
      } else {
        cnt++;
      }
    }
    return ans;
  }

  void show(int ans) {
    System.out.println(ans);
  }
}


Measured memory_bytes: 60588
n = int(input())
ls = map(int, input().split())

cur_longest = 0
sum_others = 0

for l in ls:
    sum_others += l
    if l > cur_longest:
        sum_others -= l
        sum_others += cur_longest
        cur_longest = l

if cur_longest >= sum_others:
    print('No')
else:
    print('Yes')



Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
	int Pnum[50001] = {1,1,0}, n, ans;

	for (int i = 2; i < 50001; i++) {
		if (!(Pnum[i])) {
			for (int j = i+i; j < 50001; j+=i) {
				Pnum[j] = 1;
			}
		}
	}

	while (1) {
		cin >> n;
		if (n == 0)	break;

		ans = 0;
		for (int i = 2; i < n; i++) {
			if (!(Pnum[i]) && !(Pnum[n - i])){
				ans++;

				if (i == n - i) {
					ans++;
				}
			}
		}

		cout << ans/2 << endl;
	}

	return 0;
}

Measured memory_bytes: 1360