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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n;
int a[maxn];
ll acc[maxn];
multiset<int> ms;

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

  cin>>n;
  for (int i=1; i<=n; i++) {
    cin>>a[i];
  }
  a[0]=a[n+1]=0;
  for (int i=1; i<=n+1; i++) {
    acc[i] += abs(a[i]-a[i-1]) + acc[i-1];
  }

  // for (int i=0; i<=n+1; i++) {
  //   cout<<acc[i]<<" ";
  // }
  // cout<<endl;

  for (int i=1; i<=n; i++) {
    int tot = acc[n+1];
    if (a[i-1]<=a[i] && a[i]<=a[i+1]) {
      cout<<tot<<'\n'; continue;
    }
    if (a[i-1]>=a[i] && a[i]>=a[i+1]) {
      cout<<tot<<'\n'; continue;
    }
    tot -= abs(a[i]-a[i-1]);
    tot -= abs(a[i+1]-a[i]);
    tot += abs(a[i+1]-a[i-1]);
    cout<<tot<<'\n';
  }


  return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
const int P=1e9+7,M=2001;
int n,a,b;
long long C[M][M];
int main(){
	scanf("%d%d",&n,&a);
	b=n-a;
	C[0][0]=1;
	for(int i=1;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++)C[i][j]=(C[i-1][j]+C[i-1][j-1])%P;
	}
	for(int i=1;i<=a;i++){
		if(i>b+1){
			puts("0");
			continue;
		}
		long long ans=C[a-1][i-1]*C[b+1][i]%P;
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 30080
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
pair<long long, long long> p[100010];
int main() {
	long long n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		long long a, b;
		cin >> a >> b;
		p[i] = make_pair(a, b);
	}
	sort(p, p + n);
	long long co = 0;
	for (int j = 0; j < n; j++) {
		co += p[j].second;
		if (co >= k) {
			cout << p[j].first << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  in ct,ca;
  cin>>ct>>ca;
  in t,a;
  in mt,ma;
  forn(z,n-1){
    cin>>t>>a;
    mt=((ct+t-1)/t)*t;
    ma=((ca+a-1)/a)*a;
    if(mt/t*a>ma)
      ma=mt/t*a;
    else
      mt=ma/a*t;
    ct=mt;
    ca=ma;
  }
  cout<<ct+ca<<endl;
  return 0;
}


Measured memory_bytes: 256
N , X , Y =map(int,input().split()) 

disk=[0 for i in range(N-1)]

for i in range(1,N):
    for j in range(i+1, N+1):
        distij =min( j - i , abs(X-i)+1+abs(Y-j))
        disk[distij-1] += 1
        
for k in range(N-1):
    print(disk[k])

Measured memory_bytes: 3444
def A():
    s = input().split()
    a = [int(n) for n in s]
    a.sort()
    a.reverse()
    
    a_i = a[0]
    sum = 0
    for x in a[1:]:
        sum += abs(a_i - x)
        a_i = x 
    
    print(sum)

if __name__ =='__main__':
    A()

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int MAX_N = 100;

int main()
{
    // スペース区切りの整数の入力
    long long a;
    cin >> a;

    long long b,c,d;

    b = a/500;
    c = a%500;

    d = c/5;

    cout << 1000*b + 5*d << endl;


    return 0;
}

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

march = ['M','A','R','C','H']

cnt = [0,0,0,0,0]

for _ in range(n):
    s = input()
    for i in range(5):
        if s[0] == march[i]:
            cnt[i]+=1
            break

b = list(itertools.combinations(cnt,3))

res = 0
for l in b:
    res +=(l[0]*l[1]*l[2])
 
print(res)


Measured memory_bytes: 3064
n,m=map(int,input().split())
numl=[1]*n
l=[False]*n
l[0]=True
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    numl[x]-=1
    numl[y]+=1
    if l[x]:
        l[y]=True
        if numl[x]==0:
            l[x]=False
print(l.count(True))

Measured memory_bytes: 4596
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string sa,sb,sc;
    cin>>sa>>sb>>sc;
    int a=0,b=0,c=0;
    int now = 0;
    while(1){
        //cout<<now<<"ABC"<<a<<b<<c<<endl;
        if(now == 0){
            //cout<<"now=0"<<endl;
            if(a>=sa.size()) break;
            if(sa[a]=='a') now = 0;
            if(sa[a]=='b') now = 1;
            if(sa[a]=='c') now = 2;
            a++;
            //cout<<a<<endl;
        }
        else if(now == 1){
            if(b>=sb.size()) break;
            if(sb[b]=='a') now = 0;
            if(sb[b]=='b') now = 1;
            if(sb[b]=='c') now = 2;
            b++;
        }
        else{
            if(c>=sc.size()) break;
            if(sc[c]=='a') now = 0;
            if(sc[c]=='b') now = 1;
            if(sc[c]=='c') now = 2;
            c++;
        }
        //cout<<a<<b<<c<<endl;
    }
    //cout<<"ABC"<<a<<b<<c<<endl;
    if(now==0) cout<<"A"<<endl;
    else if(now==1) cout<<"B"<<endl;
    else cout<<"C"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 int dp[101][10001];
 int main(){
   int N, W; //num, limit
   cin >> N >> W;
   int v[100], w[100]; //value, weight
   for(int i = 0; i < N ; i++){
     cin>> v[i] >> w[i];
   }
   int ans = 0;
   for(int i = 0; i < N ; i++){
     for(int j = 0; j <= W ; j++){
       dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
       if(j + w[i] <= W){
	 dp[i + 1][j + w[i]] =
	   max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
	 ans = max(ans, dp[i + 1][j + w[i]]);
       }
     }
   }
   cout<<ans<<endl;
   return 0;
 }



Measured memory_bytes: 7004
import Data.List.Split
import Data.Time.Calendar

type DateTime = String


eraName :: Day -> String
eraName day = do
  case beforeHeisei day of
    False -> "TBD"
    True  -> "Heisei"
  

beforeHeisei :: Day -> Bool
beforeHeisei day
  | day > heiseiEnd = False
  | otherwise       = True 

heiseiEnd :: Day
heiseiEnd = fromGregorian 2019 4 30


main = do
  s <- getLine
  let year = head $ map read $ splitOn "/" s :: Integer
  let [month, day] = tail $ map read $ splitOn "/" s :: [Int]
  
  let date =  fromGregorian year month day
  putStrLn $ eraName date


Measured memory_bytes: 508
from collections import deque

N,M,Q=map(int,input().split())

S=[]
for i in range(Q):
    S.append(list(map(int,input().split())))
sorted(S, key=lambda x: x[-1])

S0=sorted(S, key=lambda x: x[0],reverse=False)

tmp=deque([str(0)])
out=0
while tmp:
    T=tmp.pop()
    Ans=0
    if len(T)<N:
        for i in range(int(T[-1]),M):
            tmp.append(T+str(i))
    else:
        for i in range(Q):
            S0=S[i]
            if int(T[S0[1]-1])-int(T[S0[0]-1])==S0[2]:
                Ans+=S0[3]
        out=max(out,Ans)
print(out)

Measured memory_bytes: 9392
n = int(input())
nums = list(map(int,input().split()))
odd,even={},{}
for i in range(n):
  if i%2 == 0:
    if nums[i] in even:
      even[nums[i]] += 1
    else:
      even[nums[i]] = 1
  else:
    if nums[i] in odd:
      odd[nums[i]] += 1
    else:
      odd[nums[i]] = 1

if len(odd) == 1 and len(even) == 1:
  if odd == even:
    print(n//2)
  else:
    print(0)
elif len(even) == 1 and 1 < len(odd):
  for a,b in even.items():
    for k,v in sorted(odd.items(), key=lambda x: -x[1]):
      if a == k:
        continue
      else:
        print(n//2 - v)
        exit()
elif len(odd) == 1 and 1 < len(even):
  for a,b in odd.items():
    for k,v in sorted(even.items(), key=lambda x: -x[1]):
      if a == k:
        continue
      else:
        print(n//2 - v)
        exit()
else:
  a = sorted(odd.items(), key=lambda x: -x[1])
  b = sorted(even.items(), key=lambda x: -x[1])
  if a[0][0] == b[0][0]:
    print(n - max(a[0][1]+b[1][1],a[1][1]+b[0][1]))
  else:
    print(n - a[0][1] - b[0][1])

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

using namespace std;

int a[105];

int main(){
	int n,sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}	
	int x=sum/n-1,y=sum/n,z=sum/n+1;
	int res1=0,res2=0,res3=0;
	for(int i=0;i<n;i++){
		res1+=pow(a[i]-x,2);
		res2+=pow(a[i]-y,2);
		res3+=pow(a[i]-z,2);
	}
	cout<<min(res1,min(res2,res3))<<endl;
	return 0; 
}

Measured memory_bytes: 256
# Aizu Problem 0079: Area of Polygon
#
import sys, math, os

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


def poly_area(polygon, M):
    A = 0
    for i in range(M):
        x1, y1 = polygon[i][0], polygon[i][1]
        x2, y2 = polygon[(i+1)%M][0], polygon[(i+1)%M][1]
        A += (x1 * y2 - x2 * y1)
    return abs(A / 2)


poly = [[float(_) for _ in line.split(',')] for line in sys.stdin]
print("%.6f" % poly_area(poly, len(poly)))

Measured memory_bytes: 7600
def factorize(n):
    fct = []
    b = 2
    e = 0
    while b * b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b, e))
        b += 1
        e = 0
    if n > 1:
        fct.append((n, 1))
    return fct


n = int(input())

fct = factorize(n)

ans = 0
for i in fct:
    nokori = i[1]
    count = 1
    while nokori >= count:
        nokori -= count
        count += 1
        ans += 1

print(ans)

Measured memory_bytes: 9200
import math
#map(int,input().split())
#int(x) for x in input().split()
#for _ in range(int(input())):
n=int(input())
l=[int(x) for x in input().split()]
q=int(input())
d={}
for i in range(len(l)):
	if l[i] in d:
		d[l[i]]+=1
	else:
		d[l[i]]=1
s=sum(l)
for i in range(q):
	a,b=map(int,input().split())
	if a==b:
		print(s)
		continue
	if a not in d:
		d[a]=0
	s=(s-d[a]*a+b*d[a])
	print(s)
	if b in d:
		d[b]+=d[a]
	else:
		d[b]=d[a]
	d[a]=0









Measured memory_bytes: 87436
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<typename Monoid>
struct SegmentTree{
	using F=function<Monoid(Monoid, Monoid)>;
	int sz;
	vector<Monoid> seg;
	const F f;
	const Monoid e;

	SegmentTree(int n, const F f, const Monoid &e): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
	}

	SegmentTree(int n, const F f, const Monoid &e, vector<Monoid> v): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
		for(int i=0; i<n; i++) seg[i+sz]=v[i];
		for(int i=sz-1; i>=1; i--){
			seg[i]=f(seg[2*i], seg[2*i+1]);
		}
	}

	void update(int k, const Monoid &x){
		k+=sz;
		seg[k]=x;
		while(k>1){
			k>>=1;
			seg[k]=f(seg[2*k], seg[2*k+1]);
		}
	}

	Monoid query(int a, int b){
		a+=sz, b+=sz;
		Monoid ret=e;
		for(;a<b; a>>=1, b>>=1){
			if(b&1) ret=f(ret, seg[--b]);
			if(a&1) ret=f(ret, seg[a++]);
		}
		return ret;
	}

	/*Monoid query(int a, int b){ //演算が非可換のとき
		a+=sz, b+=sz;
		Monoid retl=e, retr=e;
		for(;a<b; a>>=1, b>>=1){
			if(b&1) retr=f(seg[--b], retr);
			if(a&1) retl=f(retl, seg[a++]);
		}
		return f(retl, retr);
	}*/

	Monoid operator[](const int &k) const{
		return seg[k+sz];
	}
};
int n;
vector<vector<int>> g;
int a[200020];
vector<int> as;

int main()
{
	cin>>n;
	as.resize(n);
	g.resize(n);
	for(int i=0; i<n; i++){
		cin>>a[i]; as[i]=a[i];
	}
	sort(as.begin(), as.end());
	as.erase(unique(as.begin(), as.end()), as.end());
	for(int i=0; i<n; i++){
		a[i]=lower_bound(as.begin(), as.end(), a[i])-as.begin();
	}
	for(int i=0; i<n-1; i++){
		int u, v; cin>>u>>v;
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int m=as.size();
	SegmentTree<int> seg(m, [](int a, int b){ return max(a, b);}, 0);
	int ans[200020];
	ans[0]=1;
	seg.update(a[0], 1);
	auto dfs=[&](auto dfs, int x, int p)->void{
		for(auto y:g[x]){
			if(y==p) continue;
			int w=seg.query(0, a[y]);
			int wp=seg[a[y]];
			if(wp<w+1) seg.update(a[y], w+1);
			ans[y]=max(ans[x], seg[a[y]]);
			dfs(dfs, y, x);
			seg.update(a[y], wp);
		}
	};
	dfs(dfs, 0, -1);
	for(int i=0; i<n; i++) cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 50892
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<functional>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vvi imos(n + 1, vi(n + 2, 0));
  rep(i, 0, m) {
    int l, r;
    cin >> l >> r;
    erep(j, 1, l) {
      imos[j][r]++;
      imos[j][n + 1]--;
    }
  }

  erep(i, 1, n) {
    rep(j, 1, n) {
      imos[i][j + 1] += imos[i][j];
    }
  }

  rep(i, 0, q) {
    int p, q;
    cin >> p >> q;
    cout << imos[p][q] << endl;
  }
}


Measured memory_bytes: 1920
using System;
class aoj
{
    static void Main()
    {
        while (true)
        {
            int a = int.Parse(Console.ReadLine());
            if (a == 0) break;
            for(int i = 0; i < 9; i++)
            {
                int b = int.Parse(Console.ReadLine());
                a -= b;
            }
            Console.WriteLine(a);
        }
    }
}

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

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(void){
    int N,D; cin >> N >> D;
    vector<vector<int>> X(N,vector<int>(D,0));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            cin >> X.at(i).at(j);
        }
    }
    int ans = 0;
    for(int i1 = 0; i1 < N-1; i1++){
        for(int i2 = i1+1; i2 < N; i2++){
            //cout << i1 << ' ' << i2 << endl;
            int dis_dis = 0;
            for(int k = 0; k < D; k++){
                dis_dis += pow(X[i1][k]-X[i2][k],2);
            }
            //cout << dis_dis << endl;
            for(int k = 1; k <= sqrt(dis_dis); k++){
                if((dis_dis % k == 0) && (dis_dis / k == k)){
                    ans++;
                    //cout << "aaa" << endl;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def mrx():
    N,T = input().split()
    N,T= int(N),int(T)
    travel = {}
    for i in range(N):
        c , t = input().split()
        travel[int(c)] = int(t)
    for j in sorted(travel):
        if travel[j] <= T:
            return j
    return "TLE"



print(mrx())


Measured memory_bytes: 3060
use std::io;

fn main() {
    let s1 = parse_line::<String>();
    let mut ss = s1.split_whitespace();
    let s = ss.next().unwrap();
    let t = ss.next().unwrap();
    println!("{}{}", t, s);
}

fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


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

using namespace std;

typedef long long int64;

const int mod = 1e9 + 7;

int dp[301][301][301];
int N, M;

int64 rec(int idx, int connect, int add)
{
  if(idx == M) return (connect == N);
  if(~dp[idx][connect][add]) return (dp[idx][connect][add]);
  int64 ret = 0;
  if(connect + add + 1 <= N) ret += rec(idx + 1, connect, add + 1) * (N - connect - add) % mod;
  if(add > 0) ret += rec(idx + 1, connect, add) * add % mod;
  ret += rec(idx + 1, connect + add, 0) * connect % mod;
  ret %= mod;
  return (dp[idx][connect][add] = ret);
}

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

Measured memory_bytes: 106752
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    int n; cin>>n; int a[n],b[n]; 
    for(int i=0;i<n+1;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int rem=b[i]-a[i]; ans+=min(a[i],b[i]); int prev=a[i+1];
        a[i+1]=max(0LL,a[i+1]-max(rem,0LL)); 
        ans+=prev-a[i+1];
       
    }
    cout<<ans<<endl; return 0;
}


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

int main(){
	
	int n;
	string a;
	string b;
	string respuesta = "";
	
	cin>>n;
	cin>>a;
	cin>>b;
	
	for(int i= 0; i < n; i++){
		respuesta = respuesta + a.at(i)+b.at(i);
	}
	
	cout << respuesta;
	
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 13 18:17:29 2018
ALDS_1_13_A
@author: maezawa
"""
import copy
def searchq(board, k):
    global result
    if k == 0:
        result = copy.deepcopy(board)
        return True
    for x in range(1,9):
        for y in range(1,9):
            #if k == 6:
                #print(x,y,board[x][y])
            if board[x][y] == 0:
                cpb = copy.deepcopy(board)
                cpb[x][y] = 9
                mark(cpb, x,y)
                #print(x,y)
                if searchq(cpb, k-1):
                    return True
                #else:
                    #print('False at {},{}'.format(x,y))
    return False
      
def mark(board, x, y):
    direction = [(-1,-1), (-1,0), (-1,1), (0,-1), (0,1), (1,-1),
                 (1,0), (1,1)]
    for dx, dy in direction:
        x1 = x
        y1 = y
        while True:
            x1 += dx
            y1 += dy
            if board[x1][y1] == 0 or board[x1][y1] == 1:
                board[x1][y1] = 1
            else:
                break
            
n = int(input())
board = [[0]*10 for _ in range(10)]
board[0] = [-1]*10
board[9] = [-1]*10

result = copy.deepcopy(board)

for i in range(10):
    board[i][0] = -1
    board[i][9] = -1
for i in range(n):
    x, y = list(map(int, input().split()))
    board[x+1][y+1] = 9
    mark(board, x+1, y+1)

#print(*board[1:9], sep='\n')
if searchq(board, 8-n):
    pass
else:
    print('Error')
#print(*result[1:9], sep='\n')
for x in range(1,9):
    for y in range(1,9):
        if result[x][y] == 9:
            print('Q', end='')
        else:
            print('.', end='')
    print()




Measured memory_bytes: 6356
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

            int K = input[0];
            int X = input[1];

            int min = X - K + 1;
            int max = X + K - 1;

            for(int i = min; i <= max; i++)
            {
                Console.Write(i);
                Console.Write(' ');
            }

            
        }
    }
}

Measured memory_bytes: 11220
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	int c;
	c=a*b;
	if(c%2==0)
	   cout<<"Even"<<endl;
	else
	   cout<<"Odd"<<endl;
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        HashMap<Integer, List<Integer>> edges = new HashMap<>();
        for (int i = 0; i < M; i++) {
            int from = scan.nextInt() - 1;
            int to = scan.nextInt() - 1;
            if (!edges.containsKey(from)) {
                edges.put(from, new ArrayList<>());
            }
            edges.get(from).add(to);
        }
        List<Integer> firstlist = edges.get(0);
        boolean answer = false;
        for (int first : firstlist) {
            List<Integer> secondlist = edges.get(first);
            if (secondlist == null) {
                continue;
            }
            for (int second : secondlist) {
                if (second == N - 1) {
                    answer = true;
                    break;
                }
            }
        }
        System.out.println(answer ? "POSSIBLE" : "IMPOSSIBLE");
    }
}


Measured memory_bytes: 134840
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, a, b, c);
	swap(a, b);
	swap(a, c);
	OUT(a, b, c);
}


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

#define rep(i, x, n) for(int i=(x);i<(n);i++)
#define reps(i, x, n) for(int i=(x);i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
//八方向を見るのに使うと便利(楽)
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

//最大公約数
lol gcd(lol x, lol y){ return (y != 0 ? gcd(y, x % y) : x); }
//最小公倍数
lol lcm(lol x, lol y){ return ((x * y) / gcd(max(x, y), min(x, y))); }

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, a, ans = 1;
  cin >> n;
  map<int, int> cnt;
  rep(i, 0, n){
    cin >> a;
    cnt[a] ++;
  }
  a = (n % 2 == 0 ? -1 : -2);
  for(auto x : cnt){
    if(a + 2 != x.first || (a != -1 && a != -2) && x.second % 2 == 1){
      cout << "0\n";
      return 0;
    }
    a = x.first;
    ans = (ans * x.second) % MOD;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 6556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
 	int n;	cin >> n;
  	if(n%2 == 0) cout << fixed << setprecision(15) << (double)1/2 << endl;
  	else cout << fixed << setprecision(15) << (double)((n-1)/2+1)/n << endl;
}

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

int main() {
    
    int v[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    
    cout<<v[k-1];
    
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int C[300000], D[300000];
void pakuripair_sort(int N, int A[], int B[]) {
	const int b = 8;
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			C[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			D[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
		}
		k++;
		rep(i, N) kazu2[C[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[C[i] >> k * b & ((1 << b) - 1)]] = C[i];
			B[kazu2[C[i] >> k * b & ((1 << b) - 1)]] = D[i];
		}
	}
}

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


	int N = getint();
	int A[300000], B[300000], A0[100000];
	ll S[100001];
	S[0] = 0;
	ll kari = 0;
	int saishou = 1e9;
	int saidai = 0;
	rep(i, 3 * N) {
		A[i] = getint();
		B[i] = i;
	}
	rep(i, N) S[0] += A[i];
	for (int i = N; i < 2 * N; i++) A0[i - N] = A[i];
	for (int i = 2 * N; i < 3 * N; i++) kari += A[i];
	
	pakuripair_sort(3 * N, A, B);
	rep(i, 3 * N) C[B[i]] = i;

	memset(B, 0, sizeof(B));
	rep(i, N) {
		B[C[i]] = 1;
		chmin(saishou, C[i]);
	}

	rep(i, N) {
		if (saishou < C[i + N]) {
			B[C[i + N]] = 1;
			while (!B[saishou]) saishou++;
			B[saishou] = 0;
			S[i + 1] = S[i] + A0[i] - A[saishou];
		}
		else S[i + 1] = S[i];
	}

	memset(B, 0, sizeof(B));
	for (int i = 2 * N; i < 3 * N; i++) {
		B[C[i]] = 1;
		chmax(saidai, C[i]);
	}

	ll kotae = S[N] - kari;
	for (int i = N - 1; i >= 0; i--) {
		if (saidai > C[i + N]) {
			B[C[i + N]] = 1;
			while (!B[saidai]) saidai--;
			B[saidai] = 0;
			kari += A0[i] - A[saidai];
		}
		chmax(kotae, S[i] - kari);
	}

	printf("%lld", kotae);

	Would you please return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> s(n);
    int sum=0;
    rep(i,n) {
        cin >> s.at(i);
        sum += s.at(i);
    }

    sort(s.begin(), s.end());
    if (sum%10) {
        cout << sum << endl;
        return 0;
    }

    rep(i,n) {
        if (s.at(i)%10) {
            cout << sum-s.at(i) << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 3580
#include <iostream>
#include <bits/stdc++.h>
// Input macros
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
// Useful constants
#define INF                         (int)1e9
#define EPS                         1e-9
// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
// Useful container manipulation / traversal macros
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
// Some common useful functions
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)                ( (n >> b) & 1)
#define DREP(a)                      sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind)               (lower_bound(all(arr),ind)-arr.begin())
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main()
{
    int A, B, C;
    bool flg = 0;
    cin>>A>>B;
    forall(i,1,4){
        if ((i * A * B ) & 1)
            flg = true;
    }
    if (flg){
        cout<<"Yes";
    } else {
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <unordered_map>
using namespace std;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

bool compare_by_b(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<2>(a) != get<2>(b)){
        return get<2>(a) > get<2>(b);
    }
}

bool compare_by_string(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<1>(a) != get<1>(b)){
        return get<1>(a) < get<1>(b);
    }else{
      	return get<2>(a) > get<2>(b);
    }
}


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int P,Q,R;
  	cin >> P >> Q >> R;
  	if(P >= Q && P >=R) cout << Q + R  << endl;
  	else if(Q >= P && Q >=R) cout << P + R << endl;
  	else if(R >= P && R >= Q) cout << P + Q << endl;
  	return 0;
}


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

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N, M;

// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;
    if (N&1) {
        N -= N&1;
        F0R(i,M) cout << i+1 << ' ' << N-i << '\n';
    } else {
        F0R(i,M) {
            if (N-2*i-1 <= N/2) cout << i+1 << ' ' << N-i-1 << '\n';
            else cout << i+1 << ' ' << N-i << '\n';
        }
    }
}

Measured memory_bytes: 3568
#include <stdio.h>

int main(void){
    int N, K, A[20005], i, j, a, b;
    long long c;
    scanf("%d%d", &N, &K);
    c=0;
    for (i=0; i<N; i++) {
        scanf("%d", &A[i]);
    }
    for (i=0; i<N; i++) {
        a=0; b=0;
        for (j=0; j<N; j++) {
            if (A[i]>A[j]) {
                if (i<j) a++;
                b++;
            }
        }
        
        c+=(long long)K*(long long)a+((long long)(K-1)*(long long)K/(long long)2)%1000000007*(long long)b;
        c%=(long long)1000000007;
        
        // printf("(%d, %d, %lld)\n", a, b, (long long)K*(long long)a+(long long)(K-1)*(long long)K*(long long)b/(long long)2);
    }
    printf("%lld", c);
    // for (i=0; i<N; i++) printf("%d", A[i]);
    return 0;
}

Measured memory_bytes: 128
N, A, B = map(int, input().split())
S = list(input())
cy = 0
co = 0
for i in range(N):
  if S[i]=='a':
    if cy < A+B:
      cy += 1
      print('Yes')
    else:
      print('No')
  if S[i]=='b':
    if cy < A+B and co < B:
      cy += 1
      co += 1
      print('Yes')
    else:
      print('No')
  if S[i]=='c':
    print('No')


Measured memory_bytes: 79556
#include <stdio.h>

int main(void) {
	double kou,sum;
	int i;
	while(1) {
		if(scanf("%lf",&kou)==-1)break;
		sum=kou;
		for(i=2;i<=10;i++) {
			if(i%2==0)kou*=2; else kou/=3;
			sum+=kou;	
		}
		printf("%f\n",sum);		
	}		
	return 0;	
}	

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a;
    b = a - (a/10)*10;
    switch (b) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;   
            break;         
    }
    return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <algorithm>
using namespace std;
int N, K, h[100000];
int main() {
  scanf("%d %d", &N, &K);
  for(int i = 0; i < N; ++i) scanf("%d", &h[i]);
  sort(h, h+N);
  int diff = 1e9;
  for(int i = 0; i+K-1 < N; ++i) {
    diff = min(diff, h[i+K-1]-h[i]);
  }
  printf("%d\n", diff);
}

Measured memory_bytes: 512
#include<stdio.h>
int se(int n){
  int cnt = 0;
  for(int i = 1;i <= n;i++){
    if(n % i == 0){
      cnt++;
    }
  }
  return cnt;
}
int main(){
  int N,cnt = 0;
  scanf("%d",&N);
  for(int i = 105;i <= N;i += 2){
    if(se(i) == 8){
      cnt++;
    }
  }
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
l=sorted(l,key=lambda x:x[1])
start,ans=0,0
for i in range(m):
    if start<l[i][0]:
        start=l[i][1]-1
        ans+=1
print(ans)

Measured memory_bytes: 29852
S=input()
flag = False
if S=="zyxwvutsrqponmlkjihgfedcba":
    T="-1"
elif len(S)<=25:
    for i in range(97,123):
        if chr(i) not in S:
            T=S+chr(i)
            break
else:
    for i in range(2,27):
        for j in range(ord(S[-i])+1,123):
            if chr(j) not in S[:-i]:
                T=S[:-i]+chr(j)
                flag=True
                break
        if flag:
            break
print(T)

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

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

int func(int n){

}


int main() {
    int h,w;
    cin >> h >> w;
    char pic[h+2][w+2] = {'.'};

    for(int i=1;i<=h;i++){
        string str;
        cin >> str;
        for(int j=1;j<=w;j++){
            pic[i][j] = str.at(j-1);
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(pic[i][j] == '#'){
                if(pic[i-1][j] == '.' && pic[i+1][j] == '.' && pic[i][j-1] == '.' && pic[i][j+1] == '.'  ){
                    cout << "No";
                    return 0;
                }
            }
        }
    }
    cout << "Yes";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int N; cin >> N;
	string s; cin >> s;
	string t1 = s.substr(0,N);
	reverse(s.begin(),s.end());
	string t2 = s.substr(0,N);
	vector<pair<string,string>> v1; 
	rep(i,1<<N){
		string a = "";
		string b = "";
		rep(j,N){
			if(i>>j&1) a += t1[j];
			else b += t1[j];

		}
		reverse(b.begin(),b.end());
		v1.emplace_back(a,b);
	}
	vector<pair<string,string>> v2;
	rep(i,1<<N){
		string a = "";
		string b = "";
		rep(j,N){
			if(i>>j&1) a += t2[j];
			else b += t2[j];
		}
		reverse(b.begin(),b.end());
		v2.emplace_back(a,b);
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	ll ans = 0;
	rep(i,1<<N){
		ans += upper_bound(v2.begin(),v2.end(),v1[i])-lower_bound(v2.begin(),v2.end(),v1[i]);
	}
	cout << ans << endl;
}



Measured memory_bytes: 64492
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int A = in.nextInt();
		int B = in.nextInt();
		List<Integer> P = new ArrayList<>();
		for (int i = 0; i < N; ++i) {
			P.add(in.nextInt());
		}

		in.close();

		List<Integer> firsts = new ArrayList<>();
		List<Integer> seconds = new ArrayList<>();
		List<Integer> thirds = new ArrayList<>();
		for (Integer p : P) {
			if (p <= A) {
				firsts.add(p);
			} else if (A + 1 <= p && p <= B) {
				seconds.add(p);
			} else if (B + 1 <= p) {
				thirds.add(p);
			}
		}
		System.out.println(Math.min(firsts.size(), Math.min(seconds.size(), thirds.size())));
	}
}

Measured memory_bytes: 22740
#include<cstdio>
typedef long long LL;
const int N=1e6+5,md=1e9+7;
int a,b,c,fac[N],iv[N],ans;
inline int pow(int a,int b){
	int ret=1;
	for(;b;b>>=1,a=(LL)a*a%md)if(b&1)ret=(LL)ret*a%md;
	return ret;
}
inline int C(int n,int m){return n>=m?(LL)fac[n]*iv[m]%md*iv[n-m]%md:0;}
int main(){
	scanf("%d%d%d",&a,&b,&c);
	if(!a--)return puts("1"),0;
	if(b>c)b^=c^=b^=c;
	for(int i=*fac=1;i<=1000000;++i)fac[i]=(LL)fac[i-1]*i%md;
	iv[1000000]=397802501;
	for(int i=1e6-1;~i;--i)iv[i]=(i+1LL)*iv[i+1]%md;
	int pL=0,pR=0;
	for(int i=0,x=1,y=pow(3,b+c);i<=b+c;++i){
		int nL=i<=c?0:(pL*2LL-C(i-1,i-c-2)+C(i,i-c-1)+md)%md;
		int nR=i<=b?x:(pR*2LL-C(i-1,b)+md)%md;
		pL=nL,pR=nR;
		ans=(ans+(LL)C(i+a,a)*(nR-nL+md)%md*y)%md;
		x=x*2%md,y=y*333333336LL%md;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7936
//Heaplax
#include<bits/stdc++.h>
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
    while(ch=getchar(),ch<33);
    if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
    while(ch=getchar(),ch>33)x=x*10+ch-48;
    if(fs)x=-x;
}
using namespace std;
int n;
char s[105],t[105];
int main()
{
	re(n);
	scanf("%s%s",s+1,t+1);
	for(int i=1;i<=n;++i)
	{
		bool ok=1;
		for(int j=i;j<=n;++j)
			if(s[j]!=t[j-i+1])
			{
				ok=0;
				break;
			}
		if(ok)
		{
			printf("%d\n",n+i-1);
			return 0;
		}
	}
	printf("%d\n",n+n);
}

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

int main(){
  vector<int> vec;
  vec={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K ;
  cout << vec.at(K - 1) << endl;
}


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

void answer1() {
  cin.tie(0);
	ios_base::sync_with_stdio(false);

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  vector<bool> alice_on(101, false);
  for (int i = a; i < b; i++) {
    alice_on.at(i) = true;
  }

  int count = 0;
  for (int i = c; i < d; i++) {
    if (alice_on.at(i)) {
      count++;
    }
  }
  cout << count << endl;
}

void answer2() {
  cin.tie(0);
	ios_base::sync_with_stdio(false);

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a <= c && c < b) {
    if (d < b) {
      cout << d - c << endl;
    } else {
      cout << b - c << endl;
    }
  } else if (c <= a && a < d) {
    if (b < d) {
      cout << b - a << endl;
    } else {
      cout << d - a << endl;
    }
  } else {
    cout << 0 << endl;
  }
}

int main() {
  //answer1();
  answer2();
}


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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
  #define DFUNC(fname, ...) fname(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFUNC(fname, ...)
#endif


class UnionFind {
protected:
  int size;
  vector<int> _leader;
  vector<int> _rank;
  
public:
  UnionFind(int s);
  int leader(int i);
  int merge(int i, int j);
};

UnionFind::UnionFind(int s) {
  size = s;
  _leader = vector<int>(size);
  for (int i = 0; i < size; i++) { _leader.at(i) = i; }
  _rank = vector<int>(size, 1);
}

int UnionFind::leader(int i) {
  int cur = i;
  int nxt = _leader.at(cur);
  vector<int> seen;
  while (cur != nxt) {
    seen.push_back(cur);
    cur = nxt;
    nxt = _leader.at(cur);
  }
  for (auto j : seen) _leader.at(j) = cur;
  return cur;
}

int UnionFind::merge(int i0, int j0) {
  int li = leader(i0);
  int lj = leader(j0);
  if (li == lj) return li;
  int ri = _rank.at(li);
  int rj = _rank.at(lj);
  if      (ri < rj)  return _leader.at(li) = lj;
  else if (ri > rj)  return _leader.at(lj) = li;
  else {
    (_rank.at(lj))++;
    return _leader.at(li) = lj;
  }
}

ll N, M;



int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N >> M;
  UnionFind uf = UnionFind(N+1);
  for (ll i = 0; i < M; i++) {
    ll x, y, z;
    cin >> x >> y >> z;
    uf.merge(x, y);
  }
  ll cnt = 0;
  for (ll j = 1; j <= N; j++) {
    if (uf.leader(j) == j)  cnt++;
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 1024
n = gets.to_i
g = Array.new(n).map{Array.new}
(n-1).times do
  s = gets.split.map(&:to_i)
  g[s[0]-1] << [s[1],s[2]]
  g[s[1]-1] << [s[0],s[2]]
end
ans = Array.new(n,nil)
ans[0] = 0
queue = [1]
while queue.size > 0
  g[queue[0]-1].each do |k|
    if ans[k[0]-1] == nil
      queue << k[0]
      ans[k[0]-1] = ans[queue[0]-1] + k[1]
    end
  end
  queue.shift
end
puts ans.map{|i|i%2}

Measured memory_bytes: 29052
D = gets.to_i
C = gets.chomp.split.map(&:to_i)
s = D.times.map{gets.split.map(&:to_i)}
c = Array.new(26, 0)
t = []

(0..D-1).each do |i|

  (0..25).each do |l|
    c[l] += C[l]
  end
ans = 0
boder = s[i][0]+8*c[0]

  (1..25).each do |e|
    if s[i][e]+8*c[e] >= boder
      ans = e
      boder = s[i][e]+8*c[e]
    end
  end
c[ans] = 0
puts ans+1
end


  



Measured memory_bytes: 14412
import math
MOD=10**9+7
MAX=10**6
sq_max=int(math.sqrt(MAX))

seive=[1 for _ in range(MAX+1)]
seive[0]=0
seive[1]=0
for i in range(sq_max+1):
  if seive[i]==0:
    continue
  for j in range(i*2,MAX+1,i):
    seive[j]=0

def factor(num):
  factordic={}
  for i in range(2,min([MAX+1,int(math.sqrt(num))+1])):
    if seive[i]==1 and num%i==0:
      factordic[i]=1
      num//=i
      while num%i==0:
        factordic[i]+=1
        num//=i
    if num==1:
      break
  else:
    factordic[num]=1
  return(factordic)


inv=[1,1]
for i in range(2, MAX+1):
  inv.append(MOD - inv[MOD % i] * (MOD // i) % MOD)

N=int(input())
ls=[int(s) for s in input().split()]
lcm={}
for num in ls:
  d=factor(num)
  for key,value in d.items():
    if key in lcm:
      lcm[key]=max(value,lcm[key])
    else:
      lcm[key]=value
lcmmod=1
for key,value in lcm.items():
  lcmmod=(lcmmod*(key**value))%MOD
invsum=0
for e in ls:
  invsum=(invsum+inv[e])%MOD
print((invsum*lcmmod)%MOD)



Measured memory_bytes: 114032
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, A[100001], a=-1, b=-1;

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

    sort(A+1, A+N+1);

    for(i=N; i>=2; i--){
        if(A[i] == A[i-1]){
            if(a == -1){
                if(A[i-1]==A[i-2] && A[i-2]==A[i-3]){
                    a = A[i];
                    b = A[i];
                    break;
                }
                else{
                    a = A[i];
                }
            }

            else{
                if(A[i] != a){
                    b = A[i];
                    break;
                }
            }
        }
    }

    if(b==-1) cout << 0 << endl;
    else cout << a*b << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>

using Bool = bool;
using Int = long long int;
using Char = char;
using String = std::string;
template <class T, class U>
using Map = std::map<T, U>;

struct Parser {
    String s;
    Int i;
    Map<Char, Int> size;
    Map<Char, Map<Int, Int>> vars;
    Bool bugged;

    Int expr() {
        Int ret = 0;

        if (std::isdigit(s[i])) {
            while (std::isdigit(s[i])) {
                ret = ret * 10 + s[i] - '0';
                ++i;
            }
        } else {
            Char name = s[i];
            i += 2;
            Int idx = expr();
            // assert(s[i] == ']');
            ++i;

            // undeclared or uninitialized
            if (!vars.count(name) || !vars[name].count(idx)) {
                bugged = true;
            } else {
                ret = vars[name][idx];
            }
        }
        return ret;
    }

    void prog() {
        Char name = s[i];
        i += 2;
        Int idx = expr();
        // assert(s[i] == ']');
        ++i;

        if (i == s.length()) {
            // declaration
            size[name] = idx;
        } else {
            // assert(s[i] == '=');
            ++i;

            // out of range
            if (size[name] <= idx) bugged = true;

            Int val = expr();
            // assert(i == s.length());
            vars[name][idx] = val;
        }
    }

    void operator()() {
        bugged = false;
        i = 0;
        prog();
    }
};

Bool solve() {
    Parser parse;
    auto& s = parse.s;
    Int ans = 0, l = 1;

    while (true) {
        std::cin >> s;
        if (s == ".") {
            break;
        } else if (ans > 0) {
            continue;
        }

        parse();
        if (parse.bugged) ans = l;
        ++l;
    }
    if (l == 1) return false;

    std::cout << ans << std::endl;
    return true;
}

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



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

using namespace std;

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

	int ans = 0;

	for (int i = 0; i < N; i++) {
		if (C[i] < V[i]) {
			ans += V[i] - C[i];
		}
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
    int n, count;
    cin >> n;
    count = 0;
    vector<int> vec(n);

    for(int i = 0; i < n; i++){
        cin >> vec.at(i);
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < i; j++){
            count += vec.at(i) * vec.at(j);
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	unsigned long long h,atk=0,i=0;
	cin>>h;
	while(h!=0)
	{
		h=h/2;
		atk+= pow(2,i);
		i++;
	}
	cout<<atk;
	return 0;
}


Measured memory_bytes: 256