akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false; }
template <typename T> bool chmin(T &a, const T& b) {if (a > b) {a = b;return true;}return false; }

struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(0);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} IoSetup;

int main() {
  int n; cin >> n;
  vector<int> vec(n);
  vector<int> exe(n);
  lint x = 1;
  lint sum = pow(3, n);
  rep(i,n) {
    cin >> vec[i];
    if (vec[i] % 2 == 0) {
      x *= 2;
    }
  }
  cout << sum - x << '\n';
  
}


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

typedef long long int ll;

typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision(i) cout << fixed << setprecision(i)

const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;

bool cd(string s){
  bool flag = true;
  REP(i,s.size()){
    if(s.at(i)!='A'&&s.at(i)!='T'&&
    s.at(i)!='G'&&s.at(i)!='C'){
      flag = false;
    }
  }

  return flag;
}

int main() {

  string s;
  cin >> s;

  ll max = 0;
  for(int i=0; i<s.size(); i++){
    for(int j=i; j<s.size(); j++){
      string ps = s.substr(i,j-i+1);
      bool fl = cd(ps);
      if(fl){
        if(max<ps.size()){
          max = ps.size();
        }
      }
    }
  }

  cout << max << endl;

  
}

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

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

  int p[3];
  p[0] = a;
  p[1] = b;
  p[2] = c;

  sort(p,p+3);

  cout << p[2] * 10 + p[1] + p[0] << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long llint;

llint d,n;

void solve(){
	cin >> d >> n;
	if(n == 100) n++;
	
	if(d >= 1) n *= 100;
	if(d >= 2) n *= 100;
	cout << n << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


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



int main(){
	int N;
	scanf("%d",&N);
	int sum=0;
	int a = 0;
	for(int i=0;i<N;i++){
		scanf("%d",&a);
		sum+=a-1;
	}
	
	
	printf("%d\n",sum);	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int N,r[506][506];
int c1[506],c2,c3;

int main(){
	scanf("%d",&N);
	
	for(int i=0;i<N;i++){
		c1[i]=0;
	}
	
	
	for(int i=0;i<N;i++){
		char str[600];
		int check=0;
		scanf("%s",str);
		for(int j=0;j<N;j++){
			if(str[j]=='#'){
				r[i][j]=1;
				c1[j]=1;
			}else{
				r[i][j]=0;
			}
		}
	}
	
	c2=N+1;
	for(int i=0;i<N;i++){
		
		int count=0;
		for(int j=0;j<N;j++){
			if(!r[i][j])
				count++;
		}
		if(!c1[i])
			count++;
		if(c2>count){
			c2=count;
		}
	}
	
	if(c2==N+1){
		printf("-1");
		return 0;
	}
	
	c3=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(!r[j][i]){
				c3++;
				break;
			}
		}
	}
	
	printf("%d\n",c2+c3);
	
	return 0;
}

Measured memory_bytes: 1152
n = int(input())
ans = 0
ary = []
i = 1
ary.append(1)
while 9**i < n+1:
    ary.append(9**i)
    i += 1

i = 1
while 6**i < n+1:
    ary.append(6**i)
    i += 1
ary.sort()

dp = [100002] * (n+1)
dp[0] = 0

for i in range(1,n+1):
    tmp = dp[i] + 1
    for j, aa in enumerate(ary):
        if i >= aa:
            tmp = min(tmp, dp[i-aa] + 1)
        else:
            break
    dp[i] = tmp
print(dp[n])


Measured memory_bytes: 3828
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int n;
  string line;
  cin >> n;
  getline(cin, line);
  while(n--){
    int p;
    getline(cin, line);
    while((p = line.find("Hoshino")) != -1){
      line[p+6] = 'a';
    }
    cout << line << endl;
  }
  return 0;
}

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

void sort(int*, int);
void swap(int*, int*);

int main(void) {
  int n, k;
  int *l;

  scanf("%d %d", &n, &k);
  l = (int *)malloc(sizeof(int) * n);
  if(l == NULL) {
    printf("malloc() failed.\n");
    return 1;
  }
  int i;
  for(i=0;i<n;i++) {
    scanf("%d", &l[i]);
  }

  sort(l, n);
  int ans = 0;
  for(i=0;i<k;i++) {
    ans += l[i];
  }
  printf("%d", ans);
  free(l);
  return 0;
}

void sort(int *data, int length) {
  int i, flag;
  while(1) {
    flag = 0;
    for(i=0;i<length-1;i++) {
      if(data[i] < data[i+1]) {
	swap(&data[i], &data[i+1]);
	flag = 1;
      }
    }
    if(flag == 0) break;
  }
}
void swap(int *x, int *y) {
  int temp = *x;
  *x = *y;
  *y = temp;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#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 allr(v) v.rbegin(), v.rend()


int main() {
  int n;
  cin >> n;
  vector<ll> a(3*n);
  rep(i, 3*n) cin >> a[i];
  sort(all(a));
  
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[n + 2*i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main()
{
	auto N = readln.chomp.to!int;
	int res;
	foreach(i; iota(1,N+1,2))
	{
		int count;
		foreach(k; 1..i+1)
		{
			if(i % k == 0) count++;
		}
		if(count == 8) res++;
	}
	res.writeln;
}

//writeln("滲み出す混濁の紋章　不遜なる狂気の器　湧き上がり　否定し　痺れ　瞬き　眠りを妨げる　爬行する鉄の王女　絶えず自壊する泥の人形　結合せよ　反発せよ　地に満ち己の無力を知れ　破道の九十　黒棺")

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    int m,d;
    cin >> m >> d;

    int ans = 0;
    for(int i=1;i<=m;++i) {
        for(int j=2;j<=d;++j) {
            if(j / 10 == 1 || j % 10 == 1) continue;
            if((j%10) * (j/10) == i) {
                ++ans;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <cstdio>
using namespace std;

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

    map<string, int> mp;
    vector<pair<string, int>> p;
    for (int i = 0; i < n; i++)
    {
        char str1[10];
        char str2[13];
        // cin >> str1 >> str2;
        scanf("%s %s", &str1, &str2);
        if (str1[0] == 'i' && mp[str2] == 0)
        {
            mp[str2] = i + 1;
        }
        else if (str1[0] == 'f')
        {
            p.push_back(make_pair(str2, i + 1));
        }
    }

    // cout << "--------------------" << endl;
    // for (auto x : mp)
    // {
    //     cout << x.first << ", " << x.second << endl;
    // }
    // cout << "--------------------" << endl;
    // for (auto x : p)
    // {
    //     cout << x.first << ", " << x.second << endl;
    // }

    for (int i = 0; i < p.size(); i++)
    {
        if (mp[p[i].first] < p[i].second && mp[p[i].first] != 0)
        {
            // cout << "yes" << endl;
            printf("yes\n");
        }
        else
        {
            // cout << "no" << endl;
            printf("no\n");
        }
    }

    return 0;
}


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

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

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

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

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  string ta; cin >> ta;
  int a[N]; rep(i,N) a[i] = ta[i]-'1';
  int count[3] = {}; rep(i,N) count[a[i]]++;
  int dv2[N] = {}, c2[N] = {};
  repr(i,1,N) {
    int tn = i;
    while (tn%2==0) {
      tn /= 2;
      dv2[i]++;
    }
  }
  repr(i,1,N) c2[i] = c2[i-1] + dv2[N-i] - dv2[i];
  // debug(dv2,dv2+N); debug(c2,c2+N);

  int result = 0;
  if (count[1]==0) {
    int sum = 0; rep(i,N) if (a[i]==2) sum += (c2[i]==0);
    // cout << sum << endl;
    if (sum%2==1) result = 2;
  }
  else {
    int sum = 0; rep(i,N) if (a[i]==1) sum += (c2[i]==0);
    // cout << sum << endl;
    if (sum%2==1) result = 1;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 13188
s =list(str(input()))
s = [int(c) for c in s]
s.reverse()

n = len(s)
p = 2019

def power(a, n, mod):
  bi=str(format(n,"b")) #2進数
  res=1
  for i in range(len(bi)):
    res=(res*res) %mod
    if bi[i]=="1":
      res=(res*a) %mod
  return res

temp = 0
cum = [0]*n
for i in range(n):
    temp += s[i]*power(10, i, p)
    temp = temp%p
    cum[i] = temp
cum = [0]+cum

#print(cum)

d = {}
ans = 0
for i in range(n+1):
  if cum[i] not in d:
    d[cum[i]] = 1
  else:
    ans += d[cum[i]]
    d[cum[i]] += 1
print(ans)


Measured memory_bytes: 87756
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sun Jun 10 21:02:32 2018
//
package main

import "fmt"

var a, b int

func main() {
	fmt.Scan(&a, &b)
	n := b - a - 1
	fmt.Println(n*(n+1)/2 - a)
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

int dp[3][100000];
long long solve( vector<vector<int> > &a,int i,int j)
{
    
    if(dp[i][j]!=-1)return dp[i][j];
    if(j==a[0].size()-1)
        {dp[i][j]=a[i][j];return dp[i][j];}
  
    dp[i][j]=a[i][j]+max(solve(a,(i-1+3)%3,j+1),solve(a,(i+1)%3,j+1));
    return dp[i][j];
}

int main()
{
  int n;
  cin>>n;
  memset(dp,-1,sizeof(dp));
  vector<vector<int> > a(3,vector<int> (n));
  for(int i=0;i<n;i++)
  {
    cin>>a[0][i]>>a[1][i]>>a[2][i];
  }
  cout<<max(max(solve(a,0,0),solve(a,1,0)),solve(a,2,0));
  
  return 0;
}

Measured memory_bytes: 10364
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    

    ll x;
    cin >> x;
    ll ten = x % 100;
    ll hun = x / 100;
    if(hun * 5 < ten){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    int n;
    cin>>n;
    if(n==0)
    cout<<2<<endl;
    else if(n==1)
    cout<<1<<endl;
    else
    {
        long long int a=2,b=1,pre=0;
        for(int i=2;i<=n;i++)
        {
            pre=a+b;
            a=b;
            b=pre;
        }
        cout<<pre;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3664
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;
const double PI = 3.1415926;
int main()
{
    int r;
    scanf("%d", &r);
    printf("%.10f\n", 2 * PI * r);
    return 0;
}



Measured memory_bytes: 3232
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<ceil(log2(double(n)))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	printf("%d\n",n-(k)+1);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
ll dp[1000005][2]={0};
const ll inf=1e18;
int main(){
  string s;
  cin>>s;
  ll d=s.length();
  for(int i=0;i<1000005;i++){
    dp[i][0]=inf;
    dp[i][1]=inf;
  }
  dp[0][0]=0;
  reverse(s.begin(),s.end());
  for(int i=0;i<d;i++){
    if(s[i]!='9'){
      ll k=(ll)(s[i]-'0');
      dp[i+1][0]=min(dp[i][0]+k,dp[i][1]+k+1);
      dp[i+1][1]=min(dp[i][0]+10-k,dp[i][1]+9-k);
    }
    else{
      dp[i+1][0]=dp[i][0]+9;
      dp[i+1][1]=min(dp[i][0]+1,dp[i][1]);
    }
  }
  cout<<min(dp[d][0],dp[d][1]+1)<<endl;
}


Measured memory_bytes: 17028
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int MR=1e6+10;
const int INF=2e9+10;
typedef long long LL;

int H,W,K;
int s[15][1005];
int b[15][1005];

int work(int p){
	int cut[15],ans=0,l;
	cut[0]=0;l=1;
	for(int i=1;i<H;i++){
		if(p&1){
			cut[l]=i;l++;
			ans++;
		}
		p/=2;
	}
	cut[l]=H;
	//for(int i=0;i<l;i++)printf("%d ",cut[i]);printf("\n");
	int pre=0,cnt[15],maxcnt;
	while(pre<W){
		memset(cnt,0,sizeof(cnt));
		maxcnt=-1;
		for(int j=pre+1;j<=W;j++){
			for(int i=1;i<=l;i++){
				cnt[i]+=b[cut[i]][j]-b[cut[i-1]][j];
				maxcnt=max(maxcnt,cnt[i]);
			}
			if(maxcnt>K){
				if(pre==j-1) return INF;
				pre=j-1;
				ans++;
				break;
			}
			if(j==W){
				pre=W;
			}
		}
	}

	return ans;
}


int main() {
	scanf("%d%d%d",&H,&W,&K);
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			scanf("%1d",&s[i][j]);
			b[i][j]=b[i-1][j]+s[i][j];
		}
	}
	int cap=1<<(H-1);
	int ans=H+W;
	for(int p=0;p<cap;p++){
		ans=min(ans,work(p));
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for k in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for k in range(c)] for k in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def compress(A):
    """ 座標圧縮 """

    zipped, unzipped = {}, {}
    for i, a in enumerate(sorted(set(A))):
        zipped[a] = i
        unzipped[i] = a
    return zipped, unzipped

while True:
    W, H = MAP()
    if W == H == 0:
        break
    N = INT()
    X = []
    Y = []
    XY = []
    for i in range(N):
        x1, y1, x2, y2 = MAP()
        X += [x1-1, x1, x2-1, x2]
        Y += [y1-1, y1, y2-1, y2]
        XY.append((x1, y1, x2, y2))

    # 座標圧縮
    X_zipped, _ = compress(X + [-1, 0, W])
    Y_zipped, _ = compress(Y + [-1, 0, H])
    for i in range(N):
        # 圧縮後の値に置き換え
        x1, y1, x2, y2 = XY[i]
        XY[i] = (X_zipped[x1], Y_zipped[y1], X_zipped[x2], Y_zipped[y2])

    # ここから全部圧縮後の値でやる
    H, W = len(Y_zipped), len(X_zipped)
    grid = list2d(H, W, 0)
    # 2次元いもす
    for i in range(N):
        x1, y1, x2, y2 = XY[i]
        grid[y1][x1] += 1
        grid[y2][x1] -= 1
        grid[y1][x2] -= 1
        grid[y2][x2] += 1
    for i in range(H):
        grid[i] = list(accumulate(grid[i]))
    grid = list(zip(*grid))
    for i in range(W):
        grid[i] = list(accumulate(grid[i]))
    grid = list(zip(*grid))
    # 枠を-1にしておく
    grid[0] = [-1] * W
    grid[H-1] = [-1] * W
    grid = list(zip(*grid))
    grid[0] = [-1] * H
    grid[W-1] = [-1] * H
    grid = list(zip(*grid))

    directions = ((1,0),(-1,0),(0,1),(0,-1))
    visited = list2d(H, W, 0)
    def dfs(i, j):
        if visited[i][j] or grid[i][j] != 0:
            return 0
        stack = [(i, j)]
        while stack:
            h, w = stack.pop()
            visited[h][w] = 1
            for dh, dw in directions:
                h2 = h + dh
                w2 = w + dw
                if not visited[h2][w2] and grid[h2][w2] == 0:
                    stack.append((h2, w2))
        return 1

    cnt = 0
    for i in range(1, H-1):
        for j in range(1, W-1):
            cnt += dfs(i, j)
    print(cnt)



Measured memory_bytes: 56800
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.next();

            Console.WriteLine(s.Replace(',',' '));
        }
    }    

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}

Measured memory_bytes: 11092
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,T=pin()
    t=tupin()

    ans=0
    for i in range(1,N):
        temp=t[i]-t[i-1]
        if temp>T:ans+=T
        else: ans+=temp
    print(ans+T)
#%%submit!
resolve()

Measured memory_bytes: 84980
from collections import deque

K = int(input())
dque = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

ans = 0
while True:
    v = dque.popleft()
    ans += 1
    if ans == K:
        print(v)
        exit(0)

    for i in range(-1, 2):
        # 10で割った余りを取得して、iを足す
        tmp = v % 10+i
        if not(0 <= tmp <= 9):
            continue
        dque.append(v*10+tmp)

Measured memory_bytes: 12396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int a, b;
    cin >> a >> b;
    switch(a+b){
        case 3: 
            cout<<3;
            break;
        case 4: 
            cout<<2;
            break;
        case 5: 
            cout<<1;
            break;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n, k; cin >> n >> k;
  vector<pair<long long, long long>> v(n);
  long long sum = 0;
  int index;
  for(int i = 0; i < n; ++i){
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < n; ++i){
    sum += v[i].second;
    if(sum >= k){
      index = i;
      break;
    }
  }
  cout << v[index].first << endl; 
}

Measured memory_bytes: 1792
p, g, ig = 998244353, 3, 332748118
W = [pow(g, (p - 1) >> i, p) for i in range(24)]
iW = [pow(ig, (p - 1) >> i, p) for i in range(24)]

def fft(k, f):
    for l in range(k, 0, -1):
        d = 1 << l - 1
        U = [1]
        for i in range(d):
            U.append(U[-1] * W[l] % p)
        
        for i in range(1 << k - l):
            for j in range(d):
                s = i * 2 * d + j
                t = s + d
                f[s], f[t] = (f[s] + f[t]) % p, U[j] * (f[s] - f[t]) % p

def ifft(k, f):
    for l in range(1, k + 1):
        d = 1 << l - 1
        U = [1]
        for i in range(d):
            U.append(U[-1] * iW[l] % p)
        
        for i in range(1 << k - l):
            for j in range(d):
                s = i * 2 * d + j
                t = s + d
                f[t] *= U[j]
                f[s], f[t] = (f[s] + f[t]) % p, (f[s] - f[t]) % p

def convolve(a, b):
    n0 = len(a) + len(b) - 1
    k = (n0).bit_length()
    n = 1 << k
    a = a + [0] * (n - len(a))
    b = b + [0] * (n - len(b))
    fft(k, a), fft(k, b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(k, a)
    invn = pow(n, p - 2, p)
    for i in range(n0):
        a[i] = a[i] * invn % p
    del a[n0:]
    return a

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
print(*convolve(A, B))


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

int main(){
    int n;
    cin >> n;
    int t[n];
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> t[i];
        sum += t[i];
    }
    int m;
    cin >> m;
    int p[m];
    int x[m];
    for(int i = 0; i < m; i++){
        cin >> p[i] >> x[i];
    }

    for(int i = 0; i < m; i++){
            sum -= t[p[i] - 1];
            sum += x[i];
            cout << sum << endl;
            sum -= x[i];
            sum += t[p[i] - 1];
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
main(){
   
  char s[100];
  char this[10]="this";
  char that[10]="that";
  char the[10]="the";
 
  while(fgets(s,sizeof(s),stdin)!=NULL){
   
    int n,i;
   
    n=strlen(s);
   
   
    while(1){
 
      int co=0;
       
      for(i=0;i<n;i++){
    if(97<=s[i] && 122>=s[i]){
      s[i]--;
      if(s[i]==96){
        s[i]=122;
      }
    }
      }
     
      for(i=0;i<n;i++){
    if(s[i]==this[0]){
      if(s[i+1]==this[1]){
        if(s[i+2]==this[2]){
          if(s[i+3]==this[3]){
        co=1;
          }
        }
        else if(s[i+2]==that[2]){
          if(s[i+3]==that[3]){
        co=1;
          }
        }
        else if(s[i+2]==the[2]){
          co=1;
        }
      }
    }
      }
 
      if(co==1){
    break;
      }
       
    }
    printf("%s",s);
  }  
  return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#define maxn 200010
using namespace std;
int f[maxn],cnt[maxn];
int getf(int u){
	return f[u]==u?u:f[u]=getf(f[u]);
}
void merge(int u,int v){
	int f1,f2;
	f1=getf(u),f2=getf(v);
	if(f1!=f2)f[f2]=f1;
}
int main(){
	int n,m,i,u,v,mx=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)f[i]=i;
	for(i=1;i<=m;i++)scanf("%d%d",&u,&v),merge(u,v);
	for(i=1;i<=n;i++)cnt[getf(i)]++;
	for(i=1;i<=n;i++)mx=max(mx,cnt[i]);
	printf("%d\n",mx);	
	return 0;
}


Measured memory_bytes: 5184
#include <stdio.h>

int main(void)
{
	long long int a,b,d,r;
	double f;
	scanf("%lld %lld",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%lld %lld %lf\n",d,r,f);
	return 0;
}

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

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI M_PI
#define bf printf("\n");

int main(void){
    int r;
    scanf("%d",&r);

    printf("%.5f\n", (double)2 * r * PI);    
    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define pld pair <ld, ld>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 1e6 + 100;

ll n, m, k, t;

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b, c, d;
    string s;
    cin >> s;
    n = s.length();
    ll cnta = 0, ans = 0;
    for (q = 0; q < n; q++) {
        if (s[q] == 'A') {
            cnta++;
        }
        else {
            if (q < n - 1) {
                if (s[q] == 'B' && s[q + 1] == 'C') {
                    ans += cnta;
                    q++;
                }
                else {
                    cnta = 0;
                }
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3796
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut a: Vec<bool> = vec![false; 101];

    for _ in 0..n {
        let ai: usize = read();
        a[ai] = true;
    }

    println!("{}", a.iter().filter(|&x| *x == true).count())
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
const int mod = 1e9 + 7;
int main()
{

  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  ll w,s;
  cin>>s>>w;
  if(w>=s)cout<<"unsafe";
  else cout<<"safe";
  

} 

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

typedef long long ll;

int main(){
    ll h, w;
    cin >> h >> w;

    ll w2 = w/2, h2 = h/2;
    ll ans = 1ll<<55;
    for(ll i = 1; i < h; i++){
        ll a = i*w;
        ll b = (h-i)*w2;
        ll c = (h-i)*(w-w2);
        ans = min(ans, max(a,max(b,c))-min(a,min(b,c)));
    }
    for(ll i = 1; i < w; i++){
        ll a = i*h;
        ll b = (w-i)*h2;
        ll c = (w-i)*(h-h2);
        ans = min(ans, max(a,max(b,c))-min(a,min(b,c)));
    }
    
    if(h%3 == 0 || w%3 == 0)    ans = 0;
    if(h >= 3)  ans = min(ans, w);
    if(w >= 3)  ans = min(ans, h);
    cout << ans << endl;

    return 0;
}

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

int main(){
    int f,e;
    string s, ret;
    cin >> s;
    f = stoi(s.substr(0,2));
    e = stoi(s.substr(2));
    
    if(f > 0 && f < 13){
        if(e > 0 && e < 13){
            ret = "AMBIGUOUS";
        }else{
            ret = "MMYY";
        }
    }else if(e > 0 && e < 13){
        if(f > 0 && f < 13){
            ret = "AMBIGUOUS";
        }else{
            ret = "YYMM";
        }
    }else{
        ret = "NA";
    }

    cout << ret << endl;
}

Measured memory_bytes: 256
# AGC 007: A – Shik and Stone
H, W = [int(s) for s in input().split()]
A = [input() for _ in range(H)]

isExact = 'Possible'

i, j = 0, 0

while i < H - 1 or j < W - 1:
    if ((i + 1 < H and A[i + 1][j] != '#') and (j + 1 < W and A[i][j + 1] != '#')) \
            or (i + 1 == H and j + 1 < W and A[i][j + 1] != '#') \
            or (i + 1 < H and j + 1 == W and A[i + 1][j] != '#'):
        isExact = 'Impossible'
        break
    elif j + 1 < W and A[i][j + 1] == '#':
        A[i] = A[i][:j] + '.' + A[i][j + 1:]
        j += 1
    elif i + 1 < H and A[i + 1][j] == '#':
        A[i] = A[i][:j] + '.' + A[i][j + 1:]
        i += 1

if isExact == 'Possible':
    A[H - 1] = A[H - 1][:W - 1] + '.'

    for line in A:
        if '#' in line:
            isExact = 'Impossible'
            break

print(isExact)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i< n; i++)
typedef unsigned long long ll;
typedef pair<int, int> P;
const ll LM = 1LL<<63;

ll tonum(string s, int N){
  ll res = 0;
  int n = s.size();
  rep(i, n){
    ll m = (isdigit(s[i])) ? s[i] - '0' : s[i] - 'A' + 10;
    res = res * (ll)N + m;
  }
  return res;
}

ll get_cnt(ll M, ll i, ll cnt){
  ll res = 0;
  ll num = 1;
  while(num < LM / i){
    num *= i;
    res += M / num;
  }
  return res / cnt;
}

int main(){
  ll N, M;
  string s;
  while(cin >> N >> s && (N || s != "0")){
    M = tonum(s,N);
    ll res = LM;
    for(ll i = 2; i * i <= N; i++){
      if(N%i == 0){
	ll cnt = 0;
	while(N % i == 0) {
	  cnt++;
	  N /= i;
	}
	res = min(res, get_cnt(M, i, cnt));
      }
    }
    if(N > 1) res = min(res, get_cnt(M, N, 1));
    cout << res << endl;
  }
  return 0;

}

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

using namespace std;


int N, ans=0, last;

int main()
{
    cin>>N;
    vector <int> H(N);
    for (int i=0; i<N; i++)
    {
        cin>>H[i];
    }

    for (int i=0; i<N; i++)
    {
        int ok = 1;
        for (int j=0; j<i; j++)
        {
            if (H[j]>H[i])
            {
                ok=0;
            }
        }
        if (ok)
        {
            ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >>s;
    if(s[5]=='1'){
        cout <<"TBD";
    }else{
        if(s[6]>='5'){
            cout <<"TBD";
        }else{
            cout <<"Heisei";
        }
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int T[105]={0};
int main(){
  int n;scanf("%d",&n);int sum=0;
  for(int i=0;i<n;i++){
    int k;scanf("%d",&k);
    sum+=k;
    T[i]=n*k;
  }
  int dif=1000000000;
  int ans=0;
  for(int i=0;i<n;i++){
    if(abs(sum-T[i])<dif){ans=i;dif=abs(sum-T[i]);}
  }
  printf("%d \n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


int N, K;
int a[1001];

signed main(){

	int sum[1002];

	cin >> N >> K;
	for (int i = 0; i < N; i++)
		cin >> a[i];

	sum[0] = 0;
	for (int i =0 ; i < N; i++){
		sum[i+1] = sum[i] + a[i];
	}

	vector<int> current;
	for (int i = 0; i < N; i++){
		for (int j = i; j < N; j++){
			int s = sum[j + 1] - sum[i];
			current.push_back(s);
		}
	}


	// 上のビットからk個以上たっているものを調べる
	for (int bitmax = 63; bitmax >= 0; bitmax--){
		vector<int> next;
		int bit = -1;
		for (int b = bitmax; b >= 0; b--){
			int c = 0;
			for (int i = 0; i < current.size(); i++){
				if (current[i] & (1LL << b)) c++;
			}
			if (c >= K){
				// b bit目がK個以上たっているので、それだけを抽出
				bit = b;

				next.clear();
				for (int i = 0; i < current.size(); i++){
					if (current[i] & (1LL << bit)) next.push_back(current[i]);
				}
				bitmax = bit - 1;
				current = next;
			}
		}
		if (bit == -1)continue;

	}

	int ans=(1LL<<60)-1;
	if (current.size() >= K){
		for (int i = 0; i < K; i++){
			ans = ans & current[i];
		}
		cout << ans << endl;
	}
	else{
		cout << 0 << endl;
	}

	return 0;
}


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

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


int main(){
  while (1){
    int N,T,L,B;
    cin >>N >>T >>L >>B;
    if(N==0) break;

    vector<bool> lose(N+1);
    vector<bool> back(N+1);
    //?????????
    fill(lose.begin(), lose.end(), false);
    fill(back.begin(), back.end(), false);

    for(int i=0; i<L; ++i){
      int t; cin>>t;
      lose[t]=true;
      if(t>=N-5) lose[2*N-t]=true;
    }
    for(int i=0; i<B; ++i){
      int t; cin>>t;
      back[t]=true;
      if(t>=N-5) back[2*N-t]=true;
    }

    //p[t][n]:t?????????????????????n??????????¢????
    double p[101][106];

    //????????¶???
    p[0][0]=1.0;
    for(int i=1; i<=105; ++i) p[0][i]=0.0;

    for(int t=1; t<=T; ++t){
      //printf("go %d turn\n", t);

      double suuuu=0.0;

      for(int n=0; n<=N+5; ++n){
        p[t][n]=0.0;

        if(n==N) p[t][n]+=p[t-1][n];

        if(lose[n]){
          int pp=1;
          double tmp=0.0;
          for(int i=t-1; i>=0; --i){
            tmp+=p[i][n]*pp;
            pp*=-1;
          }
          p[t][n] += tmp;
          //printf("%d, %d: tmp=%lf\n ",t, n, tmp);
        }

        for(int k=1; k<=6; ++k){
          if(n-k<0) break;
          if(n-k==N) continue;
          //printf("n: %d, k: %d\n", n,k);

          if(lose[n-k]){
            //printf("  go go n: %d, k: %d   ", n,k);

            int pp=1;
            double tmp2=0.0;
            for(int i=t-2; i>=0; --i){
              tmp2+=p[i][n-k]*pp;
              pp*=-1;
            }
            //printf(" tmp2=%lf\n", tmp2);

            p[t][n] +=tmp2/6.0;
          }
          else p[t][n] += p[t-1][n-k]/6.0;

        }

        //printf("p[%d][%d] = %lf\n",t, n, p[t][n]);
        suuuu += p[t][n];

        if(n>N){
          p[t][N-(n%N)] += p[t][n];
          p[t][n]=0.0;
        }
      }

      //printf("suuuu = %lf\n", suuuu);

      for(int n=1; n<N; ++n){
        if(back[n]){
          //printf("back %d\n", n);
          p[t][0]+=p[t][n];
          p[t][n]=0.0;
        }
      }

      /*
      double checksum=0.0;
      for(int n=0; n<=N; ++n){
        checksum+=p[t][n];
        printf("p[%d][%d] = %.10lf\n", t, n, p[t][n]);
      }
      printf(" ch=%.10lf\n", checksum);
      */
    }

    printf("%.10lf\n", p[T][N]);
  }
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	bool ch=false;
	while(n!=0){
		if(n%10==7){
			ch=true;
		}
		n/=10;
	}
	cout << (ch?"Yes":"No");
	// your code goes here
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

long double maxd(long double x, long double y){
    if(x>=y) return x;
    else return y;
}

int main() {
    long double N, K; cin >> N >> K;
    vector<long double> p(N);
    vector<long double> sum(N+1);
      
    rep(i, N){
        cin >> p.at(i);
        sum.at(i+1) = sum.at(i) + p.at(i);
    }

    long double ans = 0;
    rep(i, N-K+1){
        ans = maxd(ans, (sum.at(i+K)-sum.at(i)+K)/2);
    }
    cout << setprecision(10) << ans << endl;
}

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

std::vector<int> MPAlgorithm(const std::string& str)
{
	std::vector<int> vec(str.size() + 1);
	vec[0] = -1;
	for (int i{}; i < (int)str.size(); i++)
	{
		int prev{vec[i]};
		while (prev >= 0 && str[prev] != str[i]) prev = vec[prev];
		vec[i + 1] = prev + 1;
	}
	return std::move(vec);
}

std::vector<int> edges, length, rootTable;
int dfs(int, int);

int main()
{
	std::string S, T;
	std::cin >> S >> T;
	auto mp{MPAlgorithm(T)};
	edges.resize(S.size(), -1);
	for (int t_i{}, s_i{}; s_i <= (int)(S.size() + T.size()); s_i++)
	{
		while (t_i >= 0 && T[t_i] != S[s_i % (int)S.size()]) t_i = mp[t_i];
		t_i++;
		if (t_i != (int)T.size()) continue;
		edges[(s_i - (int)T.size() + 1) % (int)S.size()] = (s_i + 1) % (int)S.size();
		t_i = mp[t_i];
	}
	length.resize(S.size(), -1);
	rootTable.resize(S.size(), -1);
	int max{};
	for (int i{}; i < (int)S.size(); i++)
		max = std::max(max, dfs(i, i));
	if (max >= (1 << 30)) puts("-1");
	else printf("%d\n", max);

	return 0;
}

int dfs(int index, int root)
{
	if (index < 0) return -1;
	if (rootTable[index] == root) return 1 << 30;
	rootTable[index] = root;
	if (length[index] >= 0) return length[index];
	length[index] = dfs(edges[index], root) + 1;
	return length[index];
}

Measured memory_bytes: 24840
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int main() {
    int a, b;
    while (~scanf("%d %d", &a, &b)) {
          if (a * b == 15) puts("*");
          else if (a + b == 15) puts("+");
          else puts("x");
    }
    return 0;
}


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

int main() {
  char C;
  cin >> C;

  if((C=='a')||(C=='e')||(C=='i')||(C=='o')|| (C=='u')){
    cout <<"vowel" <<endl;
  }

  else{
    cout <<"consonant" <<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    string ans;
    for(int i = 0; i < 9; ++i)
    {
        int s = 0, e = 10;
        while(s + 1 < e)
        {
            int mid = s + e >> 1;
            cout << "? " << ans << mid;
            for(int j = 0; j < 9 - i; ++j) cout << 0;
            cout << endl; cout.flush();

            char c; cin >> c;
            if(c == 'Y') e = mid;
            else s = mid;
        }

        if(ans.empty() && !s) { ans += '1'; break; }
        cout << "? " << ans << s;
        for(int j = 0; j < 9 - i; ++j) cout << 9;
        cout << endl; cout.flush();

        char c; cin >> c;
        if(c == 'N') { ans += ('1' + s); break; }
        ans += ('0' + s);
    }

    if(ans == "1")
    {
        int k = 0;
        while(1)
        {
            cout << "? 2";
            for(int i = 0; i < k; ++i) cout << 0;
            cout << endl; cout.flush();
            char c; cin >> c;
            if(c == 'Y') break;
            ++k;
        }
        cout << "! 1";
        for(int i = 0; i < k; ++i) cout << 0;
        cout << endl; cout.flush();
    }
    else
    {
        int k = 9;
        ans.back() -= 1;
        while(1)
        {
            cout << "? " << ans;
            for(int i = 0; i < k; ++i) cout << 9;
            cout << endl; cout.flush();
            char c; cin >> c;
            if(c == 'Y') break;
            --k;
        }
        ans.back() += 1;
        cout << "! " << ans;
        for(int i = 0; i < k; ++i) cout << 0;
        cout << endl; cout.flush();
    }
}


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

const int N=1e5+100;

int op[N*3],cl[N*3];
int n;

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		op[l+N]+=1;
		cl[r+N]+=1;
	}
	long long ans=0;
	int cl_l=0,op_r=n;
	for(int i=0;i<3*N-1;i++){
		cl_l+=cl[i];
		op_r-=op[i];
		if(i-N<0) ans+=min(cl_l,op_r+1);
		else ans+=min(cl_l+1,op_r);
	}
	printf("%lld",ans*2);
	return 0;
}

Measured memory_bytes: 1792
N, C = map( int, input().split())
timetable = [ [0]*(10**5) for _ in range(C)]
for _ in range(N):
    s,t,c = map( int, input().split())
    timetable[c-1][s-1:t] = [1]*(t-s+1)
# for c in range(C):
#     print(timetable[c][:20])
ans = 0
for i in range(10**5):
    now = 0
    for c in range(C):
        now += timetable[c][i]
    if ans < now:
        ans = now
print(ans)


Measured memory_bytes: 26612
# -*- coding:utf-8 -*-

def solve():
    D = int(input())
    if D == 25:
        print("Christmas")
    elif D == 24:
        print("Christmas Eve")
    elif D == 23:
        print("Christmas Eve Eve")
    else:
        print("Christmas Eve Eve Eve")

if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
N,D=map(int,input().split())
a=[input().split() for i in range(N)]
c=0
for i in range(N-1):
  for j in range(i+1,N):
    b=0
    for m in range(D):
      b+=(int(a[i][m])-int(a[j][m]))**2
    if b**0.5==float(int(b**0.5)):
                    c+=1
print(c)

Measured memory_bytes: 3060
from  collections  import deque

N, M = map(int, input().split())
AB = [[] for _ in range(N+1)]

for _ in range(M):
  A, B = map(int, input().split())
  AB[A].append(B)
  AB[B].append(A)

ans = [0] * (N + 1)
visited = [0] * (N + 1)
root = 1
visited[root] = 1
q = deque([root])

while q:
  v = q.popleft()
  for w in AB[v]:
    if visited[w]:
      continue
    visited[w] = 1
    ans[w] = v
    q.append(w)
    
print('Yes')
for i in ans[2:]:
  print(i)
  

Measured memory_bytes: 35592
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
using namespace std;

int main() {
	char a[2],b[2];
	for (int i = 0; i <= 2; ++i) cin >> a[i];
	cout << endl;
	for (int i = 0; i <= 2; ++i) cin >> b[i];
	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) YES;
	else NO;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll n, a, b;
  cin >> n >> a >> b;
  
  cout << ( a>b or (n==1 and a!=b) ?0 :( a+(n-1)*b) -(b+(n-1)*a) +1) << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
using namespace std;

int main(){
    int N,K;
    string S,T;
    cin >> N >> S >> K;
    T.resize(S.size());
    char c = S[K-1];
    for(int i = 0; i < N; i++){
        if(S[i] != c){
            T[i] = '*';
        }else{
            T[i] = S[i];
        }
    }
    cout << T << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N, M;
  cin >> N >> M;
  ll l_max = 0;
  ll r_min = INF;

  rep(i, N) {
    ll l, r;
    cin >> l >> r;
    if (i == 0) {
      l_max = l;
      r_min = r;
    } else {
      if (l_max > r || r_min < l) {
        COUT(0);
        return 0;
      }
      l_max = max(l_max, l);
      r_min = min(r_min, r);
    }
  }

  if (r_min - l_max + 1 < 0) {
    COUT(0);
  }
  COUT(r_min - l_max + 1);
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
typedef tuple<ll,ll,ll> T;
long long euclid(long long x,long long y){
    long long a=max(x,y);
    long long b=min(x,y);
    if(a%b==0)return b;
    else{
        return euclid(b,a%b);
    }
}
long long ruijou(long long x, long long y){
    if(y==0) return 1;
    else if(y%2==0) return ruijou(x*x%mod,y/2);
    else return x*ruijou(x,y-1)%mod;
}


ll i,j,k;

int main(){
   string T;
   cin>>T;
   string ans="";
   rep(i,T.length()){
       if(T[i]=='?'){
           ans+="D";
       }
       else ans+=T[i];
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3920