akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.Map.Strict            as M
import           Data.Char


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> [Int] -> [Int] -> Int
solve n ps qs =
    let
        intListToStr xs = intercalate "" $ show <$> xs
        nList = sort $ intListToStr <$> permutations [1..n]
        listAndOrder = M.fromList $ zip nList [1..]
        pstr = intListToStr ps
        qstr = intListToStr qs
    in
    abs $ (listAndOrder M.! pstr ) - (listAndOrder M.! qstr)


main = do
    n <- readInt
    ps <- readInts
    qs <- readInts
    print $ solve n ps qs





Measured memory_bytes: 41212
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <queue>
using namespace std;

int main(){
  int N, ans = 0 ;
  cin >> N ;
  for(int i=0;i<N;i++){
    cout << "ACL" ;
  }
  cout << endl ;
  return 0 ;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll c[10];
int main() {
	string s;
	cin>>s;
	if(s.size()==2)cout<<s<<endl;
	else{
		cout<<s[2]<<s[1]<<s[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pii Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define int ll
signed main(void) {
	string s;

	cin >> s;
	int len = s.length();
	REP(i, len) {
		rep(j, i, len + 1) {
			string buf = s;

			buf.erase(buf.begin() + i, buf.begin() + j);

			if (buf == "keyence") {
				cout << "YES" << endl;
				return 0;
			}
		}
	}


	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100
#define white 0
#define gray 1
#define black 2

int time,n,g[MAX][MAX] = {0};
int d[MAX],f[MAX],color[MAX] = {white};

void dfs(void);
void visit(int);

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      g[u-1][v-1] = 1;
    }
  }

  dfs();
  return 0;
}

void dfs(){
  int u;

  time = 0;

  for(u=0;u<n;u++)
    if(color[u] == white)visit(u);

  for(u=0;u<n;u++)
    printf("%d %d %d\n",u+1,d[u],f[u]);
}

void visit(int u){
  int v;

  color[u] = gray;
  d[u] = ++time;

  for(v=0;v<n;v++){
    if(g[u][v] == 0)continue;
    if(color[v] ==white)visit(v);
  }

  color[u] = black;
  f[u] = ++time;
}

Measured memory_bytes: 636
n=int(input())
x = list(map(int,input().split()))
x.sort()
a = sum(x)
b = []
for i in range(0,n):
    b.append(x[i]**2)
c = sum(b)
s = n -2 * a
for j in range(2,101):
    t = n * (j**2) -2 * j * a
    if t < s:
        s = t
print(s+c)

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

namespace JagArrayTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var dataSetCount = Convert.ToInt32(Console.ReadLine());

            List<List<double>> dataSetList = new List<List<double>>();

            for(int count = 0; count< dataSetCount; count++)
            {
                var dataSet = Console.ReadLine().Split(' ').ToList().ConvertAll(double.Parse);
                dataSetList.Add(new List<double>() { dataSet[0], dataSet[1], dataSet[2] });
            }

            foreach(var elm in dataSetList)
            {
                if(isRightTriangle(elm))
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }

        static bool isRightTriangle(List<double> lengthList)
        {
            var sortedList = lengthList.OrderByDescending(d => d).ToList();

            if(Math.Pow(sortedList[0], 2) == (Math.Pow(sortedList[1], 2) + (Math.Pow(sortedList[2], 2))))
            {
                return true;
            }

            return false;
        }
    }
}



Measured memory_bytes: 14248
n=int(input())
a=[None]+[int(i) for i in input().split()]

check=[0]*(n+1)
ans=[]

for i in range(n,0,-1):
    if sum(check[2*i::i])%2==a[i]:
        continue
    else:
        check[i]=1
        ans.append(i)
print(len(ans))
print(*ans)

Measured memory_bytes: 82012
#include<cstdio>
#include<algorithm>
using namespace std;
int dp[101][10001];
int main(void){
	int n;
	int box[100];
	int i,j;
	int MAX,sum;
	scanf("%d",&n);
	sum=0;
	for(i=0;i<n;i++){
		scanf("%d",&box[i]);
		sum+=box[i];
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=10000;j++){
			dp[i][j]=0;
		}
	}
	dp[0][0]=1;
	for(i=0;i<n;i++){
		for(j=0;j<=sum;j++){
			if(dp[i][j]==1){
				dp[i+1][j]=1;
				if(j+box[i]<=sum){
					dp[i+1][j+box[i]]=1;
				}
			}
		}
	}
	// for(i=0;i<=n;i++){
		// for(j=0;j<=sum;j++){
			// printf("%d ",dp[i][j]);
		// }
		// printf("\n");
	// }
	MAX=0;
	for(i=0;i<=sum;i++){
		if(dp[n][i]==1){
			if(i%10!=0){
				MAX=max(MAX,i);
			}
		}
	}
	printf("%d\n",MAX);
	return 0;
}

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

int main() 
{
	int n, flag = 0;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<n; i++)
    {
        if(a[i]%2 == 0 && (a[i]%3 != 0 && a[i]%5 != 0)) flag++;
    }
    if(flag) cout<<"DENIED";
    else cout<<"APPROVED";
	return 0;
}

Measured memory_bytes: 256
class Main{
    public static void main(String[] a){
    	for(int i = 1; i <= 9; i++) {
    		for(int j = 1; j <= 9; j++) {
    			int k = i * j;
    			System.out.println(i + "x" + j + "=" + i * j);
    		}
    	}
    }
}

Measured memory_bytes: 24052
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

import copy

N,M,L = II()
A,B,C = Line(M,3)
Q = I()
s,t = Line(Q,2)

E = [[float('inf')]*N for _ in range(N)]
for i in range(N):
    E[i][i] = 0
for i in range(M):
    E[A[i]-1][B[i]-1] = C[i]
    E[B[i]-1][A[i]-1] = C[i]

for k in range(N):
    for i in range(N):
        for j in range(N):
            if E[i][j] > E[i][k]+E[k][j]:
                E[i][j] = E[i][k]+E[k][j]

E2 = [[float('inf')]*N for _ in range(N)]

for i in range(N):
    E2[i][i] = 0
for i in range(N):
    for j in range(N):
        if E[i][j]<=L:
            E2[i][j] = 1
            E2[j][i] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            if E2[i][j] > E2[i][k]+E2[k][j]:
                E2[i][j] = E2[i][k]+E2[k][j]

for i in range(Q):
    if E2[s[i]-1][t[i]-1] == float('inf'):
        print(-1)
    else:
        print(E2[s[i]-1][t[i]-1]-1)

Measured memory_bytes: 93788
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n, sum = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		sum += a[i];
	}
	int ans = sum, p = 0;
	for (int i = 0; i < n - 1; ++i)
	{
		p += a[i];
		sum -= a[i];
		ans = min(ans, abs(p - sum));
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

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

int main(){
	
	int N,M,X,Y;
	cin>>N>>M>>X>>Y;

	vector<int> arrn;
	vector<int> arrm;
	
	arrn.resize(N);
	arrm.resize(M);
	
	REP(i,N)cin>>arrn[i];
	REP(i,M)cin>>arrm[i];
	
	sort(arrn.begin(),arrn.end());
	sort(arrm.begin(),arrm.end());
	
	for(int i = X+1;i <= Y ; i++){
		if(arrn[N-1] < i && arrm[0] >= i ){
			cout<<"No War"<<endl;
	return 0;
		}
	}
	cout<<"War"<<endl;
	return 0;

	// cout<<arrn[N-1]<<","<<arrm[0]<<endl;	
	// if( arrn[N-1] <= arrm[0]){
	// 	if((arrn[N-1] < Y) && (arrn[N-1] > X)){
	// 		if((arrm[0]) > X && (arrm[0] < Y)){
	// 			cout<<"No War"<<endl;
	// 			return 0;
	// 		}
	// 	}
	// }
	// cout<<"War"<<endl;
	// return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, m, k;
	cin >> n >> m >> k;
	if (m % 2 == 0 && k % n == 0 && m / 2 == k / n) Yes();
	else {
		for (ll i = 0; i <= m; i++) {
			if (m == 2 * i) continue;
			if (abs(k - n * i) % abs(m - 2 * i) == 0 && 0 <= (k - n * i) / (m - 2 * i) && (k - n * i) / (m - 2 * i) <= n) {
				Yes();
				return 0;
			}
		}
		No();
	}
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s; cin >> s;
    int n = s.size();
    vl dp(n+1,0);
    dp[0]=1;
    string w[4] = {"dream","dreamer","erase","eraser"};
    rep(i,n+1){
        if(dp[i] == 0)continue;
        rep(j,4){
            int m = w[j].size();
            if(s.substr(i,m) == w[j]) dp[i+m] = 1;
        }
    }
    if(dp[n]==1)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

void solve(long long N, std::vector<long long> a){
    vector<pair<LL, LL>> ais(N);
    rep(i, N){
        ais[i] = make_pair(a[i], i);
    }
    sort(all(ais));
    set<LL> left, right;
    left.insert(1);
    left.insert(-N);
    right.insert(-1);
    right.insert(N);

    LL ans = 0;
    for(auto ai : ais){
        LL i=ai.second, a=ai.first;
        LL l = -(*left.upper_bound(-i));
        LL r = *right.upper_bound(i);
        left.insert(-i);
        right.insert(i);
        ans += (i-l)*(r-i)*a;
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 23680
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <algorithm>
#include <tuple>
#include <numeric>

int main()
{
	int X, Y, Z, K;
	std::vector<long> A, B, C;
	std::priority_queue<long> R, S;

	std::cin >> X >> Y >> Z >> K;
	for (int i = 0; i < X; ++i) {
		long a;
		std::cin >> a;
		A.push_back(a);
	}
	for (int i = 0; i < Y; ++i) {
		long b;
		std::cin >> b;
		B.push_back(b);
	}
	for (int i = 0; i < Z; ++i) {
		long c;
		std::cin >> c;
		C.push_back(c);
	}

	for (auto a : A) {
		for (auto b : B) {
			S.push(a + b);
		}
	}

	for (int i = 0; i < K; ++i) {
		if (S.empty())
			break;
		auto s = S.top();
		S.pop();
		for (auto c : C) {
			R.push(s + c);
		}
	}

	for (int i = 0; i < K; ++i) {
		std::cout << R.top() << "\n";
		R.pop();
	}
}


Measured memory_bytes: 43256
#include<stdio.h>

#define NIL -1
#define N 100
static const int INF=(1<<21);
 
int n;
int A[N][N],key[N],pi[N];

void MST(void){

  int i,j,u,v,flag[N],minv;
  
  for(i=0;i<n;i++){
    key[i]=INF;
    pi[i]=NIL;
    flag[i]=0;
  }
  key[0]=0;

  for(i=0;i<n;i++){
    minv=INF;
    for(j=0;j<n;j++){
      if(!flag[j] && key[j]<minv){
	u=j;
	minv=key[j];  //the minimum cost
      }
    }

    if(u==NIL) break;
    flag[u]=1;

    for(v=0;v<n;v++){
      if(!flag[v] && key[v]>=A[u][v]){
	key[v]=A[u][v];
	pi[v]=u;  //saitan
      }
    }
  }
}

int main(){

  int i,j,e,sum=0;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      A[i][j]=(e==-1)?INF:e;
    }
  }

  MST();

  for(i=0;i<n;i++){
    sum+=key[i];
  }

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

Measured memory_bytes: 640
#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
using namespace std;
template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first1,
	BidirectionalIterator last1,
	BidirectionalIterator first2,
	BidirectionalIterator last2)
{
	if ((first1 == last1) || (first2 == last2)) {
		return false;
	}
	BidirectionalIterator m1 = last1;
	BidirectionalIterator m2 = last2; --m2;
	while (--m1 != first1 && !(*m1 < *m2)) {
	}
	bool result = (m1 == first1) && !(*first1 < *m2);
	if (!result) {
		// ?
		while (first2 != m2 && !(*m1 < *first2)) {
			++first2;
		}
		first1 = m1;
		std::iter_swap(first1, first2);
		++first1;
		++first2;
	}
	if ((first1 != last1) && (first2 != last2)) {
		// ?
		m1 = last1; m2 = first2;
		while ((m1 != first1) && (m2 != last2)) {
			std::iter_swap(--m1, m2);
			++m2;
		}
		// ?
		std::reverse(first1, m1);
		std::reverse(first1, last1);
		std::reverse(m2, last2);
		std::reverse(first2, last2);
	}
	return !result;
}

template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first,
	BidirectionalIterator middle,
	BidirectionalIterator last)
{
	return next_combination(first, middle, middle, last);
}



int main() {
	while (1) {
		long long int N, A, B, C, X; cin >> N >> A >> B >> C >> X;
		vector<int>Ys;
		if (!N)break;
		for (int i = 0; i <N; ++i) {
			int Y; cin >> Y;
			Ys.push_back(Y);
		}

		int now = 0;
		int nrand = X;
		bool ok = false;
		for (int i = 0; i <= 10000; ++i) {
			if (nrand == Ys[now]) {
				now++;
				if (now == N) {
					cout << i << endl;
					ok = true;
					break;
				}
			}
			nrand = (A*nrand + B) % C;
		}
		if (!ok) {
			cout << -1 << endl;
		}

	}

	return 0;
}

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

int main() {
    cout<< fixed << setprecision(20);
    long double a, b;
    int h, m;
    cin >> a >> b >> h >> m;
    int time = 60 * h + m;
    long double p = (long double)time / 2.0;
    long double q = (long double)time * 6;
    long double sa = abs(p - q);
    long double arg = sa - floor(sa / 360) * 360;
    arg = arg * M_PI / 180;
    long double ans = a * a + b * b + - 2 * a * b * cos(arg);
    cout << sqrt(ans) << endl;
}


Measured memory_bytes: 4168
// Problem : A - Coffee
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    string s;
    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();
        var t = input.ReadLine();

        var dic1 = new Dictionary<char, char>();
        var dic2 = new Dictionary<char, char>();

        for(int i=0; i<s.Length; i++) {
            var c1 = s[i];
            var c2 = t[i];

            if (!dic1.ContainsKey(c1)) {
                dic1.Add(c1, c2);
            } else {
                if (dic1[c1] != c2) return "No";
            }

            if (!dic2.ContainsKey(c2)) {
                dic2.Add(c2, c1);
            } else {
                if (dic2[c2] != c1) return "No";
            }
        }

        return "Yes";
    }
}

Measured memory_bytes: 14688
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int inf = 5e18;  
const int mod = 1e9+7;
const int mod1 = 998244353;
const int nax = 5005;
int a[nax],p[nax],n,k,vis[nax],tot;
vector<int> cycle;
void dfs(int node)
 {
  vis[node] = 1;
  tot += a[node];
  cycle.pb(a[node]);
  if(vis[p[node]] == 0)
     dfs(p[node]);
 }
  
void solve()
 {
   cin>>n>>k;
   loop(i,1,n+1)
    cin>>p[i];
   loop(i,1,n+1)
    cin>>a[i];
   int ans = -inf;
   loop(i,1,n+1)
    {
     cycle.clear();
     memset(vis,0,sizeof vis);
     tot = 0;
     dfs(p[i]);
     int len = cycle.size();
     int pref = 0;
     loop(j,0,len) 
       {
        pref += cycle[j];
        if (j + 1> k) 
          break;
        int now = pref;
        if (tot > 0) 
         {
          int times = (k - j - 1) / len;
          now += tot * times;
         }
        ans = max(ans,now);
       }  
    }
  cout<<ans;
 }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
     solve();
 // cerr<<END<<1.0*clock()/CLOCKS_PER_SEC;
  return 0;
} 

Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  cin >> n >> k;
  vector<int>a(n);
  for (int i=0;i<n;i++) {
    cin >> a.at(i); 
  }
  for (int i=0;i<n-k;i++) {
    if(a[i]<a[k+i]){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }  
}  

Measured memory_bytes: 4044
#include <iostream>

using namespace std;

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

int solve(int h) {
  if(h <= 1) return 1;
  else return 1 + 2 * solve(h / 2);
}

signed main() {
  int h;
  cin >> h;
  cout << solve(h) << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define ll long long
#define INF 1000000007
using P = pair<int, int>;
int main(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    ans+=pow(n/k,3);
    if(k%2==0){
        if((n/k)*k+k/2<=n)ans+=pow((n/k)+1,3);
        else ans+=pow(n/k,3);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
-- end of templete


main = do
    [n,h] <- getInts
    xs <- map (apply2 (,)) <$> replicateM n getInts
    let ((da, db):ds) = sortBy (\(a,b) (a',b') -> compare a' a <> compare b b') xs
    let (ts, nts) = partition ((>=db) . snd) ds
    --print (da,db)
    --print ts
    --print nts
    let sts = sortBy (flip compare) $ map snd ts
    --print sts
    rest <- newIORef h
    result <- newIORef 0
    forM_ sts $ \b -> do
      r <- readIORef rest
      when (r>0) $ do
          writeIORef rest (r-b)
          modifyIORef result (+1)
    --readIORef rest >>= print
    --readIORef result >>= print
    let tts = sortBy (flip compare) $ filter (>=da) $ map snd nts
    --print tts
    r' <- readIORef rest
    when (r'>0) $ do
        forM_ tts $ \b -> do
            r <- readIORef rest
            when (r>da) $ do
                writeIORef rest (r-b)
                modifyIORef result (+1)
    --readIORef rest >>= print
    --readIORef result >>= print
    r_ <- readIORef rest
    when (r_>0) $ do
        let it = r_ - db
        let ct = (it+da-1) `div` da
        modifyIORef result (+(1+ct))
    readIORef result >>= print
    return ()

Measured memory_bytes: 130812
#include <stdio.h>

char *A = "CODEFESTIVAL2016";

int main() {
    char str[17];
    int i, c = 0;
    gets(str);
    for (i = 0; i < 16; ++i) {
        if (str[i] != A[i]) ++c;
    }
    printf("%d\n", c);
    return 0;
}

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

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    card_count = int(input())

    card_numbers = [int(i) for i in input().split()]
    card_numbers.sort(reverse=True)

    alice_score = 0
    bob_score = 0

    alice_cards = card_numbers[::2]
    bob_cards = card_numbers[1::2]

    for i in range(len(alice_cards)):
        alice_score += alice_cards[i]

    for j in range(len(bob_cards)):
        bob_score += bob_cards[j]

    diff = alice_score - bob_score
    print(diff)


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);


            int[] ans = new int[n];
            int[] pen = new int[n];
            for(int i = 0; i < n; i++){ ans[i] = 0; pen[i] = 0;  }

            for(int i = 0; i < m; i++)
            {
                str = Console.ReadLine().Split(' ');
                int number = int.Parse(str[0]) - 1;
                if (ans[number] == 1) { }
                else if (str[1] == "AC") { ans[number] = 1; }
                else { pen[number]++; }
            }

            int ans1 = ans.Sum();
            int ans2 = 0;
            for(int i = 0; i < n; i++)
            {
                ans2 += ans[i] * pen[i];
            }

            Console.WriteLine("{0} {1}", ans1, ans2);


            //ここまで
        }
    }
}


Measured memory_bytes: 17868
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
 
int main() {
    ll n, A[100000], s=0, i;
    cin>>n;
    map<ll, ll> M;
    for(i=0; i<n; i++)
    {
    cin>>A[i];
    s+=A[i];
    M[A[i]]++;}
    ll q;
    cin>>q;
    while(q--)
    {
        ll b, c;
        cin>>b>>c;
        ll u = M[b];
        M[b]=0;
        M[c]+=u;
        s+=(c-b)*u;
        cout<<s<<"\n";
    }
    return 0;
}

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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
class segtree {
 private:
  int n;
  vector<T> data, lazy;

 public:
  segtree(int n_) {
    n = pow(2, ceil(log2(n_)));
    data.resize(n);
    lazy.resize(n);
    auto __x = data[0];
    repi(n) {
      data[i] = __vmin(__x);
      lazy[i] = 0;
    }
  }
};

int p[10][10];
int main() {
  int n, d;
  cin >> n >> d;
  repi(n) repj(d) cin >> p[i][j];
  int re = 0;
  repi(n - 1) repr(j, i + 1, n) {
    int x = 0;
    repk(d) x += pow(p[i][k] - p[j][k], 2);
    int sx = sqrt(x);
    if (sx * sx == x) re++;
  }
  cout << re << endl;
}


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

int main()
{
  int n, h, w, i;
  int count = 0;
  cin >> n >> h >> w;
  vector<int> a(n);
  vector<int> b(n);
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i);
    cin >> b.at(i);
  }
  for(i = 0; i < n; i++)
  {
    if(a.at(i) >= h && b.at(i) >= w)
    {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const int N = 2e5 + 5;

int n;
vi lst[N];

int p[N];

int pt[5];

int cnt[2];
void dfs(int now, int par, int col){
	if(p[now] == 0)cnt[col]++;
	FOR(i,lst[now].size()){
		int to = lst[now][i];
		if(to == par)continue;
		dfs(to, now, col ^ 1);
	}
}
void fill(int now, int par, int col, int tcol, int tval){
	if(tcol == col && p[now] == 0 && pt[tval] <= n){
		p[now] = pt[tval];
		pt[tval] += 3;
	}
	
	FOR(i,lst[now].size()){
		int to = lst[now][i];
		if(to == par)continue;
		fill(to, now, col^1, tcol, tval);
	}
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    REP(i,1,3)pt[i] = i;
    
    cin>>n;
    REP(i,2,n){
    	int a,b;
    	cin>>a>>b;
    	lst[a].pb(b);
    	lst[b].pb(a);
	}
	
	cnt[0] = cnt[1] = 0;
	dfs(1, -1, 0);
	
	if(cnt[0] > cnt[1]){
		fill(1, -1, 0, 0, 1);
	}else{
		fill(1, -1, 0, 1, 1);
	}
	
	cnt[0] = cnt[1] = 0;
	dfs(1, -1, 0);
	
	if(cnt[0] > cnt[1]){
		fill(1, -1, 0, 0, 2);
		fill(1, -1, 0, 0, 3);
		fill(1, -1, 0, 1, 3);
	}else{
		fill(1, -1, 0, 1, 2);
		fill(1, -1, 0, 1, 3);
		fill(1, -1, 0, 0, 3);
	}
	
	REP(i,1,n)cout << p[i] << " ";
	cout << endl;
	
    
    return 0;
}

Measured memory_bytes: 23168
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

int main()
{
	int N, L;
	cin >> N >> L;

	int sum = 0;
	vector<int> tastes(N);
	for (int i = 0; i < N; ++i)
	{
		tastes[i] = L + i;
		sum += tastes[i];
	}

	int min_sub = INT_MAX;
	int ans = 0;
	for (int i = 0; i < N; ++i)
	{
		int sum_sub = sum - tastes[i];
		int sub = abs(sum - sum_sub);
		if (sub < min_sub)
		{
			min_sub = sub;
			ans = sum_sub;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
s = input()
moji = ''
for N in range(n):
        if N == k - 1:
                if s[N] =='A':
                        moji += 'a'
                if s[N] =='B':
                        moji += 'b'
                if s[N] =='C':
                        moji += 'c'
        else:
                moji += s[N]

print(moji)

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

int main(){
	string a;
	int n, ans = 0;
	cin >> a >> n;
	REP(i,n){
		string str;
		cin >> str;
		str += str;
		if (str.find(a) != string::npos) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3136
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, inf = 10000000;
    scanf("%d", &n);
    vector<vector<int>> a(n, vector<int>(n));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0, k; j < n; j++)
        {
            scanf("%d", &k);
            a[i][j] = k == -1 ? inf : k;
        }
    }
    
    vector<int> cost(n, inf);
    vector<bool> vis(n, false);
    cost[0] = 0;
    for (int mi = inf, u = 0; ; mi = inf)
    {
        for (int i = 0; i < n; i++)
        {
            if (!vis[i])
            {
                if (cost[i] < mi)
                {
                    mi = cost[i];
                    u = i;
                }
            }
        }
        if (mi == inf)
        {
            break;
        }
        vis[u] = true;
        for (int i = 0; i < n; i++)
        {
            if (!vis[i] && a[u][i] != -1)
            {
                cost[i] = min(cost[i], a[u][i]);
            }
        }
    }
    printf("%d\n", accumulate(cost.begin(), cost.end(), 0));
}


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

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

#[allow(dead_code)]
impl Main {}

fn main() {
    let k = read::<usize>();
    let a = read::<usize>();
    let b = read::<usize>();
    let mut res = false;
    for v in 1..1001 {
        let prod = k * v;
        if prod >= a && prod <= b {
            res = true
        }
    }
    if res {
        println!("OK")
    } else {
        println!("NG")
    }
}


Measured memory_bytes: 2148
H, W = map(int, input().split())
S = [int(input()) for _ in range(H)]
S.sort()
res = None
for i in range(len(S) - W + 1):
    sdiff = S[i + W - 1] - S[i]
    if res is None:
        res = sdiff
    if res > sdiff:
        res = sdiff

print(res)


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

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);
        }


        static void SolveA(string[] args)
        {
            string sz = (Console.ReadLine());
            int n = int.Parse(sz);
            int[] a = new int[n];
            string[] szarr = Console.ReadLine().Split(' ');
            for(int i=0;i<szarr.Length;++i)
            {
                a[i] = int.Parse(szarr[i]);
            }

            bubbleSort(a);

        }
        private static void bubbleSort(int[] a)
        {
            bool flag = true;
            int num = 0;
            while( flag)
            {
                flag = false;
                for(int j = a.Length-1;j>=1;--j)
                {
                    if( a[j] < a[j-1])
                    {
                        int tmp = a[j];
                        a[j] = a[j - 1];
                        a[j - 1] = tmp;
                        flag = true;
                        num++;
                    }
                }
            }
            Writeline(
                a);
            Console.WriteLine(num);
        }
        private static void Writeline(int[] a)
        {
            string sz = "";
            for(int i=0;i<a.Length;++i)
            {
                sz += a[i];
                if( i < a.Length - 1)
                {
                    sz += " ";
                }
            }
            Console.WriteLine(sz);
        }
    }

}



Measured memory_bytes: 9180
#include<iostream> 

using namespace std; 
typedef long long ll; 
int main() 
{ 
		ios::sync_with_stdio(false); 
		cin.tie(NULL); 
		float r;
		cin>>r; 
		const float pi=3.1415; 
		cout<<(2*pi*r); 
		return 0; 
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int a, b, k;

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

	cin >> k >> a >> b;

	while (a <= b) {
		if (a % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
		a++;
	}

	cout << "NG" << endl;

	return 0;
}

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

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

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

  cout << vec.at(k-1) << endl;
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




int main()
{
	int N, M, Q;
	cin >> N >> M >> Q;

	vector<Vi> ans(N + 1, Vi(N + 1));
	for (int i = 0; i < M; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		++ans[0][R];
		--ans[L + 1][R];
		--ans[0][N];
		++ans[L + 1][N];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			ans[i][j + 1] += ans[i][j];
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			ans[i + 1][j] += ans[i][j];
		}
	}

	for (int i = 0; i < Q; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		cout << ans[L][R] << endl;
	}

	return 0;
}

Measured memory_bytes: 1920
#include<stdio.h>
int main()
{
    int a=0,b=0,j,i,k,l,m[30],n;
    scanf("%d",&n);
    for(i=1;i<=9;i++)
    {
        if(n%i==0)
        {
            a=n/i;
            if(a<=9)
            {
                printf("Yes\n");
                b++;
                break;
            }
        }
    }
    if(b==0)
        printf("No\n");
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<ll> v(N);
  for(int i=0; i<N; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  
  if (v[0] == 0) cout << 0 << endl;
  else {
    int check = 0;
    ll result = v[0];
    for(int i=1; i<N; i++) {
      if(result > 1000000000000000000/v[i]) {
        cout << -1 << endl;
        check = 1;
        break;
      }
      result *= v[i];
    }
    if (check == 0) cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 4104
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func max(a int, b int) int {
	if a >= b {
		return a
	}
	return b
}

func solve(A int, B int64, N int64) int64 {
	var x int64 = B - 1
	if x > N {
		x = N
	}
	return (int64(A) * x / B) - (int64(A) * (x / B))
}

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	hoge := sc.Text()
	i, e := strconv.Atoi(hoge)
	if e != nil {
		panic(e)
	}
	return i
}

func nextInt64() int64 {
	sc.Scan()
	hoge := sc.Text()
	i, e := strconv.ParseInt(hoge, 0, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	A, B, N := nextInt(), nextInt64(), nextInt64()
	fmt.Println(solve(A, B, N))
}


Measured memory_bytes: 1760
#include <iostream>
#include <vector>
#include <string>

int main() {
    int a, b;
    std::string op;
    std::vector<int> ans;
    while (std::cin >> a >> op >> b) {
        if (op == "?") break;
        if (op == "+") ans.push_back(a + b);
        if (op == "-") ans.push_back(a - b);
        if (op == "*") ans.push_back(a * b);
        if (op == "/") ans.push_back(a / b);
    }
    for (std::vector<int>::iterator itr=ans.begin(); itr!=ans.end(); ++itr)
        std::cout << *itr << std::endl;
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  string a, b, c;
  cin >> a >> b >> c;
  
  cout << (a[a.size()-1]==b[0] && b[b.size()-1]==c[0] ? "YES" : "NO") << endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int x,y,tmp,z;
  scanf("%d%d",&x,&y);
  if(x<y)
    {
      tmp=x;
      x=y;
      y=tmp;
    }
  z=x%y;
  while(z!=0)
    {
      x=y;
      y=z;
      z=x%y;
    }
  printf("%d\n",y);
  return 0;
}
      



Measured memory_bytes: 2140
#include <stdio.h>

typedef long long ll;

int main(void) {
  ll x;
  scanf("%lld", &x);
  ll count = 0, ret = 100;
  while(ret < x) {
    ret *= 1.01;
    count++;
  }
  printf("%d\n", count);
  return 0;
}
  

Measured memory_bytes: 2152
#include <stdio.h>
int main(void)
{
int n,S[100000],i,j,q,T[50000],t,C,L,R,M;
	scanf("%d",&n);
	for(i=0;i!=n;i++){
		scanf("%d",&S[i]);
	}
	scanf("%d",&q);
	for(j=0;j!=q;j++){
		scanf("%d",&T[j]);
	}

	C=0;
	for(i=0;i!=q;i++){
		L=0;
		R=n;
		while (L<R){
			M=(L+R)/2;
			if (S[M]==T[i]){
				C++;
				
				break;
			}
			if (S[M]>T[i]){
				R=M;
			}else{
				L=M+1;
			}
		}
	}
	printf("%d\n",C);
	return 0;
}

Measured memory_bytes: 1616
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[1000005];
bool vis[30];
int main(){
  scanf("%s",s+1); int n=strlen(s+1);
  for(int i=1;i<=n;i++) vis[s[i]-'a']=true;
  for(int i=0;i<=25;i++)
    if(!vis[i]){
      printf("%s",s+1); putchar('a'+i);
      return 0;
    }
  for(int i=n-1;i>=1;i--)
    if(s[i]<s[i+1]){
      int k=1e9; for(int j=i+1;j<=n;j++) if(s[j]>s[i]) k=j;
      s[i]=s[k]; s[i+1]=0;
      printf("%s",s+1);
      return 0;
    }
  puts("-1");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int a,b;
    cin >> a >> b;
    if(b % a == 0) cout << a + b << endl;
    else cout << b - a << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.sqrt

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, a, b) = readLongList()
    val aMinusB = a - b
    val hArray = LongArray(n.toInt()) { readLong() }

    var ok = (hArray.max()!! + b - 1) / b + 1
    var ng = -1L
    while (ok - ng > 1) {
        val mid = (ok + ng) / 2
        val isOK = {
            var attackCount = 0L
            for (h in hArray) {
                val remain = max(0, h - mid * b)
                attackCount += (remain + aMinusB - 1) / aMinusB
            }

            attackCount <= mid
        }
        if (isOK()) ok = mid else ng = mid
    }
    out.println(ok)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 49044
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n, N, sum;
cin>>n;
N=n;
sum=0;
while(n>0)
{
sum+=n%10;
n/=10;
}
if(N%sum==0)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}


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

signed main(){
  lint N; cin >> N;
  vector<vector<lint> > alp(N, vector<lint> (26, 0));
  for(lint i = 0; i < N; i++){
    string s; cin >> s; 
    for(lint j = 0; j < s.size(); j++){
      alp[i][s[j] - 'a']++;
    }
  }
  string ans;
  for(lint i = 0; i < 26; i++){
    lint c = 200;
    for(lint j = 0; j < N; j++){
      c = min(c, alp[j][i]);
    }
    for(lint j = 0; j < c; j++) ans += char('a' + i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256