akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll N,K;
	ll result=1;
	cin>>N>>K;
	REP(i, N){
		 if(i==0){
		 	result*=K;
		 }
		 else{
		 	result*=(K-1);
		 }
	}
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

/**
 *
 * @author yoovraj.shinde
 */
public class Main {
    public static void main(String[] args) {
    //        if (true) return;
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s  = in.nextLine();
        int n = Integer.parseInt(s.split(" ")[0]);
        int act = 0;
        String tasks = in.nextLine();
        for (String t : tasks.split(" ")) {
            act = act + Integer.parseInt(t);
        }
        int res = n - act;
        if (res < 0) {
            System.out.println("-1");
        } else {
            System.out.println(res);
        }
        
    }

}


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

using namespace std;

const int INF = 0x3f3f3f3f;
int n, maxn1 = -INF, maxn2 = -INF, minn1 = INF, minn2 = INF, x, y;

int main() {
	scanf("%d", &n);
	while (n--) {
		scanf("%d%d", &x, &y);
		x += y;
		if (maxn1 < x) maxn1 = x;
		if (minn1 > x) minn1 = x;
		x -= y * 2;
		if (maxn2 < x) maxn2 = x;
		if (minn2 > x) minn2 = x;
	}
	printf("%d\n", max(maxn1 - minn1, maxn2 - minn2));
	return 0;
}


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


long long x[3][1000];

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

    for(int i = 0; i < N; i++){
        cin >> x[0][i] >> x[1][i] >> x[2][i];
    }

    long long ans = 0;
    for(int sign = 0; sign < (1 << 3); sign++){
        long long score[1000] = {};
        long long signs[3];
        for(int i = 0; i < 3; i++){
            if(((sign >> i) & 1) != 0){
                signs[i] = -1;
            }else{
                signs[i] = 1;
            }
        }
        //printf("%lld, %lld, %lld\n", signs[0], signs[1], signs[2]);
        for(int i = 0; i < N; i++){
            for(int j = 0; j < 3; j++){
                score[i] += signs[j] * x[j][i];
            }
        }
        sort(score, score+N, greater<long long>());
        long long tmp = 0;
        for(int i = 0; i < M; i++){
            tmp += score[i];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import           Data.Char (chr)
import           Data.List (unfoldr)

readInt  = readLn :: IO Int

main :: IO ()
main = do
  n <- readInt
  putStrLn $ reverse $ map (chr . (+96)) $ solve n

-- unfoldr :: (b -> Maybe (a, b)) -> b -> [a]
solve :: Int -> [Int]
solve = unfoldr twoSix
  where
    twoSix k | k == 0    = Nothing
             | k `mod` 26 == 0 = Just (26, (k `div` 26) - 1 )
             | otherwise = Just (k `mod` 26, k `div` 26)

Measured memory_bytes: 3820
#include <iostream>

int main() {
  unsigned N;
  std::cin >> N;
  for (unsigned k = 1; true; ++k) {
    if (k * (k + 1) / 2 >= N) {
      unsigned tmp = k * (k + 1) / 2 - N;
      for (unsigned i = 1; i < k; ++i) {
        if (i != tmp) {
          std::cout << i << std::endl;
        }
      }
      std::cout << k;
      break;
    }
  }
  return 0;
}

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

int main()
{
	int a,b;
	cin >>a>>b;

	if (a==b) {
		cout << "a == b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else {
		cout << "a < b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <utility>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define cl(a) memset((a),0,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))
#define rson(x) ((x<<1)|1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=1000000007;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
const double pi=acos(-1.0);

int n,ans;
int a[2][105];
bool vis[2][105];
int d[2][2]={1,0,0,1};
void dfs(int x,int y,int cnt)
{
    if(x==1&&y==n-1)
    {
        ans=max(ans,cnt);
        return;
    }
    rep(i,0,1)
    {
        int xi=x+d[i][0],yi=y+d[i][1];
        if(x<0||x>=2||y<0||y>=n)
            continue;
        if(!vis[xi][yi])
        {
            vis[xi][yi]=true;
            dfs(xi,yi,cnt+a[xi][yi]);
            vis[xi][yi]=false;
        }
    }
}
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        rep(i,0,1)
            rep(j,0,n-1)
                scanf("%d",&a[i][j]);
        ans=-inf;
        vis[0][0]=true;
        dfs(0,0,a[0][0]);
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

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

  vector<ull> d;
  each(i, n) {
    ull tmp;
    cin >> tmp;
    d.push(tmp);
  }

  ull result = 0;
  for (ull i=0; i < (n - 1); i++) {
    for (ull j=(i+1); j < n; j++) {
      ull r = (d[i] * d[j]);
      result += r;
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
H,W = list(map(int, input().split()))
a="#."*150
b=".#"*150
while H!=0 and W!=0:
    for i in range(H):
        if i % 2 == 0:
             print(a[0:W])
        elif i% 2==1 :
            print(b[0:W])
    print()
    H,W = list(map(int, input().split()))
        
            
       


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N,ans = 0;
    cin >> N;
    vector<ll> X(N),Y(N);

    for(ll i = 0;i < N;i++){
        cin >> X.at(i);
        Y.at(i) = X.at(i);
    }

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

    for(ll i = 0;i < N;i++){
        if(X.at(i) == Y.at(N/2-1)){
            cout << Y.at(N/2) << endl;
        }else if(X.at(i) == Y.at(N/2))
            cout << Y.at(N/2-1) << endl;
        else if(X.at(i) < Y.at(N/2-1))
            cout << Y.at(N/2) << endl;
        else if(X.at(i) > Y.at(N/2))
            cout << Y.at(N/2-1) << endl; 
    }

}

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

using namespace std;

int main(void){

    int n;

    cin >> n;
    string s,t, ans;

    cin >> s >> t;

    for(int i=0; i<n; i++){
        ans += s[i];
        ans += t[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

int main(){
 string s; cin>>s;
  ll ans=MM;
  for(ll i=0; i<s.size()-2;i++){
  ll t;
    t=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
    ans=min(abs(753-t),ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main()
{
	long long int N, X, Y, D, ans = 0;
	std::cin >> N >> D;
	long long int D2 = D * D;
	for (int i = 0; i < N; i++)
	{
		std::cin >> X >> Y;
		if (D2 >= X * X + Y * Y) ans++;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3652
//# pragma GCC optimize ("O2")
#include<iostream>
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<climits>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<iomanip>
#include<sstream>
#define out(i,a,now) for(int i=a.be[now],to=a.v[i];i;i=a.ne[i],to=a.v[i])
#define fo(i,a,b) for(i=a;i<=b;i++)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a>b?b:a)
#define mp(a,b) make_pair(a,b)
#define qk(x) memset(x,0,sizeof(x))
#define RG register
#define gs(x) (tr[tr[x].f].son[1]==x)
#define lb(x) (x&(-x))
#define mid ((l+r)>>1)
#ifdef Mogician
#endif
using namespace std;
typedef long long LL;
typedef double DB;
template <class T> void cmax(T &a,T b)
{
    a=max(a,b);
}
template <class T> void cmin(T &a,T b)
{
    a=min(a,b);
}
template <class T> void swp(T &a,T &b)
{
	T temp=a; a=b; b=temp;
}
LL a,b;
int main()
{
#ifdef Mogician
	freopen("D.out","w",stdout);
#endif
	scanf("%lld%lld",&a,&b);
	a--;b--;
	LL i,j;
	printf("99 99\n");
	fo(i,1,48)
	{
		if (i%3==0 || i%3==1)
		{
			fo(j,1,99) printf("#");
		}
		else
		{
			fo(j,1,99)
			if (j%2==0 && a)
			{
				printf(".");
				a--;
			}
			else printf("#");
		}
		printf("\n");
	}
	fo(i,1,51)
	{
		if (i%3==0 || i%3==1)
		{
			fo(j,1,99) printf(".");
		}
		else
		{
			fo(j,1,99)
			if (j%2==0 && b)
			{
				printf("#");
				b--;
			}
			else printf(".");
		}
		printf("\n");
	}
}

Measured memory_bytes: 256
x, y, a, b, c = map(int,input().split())

p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
rr = [0]
for i in r:
    rr.append(rr[-1]+i)
p = p[:x]
q = q[:y]
pq = sorted(p+q)
ppqq = [sum(pq)]
for i in pq:
    ppqq.append(ppqq[-1]-i)
result = []
for i in range(min(x+y, c+1)):
    result.append(ppqq[i]+rr[i])
print(max(result))

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int n,m;
	cin >> n >> m;
	int p[m+10];
	string s[m+10];
	rep(i,m) cin >> p[i] >> s[i];

	int ac = 0,wa = 0,cnt[n+10] = {},flag[n+10] = {};
	for(int i = 0; i < m; i++){
		if(s[i] == "AC"){
			if(!flag[p[i]]){
				ac++;
				wa += cnt[p[i]];
				flag[p[i]] = 1;
			} 
		}else{
			if(!flag[p[i]]){
				cnt[p[i]]++;
			}
		}
	}
	cout << ac << " " << wa << endl;
	return 0;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s,t1,t2;
    int n;
    cin >> n;
    cin >> s;
    s= " "+s;
    if (n%2==1) return cout << "No",0;
    for (int i=1; i<=n/2; i++) t1=t1+s[i];
    for (int i=n/2+1; i<=n ; i++) t2=t2+s[i];
    if (t1==t2) cout << "Yes";
    else cout <<"No";
}


Measured memory_bytes: 256
s = input()
q = int(input())
insts = [input().split() for _ in range(q)]

for inst in insts:
    a, b = int(inst[1]), int(inst[2]) + 1
    if inst[0] == "replace":
        p = inst[3]
        s = s[:a] + p + s[b:]
    elif inst[0] == "reverse":
        s = s[:a] + s[a:b][::-1] + s[b:]
    elif inst[0] == "print":
        print(s[a:b])

Measured memory_bytes: 6724
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#define N 1000000
#define NIL -1
using namespace std;

class Node{
public:
    int loc;
    int p,l,r;
    Node(){
        loc=p=l=r=-1;
    }
};
class Point{
public:
    int id,x,y;
    Point(){}
    Point(int id,int x,int y){
        this->id=id;
        this->x=x;
        this->y=y;
    }
    bool operator <(const Point &p) const{
        return this->id<p.id;
    }
};

int n;
Point P[N];
Node T[N];
int number=0;


bool compareX(Point &p1,Point &p2){
    return p1.x<p2.x;
}
bool compareY(Point &p1,Point &p2){
    return p1.y<p2.y;
}

int makeKDTree(int l,int r,int d){
    if(l>=r) return -1;
    int mid=(l+(r-l)/2);
    int t=number++;

    if(d%2==0){
        sort(P+l,P+r,compareX);
    }else{
        sort(P+l,P+r,compareY);
    }

    T[t].loc=mid;
    T[t].l=makeKDTree(l,mid,d+1);
    T[t].r=makeKDTree(mid+1,r,d+1);

    return t;
}
void findNode(int now,int sx,int tx,int sy,int ty,int depth,vector<int> &ans){
    int x=P[T[now].loc].x;
    int y=P[T[now].loc].y;

    if(sx<=x && x<=tx && sy<=y && y<=ty){
        //ans.push_back(P[T[now].loc]);
        ans.push_back(P[T[now].loc].id);
        //cout<<"###"<<P[T[now].loc].id<<endl;
    }
    if(depth %2 ==0){
        if(T[now].l!=-1){
            if(sx<=x) findNode(T[now].l,sx,tx,sy,ty,depth+1,ans);
        }
        if(T[now].r!=-1){
            if(x<=tx) findNode(T[now].r,sx,tx,sy,ty,depth+1,ans);
        }
    }else{
        if(T[now].l!=-1){
            if(sy<=y) findNode(T[now].l,sx,tx,sy,ty,depth+1,ans);
        }
        if(T[now].r!=-1){
            if(y<=ty) findNode(T[now].r,sx,tx,sy,ty,depth+1,ans);
        }
    }

}

int main(){
    int q;
    vector<int> ans;
    int a,b;
    int root;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        P[i]=Point(i,a,b);
        T[i].p=T[i].l=T[i].r=-1;
    }

    number=0;
    root=makeKDTree(0,n,0);

    cin>>q;
    int sx,sy,tx,ty;
    //vector<Point> ans;

    for(int i=0;i<q;i++){
        //cin>>sx>>tx>>sy>>ty;
        scanf("%d%d%d%d",&sx,&tx,&sy,&ty);
        ans.clear();
        findNode(root,sx,tx,sy,ty,0,ans);
        sort(ans.begin(),ans.end());
        for(int j=0;j<ans.size();j++){
            printf("%d\n",ans[j]);
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 24400
#include <iostream>

using namespace std;

int main()
{
	int r,g,b;
	cin >> r >> g >> b;
	int number;
	number = 100*r + 10*g + b;
	if (number%4==0){
		cout << "YES\n";
	}else{
		cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 256
import numpy as np
H,W,K = map(int,input().split())
grid = ""
for i in range(H):
    grid += input()

grid2 = []
for i in grid:
    if i == ".":
        grid2.append(1)
    else:
        grid2.append(0)
    
ans = 0
for i in range(2 ** (H+W)):
    X = np.array(grid2)
    X = X.reshape(H,W)
    pattern = []
    for j in range(H+W):
        if ((i >> j) & 1):
            pattern.append(j)
    
    h = []
    w = []
    
    for k in pattern:
        if k <= (H-1):
            h.append(k)
        else:
            k -= H
            w.append(k)
    X[h,:]=1
    X[:,w]=1
    if X.reshape(1,-1).tolist()[0].count(0) == K:
        ans += 1
        
print(ans)

Measured memory_bytes: 27184
#include <bits/stdc++.h>
#define MOD 1000000007
#define NUM 100005
using namespace std;
typedef long long lint;
lint n, k;
lint fact[NUM];
lint v[NUM];
lint sumMin, sumMax;
lint put(lint baza, lint num)
{
    lint aux = 1;
    while(num)
    {
        if(num & 1)
            aux = (1LL * aux * baza) % MOD;
        baza = (1LL * baza * baza) % MOD;
        num >>= 1;
    }
    return aux;
}
lint invmod(lint num)
{
    return put(num, MOD - 2);
}
lint comb(lint n, lint k)
{
    lint aux = (1LL * fact[n] * invmod(fact[k])) % MOD;
    aux = (1LL * aux * invmod(fact[n - k])) % MOD;
    return aux;
}
int main()
{
    //ifstream f("functii.in");
    //ofstream g("functii.out");
    cin >> n >> k;
    fact[0] = 1;
    for(int i = 1; i <= n; ++i)
        fact[i] = (fact[i - 1] * i) % MOD;
    for(int i = 1; i <= n; ++i)
        cin >> v[i];
    sort(v + 1, v + n + 1);
    for(int i = k; i <= n; ++i)
    {
        sumMax = (sumMax + v[i] * comb(i - 1, k - 1) % MOD) % MOD;

    }
    for(int i = 1; i <= n - k + 1; ++i)
    {
        sumMin = (sumMin + v[i] * comb(n - i, k - 1) % MOD) % MOD;
        //cout << v[i] << " " << comb(n - i, k - 1) << "\n";
    }

    cout << (sumMax - sumMin + MOD) % MOD;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int A[2000010];
int B[2000010];
int C[10010];

void countingSort(const int a[], int b[], int n, int k) {
//    for (int i = 0; i <= k; ++i) C[i] = 0;
    for (int j = 0; j < n; ++j) C[a[j]]++;
    for (int i = 1; i <= k; ++i) C[i] = C[i] + C[i - 1];
    for (int j = n - 1; j >= 0; --j) b[--C[a[j]]] = a[j];
}

void outputArray(int a[], int n) {
    cout << a[0];
    for (int i = 1; i < n; ++i) {
        cout << ' ' << a[i];
    }
    cout << endl;
}

int main() {
    int n, mx = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
        mx = max(mx, A[i]);
    }
    countingSort(A, B, n, mx);
    outputArray(B, n);
    return 0;
}



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




int solve() {
    
   int a,b;
   cin>>a>>b;
   if(a!=b) cout<<"No"<<endl;
   else cout<<"Yes"<<endl;


}


int main()
{
    int test = 1, tc = 0;
    //scanf("%d", &test);
   // (void)getchar();
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}

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

int main()
{int x,y;
    cin>>x>>y;
if(x<y)
{
    swap(x,y);
}
    while (y>0)
    { int r=x%y;
        x=y;
    y=r;
    }
    cout<<x<<endl;
        
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll; 
int main(void)
{
	int m1,m2,d1,d2;
	cin >> m1>>d1>>m2>>d2;
	if (m1 < m2) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


const ll mod=1e9+7;
ll fp(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1) res=(res*a)%mod;
		a=a*a%mod;
		b/=2;
	}
	return res;
}

int main() {
	IO;
	vector<ll> fact(200001, 1);
	for(int i=1;i<=200000;++i) {
		fact[i]=ll(i)*fact[i-1]%mod;
	}
	ll n,m,k;
	cin>>n>>m>>k;
	ll ways=fact[n*m-2]*fp(fact[k-2], mod-2)%mod*fp(fact[n*m-k], mod-2)%mod;
	
	ll sum_n=0;
	ll sum_m=0;
	for(ll i=1;i<m;++i) {
		sum_m+=i*(m-i)%mod;
		sum_m%=mod;
	}
	for(ll i=1;i<n;++i) {
		sum_n+=i*(n-i)%mod;
		sum_n%=mod;
	}
	ll ans=0;
	ans+=ways*(n*n)%mod*(sum_m)%mod;
	ans+=ways*(m*m)%mod*(sum_n)%mod;
	ans%=mod;
	cout<<(ans)<<"\n";
	
	return 0;
}


Measured memory_bytes: 4716
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define F(i) for(int i=0;i<n;i++)
#define Fm(i) for(int i=0;i<m;i++)
bool ok[1010]={false},ok2[1010]={false};
char c[111][111];
int main(){
	int n,m;
	cin>>n>>m;
	F(i)Fm(j)cin>>c[i][j];
	F(i)Fm(j)ok[i]|=c[i][j]=='#';
	Fm(i)F(j)ok2[i]|=c[j][i]=='#';
	F(i){
		Fm(j)if(ok[i]&&ok2[j])cout<<c[i][j];
		if(ok[i])cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	ll N, A, B;
	cin >> N >> A >> B;

	ll ans = 0;
	if (N >= A + B)
	{
		ans = N / (A + B) * A;
		N %= (A + B);
	}

	A >= N ? ans += N : ans += A;
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll ans = 0;
    for(ll i=1;i<n;i++){
        if(a[i]<a[i-1]){
            ans+=(a[i-1]-a[i]);
            a[i] = a[i-1];

        }
    }
    cout <<ans<<"\n";
}
int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    998244353;
string s;

int main()
{
	ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	cin>>s;
	int n;
	n=s.size();
	bool ok=true;
	if(s[0]=='0'||s[n-1]=='1')
	ok=false;

	for(int i=0;i<n-1;i++)
	{
		ok=ok&(!((s[i]-'0')^(s[n-2-i]-'0')));
	//	cout<<ok<<endl;
}

if(!ok)
{
	cout<<-1;
	return 0;
}
int cur=1;
for(int i=1;i<n;i++)
{
	cout<<cur<<" "<<i+1<<endl;
	if(s[i-1]=='1')
	cur=i+1;
}
}


Measured memory_bytes: 1616
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

     string s; ll k;
     cin >> s >> k;

     int b;
     for(int i=0; i<k; ++i){
         if(s[i] != '1'){b=i; break;}
     }

     cout << s[b] << endl;

    return 0;
}


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

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

int main(){
  int N;
  string s;
  
  bool pink = false;
  bool white = false;
  bool green = false;
  bool yellow = false;
  cin >> N;
  
  for(int i=0;i<N;i++){
    cin >> s;
    if(s == "P") pink = true;
    if(s == "W") white = true;
    if(s == "G") green = true;
    if(s == "Y") yellow = true;
  }
  
  if(pink && white && green && yellow){
    cout << "Four" << endl;
  }else if(pink && white && green){
    cout << "Three" << endl;
  }
  
}

Measured memory_bytes: 3540
k = int(input())
print([
    1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15,
    2, 2, 5, 4, 1, 4, 1, 51
][k - 1])


Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

long long cst[2005];
long long ccst[2005];

int main() {
	int n, x;
	long long ans = -1;
	scanf("%d%d", &n, &x);
	for(int i = 0;i < n;i++)	
		scanf("%lld", &cst[i]);
	memset(ccst, -1, sizeof ccst);
	for(int k = 0;k < n;k++) {
		long long s = 0;
		for(int i = 0;i < n;i++) {
			if(ccst[i] == -1) ccst[i] = cst[(i - k + n) % n];
			ccst[i] = min(ccst[i], cst[(i - k + n) % n]);
			s += ccst[i];
		}
		if(ans == -1) ans = s + 1LL * k * x;
		else ans = min(ans, s + 1LL * k * x);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<vector<P>> ev(n);
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        for(int j = 0; j < a; j++)
        {
            int x, y;
            cin >> x >> y;
            x--;
            ev[i].push_back(P(x, y));
        }
    }
    int ans = 0;
    for(int i = 0; i < (1 << n); i++)
    {
        vector<char> v(n, '?');
        bool flag = true;
        int tmp = 0;
        for(int j = 0; j < n; j++)
        {
            if(i >> j & 1)
            {
                if(v[j] == '0')
                {
                    flag = false;
                }
                tmp++;
                v[j] = '1';
                for(P p : ev[j])
                {
                    if(p.second == 1)
                    {
                        if(v[p.first] == '?') v[p.first] = '1';
                        else if(v[p.first] == '0')
                        {
                            flag = false;
                        }
                    }
                    else
                    {
                        if(v[p.first] == '?') v[p.first] = '0';
                        else if(v[p.first] == '1')
                        {
                            flag = false;
                        }
                    }
                }
            }
            else
            {
                if(v[j] == '1') flag = false;
            }
        }
        int cnt = 0;
        for(int k = 0; k < n; k++)
        {
            if(v[k] == '1') cnt++;
        }
        if(flag && cnt == tmp) ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		if(i%3==0){
			cout<<" "<<i;
			continue;
		}
			int num=i;
			while(num){
				if(num%10==3){
					cout<<" "<<i;
					break;
				}
				num/=10;
			}
	}
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  int a[9];
  bool c[9];
  rep(i,9) c[i] = false;
  rep(i,9) cin >> a[i];
  int b,n;
  cin >> n;
  rep(i,n){
    cin >> b;
    rep(j,9){
      if(a[j]==b){
	c[j] = true;
      }
    }
  }
  for(int i=0;i<9;i+=3){
    if(c[i] && c[i+1] && c[i+2]){
      cout << "Yes" << endl;
      return 0;
    }
  }

  for(int i=0; i<3;i++){
    if(c[i] && c[i+3] && c[i+6]){
      cout << "Yes" << endl;
      return 0;
    }
  }

  
  if(c[0] && c[4] && c[8]){
    cout << "Yes" << endl;
  }else if(c[2] && c[4] && c[6]){
      cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(2,n):
  if p[i-2] < p[i-1] and p[i-1] < p[i]:
    count += 1
  elif  p[i-2] > p[i-1] and p[i-1] > p[i]:
    count += 1
print(count)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

double syori1(double x1,double y1,double x2,double y2){		/* ÓÌ·³ðßéB*/
	return sqrt( pow( (x2-x1),2) + pow( (y2-y1),2) );
}

double syori2(double a,double b,double c){					/* ÊÏ,SðßéB*/
	double s,S;
	s=(a+b+c)/2;
	S=sqrt( s*(s-a)*(s-b)*(s-c) );
	return S;
}

double syori3(double n){	/*	¬_æ4ÊðlÌÜü	yg¢ûzn+=syori2(n) */
	n*=1000;
	n = n - (double)(int)n;
	if(n>=0.5){
		return (0.001);
	}else{
		return 0.;
	}
}

int main(){
	double	x1,y1,x2,y2,x3,y3,
			xp,yp,
			AB,BC,CA,
			AP,BP,CP,
			S[2];
	
	while( scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF ){
	
		AB=syori1(x1,y1,x2,y2);
		BC=syori1(x2,y2,x3,y3);
		CA=syori1(x3,y3,x1,y1);
		AP=syori1(x1,y1,xp,yp);
		BP=syori1(x2,y2,xp,yp);
		CP=syori1(x3,y3,xp,yp);
		
		S[0]=syori2(AB,BC,CA);
		
		S[1]  = syori2(AB,AP,BP);
		S[1] += syori2(BC,BP,CP);
		S[1] += syori2(CA,CP,AP);

		S[0] += syori3(S[0]);
		S[1] += syori3(S[1]);
		
		if( (int)(S[0]*1000)==(int)(S[1]*1000) )	/*syori3()Æ¹pµÄAë·(á¦Î 1.9999 Æ 2.0000 )ðÈñÆ©·éB*/
			printf("YES\n");
		else
			printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define mp make_pair
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
const int mod = (int)1e9 + 7;
int n, m;
string s[111];
int main () {
	cin >> n >> m;
	for(int i = 0; i < n; i++) cin >> s[i];
	sort(s, s + n);

	for(int i = 0; i < n; i++) cout << s[i];
 	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   double[] Si = new double[N];
   for(int i = 0; i<N;i++)
   {
		Si[i] = sc.nextDouble();       
   }
   double sum_re = 0.0;
   for(int i = 0; i<N;i++)
   {
		sum_re += 1/Si[i];
   }
   System.out.println(1/sum_re);
 }
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(0, 0); }
	V<V<pin>> qab(2);
	int sz = ab.size();
	qab[0].reserve(sz);
	qab[1].reserve(sz);
	for (pin& x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	int c = 0;
	for (pin& x : qab[0]) {
		int qc = (2 * x.first + x.second) % 3;
		c ^= (qc + 1);
	}
	if (!c) {
		pin ans = solve(qab[1], ex - 1);
		ans.first *= 2; ans.second *= 2; ans.second++;
		return ans;
	}
	pin ans = solve(qab[0], ex - 1);
  	c=0;
  	for (pin& x : qab[1]) {
		int qc = (2 * x.first + x.second) % 3;
		c ^= (qc + 1);
	}
  	if (!c) {
		ans.first *= 2; ans.second *= 2;
		return ans;
	}
	c = 0;
	for (pin& x : qab[1]) {
		int w = ans.second - x.second-1;
		if ((w & x.first) == w) { c ^= 1; }
	}
	ans.first *= 2; ans.first++; ans.second *= 2; ans.second -= c;
	return ans;
}
signed main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long inf = 1e17;
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 59);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}


Measured memory_bytes: 10436
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt(); 	
    int C = sc.nextInt(); 	     

      int x = A-B;
      int ans = C-x;
      if(ans>=0){
     System.out.println(ans);
      }else{
     System.out.println(0);        
}
    }
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  string s;
  cin >> n >> s;
  rep(i,s.size()) {
    int x=s[i]-'A';
    x+=n;
    x%=26;
    s[i]=(char)(x+'A');
  }
  pr(s);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace myApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            var c = int.Parse(line[2]);

            // 面積を求める
            // 1/2absinθ
            double S = a * b * Math.Sin(c * Math.PI / 180) / 2d;
            Console.WriteLine(S.ToString());

            // 周の長さ
            // L = a + b + √a*a + b*b - 2abcosθ
            double L = a + b + Math.Sqrt(a * a + b * b - 2d * a * b * Math.Cos(c * Math.PI / 180));
            Console.WriteLine(L.ToString());

            // aを底辺としたときの高さh
            // h = bsinθ
            double h = b * Math.Sin(c * Math.PI / 180);
            Console.WriteLine(h.ToString());
        }
    }
}



Measured memory_bytes: 15952
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n;
vector<int>G[100005],ve;
int cnt[100005];
int sec=-1;
void dfs(int v,int p){
	ve.push_back(v);
	cnt[v]=1;
	if(v==n-1){
		sec=ve[(SZ(ve)+1)/2];
	}
	rep(i,SZ(G[v])){
		int to=G[v][i];
		if(to!=p){
			dfs(to,v);
			cnt[v]+=cnt[to];
		}
	}
	ve.pop_back();
}
int main(){
    cin.sync_with_stdio(false);cin.tie(0);
	cin>>n;
	rep(i,n-1){
		int u,v;
		cin>>u>>v;
		--u;--v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(0,0);
//	rep(i,n){
//		cout<<cnt[i]<<' ';
//	}
//	cout<<endl;
	bool win=(cnt[sec]*2<n);
	string ans=win?"Fennec":"Snuke";
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12920
#include <bits/stdc++.h>
//#include "util.h"

#define ll long long
using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  constexpr char nl = '\n';
  const int mod = 1e9 + 7;

  int H = 0;
  int W = 0;
  int ans = 0;
  cin >> H >> W;
  vector<vector<char>> grid(H, vector<char>(W));
  vector<vector<int>> dp(H, vector<int>(W, 0));
  for (int i = 0; i < H; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < W; ++j) {
      grid[i][j] = s[j];
    }
  }

  dp[0][0] = 1;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (grid[i][j] == '#') {
        continue;
      }

      if (i > 0 && grid[i - 1][j] == '.') {
        dp[i][j] += dp[i - 1][j];
      }

      if (j > 0 && grid[i][j - 1] == '.') {
        dp[i][j] += dp[i][j - 1];
      }
      dp[i][j] %= mod;
    }
  }

  cout << dp[H - 1][W - 1] << nl;

  return 0;
}


Measured memory_bytes: 5248
N = int(input())
S = [i for i in input()]
ans = -999
for i in range(N-1):
  a = list(set(S[:i+1]))
  b = S[i+1:]
  cnt = 0
  for j in a:
    if j in b:
      cnt += 1
  if cnt > ans:
    ans = cnt
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define fi              first
#define se              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
const int N=2e5+5;
		
		
int main()
{
	 FIO;
	 ll a,b,k;
	 cin>>k;
	 cin>>a>>b;
	 
	for(ll i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			cout<<"OK";
			exit(0);
		}
	}
	cout<<"NG";
	 
	 
				
			
			 
}


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

int main(){
    string st;
    cin >> st;
    int n = st.size();
    rep(i, 10-n) st = '0' + st;
    ll ans = 0;
    rep(i, pow(2, n-1)){
        ll a = 0;
        bitset<9> b(i);
        a += (st.at(9)-'0');
        ll k = 10;
        for(int j=8; j>=0; j--){
            if(b.test(8-j)) k = 1;
            a += (st.at(j)-'0')*k;
            k *= 10;
        }
        ans += a;
    }
    cout << ans << endl;
    return 0;
}


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

int main(int argc, const char * argv[]) {
    int W, H, N;
    int plane[100][100] = {0};
    
    cin >> W >> H >> N;
    
    for (int i = 0; i < N; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        
        if (a == 1) {
            for (int j = 0; j < H; j++) {
                for (int k = 0; k < x; k++) {
                    plane[j][k] = 1;
                }
            }
        } else if (a == 2) {
            for (int j = 0; j < H; j++) {
                for (int k = x; k < W; k++) {
                    plane[j][k] = 1;
                }
            }
        } else if (a == 3) {
            for (int j = 0; j < y; j++) {
                for (int k = 0; k < W; k++) {
                    plane[j][k] = 1;
                }
            }
        } else if (a == 4) {
            for (int j = y; j < H; j++) {
                for (int k = 0; k < W; k++) {
                    plane[j][k] = 1;
                }
            }
        }
    }
    
    int count = 0;
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            if (plane[y][x] == 0) {
                count++;
            }
        }
    }
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    int N;
    int Aodd = 0;
    ll A;
    ll Amin = 1000000000;
    ll ans = 0;

    //input
    cin >> N;

    for(int i = 0; i < N; i++){
        cin >> A;
        if(A < 0){
            Aodd++;
            A *= -1;
        }
        if(Amin > A){
            Amin = A;
        }
        ans += A;
    }

    if(Aodd % 2 == 0){
        cout << ans << endl;
    }else{
        cout << ans - (2 * Amin) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int P[] = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }
        int count1 = 0;
        int count2 = 0;
        int count3 = 0;
        for (int i = 0; i < N; i++) {
            if (P[i] <= A) {
                count1++;
            } else if (P[i] <= B) {
                count2++;
            } else if (P[i] > B) {
                count3++;
            }
        }
        int min = Math.min(count1, count2);
        min = Math.min(min, count3);
        System.out.println(min);
    }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n);i++)
using ll = long long;
int main(){
    ll n,m,j=1;
    int f = 0;
    int k=0;
    vector<ll> a,b;
    cin >> n;

    rep(i,n){
        cin >> m;
        a.push_back(m);
        if(a.at(i)==j){
            j++;
            f++;
            k = i;
            b.push_back(k);
        }
    }
    


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

        ll c = n - a.at(b.back());
        cout << c << endl;
        
    }

}

Measured memory_bytes: 3564
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        int cnt = 0;

        for(int i = 0;i<n;i++){
            l[i] = sc.nextInt();
        }

        Arrays.sort(l);

        for(int i =0;i<n-1;i++){
            cnt+=l[i];
        }

        //System.out.println(cnt);
        //System.out.println(l[n-1]);

        if(cnt>l[n-1]){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }


    }
}


Measured memory_bytes: 23764
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int h, w, t[2222][2222], u[2222][2222];
char s[2222][2222];

int main(){
    scanf("%d%d", &h, &w);
    for(int i=0; i<h; i++){
        scanf("%s", s[i]);
        for(int j=0; j<w; j++){
            t[i][j] = s[i][j] == '.';
            u[i][j] = s[i][j] == '.';
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(j){
                if(t[i][j] != 0)t[i][j] += t[i][j-1];
            }
            if(i){
                if(u[i][j] != 0)u[i][j] += u[i-1][j];
            }
        }
    }
    for(int i=0; i<h; i++){
        for(int j=w-2; j>=0; j--){
            if(s[i][j] == '.')t[i][j] = max(t[i][j],t[i][j+1]);
        }
    }
    for(int i=h-2; i>=0; i--){
        for(int j=0; j<w; j++){
            if(s[i][j] == '.')u[i][j] = max(u[i][j],u[i+1][j]);
        }
    }
    int ans = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++)ans = max(ans, t[i][j] + u[i][j] -1);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 43136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b, c;
    cin >> a >> b >> c;
    reps(i, max(a, max(b, c)), 101) {
        ll v = i * 3;
        ll d = v - (a + b + c);
        if ((d >= 0) && (d % 2 == 0)) {
            cout << (d / 2) << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static void Main() {
        var s = Console.ReadLine();
        var hs = new HashSet<char>(s);
        Console.WriteLine(hs.Count == s.Length ? "yes" : "no");
    }
}

Measured memory_bytes: 13396