akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll n, i, now = 1, cnt = 0;
  scanf("%lld", &n);
  bool flg[n + 1];
  ll a[n + 1];
  for(i = 0; i <= n; ++i) flg[i] = false;
  flg[1] = true;
  for(i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
  }
  while( 1 ) {
    if(now == 2) break;
    else if(flg[a[now]]) {
      printf("-1");
      return 0;
    } else {
      cnt++, now = a[now], flg[now] = true;
    }
  }
  printf("%lld", cnt);
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{

  int day;
  scanf("%d",&day);
if(22<=day<=25)
{
  switch(day) {
    case 22:
    printf("Christmas Eve Eve Eve\n");
    break;

    case 23:
    printf("Christmas Eve Eve\n");
    break;

    case 24:
    printf("Christmas Eve\n");
    break;

    case 25:
    printf("Christmas\n");
    break;

    default:
    printf("error\n");

  }
}else{
  printf("error\n");
}

  return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		char c[] = fs.next().toCharArray();
		if(c[2]==c[3]&&c[4]==c[5]) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 23252
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int fib[N+1];
    fib[0]=1;
    fib[1]=1;
    for(int i=2;i<=N;i++){
        fib[i] = fib[i-1] + fib[i-2];
    }
    cout << fib[N] << endl;
}


Measured memory_bytes: 3144
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int x[n];
    for (int i=0; i<n; i++) {
        cin >> x[i];
    }
    int min_tairyoku = n*10000;
    for (int p=1; p<101; p++) {
        int sum = 0;
        for (int i=0; i<n; i++) {
            sum += (x[i]-p)*(x[i]-p);
        }
        min_tairyoku = min(sum, min_tairyoku);
    }
    cout << min_tairyoku << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long N;

int main(void)
{
	cin >> N;
	
	long long a, b, n, w, h;
	for(n = 1; n <= 3500; n++){
		for(w = 1; w <= 3500; w++){
			a = n * w * N;
			b = 4 * n * w - n * N - w * N;
			if(b == 0) continue;
			if(a % b == 0){
				h = a / b;
				if(h > 0) goto end;
			}
		}
	}
	
	end:
	cout << h << " " << n << " " << w << endl;
	return 0;
}

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

namespace sandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            var consoleReader = new ConsoleReader(Console.In);
            var A = consoleReader.Int;
            var B = consoleReader.Int;
            Console.WriteLine(new[] { A + B, A * B, A - B }.Max());
        }
    }

    class ConsoleReader
    {
        private Queue<string> queue = new Queue<string>();
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (queue.Count > 0) return queue.Dequeue();
                var line = textReader.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 1; i < line.Length; i++) queue.Enqueue(line[i]);
                return line[0];
            }
        }
        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}


Measured memory_bytes: 13396
/*
author: Apoorv Singh
*/

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }

double pi = 3.14159265358979323846264338327950288419716939937510582097494459230;
int modulo = 1e9 + 7;

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h,w; cin >> h >> w;
    string grid[h];
    FOR(i,0,h) cin >> grid[i];
    int dp[h][w]; memset(dp, 0, sizeof(dp));
    if (grid[0][0] == '.') dp[0][0] = 1;
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            if (!dp[i][j]) continue;
            if (i+1 < h and grid[i+1][j] == '.') dp[i+1][j] = (dp[i+1][j] + dp[i][j])%modulo;
            if (j+1 < w and grid[i][j+1] == '.') dp[i][j+1] = (dp[i][j+1] + dp[i][j])%modulo;
        }
    }
    cout << dp[h-1][w-1];
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    REP(i, H)
    {
        cin >> S[i];
    }

    vvi row(H, vi(W));
    vvi col(H, vi(W));

    // 横方向
    REP(i, H)
    {
        int cnt = 0;
        int start = 0;
        int goal = 0;
        REP(j, W)
        {
            char c = S[i][j];
            if (c == '.')
            {
                if (cnt == 0)
                    start = j;

                cnt++;
                goal = j;
            }

            if ((c == '#' or j == W - 1) and cnt > 0)
            {
                for (int k = start; k <= goal; k++)
                {

                    row[i][k] = cnt;
                }
                cnt = 0;
            }
        }
    }

    // 縦方向
    REP(i, W)
    {
        int cnt = 0;
        int start = 0;
        int goal = 0;
        REP(j, H)
        {
            char c = S[j][i];
            if (c == '.')
            {
                if (cnt == 0)
                    start = j;

                cnt++;
                goal = j;
            }

            if ((c == '#' or j == H - 1) and cnt > 0)
            {
                for (int k = start; k <= goal; k++)
                {
                    col[k][i] = cnt;
                }
                cnt = 0;
            }
        }
    }

    int ans = 0;

    REP(i, H)
    {
        REP(j, W)
        {
            ans = max(ans, row[i][j] + col[i][j]);
        }
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 35968
#include <iostream>

using namespace std;

int main()
{

    int n;
    cin >>n;
    int a[n+1];
    int co=0;
    for(int i=1;i<=n;i++){
        cin >>a[i];
        if(a[i]!=i){
            co++;
        }
    }
    if(co==2||co==0){
        cout <<"YES"<<endl;
    }
    else{
        cout << "NO"<< endl;
    }

    return 0;
}


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

int main() {
	int n,m,i,j,k,ans=0,cur=0;
	string s,t;
	cin >> s>>t;
	for(i=0; i<3; i++){
		if(s[i]==t[i]) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	int a = 0, b = 0;
	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		if (a < A) a = A, b = B;
	}
	cout << a + b << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;

int N;
int inf = 1e9+7;
int main(){
	cin >> N;
	vector<ll> X(N),Y(N);
	vector<P> S(N),L(N);
	for(int i=0;i<N;i++){
		cin >> X[i] >> Y[i];
		if(X[i]>Y[i]) swap(X[i],Y[i]);
		S[i] = {X[i],i};
		L[i] = {Y[i],i};
	}
	sort(S.begin(),S.end());
	sort(L.begin(),L.end());
	ll ans = (S[N-1].first-S[0].first)*(L[N-1].first-L[0].first);
	set<P> T;
	for(int i=0;i<=N-1;i++) T.insert({L[i].first,(i==0? inf:L[i].second)});
	ll mind = inf;
	while(1){
		ll d = T.rbegin()->first - T.begin()->first;
		mind =  min(mind,d);
		auto a = *T.rbegin();
		T.erase(*T.rbegin());
		if(a.second>=inf) break;
		T.insert({X[a.second],inf});
	}
	ans = min(ans,(L[N-1].first-S[0].first)*mind);
	cout << ans << endl;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,m,ans;
    cin>>n>>m;
    ans=n*(n-1)/2+m*(m-1)/2;
    cout<<ans<<endl;
    return 0;
}


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

int main(){

    int n,a,b;
    int sum=0;
    int check = 0;

    cin>>n>>a>>b;
    
    for(int i=1; i<=n; i++){
        int tmp = i, tmp2 = i%10;
        while(tmp/10!=0){
            tmp /= 10;
            tmp2+=tmp%10;
        }
        if(tmp2>=a && tmp2<=b){
            sum += i;
        }
    }
    cout<<sum<<endl;
}

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

int main(){
  int K , X; cin >> K >> X;
  int ans = 0;
  int p = 0;
  p = X - (K - 1);
  for(int i = 0;i < (K*2-1);i++){
    cout << ' ' << p++;
  }
  cout << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

S = [["#"] * (W + 2) for i in range(H + 2)]
for i in range(H):
    s = input()
    for j in range(W):
        S[i + 1][j + 1] = s[j]
#print(S)

g = H * W

d = [[float("INF")] * g for i in range(g)]
for i in range(g):
    d[i][i] = 0

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if S[i][j] == ".":
            p = (i - 1)*W + (j - 1)
            if S[i][j+1] == ".":
                d[p][p + 1] = 1
            if S[i][j-1] == ".":
                d[p][p - 1] = 1
            if S[i+1][j] == ".":
                d[p][p + W] = 1
            if S[i-1][j] == ".":
                d[p][p - W] = 1

for k in range(g):
    for i in range(g):
        for j in range(g):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = 0

for i in range(g):
    for j in range(g):
        if d[i][j] != float("INF"):
            ans = max(ans, d[i][j])

print(ans)

Measured memory_bytes: 75376
import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
import heapq
#import math
import itertools
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))

n = ri()
ans = 10**n - 2* 9**n + 8**n
print(ans%MOD)

Measured memory_bytes: 28816
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;

int main(){
    string name;
    int am,pm,cnt,mo;
    int i;
    for(i=0;i<9;i++){
        cin>>name>>am>>pm;
        cnt=am+pm;
        mo=am*200+pm*300;
        cout<<name<<" "<<cnt<<" "<<mo<<endl;
    }
    return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> v(n, 0);
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
    }
    vector<int> lis(n, 0);
    lis[0] = 0;
    lis[1] = abs(v[1]-v[0]);
    for(int i=2; i<n; i++)
    {
        lis[i] = min(abs(v[i]-v[i-1])+lis[i-1], abs(v[i]-v[i-2])+lis[i-2]);
    }
    cout<<lis[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<ctype.h>
#include<math.h>
#define NUM 1000
#define min(x,y) x < y ? x : y
#define max(x,y) x > y ? x : y

int main()
{
  double x1, x2, y1, y2;
  double distance;
  scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
  distance = sqrt(pow((x1-x2),2)+pow((y1-y2),2));
  printf("%lf\n",distance);
  return 0; 
}

Measured memory_bytes: 652
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <cmath>

typedef long long ll;

using namespace std;

ll gcd(ll a, ll b)
{
    if((a%b) == 0) return b;
    else return gcd(b, a%b);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << r*r;
}


Measured memory_bytes: 256
$<.map{|i|a=i.chop.split(?,).map(&:to_i).sort;b=a.map{|j|a.count(j)}.max;s=a.uniq.size;puts b>3?"four card":b>2?s>2?"three card":"full house":b>1?s>3?"one pair":"two pair":a[4]-a[0]<5||a[1]>9?:straight: :null}

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

const int N=2e5+5;
int n,c[N];
vector <int> G[N];
inline void addedge(int u=0,int v=0) {
	scanf("%d%d",&u,&v),
	G[u].push_back(v),G[v].push_back(u);
}

int calc(int u,int fa,int lim) {
	int res=1;
	for(auto v:G[u]) if(v<lim&&v!=fa) res+=calc(v,u,lim);
	return res;
}
void solve(int u,int fa,int t1,int t2) {
	if(u>t2) c[u]=c[fa]+calc(u,fa,t1);
	else if(t1>t2) c[u]=c[fa]+calc(u,fa,t1)-calc(u,fa,t2);
	else c[u]=c[fa];
	for(auto v:G[u]) if(v!=fa) solve(v,u,max(t1,u),max(t2,fa));
} 

int main() {
	scanf("%d",&n);
	for(int i=2;i<=n;++i) addedge();
	solve(1,0,1,1);
	for(int i=2;i<=n;++i) printf("%d ",c[i]);
	return puts(""),0;
}

Measured memory_bytes: 25856
#define _USE_MATH_DEFINES    
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define quickIO()   {cin.tie(0);    cout.sync_with_stdio(false);}
#define rep(i,n)    for(ll i=0; i<(ll)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define fcout cout << fixed << setprecision(10) 
const ll inf = 1e18;
const ll mod = 1e9 +7;
     
ld sqrtld(ld x){
    ld left = 0, right = x;
    rep(i, 100){
        ld mid = (left + right)/2;
        if (mid*mid <= x)   left =mid;
        else    right = mid;
    }
    return left;
}

ll gcd(ll a, ll b){
    if(b>a){
        ll c =b; b=a;   a=c;
    }
    ll d = a%b;
    if(d==0){
        return b;
    }else if(d==1){
        return 1;
    }else{
        gcd(b,d);
    }
}


ll cul(ll n){
    return (n-1)*n/2;
}

int main (){
    string s;    cin >> s;
    int n= s.size();
    int a=2;
    if(s[0]==s[n-1]){
        a=3;
    }
    string ans = "First";
    if((n-a)%2==0 ){
        ans = "Second";
    }

    cout << ans << endl;
}



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

int main(){
	int a,b; cin>>a>>b;
    int s=1; int i=0;
    while(b>s) { s+=a-1; i++;}
    cout<<i;
    return 0;
}

/*
0: B=1
1: 1<B<=A
2: A<B<=2*A-1
3: 
1 1+A-1 A+A-1 3A-2
(m)*A-(m-1)










*/


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

#define count_ones __builtin_popcountl
#define all(a) a.begin(), a.end()
#define gcd(a, b) __gcd(a, b)
#define lca(a, b) a / __gcd(a, b) * b
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    cout.precision(12);
    cout << ld(n / 2 + n % 2) / n;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll x, ans = 0;
  cin >> x;
  ans += 2 * (x / 11);
  if (x % 11 != 0 && x % 11 <= 6) ans++;
  else if (x % 11 > 6) ans += 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N,K; cin >> N>>K;
	VLL h(N);
	for (int i = 0;i < N;i++) {
		cin >> h[i];
	}
	sort(all(h));
	ll max = 99999999999999;
	ll ans = max;
	for (int i = 0;i <= N-K;i++) {
		if (max >= h[i + K-1] - h[i]) max = h[i + K-1] - h[i];
	}
	cout << max << endl;
}


Measured memory_bytes: 1024
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for l in da:
    if l in db:
    	dc.append(l)

dc.sort(reverse = True)
print(dc[k-1])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+7;
int n,m,s,sum=0,a,b;
int main(){
	scanf("%d%d",&n,&m);
	for(double i=1;i<=1000;i+=1)
        if((int)(i*0.08)==n&&(int)(i*0.1)==m){
            printf("%.0f",i);
            return 0;
        }
    puts("-1");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n, q; cin>>n>>q;
    string s; cin>>s;
    vector<char> t(q), d(q);
    for(int i=0; i<q; i++) cin>>t[i]>>d[i];

    // [lb, ub)
    // go left
    int lb=0, ub=n;
    while(ub - lb > 1){
        int mid = (lb + ub) / 2;
        int cv = mid;
        char cc = s[mid];

        for(int i=0; i<q; i++){
            if(t[i] == cc){
                if(d[i] == 'R'){
                    cv++;
                    if(n - 1 < cv) break;
                }
                else{
                    cv--;
                    if(cv < 0) break;
                }

                cc = s[cv];
            }
        }

        if(cv < 0) lb = mid;
        else ub = mid;
    }

    int lcnt = lb + 1;
    //cout << lcnt << endl;

    // go right
    lb=0, ub=n;
    while(ub - lb > 1){
        int mid = (lb + ub) / 2;
        int cv = mid;
        char cc = s[mid];

        for(int i=0; i<q; i++){
            if(t[i] == cc){
                if(d[i] == 'R'){
                    cv++;
                    if(n - 1 < cv) break;
                }
                else{
                    cv--;
                    if(cv < 0) break;
                }

                cc = s[cv];
            }
        }

        if(n - 1 < cv) ub = mid;
        else lb = mid;
    }

    int rcnt = (n - (lb + 1));
    //cout << rcnt << endl;

    cout << n - lcnt - rcnt << endl;
}

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

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)

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

    dsu graph(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        graph.merge(a - 1, b - 1);
    }

    int ans = graph.groups().size() - 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9040
import fractions
def lcm(A, B):
    return int((A * B) / fractions.gcd(A, B))
A, B, C, D = map(int, input().split())
A -= 1
print(B - B//C - B//D + B//lcm(C,D) - (A - A//C - A//D + A//lcm(C,D)))

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S;
    cin >> S;
    int end_num;
    end_num = pow(2,S.length()-1);
    ll ans = 0;
    for(int mask=0;mask<end_num;mask++){
        ll sum = 0;
        ll frg = 0;
        for(int i=0;i<S.length();i++){
            // 上の桁から順にみていく
            // 次の桁(1つ下の桁)に行くときに10倍する
            frg = frg*10 + S[i] -'0';
            if(mask&(1 << i) || i==S.length()-1){
                // 今見ている桁の部分にbitが立っていればsumに足す
                sum += frg;
                frg = 0;
            }
        }
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
N, M = map(int, input().split())
MOD = 10**9+7
s = np.array([int(c) for c in input().split()], dtype=np.int32)
t = np.array([int(c) for c in input().split()], dtype=np.int32)
dp = np.zeros((N+1,M+1), np.int64)
dp[0] = 1
for i in range(N):
  mask = s[i]==t
  dp[i+1,1:][mask] = dp[i,:-1][mask]
  dp[i+1] = (np.cumsum(dp[i+1])+dp[i])%MOD
print(dp[-1,-1])

Measured memory_bytes: 43772
n = int(input())
c = []
for i in range(n):
    a,b = map(int,input().split())
    c.append((b,a))
c.sort()
time = 0
f = True
for d,t in c:
    time+=t
    if time>d:
        f = False
        break
if f:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 29444
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<ll> a(n);
  for (ll i = 1; i < n; i++) {
    if(s[i] == 'C' && s[i-1] == 'A') {
      a[i] = a[i-1]+1;
    }
    else {
      a[i] = a[i-1];
    }
  }
  for (ll i = 0; i < m; i++) {
    ll l, r;
    cin >> l >> r;
    ll cnt = a[r-1] - a[l-1];
    cout << cnt << '\n';
  }
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio

  int n;
  cin >> n;

  map< string, ll > cnt;

  while(n--){
    string s;
    cin >> s;
    sort(all(s));
    cnt[s]++;
  }

  ll ans = 0;

  for(auto c : cnt){
    ans += ((c.ss) * (c.ss - 1)) / 2;
  }


  cout << ans << '\n';

  ktj();
}


Measured memory_bytes: 11264
-- Try AtCoder
-- author: Leonardone @ NEETSDKASU

import qualified Data.IntMap as IntMap

main = print . solve . map read . words =<< getContents


solve (n:a:xs) = ans where
    m0 = IntMap.singleton 1 $ IntMap.singleton 0 1
    ans = IntMap.foldlWithKey r 0 mp
    r s 1 _ = s
    r s i m = s + (IntMap.findWithDefault 0 (a * (i - 1)) m)
    mp = foldl f m0 xs
    f m1 i = IntMap.foldlWithKey g m1 m1 where
        g m2 j m3 = IntMap.insert e m5 m2 where
            e = j + 1
            m4 = IntMap.findWithDefault IntMap.empty e m2
            m5 = IntMap.foldlWithKey h m4 m3
            h m6 t c = IntMap.insert u w m6 where
                u = t + i
                w = case IntMap.lookup u m6 of
                    Nothing -> c
                    Just d -> d + c


Measured memory_bytes: 228604
{
  const run = (input: string) => {
    let split = input.trim().split("\n")
    const n = parseInt(split[0].trim())
    const w = split[1].trim()

    let count = -1
    let right = w.split("")

    let leftTurnCount = 0
    let rightTurnCount = 0
    right.forEach((v,i) => {
      if (i !== 0 && v === 'E') rightTurnCount++
    })

    for (let i = 0; i < n; i++) {
      const sum = leftTurnCount + rightTurnCount
      if (count < 0 || sum < count) {
        count = sum
      }
      if (right[i] === 'W') {
        leftTurnCount++;
      }
      if (right[i + 1] === 'E') {
        rightTurnCount--;
      }
    }

    return count
  }

  const Main = (input: string) => {
    console.log(run(input))
  };

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}


Measured memory_bytes: 36284
#include<iostream>	// 入出力
#include<stdio.h>	// prllf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;


int main()
{

	int used[200001] = { 0 };

	int N, K;
	cin >> N >> K;

	for (int i = 0; i < N; ++i)
	{
		int A;
		cin >> A;
		used[A]++;
	}

	int kind = 0;
	vector<int> a;

	for (int i = 0; i <= 200000; ++i)
	{
		if (used[i] > 0)
		{
			++kind;
			a.emplace_back(used[i]);
		}
	}

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

	if (kind <= K)
	{
		cout << 0 << endl;
	}
	else
	{
		int ans = 0;
		
		for (int i = 0; i < kind - K; ++i)
		{
			ans += a[i];
		}
		cout << ans << endl;
	}
	

	return 0;

}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
#define MOD 1000000007
using namespace std;

int solution(){
    ll h,w; cin>>h>>w;
    vector<vector<char> > a(h, vector<char> (w) );
    for(ll i = 0;i < h;i++)
        for(ll j = 0;j < w;j++)
            cin>>a[i][j];
    
    vector<vector<ll> > dp(h, vector<ll> (w, 0) );
    dp[0][0] = 0;
    for(ll i = 1;i < h;i++){
        if(a[i][0] == '#') break;
        else dp[i][0] = 1;
    }
    for(ll i = 1;i < w;i++){
        if(a[0][i] == '#') break;
        else dp[0][i] = 1;
    }
    for(ll i = 1;i < h;i++){
        for(ll j = 1;j < w;j++){
            if(a[i][j] == '.')
                dp[i][j] = (dp[i-1][j]+dp[i][j-1]) % MOD;
        }
    }
    cout<<dp[h-1][w-1]<<"\n";
    return 0;
}

int main(){
    FAST_IO;
    int T = 1; //cin>>T;
    while(T--)
        solution();
    return 0;
}

Measured memory_bytes: 12148
#include <bits/stdc++.h>
#define DEBUG(x) cout << #x << " = " << x << endl
#define pb push_back
#define ff first
#define ss second
using namespace std;
typedef long long ll;


const int MAXN = 100005;
ll a[MAXN];
ll b[MAXN];

int main()
{
    //freopen("input.txt", "r", stdin);
    ll n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }

    ll pow = 1;
    for (int i = 1; i < 34; i++) pow *= 2;


    ll ans = 0;
    while (pow)
    {
        pow /= 2;
        if (!(k & pow)) continue;
        ll mask = (k - pow) | (pow-1);
        ll res = 0;
        for (int i = 0; i < n; i++)
        {
            if ((mask | a[i]) == mask)
            {
                res += b[i];
            }
        }
        ans = max(ans, res);
        ///cout << pow << " " << mask << " " << ans << endl;
    }
    ll res = 0;
    for (int i = 0; i < n; i++)
    {
        if ((k | a[i]) == k)
            res += b[i];
    }
    ans = max(ans, res);
    cout << ans;
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main() {
	// your code goes here
	double A,B;
	cin>>A;
	cin>>B;
	
	if(A>B) cout<<"GREATER"<<endl;
	else if(A==B) cout<<"EQUAL"<<endl;
	else if(A<B) cout<< "LESS"<<endl;
	return 0;
}

Measured memory_bytes: 256
# 解説見た

def solve(k, n):
    q, r = divmod(k, n)
    a = list(range(q, n + q))

    max_ = n + q - 1
    for i in range(r):
        a[i] += n
        for j in range(n):
            if i == j:
                continue
            a[j] -= 1
            if a[j] < 0:
                return []

        if a[i] < max_:
            return []
        else:
            max_ = a[i]
    return a


if __name__ == '__main__':
    k = int(input())
    for n in range(2, 50 + 1):
        a = solve(k, n)
        if all(map(lambda x: x <= 10 ** 16 + 1000, a)):
            print(n)
            print(*a)
            break

"""
2≦N≦50,0≦ai≦10**16+1000でなければならないのでダメ。

k:偶数
(x+1,x) -> (x,x-1) 操作2回
-> (1,0)
k:奇数
(x+2,x) -> (x+1,x-1) 操作2回
-> (2,0) -> (0,1)
全体を2減らすのに操作2回
k=2より最終値は0/1なので、
偶数なら(2x+1)-1=2x=k
奇数なら(2x+2)-2+1=2x+1=k
したがって、x=k//2

n = 2
x = k // 2
a = (x, x + (1 if k % 2 == 0 else 2))
print(n)
print(*a)
"""


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int x;cin >> x;
    int ans=1;
    for(int i=2;i*i<=x;i++){
        int k=i*i;
        while(k<=x)k*=i;
        k/=i;
        ans=max(ans,k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

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

signed main(){
	int n; cin>>n;
	cout << n*n*n << endl;

  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int num = 0;
    int ans = 0;
    if(10000>N){
        if(N%1000>0){
            num = (N/1000)+1;
            ans = num*1000-N;
        }else{
            ans = 0;
        }
    }else{
        if(N%1000>0){
            num = (N/1000)+1;
            ans = num*1000-N;
        }else{
            ans = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

vector<ll> num;

void dfs(ll i,int d){
	num.push_back(i);
	if(d == 10) return;
	if(i%10 == 0){
		for(int j = 0; j <= 1; j++){
			dfs(i*10+j,d+1);
		}
	}else if(i%10 == 9){
		for(int j = 8; j <= 9; j++){
			dfs(i*10+j,d+1);
		}
	}else{
		for(int j = -1; j <= 1; j++){
			dfs(i*10+i%10+j,d+1);
		}
	}
}

int main(){
	ll k;
	cin >> k;
	for(ll i = 1; i <= 9; i++) dfs(i,0);
	sort(all(num));
	cout << num[k-1] << endl;
	return 0;
}

Measured memory_bytes: 10604
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll n,i,j,p=0,sc=0,ans=0;
    string st;
    cin>>st;
    n = st.length();
    FOR(i,0,n)
    {
        if(st[i]=='p')
        {
            if(p<sc)
                p++;
            else
            {
                sc++;
                ans--;
            }
        }
        else
        {
            if(p<sc)
            {
                p++;
                ans++;
            }
            else
                sc++;
        }
    }
    cout<<ans;

}

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

int main()
{
  int n, count = 0;
  cin >> n;
  
  char s[n];
  
  for(int i = 0; i < n; i++)
  {
    cin >> s[i];
    if(s[i] == 'R')
      count++;
  }
  
  if(count > n - count)
  {
    cout << "Yes";
    return 0;
  }
  
  cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
    int a[4],n = 4,p = 0;
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a,a + n);
    for(int i = 0; i < n; i++) p = p * 10 + a[i];
    cout << (p == 1479 ? "YES" : "NO") << endl;
}
main(){
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,ans=0;
	scanf("%d",&n);
	int now=-1,len=0;
	for (i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		if (a==now) len++;
		    else
			{
				if (len>1) ans+=len/2;
				len=1;now=a;

			} 
			//cout << now << " " << len << endl;			
	}
	if (len>1) ans+=len/2;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mx 100005
#define fr first
#define se second
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

bool color[mx];
ll parent[mx], dis[mx];
vector <ll> v[mx];

ll dfs(ll start)
{
   ll &ret = dis[start];
   if(ret!=-1) return ret;
   ll ans=0;
   for(int i=0; i<v[start].size(); i++){
      ans = max(ans,1+dfs(v[start][i]));
   }
   return ret=ans;
}
int main()
{
   fast;
   ll node,edge;
   cin >> node >> edge;
   for(int i=0; i<edge; i++){
      ll a,b;
      cin >> a >> b;
      v[a].pb(b);
   }
   ll hold=0;
   memset(dis,-1,sizeof dis);
   for(int i=1; i<=node; i++){
      if(dis[i] == -1){
         hold = max(hold,dfs(i));
      }
   }
   cout << hold << "\n";
   return 0;
}


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

int main(){
  int N,Y;
  cin>> N>>Y;
  int all = 0;
  int ans10000=-1,ans5000=-1,ans1000=-1;
  for(int i=0; i<=N; i++){
    for(int j=0; i+j<=N; j++){
      int h =N-i-j;
        all= 1000*h+5000*j+10000*i;
        if(all==Y){
          ans10000=i;
          ans5000=j;
          ans1000=h;
      }
    }
  }

  cout <<ans10000<<" "<<ans5000 <<" "<<ans1000<<endl;

        return 0;
      }



Measured memory_bytes: 256
import java.io.*;
class Main{
    public static void main(String args[]) throws IOException{
	int i=0,x=0;
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	for(;;)
	{
        String str = br.readLine();
	    x=Integer.parseInt(str);
	    if(x==0)break;
	    i++;
	    System.out.println("Case "+i+": "+x);
	}
    }
}

Measured memory_bytes: 27160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
string dp[40][500]; int n, m, s, g;
vector<pair<int, string>>x[40];
bool solve() {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 480; j++)dp[i][j] = "~";
	}
	dp[s][0] = "";
	for (int j = 0; j < 480; j++) {
		for (int i = 0; i < n; i++) {
			if (dp[i][j] == "~")continue;
			for (int k = 0; k < x[i].size(); k++) {
				int a1 = x[i][k].first, a2 = x[i][k].second.size();
				dp[a1][j + a2] = min(dp[a1][j + a2], dp[i][j] + x[i][k].second);
			}
		}
	}
	string minx = "~"; int minid = -1;
	for (int i = 0; i < 480; i++) {
		if (dp[g][i] < minx) { minx = dp[g][i]; minid = i; }
	}
	if (minid >= 350 || minid == 0 || minid == -1) { cout << "NO" << endl; return false; }
	cout << minx << endl;
	return true;
}
int main() {
	while (true) {
		cin >> n >> m >> s >> g; if (n == 0)break;
		for (int i = 0; i < n; i++) { x[i].clear(); }
		for (int i = 0; i < m; i++) {
			int a, b; string T; cin >> a >> b >> T;
			x[a].push_back(make_pair(b, T));
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 11524
def main():
    N = int(input())
    S = input()
    R, G, B = set(), set(), set()
    for i, s in enumerate(S):
        if s == 'R':
            R.add(i)
        elif s == 'G':
            G.add(i)
        else:
            B.add(i)
    lr, lg, lb = len(R), len(G), len(B)
    #if lr < lg:
    #    lr, lg = lg, lr
    #    R, G = G, R
    #if lr < lb:
    #    lr, lb = lb, lr
    #    R, B = B, R

    a = 0

    for g in G:
        for b in B:
            b0, g0 = b, g
            if b0 < g0:
                b0, g0 = g0, b0
            r = lr
            gb = b0 - g0
            if (g0 - gb) in R:
                r -= 1
            if (b0 + gb) in R:
                r -= 1
            if gb % 2 == 0 and (g0 + gb // 2) in R:
                r -= 1
            a += r

    return a

print(main())


Measured memory_bytes: 74148
#include<stdio.h>
#include<ctype.h>

int main(){

  char pass[22];
  int i = 0;
  int a = 0, b = 0, c = 0, d = 0;
  int count = 0;
  
  scanf("%s", pass);
  while(pass[i] != '\0'){
    if(isdigit(pass[i])){
      b = 1;
    }
    if(65 <= pass[i] && pass[i] <= 90){
      c = 1;
    }
    if(97 <= pass[i] && pass[i] <= 122){
      d = 1;
    }
    count++;
    i++;
  }
  if(6 <= count){
    a = 1;
  }
  if(a == 1 && b == 1 && c == 1 && d == 1){
    printf("VALID\n");
  }else{
    printf("INVALID\n");
  }



  return 0;
}

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

namespace C_Unification
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            int cnt = 2 * Math.Min(S.Count(x => x == '0'), S.Count(x => x == '1'));

            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13268