akhauriyash/Code-Regression huggingface dataset:
Uses math;
var
	n,i,z,w,a,b,t:Longint;
	s:String;
begin
	readln(n,z,w);
	if n=1 then begin
		read(b);
		writeln(abs(b-w));
		exit;
	end;
	setlength(s,n*11+100);
	readln(s);
	i:=length(s);
	while s[i]>' ' do dec(i);
	for z:=i+1 to length(s) do b:=b*10+ord(s[z])-48;
	dec(i);
	t:=i;
	while(i>0)and(s[i]>' ')do dec(i);
	for z:=i+1 to t do a:=a*10+ord(s[z])-48;
	writeln(Max(abs(b-w),abs(a-b)));
end.


Measured memory_bytes: 256
using System;

namespace A___Iroha_and_Haiku__ABC_Edition_
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var c = int.Parse(input[2]);
            if (a == 5 && b == 5 && c == 7 || a == 7 && b == 5 && c == 5 || a == 5 && b == 7 && c == 5)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}

Measured memory_bytes: 13140
/* in the name of allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n, dp[N], o[N];
bool vis[N];
vector<int> adj[N];

void readInput() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		adj[--u].push_back(--v);
		adj[v].push_back(u);
	}
}

void dfs(int x) {
	vis[x] = true;
	for (auto v: adj[x])
		if (!vis[v])
			dfs(v), dp[x] += dp[v], o[x] += dp[v] % 2;
	dp[x]++;
	if (o[x] > 1) {
		cout << "First\n";
		exit(0);
	}
}

void solve() {
	if (n % 2) {
		cout << "First\n";
		return;
	}
	dfs(0);
	cout << "Second\n";
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	readInput(), solve();
	return 0;
}

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

#define debug(x) cerr << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

void initFactorials()
{
  fat[0] = 1;
  inv[0] = 1;
  for(int i = 1; i < maxn; i++)
  {
    fat[i] = (i * fat[i-1]) % mod;
    inv[i] = exp(fat[i], mod - 2);
  }
}

int a[maxn];

int main()
{
  ios::sync_with_stdio(0);
  ll n;
  cin >> n;
  n--;
  auto ans = (n * (n + 1)) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

typedef pair<int, int> pii;

int N;
vector<pii> A;
int main() {
	cin >> N;
	A.resize(N);
	for (int n = 1; n <= N; n++) {
		int a;
		cin >> a;
		A[n-1] = pii(n,a);
	}
	sort(A.begin(), A.end(), [](pii a, pii b) {
		return a.second < b.second;
	});
	for (int n = 0; n < N; n++) {
		cout << A[n].first << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
int A[1000000], n;

int binarySearch(int key)
{
  int left = 0;
  int right = n;
  int mid;
  while(left < right){
    mid = (left + right)/2;
    if(key == A[mid]) return 1;
    if(key > A[mid]) left = mid+1;
    else if(key < A[mid]) right = mid;
  }
  return 0;
}

int main()
{
  int i, q, k, sum = 0;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &k);
    if( binarySearch(k) ) sum++;
  }
  printf("%d\n", sum);

  return 0;
}

Measured memory_bytes: 984
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

class Point{
public:
  short n,a;
};

int main(){
  int i,j,n,a[100];
  long long b[2][21];
  while(cin >> n){
    for(i=0;i<n;i++) cin >> a[i];

    for(i=0;i<=20;i++) b[0][i] = b[1][i] = 0;
    b[1][a[0]] = 1;

    for(i=1;i<n-1;i++){
      for(j=0;j<=20;j++){
	b[0][j] = b[1][j];
	b[1][j] = 0;
      }

      for(j=0;j<=20;j++){
	if(b[0][j] > 0){
	  int plus = j + a[i];
	  if(plus >= 0 && plus <= 20){
	    b[1][plus] += b[0][j];
	  }
	  int minus = j - a[i];
	  if(minus >= 0 && minus <= 20){
	    b[1][minus] += b[0][j];
	  }
	}
      }
    }

    cout << b[1][a[n-1]] << endl;

  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
    public static void main(String[] args) throws java.io.IOException{
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a<b && a <c) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 17160
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        long ans = 0;
        long twoFactor = 1;
        int MOD = 1_000_000_007;
        for (int i = 0; i < 60; i++) {
            long odd = 0;
            long even = 0;
            for (int j = 0; j < n; j++) {
                if ((a[j] >>> i & 1) == 1) {
                    odd++;
                } else {
                    even++;
                }
            }
            ans += (odd * even) % MOD * twoFactor % MOD;
            ans %= MOD;
            twoFactor *= 2;
            twoFactor %= MOD;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 63220
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000009
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main() {
    fastio;
    int n,a,b,c,d;
    cin>>n;
        a = n%10;
        n = n/10;
        b=n%10;
         n = n/10;
        c=n%10;
         n = n/10;
        d=n%10;
    if(a==b) cout<<"Bad";
    else if(b==c) cout<<"Bad";
    else if(c==d) cout<<"Bad";
    //if(b==c) cout<<"Bad";
    else cout<<"Good";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<queue>
using namespace std;
int main()
{
	int i,j,k,n,m;
	for(i=0;i<3;i++)
	{
		char ch=getchar();
		if(ch=='9')
		{
			printf("1");
		}
		else
		{
			printf("9");
		}
	}
	return 0;
}


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

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

    bool res = false;
    rep(i, S.size()) {
        int t = i;
        bool temp = true;
        for(int j=0; j<T.size(); j++) {
            if(S[t%S.size()] != T[j]) temp = false;
            t++;
        }
        if(temp) {
            res = true;
            break;
        } 
    }

    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(3000)
h, w = map(int, raw_input().split())
s = [[c for c in raw_input()] for i in range(h)]
def isValid(i, j):
    if i < 0 or i >= h or j < 0 or j >= w:
        return False
    return True
    
def dfs(s, i, j):
    if not isValid(i, j) or s[i][j] == "0" or s[i][j] == ".":
        return 0
    if s[i][j] == "#":
        s[i][j] = "0"
        a = dfs(s, i+1, j)
        b = dfs(s, i-1, j)
        c = dfs(s, i, j+1)
        d = dfs(s, i, j-1)
        return 1 + a + b + c + d

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            ccs = dfs(s, i, j)
            #print ccs
            if ccs == 1:
                print "No"
                exit()
print "Yes"

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

int main() {
  const int inf = 1e9;
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    to.at(a - 1).push_back(b - 1);
  }
  int shortest = inf, shortest_i = -1;
  for (int i = 0; i < n; i++) {
    vector<bool> seen(n);
    queue<pair<int, int>> q;
    q.emplace(i, 0);
    while (!q.empty()) {
      int present = q.front().first, d = q.front().second;
      q.pop();
      seen.at(present) = true;
      for (int next : to.at(present)) {
        if (seen.at(next)) {
          if (next == i) {
            if (shortest > d + 1) {
              shortest = d + 1;
              shortest_i = i;
            }
          }
          continue;
        }
        q.emplace(next, d + 1);
      }
    }
  }
  if (shortest == inf) {
    cout << -1 << endl;
    return 0;
  }
  cout << shortest << endl;
  vector<vector<int>> v(n);
  vector<bool> seen(n);
  queue<int> q;
  q.push(shortest_i);
  v.at(shortest_i).push_back(shortest_i);
  while (!q.empty()) {
    int present = q.front();
    q.pop();
    seen.at(present) = true;
    for (int next : to.at(present)) {
      if (seen.at(next)) {
        if (next == shortest_i) {
          for (int x : v.at(present)) {
            cout << x + 1 << endl;
          }
          return 0;
        }
        continue;
      }
      q.push(next);
      v.at(next) = v.at(present);
      v.at(next).push_back(next);
    }
  }
}


Measured memory_bytes: 4736
#include "bits/stdc++.h"
using namespace std;
const int mod = 1e9 + 7;
int n , m;
int fact(int n){
	if(n <= 1){
		return 1;
	}
	return (1LL * n * fact(n - 1)) % mod;
}
int main(){
	cin >> n >> m;
	if(n == m){
		cout << (2LL * fact(n) * fact(m)) % mod;
	}
	else if(n == m + 1 || m == n + 1){
		cout << (1LL * fact(n) * fact(m)) % mod;
	}
	else{
		cout << 0;
	}
	cout << endl;
}

Measured memory_bytes: 1792
w, h, n = map(int, input().split())
x_pos = [0, w]
y_pos = [0, h]
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        x_pos[0] = max(x_pos[0], x)
    elif a == 2:
        x_pos[1] = min(x_pos[1], x)
    elif a == 3:
        y_pos[0] = max(y_pos[0], y)
    else:
        y_pos[1] = min(y_pos[1], y)
ans = max(0, (x_pos[1] - x_pos[0])) * max(0, (y_pos[1] - y_pos[0]))
print(ans)


Measured memory_bytes: 9100
N, M = map(int, input().split())

S = [0] * M
C = [0] * M

Q = [None] * N

for i in range(M):
    S[i], C[i] = map(int, input().split())


is_exist = True
for i in range(M):
    if N > 1 and S[i] == 1 and C[i] == 0:
        is_exist = False

    for j in range(N):
        if S[i] == j + 1:
            if Q[j] == None:
                Q[j] = C[i]
            elif Q[j] != C[i]:
                is_exist = False


ret = ""
if is_exist:
    for i in range(N):
        if i == 0 and Q[i] == None and N == 1:
            ret = "0"
        elif i == 0 and Q[i] == None:
            ret = "1"
        elif Q[i] == None:
            ret = ret + "0"
        else:
            ret = ret + str(Q[i])
    print(ret)
else:
    print("-1")


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

int main()
{
    string str;
    cin>>str;
    int a=0;
    for(char b:str)
    {
        a+=b-'0';
    }
    if(a%9)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    




    return 0;
}

Measured memory_bytes: 3748
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
 

 class Main{

     static int[] dens=new int[10];
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{
             String line;int[] bs=new int[4]; 
             while((line=br.readLine())!= null){if(line.isEmpty())break;
                 String split[] = line.split(",");
                 int a = Integer.parseInt(split[0]);//val
                 String b = split[1];//num
                 if(b.equals("A"))bs[0]++;
                 else if(b.equals("B"))bs[1]++;
                 else if(b.equals("AB"))bs[2]++;
                 else if(b.equals("O"))bs[3]++;
             }
             for(int val:bs){
                 System.out.println(val);}
             
         }catch(Exception e){}         
     }
    
 }

Measured memory_bytes: 16920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n, T;
    cin >> n >> T;
    vector<ll> c(n), t(n);
    rep(i, n) cin >> c[i] >> t[i];

    ll mi = INF;

    rep(i, n) {
        if(t[i] <= T)
            mi = min(mi, c[i]);
    }
    if(mi == INF)
        cout << "TLE";
    else
        cout << mi;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int compare(const void* a, const void* b)
{
    if(*(long long int*)a - *(long long int*)b < 0)
        return -1;
    if(*(long long int*)a - *(long long int*)b == 0)
        return 0;
    if(*(long long int*)a - *(long long int*)b > 0)
        return 1;
}
int main(){
   long long n,k,j,ct=0,l,i;
    scanf("%lld%lld",&n,&k);
    long long a[n];
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    if(k>=n) printf("0");
    else{
    qsort(a,n,sizeof(long long int),compare);
            for(i=0;i<n-k;i++){
                ct = ct + a[i];
            }
            printf("%lld",ct);
        }
    }

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

struct COM {
    vector<ll> inv, fac, finv;
    COM(int N) : inv(N), fac(N), finv(N) {
        inv[1] = 1;
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        for (int i = 2; i < N; ++i) {
            inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
            fac[i] = fac[i - 1] * i % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    ll calc(int a, int b) {
        return (fac[a] * finv[b] % MOD) * finv[a - b] % MOD;
    }
};

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

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    COM com(C * D + 10);
    int m = C * D - A * B, n = C + D - A - B;
    ll ans = com.calc(m, n);

    vector<vector<ll>> dp(C + 3, vector<ll>(D + 3));
    dp[A][B] = 1;
    for (int i = A; i <= C; ++i) {
        for (int j = B; j <= D; ++j) {
            (dp[i + 1][j] += (dp[i][j] * j) % MOD) %= MOD;
            (dp[i][j + 1] += (dp[i][j] * i) % MOD) %= MOD;
            (dp[i + 1][j + 1] -= (dp[i][j] * i % MOD) * j % MOD) %= MOD;
        }
    }

    if (dp[C][D] < 0)
        dp[C][D] += MOD;
    cout << dp[C][D] << endl;

    return 0;
}


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

int main() {
	int N,M;
  	cin >> N >> M;
  
  	vector<int> a(N),b(N),c(M),d(M);
  
  	for(int i = 0; i < N; i++) {
    	cin >> a.at(i) >> b.at(i); 
    }
  
  	for(int i = 0; i < M; i++) {
    	cin >> c.at(i) >> d.at(i); 
    }
  
  	for(int i = 0; i < N; i++) {
    	int minimum = abs(a.at(i) - c.at(0)) + abs(b.at(i) - d.at(0));
      	int ans = 1;
      	for(int j = 1; j < M; j++) {
          int minimum2 = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
          if(minimum2 < minimum) {
          	minimum = minimum2;
            ans = j + 1;
          }
        }
      cout << ans << endl;
    }
  	
}

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

int main(void) {
    int N, M;
cin >> N >> M;
 int NMMAX = 50;
    int A[NMMAX], B[NMMAX];
for (int i=0;i<M;++i){ cin >> A[i] >> B[i];
}
int road[NMMAX];
for (int i=0;i<N;++i){
road[i] = 0; }
for (int i=0;i<M;++i){ road[A[i] - 1] += 1; road[B[i] - 1] += 1;
}
for (int i=0;i<N;++i){ cout << road[i] << endl;
}
return 0; }



Measured memory_bytes: 3572
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

int main(){
  
  long long int N, K, tmp;
  std::vector<long long int> H;

  scanf("%lld%lld", &N, &K);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    H.push_back(tmp);
  } 

  std::sort(H.begin(), H.end(), std::greater<long long int>());

  // solve problem
  long long int ans = 0;
  for(long long int i = K; i < N; i++){
    ans += H[i];
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 2420
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
  N = int(input())
  A = [list(map(int, input().split())) for _ in range(N)]
  mod = 10**9+7
  dp = [[0]*(1<<N) for _ in range(N+1)]
  dp[N][-1] = 1
  for i in range(N-1,-1,-1):
    for com in combinations(range(N),i):
      S = 0
      for k in com:
        S += 1<<k
      for j in range(N):
        if not S>>j&1: #jがSに含まれないなら
          if A[i][j]==1:
            dp[i][S] += dp[i+1][S+(1<<j)]
            dp[i][S] %= mod
  return dp[0][0]
print(solve())

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

void bfs(int x,int y);
int tmap[12][12]={0};
char input[13][13];
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int cou;

int main(){
  while(scanf("%s",input[0]) != EOF){
    for(int i=1;i<12;i++){
      scanf("%s",input[i]);
    }
    for(int i=0;i<12;i++){
      for(int j=0;j<12;j++){
	if(input[i][j] == '1'){
	  tmap[i][j] = 1;
	}
	else {
	  tmap[i][j] = 0;
	}
      }
    }
    cou = 0;
    for(int i=0;i<12;i++){
      for(int j=0;j<12;j++){
	if(tmap[i][j] == 1){
	  bfs(j,i);
	  cou++;
	}
      }
    }
    cout << cou << endl;
  }
}
	
void bfs(int x,int y){
  tmap[y][x] = 0;
  for(int i=0;i<4;i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx >= 0 && nx < 12 && ny >= 0 && ny < 12 && tmap[ny][nx] == 1){
      bfs(nx,ny);
    }
  }
  return;
}

Measured memory_bytes: 1156
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?
	
	// I don't wanna feel the PAIN.

// I BeG you to KILL me, pleASE...

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Os")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e5+10, lg=22, mod=1e9+7, inf=1e18;

ll n,a[maxn],b[maxn];

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

	cin>>n;
	ll sum=0;
	for(int i=0;i<n;i++) cin>>a[i], sum+=a[i];
	ll p=n*(n+1)/2;
	if(sum%p) return cout<<"NO", 0;
	ll k=sum/p;
	for(int i=0;i<n;i++) b[i]=a[(i+1)%n]-a[i]-k;
	for(int i=0;i<n;i++)if(b[i]>0 || (-b[i])%n) return cout<<"NO", 0;
	cout<<"YES"<<endl;

	return 0;
}












Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define PR       pair<ll, ll>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

map<string, int> cnt;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (cnt[s] == 0) {
            ans++;
        }
        cnt[s]++;
    }
    cout << ans << '\n';
    return 0;
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' 
      || c == 'e' 
      || c == 'i' 
      || c == 'o' 
      || c == 'u') {
    cout << "vowel" << endl;
  }
  else { cout << "consonant" << endl; }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	String S = scan.next();

	int[] alpha = new int[26];
	for(int i = 0; i < S.length(); i++){
	    alpha[S.charAt(i)-97]++;
	}

	int moji = 97;
	int flag = 0;
	for(int i = 0; i < 26; i++){
	    if(alpha[i] == 0){
		flag = 1;
		break;
	    }else{
		moji++;
	    }
	}

	if(flag == 1){
	    System.out.println((char)moji);
	}else{
	    System.out.println("None");
	}
    }
}


Measured memory_bytes: 24404
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,a,cnt=0;
    cin>>n;
    rep(i,n){
        cin>>a;
        while(a%2==0){
            a/=2;
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int a,b,c;
	cin>>a;
	cin>>b;
	cin>>c;
	
	if(!((a == b) || (a == c))){
		cout<<a;
	}
	else if(!((b == a) || (b == c))){
		cout<<b;
	}
	else{
		cout<<c;
	}
	
	return 0;
}

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

using namespace std;

int main(){
	
	int N, M, d;
	
	int map[2000];
	int dice[2000];
	
	while(true){
		
		cin >> N >> M;
		
		if(N == 0 && M == 0){
			break;
		}
		for(int i = 0; i < N; i++){
			cin >> map[i];
		}
		int p = 0;
		for(int i = 0; i < M; i++){
			cin >> d;
			dice[i] = d;
		}
		for(int i = 0; i < M; i++){
			p += dice[i];
			if(p >= N - 1){
				printf("%d\n", i + 1);
				break;
			}
			p += map[p];
			if(p >= N - 1){
				printf("%d\n", i + 1);
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1156
n, m = map(int, input().split())
ipy = []
for i in range(m):
  p, y = map(int, input().split())
  ipy.append([i, p, y])

dict_p = {}
dict_c = {}

for i, p, y in sorted(ipy, key=lambda x: x[2]):
  if not p in dict_p:
    dict_p[p] = 0
  dict_p[p] += 1
  dict_c[p,i] = dict_p[p]

for i, p, y in ipy:
  print('{0:06}{1:06}'.format(p, dict_c[p,i]))


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

int main() {
  string N;
  cin >> N;
  for (int i = 0; i < 3; i++) {
    if (N.at(i) == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

int main() {
  int N;
  cin>>N;
  vector<int> mochi(N);
  for(int i=0;i<N;i++){
    cin>>mochi.at(i);
  }
  sort(mochi.begin(),mochi.end());    
  int a=1;
  for(int i=0;i<(N-1);i++){
    if(mochi.at(i)!=mochi.at(i+1)){
      a++;
    }
  }
  cout<<a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	char s[20];
	cin >> s;

	for (int i = 0; i < 19; i++) {
		if (i == 5 || i == 13) {
			cout << ' ';
			continue;
		}
		else
		{
			cout << s[i];
		}
	}
	cout << endl;

	return 0;
}

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

int n,m,q;
vector<int> a,b,c,d;
int ans = 0;

void dfs(vector<int> A){
  if(int(A.size())==n+1){
    int res = 0;
    rep(i,q){
      if(A[b[i]]-A[a[i]]==c[i]) res += d[i];
    }
    ans = max(ans,res);
    return;
  }
  A.pb(A.back());
  while(int(A.back())<=m){
    dfs(A);
    A.back()++;
  }
}

int main(){
  cin>>n>>m>>q;
  a.resize(q); b.resize(q); c.resize(q); d.resize(q);
  rep(i,q) cin>>a[i]>>b[i]>>c[i]>>d[i];
  dfs(vector<int>(1,1));
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
int g[20][20];
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    for(int i=0;i<a;i++)
        for(int j=0;j<a;j++)
            g[i][j]=99999999;
    for(int i=0;i<b;i++){
        int c,d,e,f;
        scanf("%d,%d,%d,%d",&c,&d,&e,&f);
        g[c-1][d-1]=e;
        g[d-1][c-1]=f;
    }
    int c,d,e,f;
    scanf("%d,%d,%d,%d",&c,&d,&e,&f);
    for(int k=0;k<a;k++)
        for(int i=0;i<a;i++)
            for(int j=0;j<a;j++)
                if(g[i][j]>g[i][k]+g[k][j])g[i][j]=g[i][k]+g[k][j];
    printf("%d\n",e-f-g[c-1][d-1]-g[d-1][c-1]);
}


Measured memory_bytes: 2736
#include<iostream>
#include<cstdio>
#include<string.h>


const int INF = -1;

using namespace std;

char maze[1010][1010];
int H, W, N;
int d[1010][1010];
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1, -1, 0, 0 };
int sx[10], sy[10];
int ans = 0;

struct QNode
{
	int data_sx[1010];
	int data_sy[1010];
	int front, rear;
	int maxsize;
};
typedef struct QNode *Queue;

Queue Create()
{
	Queue Q;
	Q = (Queue)malloc(sizeof(struct QNode));
	Q->front = Q->rear = 0;
	Q->maxsize = 1010;
	return Q;
}
void push(Queue Q,int x,int y)
{
	if ((Q->rear + 1) % Q->maxsize == Q->front)
		return;
	Q->rear = (Q->rear + 1) % Q->maxsize;
	Q->data_sx[Q->rear] = x;
	Q->data_sy[Q->rear] = y;
}
int pop1(Queue Q)
{
	if (Q->front == Q->rear)
		return -1;
	Q->front = (Q->front + 1) % Q->maxsize;
	return Q->data_sx[Q->front];
}
int pop2(Queue Q)
{
	return Q->data_sy[Q->front];
}


void bfs(int i)
{
	Queue Q;
	Q = Create();
	memset(d, -1, sizeof(d));
	push(Q, sx[i], sy[i]);
	d[sx[i]][sy[i]] = 0;
	if (i == N)
		return;
	while (Q->front != Q->rear)
	{
		int x = pop1(Q), y = pop2(Q);
		if (x == sx[i + 1] && y == sy[i + 1])
			return;

		for (int j = 0; j < 4; j++)
		{
			int nx = x + dx[j], ny = y + dy[j];
			if (nx >= 0 && nx < H && ny >= 0 && ny < W && d[nx][ny] == INF && maze[nx][ny]!='X')
			{
				push(Q, nx, ny);
				d[nx][ny] = d[x][y] + 1;
			}
		}
	}
}

void solve()
{
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (maze[i][j] == 'S')
				sx[0] = i, sy[0] = j;
			else if (maze[i][j] >= '1'&&maze[i][j] <= '9')
				sx[maze[i][j] - '0'] = i, sy[maze[i][j] - '0'] = j;
		}
	}
	for (int i = 0; i < N; i++)
	{
		bfs(i);
		ans += d[sx[i + 1]][sy[i + 1]];
	}
	cout << ans << endl;
}

int main()
{
	cin >> H >> W >> N;

	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
			cin >> maze[i][j];
	solve();
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int k,x;
    cin>>k>>x;
    for (int i=x-k+1;i<=x+k-1;i++)
        cout<<i<<" ";
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    int ans = 1e9 + 7;
    for (int i = 0; i + k - 1 < n; i++) {
        ans = min(ans, h[i + k - 1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MA=1e5+5;

int main(){
	int a,b;
	cin>>a>>b;
	if(a>9||b>9)cout<<"-1"<<endl;
	else cout<<a*b<<endl; 
	
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

 main(){

   int n,i,c=0;
   scanf("%d",&n);
   int s[n],a[n];
   
   for(i=0;i<n;i++){
     scanf("%d",&s[i]);
     a[i]=i+1;
   }
   
   for(i=0;i<n;i++){
     if(a[i]!=s[i])
       c++;
   }
     
   /*for(i=1;i<n;i++){
     if(s[i]-s[i-1]<0)
        c++;
   } */
   if(c==0 || c==2)
     printf("YES");
   else
     printf("NO");
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.ArrayList;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      String S,T;
      
       while (scan.hasNextLine()) {
      String an = scan.nextLine();
      list.add(an);
      }
      S = list.get(0);
      T = list.get(1);
      check(S,T);
        scan.close();
    }
  
  public static void check(String S , String T){
    int l,s,t;
    int i = 0;
    boolean flag = true;
    s = S.length();
    t = T.length();
    l = t - s;
    char[] tst = new char[t];
    char[] sst = new char[s];
    if(l == 1){
      while(i < s){
        tst[i] = T.charAt(i);
        sst[i] = S.charAt(i);
        if( tst[i] ==  sst[i]){
          flag = true;
        }else{
          flag = false;
          break;
        }
        i++;
      }
    }else{
      System.out.println("No");
      return;
    }
    
    if(flag){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    return;
  }
}

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

int n,m,a,b,x,y,z;
string c[1000],ans="NO";

void f(){
    cout<<ans<<endl;
    if(ans=="NO")return;
    for(int i=0;i<n;i++){
        cout<<c[i]<<endl;
    }
}

int main(void){
    cin>>n>>m>>a>>b;
    c[0]="";
    for(int i=0;i<m;i++){
        c[0]+=".";
    }
    for(int i=1;i<n;i++){
        c[i]=c[0];
    }
    if(n%2==1){
        for(int i=0;i+1<m;i+=2){
            if(a>0){
                c[n-1][i]='<';
                c[n-1][i+1]='>';
                a--;
            }
        }
    }
    if(m%2==1){
        for(int i=0;i+1<n;i+=2){
            if(b>0){
                c[i][m-1]='^';
                c[i+1][m-1]='v';
                b--;
            }
        }
    }
    for(int i=0;i+1<n;i+=2){
        for(int j=0;j+1<m;j+=2){
            if(a>=2){
                c[i][j]=c[i+1][j]='<';
                c[i][j+1]=c[i+1][j+1]='>';
                a-=2;
            }else if(b>=2){
                c[i][j]=c[i][j+1]='^';
                c[i+1][j]=c[i+1][j+1]='v';
                b-=2;
            }else if(n%2==1&&m%2==1&&i==n-3&&j==m-3&&a==1&&b==1){
                c[i][j]=c[i+2][j+1]='<';
                c[i][j+1]=c[i+2][j+2]='>';
                a--;
                c[i+1][j]='^';
                c[i+2][j]='v';
                b--;
            }else if(a>0){
                c[i][j]='<';
                c[i][j+1]='>';
                a--;
            }else if(b>0){
                c[i][j]='^';
                c[i+1][j]='v';
                b--;
            }
        }
    }
    if(a==0&&b==0)ans="YES";

    f();
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int T;
typedef long long LL;

#define dbg(x) cout << #x"=" << x << endl;
const int MAX_N = 2e5+100;
typedef pair<int, int> P;
int N,D,A;
#define x first
#define h second
P p[MAX_N];
queue<P> que;

int main(){
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> N >> D >> A;
    for(int i = 0; i < N; ++i){
        cin >> p[i].x >> p[i].h;
        int x = p[i].h;
        p[i].h /= A;
        if(p[i].h * A < x) ++p[i].h;
    }
    sort(p, p+N);
    LL ans = 0;
    LL sum = 0;
    for(int i = 0; i < N; ++i){
        if(p[i].h <= 0) continue;
        while(!que.empty() && que.front().x < p[i].x){
            sum -= que.front().h;
            que.pop();
        }
        p[i].h -= sum;
        if(p[i].h > 0){
            ans += p[i].h;
            que.push(make_pair(p[i].x + 2*D, p[i].h));
            sum += p[i].h;
        }
    }
    cout << ans << endl;
    return 0;
}

/*
炸弹放在x
[x-D, X+D]的范围会-A
N D A
3 3 2
1 2
5 4
9 2

1+2D
que[].x 是单调递增的
*/

Measured memory_bytes: 2688
N,M = map(int,input().split())
MOD = 10**9+7

from collections import Counter
def factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

MAXN = N+99
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def ncr(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

def nhr(n,r):
    return ncr(n+r-1, r)

factors = factorize(M)
ans = 1
for v in factors.values():
    ans *= nhr(N,v)
    ans %= MOD
print(ans)

Measured memory_bytes: 15972
#include <bits/stdc++.h>
#define int long long int
#define MAX 1000007
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
void solve() {
 	int l;
 	cin >> l;
 	string s1, s2;
 	cin >> s1 >> s2;
 	string ans = "";
 	int c = 0;
 	for(int i=0;i<2*l;i++) {
 		if(i%2 == 0)
 			ans += s1[i/2];
 		else
 			ans += s2[i/2];
 	}
 	cout << ans << '\n';
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}


Measured memory_bytes: 256
$s = <STDIN>;
my ($K,$N) = split(/ /,$s);
$s = <STDIN>;
chomp $s;
my $max= 0;
my @dat = split(/ /,$s);
for(my $i =1;$i<$N;$i++){
  my $dist = $dat[$i] - $dat[$i-1];
  if($dist > $max ){
    $max = $dist;
  } 
}
$add = $dat[0] + ($K-$dat[$N-1]);
if($add > $max ){
    $max = $add;
} 

my $ans = $K - $max ;
print "$ans";

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

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

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

template <typename T1, typename T2>
bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S;
    cin >> S;
    ll A, B, C, D;
    A = S[0] - '0';
    B = S[1] - '0';
    C = S[2] - '0';
    D = S[3] - '0';
    if (A + B + C + D == 7) {
        prints("")(A, "+", B, "+", C, "+", D, "=7");
    }
    else if (A + B + C - D == 7) {
        prints("")(A, "+", B, "+", C, "-", D, "=7");
    }
    else if (A + B - C + D == 7) {
        prints("")(A, "+", B, "-", C, "+", D, "=7");
    }
    else if (A + B - C - D == 7) {
        prints("")(A, "+", B, "-", C, "-", D, "=7");
    }
    else if (A - B + C + D == 7) {
        prints("")(A, "-", B, "+", C, "+", D, "=7");
    }
    else if (A - B + C - D == 7) {
        prints("")(A, "-", B, "+", C, "-", D, "=7");
    }
    else if (A - B - C + D == 7) {
        prints("")(A, "-", B, "-", C, "+", D, "=7");
    }
    else if (A - B - C - D == 7) {
        prints("")(A, "-", B, "-", C, "-", D, "=7");
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(nullptr), cout.tie(nullptr);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

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

using namespace std;
typedef long long ll;

const int N = int(1e8) + 7;

void init() {

}

void solve() {
	vector<ll> A;
	vector<ll> B;
	vector<ll> C;
	vector<ll> ans;
	int x, y, z, k;
	scanf("%d%d%d%d", &x, &y, &z, &k);
	for (int i = 0; i < x; i++) {
		ll p; scanf("%lld", &p);
		A.push_back(p);
	}
	for (int i = 0; i < y; i++) {
		ll p; scanf("%lld", &p);
		B.push_back(p);
	}
	for (int i = 0; i < z; i++) {
		ll p; scanf("%lld", &p);
		C.push_back(p);
	}
	sort(A.begin(), A.end(), greater<ll>());
	sort(B.begin(), B.end(), greater<ll>());
	sort(C.begin(), C.end(), greater<ll>());
	for(int a = 0; a < A.size(); a++) for(int b = 0; b < B.size(); b++) for(int c = 0; c < C.size(); c++){
	    if( (a+1)*(b+1)*(c+1) > k) break;
	    ans.push_back(A[a]+B[b]+C[c]);
	}
	sort(ans.begin(), ans.end(), greater<ll>());
	for(int i = 0; i < k; i++)
	    printf("%lld\n", ans[i]);
}

const bool mtc = false;

int main() {
	int t;
	if (mtc) {
		scanf("%d", &t);
		while (t--) solve();
	}
	else solve();
}



Measured memory_bytes: 1920
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var a = intShift();
  
  var o = [];
  for(var i = 0; i < a;i++){
  	o.push(intShift());
  }
  o = o.sort((a,b)=>b-a);
  return o.filter((a,b)=>b%2==0).reduce((a,b)=>a+b) - o.filter((a,b)=>b%2==1).reduce((a,b)=>a+b)
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
3
2 7 4
`);

Measured memory_bytes: 11468
#include<bits/stdc++.h>
using namespace std;
int n;
int arr[100010];
int t[100010];
int dp(int n)
{
	if(n==2) return abs(arr[2]-arr[1]);
	if(n==3) return min(abs(arr[3]-arr[1]) , abs(arr[3]-arr[2]) + abs(arr[2]-arr[1]));
	
	if(t[n]!=-1)
	{
		return t[n];
	}
	t[n]=min(abs(arr[n]-arr[n-1]) + dp(n-1) , abs(arr[n]-arr[n-2]) + dp(n-2));
	
	return t[n];
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
	}
	memset(t , -1 , sizeof(t));
	int ans=dp(n);
	cout<<ans<<endl;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

int cnt[2];

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

    int n,p;
    cin >> n >> p;
    forn(i,n) {
        int x; cin >> x;
        cnt[x&1]++;
    }
    
    ll ans;
    if (cnt[1] == 0) {
        if (p == 0) ans = 1LL<<n;
        else ans = 0;
    }
    else ans = 1LL<<(n-1);
    cout << ans << endl;

    return 0;
}


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

public class Main {

	public static void main(String[] args)throws Exception {
		// TODO ?????????????????????????????????????????????

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		 
        int input = Integer.parseInt(br.readLine());
 
        int hour = input / 3600;
        int minutes = (input - hour * 3600) / 60;
        int seconds = input - (hour * 3600) - (minutes * 60);
 
        System.out.println(hour + ":" + minutes + ":" + seconds);
		
	}

}

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

using namespace std;
using ll = long long;
constexpr int INF = numeric_limits<int>::max();
template <typename T, typename... Args>
const T& min(const T& a, Args... args) {
  return min(a, min(args...));
}
template <typename T, typename... Args>
const T& max(const T& a, Args... args) {
  return max(a, max(args...));
}

#pragma GCC optimize("O3")
static const auto __ = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();

int a, b, c;

int main(int argc, char* argv[]) {
  cin >> a >> b >> c;
  cout << std::max(0, c - (a - b)) << '\n';
  return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
q = ni()
from collections import Counter

d = Counter(a)
s = sum(a)

for i in range(q):
    b,c = na()
    k = d[b]
    s += k*(c-b)
    d[c]+=d[b]
    d[b] = 0
    print(s)

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

long long pow(long long a, int b) {
  long long acc = 1;

  for(int i = 0; i < b; i++) {
    acc *= a;
  }

  return acc;
}

int main(int argc, char** argv){
  long long n;

  while(cin >> n) {
    vector<int> bits;
    int count = 0;
    long long base = 2;    

    if (n == 0) {
      bits.push_back(0);
    } else {
      while(n != 0) {
	if (n % base == 0) {
	  bits.push_back(0);
	} else {
	  bits.push_back(1);

	  n -= pow(-2, count);
	}
      
	count++;
	base *= 2;
      }

    }
   
    int size = bits.size();
    for(int i = 0; i < size; i++) {
      cout << bits.back();
      bits.pop_back();
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
struct Point {
	long long x, y;
	inline Point(long long _x = 0, long long _y = 0): x(_x), y(_y) {}
};
inline Point operator - (const Point &a, const Point &b) {
	return Point(a.x - b.x, a.y - b.y);
}
inline long long cross(const Point &a, const Point &b) {
	return a.x * b.y - a.y * b.x;
}
int n;
long long A[N], B[N], C[N];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%lld", &A[i]);
	for (int i = 0; i < n; i++) scanf("%lld", &B[i]);
	int mv = 0;
	for (int i = 1; i < n; i++) if (A[i] > A[mv]) mv = i;
	rotate(A, A + mv, A + n);
	rotate(B, B + mv, B + n);
	A[n] = A[0];
	B[n] = B[0];
	C[0] = C[1] = 0;
	for (int i = 2; i <= n; i++) C[i] = 2 * (C[i - 1] + B[i - 1]) - C[i - 2];
	vector<Point> stk;
	for (int i = 0; i <= n; i++) {
		Point cur(i, A[i] - C[i]);
		while (stk.size() >= 2 && cross(stk.back() - stk[stk.size() - 2], cur - stk[stk.size() - 2]) >= 0)
			stk.pop_back();
		stk.push_back(cur);
	}
	long long sum = 0;
	for (int i = 0; i < (int)stk.size() - 1; i++) {
		sum += stk[i].y * (stk[i + 1].x - stk[i].x + 1) + stk[i + 1].y * (stk[i + 1].x - stk[i].x - 1);
	}
	for (int i = 0; i < n; i++) sum += 2 * C[i];
	double ans = sum;
	ans /= 2.0 * n;
	printf("%.12lf\n", ans);
	return 0;
}

Measured memory_bytes: 11976
N, K = map(int, input().split())

if K > (N-1)*(N-2) // 2:
    print(-1)
else:
    max_dif = (N-1)*(N-2) // 2 - K
    M = N - 1 + max_dif
    print(M)
    for i in range(N-1):
        print("{} {}".format(1, i+2))
    node1 = 2
    node2 = 3
    for i in range(max_dif):
        print("{} {}".format(node1, node2))
        if node2 == N:
            node1 += 1
            node2 = node1 + 1
        else:
            node2 += 1


Measured memory_bytes: 42088
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

vector<int> divisors(int n) {
    vector<int> res;
    for(int i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i);
        if(n/i == i) continue; // 上の行で追加済み。
        res.push_back(n/i);
    }
    return res;
}

int main() {
    int N, M;

    cin >> N >> M;

    vector<int> divs = divisors(M);
/*
    for(vector<int>::iterator it = divs.begin(); it != divs.end(); ++it) {
        cout << *(it) << endl;
    }
*/
    
    sort(divs.begin(), divs.end());

    vector<int>::iterator it = lower_bound(divs.begin(), divs.end(), M/N);

    if (*(it) == M/N) {
        cout << *(it) << endl;
    } else {
        cout << *(it-1) << endl;
    }

    return 0;
}


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

const int MAXN = 1.1e5;
int N;
ll A[MAXN];
ll B[MAXN];

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> N;
  for (int i=0; i<N+1; i++){
    cin >> A[i];
  }
  for (int i=0; i<N; i++){
    cin >> B[i];
  }
  
  ll ans = 0;
  
  for (int i=0; i<N+1; i++){
    if (i){
      ll v = min(A[i], B[i-1]);
      ans += v;
      A[i] -= v;
      B[i-1] -= v;
    }
    if (i<N){
      ll v = min(A[i],B[i]);
      ans += v;
      A[i] -= v;
      B[i] -= v;
    }
      
  }
  
  cout << ans << '\n';
  
  return 0;
  
}


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

#define lint long long
#define P pair<lint, lint>

int main(){
    int H1,M1,H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    cout << (H2-H1)*60 + (M2-M1)-K << endl;
}

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

int main() {
  
  int x=0, y=0, z=0;
  
  cin >> x >> y >>z;
  
  swap(x, y);
  swap(x, z);
  
  cout << x << " " << y << " " << z << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2])cout <<"No" <<endl;
    else cout << "Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256