akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

    auto edges = vector<vector<int>>(N);
    for(int i=0; i<N; i++)
        edges[i] = vector<int>();

    for(int i=0; i<N-1; i++) {
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    auto c = vector<int>(N);
    for(int i=0; i<N; i++)
        cin >> c[i];
    sort(c.begin(), c.end(), greater<int>());

    auto degrees = vector<int>(N);
    auto assign = vector<int>(N);
    for(int i=0; i<N; i++) {
        degrees[i] = edges[i].size();
        assign[i] = -1;
    }

    int max_degree = 0;
    int max_degree_idx = 0;
    for(int i=0; i<N; i++) {
        if(degrees[i] <= max_degree)
            continue;
        max_degree = degrees[i];
        max_degree_idx = i;
    }

    auto q = queue<int>();
    q.push(max_degree_idx);

    int i = 0;
    while(!q.empty()) {
        int n = q.front();
        q.pop();

        assign[n] = c[i];
        i++;
        
        auto neighbor_d = vector<pair<int, int>>();
        for(auto e : edges[n]) {
            if(assign[e] != -1)
                continue;
            neighbor_d.push_back(pair<int, int>(degrees[e], e));
        }
        sort(neighbor_d.begin(), neighbor_d.end(), greater<pair<int, int>>());

        for(auto x : neighbor_d)
            q.push(x.second);
    }

    q = queue<int>();
    q.push(0);

    auto visited = vector<bool>(N);
    for(int i=0; i<N; i++)
        visited[i] = false;

    int count = 0;
    while(!q.empty()) {
        int n = q.front();
        q.pop();

        visited[n] = true;

        for(auto e : edges[n]) {
            if(visited[e])
                continue;

            count += min(assign[n], assign[e]);
            q.push(e);
        }
    }

    cout << count << endl;
    for(auto x : assign)
        cout << x << ' ';
    cout << endl;

    return 0;
}

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

int main(){
    ll n,d,cnt=0;
    cin>>n>>d;
    rep(i,n){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3616
from collections import defaultdict
N = int(input())
s = ["".join(sorted(list(input()))) for _ in  range(N)]

d = defaultdict(int)
ans = 0
for i in range(N):
  if s[i] in d.keys():
    ans += d[s[i]]
    d[s[i]] += 1
  else:
    d[s[i]] += 1

print(ans)

Measured memory_bytes: 19728
#include<bits/stdc++.h>
#define pb push_back
#define in insert
#define ff first
#define ss second
#define mp make_pair
#define int long long
#define uint unsigned long long
#define rep(i,x,m) for(int i=x;i<m;i++)
#define repr(i,x,m) for(int i=x;i>=m;i--)
#define MOD 1000000007
#define endl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define vi vector<int>
#define vs vector<string>
#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
using namespace std;
#define noob ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void ram5564()
{
    int row,col;
    cin>>row>>col;
    int fir=row/2+(row&1);
    int sec=row/2;
    if(row==1||col==1)
        {cout<<1;return;}
    cout<<fir*(col/2)+(col&1)*fir+(sec)*(col/2)<<endl;
    
}

signed main()
{
        noob
         
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

ll mod_pow(ll x, ll n){
    ll ret = 1;
    while(n){
        if(n&1) (ret *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

ll mod_inv(ll x){
    return mod_pow(x,mod-2);
}

const int N = 1010;
ll f[N];

ll comb(ll n, ll r){
    ll ret = f[n];
    (ret *= mod_inv(f[r])) %= mod;
    (ret *= mod_inv(f[n-r])) %= mod;
    return ret;
}

int main(){
    f[0] = 1;
    for(int i=1; i<N; ++i) f[i] = (f[i-1]*i)%mod;

    int R,C,ai,aj,bi,bj;
    cin >>R >>C >>ai >>aj >>bi >>bj;

    // vertical
    int mi = abs(ai-bi);
    int I = 1;
    for(int ii:{bi+1, R-bi}){
        if(ii < mi){
            mi = ii;
            I = 1;
        }
        else if(ii == mi) ++I;
    }

    // horizontal
    int mj = abs(aj-bj);
    int J = 1;
    for(int jj:{bj+1,C-bj}){
        if(jj < mj){
            mj = jj;
            J = 1;
        }
        else if(jj == mj) ++J;
    }

    cout << mi+mj << " " << (comb(mi+mj,mi)*I*J)%mod << endl;
    return 0;
}



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

int main(){
  string s;
  cin>>s;
  int len=s.length();
  for(int i=0;i<len-1;i++){
    if(s.at(i)==s.at(i+1)){
      cout<<i+1<<" "<<i+2<<endl;
      return 0;
    }
  }
  for(int i=0;i<len-2;i++){
    if(s.at(i)==s.at(i+2)){
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
    }
  }  
  
  cout<<-1<<" "<<-1<<endl;
  return 0;
}

  

Measured memory_bytes: 3756
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
using qll = queue<ll>;
using vb = vector<bool>;
using sll = stack<ll>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
ll INF = 1LL << 60;

void solve(long long N, long long K, string S){
    vll cnt1, cnt0;
    if(S[0]=='0')
        cnt1.push_back(0);
    ll tmp0 = 0, tmp1 = 0;
    REP(i, N){
        if(i == 0){
            if(S[i]== '0'){
                tmp0++;
            }
            else{
                tmp1++;
            }
        }
        else{//* i>= 1( i-1 valid)
            if(S[i]== '0'){
                tmp0++;
                if(S[i]!= S[i-1]){
                    cnt1.push_back(tmp1);
                    tmp1=0;
                }
            }
            else{
                tmp1++;
                if(S[i]!= S[i-1]){
                    cnt0.push_back(tmp0);
                    tmp0=0;
                }

            }
        }
    }
    if(tmp0>0){
        cnt0.push_back(tmp0);
        cnt1.push_back(0);
    }
    if(tmp1>0)
        cnt1.push_back(tmp1);
    //* do accumulate sum
    if(cnt0.size()<= K){
        cout << N << endl;
        return;
    }
    vll sum0(cnt0.size()+1, 0), sum1(cnt1.size()+1, 0);
    REP(i, cnt0.size()){
        sum0[i+1] = sum0[i]+cnt0[i];
    }
    REP(i, cnt1.size()){
        sum1[i+1] = sum1[i]+cnt1[i];
    }
    ll res = 0;
    REP(i, cnt0.size()-K+1){
        res = max(res, sum0[i+K]-sum0[i]+sum1[i+K+1]-sum1[i]);
    }
    cout << res << endl;




    //for(auto x: cnt0) cout << x << " "; cout << endl;
    //for(auto x: cnt1) cout << x << " "; cout << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    string S;
    cin >> S;
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 2292
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>

int main()
{
	std::string a, b, c;
	std::cin >> a >> b >> c;
	if (a.back() == b.front() && b.back() == c.front())
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n; cin >> n;
  map<string,int> mp;
  string tmp;
  int count = 0;
  REP(i,n){
    cin >> tmp;
    mp[tmp]++;
    count = max(count,mp[tmp]);
  }
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    if(itr->second == count)
      std::cout << itr->first << endl;
  }
}

Measured memory_bytes: 19264
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = collections.Counter(l)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))


n = II()
l = []
for _ in range(n):
	l.append(input())

c = Counter(l)
print(len(c))








Measured memory_bytes: 141968
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S, T;
    cin >> S >> T;
    rep(i, S.size()){
        if(S[i] != T[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll A, B, C, D;
ll gcd (ll a,ll b){
    return b ? gcd(b,a%b) : a;
}
ll lcm(ll a, ll b){
    return a / gcd(a,b) * b;
}
ll func(ll x){
    return x - ((x / C) + (x / D) - (x / lcm(C,D)) );
}
main(){
    
    cin >> A >> B >> C >> D;
    
    cout << func(B) - func(A-1) << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back



int main(){
    int a,b;
    cin >> a>> b;
    if(b*2>=a){
        cout << 0 << endl;
    }else{
        cout << a-b*2 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
ll ncr(ll x, ll y) {
	ll ans = 1;
	for (ll i = 1; i <= y; ++i) {
		ans *= (x - y + i);
		ans /= i;
	}

	return ans;
}
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}
int main()
{
    fio;
   int n;
   cin>>n;
   int a1[n+1][2];
   loop(i,0,n)
   {
       loop(j,0,2)
       {
           cin>>a1[i][j];
       }
   }
   bool chk = false;
   loop(i,0,n-2)
   {
       if(a1[i][0]==a1[i][1] && a1[i+1][0]==a1[i+1][1] && a1[i+2][0]==a1[i+2][1])
       {
           chk = true;
       }
   }
   if(chk)
    cout<<"Yes\n";
   else
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


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

int main() {
    int n, r;
    cin >> n >> r;
    if(n > 9){
        cout << r << endl;
    } else {
        cout << r + 100 * (10 - n) << endl;
    }
}



Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();
		if (a.equals("H")) {
			if (b.equals( "H")) {
				System.out.println("H");
			}
			else {
				System.out.println("D");
			}
		}
		if (a.equals("D")) {
			if (b.equals( "H")) {
				System.out.println("D");
			}
			else {
				System.out.println("H");
			}
		}
	}
}


Measured memory_bytes: 19412
#include <stdio.h>
int main(void){
    int n,ans=0;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    for(int i=0; i<n; i++){
        if(s[i]!=s[i+1])
            ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define     debug       printf("\n<<CameHere<<\n")
#define     mem(x,y)    memset(x, y, sizeof(x))
#define     all(qz)     qz.begin(),qz.end()
#define     rall(qz)    qz.rbegin(),qz.rend()
#define     inf         LLONG_MIN
#define     INF         LLONG_MAX
#define     mod         1000000007
#define     Sqr(x)      ((x)*(x))
#define     ll          long long
#define     mk          make_pair
#define     pb          push_back
#define     pi          acos(-1.0)
#define     cos(a)      cos(a*pi/180)
#define     sin(a)      sin(a*pi/180)
#define     tan(a)      tan(a*pi/180)

ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
/*---------AL ASAD NUR RIYAD------------*/


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) cin>>v[i];
    sort(v.rbegin(),v.rend());
    ll cnt=v[0];
    for(ll i=1,j=1;i<n-1;){
        if(i<n-1){
            cnt+=v[j];
            i++;
        }
        if(i<n-1){
            cnt+=v[j];
            i++;
        }
        j++;
    }
    cout<<cnt<<endl;
    return 0;
}


















Measured memory_bytes: 4792
# 入力
n,m = map(int,input().split())
ans = 0

l = [-1]*n
for i in range(m):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and n > 1:
        ans = -1
    if l[s-1] == -1 or l[s-1] == c:
        l[s-1] = c
    else:
        ans = -1

if ans >= 0:
    a = ""
    if l[0] == -1 and n != 1:
        a += "1"
    elif l[0] == -1 and n == 1:
        a += "0"
    else:
        a += str(l[0])
    for i in range(1,n):
        if l[i] == -1:
            a += str(0)
        else:
            a += str(l[i])
    ans = int(a)

print(ans)


Measured memory_bytes: 38384
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    a = nl()
    e = 0
    for x in a:
        e ^= x
    b = [e^x for x in a]
    print(*b)
    return

solve()


Measured memory_bytes: 31472
#include<stdio.h>
int main (){
  char s[11]={0};
  int a=0,b=0;
  scanf ("%s",s);
  for (int i=0;i<10;i++){
    if (s[i]=='A' || s[i]=='G' || s[i]=='C' || s[i]=='T'){

a++;

    
    }
    else {
    a=0;
      
    }
    if (b<a) b=a;
}
      

    printf ("%d",b);
  return 0;
  }

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

class union_find{
public:
	int n;
	vector<int> parent;
	union_find(int _n):n(_n){
		parent.resize(n);
		rep(i, n){
			parent[i]=i;
		}
	}

	int get_parent(int x){
		if(parent[x]==x)return x;
		return parent[x] = get_parent(parent[x]);
	}

	bool is_same(int a, int b){
		int ap = get_parent(a);
		int bp = get_parent(b);
		return ap == bp;
	}

	void merge(int a, int b){
		int ap = get_parent(a);
		int bp = get_parent(b);
		if(ap==bp)return;
		parent[bp] = ap;
	}

};

int main(){
	int n;
	int m;
	cin >> n >> m;
	union_find uni(n);
	rep(i, m){
		int a, b;
		cin >> a >> b;
		uni.merge(a, b);
	}
	int q;
	cin >> q;
	rep(i, q){
		int a, b;
		cin >> a >> b;
		cout << (uni.is_same(a, b)?"yes":"no") << endl;
	}
	return 0;
}



Measured memory_bytes: 3088
#!/usr/bin/python3

def ceil(x):
    if x % 10 == 0:
        return x
    else:
        return x // 10 * 10 + 10


def main():
    data = [int(input()) for _ in range(5)]

    firstdigit = [i % 10 if i % 10 != 0 else 10 for i in data]
    index = firstdigit.index(min(firstdigit))

    totaltime = 0
    for i, time in enumerate(data):
        if i == index:
            totaltime += time
        else:
            totaltime += ceil(time)

    print(totaltime) 


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.*;
public class Main  
{ 
    static boolean isPalindrome(String str)
    {
      	StringBuilder sb = new StringBuilder(str);
      	String st = sb.reverse().toString();
      	return st.equals(str);
    }  
    public static void main(String[] args) 
    { 
        Scanner sc =new Scanner(System.in);
        String str = sc.next();
        int N = str.length();
      	String s = str + " ";
      	int q =(N-1)/2 , p = (N+3)/2;
        if(isPalindrome(str) && isPalindrome(str.substring(0,q)) && isPalindrome(s.substring(p-1,str.length())))
        {
          	System.out.println("Yes");
        }
      else
      {
        System.out.println("No");
      }
    } 
} 

Measured memory_bytes: 22868
from numpy import zeros, roll

mod = 998244353

N, *A = map(int, open(0))

S = sum(A)

dp1 = zeros(S + 1, dtype=int)
dp1[0] = 1

dp2 = zeros(S + 1, dtype=int)
dp2[0] = 1

for a in A:
    dp1 = (2 * dp1 + roll(dp1, a)) % mod
    dp2 = (dp2 + roll(dp2, a)) % mod

M = (S + 1) // 2

res = 3 * dp1[M:].sum()
if S % 2 == 0:
    res -= 3 * dp2[M]

print((pow(3, N, mod) - res) % mod)

Measured memory_bytes: 30912
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) begin(x),end(x)
#define oo(i,a) for (int i = 0; i < (a); i++)
#define ooo(i,a,b) for (int i = a; i < (b); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const char newl = 10;
const int MOD = 998244353;
const int N = 100005;
// set N | watch out for overflow | n == 1 |
void run(){
   string s;
   cin >> s;
   bool pass = 1;
   if (s[2] != s[3]) pass = 0;
   if (s[4] != s[5]) pass = 0;
   for (int i = 0; i < 5; i++){
      for (int j = i + 1; j < 6; j++){
         if (i == 2 && j == 3) continue;
         if (i == 4 && j == 5) continue;
         if ((i == 2 || i == 3) && (j == 4 || j == 5) ) continue;
         if (s[i] == s[j]) pass = 0;
      }
   }
   if (pass) cout << "Yes" << newl;
   else cout << "No" << newl;
   return ;
}
int main(){
   ios_base::sync_with_stdio(0);
   cout.tie(0);cin.tie(0);
   int t = 1;
   // cin >> t;
   for (int tc = 1; tc <= t; tc++) {
      // cout << "Case #" << tc << ": ";
      run();
   }
   return 0;
}

Measured memory_bytes: 256
s = gets.chomp.chars
if s.uniq.size != 2
  puts "No"
else
  if (s[0] == s[1] && s[2] == s[3]) || (s[0] == s[2] && s[1] == s[3] || s[0] == s[3] && s[1] == s[2])
    puts "Yes"
  else
    puts "No"
  end
end

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

int main() {
  int n,m;
  cin >> n >> m;
  priority_queue<P, vector<P>, greater<P>> q;
  rep(i,0,n) {
    ll a; int b;
    cin >> a >> b;
    q.push(P(a,b));
  }
  ll ans = 0;
  while(m > 0) {
    P p = q.top(); q.pop();
    ans += p.first * min(m,p.second);
    m -= p.second;
  }
  cout << ans << endl;
  return 0;
}


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

int X, Y, Z;

int main() {
    cin >> X >> Y >> Z;

    int cnt = 0;
    while (X >= Z + (Z + Y)*cnt) {
        cnt++;
    }

    cout << cnt - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,k;
    while(cin>>n>>k){
        vi a(n); forn(i,n) cin>>a[i];
        sort(all(a));
        ll sum = 0;
        forn(i,k) sum+=a[i];
        cout<<sum<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3664
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String h = sc.next();
      	String haiku = "";
      	for(int i = 0; i < h.length(); i++){
        	if(h.charAt(i) == ','){
            	haiku += " ";
            }else{
            	haiku += h.charAt(i);
            }
        }
      	System.out.println(haiku);
    }
}

Measured memory_bytes: 39316
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define ull unsigned long long
#define EPS 1e-8
using namespace std;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const double pi = acos(-1.0);
int read()
{
	int ret=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret;
}
const int MAX_N=55;
struct Node
{
	int x,y;
}node[MAX_N];
vector <int>  recx,recy;
ull ans=4e18;
int n,k;
int main()
{
 	#ifdef TEST
	 	freopen("input.txt","r",stdin);
	#endif
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&node[i].x,&node[i].y);
		recx.push_back(node[i].x);
		recy.push_back(node[i].y);
	}
	sort(recx.begin(),recx.end());
	sort(recy.begin(),recy.begin());
	recx.erase(unique(recx.begin(),recx.end()),recx.end());
	recy.erase(unique(recy.begin(),recy.end()),recy.end());
	for(int i=0;i<recx.size();i++)
	{
		for(int ii=i+1;ii<recx.size();ii++)
		{
			for(int j=0;j<recy.size();j++)
			{
				for(int jj=j+1;jj<recy.size();jj++)
				{
					if((ull)abs(recx[i]-recx[ii])*(ull)abs(recy[j]-recy[jj])>=ans)
							continue;
					int cnt=0;
					for(int kk=0;kk<n;kk++)
					{
						if(node[kk].x>=min(recx[i],recx[ii])&&node[kk].x<=max(recx[i],recx[ii])&&node[kk].y>=min(recy[j],recy[jj])&&node[kk].y<=max(recy[j],recy[jj]))
						{
								cnt++;
								if(cnt>=k)
								{
									break;
								}
						}	
					}
					if(cnt>=k)
					{
						ans=(ll)abs(recx[i]-recx[ii])*(ll)abs(recy[j]-recy[jj]);
					}	
				} 
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}



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

class Program
{
    static void Main()
    {
        int[] ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int A = ab[0];
        int B = ab[1];

        if (A <= 8 && B <= 8)
        {
            Console.WriteLine("Yay!");
        }
        else
        {
            Console.WriteLine(":(");
        }
    }
}



static class MathUtil
{
    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}



Measured memory_bytes: 13268
def main():
    H,W,K=map(int,input().split())
    HW = [input() for _ in range(H)]
    ans = 0
    for h in range(1<<H):
        for w in range(1<<W):
            tmp = 0
            for i in range(H):
                for j in range(W):
                    if ((h>>i)&1)==0 and ((w>>j)&1)==0 and HW[i][j]=="#":
                        tmp += 1
            if K == tmp:
                ans += 1
    print(ans)

main()

Measured memory_bytes: 9200
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }
    
    return;
}
 

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    for(int i=1;i<10000;i++){
        if((int)(i*0.08)==a &&(int)(i*0.1)==b){
            printf("%d",i);
            return 0;
        }
    }
    printf("-1");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
map<LL,LL>u;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n>>m;
    s=0;
    for(i=0; i<n; i++)
    {
        cin>>o;
        if(u[o]==0)
        {
            s++;
        }
        u[o]++;
    }
    for(MLL it=u.B; it!=u.E; it++)
    {
        v.PSB(it->SE);
    }
    sort(v.B,v.E);
    for(i=0,k=0;i<s-m;i++)
    {
        k+=v[i];
    }
    cout<<k<<endl;
    return 0;
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int n,m;
	cin>>n>>m;
	pair<ll,ll> ans={1,n};
	for(int i=0;i<m;++i){
		ll x,y;cin>>x>>y;
		ans.ff=max(ans.ff,x);
		ans.ss=min(ans.ss,y);
	}
	if(ans.ss>=ans.ff)
		cout<<ans.ss-ans.ff+1<<endl;
	else
		cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 384
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

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

  int ans;
  if (N == 1 && M == 1) {
    ans = 1;
  } else if (N == 1) {
    ans = M - 2;
  } else if (M == 1) {
    ans = N - 2;
  } else {
    ans = (N - 2) * (M - 2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n;
    cin >> n;

    vector<int> a(n + 2);
    for (int i = 0; i < n; i++) {
        cin >> a[i + 1];
    }
    a[0] = a[n + 1] = 0;

    vector<int> b(n + 2);
    for (int i = 1; i < n + 2; i++) {
        b[i] = abs(a[i] - a[i - 1]);
    }

    for (int i = 1; i < n + 2; i++) {
        b[i] += b[i - 1];
    }

    for (int i = 0; i < n; i++) {
        cout << b[i] + abs(a[i] - a[i + 2]) + (b[n + 1] - b[i + 2]) << '\n';
    }
    cout << flush;

    return 0;
}

Measured memory_bytes: 2048
# https://atcoder.jp/contests/abc145/tasks/abc145_a
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    r = int(input())
    print(r * r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
string S0, T;

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> S0 >> T;
  if (S0 == T) {
    cout << 0 << "\n";
    return 0;
  }
  vector<int> A;
  rep(i, N) if (i==0 || T[i-1]!=T[i]) A.pb(i);

  vector<int> B(A.size());
  int pos = N-1;
  for (int j=A.size()-1; j>=0; j--) {
    int i = A[j];
    pos = min(pos, i);
    while (pos >= 0 && S0[pos] != T[i]) pos--;
    if (pos == -1) {
      cout << -1 << "\n";
      return 0;
    }
    B[j] = pos--;
  }
  //cout<<"["; for (int x : A)cout<<x<<",";cout<<"]\n";
  //cout<<"["; for (int x : B)cout<<x<<",";cout<<"]\n";

  int i = 0;
  rep(x, A.size()) while (x>=i && A[x-i]+i > B[x]) i++;
  i++;
  cout << i << "\n";
  return 0;
}


Measured memory_bytes: 11156
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int ,int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N;
	cin >> N;
	vector<int> vec(N);
	rep(i,0,N){
		cin >> vec[i];
		vec[i]--;
	}
	int cnt = 0;
	int now = vec[0];
	while(cnt <= N){
		cnt++;
		if (now == 1){
			cout << cnt << endl;
			return 0;
		}
		now = vec[now];
	}
	cout << "-1\n";
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  ll n;
  cin>>n;
  ll ans=0;
  rep(i,n){
    ans+=i;
  }

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

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

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	string s;
	cin >> s;
	int n = s.size();
	puts(n % 2 == (s[0] == s[n - 1]) ? "Second" : "First");
	
}



}
int main() try{
//	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int w,h,n,x,y,a;
    cin >> w >> h >> n;
    int a1 = 0,a2 = w,a3 = 0,a4 = h;
    rep(i, n){
        cin >> x >> y >> a;
        switch (a) {
            case 1:
                if (a1 < x) {
                    a1 = x;
                }
                break;
            case 2:
                if (a2 > x) {
                    a2 = x;
                }
                break;
            case 3:
                if (a3 < y) {
                    a3 = y;
                }
                break;
            case 4:
                if (a4 > y) {
                    a4 = y;
                }
                break;
        }
    }
    if (a2 - a1 > 0 && a4 - a3 > 0) {
        cout << (a2 - a1) * (a4 - a3) << endl;
    }else{
        cout << 0 << endl;
    }
    
}


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

#define int long long
#define double long double

using namespace std;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e9;

signed main() {

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

	rep(i, 100000){
		if(a % 2 || b % 2 || c % 2){
			cout << i << endl; return 0;
		}
		int ha = a / 2, hb = b / 2, hc = c / 2;
		a = hb + hc; b = ha + hc; c = ha + hb;
	}

	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
<?php
	fscanf(STDIN, "%d", $n);

	$x = array();
	$y = array();
	for ($i = 0; $i < $n; $i++) {
		fscanf(STDIN, "%d %d", $x[$i],$y[$i]);
	}

	// 総当たりパターン数
	$k = 1;
	for ($i = $n; $i > 0; $i--) {
		$k *= $i;
	}

	// 距離配列
	$distance_array = array();
	$distance_total = 0;

	// 距離を求める
	$diff_pettern = 0;
	for ($i = 0; $i < $n; $i++) {
		for ($j = $i+1; $j < $n; $j++) {
			$distance_array[$diff_pettern] = sqrt(pow(($x[$i] - $x[$j]), 2) + pow(($y[$i] - $y[$j]), 2));
			$distance_total += $distance_array[$diff_pettern];
			$diff_pettern++;
		}
	}

	$cond_num = ($k * ($n-1)) / $diff_pettern;

	echo ($cond_num * $distance_total / $k);




Measured memory_bytes: 3956
import bisect
import sys

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

A, B, Q = map(int, input().split())

shrines = []
for i in range(A):
    shrines.append(int(input()))

temples = []
for i in range(B):
    temples.append(int(input()))

shortest_s_to_t = {}
for shrine in shrines:
    index = bisect.bisect_left(temples, shrine)
    if index == 0:
        distance = abs(shrine - temples[index])
        shortest_s_to_t[shrine] = distance
    elif index == B:
        distance = abs(shrine - temples[index - 1])
        shortest_s_to_t[shrine] = distance
    else:
        distance_left = abs(shrine - temples[index - 1])
        distance_right = abs(shrine - temples[index])
        shortest_s_to_t[shrine] = min(distance_left, distance_right)

shortest_t_to_s = {}
for temple in temples:
    index = bisect.bisect_left(shrines, temple)
    if index == 0:
        distance = abs(temple - shrines[index])
        shortest_t_to_s[temple] = distance
    elif index == A:
        distance = abs(temple - shrines[index - 1])
        shortest_t_to_s[temple] = distance
    else:
        distance_left = abs(temple - shrines[index - 1])
        distance_right = abs(temple - shrines[index])
        shortest_t_to_s[temple] = min(distance_left, distance_right)

for i in range(Q):
    x = int(input())

    # shrine to temple
    index = bisect.bisect_left(shrines, x)
    ans = 10**11
    if index > 0:
        left_shrine = shrines[index - 1]
        candidate = abs(x - left_shrine) + shortest_s_to_t[left_shrine]
        ans = min(ans, candidate)
    if index < A:
        right_shrine = shrines[index]
        candidate = abs(x - right_shrine) + shortest_s_to_t[right_shrine]
        ans = min(ans, candidate)

    # temple to shrine
    index = bisect.bisect_left(temples, x)
    if index > 0:
        left_temple = temples[index - 1]
        candidate = abs(x - left_temple) + shortest_t_to_s[left_temple]
        ans = min(ans, candidate)
    if index < B:
        right_temple = temples[index]
        candidate = abs(x - right_temple) + shortest_t_to_s[right_temple]
        ans = min(ans, candidate)

    print(ans)

Measured memory_bytes: 35368
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

  vector<size_t> P;
  for (size_t i = 0; i < N; i++) {
    size_t p;
    cin >> p;
    P.emplace_back(p);
  }

  vector<size_t> sp(P.size());
  copy(P.begin(), P.end(), sp.begin());

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

  size_t count = 0;
  for (size_t i = 0; i< N; i++) {
    if (P[i] != sp[i]) {
      count++;
    }
  }

  if (count <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" <<endl;
  }

  return 0;
}

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

int main() {
  int N;
  cin>>N;
  int Z=0;
  if(N>=105){
    Z++;
  }
  if(N>=135){
    Z++;
  }
  if(N>=165){
    Z++;
  }
  if(N>=189){
    Z++;
  }
  if(N>=195){
    Z++;
  }
  cout<<Z<<endl;
}


Measured memory_bytes: 256