akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

const int LIM=1e6;
int a[LIM];

int main() {
	int n;
	scanf("%d", &n);
	printf("%d:", n);
	for(int i=2; i<=n/i; i++) {
		while(n%i==0) printf(" %d", i), n/=i;
	}
	if(n>1) printf(" %d", n);
	putchar('\n');
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
    int K, X;
    cin >> K >> X;
    
    string res = "No";
    if (500 * K >= X) res = "Yes";

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
H, W = map(int, input().split())
if H == 1:
    if W == 1:
        s = input()
        if s == "#":
            print("#")
        else:
            print(0)
    else:
        cnt = [0 for _ in range(W)]
        s = list(input())
        for w in range(W):
            if w == 0:
                cnt[w] += s[w+1] == "#"
            elif w == W-1:
                cnt[w] += s[w-1] == "#"
            else:
                cnt[w] += s[w+1] == "#"
                cnt[w] += s[w-1] == "#"
        for w in range(W):
            if s[w] == "#":
                cnt[w] = "#"
        ans = map(str, cnt)
        print("".join(ans))
    sys.exit(0)
if W == 1:
    cnt = [0 for _ in range(H)]
    s = []
    for h in range(H):
        s.append(input())
    for h in range(H):
        if h == 0:
            cnt[h] += s[h+1] == "#"
        elif h == H-1:
            cnt[h] += s[h-1] == "#"
        else:
            cnt[h] += s[h-1] == "#"
            cnt[h] += s[h+1] == "#"
    for h in range(H):
        if s[h] == "#":
            print("#")
        else:
            print(cnt[h])
    sys.exit(0)
    
S = []
cnt = [[0 for _ in range(W)] for _ in range(H)]
for h in range(H):
    s = list(input())
    for w in range(W):
        if w == 0:
            cnt[h][w] += s[w+1] == "#"
        elif w == W-1:
            cnt[h][w] += s[w-1] == "#"
        else:
            cnt[h][w] += s[w+1] == "#"
            cnt[h][w] += s[w-1] == "#"
    S.append(s)
    
for h in range(H):
    for w in range(W):
        if h == 0:
            cnt[h][w] += S[h+1][w] == "#"
            if w == 0:
                cnt[h][w] += S[h+1][w+1] == "#"
            elif w == W-1:
                cnt[h][w] += S[h+1][w-1] == "#"
            else:
                cnt[h][w] += S[h+1][w-1] == "#"
                cnt[h][w] += S[h+1][w+1] == "#"
        elif h == H-1:
            cnt[h][w] += S[h-1][w] == "#"
            if w == 0:
                cnt[h][w] += S[h-1][w+1] == "#"
            elif w == W-1:
                cnt[h][w] += S[h-1][w-1] == "#"
            else:
                cnt[h][w] += S[h-1][w-1] == "#"
                cnt[h][w] += S[h-1][w+1] == "#"
        else:
            cnt[h][w] += S[h+1][w] == "#"
            if w == 0:
                cnt[h][w] += S[h+1][w+1] == "#"
            elif w == W-1:
                cnt[h][w] += S[h+1][w-1] == "#"
            else:
                cnt[h][w] += S[h+1][w-1] == "#"
                cnt[h][w] += S[h+1][w+1] == "#"
            cnt[h][w] += S[h-1][w] == "#"
            if w == 0:
                cnt[h][w] += S[h-1][w+1] == "#"
            elif w == W-1:
                cnt[h][w] += S[h-1][w-1] == "#"
            else:
                cnt[h][w] += S[h-1][w-1] == "#"
                cnt[h][w] += S[h-1][w+1] == "#"
                
for h in range(H):
    s = S[h]
    for w in range(W):
        if s[w] == "#":
            cnt[h][w] = "#"
    ans = map(str, cnt[h])
    print("".join(ans))

Measured memory_bytes: 9364
#include <iostream>
#include <string>

using namespace std;

int main(){
  char s[110] = {'\0'};
  std::cin >> s;

  int evenCount = 0;
  int evenNum = 0;
  int oddCount = 0;
  int oddNum = 0;
  int size = 0;
  for(int i=0; s[i] != '\0'; i++){
    if( i%2 == 0 ){
      if( s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
        oddCount += 1;
      }
      oddNum += 1;
    }else if(i%2 == 1){
      if( s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
        evenCount += 1;
      }
      evenNum += 1;
    }
    size+=1;
  }

  if( evenCount == evenNum && oddCount == oddNum ){
    std::cout << "Yes" << '\n';
  }else{
    std::cout << "No" << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			execute(scanner);
		}
	}

	private static void execute(Scanner scanner) {
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		int z = scanner.nextInt();
		System.out.println((x - z) / (y + z));
	}
}


Measured memory_bytes: 23892
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef long long int ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define MAX ((ll)1<<(ll)31)-1
int N, K, R, S, P;
int point(char a) {
	if (a == 'r')return P;
	if (a == 's')return R;
	if (a == 'p')return S;
	return 0;
}

int main(void) {
	cin >> N >> K >> R >> S >> P;
	vector<char> T(N); rep(i, N)cin>>T[i];
	vint dp(N);
	dp[0] = point(T[0]);
	for (int i = 1; i < N ;i++) {
		if (i < K) {
			dp[i] = dp[i-1] + point(T[i]);
		}
		else {
			if (T[i - K] == T[i]) {
				dp[i] = dp[i - 1];
				T[i] = 'a';
			}
			else {
				dp[i] = dp[i - 1] + point(T[i]);
			}
		}
	}
	cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 768
while True:
    m,n=map(int,input().split())
    if m==0 and n==0:
        break
    A=[]
    B=[]
    S=0
    T=0
    V=0
    for i in range(m):
        a=int(input())
        A.append(a)
        S=S+a
    for i in range(n):
        b=int(input())
        B.append(b)
        T=T+b
    for j in range(m):
        for k in range(n):
            J=A[j]
            K=B[k]
            X=S-J+K
            Y=T-K+J
            if X==Y and V==0:
                print(J,K)
                V=1
    if V==0:
        print('-1')


Measured memory_bytes: 5600
from fractions import gcd

def ngcd(nums):
	n = 0
	for i in nums:
		n = gcd(n, i)
	return n

def resolve():
	nums = list(map(int, input().split()))
	t = ngcd(nums)
	if t != 1:
		nums = [int(i/t) for i in nums]
	if gcd(nums[0], nums[1]) == 1:
		print("YES")
	else:
		print("NO")
resolve()

Measured memory_bytes: 5076
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
int main()
{
#ifdef DEBUG
	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);
#endif
	int n;
	scanf("%d",&n);;
	int i=1;
	for(;;){
		int x=i;
		if(x%3==0){
			cout<<" "<<i;
		}
		else {
			for(;;){
				if(x%10==3){
					cout<<" "<<i;
					break;
				}
				else {
					x/=10;
					if(!x)break;;
					}
			}
		}
		if(++i>n)break;
	}
		cout<<endl;
		
		//insert code
		return 0;
	}
	//aoj1_5_d.cc

Measured memory_bytes: 1208
#include<stdio.h>
int main(){
  int e[12],i,kount=0,n=0,num;

  for(i=0;i<12;i++){
    scanf("%d",&e[i]);
  }

  while(n<12){
    num=e[n];
    for(i=0;i<12;i++){
      if(e[i]==num){
	kount++;
      }
    }
    if(kount%4!=0){
      printf("no\n");
      return 0;
    }
    n++;
    kount=0;
  }
  printf("yes\n");
  return 0;
}


Measured memory_bytes: 2680
#include <bits/stdc++.h>//coded by Nurstan ^_^

#define ll long long
#define pb push_back

#define mp make_pair
#define lb lower_bound
#define ub upper_bound

#define all(x) x.begin(), x.end()
#define F first
#define S second

// fixed << setprecision
// next_permutation(a, a + n)
// set <int> :: iterator it = x.begin(); it != x.end(); it ++

using namespace std;

inline void boost(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main(){
	boost();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	string a;
	cin >> a;
	string b;
	cin >> b;
	if(a == b) {
		cout << n;
		return 0;
	}
	int maxi = -1;
	for(int i = 1; i < n; i ++) {
		int k = i;
		int l = 0;
		int sum = 0;
		bool t = 0;
		for(int j = k; j < n; j ++) {
			if(a[j] != b[l]) {
				t = 1;
				break;
			}
			else {
				sum ++;
			}
			l ++;
		}
		if(t == 0) {
			maxi = max(maxi, sum);
		}
	}
	if(maxi != -1) {
		cout << n * 2 - maxi;
	}
	else {
		cout << n * 2;
	}
	exit(0);
}



Measured memory_bytes: 256
A,B,C=input().split()

A=str(A);B=str(B);C=str(C);
if A == B:
  if A == C:
    print('No')
  else:
    print('Yes')
else:
  if A == C:
    print('Yes')
  elif B == C:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 2940
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>

using namespace std;

int n,m,a[60],b[60],c[60],d[60],hz,r,q;

int main(){
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)scanf("%d %d",&a[i],&b[i]);
    for(int i=0;i<m;i++)scanf("%d %d",&c[i],&d[i]);
    for(int i=0;i<n;i++){
        r=0;
        for(int j=0;j<m;j++){
            q=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(j==0)hz=q;
            else{
                if(hz>q){
                    hz=q;
                    r=j;
                }
            }
            //else hz=min(abs(a[i]-c[j])+abs(b[i]-d[j]),hz);
        }
        printf("%d\n",r+1);
    }
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

vector<ll>ba(51, 0), bp(51, 0);

ll func(ll n, ll x) {

	if (n == 0) {
		return 1;
	}
	else if (x == 1) {
		return 0;
	}
	else if (x > 1 && x <= ba[n-1] + 1) {
		return func(n - 1, x - 1);
	}
	else if (x == ba[n-1]+2) {
		return bp[n - 1] + 1;
	}
	else if (x > ba[n - 1] + 2 && x < ba[n]) {
		return bp[n - 1] + 1 + func(n - 1, x - ba[n - 1] - 2);
	}
	else if (x == ba[n]) {
		return bp[n];
	}



	return 0;
}


signed main() {
	int i, j;
	ll n, x;

	cin >> n >> x;

	ba[0] = 1;
	bp[0] = 1;

	for (i = 1; i <= n; i++) {
		ba[i] = ba[i - 1] * 2 + 3;
	}

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




	cout << func(n, x) << endl;






	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
x = [list(map(int, input().split())) for _ in range(n)]
from itertools import *
res = 0
for a in product([-1, 1], [-1, 1], [-1, 1]):
    ts =[]
    for t in x:
        ta = 0
        for i,j in zip(a,t):
            ta+=i*j
        ts.append(ta)
    s = sum(sorted(ts,reverse=True)[:m])
    res = max(res, s)
print(res)

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 8010;
string S;
int x,y;
bool p[MC],q[MC],t[MC];

int main(){
	cin >> S;
	cin >> x >> y;
	int n = S.size();
	int z = 0;
	while(z < n && S[z] == 'F') ++z;
	x -= z;
	if(abs(x)>MC) return cout << "No" << endl , 0;
	p[0] = q[0] = 1;
	int r = 0;
	bool b = 0;
	for(; z < n ; ++z){
		if(S[z] == 'T'){
			if(r){
				fill(t,t+MC,0);
				repp(i,0,z){
					if(!(b?q:p)[i]) continue;
					t[i+r] = t[abs(i-r)] = 1;
				}
				swap(t,b?q:p);
			}
			r = 0;
			b = !b;
		} else {
			++r;
		}
	}
	if(r){
		fill(t,t+MC,0);
		repp(i,0,z){
			if(!(b?q:p)[i]) continue;
			t[i+r] = t[abs(i-r)] = 1;
		}
		swap(t,b?q:p);
	}
	cout << (p[abs(x)] && q[abs(y)] ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll n,m;
  cin >> n >> m;

//———————ワーシャルフロイド—————————————————————————————————

  vector<vector<ll>> dist(10,vector<ll>(10,1000000000000000000));
  rep(i,10){
    rep(j,10){
      cin>>dist[i][j];
    }
  }

  rep(i,10){
    rep(j,10){
      rep(k,10){
        dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
      }
    }
  }

  ll ans=0;
  rep(i,n){
    rep(j,m){
      int x;
      cin>>x;
      if(x==-1) continue;
      else ans+=dist[x][1];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#define LL long long
const int maxn = 200010;
const int mod = (int)(1e9 + 7);
using namespace std;

vector<pair<int, int>> bags;

int solve1(vector<pair<int, int>> b, int Bmin, int Bmax, int min_i, int max_i)
{
	int i, j, ret;
	vector<pair<int, int>> c;
	c.clear();
	for (i = 0; i < b.size(); i ++)
		if (i != min_i && i != max_i)
		{
			if (b[i].first > Bmax)
				Bmax = b[i].first;
			else if (b[i].second < Bmin)
				Bmin = b[i].second;
		}
	for (i = 0; i < b.size(); i ++)
		if (i != min_i && i != max_i)
		{
			if (b[i].first < Bmin && b[i].second > Bmax)
				c.push_back(b[i]);
		}
	if (c.size() == 0)
	{
		return ret = Bmax - Bmin;
	}
	ret = mod;
	sort(c.begin(), c.end());
	for (i = 0; i < c.size(); i ++)
	{
		if (Bmax - c[i].first < ret)
			ret = Bmax - c[i].first;
		Bmax = max(c[i].second, Bmax);
	}
	return ret;
}

void solve2(vector<pair<int, int>> b, int &Bmin, int &Rmax, int min_i, int max_i)
{
	int i, j;
	for (i = 0; i < b.size(); i ++)
		if (i != min_i && i != max_i)
		{
			Bmin = min(Bmin, b[i].second);
			Rmax = max(Rmax, b[i].first);
		}
}

int main()
{
	int N, i, j, x, y, min_i, max_i, Bmax, Bmin, Rmin, Rmax;
	int dis;
	LL ans;
	cin >> N;
	min_i = max_i = 0;
	for (i = 0; i < N; i ++)
	{
		cin >> x >> y;
		if (x > y)
			swap(x, y);
		bags.push_back(make_pair(x, y));

		if (x < bags[min_i].first)
			min_i = i;
		if (y > bags[max_i].second)
			max_i = i;
	}
	if (min_i != max_i)
	{
		Rmin = bags[min_i].first;
		Rmax = bags[max_i].second;
		Bmin = min(bags[min_i].second, bags[max_i].first);
		Bmax = max(bags[min_i].second, bags[max_i].first);
		dis = solve1(bags, Bmin, Bmax, min_i, max_i);
		ans = 1LL * dis * (Rmax - Rmin);
		
		Rmin = bags[min_i].first;
		Bmax = bags[max_i].second;
		Bmin = bags[min_i].second;
		Rmax = bags[max_i].first;

		solve2(bags, Bmin, Rmax, min_i, max_i);
		ans = min(ans, 1LL * (Bmax - Bmin) * (Rmax - Rmin));
	}
	else
	{
		Rmax = Rmin = bags[min_i].first;
		Bmin = Bmax = bags[max_i].second;

		solve2(bags, Bmin, Rmax, min_i, max_i);
		ans = 1LL * (Bmax- Bmin) * (Rmax - Rmin);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3440
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,c,d,x,y,z,p,q,r;
  cin>>a>>b>>c>>d;
  x=b*d;
  y=a*c;
  p=a*d;
  q=b*c;
  cout<<max(max(x,y),max(p,q));
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;
  cin>>k>>a>>b;
  int r;
  r=(b/k)*k;
  if(a<=r){
    cout<<"OK"<<endl;
  }
  else{
    cout<<"NG"<<endl;
  }
  
  return 0;
}

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

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

Measured memory_bytes: 256
<?php
  $s = trim(fgets(STDIN));
  $s = str_replace(array("\r\n","\r","\n"), '', $s);
  $s = explode(" ", $s);
  
  $answer_arr = [];
for ($i = 0; $i <= $s[0]; $i++) {
    $num_arr = str_split($i);
    $sum = array_sum($num_arr); 
  if ($sum <= $s[2] && $sum >= $s[1]) {
      $answer_arr[] = $i;
  }
}

echo array_sum($answer_arr);

?>

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

#define int long long

signed main(){
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
	return 0;
}

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

using namespace std;

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

	int n, x, ans = 0;
	vector <int> v;
	vector <int> c;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> x;
		v.push_back(x);
	}

	for (int i = 0; i < n; i++) {
		cin >> x;
		c.push_back(x);
	}

	for (int i = 0; i < n; i++) {
		if (v[i] - c[i] > 0) {
			ans += v[i] - c[i];
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
from math import sqrt
n=int(input())
rn=int(sqrt(n))
s=[0]*(rn+1)
s[0]=-1
s[1]=-1
t=[0]*(rn+1)
for i in range(2,rn+1):
    if s[i] != 0:
        continue
    s[i] = i
    j = i
    while j < rn + 1:
        t[j] = 1
        j *= i
    for j in range(i * i, rn + 1,i):
        if s[j] == 0:
            s[j] = i

result = 0
last = -1
for i in range(2,rn+1):
    if t[i] == 0:
        continue
    if n % i == 0:
        result += 1
        n //= i
        last =i
if n != 1 and n > rn:
    result += 1
print(result)

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

bool ok(const string &s)
{
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

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

    string s; cin >> s;
    int n = s.length();
    cout << ((ok(s) && ok(s.substr(0, (n - 1) / 2)) && ok(s.substr((n + 3) / 2 - 1))) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        x: i64,
        y: i64,
    }
    let mut num_a = x;
    let mut num_b = y;
    let mut num_c = 0;
    let mut pseudo_cost = a * x + b * y;
    loop {
        let tmp =
            a * std::cmp::max(num_a - 1, 0) + b * std::cmp::max(num_b - 1, 0) + c * (num_c + 2);
        if tmp < pseudo_cost {
            pseudo_cost = tmp;
            num_a = std::cmp::max(num_a - 1, 0);
            num_b = std::cmp::max(num_b - 1, 0);
            num_c = num_c + 2;
        } else {
            break;
        }
    }
    println!("{}", pseudo_cost);
}


Measured memory_bytes: 4352
package main

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

var graph [60][60]bool
var visited []bool

type edge struct {
	a int
	b int
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, m int
	fmt.Fscan(r, &n)
	fmt.Fscan(r, &m)

	var a, b int
	edges := make([]edge, m)
	for i := 0; i < m; i++ {
		fmt.Fscan(r, &a)
		fmt.Fscan(r, &b)
		a--
		b--

		graph[a][b] = true
		graph[b][a] = true
		edges[i] = edge{a: a, b: b}
	}

	ans := 0
	for _, e := range edges {
		// 辺を切ってみる
		graph[e.a][e.b] = false
		graph[e.b][e.a] = false

		// DFSで連結されているかをチェック
		visited = make([]bool, n)
		dfs(0, n)
		for i := 0; i < n; i++ {
			if !visited[i] {
				ans++
				break
			}
		}

		// 切った辺を戻しておく
		graph[e.a][e.b] = true
		graph[e.b][e.a] = true
	}

	fmt.Println(ans)
}

func dfs(x, n int) {
	if visited[x] {
		// すでの訪れている場合は探索終了
		return
	}

	// 連結されていることを記録
	visited[x] = true

	// 辺でつながっている次のノードを探索
	for i := 0; i < n; i++ {
		if graph[x][i] {
			dfs(i, n)
		}
	}
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 640
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int a,b,c;
  
 
   cin >> a >> b >> c;
  
   cout << c << " " << a << " "<< b <<endl;
  
   
   
  return 0;
}

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

int main(void){
    int N,K;
    cin >> N >>K;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    for(int i=0;i<N-K;i++){
        if(A.at(i)<A.at(i+K)) cout << "Yes" << endl; 
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 4048
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int count1 = 0,count2 = 0;

	for (int i = 0; i < s.length(); i++)
	{
		if(s[i] == 'a')
		{
			if (count1 < a + b) { 
				cout << "Yes\n"; 
			}
			else {
				cout << "No\n";
			}
			count1++;
		}
		else if (s[i] == 'b') {
			if (count1 < a + b && count2 < b) {
				cout << "Yes\n";
				count1++;
				count2++;
			}
			else {
				cout << "No\n";
			}
		}
		else {
			cout << "No\n";
		}
	}
	return 0;
}

Measured memory_bytes: 896
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


nums = fetch_int_input()
results = ["No", "Yes"]
val = nums[0] * nums[1] % 2
print(results[val])



Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,l[200005],r[200005];
multiset<ll>N,P;
ll sumN,sumP,ans;
int main(){
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> l[i] >> r[i];
		if(i==1){
			N.insert(1LL*l[i]);
			P.insert(1LL*l[i]);
		}
		else{
			multiset<ll>::iterator it = N.end(); it--;
			sumN += r[i]-l[i];
			sumP += r[i-1]-l[i-1];
			ll v = (*it)-sumN;
			ll v2 = (*P.begin())+sumP;
			if(v2<l[i]){
				ans+=l[i]-v2;
			}
			else if(l[i]<v){
				ans+=v-l[i];
			}
			if(v2<=l[i]){
				P.insert(l[i]-sumP);P.insert(l[i]-sumP);
				ll x = (*P.begin())+sumP;
				P.erase(P.begin());
				N.insert(x+sumN);
			}
			else if(v>=l[i]){
				N.insert(l[i]+sumN);N.insert(l[i]+sumN);
				multiset<ll>::iterator it = N.end(); it--;
				ll x = (*it)-sumN;
				N.erase(it);
				P.insert(x-sumP);
			}
			else{
				N.insert(l[i]+sumN); P.insert(l[i]-sumP);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 10368
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;

// typedef  long long int ll;
// typedef long double   ld;

#define    int                      long long int
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ppl                      pair <int , pii>
#define    sp(x)                    setprecision(x)
bool cmp(pii a ,pii b)
{
    if(a.ff==b.ff)
        return a.ss<b.ss;
    return a.ff<b.ff;
}

int32_t main()
{
    speed upp
    int a,b,n;
    cin>>n;
    vector<pii>v;
    f(i,1,n)
    {
        cin>>a>>b;
        v.pb(mp(a+b,a-b));
    }
    sort(all(v),cmp);
    int ans=1,l=v[0].ff;
    f(i,1,n-1)
    {
        b=v[i].ff;
        a=v[i].ss;
        if(l<=a)
        {
            ans++;
            l=b;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define srep(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back
#define fcout cout << fixed << setprecision(15)

using namespace std;
using ll = long long;
using P = pair<int,int>;

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

double dp[3000][3000];
int main() {
  int n;
  cin >> n;
  vector<double> p(n,0);
  rep(i,n) cin >> p.at(i);

  dp[0][0] = 1.0;
  rep(i,n) {
    rep(j,n+1) {
      if(j-1>=0) dp[i+1][j] += dp[i][j-1]*p.at(i);
      dp[i+1][j] += dp[i][j]*(1-p.at(i));
    }
  }

  double ans=0;
  srep(i,n/2+1,n+1) {
    ans+=dp[n][i];
  }
  fcout << ans << endl;

  return 0;
}


Measured memory_bytes: 70528
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (N, K) = (input[0], input[1])
print((1..<N).reduce(K){$0.0*(K-1)})


Measured memory_bytes: 7908
#include <iostream>
using namespace std;
int dp[3][3],n,a,ok;
int main(void){
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>dp[i][j];
        }
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(dp[j][k]==a)dp[j][k]=0;
            }
        }
    }
    for(int i=0;i<3;i++){
        if(dp[i][0]==0&&dp[i][1]==0&&dp[i][2]==0)ok=1;
        if(dp[0][i]==0&&dp[1][i]==0&&dp[2][i]==0)ok=1;
    }
    if(dp[0][0]==0&&dp[1][1]==0&&dp[2][2]==0)ok=1;
    if(dp[0][2]==0&&dp[1][1]==0&&dp[2][0]==0)ok=1;
    if(ok==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
from operator import mul
from functools import reduce

def cmb(n,r):
    if n < 2 :
        return 0
    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

import math

'''
def combinations_count(n, r):
    if n < 2 :
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
'''

n = int(input())
a = input().split()

dic = {}
for i in range(len(a)) :
    if a[i] in dic :
        dic[a[i]] = dic[a[i]] + 1
    else :
        dic[a[i]] = 1

#print(dic)
dicSum = {}
total = 0

for key in dic:
    dicSum[key] = cmb(dic[key], 2)
    total += dicSum[key]

#print(dicSum, total)

for i in range(n) :
    #print(total, dicSum[a[i]], combinations_count(dic[a[i]]-1, 2))
    print(total - dicSum[a[i]] + cmb(dic[a[i]]-1, 2))


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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int32_t main()
{
 int d;
 cin>>d;
 if(d==22)
  cout<<"Christmas Eve Eve Eve";
  else if(d==23)
   cout<<"Christmas Eve Eve";
   else if(d==24)
    cout<<"Christmas Eve";
    else
     cout<<"Christmas\n";   
     return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int n,a[1000000],i,j,tmp,cnt; 
  while(1){
    cnt=0;
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++)scanf("%d",&a[i]);

    for(i=0;i<n-1;i++){
      for(j=n-1;j>i;j--){
	if(a[j]<a[j-1]){
	  cnt++;
	  tmp=a[j];
	  a[j]=a[j-1];
	  a[j-1]=tmp;
	}
      }
    }

    printf("%d\n",cnt);
  }
  return 0;
}

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

int main() {
  
  int A=0, B=0, C=0;
  
  cin >> A >> B >> C;
  
  if(A<=C && C<=B) {
    
    cout << "Yes" << endl;
    
  } else {
    
    cout << "No" << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] alphabet = new char[26];
		for (int i = 0; i < s.length(); i++) {
			alphabet[s.charAt(i)-'A']++;
		}		
		boolean flag = false;
		for (int i = 0; i < alphabet.length; i++) {
			if(alphabet[i] == 1) {
				flag = true;
			}else if(alphabet[i] == 4) {
				flag = true;
			}
		}
		System.out.println((flag)?"No":"Yes");
	}

}


Measured memory_bytes: 21844
#include <stdio.h>
#include <set>
#include <algorithm>
using namespace std;

int main() {
	int X, N;
	scanf("%d%d", &X, &N);
	set<int> p{};
	for (int i = 0; i < N; i++) {
		int a;
		scanf("%d", &a);
		p.insert(a);
	}

	for (int i = 0; i <= N; i++) {
		if (p.find(X - i) == p.end()) {
			printf("%d\n", X - i);
			return 0;
		}
		if (p.find(X + i) == p.end()) {
			printf("%d\n", X + i);
			return 0;
		}
	}
}


Measured memory_bytes: 3296
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    int r, d, x, y;
    cin >> r >> d >> x;
    for (int i = 0; i < 10; i++)
    {
        y = r * x - d;
        cout << y << endl;
        x = y;
    }
}


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

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

  string a,b,c;
  while(cin>>a,a!="-"){
    cin>>b>>c;
    Int n=a.size(),m=b.size();
    
    set<char> sc(c.begin(),c.end());
    Int i=0,j=0;
    char t=b[j++];
    string ans;
    while(i<n||j<m){
      if(sc.count(t)){        
        t=a[i++];   
      }else{
        ans+=t;
        t=b[j++];
      }
    }
    
    if(!sc.count(t)) ans+=t;
    cout<<ans<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//BEGIN CUT HERE
template<typename T>
struct DiameterOfVertex{
  vector<T> vs,dp;
  vector<vector<int> > G;
  DiameterOfVertex(vector<T> vs):vs(vs),dp(vs.size()),G(vs.size()){}
  void add_edge(int u,int v){
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }
  void dfs(int v,int p,int &s){
    if(p<0) dp[v]=T(0);
    dp[v]+=vs[v];
    if(dp[s]<dp[v]) s=v; 
    for(int u:G[v]){
      if(u==p) continue;
      dp[u]=dp[v];
      dfs(u,v,s);
    }    
  }  
  T build(){    
    int s=0;
    dfs(s,-1,s);
    dfs(s,-1,s);
    return dp[s];    
  }
};
//END CUT HERE

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE

signed AGC033_C(){
  int n;
  cin>>n;
  vector<int> vs(n,1);
  DiameterOfVertex<int> G(vs);
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    G.add_edge(x,y);
  }  
  int ans=G.build();
  cout<<((ans%3!=2)?"First":"Second")<<endl;
  return 0;
}
/*
  verified on 2019/05/07
  https://atcoder.jp/contests/agc033/tasks/agc033_c
*/

signed main(){
  AGC033_C();
  return 0;
}


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

using namespace std;
#define ll long long int

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

    if (N % 2 == 0)
    {
        cout << N;
    }
    else
    {
        N *= 2;
        cout << N;
    }

    return 0;
}


Measured memory_bytes: 3516
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;

    int ans;
    FOR(i,N,1000) {
        if (i % 111 == 0) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int P = sc.nextInt();
            int Q = sc.nextInt();
            int R = sc.nextInt();
            int[] list = {P, Q, R};
            Arrays.sort(list);
            System.out.println(list[1] + list[0]);
          }
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> c(N);
  
  for (int i = 0;i < M;i++) {
    int a,b;
    cin >> a >> b;
    c.at(a-1)++;
    c.at(b-1)++;
  }
  
  for (int i = 0;i < N;i++) {
    cout << c.at(i) << endl;
  }
}


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

#define MAX_N 100000

using namespace std;

typedef long long lint;

const int MOD = (int)(1e9) + 7;

int a[MAX_N + 1];

int n;
int v[3];

lint rez;

void readFile()
{
    cin >> n;
    for(int i = 1; i <= n; i ++)
        cin >> a[i];
}

void solve()
{
    rez = 1;

    v[2] = 1;

    int a0 = 1;
    if(a[1] != 0)
        rez = 0;

    for(int i = 2; i <= n; i ++)
    {
        if(a[i] > i - 1)
            rez = 0;

        int x = 0;
        int p = 0;
        for(int j = 0; j < 3; j ++)
        {
            if(v[j] == a[i])
            {
                x ++;
                p = j;
            }
        }

     //   cout << x << " " << p << "\n";

        if(a[i] == 0)
            a0 ++;

        if(!(a[i] == 0 && a0 <= 3))
        {
            //assert(x != 0);
            rez *= x;
            rez %= MOD;
        }

        v[p] ++;
    }

    int zeros = 0;
    for(int j = 0; j < 3; j ++)
        zeros += (v[j] == 0);

    rez *= 3;
    rez %= MOD;

    if(zeros < 2)
    {
        rez = rez << 1;
        rez %= MOD;
    }
}

void printFile()
{
    cout << rez << "\n";
}

int main()
{
    readFile();

    solve();

    printFile();

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
vector<pair<ll,ll>> G[100000];
ll D[100000];


void dfs(int idx,int pair = -1)
{
	for(auto i:G[idx])
	{
		if(pair==i.first)continue;
		D[i.first] += D[idx] + i.second;
		dfs(i.first,idx);
	}
}

int main()
{
	cin >> n;
	for(int i = 0;i<n-1;i++)
	{
		ll a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		G[a].emplace_back(b,c);
		G[b].emplace_back(a,c);
	}
	ll q,k;
	cin >> q >> k;
	k--;
	dfs(k);
	while(q--)
	{
		int x,y;
		cin >> x >> y;
		x--;y--;
		cout<<D[x]+D[y]<<endl;
	}
	

}

Measured memory_bytes: 14336
#include<iostream> 
#include<string> 
#include<cstring> 
#include<algorithm> 
#define MOD 1000000007 
#define ll long long 
using namespace std; 
  
ll cache[5001][5001]; 
int N; 
string input; 
  
ll solve(int n, int k) { 
    if (n == 1 && k == 0) return 1; 
    if (n < 0 || k < 0) return 0; 
    if (n == k) return 1; 
    if (k > n) return 0; 
    ll& ret = cache[n][k]; 
    if (ret != -1) return ret; 
  
    ret = 0; 
    ret += 2 * solve(n - 1, k + 1) + solve(n - 1, max(0, k - 1)); 
    ret %= MOD; 
    return ret; 
} 
  
int main() { 
    memset(cache, -1, sizeof(cache)); 
    cin >> N; 
    cin >> input; 
  
    cout << solve(N, input.size()); 
}

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

//abc135E
int main(void) {
  int n, k, i, cou=0, tmp, mini=0;
  scanf("%d", &n);
  int a[n], b[n];
  for(i=0; i < n; i++){
    scanf("%d", &a[i]);
    b[i]=-1;
  }
  b[0]=a[0];
  for(i=1; i < n; i++){
    k=0;
    if(a[i]<=b[mini]){
      b[mini+1]=a[i],mini++;
      continue;
    }
    while(a[i] <= b[k])
      k++;
    b[k]=a[i];
    if(mini<k)mini=k;
  }
  for(i=0; i < n; i++){
    if(b[i] == -1) break;
  }
  printf("%d", i);
  return 0;
}

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

using namespace std;

const int N = 10;

vector <int> g[N];
int visited[N];
int n;

int dfs(int u) {
	bool fail = 0;
	for (int i = 0; i < n; i++) {
		if (visited[i] == 0) fail = 1;		
	}
	if (!fail) return 1;
	int ans = 0;
	for (int i = 0; i < (int)g[u].size(); i++) {
		int v = g[u][i];
		if (!visited[v]) {
			visited[v] = 1;
			ans += dfs(v);
			visited[v] = 0;
		}
	}
	return ans;
}

int main() {
	int m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		g[x - 1].push_back(y - 1);
		g[y - 1].push_back(x - 1);			
	}
	visited[0] = 1;
	int ans = dfs(0);
	printf("%d\n", ans);
	return 0;
}

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

ll mod = 998244353;
class SegmentTree {
private:
    int n;
    vector<ll> node, lazy;
    vector<bool> flag_lazy;
public:
    SegmentTree(int N) {
        n = 1;
        while (n < N) n *= 2;
        node.resize(2 * n - 1, 0);
        lazy.resize(2 * n - 1, 0);
        flag_lazy.resize(2 * n - 1, false);
    }

    void update(int i, int l, int r) {
        if (!flag_lazy[i]) return;
        node[i] += lazy[i];
        node[i] %= mod;
        if (r - l > 1) {
            lazy[2 * i + 1] += lazy[i] / 2;
            lazy[2 * i + 2] += lazy[i] / 2;
            flag_lazy[2 * i + 1] = true;
            flag_lazy[2 * i + 2] = true;
        }
        lazy[i] = 0;
    }

    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return;
        
        if (a <= l && r <= b) {
            lazy[k] += ((r - l) * (x));
            flag_lazy[k] = true;
            update(k, l, r);
        } else {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = (node[2 * k + 1] + node[2 * k + 2]) % mod;
        }
    }

    ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return 0;        
        if (a <= l && r <= b) return node[k] % mod;

        ll sum_l = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll sum_r = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return (sum_l + sum_r) % mod;
    }

    void disp() {
        for (int i : node) {
            cout << i << " ";
        }
        cout << "\n";
    }

};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int L[K], R[K];
    for (int i = 0; i < K; i++) {
        cin >> L[i] >> R[i];
    }

    SegmentTree st(N + 1);
    st.add(1, 2, 1);
    
    for (int i = 1; i < N; i++) {
        ll x = st.query(i, i + 1);
        for (int j = 0; j < K; j++) {
            int l = i + L[j];
            int r = i + R[j] + 1;
            
            st.add(min(l, N + 1), min(r, N + 1), x);
            //st.add(l, r, x);
        }
        //cout << x << "\n";
    }

    cout << st.query(N, N + 1) << "\n";

    return 0;
}

Measured memory_bytes: 11364