akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	int k,a,b;
	cin>>k>>a>>b;
	int r1=a/k;
	int r2=b/k;
	if(r1==r2&&a%k!=0)cout<<"NG\n";
	else cout<<"OK\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3652
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,W,A,B = MI()
    #最初のA列は上からB行1
    #それ以降は上からB行0,他1
    #最初のB行左からA個が1
    #それ以降左からA個が0
    ans = []
    for h in range(H):
        if h <B:
            S = "1"*A + "0"*(W-A)
        else:
            S = "0"*A + "1"*(W-A)
        ans.append(S)
    print(*ans,sep="\n")

if __name__ == '__main__':
    main()

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int count = 1; //最初から一段重ねとなるため
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n - 1; i++){
    if(a.at(i) < a.at(i + 1)){
      count++;
    }
  }
  cout << count << endl;
}

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

//     int n,k;
//     cin >> n >> k;
//     int  count = 0;
//     vector<int> a(3));

//     for (int i = 0; i < k; i++)
//     {
//         int d;
//         cin >> d;
//         for (int j = 0; j < d; j++) {
//             if (a[j] == j) a[j] += 1;
//         }
//     }

//     for (int i = 0; i < n; i++) {
//         if (a[i] == 0) count++;
//     }

//     cout << count << endl;
    

int n, k;
vector<int> d;
vector<vector<int>> a;


void input() {
    cin >> n >> k;
    d.resize(k);
    a.resize(k, vector<int>());
    for (int i = 0; i < k; i++) {
        cin >> d[i];
        a[i].resize(d[i]);
        for (int j = 0; j < d[i]; j++) {
            cin >> a[i][j];
        }
    }
}

void solve() {
    int ans = 0;
    for (int i = 1; i< n+1;i++){
        bool have = false;
        for (auto p : a) {
            for (auto v : p) {
                if (i == v) have = true;
            }
        }
        if (!have) ans++;
    }

    cout << ans << endl;
}

int main() {
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdlib>
#include<string>
#include<algorithm>
#define LL long long
#define INF 1000000009
using namespace std;
int main()
{
    LL n,a,b;
    scanf("%lld %lld %lld",&n,&a,&b);
    if(a>b||(n==1&&a!=b))
    printf("0\n");
    else
    {
        LL ans=(n-2)*b-(n-2)*a+1;
        if(ans<0)
        printf("0\n");
        else
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 998244353;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  int n,a,b; cin>>n>>a>>b;
  cout<<min(a,b)<<" "<<max(0,a+b-n)<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, M = read_int()
A = read_int()


def solve():
    ans = 'No'
    res = 0
    all = sum(A)
    for a in A:
        if a >= all / (4 * M):
            res += 1
    if res >= M:
        ans = 'Yes'
    return ans

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3768
#include <map>
#include <cstdio>
using namespace std;
void solve(int T){
	map<pair<int,int>,int>m;
	char cmd[2];
	int n;
	for(;T--;){
		scanf("%s%d",cmd,&n);
		if(*cmd=='D'){
			for(typeof(m.begin()) it=m.begin();it!=m.end();){
				if(it->second==n){
					typeof(m.begin()) it2=it;
					++it;
					m.erase(it2);
				}else{
					++it;
				}
			}
		}else if(*cmd=='R'){
			pair<int,int> f=make_pair(n,2000000000);
			typeof(m.begin()) it=m.lower_bound(f);
			if(it==m.begin()){
				puts("-1");
			}else{
				--it;
				printf("%d\n",it->first.first<=n&&n<=it->first.second ? it->second : -1);
			}
		}else if(*cmd=='W'){
			int z;
			scanf("%d",&z);
			int cur=0;
			for(typeof(m.begin()) it=m.begin();it!=m.end();++it){
				int d=it->first.first-cur;
				if(d>z)d=z;
				if(d)m[make_pair(cur,cur+d-1)]=n;
				z-=d;
				if(z==0)break;
				cur=it->first.second+1;
			}
			if(z)m[make_pair(cur,cur+z-1)]=n;
		}
	}
}
int main(){for(int T;~scanf("%d",&T)&&T;puts(""))solve(T);}

Measured memory_bytes: 1260
#include <iostream>
#include <utility>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    int n;
    cin >> n;
    
    vector<string> s_vec;
    vector<int> check_flag_s_vec;
    for(int i = 0; i < n; i++){
        string s_input;
        cin >> s_input;
        s_vec.push_back(s_input);
        //cout << "--------------- " << s_vec[i] << " ---------------" << endl;
        check_flag_s_vec.push_back(0);
    }

    int m;
    cin >> m;
    
    vector<string> t_vec;
    //vector<int> check_flag_t_vec;
    for(int i = 0; i < m; i++){
        string t_input;
        cin >> t_input;
        t_vec.push_back(t_input);
        //cout << "--------------- " << t_vec[i] << " ---------------" << endl;
        //check_flag_t_vec.push_back(0);
    }

    int ans = 0, point_loop;
    for(int i = 0; i < n; i++){
        point_loop = 0;
        if(!check_flag_s_vec[i]){
            for(int j = 0; j < n; j++){
                if(s_vec[i] == s_vec[j]){
                    point_loop++;
                    check_flag_s_vec[j] = 1;
                }
            }

            for(int k = 0; k < m; k++){
                if(s_vec[i] == t_vec[k]){
                    point_loop--;
                }
            }
            ans = max(ans, point_loop);
        }
    }

    //string ans = (a + b >= c)? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  REP(i, N) {
    int A; cin >> A;
    for (int j = 1; j <= D; j++) {
      if (j*A + 1 <= D) X++;
    }
  }
  X += N;
  cout << X << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

cnt = 0
for i in range(n):
	if i != a[i]-1:
		continue
	if i == n-1:
		a[i-1], a[i] = a[i], a[i-1] # swap
		cnt+=1
	else:
		a[i], a[i+1] = a[i+1], a[i] # swap
		cnt+=1
print(cnt)


Measured memory_bytes: 14008
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
#include<bits/stdc++.h>
using namespace std;
double sum;
int n;
double a;
int main()
{
	cin>>n;
	while(n--)
	{
		cin>>a;
		sum+=1.0*1/a;
	}
	printf("%.5f",1.0*1/sum);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int cnt[] = new int[100002];
            int n = sc.nextInt();
            for (int i = 0; i < n; i++) {
                int a = sc.nextInt();
                cnt[a]++;
            }

            int ans = 0;
            int evenCnt = 0;
            for (int i = 0; i <= 100000; i++) {
                if ( cnt[i] == 0 )
                    continue;
                if ( cnt[i] % 2 == 1 ) {
                    ans++;
                } else {
                    evenCnt++;
                }
            }

            if ( evenCnt > 0 ) {
                if ( evenCnt % 2 == 0 ) {
                    ans += evenCnt;
                } else {
                    ans += evenCnt - 1;
                }
            }
            System.out.println(ans);
        }
    }
}


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

#define IO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define m(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
typedef pair<string,int> p;
const int MAXN=1e5+10;
int a[105];
int main(){
	IO;
	int n,x,sum=0;
	cin>>n>>x;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	sort(a+1,a+1+n);
	cout<<n+(x-sum)/a[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
flag = 0
ans = 1

for i in a:
    if i == 0:
        flag = -1
        break
    if ans * i > 10 ** 18:
        flag = 1
    else:
        ans *= i

if flag == 1:
    print(-1)
elif flag == -1:
    print(0)
else:
    print(ans)

Measured memory_bytes: 21592
#abc096 b
n=int(input())
s=input()
ans=0
for i in range(1,n):
    left=set(s[:i])
    right=set(s[i:])
    cnt=0
    for j in left:
        if j in right:
            cnt+=1
    ans=max(ans,cnt)
print(ans)


Measured memory_bytes: 3060
program abc129e
  implicit none
  character(100000) :: s
  integer :: n, i
  integer(8),dimension(:,:),allocatable :: dp
  read *, s
  n = len_trim(s)
  allocate(dp(2,0:n))
  dp = 0
  dp(1,0) = 1
  do i = 1,n
     dp(1,i) = mod(merge(dp(1,i-1),dp(1,i-1)*2,s(i:i)=='0'),10**9+7)
     dp(2,i) = mod(merge(dp(2,i-1)*3,dp(1,i-1)+dp(2,i-1)*3,s(i:i)=='0'),10**9+7)
  end do
  print *, mod(sum(dp(:,n)),10**9+7)
end program abc129e


Measured memory_bytes: 2084
#include <iostream>
#include <vector>
#include <string>

using namespace std;
string str;
int idx;


int calc() {
    char c = str[idx];
    if (c == '-') {
        idx++;
        return 1-calc();
    }
    if (c == '(') {
        idx++;
        int r1 = calc();
        char cc = str[idx];
        idx++;
        if (cc == '-') {
            idx++;
        }
        int r2 = calc();
        idx++;
        if (cc == '*') {
            return r1*r2;
        }
        if (cc == '+') {
            return min(1, r1+r2);
        }
        if (cc == '-') {
            if (r1 && !r2) {
                return 0;
            } else {
                return 1;
            }
        }
    }
    idx++;
    return c == 'T' ? 1 : 0;
}

int main() {
    while (true) {
        string s;
        cin >> s;
        if (s == "#") break;
        string s1 = "", s2 = "";
        int u = 0;
        while (s[u] != '=') {
            s1 += s[u];
            u++;
        }
        u++;
        while (u < s.size()) {
            s2 += s[u];
            u++;
        }
        bool f = true;
        for (int i = 0; i < (1<<11); i++) {
            str = s1;
            for (int j = 0; j < str.size(); j++) {
                if ('a' <= str[j] && str[j] <= 'k') {
                    str[j] = ((i>>(str[j]-'a')) & 1) ? 'T' : 'F';
                }
            }
            idx = 0;
            int r1 = calc();
            str = s2;
            for (int j = 0; j < str.size(); j++) {
                if ('a' <= str[j] && str[j] <= 'k') {
                    str[j] = ((i>>(str[j]-'a')) & 1) ? 'T' : 'F';
                }
            }
            idx = 0;
            int r2 = calc();
            if (r1 != r2) {
                f = false;
                break;
            }          
        }
        if (f) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }  
    }
}

Measured memory_bytes: 1196
#include<stdio.h>

int main(){
  int a=0;
  int b=0;
  int c=0;
  scanf("%d %d %d", &a, &b, &c);

  if((a<b)&&(b<c)){
      puts("Yes");
  }
  else{
      puts("No");
  }

  return 0;
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

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

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    string s; cin >> s;
    REP(i, 1, s.size() / 2) {
        string str1 = s.substr(0, s.size()/2 - i);
        string str2 = s.substr(s.size()/2 - i, s.size()/2 - i);
        if (str1 == str2) {
            cout << str1.size() + str2.size() << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
from operator import mul
from functools import reduce
def comb2(n,r):
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

def examD():
    N, A, B = LI()
    v = LI(); v.sort(reverse = True)
    ans = sum(v[:A])/A
    d = defaultdict(int)
    for s in v:
        d[s] +=1
#    print(d)
    cur = A
    for i in v:
        if cur<=d[i]:
            break
        else:
            cur -=d[i]
    if i!=max(v):
        ansC = comb2(d[i],cur)
    else:
        ansC = 0
        for j in range(A,min(B,d[i])+1):
            ansC += comb2(d[i],j)
    print(ans)
    print(ansC)


import sys
import copy
import bisect
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;
  cout << (B % A == 0 ? A + B : B - A) << '\n';
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
int main(){
    double l;
    cin>>l;
    double v=(l*1.0)/3.0;
    double s=pow(v,3.0);
    std::cout << std::setprecision (15) << s << std::endl;

    return 0;
}

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

int main() {
    string S, T; cin >> S >> T;

    int ans = 1 << 28;
    REP(i, 0, S.size()) {
        int cnt = 0;
        REP(j, 0, T.size()) {
            if (i + j >= S.size()) {
                cnt = 1 << 28;
                break;
            }
            if (S[i + j] != T[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
N = gets.to_i
T, A = gets.split.map(&:to_i)

H = gets.split.map(&:to_i)

Diff_C = H.map{ |h| (A - (T - h*0.006)).abs }

Min_diff = Diff_C.min

p Diff_C.index(Min_diff) + 1


Measured memory_bytes: 1788
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int p[100005];
int q[100005];
int r[100005];
int app[300005];

bool cmp(int x, int y) {
    return x > y;
}

int main() {
    int x, y, a, b, c;
    scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
    for (int i = 0; i < a; i++) {
        scanf("%d", &p[i]);
    }
    for (int i = 0; i < b; i++) {
        scanf("%d", &q[i]);
    }
    for (int i = 0; i < c; i++) {
        scanf("%d", &r[i]);
    }
    sort(p, p + a, cmp);
    sort(q, q + b, cmp);
    sort(r, r + c, cmp);
    for (int i = 0; i < x; i++) {
        app[i] = p[i];
    }
    for (int i = 0; i < y; i++) {
        app[x + i] = q[i];
    }
    for (int i = 0; i < c; i++) {
        app[x + y + i] = r[i];
    }
    sort(app, app + x + y + c, cmp);
    LL ans = 0;
    for (int i = 0; i < x + y; i++) {
        ans += app[i];
    }
    printf("%lld\n", ans);
}


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

int main() {
    int N = 0;
    int cnt = 0;

    cin >> N;
    char S[N];
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    for (int i = 0; i < N/2; i++) {
        if (S[i] != S[i+N/2]) cnt++;
    }
    if (N%2!=0) cout << "No";
    else if (cnt != 0)   cout << "No";
    else if (cnt == 0)  cout << "Yes";
    return 0;
}

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


using namespace std;


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

    cout << max(0, (min(b, d) - max(a, c))) << endl;


    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    int a[1000000]={};
    a[n]++;

    int i=1;
    while(1){
        n=(n%2==0?n/2:3*n+1);
        i++;
        if(a[n]++>0){
            p(i);
            return 0;
        }
    }
} 

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define modd 998244353
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
lld n,m;
lld arr[300000];
lld par[300000];
vector<lld> adj[300000];
lld dp[300000];
bool dfs(lld node){
    //bool ret=true;
    for (auto it:adj[node]) {if (it!=par[node]) if (!dfs(it))return false;}
    lld dp2[adj[node].size()+1][arr[node]+1];
    n=adj[node].size();m=arr[node];
    rep(i,0,n) rep(j,0,m) dp2[i][j]=1e11;
    dp2[0][0]=0;
    rep(i,1,n) rep(j,0,m) {
        lld ele=adj[node][i-1];
        if (j-dp[ele]>=0) dp2[i][j]=min(dp2[i][j],dp2[i-1][j-dp[ele]]+arr[ele]);
        if (j-arr[ele]>=0) dp2[i][j]=min(dp2[i][j],dp2[i-1][j-arr[ele]]+dp[ele]);
    }
    dp[node]=1e11;
    rep(j,0,m) dp[node]=min(dp[node],dp2[n][j]);
    if (dp[node]==1e11)return false;
    return true;
}
int main()
{
     ios;
     lld TESTS,q,a,s,b,l,r,c,k,p,h,w,d,x,y,z,xs,ys,t;
     TESTS=1;
     //cin>>TESTS;
     while(TESTS--)
     {
         cin>>n;
         par[0]=-1;
         rep(i,1,n-1){
             cin>>par[i];
             par[i]--;
             //adj[i].pb(par[i]);
             adj[par[i]].pb(i);
         }
         rep(i,0,n-1)cin>>arr[i];
         (dfs(0))?cout<<"POSSIBLE":cout<<"IMPOSSIBLE";
     }
    return 0;
}


Measured memory_bytes: 12544
N = int(input())
a = [int(x) for x in input().split()]
def selectionSort(A, N):
	count = 0
	for i in range(0,N):
		minj = i
		for j in range(i,N):
			if A[minj] > A[j]:
				minj = j
		if i != minj:
			tmp = A[minj]
			A[minj] = A[i]
			A[i] = tmp
			count += 1
	return A,count
ans,c = selectionSort(a,N)
print(*ans)
print(c)

Measured memory_bytes: 7740
#include <cstdio>
#include <cstring>
#include <list>

using namespace std;

#define M 1048721
#define null (-1)
#define L 14

char H[M][L];

//??????????????°????????????

int getnumber( char c ){

    if( c == 'A' ) return 1;
    else if( c =='C' ) return 2;
    else if( c == 'G' ) return 3;
    else if( c == 'T' ) return 4;
    else return 0;

}

//???????????????key?????????

long long str_to_key( char str[] ){

    long long p = 1, sum = 0, i;
    
    for( i = 0 ; i < strlen(str) ; i++ ){

        sum += p * getnumber( str[i] ) ;

        p *= 5;

    }

    return sum;

} 

//???????????\??¢??°???????£?

int h1( int key ){

    return key % M;

}

int h2( int key ){

    return 1 + key % ( M - 1 );

} 

long long h( int key, int i ){

    return ( h1(key) + i * h2(key) ) % M ;

}

//insert

int insert( char A[] ){

    long long key, j, i;

    key = str_to_key( A );

    for( i = 0 ;; i++ ){

        j = h( key, i);

        if( strcmp( H[j] , A ) == 0 ){
        
            return 1;

        } else if( strlen(H[j]) == 0 ){

            strcpy( H[j] , A );
            return 0;

        }

    }

}

//search

int search( char A[] ){

    long long key, j, i;

    key = str_to_key( A );

    for( i = 0 ;; i++ ){

        j = h( key, i);

        if( strcmp( H[j], A ) == 0 ){

            return 1;

        } else if( strlen(H[j]) == 0 ){

            return 0;

        }

    }

    return 0;

} 

//??¬???

int main(){

    int n , i = 0;

    scanf("%d", &n);

    char str[L], cmd[10];

    for( i = 0; i < M ; i++ ) H[i][0] = '\0';

    for( i = 0 ; i < n ; i++ ){

        scanf("%s %s", cmd, str);

        if( cmd[0] == 'i' ){

            insert( str );

        }else if( cmd[0] == 'f' ){

            if( search( str ) ) printf("yes\n");
            else printf("no\n");

        }

    }

    return 0;

}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n; std::cin >> n;
    vi a(n); rep(i, n) std::cin >> a[i];

    ll ans = 0;
    rrep(i, n-1) {
        if (a[i-1] > a[i]) ans += a[i-1] - a[i], a[i] = a[i-1];
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 3988
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
	ll n,m;
	cin>>n>>m;
	vector<ll> vx;
	rep(i,0,n){
		ll a;
		cin>>a;
		vx.pb(a);
	}
	ll tot_x = 0;
	rep(i,0,vx.sz-1){
		ll a = vx[i+1]-vx[i];
		a %= MOD;
		ll r = i+1;
		ll l = vx.sz-r;
		a = a*r;
		a %= MOD;
		a = a*l;
		a %= MOD;
		tot_x += a;
		tot_x %= MOD;
	}
	vector<ll> vy;
	rep(i,0,m){
		ll a;
		cin>>a;
		vy.pb(a);
	}
	ll tot_y = 0;
	rep(i,0,vy.sz-1){
		ll a = vy[i+1]-vy[i];
		a %= MOD;
		ll r = i+1;
		ll l = vy.sz-r;
		a = a*r;
		a %= MOD;
		a = a*l;
		a %= MOD;
		a *= tot_x;
		a %= MOD;
		tot_y += a;
		tot_y %= MOD;
	}
	cout << tot_y << endl;
	return 0;
}




Measured memory_bytes: 2548
N = int(input())
word = []
for i in range(N):
    word.append(input())

if len(word) > len(set(word)):
    print('No')
else:
    success = True
    for i in range(N-1):
        if word[i][-1] != word[i+1][0]:
            success = False
            print('No')
            break
    if success:
        print('Yes')

Measured memory_bytes: 3060
# coding: utf-8

# https://atcoder.jp/contests/abc103
# 11:25-


def main():
    S = input()
    T = input()
    N = len(S)

    if S == T:
        return "Yes"

    for i in range(N):
        S = S[-1] + S[:N-1]
        if S == T:
            return "Yes"
    
    return "No"


print(main())


Measured memory_bytes: 2940
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
ans = A[0]
for i in range(1,(N - 1)//2 + 1):
    ans += A[i] * 2
if N%2 == 1:
    ans -= A[(N - 1)//2]
print(ans)

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


int main() {
    int m,f,r;
    vector<int> scores(3);
    while (true) {
        cin >> m >> f >> r;
        scores[0] = m;
        scores[1] = f;
        scores[2] = r;
        int sum = scores[0] + scores[1];
        if (scores[0]==-1 && scores[1]==-1 && scores[2]==-1) break;
        if (scores[0]==-1 || scores[1]==-1) {
            cout << 'F' << endl;
        }else if (sum>=80) {
            cout << 'A' << endl;
        }else if (sum>=65 && sum<80) {
            cout << 'B' << endl;
        }else if (sum>=50 && sum<65) {
            cout << 'C' << endl;
        }else if (sum>=30 && sum<50) {
            if (r>=50) {
                cout << 'C' << endl;
            }else{
                cout << 'D' << endl;
            }
        }else{
            cout << 'F' << endl;
        }
    }
    
    
    return 0;
}




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

int main(){
	int n,m;
	long a[511],b[50];
	int x,y;
	bool unko[50][50];
	int count = 0;
	cin >> n >> m;

	for(int i = 0; i < n;++i){
		a[i] =0;
		for(int j = 0; j < n;++j){
			unko[i][j] = 0;
		}
	}

	for(int i = 0;i < m;++i){
		cin >> x >> y;
		
		a[x]++;
		a[y]++;
	
	}

	for(int i = 1;i < n + 1;++i)
		cout << a[i] <<endl;


}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

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

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    a, b = MI()
    print(a * b)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9492
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
int v[9][2]={{-2,-2},{-1,-2},{0,-2},{-2,-1},{-1,-1},{0,-1},{-2,0},{-1,0},{0,0}};

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

    long long h,w,n;
    cin>>h>>w>>n;
    set<pair<int,int>> st;
    vector<pair<int,int>> vp(n);
    for(int i=0;i<n;i++){
        cin>>vp[i].first>>vp[i].second;
        st.insert(vp[i]);
    }
    long long ans[10]={};
    ans[0]=(h-2)*(w-2);
    set<pair<int,int>> s;
    for(int i=0;i<n;i++){
        for(int j=0;j<9;j++){
            int cnt=0;
            int y=vp[i].first+v[j][0],x=vp[i].second+v[j][1];
            pair<int,int> pp={y,x};
            if(y<=0 || x<=0 || y+2>h || x+2>w || s.count(pp))continue;
            //cout<<y<<" "<<x<<endl;
            s.insert(pp);
            for(int k=y;k<y+3;k++){
                for(int l=x;l<x+3;l++){
                    pair<int,int> p={k,l};
                    if(st.count(p))cnt++;
                }
            }
            ans[cnt]++;
        }
    }
    for(int i=1;i<10;i++)ans[0]-=ans[i];
    for(int i=0;i<10;i++)cout<<ans[i]<<endl;

}

Measured memory_bytes: 47872
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k,ans=0;
    cin >> n>> k;
    if(k==0) ans=n*n;
    else
    {
        for(int b=k+1;b<=n;b++)
        {
        ans+=(n/b)*(b-k);
        if(n%b>=k) ans+=n%b-k+1;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
A = raw_input().split()
S = []
for x in A:
    if x in ['+', '-', '*']:
        b = int(S.pop())
        a = int(S.pop())
        if x == '+':
            S.append(a + b)
        elif x == '-':
            S.append(a - b)
        else:
            S.append(a * b)
    else:
        S.append(x)

print S.pop()

Measured memory_bytes: 4212
#include<bits/stdc++.h>
#define ulli unsigned long long int
using namespace std;

bool compare(pair<int, int> p1, pair<int, int> p2){
    return p1.first < p2.first;
}

main(){

    std::ios::sync_with_stdio(0);
    std::cin.tie(0);

    int n, a[(int)2e5 + 1];
    vector< pair<int, int> >v;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        v.push_back({a[i], i + 1});
    }
    sort(v.begin(), v.end(), compare);
    for(int i = 0; i < v.size(); ++i) cout << v[i].second << " ";
    cout << '\n';
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    string s;
    cin >> s;
    int query;
    cin >> query;
    bool state = true;
    string l,r;
    rep(i,query){
        int q;
        cin >> q;
        if(q==1){
            if(state) state = false;
            else state = true;
        }
        else{
            int side;
            cin >> side;
            char c;
            cin >> c;
            if(side==1){
                if(state) l.push_back(c);
                else r.push_back(c);
            }
            else{
                if(state) r.push_back(c);
                else l.push_back(c);
            }
        }
    }
    string ans;
    reverse(l.begin(),l.end());
    ans = l+s+r;
    if(state){
        cout << ans << endl;
    }
    else{
        reverse(ans.begin(),ans.end());
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4296
package main

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

func main() {
	io, flush := NewIO()
	defer flush()

	n := io.ScanInt()
	a := io.ScanInts(n)

	sort.Ints(a)
	fmt.Println(a[len(a)-1] - a[0])
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, 0)
	for i := 0; i < y; i++ {
		str := io.ScanString()
		if strings.Contains(str, "#") {
			strs = append(strs, strings.Split(str, ""))
		}
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 2176
#include <iostream>
#include <map>
 
int main(int argc, char* argv[]) {
  std::map<char, char> m = {
      {'A', 'T'},
      {'C', 'G'},
      {'G', 'C'},
      {'T', 'A'},
  };
  char inputChar;
  std::cin >> inputChar;
  std::cout << m[inputChar] << std::endl;
  return 0;
}

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

string a,s,t;

void search(ll now,ll sum,string t)
{
    if(now==s.size())
    {
        if(sum==7) a=t+"=7";
        return;
    }
    search(now+1,sum+s[now]-'0',t+'+'+s[now]);
    search(now+1,sum-s[now]+'0',t+'-'+s[now]);
}
int main()
{
    cin>>s;
    t=s[0];
    search(1,s[0]-'0',t);
    cout<<a<<endl;
}


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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

void no(){
	cout<<"No"<<endl;
	exit(0);
}
void yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

//KUPC2017J
//AOJDSL1A
//without rank
struct unionfind{
	vi p,s;
	int c;
	unionfind(int n):p(n,-1),s(n,1),c(n){}
	int find(int a){
		return p[a]==-1?a:(p[a]=find(p[a]));
	}
	//set b to a child of a
	bool unite(int a,int b){
		a=find(a);
		b=find(b);
		if(a==b)return false;
		p[b]=a;
		s[a]+=s[b];
		c--;
		return true;
	}
	bool same(int a,int b){
		return find(a)==find(b);
	}
	int sz(int a){
		return s[find(a)];
	}
};

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n,m,q;cin>>n>>m>>q;
	
	vc<pi> dup;
	unionfind uf(n);
	rep(_,q){
		int u,v,f;cin>>u>>v>>f;
		if(f==0)
			uf.unite(u,v);
		else
			dup.eb(u,v);
	}
	
	if(m==n-1){
		if(dup.size())no();
		yes();
	}
	
	for(auto e:dup)
		if(uf.same(e.a,e.b))no();
	
	if(m<=n-uf.c+uf.c*(uf.c-1)/2)yes();
	else no();
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	string A, B, C;
	cin >> A >> B >> C;
	cout << char(A[0] - 32) << char(B[0] - 32) << char(C[0] - 32);
}


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

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

  bool can = false;
  for (int i = 0; i <= X; i++) {
    int j = X - i;
    if ((i * 2 + j * 4) == Y) {
      can = true;
    }
  }

  cout << (can ? "Yes" : "No") << endl;
  return 0;
}

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

int main()
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  printf("%d\n", (int)fmax(fmax(a * 10 + b + c, b * 10 + a + c), c * 10 + a + b));

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int h,r;
	scanf("%d%d",&h,&r);
	if(h>-r){
		printf("1\n");
	}else if(h==-r){
		printf("0\n");
	}else{
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 2660
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <set>
#include <map>
#define ll long long
#define ull unsigned long long
#define rep(i, to) for(int i = 0; i < (to); ++i)
#define rep1(i, to) for(int i = 1; i <= (to); ++i)
#define ms(x, v) memset(x, v, sizeof(x))
using namespace std;
const int N = 100005, M = 6;
char s[N];
int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
#endif
//    ios::sync_with_stdio(0);
    while(scanf("%s", s) > 0)
    {
        int n = strlen(s);
        if(s[0] != s[n - 1]) n++;
        puts((n & 1) ? "Second" : "First");
    }
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int comp(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main()
{
 int i;
  int s=0;
  int N;
  scanf("%d",&N);
  int A[N];
  long a;
  for(i=0;i<N;i++){
    scanf("%ld",&A[i]);
  }
  qsort(A,N,sizeof(int),comp);
  a=0;
  for(i=0;i<N;i++){
	if(A[i] == a){
      s--;
      a=0;
    }else{
      s++;
      a=A[i];
    }
  }
  printf("%d",s);
  return 0;
}

Measured memory_bytes: 892
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    int ans;
    if(1 <= a && a <= 9 && 1 <= b && b <= 9){
        ans = a * b;
    } else {
        ans = -1;
    }

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


Measured memory_bytes: 256
mod = 10**9 + 7

def ncr(n, r):
    r = min(r, n-r)
    x, y = 1, 1
    for i in range(r):
        x = (x * (n-i)) % mod
        y = (y * (i+1)) % mod
    
    return x * pow(y, mod-2, mod) % mod


X, Y = map(int, input().split())


if 2*Y - X < 0 or 2*X - Y < 0 or (2*Y - X) % 3 != 0 or (2*X - Y) % 3 != 0:
    print("0")
else:
    M = (2*Y - X) // 3
    N = (2*X - Y) // 3
    print(ncr(M+N,N))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define mem(a,b)   memset(a,b,sizeof(a))
#define en         cout<<endl;
#define pb         push_back
#define gcd(n,m)   __gcd(n,m)
#define lcm(n,m)   ((n)/__gcd(n,m))*(m)
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(a,b)     for(ll i=a;i<b;i++)
#define all(x)     (x).begin(),(x).end()
#define allr(x)    (x).rbegin(),(x).rend()
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long
#define PI         2*acos(0.0)


int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,c,res,c1,x,y,w,z,c2;
    ci>>n;
    vector<ll>a(n);
    f(0,n) ci>>a[i];
    res=a[0];
    f(1,n) res=gcd(res,a[i]);
    co<<res;
    return 0;
}





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

using namespace std;

const int N = 1e5+2;
long long plecak[N];
int n,w;




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

    cin >> n >> w;


    for (int i=1; i<=w; i++) plecak[i] = -1;
    
    int m;
    long long v;
    for (int i=0; i<n; i++){

        cin >> m >> v;

        for (int i=w; i>=0; i--){

            if (plecak[i] != -1){

                if (i+m <= w) plecak[i+m] = max(plecak[i] +v, plecak[i+m]);
            }
        }
    }

    long long odp=0;
    for (int i=0; i<=w; i++) odp=max(odp,plecak[i]);    
    cout << odp;
}

Measured memory_bytes: 1024
s=list(input())
ans=[]
count=0
for i in range(len(s)):
  if s[i]=='A' or s[i]=='T' or s[i]=='G' or s[i]=='C':
    count+=1
  else:
    ans.append(count)
    count=0
    
ans.append(count)    
print(max(ans))

Measured memory_bytes: 3060
n = int(input())
t, x, y = 0, 0, 0
for i in range(n):
    ti, xi, yi = map(int, input().split())
    dt = ti - t
    dx = abs(xi - x)
    dy = abs(yi - y)
    if dt >= dx + dy and dt % 2 == (dx + dy) % 2:
        t, x, y = ti, xi, yi
        continue
    print('No')
    break
else:
    print('Yes')

Measured memory_bytes: 3064
from collections import deque

N, M = map(int, input().split())
G = [deque([]) for i in range(N+1)] 

road = [input().split() for i in range(M)]

for i in range(M):
    G[int(road[i][0])].append(int(road[i][1]))
    G[int(road[i][1])].append(int(road[i][0]))     

check = [-1] * (N+1)   

def dfs(v):
    stack = deque([v])
    
    while stack:    
        tmp = stack[0]
        if G[tmp]:
            w = G[tmp].popleft() 
            if check[w] < 0:
                check[w] = tmp
                stack.append(w)
        else:
            stack.popleft()
    return check


check = dfs(1)
check[0] = 100
check[1] = 100

if -1 in check:
    print('No')
else:
    print('Yes')
    for i in range(2, N+1):
        print(check[i])

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

int main()
{
	int A, B;
	scanf("%d%d", &A, &B);

	int i, j, k;
	int num;
	for (i = A, num = 0; i <= B; i++) {
		if ((i % 10 == i / 10000) && (((i % 100) / 10) == ((i / 1000) % 10)))
			num += 1;
	}

	printf("%d\n", num);

	return 0;
}


Measured memory_bytes: 128
use std::io::Read;
use std::cmp::max;

#[allow(non_snake_case)]
fn main() {
  let mut buf = String::new();
  std::io::stdin().read_to_string(&mut buf).unwrap();
  let mut S : Vec<usize> = buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
  let N = S[0];

  let mut dp1 = vec![None; N + 1];
  let mut dp2 = vec![vec![None; N + 1];N + 1];
  {
    let s = &mut S[1 ..= 2];
    s.sort();
    let (a,b) = (s[0], s[1]);
    dp1[a].get_or_insert(0);
    dp1[b].get_or_insert(0);
    dp1[0].get_or_insert(0);
    dp2[a][b].get_or_insert(0);
  }

  let mut base = 0;
  let mut q = Vec::new();

  for i in 1 .. N {
    let s = &mut S[3 * i .. 3 * (i + 1)];
    s.sort();
    let (a,b,c) = (s[0],s[1],s[2]);
    
    if a == c {
      base += 1;
      continue;
    } else if a == b {
      for x in 1 ..= N {
        if x < a {
          if let Some(v) = dp2[x][a] {
            q.push((x, c, v + 1));
          }
        } else if x < c {
          if let Some(v) = dp2[a][x] {
            q.push((x, c, v + 1));
          }
        } else {
          if let Some(v) = dp2[a][x] {
            q.push((c, x, v + 1));
          }
        }
      }
      if let Some(v) = dp2[c][c] {
        q.push((a, a, v + 1));
      }
    } else if b == c {
      for x in 1 ..= N {
        if x < a {
          if let Some(v) = dp2[x][c] {
            q.push((x, a, v + 1));
          }
        } else if x < c {
          if let Some(v) = dp2[x][c] {
            q.push((a, x, v + 1));
          }
        } else {
          if let Some(v) = dp2[c][x] {
            q.push((a, x, v + 1));
          }
        }
      }
      if let Some(v) = dp2[a][a] {
        q.push((c, c, v + 1));
      }
    } else {
      if let Some(v) = dp2[a][a] {
        q.push((b, c, v + 1));
      }
      if let Some(v) = dp2[b][b] {
        q.push((a, c, v + 1));
      }
      if let Some(v) = dp2[c][c] {
        q.push((a, b, v + 1));
      }
    }
    
    q.push((a, b, dp1[0].unwrap()));
    q.push((a, c, dp1[0].unwrap()));
    q.push((b, c, dp1[0].unwrap()));
    
    for x in 1 ..= N {
      if let Some(v) = dp1[x] {
        for y in &[a,b,c] {
          if x < *y {
            q.push((x, *y, v));
          } else {
            q.push((*y, x, v));
          }
        }
      }
    }
    
    while let Some((a,b,v)) = q.pop() {
      if dp2[a][b].is_none() || dp2[a][b].unwrap() < v {
        let u = dp2[a][b].replace(v);
        for i in &[0, a, b] {
          let u = dp1[*i].get_or_insert(v);
          *u = max(*u, v);
        }
      }
    }
  }

  let s = S[S.len() - 1];
  println!("{}", match dp2[s][s] {
    Some(v) => base + max(v + 1, dp1[0].unwrap()),
    None    => base + dp1[0].unwrap(), 
  });
}


Measured memory_bytes: 33764