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

public class Solution
{
    public static int[] GetZarray(string str)
    {
        var n = str.Length;
        var z = new int[n];
        var l = 0;
        var r = 0;

        for (int i = 1; i < n; i++)
        {
            if (i > r)
            {
                l = r = i;
                while (r < n && str[r - l] == str[r])
                {
                    r++;
                }
                z[i] = r - l;
                r--;
            }
            else
            {
                int k = i - l;
                if (z[k] < r - i + 1)
                {
                    z[i] = z[k];
                }
                else
                {
                    l = i;
                    while (r < n && str[r - l] == str[r])
                    {
                        r++;
                    }
                    z[i] = r - l;
                    r--;
                }
            }
        }
        return z;
    }

    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var S = Console.ReadLine();

        var max = 0;
        for (int i = 0; i < N; i++)
        {
            var z = GetZarray(S.Substring(i));
            for (int j = 0; j < N - i; j++)
            {
                if (z[j] <= j)
                {
                    max = Math.Max(max, z[j]);
                }
            }
        }
        Console.WriteLine(max);
    }
}

Measured memory_bytes: 34984
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,m;
  cin >> n >> m;
  cout << (n-1)*(m-1)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

int n,k;
ll ans;

int main(){
	scanf("%d %d",&n,&k);
	cout<<(ll)(n / k) * (n / k) * (n / k) + (ll)(k % 2 == 0) * ((n + k / 2) / k) * ((n + k / 2) / k) * ((n + k / 2) / k)<<endl;

}


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

struct UnionFind {
private:
    int n;
    vector<int> r, p; //r means "rank", p means "parent"
    
public:
    UnionFind() = delete;
    explicit UnionFind(int sz) : n(sz), r(sz, 1), p(sz, 0){
        iota(p.begin(), p.end(), 0);
    }// set data as parent[i] = i
    
    int find(int x) {
        return (x == p[x] ? x : p[x] = find(p[x]));
    }// find and return parents

    bool same(int x, int y) {
        return find(x) == find(y);
    }// if node x and y is same root or not

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(r[x] < r[y]) swap(x, y);
        r[x] += r[y];
        p[y] = x;
    }// unite different groups into same one

    int size(int x) {
        return r[find(x)];
    }// return size of group where r[x]belong
};

int main(){

  int n,m;

  cin >> n >> m;
  
  vector<int> a(m), b(m);

  for(int i = 0; i < m; i++){
      cin >> a[i] >> b[i];
  }
  UnionFind uf(n);
  vector<ll> ans(m+1, 0);
  
  ans[m] = (ll) n*(n-1)/2;
  
  for(int i = m-1; i >= 0; i--){
    a[i]--;
    b[i]--;
    ans[i] = ans[i+1]; //到達可能な辺の差分を求めるため、前回の分をコピー
    if(uf.same(a[i], b[i])) continue; //辺のグループが同じなので組が変化しない
    
    ll x = uf.size(a[i]), y = uf.size(b[i]); //つながっている辺の数を求める
    ans[i] -= x * y; //group_Aのつながり＊group_Bのつながり　＝　組の数

    uf.unite(a[i], b[i]);
  }

  for(int i = 1; i <= m; i++){
      cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#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<ll> A(N), c(N);

    rep(i, N) {
        int a; cin >> a;
        a--;
        A[i] = a;
        c[a]++;
    }

    ll ans = 0;
    rep(i, N)
        ans += c[i] * (c[i] - 1) / 2;

    rep(i, N) {
        int a = A[i];
        if (c[a] < 2)
            cout << ans << endl;
        else {
            ll cal = ans;
            ll t = c[a] - 1;
            cal -= c[a] * t / 2;
            cal += t * (t - 1) / 2;

            cout << cal << endl;
        }
    }
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  int n_subsets = pow(2, n);

  int n_mask_bits;
  cin >> n_mask_bits;

  bitset<18> mask(0);
  for (int i = 0; i < n_mask_bits; i++) {
    int tmp;
    cin >> tmp;
    mask.set(tmp);
  }

  for (int i = 0; i < n_subsets; i++) {
    bitset<18> bs(i);
    if ((bs & mask) == mask) {
      cout << i << ":";
      for (int j = 0; j < 18; j++) {
        if (bs.test(j)) {
          cout << " " << j;
        }
      }
      cout << endl;
    }
  }
}




Measured memory_bytes: 3364
import java.util.Scanner;
public class Main {
	static int[] arr = new int[110];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0;i<n;i++)
			arr[i] = sc.nextInt();
		int res = selectSort(n);
		print(n);
		System.out.println(res);
	}
	
	static int selectSort(int n) {
		int cnt = 0;
		for(int i=0;i<n;i++) {
			int minIndex = i;
			for(int j=i+1;j<n;j++)
				if(arr[j]<arr[minIndex])
					minIndex = j;
			if(minIndex!=i) {
				swap(i,minIndex);
				cnt++;
			}
		}
		return cnt;
	}
	
	static void swap(int a,int b) {
		int t = arr[a];
		arr[a] = arr[b];
		arr[b] = t;
	}
	static void print(int n) {
		for(int i=0;i<n;i++) {
			if(i==0) System.out.print(arr[i]);
			else System.out.print(" "+arr[i]);
		}
		System.out.println();
	}
}


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

int main(){
    int n,m,a[100];
    cin>>n>>m;
    for(int i=0;i<m;i++)cin>>a[i];

    int cnt[100]={0};

    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            int t;cin>>t;
            if(a[i]==t)cnt[j]++;
            else cnt[a[i]-1]++;
        }
    }

    for(int i=0;i<n;i++)cout<<cnt[i]<<endl;
    return 0;
}

Measured memory_bytes: 1160
import sys

s = sys.stdin.readline()

n1 = int(s[:2])
n2 = int(s[2:])

n1m = n1 >= 1 and n1 <= 12
n2m = n2 >= 1 and n2 <= 12

if n1m and n2m:
    print('AMBIGUOUS')
elif n1m:
    print('MMYY')
elif n2m:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
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;
}
const long long INF = 1LL << 60;

ll n;
int main()
{
    cin >> n;
    int ans = 0;
    ans = (n % 1000 == 0) ? 0 : 1000 - (n % 1000);
    cout << ans << endl;
    return 0;
}


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

int main(){
    long double l;
    long double a,b,c,ans(0.0);
    cin >> l;

    a = b = c = l/3;

    ans = a*b*c;
    cout << fixed << setprecision(13) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  sort(all(A));
  reverse(all(A));
  
  int ans = A[0];
  N -= 2;
  int k = 1;
  
  while(N >= 2) {
    ans += A[k]*2;
    k++;
    N -= 2;
  }
  if(N > 0) ans += A[k];
  cout << ans << endl;
}

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

using namespace std;

int main() {
  int64_t L, R;
  cin >> L >> R;
  R = min(R, L + 2019);

  int64_t answer = 2019;
  for (int64_t a = L; a <= R; a++) {
    for (int64_t b = a + 1; b <= R; b++) {
      int64_t r = a * b % 2019;
      answer = min(answer, r);
    }
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k;
    cin>>n>>k;
    vector<int> dp(100005,-1);
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        v[i]=x;
        dp[x] = 0;
    }
    for(int i=1;i<=k;i++)
    {
        if(dp[i]==-1)
        {
           int ans=0;
           for(int j=0;j<n;j++)
           {
               if(i>v[j])
               {
                  ans|=dp[i-v[j]];
               }
           }
           dp[i] = !ans;
        }
    }
    if(!dp[k])
    cout<<"First";
    else
    cout<<"Second";
}


Measured memory_bytes: 3772
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	int count[3] = { 0, 0, 0 };
	for (auto i = 0; i < S.length(); ++i)
	{
		if (S[i] == 'a')
		{
			++count[0];
		}
		else if (S[i] == 'b')
		{
			++count[1];
		}
		else
		{
			++count[2];
		}
	}

	sort(count, count + 3);

	if (count[2] - count[0] <= 1)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
#define rep(i,m,n) for(ll i=m;i<n;i++)

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

 ll n,k;
  cin >> n >> k;
  vll a(n),f(n);
 rep(i,0,n) cin >> a[i];
 rep(i,0,n) cin >> f[i];
  sort(a.begin(),a.end());
  sort(f.begin(),f.end(),greater<ll>());
  
 
 vll total(n);
  rep(i,0,n) total[i]=a[i]*f[i];
    ll l=-1,r=*max_element(total.begin(), total.end());
  
  while(r-l>1){
   ll x=(l+r)/2;
   ll c=0;
   rep(i,0,n) c+=(max(0ll,total[i]-x)+f[i]-1)/f[i];
    if(c<=k) r=x;
    else l=x;
  }
  cout << r << endl; 
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var NL = ReadInts();
            var N = NL[0];
            var L = NL[1];

            var list = new List<int>();
            for (int i = 1; i <= N; i++)
            {
                list.Add(L + i - 1);
            }

            var ans = 100000;
            int res = 100000;
            var x = 1;
            foreach (var item in list)
            {
                var tmp = Math.Abs(item - 0);
                if (ans > tmp)
                {
                    ans = tmp;
                    res = tmp;
                    if(item - 0 < 0)
                    {
                        x = -1;
                    }
                    else
                    {
                        x = 1;
                    }
                }
            }
            WriteLine(list.Sum() - res * x);
            
        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数

        public static long Gcd(long a, long b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
        static long fibonacci(int n)
        {
            switch (n)
            {
                case 0:
                case 1:
                    return n;
                default:
                    return fibonacci(n - 2) + fibonacci(n - 1);
            }
        }
    }
}


Measured memory_bytes: 13268
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

from collections import deque



def calc(seq):
    score = 0
    for a, b, c, d in req:
        if seq[b - 1] - seq[a - 1] == c:
            score += d

    return score


n, m, q = list(map(int, input().split()))
req = [list(map(int, input().split())) for _ in range(q)]

ans = 0

que = deque()


for i in range(1, m + 1):
    que.append([i])

while que:
    seq = que.popleft()

    if len(seq) == n:
        
        score = calc(seq)
        ans = max(ans, score)
    else:
        
        for i in range(seq[-1], m + 1):
            seq_next = seq + [i]
            que.append(seq_next)

print(ans)

Measured memory_bytes: 103116
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int count = 0;
    string s;
    cin >> s;
    for(int i = 0;i < s.size() - 1;i++)
    {
        if(s[i] == s[i + 1])
        {
            if(s[i] == '1'){s[i + 1] = '0';}
            else{s[i + 1] = '1';}
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

int main()
{
    long long a, b;
    cin >> a >> b;
    if((a+b)%2 == 0){
        cout << (a+b)/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import heapq

class job:
    def set_data(self):
        self.time=1
        self.poi=0
    def __lt__(self, other):
        return self.time<other.time


n,m=map(int,input().split())

j=[]
for _ in range(n):
    a,b=map(int,input().split())
    p=job()
    p.time=a
    p.poi=-b
    j.append(p)
j.sort()
"""
for i in range(n):
    print(j[i].time,j[i].poi)
"""
h=[]
heapq.heapify(h)
pos=0
ans=0
for date in range(m+1):
    while pos<=n-1:
        if pos<=n-1 and j[pos].time==date:
            heapq.heappush(h,j[pos].poi)
            pos+=1
        else:
            break
    if(len(h)>=1):
        ans+=heapq.heappop(h)
   # print(date,ans)
print(ans*(-1))
    



Measured memory_bytes: 27904
N, K = map(int, input().split())
V = list(map(int, input().split()))

V_minus = len([v for v in V if v < 0])
K = min(K, N + V_minus)

vc_left = [0] * (K + 1)
minus_num = [0]
for i in range(N):
    if V[i] < 0:
        minus_num.append(-V[i])
        minus_num.sort(reverse=True)
    if i + 1 <= K:
        vc_left[i + 1] = max(vc_left[i + 1], sum(V[:i + 1]), vc_left[i])
    for j in range(1, len(minus_num)):
        if i+1+j <= K:
            vc_left[i+1+j] = max(vc_left[i + 1 + j], sum(V[:i + 1])+sum(minus_num[:j]), vc_left[i+j])

V.reverse()
vc_right = [0] * (K+1)
minus_num = [0]
for i in range(N):
    if V[i] < 0:
        minus_num.append(-V[i])
        minus_num.sort(reverse=True)
    if i + 1 <= K:
        vc_right[i + 1] = max(vc_right[i + 1], sum(V[:i + 1]), vc_right[i])
    for j in range(1, len(minus_num)):
        if i+1+j <= K:
            vc_right[i+1+j] = max(vc_right[i + 1 + j], sum(V[:i + 1])+sum(minus_num[:j]), vc_right[i+j])

ans_cand = [0] * (K+1)
for i in range(K+1):
    ans_cand[i] = vc_left[i] + vc_right[K-i]
ans_max = sum([v for v in V if v > 0])
print(min(max(ans_cand), ans_max))


Measured memory_bytes: 40560
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>
// #include "atcoder/all"

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "Yes";
const string NO = "No";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<std::vector<long long>> d){
    int len = 0;
    for(int i = 0; i < n; ++i){
        if(d[i][0] == d[i][1])
            ++len;
        else
            len = 0;
        if(len >= 3){
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
    return;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::vector<long long>> D(N, std::vector<long long>(2));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < 2 ; j++){
            scanf("%lld",&D[i][j]);
        }
    }
    solve(N, std::move(D));
    return 0;
}


Measured memory_bytes: 3692
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main() {
    int n,m;
    cin>>n>>m;
    if(n==m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
M = min([A,B,C,D,E])
def ceil(n):
    if n > int(n):
        return(int(n)+1)
    else:
        return(int(n))


ans = ceil(N/M) + 4
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)

int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	string s;
	cin >> s;

	int A = (int)(s[0] - '0');
	int B = (int)(s[1] - '0');
	int C = (int)(s[2] - '0');
	int D = (int)(s[3] - '0');

	for (size_t op1 = 0; op1 < 2; op1++)
	{
		for (size_t op2 = 0; op2 < 2; op2++)
		{
			for (size_t op3 = 0; op3 < 2; op3++)
			{
				int res = A;
				res = (op1 == 0) ? (res + B) : (res - B);
				res = (op2 == 0) ? (res + C) : (res - C);
				res = (op3 == 0) ? (res + D) : (res - D);

				if (res == 7)
				{
					cout << A << ((op1 == 0) ? "+" : "-") << B << ((op2 == 0) ? "+" : "-") << C << ((op3 == 0) ? "+" : "-") << D << "=7" << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 15
#define MAX_VAL 100005
#define INF 50000000
char s[MAX],t[MAX];
int A[MAX][MAX],C[MAX];
int skill[MAX];
int result,cost;
void backtrack(int book,int M,int X)
{
    int i;
    if(book<0)
    {
        for(i=0;i<M;i++)
        {
            if(skill[i]<X) return;
        }
        result=min(result,cost);
        return;
    }
    backtrack(book-1,M,X);
    cost=cost+C[book];
    for(i=0;i<M;i++)
    {
        skill[i]=skill[i]+A[book][i];
    }
    backtrack(book-1,M,X);
    cost=cost-C[book];
    for(i=0;i<M;i++)
    {
        skill[i]=skill[i]-A[book][i];
    }
}
int main()
{
    int N,M,X;
    int i,j,k;
    scanf("%d %d %d",&N,&M,&X);
    for(i=0;i<N;i++)
    {
        scanf("%d",&C[i]);
        for(j=0;j<M;j++)
        {
            scanf("%d",&A[i][j]);
        }
    }
    result=INF;
    backtrack(N-1,M,X);
    if(result>=INF) result=-1;
    printf("%d",result);
    return 0;
}


Measured memory_bytes: 3788
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>
#include<bitset>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++) //0から
#define REP(i,n) for(int j=i;j<n;j++) //iから

typedef long long ll;



//英字ならture、数字ならfalse
bool isalpha(char s){
    if(('A'<=s&&s<='Z')||('a'<=s&&s<='z')){
        return 1;
    }else{
        return 0;
    }
}
//全ての文字が英字ならture、数字ならfalse
bool Isalpha(string s){
    ll n;
    bool tmp = true;
    rep(i,n){
        if(isalpha(s[i])){
            tmp = false;
        }
    }
    return tmp;
}




using Graph = vector<vector<ll>>;



//cout<<fixed<<setprecision(10);

ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}



int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll q;
    cin>>q;
    vector<ll> b(q),c(q);
    rep(i,q){
        cin>>b[i]>>c[i];
    }
    ll m=100010;
    ll cnt[100010];
    rep(i,m){
        cnt[i]=0;
    }
    rep(i,n){
        cnt[a[i]]++;
    }
    ll ans=0;
    rep(i,m){
        ans+=i*cnt[i];
    }
    rep(i,q){
        ans+=(c[i]-b[i])*cnt[b[i]];
        cnt[c[i]]+=cnt[b[i]];
        cnt[b[i]]=0;
        cout<<ans<<endl;
    }



    return 0;
}



Measured memory_bytes: 6428
import sys
import copy
import math
import itertools
import numpy as np

A,B,C = [int(c) for c in input().split()]
a = []
cnt=0
while True:
    cnt+=A
    a.append(cnt%B)
    if C == cnt%B:
        print("YES")
        sys.exit(0)
    elif a.count(cnt%B) >1:
        print("NO")
        sys.exit(0)

Measured memory_bytes: 27184
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;

int main() {
    

    
    string s;
    cin >> s;
    vector<vector<long long>> dp(s.size(), vector<long long>(13));
    long long mod = 1e9 + 7;
    
    int cp = 10;
    for (int i = s.size() - 1; i >= 0; --i)
    {
        if (s[i] != '?')
        {
            int num = s[i] - '0';
            if (i == s.size() - 1)
            {
                dp[i][num] = 1;
                continue;
            }
            for (int j = 0; j < 13; ++j)
            {
                int next = (j + num * cp) % 13;
                dp[i][next] += dp[i + 1][j];
                dp[i][next] %= mod;
            }
        }
        else
        {
            if (i == s.size() - 1)
            {
                for (int j = 0; j < 10; ++j)
                {
                    dp[i][j] = 1;
                }
                continue;
            }
            for (int j = 0; j < 10; ++j)
            {
                for (int k = 0; k < 13; ++k)
                {
                    int next = (k + j * cp) % 13;
                    dp[i][next] += dp[i + 1][k];
                    dp[i][next] %= mod;
                }
            }
        }
        cp *= 10;
        cp %= 13;
    }
    
    cout << dp[0][5] << endl;
    
    return 0;
}

Measured memory_bytes: 13696
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int N,M;
    cin>>N>>M;
    int ans=0;
    int A=N*(N-1)/(2*1);
    int B=M*(M-1)/(2*1);

    ans=A+B;

    cout<<ans<<endl;



}




Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int n,k;
	cin>>n>>k;
	vi in(n);
	rep(i,n)cin>>in[i];
	rep(_,k){
		bool h=true;
		rep(i,n)if(in[i]-n)h=false;
		if(h)break;

		vi dp(n+1);
		rep(i,n){
			dp[max(0ll,i-in[i])]++;
			dp[min(n,i+in[i]+1)]--;
		}
		rep(i,n)dp[i+1]+=dp[i];
		rep(i,n)in[i]=dp[i];
	}
	show1d(in);
}


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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

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

double ki(double a){
    int su = 0;
    for(int i = 1; i <= a; i++) su += i;
    return su / a;
}

int main(){
    vector<int>a(3);
    REP(i, 3) cin >> a.at(i);
    sort(all(a));
    int ans = abs(a.at(0) - a.at(1)) + abs(a.at(1) - a.at(2));
    print(ans);
}


Measured memory_bytes: 256
import math

a, b, c = map(int, input().split())

h = b*math.sin(c/180*math.pi)
s = a*h/2

e = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(c/180*math.pi))

print('%.5f'%s)
print('%.5f'%(a+b+e))
print('%.5f'%h)


Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 , INF = 1e9;
int dp[maxn],n,m;
vector<int> grafo[maxn];

int solve( int v )
{

	if( dp[v]  !=  -INF )
		return dp[v];

	for( int x = 0 ; x < grafo[v].size() ; x++ )
		dp[v] = max( solve( grafo[v][x] ) , dp[v] );

	if( dp[v]  ==  -INF )
		dp[v] = -1;

	dp[v]++;


	return dp[v];

}



int main(){


	for(int x = 0 ; x < maxn ; x++ )
		dp[x] = -INF;


	scanf("%d%d",&n,&m);
	for(int x=0;x<m;x++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		grafo[a].push_back(b);
	}


	int resp = -INF;
	for( int x = 1 ; x <= n ; x++ )
	{
		solve( x );
		resp = max( resp , dp[x] );

	}


	printf("\n%d\n",resp);

}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long N, M;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int c[5][5] = {0};
	for(int i=1; i<=3; i++){
		for(int j=1; j<=3; j++){
			cin >> c[i][j];
		}
	}
	int ans = 0;
	int u, v, w, x, y, z;
	u = c[1][2] - c[1][1];
	v = c[2][2] - c[2][1];
	w = c[3][2] - c[3][1];
	x = c[1][3] - c[1][1];
	y = c[2][3] - c[2][1];
	z = c[3][3] - c[3][1];

	if(u == v && v == w && x == y && y == z){
		ans = 1;
	}
	if(ans == 1){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    int ansCount = 0;
    Cini(N);
    vector<int> v(N);
    rep(i,N) cin >> v[i];
    rep(i,N-2)if(v[i+1] == v[i]+v[i+1]+v[i+2]-min(v[i],min(v[i+1],v[i+2]))-max(v[i],max(v[i+1],v[i+2])))ansCount++;
    cout << ansCount << nn;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const int siz = 2 * 1e3 + 7;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	clock_t begin = clock();
	int n, x, y;
	cin >> n >> x >> y;
	vector < int>v(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			int dis = min({abs(i - j), abs(x - i) + abs(y - j) + 1, abs(y - i) + abs(x - j) + 1});
			//	cout << i << " " << j << " " << dis << endl;
			v[dis]++;
		}
	}
	for (int i = 1; i < n; i++) {
		cout << v[i] / 2 << endl;
	}
	cout << endl;
	clock_t end = clock();
	cerr << "Time run: " << (float)(end - begin) / CLOCKS_PER_SEC << " s" << endl;
}

Measured memory_bytes: 3844
#include<stdio.h>

int main(void)
{
  int i,j,N;
  int count=0;

  scanf("%d",&N);
    for(i=1;i<=N;i+=2){
      int res = 0;
      for(j=1;j<=i;j++){
        if(i%j==0){res++;}
        }
      if(res==8){count++;}
    }

  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
function inI()
    a = Ref{Int64}(0)
    ccall(:scanf, Int32, (Ptr{UInt8}, Ref{Int64},), "%lld", a)
    Int(a[])
end

let
    n = inI()
    x = Int[inI() for _ in 1:n]
    l = inI()
    q = inI()
    const lg = 20
    F = Array(Int, lg, n)
    B = Array(Int, lg, n)
    for i = 1:n
        F[1,i] = searchsortedlast(x, x[i]+l)
        B[1,i] = searchsortedfirst(x, x[i]-l)
    end

    for fe = 2:lg
        for i = 1:n
            F[fe,i] = F[fe-1,F[fe-1,i]]
            B[fe,i] = B[fe-1,B[fe-1,i]]
        end
    end

    for i = 1:q
        a = inI()
        b = inI()

        ans = 1
        if a < b
            for fe = lg:-1:1
                if F[fe,a] < b
                    a = F[fe,a]
                    ans += 2^(fe-1)
                end
            end
        else
            for fe = lg:-1:1
                if B[fe,a] > b
                    a = B[fe,a]
                    ans += 2^(fe-1)
                end
            end
        end
        println(ans)
    end
end


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

int main() {
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  int ans=a[0],cnt=0;
  rep(i,n){
    cnt++;
    if(ans==1){
      cout<<cnt<<endl;
      return 0;
    }
    ans=a[ans];
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

typedef long long LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = N; i >= 0; i--)

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N)
    cin >> a[i];

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if ((i+1) % 2 != 0 && a[i] % 2 != 0) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3604
N, M = io.read("*n", "*n", "*l")
L_max = 0
R_min = 10^5
for i = 1, M do
    L, R = io.read("*n", "*n", "*l")
    L_max = math.max(L, L_max)
    R_min = math.min(R, R_min)
end
print(math.max(0, R_min-L_max+1))

Measured memory_bytes: 760
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>
#include <math.h>
 
#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  For(i,0,n)
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)
 
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;
 
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };

int main() {
    static ll d,g; cin >> d >>g;
    vi(p,d);
    vi(c,d);
    rep(i,d)
        cin >> p[i] >> c[i];

    vi(cp, d);
    copy(c.begin(), c.end(), back_inserter(cp) );
    SORT(cp);
    if(g <= cp[0]){
        cout << g / 100 << endl;
    }

    ll saisyou = 100000000;
    rep(i, 1 << d ){
        ll result = 0;
        ll mondaisuu = 0;
        int tmp = i  + (1 << d);
        int index = 0;
        stack<int> st;
        while( tmp != 1){
            if(tmp % 2 == 1){
                result += c[index] + p[index] * 100 * (index + 1);
                mondaisuu += p[index];
            }
            st.push(tmp % 2);
            index++;
            tmp /= 2;
        }

        if ( g > result){
            index = d - 1;
            while(!st.empty()){
                int num = st.top();
                st.pop();
                if (num == 0){
                    if (g > result){
                        mondaisuu += min((int)ceil((g - result) / ((index+1) * 100)), p[index]);
                        result += min( (int)ceil((g - result) / ((index  + 1) * 100)), p[index]) * ((index  + 1) * 100);
                    }
                }
                if (g <= result){
                    break;
                }
                index--;
            }
        }
        saisyou = min(saisyou,mondaisuu);
    }
    cout <<  saisyou << endl;


    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC125_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] vs = Console.ReadLine().Split(' ');
            string[] cs = Console.ReadLine().Split(' ');

            int[] v = new int[n];
            int[] c = new int[n];
            int[] diff = new int[n];

            for (int i = 0; i < n; ++i)
            {
                v[i] = int.Parse(vs[i]);
                c[i] = int.Parse(cs[i]);

                diff[i] = v[i] - c[i];
            }

            Array.Sort(diff);

            int value = 0;

            for (int i = n - 1; i >= 0; --i)
            {
                if (diff[i] > 0)
                {
                    value += diff[i];
                }
                else
                {
                    break;
                }
            }

            Console.WriteLine("{0}", value);
        }
    }
}


Measured memory_bytes: 13268
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn.{readInt, readLine}

object Main extends App {

  val n = readInt
  val nodes = Array.fill[Node](n)(new Node)
  for (_ <- 0 until n) {
    val arr = readLine.split(" ").map(_.toInt)
    val id = arr(0)
    nodes(id).id = id
    for (i <- 2 until 2 + arr(1)) {
      val childId = arr(i)
      nodes(id).children += childId
      nodes(childId).parent = id
    }
  }
  val root = nodes.filter(_.parent == -1)(0)
  setDepth(nodes, root.id, 0)
  println(nodes.mkString("\n"))

  def setDepth(nodes: Array[Node], id: Int, depth: Int): Unit = {
    nodes(id).depth = depth
    nodes(id).children.foreach( e => {
      setDepth(nodes, nodes(e).id, depth + 1)
    })
  }

  class Node {
    var id = -1
    var parent = -1
    var children = new ArrayBuffer[Int]()
    var depth = 0
    override def toString: String = {
      val nodeType = {
        if (parent == -1) "root"
        else if (children.length == 0) "leaf"
        else "internal node"
      }
      s"node ${id}: parent = ${parent}, depth = ${depth}, ${nodeType}, [${children.mkString(", ")}]"
    }
  }
}



Measured memory_bytes: 288932
#include <stdio.h>
long long n, a, f, g, x;
long long m[300][300];
int main() {
	scanf("%lld", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%lld", m[i] + j);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			g = 1;
			for (int k = 0; k < n; k++) {
				if (m[i][j] > m[i][k] + m[k][j])f = 1;
				if (i != k && j != k && m[i][j] == m[i][k] + m[k][j])g = 0;
			}
			x += m[i][j] * g;
		}
	}
	x /= 2;
	if (f)x = -1;
	printf("%lld\n", x);
}

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

void solve() {
	int a[3]; scanf("%d %d %d", a, a+1, a+2);
	sort(a, a+3);
	puts((a[0] == 5 && a[1] == 5 && a[2] == 7)?"YES":"NO");
}

int main() {
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

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

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;


int main(){
    int N;cin >> N;
    string s;cin >> s;
    vector<vector<LL>> dp(N,vector<LL> (N,0));
    dp[0][0]=1;
    for (int i = 1; i < N; i++) {
        vector<LL> st(i+1,0);
        for (int j = 0; j < i; j++) {
            st[j+1]=(st[j]+dp[i-1][j])%mod;
        }
        if(s[i-1]=='<'){
            for (int j = 0; j <= i; j++) {
                dp[i][j]=st[j]%mod;
            }
        }
        else{
            for (int j = 0; j <= i; j++) {
                dp[i][j]=(st[i]+mod-st[j])%mod;
            }
        }
    }
    LL ans=0;
    for (int i = 0; i < N; i++) {
        ans=(ans+dp[N-1][i])%mod;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 70656
#include <iostream>
#include <cmath>
using namespace std;
bool ok(int a,int b,int c){
  if(c%a == 0 || c%b == 0)return true;
  for(int i = max(a,b); c>i;i+=max(a,b)){
    if((c-i)% min(a,b) == 0)return true;
  }
  return false;
}
int main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  int zants=1,zantw=1000000000;
  for(int i = 1; f/100 >= i; i++){
    if(!ok(a,b,i))continue;
    //cout << i << endl;
    //cとdで作れるe*iより下の数値
    for(int j = e*i; 0 < j; j--){
      if(ok(c,d,j)){
        if(i*100+j > f)continue;
        if((double)zantw/zants > (double)i*100/j){
          zantw = i*100;
          zants = j;
        }
        break;
      }
    }
  }
  if(zants == 1 && zantw == 1000000000) cout << a*100 << " " << 0 << endl;
  else cout << zantw+zants << " " << zants << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	
	char str[N];
	scanf("%s", str);

	if(0 != N % 2){
		printf("No\n");
		return 0;
	}

	for(int i=0; i < N/2; i++){
		if(str[i] != str[N/2 + i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
N = gets.to_i
hs = gets.chomp.split(' ').map(&:to_i)
array = []
(N-2).times do |i|
  if hs[i+1]<= hs[i] && hs[i+1] <hs[i+2] 
    array.push(i+1)
  end
end
array.push(N-1)
stt = 0
result = 0
max = 0
hole = 0
array.each do |i|
  max = 0
  hs[stt..i].each do |item|
    if item>max
    max = item
    end
  end
  if i == N-1
    result += max
  else
	result=result+max-hs[i]
  end
  stt = i+1
end
puts result

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll n,m;
    cin>>n>>m;
    if (n==1 && m==1)
        cout<<"1\n";
    else if (n==1)
        cout<<m-2<<endl;
    else if (m==1)
        cout<<n-2<<endl;
    else
        cout<<(n-2)*(m-2)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }
  if(a>b){
    printf("a > b\n");
  }
  if(a==b){
    printf("a == b\n");
  }
  return 0;
}


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

int main(){
    using namespace std;
    constexpr unsigned long MOD{1000000007};
    unsigned long N;
    cin >> N;
    const auto& modpow = [](unsigned long a, unsigned long n, unsigned long b = 1) -> unsigned long {
        unsigned long r{b % MOD};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    cout << (modpow(10, N) + modpow(8, N) + 2 * modpow(9, N, MOD - 1)) % MOD << endl;
    return 0;
}

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

#define all(x) x.begin(), x.end()
using namespace std;

int main() {
    string s;
    cin >> s;
    map<char,char> f = {{'1', '9'}, {'9', '1'}};
    for (int i = 0; i < s.size(); i++) {
        cout << f[s[i]];
    }
    cout << endl;
}

Measured memory_bytes: 256