akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        struct Card
        {
            internal char suit;
            internal int value;
        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Card[] A1 = new Card[n];
            Card[] A2 = new Card[n];

            string[] input;
            for(int i = 0; i < n; i++)
            {
                input = Console.ReadLine().Split(' ');

                A1[i].suit = input[0][0];
                A2[i].suit = input[0][0];
                A1[i].value = int.Parse(input[1]);
                A2[i].value = int.Parse(input[1]);
            }

            QuickSort(A1, 0, n - 1);
            A2 = A2.OrderBy(a => a.value).ToArray();

            StringBuilder sb = new StringBuilder();
            sb.AppendLine(IsStable(A1, A2, n) ? "Stable" : "Not stable");
            foreach (var a in A1)
            {
                sb.AppendLine(a.suit + " " + a.value);
            }
            Console.Write(sb);
        }

        static bool IsStable(Card[] A1,Card[] A2,int n)
        {
            for (int i = 0; i < n; i++)
            {
                if (A1[i].suit != A2[i].suit) return false;
            }
            return true;
        }

        static void QuickSort(Card[] A,int p,int r)
        {
            if (p < r)
            {
                int q = Partition(A, p, r);
                QuickSort(A, p, q - 1);
                QuickSort(A, q + 1, r);
            }
        }

        static int Partition(Card[] A,int p,int r)
        {
            int x = A[r].value;
            int i = p - 1;
            Card temp;

            for(int j = p; j < r; j++)
            {
                if (A[j].value <= x)
                {
                    i++;

                    temp = A[i];
                    A[i] = A[j];
                    A[j] = temp;
                }
            }

            temp = A[i + 1];
            A[i + 1] = A[r];
            A[r] = temp;

            return i + 1;
        }
    }
}

Measured memory_bytes: 19324
#include <iostream>

using namespace std;

string a(int N) {
  for(int i = 0; i < 10; i++) {
    for(int j = 0; j < 10; j++) {
      if(i * j == N) {
        return "Yes";
      }
    }
  }

  return "No";
}

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

  cout << a(N);
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    int x=n/2;
    int y=n-x;
    cout<<x*y<<"\n";
    return 0;
}
/**

**/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;
using ll=long long;

int main()
{
    int X, A, B;
    
    cin >> X >> A >> B;
    
    if (A - B >= 0)
    {
        printf("delicious\n");
    }
    else if (A + X - B >= 0)
    {
        printf("safe\n");
    }
    else
    {
        printf("dangerous\n");
    }
    
    return 0;
}


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

#define int long long int
#define fi first
#define so second
#define ps push_back
#define ld long double
#define mod 1000000007

signed main()
{
    int a,b,c,z=0;
    cin>>a>>b>>c;
    cout<<max(z,c-(a-b));

}


Measured memory_bytes: 256
s = input()
n = len(s)-1
ss = s
sum = 0
for x in range(2**n):
    s = list(s)
    j = 0
    for i in range(n):
        if (x>>i)&1:
            s.insert(i+j+1,"+")
            j += 1

    s = "".join(s)
    sum += eval(s)
    s = ss



print(sum)








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

#define N	0
#define W	1
#define S	2
#define E	3

int main() {
	int i;
	int dir[4] = { 0 };
	char buf[1001];
	fgets(buf, sizeof(buf), stdin);
	for (i = 0; i < 1000 && buf[i]!='\0'; i++) {
		switch (buf[i]) {
		case 'N':
			dir[N]++;
			break;
		case 'W':
			dir[W]++;
			break;
		case 'S':
			dir[S]++;
			break;
		case 'E':
			dir[E]++;
			break;
		}
	}
	if (dir[N])dir[N] = 1;
	if (dir[W])dir[W] = 1;
	if (dir[S])dir[S] = 1;
	if (dir[E])dir[E] = 1;
	if (dir[N] != dir[S] || dir[W] != dir[E])printf("No");
	else printf("Yes");
	return 0;
}

Measured memory_bytes: 128
s = input().rstrip()
n = len(s)
res = 0
for i in range(2**(n - 1)):
    bs = bin(i)[2:].rjust(n - 1, '0')
    ss = s[0]
    for b, c in zip(bs, s[1:]):
        if b == '1':
            ss += '+'
        ss += c
    res += eval(ss)
print(res)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string>

int main(){

    std::string day[7] = {"fri","sat","sun","mon","tue","wed","thu"};

    int x;
    scanf("%d",&x);
    int amari = (x-1) % 7;
    printf("%s\n", day[amari].c_str());

    return 0;
}

Measured memory_bytes: 2804
def examC():
    N = I()
    a = LI()
    v = [i for i in range(N)]
    if N%2==0:
        ans = a[::-2]
        ans.extend(a[0::2])
    else:
        ans = a[-1::-2]
        ans.extend(a[1::2])
    print(" ".join(map(str,ans)))



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

examC()


Measured memory_bytes: 39300
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(0)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
const int MOD = 1000 * 1000 * 1000 + 7;
const int N = 100;
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int main()
{
    Fast_IO();
    ll n , l ;
    cin >> n >>l ;
    ll flavour = l * n + ( n * (n+1) / 2 ) - n ;
    ll res = 1000* 1000 * 1000 ,g=0;
    for ( int i = 1 ; i <= n ; ++i)
       if( res >  abs( ( l + i -1 ) ))g=i,res=abs( ( l + i -1 ));//,cout<<g<<" ";

    cout << flavour - l - g +1 ;
    return 0 ;
}


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

int main(){
    int h,n; cin >> h >> n;
    int sum = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        sum += a;
    }
    cout << (sum >= h ? "Yes" : "No") << endl;
    return 0;
}

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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if ( x >= r && y >= r && (x + r) <= W && (y + r) <= H){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3116
#!/usr/bin/env python3
#SoundHound D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m,s,t = LI()
graph1 = [[] for _ in range(n)]
graph2 = [[] for _ in range(n)]
for _ in range(m):
    u,v,a,b = LI()
    graph1[u-1].append((v-1,a))
    graph1[v-1].append((u-1,a))
    graph2[u-1].append((v-1,b))
    graph2[v-1].append((u-1,b))

def dijkstra(s,graph):
    d = [inf]*n
    d[s] = 0
    h = [(0,s)]
    while h:
        c,v = heappop(h)
        if d[v] < c:
            continue
        for t,cost in graph[v]:
            if d[v] + cost < d[t]:
                d[t] = d[v] + cost
                heappush(h,(d[t],t))
    return d

c1 = dijkstra(s-1,graph1)
c2 = dijkstra(t-1,graph2)
c = [c1[i] + c2[i] for i in range(n)]
money = 10**15
mi = c[-1]
for i in range(n-1)[::-1]:
    mi = min(mi,c[i])
    c[i] = mi
for i in range(n):
    print(money - c[i])


Measured memory_bytes: 116076
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n;
    while(n>0)
    {
        if(n%10==7)
        {
            cout<<"Yes";
            return 0;
        }
        n=n/10;
    }
    cout<<"No";
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10656
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int x,a,b;
      cin >> x >> a >> b;
      cout << (x-a)%b << endl;
      return 0;}

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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000

typedef long long ll;
typedef pair<ll,ll> P;

int dp[333][333][333];
string s;
int k;

int dfs(int K,int L,int R)
{
//	cout << K << ' ' << L << ' ' << R << endl;
	if(K < 0)return -100000000;
	if(L > R)return 0;
	if(dp[K][L][R] != 0)return dp[K][L][R];
	int ret = 0;
	if(s[L] == s[R])ret = max(ret,dfs(K,L+1,R-1)+2);
	else ret = max(ret,dfs(K-1,L+1,R-1)+2);
	ret = max(ret,dfs(K,L+1,R));
	ret = max(ret,dfs(K,L,R-1));
	
	return dp[K][L][R] = ret;
}


int main()
{
	cin >> s >> k;
	
	REP(K,333)REP(i,333)dp[K][i][i] = 1;
	cout << dfs(k,0,s.size()-1) << endl;
	
	return 0;
}


Measured memory_bytes: 144512
N, M = list(map(int, input().split()))
height_list = list(map(int, input().split()))
tenbo_list = []

count = 0

for n in range(N):
    tenbo_list.append([])

for n in range(M):
    A, B = list(map(int, input().split()))
    tenbo_list[A-1].append(B-1)
    tenbo_list[B-1].append(A-1)

ite = 0
for t in tenbo_list:
    count += 1
    for a in t:
        if height_list[a] >= height_list[ite]:
            count -= 1
            break
    ite += 1

print(count)

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

/*  using namespace  */
using namespace std;

/*  local var  */
//None

/*  define  */
#define loop(i,j) for(int i = 0; i < j; i++)

/*  struct  */
//None

/*  typedef  */
typedef long long ll;

/*  Otter ―ニホンカワウソ―  */
//None

/*  main program  */
int main()
{
	int N,num;
	cin>>N>>num;
	vector<string> s(N);
	loop(i,N)cin>>s[i];
	sort(s.begin(),s.end());
	loop(i,N)cout<<s[i];
	cout<<endl;
}



Measured memory_bytes: 256
def get_point(dist, to_i)
  x = dist / 100.0
  y = to_i / 30.0
  
  point = [x.ceil + y.ceil * 5, x.ceil + y.to_i * 5,
           x.to_i + y.ceil * 5, x.to_i + y.to_i * 5]
 
  point.uniq.sort.join(" ")
end

gets.to_i.times do
  r, t = gets.chomp.split(" ").map(&:to_f)
  
  puts get_point(r, t)
end

Measured memory_bytes: 8636
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
	int n, a, b;
	cin >> n >> a >> b;
	
	int sum = 0;
	rep(i, 1, n + 1){
		string s = to_string(i);
		int sums = 0;
		for (char c: s){
			sums += (int)(c - '0');
		}
		if (a <= sums && sums <= b) sum += i;
	}
	
	cout << sum << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String[] lines = br.readLine().split(" ");
            int a = Integer.parseInt(lines[0]);
            String op = lines[1];
            int b = Integer.parseInt(lines[2]);
            if (op.equals("?")) {
                break;
            }
            if (op.equals("+")) {
                System.out.println(a + b);
            } else if (op.equals("-")) {
                System.out.println(a - b);
            } else if (op.equals("*")) {
                System.out.println(a * b);
            } else {
                System.out.println(a / b);
            }
        }
    }
}

Measured memory_bytes: 24324
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,total,ans;cin >> n;
  vector<long long> a(n),b(n);
  total=0;
  ans=0;
  for (int i=0;i<n;i++) {
    cin >> a[i];
	total+=a[i];
    b[i]=total;
  }
  for (int i=0;i<n-1;i++) {

    ans+=(a[n-1-i]*(b[n-i-2]%1000000007))%1000000007;
  }
  cout << ans%1000000007 << endl;
}

Measured memory_bytes: 6404
#include <iostream>

using namespace std;

int n, q, m;
int A[2000];

bool rec(int p, int s) {

    if (s == m) return true;

    bool ret = false;

    if (p < n) {
        ret |= rec(p + 1, s + A[p]);
        ret |= rec(p + 1, s);
    }

    return ret;
}

int main() {

    cin >> n;

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

    cin >> q;

    for (int i = 0; i < q; i++) {
        cin >> m;
        cout << (rec(0, 0) ? "yes" : "no") << endl;
    }
}


Measured memory_bytes: 3112
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#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(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;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())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
 ll a,b; cin>>a>>b;
 if(a <= b) cout<<"unsafe"<<endl;
 else cout<<"safe"<<endl;





}


Measured memory_bytes: 3636
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

diff = b.inject(&:+) - a.inject(&:+)
cnt_a = cnt_b = 0
a.zip(b).each do |ai, bi|
  if ai < bi
    cnt_a += (bi - ai + 1) / 2
  else
    cnt_b += (ai - bi)
  end
end
puts ((diff >= 0) && (diff >= [cnt_a, cnt_b].max)) ? "Yes" : "No"


Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,g=0;
  cin >> a >> b >> c >> n;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k==n)g++;
      }
    }
  }
  cout << g;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for(int i = 0; i <= n/r; i++)
    {
        for(int j = 0; j <= n/g; j++)
        {
            int x = n -  i * r - j * g;
            if(x >= 0 && x % b == 0){
              ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import math
while 1:
    n=int(input())
    if n==0:
        break
    ave=0.0
    aru=0.0
    m=[float(i) for i in input().split()]
    for i in range(n):
        ave=ave+m[i]
    ave=ave/n
    for i in range(n):
        aru=aru+(m[i]-ave)*(m[i]-ave)
    aru=math.sqrt(aru/n)
    print("%.5f"% aru)

Measured memory_bytes: 7748
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (h, w) = readIntegerList()
    val grid = Array(h) { br.readLine()!! }
    val whiteCount = grid.fold(0) { acc, i -> acc + i.count {it == '.'} }
    val tmp = gridBfs(h, w, grid)
    val ans = if (tmp[h - 1][w - 1] == 0L) -1 else whiteCount - (tmp[h - 1][w - 1] + 1)
    out.println(ans)
}

/** direction */
enum class GridDirection(val dx: Int, val dy: Int) {
    UP(0, -1),
    DOWN(0, 1),
    LEFT(-1, 0),
    RIGHT(1, 0),
}

/** 幅優先探索 O(E) with queue
 * @param grid 幅w、高さhの状態(要素数hのString配列)（高さ：h, 幅：w）
 *  @return countGrid 各マスへの最短経路
 */
fun gridBfs(h: Int, w: Int, grid: Array<String>): Array<LongArray> {
    /** point of coordinate */
    data class Point(val x: Int, val y: Int)

    val countGrid = Array(h) { LongArray(w) }
    val checkedGrid = Array(h) { BooleanArray(w) }
    val queue = ArrayDeque<Point>()
    queue.addLast(Point(0, 0))
    checkedGrid[0][0] = true
    while (queue.isNotEmpty()) {
        val node = queue.removeFirst()
        for (d in GridDirection.values()) {
            val x = node.x + d.dx
            val y= node.y + d.dy
            if (!(y in 0 until h && x in 0 until w)) continue
            if (checkedGrid[y][x]) continue

            if (grid[y][x] == '#') continue

            countGrid[y][x] = countGrid[node.y][node.x] + 1
            checkedGrid[y][x] = true
            queue.addLast(Point(x, y))
        }
    }

    return countGrid
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36616
import java.util.Scanner;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ1009().doIt();
	}

	class AOJ1009{
		void doIt(){
			while(in.hasNext()){
				System.out.println(gcd(in.nextInt(), in.nextInt()));
			}
		}
		int gcd(int a,int b){
			return b==0? a: gcd(b, a%b);
		}
	}
}

Measured memory_bytes: 17208
package main

import (
	"fmt"
)

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

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

func main() {
	var s string
	fmt.Scan(&s)

	const AKIBA string = "AKIHABARA"

	var ok bool = false
	for i := 0; i < (1 << uint(9)); i++ {
		var str string

		for j := 0; j < 9; j++ {
			if i&(1<<uint(j)) != 0 {
				str += string(AKIBA[j])
			} else if AKIBA[j] != 'A' {
				str += string(AKIBA[j])
			}
		}
		if str == s {
			ok = true
		}
	}

	if ok {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
//1,000,000,000,000,001	dogs dinomorin
//trs dinamain 1-26 a-z
//27-702 aa, ab, ac-zy, zz
//703-18278 aaa, aab, aac-zzy, zzz
//18279 - 475254 aaaa, aaab-zzzy, zzzz
//dst
//trs ditanya, utk anjing ke N, siapa namanya
//1<=N<=1000000000000001
//inputnya int sekali doang

#include <stdio.h>
int main(){
	long long int pilih;
	scanf("%lld", &pilih);	//nomor ajgnya
	
	char namaAnjing[16]={0};	//kosong semua
	
	pilih--;	//biar dia sesuai sama indeks
	
	int i = 0;
	while(pilih > -1)
	{
		namaAnjing[i] = pilih % 26 + 'a';	//isi dari namaAnjing ke i itu huruf
											//dia bakal bagi 26 biar jadi angka yg bisa diubah jadi huruf
											//kl a bagi 26 kan 0 sisa baginya, abis soalnya, trs tambahin 'a' biar jadi huruf
											//kalo b kan 1, ditambah a jadi asciinya b, dst
		pilih = pilih / 26;					//ini fungsinya cmn 1 sebenernya, biar dia bisa abis, jd kl ga dibagi dia bakal gede terus angkanya, trs namanya panjang
											//kan salah eta, kita maunya urutan kan, makanya dibagi 26 jadi kayak tiap udah 1 huruf muncul, ya berarti udh 1 abjad terlewati kan
		i++; //biar dia isi nama indeksnya bener urutannya maju
		pilih--;		//biar dia tetep masuk dlm array
	}										
	
	
	while(i--)		//ini kan bakal kebalik munculnya di inya, jadi biar bener urutannya
	{					//print aja dari paling gede trs dikurangin, slesai
		printf("%c", namaAnjing[i]);		//di print terus sampe dia udah keluar dari array
	}
	
	//kalo udah biar aman, ato kalo user gila inputnya gaada
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 1620
a,b = map(str,input().split())
c = ["A","B","C","D","E","F"]
d,e= 0,0
for i in range(6):
    if a == b == c[i]:
        d = i
        e = i
    elif a == c[i]:
        d = i
    elif b == c[i]:
        e = i

print(">" if d>e else "=" if d==e else "<")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstdlib>

using namespace std;
const int MAXN = 1008;
int n,m;

char A[MAXN][MAXN];
char B[MAXN][MAXN];
char C[MAXN][MAXN];

int main(){
	cin >> n >> m;
	for (int i = 1 ; i <= n ; i++){
		for (int j = 1 ; j <= m ; j++){
			B[i][j] = C[i][j] = '.';
		}
	}
	for(int i = 1 ; i <= n ; i++){
        for (int j = 1 ; j <= m ; j++){
        	cin >> A[i][j];
        	if(A[i][j] == '#') B[i][j] = C[i][j] = '#';
		}
    }
    for (int i = 2 ; i < n ; i++){
    	for (int j = 1 ; j <= m ; j += 2){
    		B[i][j] = '#';
		}
	}
    for (int i = 2 ; i < n ; i++){
    	for (int j = 2 ; j <= m ; j += 2){
    		C[i][j] = '#';
		}
	}
	for (int i = 1 ; i <= m ; i++)
        B[1][i] = C[n][i] = '#';
        
    for (int i = 1 ; i <= n ; i++){
    	for (int j = 1 ; j <= m ; j++){
    		cout << B[i][j];
		}
		cout << endl;
	}
	cout << endl;
	for (int i = 1 ; i <= n ; i++){
    	for (int j = 1 ; j <= m ; j++){
    		cout << C[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 2304
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
    N = int(readline())
    A = [0] + [int(i) for i in readline().split()]
    table = [0 for _ in range(N+1)]
    for i in range(N, 0, -1):
        table[i] = (sum(table[::i])+A[i])%2

    print(sum(table))
    for i in range(N):
        if table[i+1]:
            print(i+1, end=' ')
if __name__ == '__main__':
    main()

Measured memory_bytes: 8360
#include <iostream>
#include <stdio.h>
#include <vector>

#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll;

using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const double PI=3.14159265358979323846;

int main(){
  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  rep(i,N) H -= A[i];
  if(H<=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 640
l, r = map(int, input().split())
ans = 10**10
for i in range(l, r+1):
    for j in range(i+1, r+1):
        ans = min(ans, (i*j)%(2019))
        if i*j%2019==0:
            break
    if i*j%2019==0:
        break
print(ans)

Measured memory_bytes: 3060
#C - Build Stairs
N=int(input())
H=list(map(int, input().split()))
t=True
M=H[0]
for i in range(1,N):
    if M<H[i]:
        M=H[i]
    if M>H[i]+1:
        print("No")
        t=False
        break
if t:
    print("Yes")

Measured memory_bytes: 14252
n = gets.to_i
au = gets.chomp.split(" ").map(&:to_i)
ad = gets.chomp.split(" ").map(&:to_i)
(n-1).times do |i|
  au[i+1] += au[i]
  ad[n-2-i] += ad[n-1-i]
end
ans = 0
n.times do |i|
  if ans < au[i]+ad[i]
    ans = au[i]+ad[i]
  end
end
puts ans

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>
 
const int64_t cc = pow( 10, 9 );
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< std::string, int64_t > origin, std::pair< std::string, int64_t > another )
{
    return origin.second  > another.second;
}
 
int main()
{
    std::string word = "aa";
    int64_t a,b,c,d,e;
    std::vector< std::string > list;

    std::cin>> a;

    for( int i = 0; i < a; i++ )
    {
        std::cin>> word;
        list.push_back( word );
    }

    std::sort( list.begin(), list.end() );
    std::pair< std::string, int64_t > ii;
    std::vector< std::pair< std::string, int64_t > > ll;
    word = "";
    
    for( int i = 0; i < a; i++ )
    {
        if( word == list[i] )
        {
            ll.back().second += 1;
        }
        else
        {
            ii.first = list[i];
            word = list[i];
            ii.second = 1;
            ll.push_back( ii );
        }
    }

    std::sort( ll.begin(), ll.end(), sort_pair );
    int64_t max = ll.front().second;
    std::vector< std::string > last;

    for( int i = 0; i < ll.size(); i++ )
    {
        if( max == ll[i].second )
        {
            last.push_back( ll[i].first );
        }
    }

    std::sort( last.begin(), last.end() );

    for( int i = 0; i < last.size(); i++ )
    {
        std::cout<< last[i] <<"\n";
    }
}


Measured memory_bytes: 21740
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, const char * argv[]) {
    int H,W;
    cin >> H >> W;
    vector<vector<char>> sij = vector<vector<char>>(H,vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> sij[i][j];
        }
    }
    bool can_paint = true;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (sij[i][j] == '.') continue;
            bool local_can_paint = false;
            int neighbor[4][2] = {
                {i-1,j},
                {i+1,j},
                {i,j-1},
                {i,j+1},
            };
            for (int ni = 0;ni < 4; ni++) {
                if (neighbor[ni][0] < 0) continue;
                if (neighbor[ni][1] < 0) continue;
                if (neighbor[ni][0] >= H) continue;
                if (neighbor[ni][1] >= W) continue;
                if (sij[neighbor[ni][0]][neighbor[ni][1]] == '#') {
                    local_can_paint = true;
                }
            }
            if (!local_can_paint) can_paint = false;
        }
    }
    
    if (can_paint) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;

int main(){
 ll x,ans;
 cin>>x;
 rep(i,100000){
     ans=i*(i+1)/2;
     if(ans>=x){
         ans=i;
         break;
     }
 }
 cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using ll = long long;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;

const int MOD = 1e9+7;

int main(){
    int n,m;
    ll ans = 0;
    ll ans2 = 0;
    ll ans3 = 0;
    cin >> n >> m;
    vector<ll> x(n+1,0),y(m+1,0);
    rep(i,n){
        cin >> x[i];
    }
    rep(j,m){
        cin >> y[j];
    }

    reps(k,0,n){
        ans += (k*x[k] - (n-k-1)*x[k]) % MOD;
        ans %= MOD;
    }

    reps(k,0,m){
        ans2 +=  (k*y[k] - (m-k-1)*y[k]) % MOD;
        ans2 %= MOD;
    }

    ans3 = (ans * ans2 ) % MOD;
    cout << ans3 << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int n;
LL s[100];
inline int dep(int x) { for (int i=0;;i++) if (x<=s[i]) return i; }
inline int solve(int a,int b) {
	if (n==1) return min(a,b);
	while (dep(a)>dep(b)) a=(a+n-2)/n;
	while (dep(a)<dep(b)) b=(b+n-2)/n;
	while (a!=b) a=(a+n-2)/n,b=(b+n-2)/n;
	return a;
}
int main()
{
	n=gi();
	if (n>1) {
		s[0]=1;
		for (int i=1;(s[i]=s[i-1]*n+1)<=1e9;i++);
	}
	for (int Q=gi();Q--;)
		cout<<solve(gi(),gi())<<endl;
	return 0;
}


Measured memory_bytes: 1280
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)*}
    };
}

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)*}
    };
}

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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        w: [i32;n],
    }

    let mut sum = 0;
    
    for &weight in &w{
        sum += weight;
    }
    let mut s1 = sum;
    let mut s2 = 0;
    let mut dis = sum;
    for i in 0..n{
        s1 = s1 - w[n-i-1];
        s2 += w[n-i-1];
        if dis <= (s1-s2).abs() {
            println!("{}", dis);
            return;
        }
        dis = (s1-s2).abs();
    }

}

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

#define NIL -1

class Node {
public:
	int iParent_;
	int iLeftChild_;
	int iRightBrother_;
	int iDepth_;
};

class Tree {
public:
	Tree(int iNum):iMaxNodeNum_(iNum){
		for (int i = 0; i < iNum; i++) {
			noNode_[i].iParent_            = NIL;
			noNode_[i].iLeftChild_       = NIL;
			noNode_[i].iRightBrother_ = NIL;
		}
	}

	int searchRootIndex() {
		for (int i = 0; i < iMaxNodeNum_; i++)
			if (noNode_[i].iParent_ == NIL) return i;
	}

	void setNodeValue() {
		for (int iCurNo_i = 0; iCurNo_i < iMaxNodeNum_; iCurNo_i++) {
			int iNo, iChiNum;
			int leftBrotherOfChild = NIL;
			cin >> iNo >> iChiNum;
			for (int iCurChi_i = 0; iCurChi_i < iChiNum; iCurChi_i++) {
				int iChi;
				cin >> iChi;
				//???????????????????????????????????\???????????????????????????
				if (iCurChi_i == 0) noNode_[iNo].iLeftChild_ = iChi;
				else {
					noNode_[leftBrotherOfChild].iRightBrother_ = iChi;
				}
				leftBrotherOfChild = iChi;
				noNode_[iChi].iParent_ = iNo;
			}
		}

		int iRoIn = searchRootIndex();
		setDepth(iRoIn, /*depth =*/0);
	}

	void setDepth(int iNum, int iDep) {
		noNode_[iNum].iDepth_ = iDep;
		if (noNode_[iNum].iRightBrother_ != NIL) 
			setDepth(noNode_[iNum].iRightBrother_, iDep);
		if (noNode_[iNum].iLeftChild_ != NIL)
			setDepth(noNode_[iNum].iLeftChild_, iDep+1);
	}

	void print() {
		for (int iNodeNum_i = 0; iNodeNum_i < iMaxNodeNum_; iNodeNum_i++) {
			//?????????????±????
			string type = "internal node";
			if (noNode_[iNodeNum_i].iParent_ == NIL) type = "root";
			else if (noNode_[iNodeNum_i].iLeftChild_ == NIL) type = "leaf";

			//??????
			cout << "node " << iNodeNum_i << ": ";
			cout << "parent = " << noNode_[iNodeNum_i].iParent_ << ", ";
			cout << "depth = " << noNode_[iNodeNum_i].iDepth_ << ", ";
			cout << type << ", ";
			cout << "[";
			Node currentNode = noNode_[iNodeNum_i];
			int i = 0;
			for (int iChildNodeNum_i = currentNode.iLeftChild_; iChildNodeNum_i != NIL;iChildNodeNum_i = noNode_[iChildNodeNum_i].iRightBrother_) {
				if (i++)  cout << ", ";
				cout << iChildNodeNum_i;
			}
			cout << "]" << endl;
		}
	}
private:
	static const int kMax_Node = 100000;
	Node noNode_[kMax_Node];
	int iMaxNodeNum_;
};

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

	//????????????NULL?????\?????????
	Tree trNodeTree(iNodeNum);
	
	//???????????§??\????????????
	trNodeTree.setNodeValue();

	//??????
	trNodeTree.print();
	return 0;
}

Measured memory_bytes: 6220
n, m = map(int, input().split())
mod = 10 ** 9 + 7

def prf(n):
    pf = {}
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            pf[i] = pf.get(i, 0) + 1
            n //= i
    if n > 1:
        pf[n] = 1
    return pf

def comb(n, k):
    k = min(k, n-k)
    result = 1
    for i in range(n-k+1, n+1):
        result *= i
    for i in range(1, k+1):
        result //= i
    return result

ans = 1
for v in prf(m).values():
    ans = ans * comb(n-1+v, v) % mod
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans=0;
    for(int i=0; i<n-2; i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] line = sc.nextLine().split(" ", 0);
		char A = line[0].charAt(0);
		char B = line[1].charAt(0);
		StringBuilder sb = new StringBuilder();
		if (A <= B) {
			for (int i = 0; i < Integer.parseInt(line[1]); i++) {
				sb.append(A);
			}
			System.out.println(sb.toString());
		} else {
			for (int i = 0; i < Integer.parseInt(line[0]); i++) {
				sb.append(B);
			}
			System.out.println(sb.toString());
		}

	}
}

Measured memory_bytes: 35640
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <bitset>

using namespace std;
using ll = long long;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end());
    int prev = -1;
    vector<int> c;
    c.reserve(n);
    vector<int> total;
    total.reserve(n);
    int res = b.back() - b.front();
    for (int x : b) {
        if (x == prev) {
            continue;
        }
        prev = x;
        c.clear();
        total.clear();
        for (int v : a) {
            if (v < x) {
                sort(c.begin(), c.end());
                for (int i = 0; i <= (int)c.size() - k; ++i) {
                    total.push_back(c[i]);
                }
                c.clear();
            } else {
                c.push_back(v);
            }
        }
        sort(c.begin(), c.end());
        for (int i = 0; i <= (int)c.size() - k; ++i) {
            total.push_back(c[i]);
        }
        sort(total.begin(), total.end());
        if ((int)total.size() >= q) {
            res = min(res, total[q - 1] - x);
        }
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
int main(void){
    
    double r, sum, length;
    
    scanf("%lf", &r);
    sum = M_PI * r * r;
    length = 2 * M_PI * r;
    printf("%.6f %.6f", sum, length);
    
    return 0;
}

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

int main() {

  int A, B, C;
  cin >> A >> B >> C;

  if((A == B && A != C) || (B == C && A != B) || A == C && A != B){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

void solve(int h[], int n){
	
	int dp[n+1];	memset(dp,0,sizeof(dp));
	//dp[1] = 0;
	dp[2] = abs(h[1] - h[2]);
	for(int i=3 ;i<=n ; i++){
		dp[i] =	 min(dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs(h[i] - h[i-2]));
	}
	cout << dp[n];
}

int main(){
	int n;	cin >> n;	int h[n+1];
	for(int i=1; i<=n ;i++)	cin >> h[i];
	solve(h,n);
}

Measured memory_bytes: 1024
nn = gets.to_i
xyh =[]
$stdin.each_line{|line|
xyh.push((line.split).map!(&:to_i))}
xyh.delete_if{|a|a[2] == 0}
if xyh.size == 1
  puts "#{xyh[0][0]} #{xyh[0][1]} #{xyh[0][2]}"
else
h = Array.new(xyh.size)
for i in (0..100)
  for j in (0..100)
    for k in (0..xyh.size-1)
      h[k] = (xyh[k][0] - i).abs + (xyh[k][1] - j).abs + xyh[k][2]
    end
    if h.uniq.size == 1
      puts "#{i} #{j} #{h[0]}"
    end
  end
end
end


Measured memory_bytes: 2556
#include <stdio.h>

void CountingSort(int[], int[], int);

int n, A[2000001], B[2000001];

int main(){
  int i;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  CountingSort(A, B, 10000);
  
  for (i=1;i<=n;i++){
    if (i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


void CountingSort(int A[], int B[], int k){
  int i, j;
  int C[k+1];
  for(i=0;i<=k;i++) C[i]=0;
  
  /* C[i] ??? i ???????????°????¨?????????? */
  for(j=0;j<n;j++) C[A[j]]++;
  
  /* C[i] ??? i ??\????????°???????????°????¨??????????*/
  for(i=1;i<=k;i++) C[i] = C[i] + C[i-1];
  
  for(j=n;j>=0;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}

Measured memory_bytes: 16264
from bisect import bisect_right

def main():
    n, k = map(int, input().split())
    x = [int(i) for i in input().split()]
    o = bisect_right(x, 0)
    ans = 10**9
    for i in range(max(o - k, 0), min(o, n - k) + 1):
        a, b = x[i], x[i + k - 1]
        c, d = abs(a), abs(b)
        if a * b > 0:
            ans = min(max(c, d), ans)
        else:
            ans = min(min(c, d) * 2 + max(c, d), ans)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14660
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<vector<int>> e(n+1);
    for(int i = 0; i < n-1; i++)
    {
        int a, b;
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    vector<int> d(n+1);
    using P = pair<int, int>;
    function<void(int, vector<int> &)> dfs = [&](int s, vector<int> &d)
    {
        queue<P> que;
        que.push(P(0, s));
        while(!que.empty())
        {
            P p = que.front();
            int v = p.second;
            int cost = p.first;
            que.pop();
            for(auto next : e[v])
            {
                if(next != s && d[next] == 0)
                {
                    que.push(P(cost+1, next));
                    d[next] = cost + 1;
                }
            }
        }
    };
    dfs(1, d);
    int ma = 0;
    int pos = 0;
    for(int i = 1; i <= n; i++)
    {
        if(ma < d[i])
        {
            ma = d[i];
            pos = i;
        }
    }
    vector<int> d2(n+1);
    dfs(pos, d2);
    int ma2 = 0;
    
    for(int i = 1; i <= n; i++)
    {
        if(ma2 < d2[i])
        {
            ma2 = d2[i];
        }
    }
    if((ma2+1) % 3 != 2)
    {
        cout << "First" << endl;
    }
    else cout << "Second" << endl;
}

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

using namespace std;

const int BASE=1e9+7;

long long N,f[100][2][2][2];

long long dp(int bit, int carry, int isA, int isB)
{
    if (bit==63)
    {
        if (carry==0) return (!isA && !isB);
        else
        {
            if (N>>bit&1) return (!isA && !isB);
            else return 0;
        }
    }
    if (f[bit][carry][isA][isB]==-1)
    {
        f[bit][carry][isA][isB]=0;
        bool nxA,nxB;
        int bitA,bitB,ncarry;
        // bit u^v= 0 && u+v=0
        bitA=carry;
        bitB=0;
        ncarry=0;
        if (N>>bit&1)
        {
            if (bitA) nxA=isA;
            else nxA=0;
            nxB=0;
        }
        else
        {
            if (bitA) nxA=1;
            else nxA=isA;
            nxB=isB;
        }
        f[bit][carry][isA][isB]+=dp(bit+1,ncarry,nxA,nxB);
        f[bit][carry][isA][isB]%=BASE;
        // bit u^v= 1
        bitA=(carry+1)%2;
        ncarry=(carry+1)/2;
        bitB=1;
        if (N>>bit&1)
        {
            if (bitA) nxA=isA;
            else nxA=0;
            nxB=isB;
        }
        else
        {
            if (bitA) nxA=1;
            else nxA=isA;
            nxB=1;
        }
        f[bit][carry][isA][isB]+=dp(bit+1,ncarry,nxA,nxB);
        f[bit][carry][isA][isB]%=BASE;
        // bit u^v=0 && u+v=1
        bitA=carry;
        ncarry=1;
        bitB=0;
        if (N>>bit&1)
        {
            if (bitA) nxA=isA;
            else nxA=0;
            nxB=0;
        }
        else
        {
            if (bitA) nxA=1;
            else nxA=isA;
            nxB=isB;
        }
        f[bit][carry][isA][isB]+=dp(bit+1,ncarry,nxA,nxB);
        f[bit][carry][isA][isB]%=BASE;
    }
    return f[bit][carry][isA][isB];
}

int main()
{
    cin >> N;
    memset(f,-1,sizeof f);
    cout << dp(0,0,0,0);
}


Measured memory_bytes: 256
inputs = input().split()

N = int(inputs[0]) # number of participants
A = int(inputs[1])
B = int(inputs[2])

S = input()

# a = Japanese student
# b = overseas student
# c = other (not eligible)


num_passes = 0
num_jap_students = 0
num_overseas_students = 0
num_ineligible = 0

for rank in range(N):
    curr = S[rank]
    if curr == 'c':
        print('No')
        num_ineligible += 1
        continue
    if curr == 'a': 
        if num_passes < A + B: # Japanese student passes if ...
            print('Yes')
            num_passes += 1
        else:
            print('No')
        num_jap_students += 1
    elif curr == 'b':
        
        if num_passes < A + B and num_overseas_students + 1 <= B:
            print('Yes')
            num_passes += 1
        else:
            print('No')
        num_overseas_students += 1

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

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

int n;
int f[1000005], rf[1000005];

void init() {
    rf[0] = rf[1] = 1;
    for (int i = 2; i < 1000005; ++i) {
        rf[i] = (MOD - (LL)(MOD / i) * rf[MOD % i] % MOD) % MOD;
    }
    f[0] = 1;
    for (int i = 1; i < 1000005; ++i) {
        f[i] = (LL)f[i - 1] * i % MOD;
        rf[i] = (LL)rf[i - 1] * rf[i] % MOD;
    }
}

int c(int n, int k) {
    return (LL)f[n] * rf[k] % MOD * rf[n - k] % MOD;
}

int main() {
    init();
    scanf("%d", &n);
    int ans = 0;
    int pre = 0;
    for (int k = (n + 1) / 2; k < n; ++k) {
        int cur = (LL)c(k - 1, n - k - 1) * f[k] % MOD * f[n - 1 - k] % MOD;
        ans = (ans + (LL)k * (cur - pre)) % MOD;
        pre = cur;
    }
    if (ans < 0) ans += MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
n, m = gets.chomp.split.map(&:to_i)
if m == 0
  puts 0
  exit
end
a1 = []
a2 = []
a3 = []
a4 = []
a5 = []
a6 = []
a7 = []
a8 = []
n.times do |i|
  x, y, z = gets.chomp.split.map(&:to_i)
  a1[i] = x + y + z
  a2[i] = x + y - z
  a3[i] = x - y + z
  a4[i] = x - y - z
  a5[i] = -x + y + z
  a6[i] = -x + y - z
  a7[i] = -x - y + z
  a8[i] = -x - y - z
end
puts [
  a1.sort.reverse[0...m].inject(:+),
  a2.sort.reverse[0...m].inject(:+),
  a3.sort.reverse[0...m].inject(:+),
  a4.sort.reverse[0...m].inject(:+),
  a5.sort.reverse[0...m].inject(:+),
  a6.sort.reverse[0...m].inject(:+),
  a7.sort.reverse[0...m].inject(:+),
  a8.sort.reverse[0...m].inject(:+)
].max


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

const int M = 1000005;

int main() {
  string o, e;
  cin >> o >> e;
  rep(i, e.size()){
    cout << o[i] << e[i];
  }
  if(o.size() > e.size()) cout << o[o.size()-1];
  return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll a, b, c, ans = 0;
  scanf("%lld%lld%lld", &a, &b, &c);
  for (int i = 0; i <= c; i += a)
  {
    if (a > c)
      break;
    if (!i)
      continue;
    ans += b;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>

using namespace std;

int N;
long long x;

int main() {
    cin >> N >> x;
    vector<long long> nums(N);
    for (int i = 0; i < N; i++)
        cin >> nums[i];

    long long ans = 0;
    for (int i = 1; i < N; i++) {
        long long diff = nums[i - 1] + nums[i] - x;
        if (0 < diff) {
            nums[i] -= diff;
            nums[i - 1] -= max(0 - nums[i], (long long)0);
            nums[i] = max(nums[i], (long long)0);
            ans += diff;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define endl "\n"
#define ll long long

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,i,j,cnt = 0;
	string s;
	cin >> n;
	cin >> s;
	sort(s.begin(),s.end());
	for(i=0;i<n;i+=2)
	{
		if(s[i]==s[i+1]) cnt++;
	}
	if(cnt == (n/2) && n%2==0) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3596