akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

int main() {
    int n;
    cin>>n;
    string s;
    set<string> st;
    rep(i,n) {
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
}


Measured memory_bytes: 19224
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))

typedef struct block {
  int w,s,v;
} node;

int cmp(const void *a,const void *b){
  node *p=(node *)a;
  node *q=(node *)b;
  return (p->w+p->s)-(q->w+q->s);
}

void run(void){
  int n;
  scanf("%d",&n);
  node *b=(node *)calloc(n,sizeof(node));
  int i;
  for(i=0;i<n;i++){
    int w,s,v;
    scanf("%d%d%d",&w,&s,&v);
    b[i]=(node){w,s,v};
  }
  qsort(b,n,sizeof(node),cmp);
  int64 *dp=(int64 *)calloc(20000+1,sizeof(int64));
  for(i=0;i<n;i++){
    int j;
    for(j=b[i].s;j>=0;j--){
      dp[j+b[i].w]=MAX(dp[j+b[i].w],dp[j]+b[i].v);
    }
  }
  int64 max=0;
  for(i=0;i<=20000;i++) max=MAX(max,dp[i]);
  printf("%lld\n",max);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 380
#include<bits/stdc++.h>
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define fi first
#define se second
#define inf 1000000000
#define mod 1000000007
using namespace std;
template <class T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <class T> void chmin(T &x,T y){x=x<y?x:y;return;}
typedef long long ll;
typedef unsigned long long ull;

int n,m;

int main()
{
	scanf("%d%d",&n,&m);
	printf("%d\n",n*max(0,n-1)/2+m*max(0,m-1)/2);
	return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    string s;
    int  p = 0;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'g')
        {
        }
        else
        {
            p++;
        }
        
    }
    cout<<s.length()/2-p;
    return 0;
}


Measured memory_bytes: 512
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

H, W, K = iInM()
C = []
for _ in range(H):
  C.append(list(input()))
#print(C)

ans = 0
for i in range(2**H):
    h_lst = []
    for k in range(H):
       if (i >> k) & 1:
           h_lst.append(k)

    for j in range(2**W):
        w_lst = []
        for k in range(W):
            if (j >> k) & 1:
                w_lst.append(k)
        
        #print(h_lst, w_lst)
        ## 以下、hとwを選んだ列として処理する
        cnt = 0
        for h in h_lst:
            for w in w_lst:
                #print(h, w)
                if C[h][w] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1


print(ans)

Measured memory_bytes: 68544
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

//↑template↑




void dijkstra(int n) {
	priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>que;
	fill(dij.begin(), dij.end(), INF);
	dij[n] = 0;
	que.push(pair<ll, ll>(0, n));

	while (!que.empty()) {
		pair<ll, ll>p = que.top();
		que.pop();
		ll mon = p.second;
		if (dij[mon] < p.first) continue;
		for (int i = 0; i < G[mon].size(); ++i) {
			edge e = G[mon][i];
			if (dij[e.to] > dij[mon] + e.cost) {
				dij[e.to] = dij[mon] + e.cost;
				que.push(pair<ll, ll>(dij[e.to], e.to));
			}
		}
	}
}


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	G.resize(a + 1);
	dij.resize(a + 1);
	for (int i = 0; i < b; ++i) {
		int n, m, mm;
		cin >> n >> m >> mm;
		G[n].push_back({ m,mm });
	}

	dijkstra(c);
	for (int i = 0; i < a; ++i) {
		if (dij[i] != INF) { cout << dij[i] << endl; }
		else { cout << "INF" << endl; }
	}
}


Measured memory_bytes: 19376
#include<bits/stdc++.h>
using namespace std;
struct Node{
  int val;
  char c;
  bool operator==(const Node& a)const{
    return val == a.val && c == a.c;
  }
};
void Print(vector<Node>a){
  for(int i = 0; i < a.size(); i++){
    if(i)cout << ' ';
    cout << a[i].c << a[i].val;
  }
  cout << endl;
}
void BubbleSort(vector<Node>&a){
  for(int i = 0; i < a.size()-1; i++){
    for(int j = 0; j < a.size() - i - 1; j++){
      if(a[j].val > a[j+1].val){
        swap(a[j], a[j+1]);
      }
    }
  }
}
void SelectionSort(vector<Node>&a){
  for(int i = 0; i < a.size() - 1; i++){
    int p = i;
    for(int j = i + 1; j < a.size(); j++){
      if(a[p].val > a[j].val){
        p = j;
      }
    }
    if(p != i){
      swap(a[p], a[i]);
    }
  }
}
int main(){
  int n;
  cin >> n;
  vector<Node>a(n), b(n);
  string s;
  for(int i = 0; i < n; i++){
    cin >> s;
    a[i].c = s[0];
    a[i].val = s[1]-'0';
    b[i] = a[i];
  }
  // Stable Bubble Sort
  BubbleSort(a);
  Print(a);
  cout << "Stable" << endl;
  // NotStable Selection Sort
  SelectionSort(b);
  Print(b);
  if(a == b){
    cout << "Stable" << endl;
  }else{
    cout << "Not stable" << endl;
  }
}


Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <iomanip>

#define MOD (1000000007)
using namespace std;

typedef long long ll;

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

    string S;
    cin >> S;


    if(S.length() <= K) cout << S << endl;
    else cout << S.substr(0, K) << "..." << endl;

    return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int x=0, ans=0;
    for(int i=0; i<n; i++){
        if(s[i]=='I'){
            x++;
            ans = max(ans, x);
        }else{
            x--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
public class Main {
	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		//StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int i = 0;
		for (int j =0;a + j <= b;j++){
			if (c % (a + j) == 0) { i++; }
		}
		System.out.println(i);
	}
}

Measured memory_bytes: 26056
import numpy as np

N, K = map(int, input().split())
a_list = []
b_list = []
for i in range(N):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)

a_order = np.argsort(a_list)
kc = 0
for i in range(N):
    kc += b_list[a_order[i]]
    if kc >= K:
        print(a_list[a_order[i]])
        break


Measured memory_bytes: 22020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int H,W;
char maze[60][60];
int d[60][60];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void bfs(int sx,int sy){
    queue<pair<int,int>> que;
    rep(i,H){
        rep(j,W){
            d[i][j]=INF;
        }
    }
 
    que.push(make_pair(sx,sy)); // (0,0)ã‚¹ã‚¿ãƒ¼ãƒˆ
    d[sx][sy]=0;
    while(!que.empty()){
        pair<int,int> p=que.front();
        que.pop();
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx && nx<H && 0<=ny && ny<W && maze[nx][ny]!='#' && d[nx][ny]==INF){
                que.push(make_pair(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
}

int main(){
    cin>>H>>W;
    int c=0;
    rep(i,H){
        rep(j,W){
            cin>>maze[i][j];
            if(maze[i][j]=='.') c++;
        }
    }

    bfs(0,0);
    if(d[H-1][W-1]==INF){
        cout<<-1<<endl;
        return 0;
    }

    cout<<c-d[H-1][W-1]-1<<endl;
}

Measured memory_bytes: 3592
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    s, t = [], []
    for _ in range(N):
        _s, _t = LS()
        _t = int(_t)
        s.append(_s)
        t.append(_t)
    X = S()
    for i, title in enumerate(s):
        if title == X:
            break
    i += 1
    cnt = 0
    for j in range(i, N):
        cnt += t[j]
    print(cnt)
main()



Measured memory_bytes: 7752
#include<iostream>
#include<cmath>
#include<cstdlib>
using namespace std;
struct coo{
	int x;
	int y;
	int h;
}c[110];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>c[i].x;
		cin>>c[i].y;
		cin>>c[i].h;
	}
	int ch;
	int p=0;
	while(c[p].h==0) p++;
	for(int i=0;i<=100;i++)
	{
		for(int j=0;j<=100;j++)
		{
			int ch=c[p].h+abs(i-c[p].x)+abs(j-c[p].y);
			int f=0;
			for(int k=0;k<n;k++)
			{
				int hh=ch-abs(i-c[k].x)-abs(j-c[k].y);
				if(hh<0) hh=0;
				if(hh!=c[k].h)
				{
					f=1;
					break;
				}
			}
			if(!f)
			{
				cout<<i<<' '<<j<<' '<<ch<<endl; return 0;
			} 
		}
	}
} 


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

int main(){
  int r,g,b;
  scanf("%d %d %d",&r,&g,&b);
  r = r * 100;
  g = g * 10;
  int sum = r + g + b;
  if(sum%4==0)
    printf("YES\n");
  else
    printf("NO\n");
  
  return 0;
}


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

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K <= A) cout << K << endl;
    else if (K <= A + B) cout << A << endl;
    else if (K <= A + B + C) cout << A - (K - A - B) << endl;
}

Measured memory_bytes: 3660
def main():
    Ss = input()
    S = list(Ss)
    now = 0
    T = ''
    Sr = []
    for i in range(1,len(S)+1):
        Sr.append(S[-i])
    ans = []
    while True:
        tmp5 = Sr[now:now+5]
        tmp6 = Sr[now:now+6]
        tmp7 = Sr[now:now+7]
        if tmp5[0] == 'e' and tmp5 == ['e','s','a','r','e']:
            ans.append('erase')
            now += 5
        elif tmp5[0] == 'm' and tmp5 == ['m','a','e','r','d']:
            ans.append('dream')
            now += 5
        elif tmp6[0] == 'r' and tmp6 == ['r','e','s','a','r','e']:
            ans.append('eraser')
            now += 6
        elif tmp7[0] == 'r' and tmp7 == ['r','e','m','a','e','r','d']:
            ans.append('dreamer')
            now += 7
        else:
            print('NO')
            
            return

        if now >= len(S):
            break
    for i in range(1,len(ans)+1):
        T += ans[-i]
    if Ss == T:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 137396
loop{
  h, w = gets.split.map &:to_i
  break if h == 0 && w == 0
  puts '#' * w
  (h-2).times{|i|
    print '#' if w > 1
    puts '.' * [w-2, 0].max + '#'
  }
  puts '#' * w
  puts
}

Measured memory_bytes: 8780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;cin >> h >> w;
    int sx,sy,gx,gy;cin >> sx >> sy >> gx >> gy;
    sx--,sy--,gx--,gy--;
    int s=sx*w+sy,g=gx*w+gy;
    vector<char> a(h*w);
    REP(i,h) REP(j,w) cin >> a[i*w+j];
    vector<vector<pair<int,int>>> e(h*w);
    REP(i,h){
        REP(j,w){
            FOR(k,-2,3){
                FOR(l,-2,3){
                    if(k==0&&l==0) continue;
                    int x=i+k,y=j+l;
                    if(x>=0&&x<h&&y>=0&&y<w){
                        if(a[x*w+y]=='.'){
                            if(abs(k)+abs(l)==1){
                                e[i*w+j].push_back({x*w+y,0});
                            }
                            else{
                                e[i*w+j].push_back({x*w+y,1});
                            }
                        }
                    }
                }
            }
        }
    }
    vector<int> d(h*w,inf);
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
    pq.push({0,s});
    d[s]=0;
    while(!pq.empty()){
        auto p=pq.top();
        pq.pop();
        int dd=p.first,du=p.second/w,dv=p.second%w;
        int cur=du*w+dv;
        if(dd<d[cur]) continue;
        for(auto to:e[cur]){
            if(chmin(d[to.first],d[cur]+to.second)){
                pq.push({d[to.first],to.first});
            }
        }
    }
    cout << (d[g]==inf?-1:d[g]) << endl;
}


Measured memory_bytes: 171408
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

class Point {
    public:
        double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator+ (Point p) { return Point(x + p.x, y + p.y); }
    Point operator- (Point p) { return Point(x - p.x, y - p.y); }
    Point operator* (double a) { return Point(x * a, y * a); }
    Point operator/ (double a) { return Point(x / a, y / a); }

    double norm() { return x * x + y * y; }
    double abs() { return sqrt(norm()); }

    bool operator< (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }
    bool operator== (const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }
};
// struct Segment { Point p1, p2; };
struct Segment {
    Point p1, p2;
    Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};
typedef Point Vector;
typedef Segment Line;
typedef vector<Point> Polygon;

double dot(Vector v1, Vector v2) {
    return v1.x * v2.x + v1.y * v2.y;
}

class Circle {
    public:
        Point c;
        double r;
        Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / base.norm();
    return s.p1 + base * r;
}

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    Point p1(x1, y1), p2(x2, y2);
    Segment s(p1, p2);

    int q;
    cin >> q;
    vector<Point> ps;
    rep(i, q) {
        double xp, yp;
        cin >> xp >> yp;
        ps.push_back(Point(xp, yp));
    }

    cout << fixed << setprecision(10);
    rep(i, q) {
        Point x = project(s, ps[i]);
        cout << x.x << " " << x.y << endl;
    }
}



Measured memory_bytes: 3336
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

typedef struct 
{   
    /* 水溜りの面積を求めるために必要なデータ */
    unsigned int uiLeft;    /* 水溜りの左端のインデックス */
    unsigned int uiArea;    /* 水溜りの面積 */
}AreaInfo_t;

#define CALC_AREA(x,y) ((x) - (y))          /* 水溜りの面積の計算 */

stack<unsigned int> stuiArealeftIdx;        /* 水溜りの左端を保持するstack */
vector<AreaInfo_t> vectAreaInfo;            /* 水溜りの情報を持つvector */

unsigned int Decision(char, unsigned int);  /* 水溜り検出 */
void Fusion(AreaInfo_t);                    /* 水溜り合成 */

/*
水溜りの面積が連続で入力されため、水溜りが構成できる場合、
'\', '_', '/' の順に入力される
*/
int main(void){
    char ch = '\0';                 /* 入力を受け取るバッファ */
    unsigned int uiIdx = 0;         /* 何番目かの入力かをカウントする変数 */
    unsigned int uiTotal = 0;       /* 水溜りの総面積を表す変数 */
    
    /* 入力される文字列を一文字ずつ処理するループ */
    while(cin >> ch)
    {
        /* '\'と'/'で構成される水溜りの一部を計算 */
        uiTotal += Decision(ch, uiIdx);
        uiIdx++;
    }
    
    /* 水溜り情報の出力 */
    cout << uiTotal << endl;
    cout << vectAreaInfo.size();
    
    /* 各水たまりの面積を左側から順に表示 */
    for(vector<AreaInfo_t>::iterator it = vectAreaInfo.begin(); it != vectAreaInfo.end(); it++)
    {
        cout << ' ' <<  it->uiArea;
    }
    cout << endl;
    
    return 0;
    
}

/*
入力された文字によって、構成できる水溜りの一部の面積を計算する
'\'と'/'の一組で水たまりの一部とする
ch      [in] 水溜りを構成する文字
uiIdx   [in] 何番目の文字か
return 水たまりの一部の面積
*/
unsigned int Decision(char ch, unsigned int uiIdx)
{
    unsigned int rslt = 0;  /* 水溜りの一部の面積*/
    
    /*水溜りの面積を構成する文字を判定  */
    switch(ch)
    {
        case '\\':
            /* 入力された最新を取り出すため、水溜りの左端はstackに保存 */
            stuiArealeftIdx.push(uiIdx);
            break;
        case '/':
            /* 水溜りの左端が入力されている場合、左端を取り出し計算 */
            if(!stuiArealeftIdx.empty())
            {
                /* 水溜りの一部の面積の計算と合成の準備 */
                AreaInfo_t tInfo;
                tInfo.uiArea = CALC_AREA(uiIdx, stuiArealeftIdx.top());
                tInfo.uiLeft = stuiArealeftIdx.top();
                /* 水溜りの一部を対応した水溜りに合成 */
                Fusion(tInfo);
                /* 後処理 */
                stuiArealeftIdx.pop();
                rslt =  tInfo.uiArea;
            }
            break;
        case '_':
            // pass
            break;
        default:
            // unreachable
            break;
    }

    return rslt;
}
/*
水溜りの面積の一部同士を合体させ、一つの水たまりとして保存する
tInfo   [in]    最新の水たまりの情報
return  なし
*/
void Fusion(AreaInfo_t tInfo)
{
    /* 水たまりが合成できなくなるまでのループ */
    while(1)
    {
        /* 一つ前の水溜りの面積が保存されている場合 */
        if(!vectAreaInfo.empty())
        {
            /* 最新の水たまりが一つの水たまりよりも内側(入力的には右側)にある場合、 */
            AreaInfo_t tmp = vectAreaInfo.back();
            if(tmp.uiLeft > tInfo.uiLeft)
            {
                /* 最新の水たまりの面積を更新（一つ前の水たまりと合算） */
                tInfo.uiArea += tmp.uiArea;
                vectAreaInfo.pop_back();
                continue;
            }
        }
        /* 最新の水たまりを保存 */
        vectAreaInfo.push_back(tInfo);
        break;
    }

    return;
}



Measured memory_bytes: 3188
//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int int64_t
#define double long double
#define pii pair<int, int>
#define pdd pair<double, double>
#define F first
#define S second
#define pb push_back
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orset;

const int N = 202000;

int32_t main(){
   ios_base :: sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   int n, m;
   cin >> n >> m;
   vector<int> ar(n);
   for(int &i : ar)
      cin >> i;
   int sum = 0;
   for(int i = 0; i < n; i ++)
      sum += ar[i];
   int take = 0;
   int need = sum / (4 * m);
   if(sum % (4 * m) == 0)
      need --;
   for(int i = 0; i < n; i ++){
      if(ar[i] > need)
         take ++;
   }
   if(take >= m)
      cout << "Yes";
   else
      cout << "No";

}


Measured memory_bytes: 256
data="1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(", ").map(&:to_i)

K=gets.to_i
puts data[K-1]


Measured memory_bytes: 3836
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    var cnt = Array<Int>(n, {i -> 0})
    for(i in 0 until k){
        var (a, b) = readLine()!!.split(" ").map(String::toInt)
        a--
        b--
        cnt[a]++
        cnt[b]++
    }    
    for(i in 0 until n){
        if(cnt[i]%2 != 0){
            println("NO")
            return
        }
    }
    println("YES")
}

Measured memory_bytes: 58332
# Aizu Problem 0027: What day is today?
#
import sys, math, os, datetime

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


DAY = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
while True:
    m, d = [int(_) for _ in input().split()]
    if m == d == 0:
        break
    print(DAY[datetime.date(2004, m, d).weekday()])

Measured memory_bytes: 8144
K = int(input())

def gcp(a, b):
  while b % a != 0:
    mod = b % a
    b = a
    a = mod
  return a

ans = 0

for a in range(1, K+1):
  for b in range(1, K+1):
    r = gcp(a, b)
    for c in range(1, K+1):
      ans += gcp(r, c)
      
print(ans)

Measured memory_bytes: 9196
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#include <immintrin.h>

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

#define xor_add(xmm0, xmm1, xmm2) do{ __m128i xmm7 = _mm_add_epi32(xmm1, xmm2); xmm0 = _mm_xor_si128(xmm0, xmm7); }while(0)

int a[200000];
int b[200000];
int main(void){
	int n=nextint();
	for(int i=0; i<n; i++){
		a[i]=nextint();
	}
	for(int i=0; i<n; i++){
		b[i]=nextint();
	}
	int ans=0;
	int m1=(n+1)/2*2;
	int m=(n+15)/16*16;

	__m128i xmm0 = _mm_setzero_si128();
	for(int i=0; i<m1; i+=2){
		__m128i xmm1 = _mm_set1_epi32(a[i+0]);
		__m128i xmm2 = _mm_set1_epi32(a[i+1]);
		for(int j=0; j<m; j+=8){
			__m128i xmm3 = _mm_loadu_si128((__m128i*)&b[j+0]);
			__m128i xmm4 = _mm_loadu_si128((__m128i*)&b[j+4]);
			xor_add(xmm0, xmm1, xmm3);
			xor_add(xmm0, xmm1, xmm4);
			xor_add(xmm0, xmm2, xmm3);
			xor_add(xmm0, xmm2, xmm4);
		}
	}
	int c[4];
	_mm_storeu_si128((__m128i*)&c, xmm0);
	ans^=c[0];
	ans^=c[1];
	ans^=c[2];
	ans^=c[3];
	if(n%2==1){
		for(int i=0; i<n; i++){
			ans^=a[i];
			ans^=b[i];
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3116
#include <stdio.h>
int main(void){
    int x;
    scanf("%d", &x);
    while(1){
        int cnt=0;
        for(int i=2; i<=x; i++){
            if(x%i==0)cnt++;
        }
        if(cnt==1){
            printf("%d\n", x);
            return 0;
        }
        x++;
    }
}


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


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

	string s;
	cin >> s;

	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	
	return 0;
}

Measured memory_bytes: 256
from numba import njit


@njit
def main(X):
    for a in range(-2000, 2001):
        for b in range(-2000, 2001):
            if pow(a, 5) - pow(b, 5) == X:
                print(a, b)
                return


if __name__ == '__main__':
    X = int(input())
    main(X)


Measured memory_bytes: 110456
#include<stdio.h>
#include<string.h>
int main(){
    char a[27];
    int i,j,c=0;
    scanf("%s",a);
    for(i=0;i<strlen(a);i++){
        for(j=i+1;j<strlen(a);j++){
            if(a[i]==a[j])
                c++;
        }
    }
    if(c==0)
        printf("yes");
    else
        printf("no");}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e5 + 5, inf = 1e9;
#define pb push_back
#define mp make_pair
#define ll long long
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define sz(x) (int)x.size()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n, m;
	cin >> n >> m;
	vi a(m);
	ll sum = 0;
	for(int i = 0; i < m; i++)cin >> a[i], sum += a[i];
	cout << max(-1ll, n - sum);
	return 0;
}



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

int main(){
    int n; cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s; cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
#define INF 1145141919810893

int main(){
    vector<char> V;
    string S;
    cin >> S;
    REP(i,S.size()){
        if(S[i]=='S'){
            V.push_back('S');
        }else if(S[i]=='T' && (V.empty() == true || V[V.size()-1]=='T')){
            V.push_back('T');
        }else{
            V.pop_back();
        }
    }
    //cout << V << endl;
    cout << V.size() << endl;
    return 0;
}


Measured memory_bytes: 772
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7;
const int larg = 1e5;

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

int main() {
	int H,W,A,B;
	cin >> H >> W >> A >> B;
	rep(i, H){
		rep(j, W){
			/*if(A == 0 && i<B) cout << "0";
			else if(B == 0 && j<A) cout << "0";
			else */if((i<B&&j<A)||(i>=B&&j>=A)) cout << "0";
			else cout << "1";
		}
		cout << "\n";
	}
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>

#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int main(){

  int n;
  int i=0;

  cin >>n;

  while(i<n){
    i++;
    if(i%10==3 || (i/10)%10==3 || (i/100)%10==3 || (i/1000)%10==3 || i%3==0)cout <<" " <<i;
  }
  cout <<endl;

  return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++)
  {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end(), greater<int>());
  int ans = p.at(0) / 2;
  for (int i = 1; i < N; i++)
  {
    ans += p.at(i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] array = new int[N];
		for(int i=0;i<N;i++) {
			array[i] = sc.nextInt();
		}
		int[] buff = array.clone();
		int M = sc.nextInt();
		int[][] arrayM = new int[M][2];
		long sum=0;

		for(int i=0;i<M;i++) {
			for(int j=0;j<2;j++) {
				arrayM[i][j] = sc.nextInt();
			}
		}

		for(int i=0;i<M;i++) {
			buff[arrayM[i][0]-1] = arrayM[i][1];
			for(int a:buff) {
				sum+=a;
				//System.out.print(a+ " ");
			}
			//System.out.println();
			System.out.println(sum);
			sum=0;
			buff=array.clone();
		}


	}
	public static int sample(int n) {
		return n;
	}

}


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

typedef long long ll;
typedef double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

inline int mul(int a, int b) {
    return (1LL * a * b) % MOD;
}

inline int add(int a, int b) {
    return (0LL + a + b) % MOD;
}

inline int sub(int a, int b) {
    return (0LL + a - b + MOD) % MOD;
}

int mexp(int x, int y) {
    int res = 1;
    while (y) {
        if (y & 1)
            res = mul(res, x);
        y >>= 1;
        x = mul(x, x);
    }
    return res;
}

int f[N], f_inv[N];
void pre() {
    f[0] = 1;
    f_inv[0] = mexp(f[0], MOD - 2);
    for (int i = 1; i < N; i++) {
        f[i] = mul(i, f[i - 1]);
        f_inv[i] = mexp(f[i], MOD - 2);
    }
}

int calc(int p, int q, int m, int n) {
    return mul(f[m - p + n - q], mul(f_inv[m - p], f_inv[n - q]));
}

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

    pre();

    int h, w, a, b;
    cin >> h >> w >> a >> b;

    int ans = 0;
    for (int i = b + 1, cur, prev = 0; i <= w; i++) {
        cur = calc(1, 1, h - a, i);
        ans = add(ans, mul(sub(cur, prev), calc(h - a, i, h, w)));
        prev = cur;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define m(a,b) memset(a,b,sizeof a)
#define en '\n'
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];
int main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int l=1,r=1,tmp=0;ll sum=0;
    while(r<=n)//枚举l,找到最优的r.
    {
        while((a[r]^tmp)==(a[r]+tmp)&&r<=n)
            tmp^=a[r],r++;
        if(r!=n+1)
            sum+=r-l;//分别指区间[l,r-1],[l+1,r-1],[l+2,r-1]....[r-1,r-1].
        else
            sum+=(ll)(r-l)*(ll)(r-l+1)/(ll)2;//因为r==n+,要break了,所以不能只加以l为起点向r-1扩展的,还应加从l+1,l+2...r-1出发的,故sum+=r-l+r-(l+1)+r-(l+2)+...+r-(r-1).
        tmp^=a[l],l++;//tmp的值把异或的a[l]去掉,l右移.
    }
    printf("%lld\n",sum);
}

Measured memory_bytes: 1024
k,t=map(int,input().split())
a=[int(i) for i in input().split()]

a=sorted(a,reverse=True)

if len(a)==1:
	ans=a[0]-1

else:
	while True:
		if a[1]==0:
			ans=max(a[0]-1,0)
			break
		a[0]-=1
		a[1]-=1
		a=sorted(a,reverse=True)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
map<i64, i64> mp;

bool f() {
  if (mp.size() >= 3) return false;

  vector<i64> col, cnt;
  i64 i = 0;
  for (auto p : mp) {
    col.push_back(p.first);
    cnt.push_back(p.second);
  }

  if (mp.size() == 1) {
    if (col[0] <= n / 2 || col[0] == n - 1) return true;
    return false;
  }

  if (col[0] + 1 != col[1] || cnt[1] == 1) return false;

  if (cnt[0] <= col[0] && 
      col[0] < cnt[0] + cnt[1] / 2) return true;
  return false;
}

// a b b b b b
// 1 2 2 2 2 2
//
// a b b c c c
// 2 3 3 3 3 3
//
// a b c c c c
// 2 2 3 3 3 3
//
// a b c c d d
// 3 3 4 4 4 4
//
// a b c d d d
// 3 3 3 4 4 4
//
// a b c d e e
// 4 4 4 4 5 5

int main() {
  cin >> n;
  for (i64 i = 0; i < n; ++i) {
    i64 a;
    cin >> a;
    mp[a]++;
  }
  cout << (f() ? "Yes" : "No") << endl;
  return 0;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;
	int n; cin >> n;
	vector<int> a(n); cin >> a;
	sort(a.begin(), a.end());

	map<int, int> cnt;
	for(int i=0; i<n; i++) cnt[a[i]]++;

	vector<bool> dp(a.back()+1, true);
	for(auto p: cnt){
		for(int j=2; j*p.first<=a.back(); j++){
			dp[j*p.first] = false;
		}
	}

	int ans = 0;
	for(int i=0; i<n; i++){
		if(cnt[a[i]]==1&&dp[a[i]]) ans++;
	}

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


Measured memory_bytes: 13644
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

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

    if (a>=k) {
        cout << k << endl;
    }
    else {
        int ans = a - max(k-a-b,0);
        cout << ans << endl;
    }

}





Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main () {
    int n;
    while (cin >> n) {
        int k;
        cin >> k;
        map<int, int> cnt;
        rep(i, n) {
            int x;
            cin >> x;
            ++cnt[x];
        }

        vector<pair<int,int>> p;
        for (auto &e : cnt) {
            p.emplace_back(e.second, e.first);
        }
        sort(all(p));

        int kinds = p.size();
        int ans = 0;
        for (auto &e : p) {
            if (kinds <= k) break;
            int c, x;
            tie(c, x) = e;
            ans += c;
            kinds--;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 11768
k, a, b = map(int, input().split(" "))
p = 1

if a + 1 >= b:
    print(k + p)
else:
    c = min(k, a - p)
    p += c
    k -= c
    if k == 0:
        print(p)
    else:
        p += (-a + b) * (k // 2)
        k = k % 2
    
    if k == 1:
        print(p + 1)
    else:
        print(p)

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n,m,k;cin>>n>>m>>k;
  vector<ll> a(n), b(m);
  rep(i, n)cin>>a[i];
  rep(i, m)cin>>b[i];

  rep(i, n-1)a[i+1]+=a[i];
  rep(i, m-1)b[i+1]+=b[i];

  ll result=0;
  auto ait = lower_bound(a.begin(), a.end(), k);
  if(ait==a.begin() && *ait<=k)result = max<ll>( result, (ll)(ait-a.begin()) );
  if( ait != a.end() && ait != a.begin() ){
    if(*ait>k)ait--;
    result = max<ll>( result, (ll)(ait-a.begin())+1 );
  }
  
  auto bit = lower_bound(b.begin(), b.end(), k);
  if(bit==b.begin() && *bit<=k)result = max<ll>( result, (ll)(bit-b.begin()) );
  if( bit != b.begin() && bit!=b.end()){
    if(*bit>k)bit--;
    result = max<ll>( result, (ll)(bit-b.begin())+1 );
  }

  rep(i, n){
    ll ac = i+1;
    ll lim = k-a[i];
    if(lim<0)continue;

    result = max<ll>(result, ac);

    auto it = lower_bound(b.begin(), b.end(), lim);
    if(it==b.end())continue;
    if(*it>lim){
      if(it==b.begin())continue;
      it--;
    }

    ll bc = it-b.begin();bc++;
    result = max<ll>(result, ac+bc);
  }

  cout<<result<<endl;

  return 0;
}


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

int main(void) {
    auto chmax = [&](long &x, const long &y) {
        return x<y?x=y,1:0;
    };

    long n;
    cin >> n;

    vector<vector<long>> G(n);
    for(long i=0; i<n-1; i++) {
        long a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    if(n == 1) {
        cout << "First" << endl;
        return 0;
    }

    long v;
    {
        vector<long> dis(n);
        auto dfs = [&] (auto dfs, long cur, long prev) -> void {
            for(auto &v: G[cur]) {
                if(v == prev) continue;
                dis[v] = dis[cur]+1;
                dfs(dfs, v, cur);
            }
        };
        dis[0] = 0;
        dfs(dfs, 0, -1);

        long d = 0;
        for(long i=0; i<n; i++)
            chmax(d, dis[i]) && (v = i);
    }

    long d = 0;
    {
        vector<long> dis(n);
        auto dfs = [&] (auto dfs, long cur, long prev) -> void {
            for(auto &v: G[cur]) {
                if(v == prev) continue;
                dis[v] = dis[cur]+1;
                dfs(dfs, v, cur);
            }
        };
        dis[v] = 1;
        dfs(dfs, v, -1);

        for(auto &e: dis)
            d = max(d, e);
    }

    cout << (d%3==2 ? "Second" : "First") << endl;
}


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

int main() {
  
  	int A,B,count;
  	cin >> A >> B;
  
  	vector<int> C(5);
  	count=0;
  	for(int i=A;i<=B;i++){
    	C.at(0)=i/10000;
      	C.at(1)=(i-C.at(0)*10000)/1000;
      	C.at(2)=(i-C.at(0)*10000-C.at(1)*1000)/100;
      	C.at(3)=(i-C.at(0)*10000-C.at(1)*1000-C.at(2)*100)/10;
      	C.at(4)=i-C.at(0)*10000-C.at(1)*1000-C.at(2)*100-C.at(3)*10;
	      
      	if(C.at(0)==C.at(4) && C.at(1)==C.at(3)){
        	count++;
        }
    }
  
  	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define tc() int t; cin>>t; while(t--)
#define print(n) cout<<n<<"\n"
#define inp(n) int n; cin>>n
#define mem(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define fr(i, n) FOR(i, 0, n, 1)
#define rfr(i, n) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define gcd(a,b)  __gcd(a,b)
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define clr clear
#define len length
#define inf (int)1e9
#define eps 1e-9
#define pi 3.1415926535897932384626433832795
#define h 1000000007
#define read(type) readInt<type>()
#define gc getchar//_unlocked
#define pc putchar//_unlocked
const double PI=acos(-1.0);
#define printlist(a, n) for (ll i = 0; i < n; i++) cout << a[i] << ' ' ; br
#define printvec(v) for (auto itv = v.begin(); itv != v.end(); itv++) cout << *itv << ' ' ; br
#define printset(s) for (auto its = s.begin(); its != s.end(); its++) cout << *its << ' '; br
#define printmap(m) for (auto itm = m.begin(); itm != m.end(); itm++) cout << (*itm).ff << ' ' << (*itm).ss << endl;
#define printmm(m) for (auto itm = m.begin(); itm != m.end(); itm++) cout << (*itm).ff << ' ' << (*itm).ss << endl;
#define print2(a, b) cout << a << ' ' << b; br
#define print3(a, b, c) cout << a << ' ' << b << ' ' << c; br
#define print4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d; br
#define sum(a, n,s) ll s = 0; for (ll i = 0; i < n; i++) s += a[i];
#define br cout << endl;
#define inputlist(arr,n) vi arr(n,0); fr(i,n) {cin>>arr[i];}


typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> seti;
typedef multiset<int> mulset;
typedef long int ld;
typedef unsigned long int uld;
typedef long long int ll;
typedef unsigned long long int  ull;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

bool sortbysec(const tuple<string, int, int>& a,  
               const tuple<string, int, int>& b) 
{ 
	if(get<0>(a)==get<0>(b))
		return (get<1>(a) > get<1>(b));
    return (get<0>(a) < get<0>(b)); 
} 

/*---------------------------------------------------------------------------------------------------------------------------------------*/
signed main()
{
  	fast();
  	inp(n); inp(m);
  	vector<int> v[m];
 	vector<int> p;
	fr(i,m){
 	inp(k);
 	fr(j,k){
 		inp(data);
 		v[i].push_back(data-1);
 	}
 	}
 	fr(i,m){
 	inp(pit);
 	p.push_back(pit);
 	}
 	int ans=0;
 	fr(i,1<<n){
 		int c=0;
 		fr(u,m){
 			int count=0;
	 		for(auto j:v[u]){
	 			if((1<<j)&i)
	 				count++;
	 		}
	 		if(count%2==p[u])
	 			c++;
 		}
	 	if(c==m)
	 		ans++;
 }
 print(ans);
  return 0;
}



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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
	    ll a,b,c,d;
	    cin>>a>>b>>c>>d;
	    bool turn =false;
	    while(a>0 and c>0)
        {
            if(turn)
                a-=d;
            else
                c-=b;
            turn^=1;
        }

        if(a<=0)
            cout<<"No\n";
        else
            cout<<"Yes\n";



	}
	return 0;
}













Measured memory_bytes: 3652
#include <iostream>
#include <array>

int main(){
	std::array<int, 4> a;
	std::array<int, 4> b;
	int hit = 0;
	int blow = 0;

	while(std::cin >> a[0] >> a[1] >> a[2] >> a[3] && std::cin >> b[0] >> b[1] >> b[2] >> b[3]){
		//std::cin >> a[0] >> a[1] >> a[2] >> a[3];
		//std::cin >> b[0] >> b[1] >> b[2] >> b[3];

		for(int i=0; i<4; ++i){
			if(a[i] == b[i]){
				++hit;
			}else{
				for(int j=0; j<4; ++j){
					if(a[i] == b[j] && i != j){
						++blow;
					}
				}
			}
		}

		std::cout << hit << " " << blow << std::endl;

		hit = 0;
		blow = 0;
	}

}

Measured memory_bytes: 3032
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    a = [111,222,333,444,555,666,777,888,999];
    for(i=0;i<9;i++){
        check = a[i]-input;
        if(0 <= check){
            answer = a[i];
            break;
        }
    }
    console.log(answer);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
namespace QiFeng233{
	double r,pi;
	void solve(){
		pi=acos(-1);
		scanf("%lf",&r);
		printf("%.20lf",2.0*r*pi);
	}
}
signed main(){
	QiFeng233::solve();
	return 0;
}

Measured memory_bytes: 3832
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

vector<int>vec[26];


int main(){

	string s;

	cin>>s;

	int i,j;

	for(i=0;i<s.length();i++){
		vec[s[i]-'a'].push_back(i+1);
	}

	for(i=0;i<26;i++){
		if(vec[i].size()>0){
			for(j=0;j<vec[i].size()-1;j++){
				if(vec[i][j+1]-vec[i][j]<=2){
					cout<<vec[i][j]<<" "<<vec[i][j+1]<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"-1"<<" "<<"-1"<<endl;

	return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  double a, b, x;
  cin >> a >> b >> x;
  x /= a;
  const double PI = acos(-1.0);
  cout << fixed << setprecision(10);
  if (x > a * b / 2) {
    cout << atan2(2 * (a * b - x), a * a) * 180 / PI << endl;
  } else {
    cout << atan2(b * b, 2 * x) * 180 / PI << endl;
  }
  return 0;
}

Measured memory_bytes: 4032
class Dice():
    def __init__(self, spots):
        self.spots = [spots[i] for i in range(6)]
    
    def roll(self, direction):
        if direction == 0:
            self.spots = [self.spots[i] for i in [1, 5, 2, 3, 0, 4]]
        elif direction == 1:
            self.spots = [self.spots[i] for i in [3, 1, 0, 5, 4, 2]]
        elif direction == 2:
            self.spots = [self.spots[i] for i in [4, 0, 2, 3, 5, 1]]
        elif direction == 3:
            self.spots = [self.spots[i] for i in [2, 1, 5, 0, 4, 3]]
            
    
spots = list(map(int, input().split()))
moves = input()
my_dice = Dice(spots=spots)
for move in moves:
    if move == 'N':
        my_dice.roll(0)
    elif move == 'E':
        my_dice.roll(1)
    elif move == 'S':
        my_dice.roll(2)
    elif move == 'W':
        my_dice.roll(3)
        
print(my_dice.spots[0])
        


Measured memory_bytes: 5608