akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e2 + 5;

int a[N];
int n,x;

int32_t main()
{
	IOS;
	cin >> n >> x;
	rep(i,1,n)
	{
		cin >> a[i];
	}
	int cur=0;
	int i=1;
	int c=0;
	c=1;
	while(cur<=x && i<=n)
	{
		cur += a[i];
		if(cur>x)
		{
			break;
		}
		c++;
		i++;
	}
	cout << c << endl;
}


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

int main() {
  string S;
  cin >> S;

  int cnt_b = 0;
  int cnt_w = 0;

  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == '0') cnt_b++;
    else cnt_w++;
  }
  cout << 2 * min(cnt_b, cnt_w) << endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	long long int n;
	cin >> n;
	if (n % 2 == 1)
	{
		cout << 0 << endl;
	}
	else
	{
		n /= 2;
		long long int ans = 0;
		long long int tmp = 5;
		while (tmp <= n)
		{
			ans += n / tmp;
			tmp *= 5;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
T = int(input())
NMAB = [tuple(map(int,input().split())) for i in range(T)]

def floor_sum(n,m,a,b):
    ret = 0
    if a >= m:
        ret += (n-1) * n * (a//m) // 2
        a %= m
    if b >= m:
        ret += n * (b//m)
        b %= m
    y_max = (a * n + b) // m
    x_max = y_max * m - b
    if y_max == 0: return ret
    ret += (n - (x_max + a - 1) // a) * y_max
    ret += floor_sum(y_max, a, m, (a - x_max%a)%a)
    return ret

for n,m,a,b in NMAB:
    print(floor_sum(n,m,a,b))

Measured memory_bytes: 23996
<?php
fscanf(STDIN, "%d", $n);
$x = 1;
while ($n--) {
	fscanf(STDIN, "%d", $t);
	$x = $x / gcd($x, $t) * $t;
}
echo $x;

function gcd($n, $m) {
	return $n % $m ? gcd($m, $n % $m) : $m;
}


Measured memory_bytes: 4604
#include <stdio.h>
int main(void){
    int a,b,c,d,e;
    scanf("%d",&a);
    b=a/1000;
    c=(a-b*1000)/100;
    d=(a-b*1000-c*100)/10;
    e=(a-b*1000-c*100-d*10);
    if(b+c+d+e==7){
        printf("%d+%d+%d+%d=7",b,c,d,e);
    }
    else if(b+c+d-e==7){
        printf("%d+%d+%d-%d=7",b,c,d,e);
    }
    else if(b+c-d-e==7){
        printf("%d+%d-%d-%d=7",b,c,d,e);
    }
    else if(b+c-d+e==7){
        printf("%d+%d-%d+%d=7",b,c,d,e);
    }
    else if(b-c+d+e==7){
        printf("%d-%d+%d+%d=7",b,c,d,e);
    }
    else if(b-c+d-e==7){
        printf("%d-%d+%d-%d=7",b,c,d,e);
    }
    else if(b-c-d-e==7){
        printf("%d-%d-%d-%d=7",b,c,d,e);
    }
    else if(b-c-d+e==7){
        printf("%d-%d-%d+%d=7",b,c,d,e);
    }
    
    return 0;
}

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

int n, m, a, b, c = 0;
int p[200000], r[200000];

int find(int x) {
	if (p[x] == x)
		return x;
	else
		return p[x] = find(p[x]);
}

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

	for (int i = 0; i < n; i++) {
		p[i] = i;
		r[i] = 1;
	}

	for (int i = 0; i < m; i++) {
		cin >> a >> b;

		a--;
		b--;

		a = find(a);
		b = find(b);

		if (a != b) {
			p[a] = b;
			r[b] += r[a];
		}
	}

	for (int i = 0; i < n; i++)
		find(i);

	for (int i = 0; i < n; i++)
		c = max(c, r[i]);

	cout << c << endl;
}

Measured memory_bytes: 11384
/************************************************************
	> File Name: e.cpp
	> Author: TSwiftie
	> Mail: tswiftie@foxmail.com 
	> Created Time: Sun 21 Jun 2020 09:25:37 PM CST
************************************************************/
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <ext/rope>
#define int long long
#define lowbit(x) (x&-x)
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int INF = 0x3f3f3f3f;
const LL INF_ll = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int N = 2e5+10;
int a[N],n,ans = -1;
signed main(void){
	cin >> n;
	for(int i = 1;i <= n;++i){
		cin >> a[i];
		if(ans==-1) ans = a[i];
		else ans ^= a[i];
	}
	for(int i = 1;i <= n;++i)
		cout << (ans^a[i]) << (i==n?'\n':' ');
	return 0;
}


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

#define NIL NULL

struct Node{
  int key;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};

struct Node *root;

void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);
struct Node * find(struct Node *,int);

int main(){
  int n,i,num,x;
  char order[10];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",order);
    if(order[0]=='f'){
      scanf("%d",&x);
      struct Node *t = find(root,x);
      if(t!=NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(order[0]=='i'){
      scanf("%d",&num);
      insert(num);
    } else if(order[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int num){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;
  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=num;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    } else {
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  } else {
    if(z->key < y->key){
      y->left=z;
    } else {
      y->right=z;
    }
  }
}

void inorder(struct Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(struct Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
struct Node * find(struct Node *u,int k){
  while (u!=NIL && k!=u->key){
    if(k < u->key)u=u->left;
    else u=u->right;
  }
  return u;
}



  



Measured memory_bytes: 20456
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
int main(){
    int d,t,s;
    scanf("%d %d %d",&d,&t,&s);
    if(s*t>=d){
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 1728
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

// 151-d
int main() {
    int n;
    cin >> n;

    map<string, int> dic;

    string inp;
    int typecnt = 0;
    rep(_n, 0, n) {
        cin >> inp;
        if (dic[inp] == 0) {
            typecnt++;
            dic[inp] = 1;
        }
    }

    cout << typecnt << endl;

    return 0;
}



Measured memory_bytes: 19256
cnt=0
def mer(l,r):
    global cnt
    ll=len(l)
    rr=len(r)
    md=[]
    i,j=0,0
    l.append(float('inf'))
    r.append(float('inf'))
    for k in range(ll+rr):
        cnt+=1
        if l[i]<=r[j]:
            md.append(l[i])
            i+=1
        else:
            md.append(r[j])
            j+=1
    return md
def mergesort(a):
    m=len(a)
    if m<=1:
        return a
    m=m//2
    l=mergesort(a[:m])
    r=mergesort(a[m:])
    return mer(l,r)
n=int(input())
a=list(map(int, input().split()))
b=mergesort(a)
for i in range(n-1):
    print(b[i],end=" ")
print(b[n-1])
print(cnt)


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

// templates -------------------------------------

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for(LL i = 0; i < n; i++)
#define INV_REP(i, n) for(LL i = n; 0 <= i; i--)

LL sumOfDigits(LL n)
{
  LL sum = 0;
  while(0 < n)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

LL combination(LL n, LL m)
{
  LL nume = 1;
  REP(i, m) nume *= (n-i);
  LL demo = 1;
  for(int i = 1; i <= m; i++) demo *= i;
  return nume / demo;
}

template<class T>
class UnionFind
{
private:
  vector<T> par;
  vector<T> rank;
  vector<T> size;

public:
  UnionFind(T N) :
    par(N, T()), rank(N, T()), size(N, T())
  {
    REP(i, N)
    {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  inline T root(T x)
  {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  inline bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  inline T getSize(T x)
  {
    return size[root(x)];
  }

  void unite(T x, T y)
  {
    T r1 = root(x);
    T r2 = root(y);
    if(r1 == r2) return;

    if(rank[r1] < rank[r2]) swap(r1, r2);
    if(rank[r1] == rank[r2]) rank[r1]++;
    par[r2] = r1;
    size[r1] += size[r2];
  }
};

// --------------------------------------

int x, y, z;

void input()
{
  cin >> x >> y >> z;
}

void solve()
{
  cout << x * y / 2;
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]int, n, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	for i := range as {
		if as[i] == 0 {
			fmt.Println(0)
			return
		}
	}

	ret := 1
	for i := range as {
		if as[i] <= 1000000000000000000/ret {
			ret *= as[i]
		} else {
			fmt.Println(-1)
			return
		}

	}

	fmt.Println(ret)
}

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

struct P
{
    long long x,y,z;

    bool operator<(const P &a)const{
              return x<a.x;
    }

};

vector<int> v[1];
//bitset<4001000> b;
int a,c,i,b,n,m,k,d;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int o[122];
int l[1];
int j[1];
int e;
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long x,y,mod=1000000007,mod2=1000000009,mod3=2017;
long long z;
double pi=3.14159265;
P u[1];
//stack<int> s;

//set<long long> s;
queue<int> q,q1;

//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//list<int> l;

//string r,r1;
//char r[1333336];
//deque<int> de;
//srand((int)time(NULL));
bool as(P a,P b)
{
    if(a.x*b.y!=b.x*a.y)
    return a.x*b.y<b.x*a.y;
    return a.y>b.y;
}


int main()
{
    scanf("%d %d",&a,&b);
    for(int t=1;t<=a;x+=o[t],t++)
        scanf("%d",&o[t]);
    sort(o+1,o+a+1);
    if(x==b)
    {
        printf("%d",a);
        return 0;
    }
    for(int t=1;t<=a;t++)
    {
        y+=o[t];
        if(y>b)
        {
            printf("%d",t-1);
            return 0;
        }
    }
    printf("%d",a-1);
}
//1 4 3 2 1


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  string s;
  cin>>s;
  ll c=1;
  for(int i=0;i<s.size();i+=2){
    if(s[i]!='h'||s[i+1]!='i'){
      c=0;
      break;
    }
  }
  if(c){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}


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 f=0;
		for(int i=0;i<n;i++) {
			int a=sc.nextInt();
			if(a%2==0) {
				if(a%3!=0&&a%5!=0) {
					f=1;
				}
			}
		}
		if(f==0) {
			System.out.println("APPROVED");
		}else {
			System.out.println("DENIED");
			
		}

	}

}


Measured memory_bytes: 21844
open System
open System.Collections
open System.Collections.Generic
open System.IO
open System.Linq

let Str() = Console.ReadLine()
let Int() = Str() |> int
let Char() = [for c in Str() -> c]

let rec game p1 p2 p3 cur=
    match cur with
    | 'a' -> if p1<>[] then game p1.Tail p2 p3 p1.Head
             else           'A'
    | 'b' -> if p2<>[] then game p1 p2.Tail p3 p2.Head
             else           'B'
    |  _  -> if p3<>[] then game p1 p2 p3.Tail p3.Head
             else           'C'

[<EntryPoint>]
let main _ = 
    let a = Char()
    let b = Char()
    let c = Char()

    let ans = game a b c 'a'

    printfn "%c" ans

    0
    



Measured memory_bytes: 14812
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define PI 3.14159265
#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 300000000000000001
#define infx 9223372036854775806
#define all(c) c.begin(),c.end()
#define mk(x,yy) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
#define re return
// #define endl "\n"
#define max2(x,y)           (x>y)?x:y
#define min2(x,y)           (x<y)?x:y
#define mid(s,e)               (s+(e-s)/2)
#define mini                   INT_MIN
#define maxo                   INT_MAX
#define rep(i,a,b) for(int i=a;i<(int)(b);++i)
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define show(a,n) for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl
#define ene cout<<"\n";

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
ll power(ll x,  ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
 
bool compr(std::vector<ll> a, std::vector<ll> b)
{
    if(a[0]==b[0])
        return a[1]<b[1];
    else
        return a[0]<b[0];
}

bool comp(std::vector<ll> a, std::vector<ll> b)
{
    if(a[1]==b[1]&&a[2]==b[2])
        return a[0]<b[0];
    else if(a[1]==b[1])
        return a[2]>b[2];
    else
        return a[1]<b[1];
}

ll dfs(ll visited[], vector<ll> adj[], ll x)
{
    visited[x] = 1;
    ll tmp = 0;
    for(ll i=0;i<adj[x].size();i++)
    {
        if(visited[adj[x][i]]==0)
        {
            ll ch = dfs(visited,adj,adj[x][i]);
            tmp = max(tmp,ch);
        }
        else
        {
            tmp = max(tmp,visited[adj[x][i]]);
        }
    }
    visited[x]+=tmp;
    return visited[x];
}

int main()
{
    #ifdef SHIVANSH 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll visited[n] = {};
    vector<ll> adj[n];
    for(ll i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        x--;y--;
        adj[x].push_back(y);
    }
    for(ll i=0;i<n;i++)
    {
        if(visited[i]==0)
        {
            // cout<<"helllo"<<endl;
            ll tr = dfs(visited,adj,i);
        }
    }
    ll ans = 0;
    for(ll i=0;i<n;i++)
    {
        ans = max(ans, visited[i]);
    }
    cout<<ans-1<<endl;
}

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

int main()
{
    int n,x;
    cin >> n >> x;
    
    int d = 100000;
    int sum = 0;
    vector<int> m(n);
    for (int i = 0; i < n; i++)
    {
        cin >> m[i];
        d = min(d, m[i]);
        sum += m[i];
    }

    cout << (x-sum)/d + n << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

ans = [0] * n

for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            f = x*x + y*y + z*z + x*y + y*z + z*x
            if f <= n:
                ans[f-1] += 1

for i in ans:
    print(i)

Measured memory_bytes: 69348
a = Array.new(4){Array.new(3){Array.new(10,0)}}
b = gets.to_i
b.times do
  c = gets.split.map(&:to_i)
  a[c[0]-1][c[1]-1][c[2]-1] += c[3]
end
4.times do |i|
  3.times do |j|
    print " ", a[i][j].join(" "),"\n"
  end
  if (i < 3) then
    puts "#"*20
  end
end

Measured memory_bytes: 6112
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

const int mod = 1e9 + 7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

combination comb(3000);

// K個をnグループに分ける
// グループに0個のものがあっても良い
mint f2(int k, int n) {
    return comb(k + n, n);
}

// k個をnグループに分ける
// 各グループは1個以上ある
mint f(int k, int n) {
    if (k < n) return 0;
    // if (k == 0 && n == 0) return 1;
    // if (n - 1 == 0) return 1;
    if (n - k == 0) return 1;

    return f2(k - n, n - 1);
}

ll N, K;
int main() {
    cin >> N >> K;

    mint ans = 0;
    for (int i = 1; i <= K; i++) {
        mint blue = f(K, i);
        mint red = 0;
        red += f(N - K, i + 1);
        red += f(N - K, i);
        red += f(N - K, i);
        red += f(N - K, i - 1);
        // cout << blue << " " << red << endl;

        ans = blue * red;
        cout << ans << endl;
    }
}

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

import static java.lang.System.in;

public class Main {
    static int[] id;
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(), M = sc.nextInt();
        boolean[] used = new boolean[M+1];
        id = new int[M+1];
        for(int i=0;i<=M;i++) id[i]=i;
        int l0 = 0;
        for(int i=0;i<N;i++){
            int k = sc.nextInt();
            l0 = sc.nextInt();
            used[l0] = true;
            for(int j=1;j<k;j++){
                int lj = sc.nextInt();
                used[lj]=true;
                union(lj,l0);
            }
        }
        int root = find(l0);
        boolean ans = true;
        for(int i=1;i<=M;i++){
            if(!used[i]) continue;
            ans &= find(i)==root;
        }
        String res = ans?"YES":"NO";
        System.out.println(res);
    }
    static int find(int p){
        while(id[p]!=p){
            id[p] = id[id[p]];
            p = id[p];
        }
        return id[p];
    }
    static void union(int p, int q){
        int i=find(p), j=find(q);
        if(i==j) return;
        id[j]=i;
    }
}


Measured memory_bytes: 64652
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>
#include <stdlib.h>
# include <map>

using namespace std;

int main(){
    int d;
    cin >> d;
    if (d == 25){
        cout << "Christmas" << endl;
    }
    else if(d == 24){
        cout << "Christmas Eve" << endl;
    }
    else if(d == 23){
        cout << "Christmas Eve Eve" << endl;
    }
    else{
        cout << "Christmas Eve Eve Eve" << endl;
    }
}


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

using namespace std;

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

  for (int i = 0; i < n_problems; i++) {
    int n_houses, n_strips;
    
    cin >> n_houses >> n_strips;
    
    int position_array[n_houses];

    //read positions into array
    for (int j = 0; j < n_houses; j++) {
      cin >> position_array[j];
    }
    //max distance between houses
    int max_distance = position_array[n_houses - 1] - position_array[0];

    int n_distance = n_houses - 1;

    //array of distances
    int distance_array[n_distance];

    //calculate distances and read into array
    for (int j = 0; j < n_distance; j++) {
      distance_array[j] = position_array[j+1] - position_array[j];
    }

    //sort distance_array in ascending order
    sort(distance_array, distance_array+ n_houses - 1);

    //find shortest_distance through greedy selection
    int shortest_distance = max_distance;

    int n_to_eliminate = (n_houses >= n_strips ? n_strips : n_houses);
    // elimate distances, longest first
    for (int j = 0; j < n_to_eliminate - 1; j++) {
      shortest_distance -= distance_array[n_distance - 1 - j];
    }
    cout << shortest_distance << endl;
  }
}

Measured memory_bytes: 1960
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int findSum(string s) {
	int sum = 0;
	for (int i = 0; i < s.length(); i++) {
		sum += s[i] - '0';
	}
	return sum;
}

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	string s;
	cin >> s;
	if (findSum(s) % 9 == 0)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int h, w;
char f[101][101];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
void dfs(int x, int y, char s){
    f[x][y] = '.';
    rep(i, 4){
        int nx = x + dx[i], ny = y + dy[i];
        if(0 <= nx && 0 <= ny && f[nx][ny] == s)
          dfs(nx, ny, s);
    }
    return;
}
int main(){
    while(scanf("%d %d", &h, &w) && h && w){
        rep(i, h + 1) rep(j, w + 1)
          f[i][j] = '.';
        rep(i, h) rep(j, w)
          cin >> f[i][j];
        int res = 0;
        rep(i, h) rep(j, w){
            if(f[i][j] != '.'){
                dfs(i, j, f[i][j]);
                res++;
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1696
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
#define PI 3.1415926
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, t, a, h[1000];
	cin >> n >> t >> a;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	double ans = 50000.0;
	int aans = 0;
	for (int i = 0; i < n; i++) {
		double p = (double)t - (double)h[i]*0.006;
		//cout << p << endl;
		if(abs(ans - (double)a) > abs((double)a - p)){
			ans = p;
			aans = i+1;
		}
	}
	cout << aans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[20];
int B[20];
int C[20];
int main(){
  int i, res;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);A[Lj4PdHRW] += (-1);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<(N);KL2GvlyY++){
      rd(B[KL2GvlyY]);
    }
  }
  {
    int Q5VJL1cS;
    for(Q5VJL1cS=0;Q5VJL1cS<(N-1);Q5VJL1cS++){
      rd(C[Q5VJL1cS]);
    }
  }
  {
    int cTE1_r3A, e98WHCEY;
    if(N==0){
      cTE1_r3A = 0;
    }
    else{
      cTE1_r3A = B[0];
      for(e98WHCEY=(1);e98WHCEY<(N);e98WHCEY++){
        cTE1_r3A += B[e98WHCEY];
      }
    }
    res =cTE1_r3A;
  }
  for(i=(1);i<(N);i++){
    if(A[i-1]+1==A[i]){
      res += C[A[i-1]];
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// int N, A[20], B[20], C[20];
// {
//   int res;
//   rd(N,(A--)(N),B(N),C(N-1));
//   res = sum(B(N));
//   rep(i,1,N) if(A[i-1]+1==A[i]) res += C[A[i-1]];
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) 
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main() {

	int h,w;
	cin >> h>>w;
	
	int dist[10][10];
	rep(i, 10)rep(j, 10) cin >> dist[i][j];

	int a[210][210];
	rep(i, h)rep(j, w) cin >> a[i][j];

	rep(k, 10)rep(i, 10)rep(j, 10) {
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
		if (i == j)  dist[i][j] = 0;
	}
	
	int ans = 0;
	rep(i, h)rep(j, w) {
		if (a[i][j] == -1) continue;
		ans += dist[a[i][j]][1];
	}

	cout << ans << endl;
}

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

int main(){
    string s;
    cin >> s;

    ll k;
    cin >> k;

    int flag = 0;
    for(ll i = 0; i < k; i++){
        if(s[i] - '0' != 1){
            flag = s[i] - '0'; 
            break;
        }
    }

    if(flag == 0){
        cout << 1 << endl;
    }else{
        cout << flag << endl;
    }
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int s = 0;
  int t = 0;
  
  int len = S.size();
  vector<int> vS(len), vT(len);
  map<char,int> mS, mT;
  
  for(int i=0; i<S.size(); i++) {
    
    if(mS.find(S[i]) == mS.end()) {
      mS.insert(make_pair(S[i],s));  
      s++;
    }
    vS[i] = mS[S[i]];
    
    if(mT.find(T[i]) == mT.end()) {
      mT.insert(make_pair(T[i],t)); 
      t++;
    }
    vT[i] = mT[T[i]];
  }
  
  if(vS==vT) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2312
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   string n;
   cin >> n;
   cout << (n[0]==n[2] ? "Yes" : "No") << endl;
}

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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }
bool inside(int y, int x, int H, int W) {return 0 <= y and y < H and 0 <= x and x < W; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, 1, 0, -1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）


using namespace std;


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

    while (true) {
        int N;
        cin >> N;
        if (N == 0) { break; }
        char S, T, B;
        cin >> S >> T >> B;
        int sy = (S - 'A') / 3;
        int sx = (S - 'A') % 3;
        int ty = (T - 'A') / 3;
        int tx = (T - 'A') % 3;
        int by = (B - 'A') / 3;
        int bx = (B - 'A') % 3;

        vector<vector<vector<double>>> dp(N + 1, vector<vector<double>>(3, vector<double>(3, 0)));
        dp[0][sy][sx] = 1;

        FOR(n, 0, N) {
            FOR(y, 0, 3) {
                FOR(x, 0, 3) {

                    FOR(i, 0, 4) {
                        int ny = y + dy[i];
                        int nx = x + dx[i];

                        if (inside(ny, nx, 3, 3) and not(ny == by and nx == bx)) {
                            dp[n + 1][ny][nx] += dp[n][y][x] * 0.25;
                        } else {
                            dp[n + 1][y][x] += dp[n][y][x] * 0.25;
                        }
                    }
                }
            }
        }
        print(dp[N][ty][tx]);
    }
    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;

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

int main()
{
  int V, E;
  cin >> V >> E;

  ll d[110][110];
  memset(d, 0x3f, sizeof(d));

  rep(i, V)
  {
    rep(j, V)
    {
      d[i][j] = INF;
    }
    d[i][i] = 0;
  }

  rep(i, E)
  {
    int s, t, dist;
    cin >> s >> t >> dist;
    d[s][t] = dist;
  }

  rep(k, V) rep(i, V) rep(j, V)
  {
    if (d[i][k] != INF && d[k][j] != INF)
      d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }

  rep(i, V)
  {
    rep(j, V)
    {
      if (d[i][i] != 0)
      {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
      }
    }
  }

  rep(i, V)
  {
    rep(j, V)
    {
      if (d[i][j] >= INF)
        cout << "INF";
      else if (i == j)
        cout << 0;
      else
        cout << d[i][j];
      if (j != V - 1)
        cout << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3224
#!/usr/bin/env python3
#AOJ F
from collections import deque
from itertools import permutations

dx = [1,0,-1,0]
dy = [0,1,0,-1]

def bfs(sy,sx):
    dist = [[-1]*w for _ in range(h)]#初期化
    que = deque()
    que.append((sy,sx))
    dist[sy][sx] = 0
    while que:
        y,x = que.popleft()
        for i in range(4):
            nx,ny = x+dx[i],y+dy[i]
            if 0 <= nx < w and 0 <= ny < h:
                if dist[ny][nx] < 0 and M[ny][nx] != "x":
                    dist[ny][nx] = dist[y][x] + 1#移動できるなら移動先の距離+1
                    que.append((ny,nx))

    return dist#引数をスタートにした距離のリストを返す

while 1:
    w,h = map(int,input().split())
    if w == 0 and h == 0:
        break
    M = [list(input()) for _ in range(h)]
    p = []
    for i in range(h):
        for j in range(w):
            if M[i][j] == "o":
                p.append((i,j))
                break
    for i in range(h):
        for j in range(w):
            if M[i][j] == "*":
                p.append((i,j))
    #p[0]はスタート位置,その他は汚れの位置
    n = len(p)
    dist = [[float("inf")]*n for _ in range(n)]#スタート及び各汚れ間の最短路
    f = 0
    for i in range(n):
        di = bfs(*p[i])#*listとすると、list[0],list[1],list[2],…と同値
        for j in range(n):
            dist[i][j] = di[p[j][0]][p[j][1]]#dist[i][j]はp[i]をスタートにした場合の汚れまたはスタート間の最短距離
            if dist[i][j] < 0:
                f = 1#もしたどりつけない点があったら終了
                break
    #print(dist)
    if f:
        print(-1)
        continue

    #bitDP
    po = [1<<i for i in range(11)]
    ma = po[n]#ma=11...1 + 1
    dp = [[float("inf")]*(n) for _ in range(ma)]#最後に消したところからの最短路を見る必要があるため2次元(dp[b][i] := 汚れを消した状態がbかつ最後に消した汚れが汚れiの時の最短路)
    dp[1][0] = 0#スタート位置は0
    for b in range(ma):#bは汚れを消した部分を表す
        for j in range(n):
            if b&po[j]:#汚れjが消えていたら終了
                continue
            nb = b|po[j]#新たに汚れjを削除
            for i in range(n):
                if not b&po[i]:#汚れiが消えていないなら終了
                    continue
                #汚れiを最後に消したときb,nbについて比較
                if dp[nb][j] > dp[b][i] + dist[i][j]:#iの後にjを消すほうが最短なら更新
                    dp[nb][j] = dp[b][i] + dist[i][j]
    print(min(dp[ma - 1]))#全部消したときの最短距離を出力


Measured memory_bytes: 6292
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#define llint long long
#define mod 1000000007
#define inf 1e9

using namespace std;
typedef pair<llint, llint> P;

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

string s, t;
llint n;
UnionFind uf(600005);
map<llint, char> mp;

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod)*(modpow(a,n-1)%mod))%mod;
	}
	else{
		return modpow((a*a)%mod, n/2)%mod;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> s >> t >> n;
	
	if(n <= 200000){
		string x;
		for(int i = 0; i < n; i++) x += "*";
		x = x + s + x + t;
		
		for(int i = 0; i < n; i++) uf.unite(i, n+s.size()+i);
		for(int i = 0; i < x.size(); i++) uf.unite(i, x.size()-1-i);
		
		for(int i = 0; i < x.size(); i++){
			mp[uf.root(i)];
			if(x[i] != '*'){
				if(mp[uf.root(i)] != 0 && mp[uf.root(i)] != x[i]){
					cout << 0 << endl;
					return 0;
				}
				else mp[uf.root(i)] = x[i];
			}
		}
		
		llint ans = 1;
		for(auto it = mp.begin(); it != mp.end(); it++){
			if(it->second == 0) ans *= 26, ans %= mod;
		}
		cout << ans << endl;
		return 0;
	}
	
	if(s.size() >= t.size()){
		string x = t;
		reverse(x.begin(), x.end());
		x = s + x;
		for(int i = 0; i < x.size(); i++){
			if(x[i] != x[x.size()-1-i]){
				cout << 0 << endl;
				return 0;
			}
		}
		llint ans = modpow(26, (n-t.size()+1)/2);
		cout << ans << endl;
	}
	else{
		string x = s;
		reverse(x.begin(), x.end());
		x = x + t.substr(0, s.size());
		for(int i = 0; i < x.size(); i++){
			if(x[i] != x[x.size()-1-i]){
				cout << 0 << endl;
				return 0;
			}
		}
		
		x = t.substr(s.size());
		for(int i = 0; i < x.size(); i++){
			if(x[i] != x[x.size()-1-i]){
				cout << 0 << endl;
				return 0;
			}
		}
		
		llint ans = modpow(26, (n-t.size()+1)/2);
		cout << ans << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 12108
def main():
    n, k, c = (int(i) for i in input().split())
    s = input()

    if k > sum(1 for c in s if c == 'o'):
        return

    latest = [None] * k
    earliest = [None] * k
    earliest[0] = s.index('o')
    for i in range(1, k):
        try:
            earliest[i] = s.index('o', earliest[i-1] + c + 1)
        except ValueError:
            return
    
    latest[-1] = s.rindex('o')
    for i in reversed(range(k-1)):
        try:
            latest[i] = s.rindex('o', 0, latest[i+1] - c)
        except ValueError:
            return

    bound_days = [earliest[i] + 1 for i in range(k) if earliest[i] ==
            latest[i]]

    for e, l in zip(earliest, latest):
        if e == l:
            print(e + 1)
main()


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

int main()
{
  int n, m, x, y, x_i, y_i;
  int x_max = -101, y_min = INF;
  scanf("%d%d%d%d", &n, &m, &x, &y);
  for (int i; i < n; i++)
  {
    scanf("%d", &x_i);
    if (x_i > x_max)
    {
      x_max = x_i;
    }
  }
  for (int i; i < m; i++)
  {
    scanf("%d", &y_i);
    if (y_i < y_min)
    {
      y_min = y_i;
    }
  }
  for (int i = x + 1; i <= y; i++)
  {
    if (x_max < i && y_min >= i)
    {
      puts("No War");
      return 0;
    }
  }

  puts("War");

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<pair<int, int>> Ryx(n); //<x, y>
  vector<pair<int, int>> Bxy(n); //<y, x>
  REP(i,n){
    cin >> Ryx[i].second >> Ryx[i].first;
  }
  REP(i,n){
    cin >> Bxy[i].first >> Bxy[i].second;
  }
  sort(all(Bxy));
  sort(all(Ryx), greater<pair<int, int>>());
  // cout << "RED" << endl;
  // REP(i,n){
  //   cout << "("<<Ryx[i].second << ", " << Ryx[i].first <<")"<< endl;
  // }
  // cout << "BLUE" << endl;
  // REP(i,n){
  //   cout << "("<<Bxy[i].first << ", " << Bxy[i].second <<")"<< endl;
  // }
  vector<bool> Bseen(n, false);
  int ans = 0;
  int rx, ry;
  int bx, by;
  REP(i,n){
    bx = Bxy[i].first;
    by = Bxy[i].second;
    REP(j,n){
      if(!Bseen[j]){
	rx = Ryx[j].second;
	ry = Ryx[j].first;
	if(rx < bx &&ry < by){
	  ans ++;
	  Bseen[j] = true;
	  // cout << "("<<rx<<","<<ry<< ") <-> ("<<bx<<","<<by<< ")"<< endl;
	  break;
	}
      }
    }
  }
  cout << ans << endl;
}


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

//D日目時点のスコアを計算
int score(int D, int c[], int s[][26], int t[]){
    int pen_day[26]={1};
    for(int i=0; i<26; i++){
        pen_day[i]=1;
    }
    int score=0;
    
    for(int i=0; i<D; i++){
        int type=t[i]-1;
        pen_day[type]=0;
        //満足度増加
        score+=s[i][type];
        //満足度低下
        for(int j=0; j<26; j++){
            int dec=c[j]*pen_day[j];
            score-=dec;
        }
        //日数追加
        for(int j=0; j<26; j++){
            pen_day[j]++;
        }        
    }
    return score;
}

void Greedy(int D, int c[], int s[][26]){
    int t[D], max_type=0, max_score=0;

    for(int i=0; i<D; i++){
        max_score=0;
        for(int j=0; j<26; j++){
            t[i]=j+1;
            int S=score(i+1, c, s, t);
            if(max_score < S){
                max_score = S;
                max_type=j+1;
            }
        }
        t[i]=max_type;
    }

    for(int i=0; i<D; i++){
        printf("%d\n", t[i]);
    }
}

int main(void){
    int D, c[26], s[365][26], t[365];

    //入力
    scanf("%d", &D);
    for(int i=0; i<26; i++){
        scanf("%d", &c[i]);
    }
    for(int i=0; i<D; i++){
        for(int j=0; j<26; j++){
            scanf("%d", &s[i][j]);
        }
    }
    /*
    for(int i=0; i<D; i++){
        scanf("%d", &t[i]);
    }
    */

   /*ここから処理*/
   /*
    int num=1;
    for(int i=0; i<D; i++){
        printf("%d\n", num);
        num++;
        if(num>26) num=1;
    }
    */

   Greedy(D, c, s);


    return 0;
}

Measured memory_bytes: 1772
n, k = map(int, input().split())
A = [int(x) for x in input().split()]
appeared = [False] * (n + 1)
load = [1]
cnt = 0
cycle_init = -1
no_cycle = False
while True:
    nxt = A[load[-1] - 1]
    if appeared[nxt]:
        cycle_init = nxt
        break
    else:
        load.append(nxt)
        appeared[nxt] = True
    cnt += 1
    if cnt == n:
        no_cycle = True
        break
if no_cycle:
    print(load[k])
else:
    idx_ci = load.index(cycle_init)
    cycle = load[idx_ci:]
    b_cycle = load[:idx_ci]
    lenb = len(b_cycle)
    if k < lenb:
        print(b_cycle[k])
    else:
        m = len(cycle)
        k = k - lenb
        print(cycle[k % m])



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

int n;

void print_std(string res, char max_char, int num){
    
    if(num == n){
        for(char c = 'a'; c <= max_char+1; ++c){
            cout << res + c << endl;
        }
    }

    else {
        for(char c = 'a'; c <= max_char+1; ++c){
            print_std(res+c, max(max_char, c), num+1);
        }
    }
}

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

    cin >> n;
    if(n==1){
        puts("a");
        return 0;
    }
    --n;

    char max_char = 'a';
    print_std("a", max_char, 1);

    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <string>

using namespace std;

#define U unsigned
#define S short
#define L long
#define LL long long 
#define LLU long long unsigned

//Reading and Printing Arrays

//short int
#define rhd(arr, n) for(int aab = 0; aab < n; aab++){scanf("%hd", &arr[aab]);}
#define phd(arr, n) for(int aab = 0; aab < n; aab++){printf("%hd ", arr[aab]);}
//int
#define rd(arr, n) for(int aab = 0; aab < n; aab++){scanf("%d", &arr[aab]);}
#define pd(arr, n) for(int aab = 0; aab < n; aab++){printf("%d ", arr[aab]);}
//unsigned int
#define ru(arr, n) for(int aab = 0; aab < n; aab++){scanf("%u", &arr[aab]);}
#define pu(arr, n) for(int aab = 0; aab < n; aab++){printf("%u ", arr[aab]);}
//long int
#define rld(arr, n) for(int aab = 0; aab < n; aab++){scanf("%ld", &arr[aab]);}
#define pld(arr, n) for(int aab = 0; aab < n; aab++){printf("%ld ", arr[aab]);}
//unsigned long int
#define rlu(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lu", &arr[aab]);}
#define plu(arr, n) for(int aab = 0; aab < n; aab++){printf("%lu ", arr[aab]);}
//long long int
#define rlld(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lld", &arr[aab]);}
#define plld(arr, n) for(int aab = 0; aab < n; aab++){printf("%lld ", arr[aab]);}
//unsigned long long int
#define rllu(arr, n) for(int aab = 0; aab < n; aab++){scanf("%llu", &arr[aab]);}
#define pllu(arr, n) for(int aab = 0; aab < n; aab++){printf("%llu ", arr[aab]);}
//float
#define rf(arr, n) for(int aab = 0; aab < n; aab++){scanf("%f", &arr[aab]);}
#define pf(arr, n) for(int aab = 0; aab < n; aab++){printf("%f ", arr[aab]);}
//double
#define rlf(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lf", &arr[aab]);}
#define plf(arr, n) for(int aab = 0; aab < n; aab++){printf("%lf ", arr[aab]);}
//char
#define rc(arr, n) for(int aab = 0; aab < n; aab++){scanf("%c", &arr[aab]);}
#define pc(arr, n) for(int aab = 0; aab < n; aab++){printf("%c", arr[aab]);}
//string
#define rs(arr) scanf("%s", arr);
#define ps(arr) puts(arr);

//swap
#define swap(a, b, tip) tip tempswap = a;a = b;b = tempswap;
//freopen
#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);

/*       ▄▀▄     ▄▀▄
        ▄█░░▀▀▀▀▀░░█▄
    ▄▄  █░░░░░░░░░░░█  ▄▄
   █▄▄█ █░░▀░░┬░░▀░░█ █▄▄█       */

int min(int a, int b){	return a <= b ? a : b;}
int max(int a, int b){	return a >= b ? a : b;}
int findmin(int arr[], int n){int min = 0;for(int i = 1; i < n;min = arr[i] < arr[min] ? i : min, i++);return min;}
int findmax(int arr[], int n){int max = 0;for(int i = 1; i < n;max = arr[i] > arr[max] ? i : max, i++);return max;}
int arrsum(int arr[], int n){int sum = 0;for(int i = 0; i < n; sum += arr[i], i++);return sum;}
	
int main(){

	LLU a, b, cevap;

	scanf("%llu %llu", &a, &b);

	cevap = a * b;

	if(a == 1 || b == 1){
		printf("1");
		return 0;
	}

	if(cevap % 2 == 0){
		printf("%llu", cevap / 2);
	}
	else{
		printf("%llu", cevap / 2 + 1);
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int ans = 0;
    int tem;
    for(int i = 0 ; i < n ; i++){
        cin>>tem;
        if(tem%2 ==0){
            if(tem%3 == 0 || tem%5 ==0)
                continue;
            ans++;
        }
    }
    if(ans>0)
        cout<<"DENIED\n";
    else
        cout<<"APPROVED\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

 ll p[20];

int main(int argc, char const *argv[]) {
  int n,k;
  cin >> n >> k;
  p[0]=1.00000000;
  rep(i,19) p[i+1]=p[i]*2;

  double ans=0.00000000;

  for(int i=1; i<=n; i++){
      int m=i,cnt=0;
      while(m<k){
        m*=2;
        cnt++;
      }
      ;
      double q=p[cnt]*n;
      
      ans+=(double)(1/q);
  }

  printf("%.9f\n",ans);

  return 0;
}


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

#define int long long

using namespace std;

const int maxn = 1e5 + 10;
int a[maxn], n, m, v, p;

bool f(int h)
{
    int x = p - 1 + n - h, s = max(0ll, v - x) * m;
    for (int i = p - 1; i < h; i++) {
        if (a[i] > a[h] + m)
            return false;
        s -= min(m, a[h] + m - a[i]);
    }
    return s <= 0;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m >> v >> p;

    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n, greater<int>());

    int l = 0, r = n;
    while (r - l > 1)
    {
        int mid = l + r >> 1;
        if (f(mid))
            l = mid;
        else
            r = mid;
    }

    cout << r;

    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#define ll long long
using namespace std;
int main()
{
	string str;
	ll len,sum,a[20];
	cin>>str;
	len=str.length();
	for(int i=0;i<len;i++) a[i]=str[i]-'0';
	for(int i=0;i<len;i++) sum+=a[i];
	int n= atoi(str.c_str());
	if(n%sum==0) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  int r;
  cin >> r;

  double pi = 3.1415;
  
  cout << 2*pi*r << endl;
  return 0;
}

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

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int[] n=new int[3];
    for(int i=0;i<n.length;i++){
      n[i]=Integer.parseInt(scan.next());
    }

    if(n[0]<n[1] && n[1]<n[2]){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 26020