akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    char c1,a1[101];
    int a,b,d,i,l;
    gets(a1);
    l=strlen(a1);

    for(c1='a';c1<=122;c1++)
    {
        d=0;
        for(i=0;i<l;i++)
        {
            if (c1==a1[i])
                d=d+1;
        }
        if(d%2 != 0)
        {
            printf("No");
            break;
        }
    }
    if(d%2 ==0)
        printf("Yes");
    return 0;
}




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

int main(){
string A, B; cin >> A >> B;
if (A.size() > B.size()) {
    cout << "GREATER" << endl;
} else if (A.size() < B.size()) {
    cout << "LESS" << endl;
} else {
    if (A > B) {
        cout << "GREATER" << endl;
    } else if (A < B) {
        cout << "LESS" << endl;
    } else {
        cout << "EQUAL" << endl;
    }
}

}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Vacation
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();

            long[][] dp = new long[3][N + 1];

            for (int i = 1; i <= N; i++) {
                int a = sc.nextInt();
                int b = sc.nextInt();
                int c = sc.nextInt();

                dp[0][i] = a + Math.max(dp[1][i - 1], dp[2][i - 1]);
                dp[1][i] = b + Math.max(dp[2][i - 1], dp[0][i - 1]);
                dp[2][i] = c + Math.max(dp[0][i - 1], dp[1][i - 1]);
            }

            long ans = Math.max(dp[0][N], Math.max(dp[1][N], dp[2][N]));

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 93752
import math
N, D = list(map(int, input().split()))
def dis(x, y):
    return math.sqrt(x**2+y**2)

cnt = 0
for _ in range(N):
    x, y = list(map(int, input().split()))
    if dis(x, y)<=D:
        cnt+=1
print(cnt)

Measured memory_bytes: 70028
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  map<string,long long int>m;
  for (int i = 0; i < n; ++i)
  {
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    m[s]++;
  }
  long long int ans = 0;
  for (auto &&g : m)
  {
    if(g.second > 1){
      ans += (g.second)*(g.second-1)/2;
    }
  }
  cout << ans << endl;
  return 0;
} 


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 


int main() {
  fastio;
  ll a,b;
  cin>>a>>b;
  if(a<=9 and b<=9) {
    cout<<a*b<<endl;
  } else {
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define MAX 30000
using namespace std;

bool dfs(string s) {
    if (s == "ABC") return true;
    if (s.find("ABC") == string::npos) return false;

    char x;
    if (s.substr(0, 3) == "ABC") x = 'A';
    else  if (s.substr(s.size() - 3) == "ABC") x = 'C';
    else x = 'B';

    string res;
    for (int j = 0; j < s.length(); j++) {
        if (j < s.length() - 2 && s.substr(j, 3) == "ABC") {
            res += x;
            j += 2;
        } else {
            if (x == 'A') {
                if (s[j] == x &&(j + 2 >= s.length()
                    || s[j + 1] != 'B' || s[j + 2] != 'C')) return false;
            } else if (x == 'B') {
                if (s[j] == x && (j + 1 >= s.length() || j == 0 
                    || s[j - 1] != 'A' || s[j + 1] != 'C')) return false;
            } else {
                if (s[j] == x && (j < 2 || s[j - 2] != 'A' 
                    || s[j - 1] != 'B')) return false;
            }
            res += s[j];
        }
    }

//    cout << res << endl;
    return dfs(res);
}

int main() {
    string s;
    cin >> s;
    
    cout << ((dfs(s)) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 21820
#include <algorithm> // min
#include <cmath> // abs
#include <iostream>
using namespace std;
int main(){
string S;
cin >> S;
 int N = S.size();
 int ans = 999;
 for(int i = 0; i <= N - 3; ++i){
 int num = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + S[i+2] - '0';
 ans = min(ans, abs(num - 753));
 }
 cout << ans << endl;
 }


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

using namespace std;

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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
 
#define int long long
 
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
 
string s;
 
signed main() {
    cin >> s;
    int ans = s.size();
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] != s[i + 1]) {
            int cur = max(i + 1, (int)s.size() - i - 1);
            ans = min(ans, cur);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

ll N;

int main(){
    cin >> N;
    if(N%10 == 3){
        cout << "bon" << endl;
    }else if(N%10 == 0 || N%10==1 || N%10==6 || N%10==8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
while True:
    a,op,b=input().split()
    
    a=int(a)
    b=int(b)
    
    if op=='?':
        break
    
    if op=="+":
        print(a+b)
    if op=="-":
        print(a-b)
    if op=="*":
        print(a*b)
    if op=="/":
        print(a//b)


Measured memory_bytes: 5592
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)
x = sorted(x)
y = sorted(y)

for z in range(-100,101):
    if z > max(x) and z <= min(y):
        ans = "No War"
        break
    else:
        ans = "War"
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        for (int j = 1; j <= m; j++) {
            if (j % 3 == 0) {
                System.out.print(" "+j );
                continue;
            }
 
            for (int i = j; i > 0; i /= 10) {
                if (i % 10 == 3) {
                    System.out.print(" "+j );
                    break;
                }
            }
 
        }
        System.out.println();
        sc.close();
    }
}

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

#define int long long

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

int N;
int ap[100] = {};

signed main() {
    int max_a = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        max_a = max(max_a, a);
        ap[a]++;
    }
    if (max_a == 1 && N != 2) {
        cout << "Impossible" << endl;
        return 0;
    }
    if (max_a % 2 == 0) {
        ap[max_a / 2]--;
    } else if (ap[max_a / 2 + 1] != 2) {
        cout << "Impossible" << endl;
        return 0;
    }
    for (int i = 1; i < 100; i++) {
        if ((i > max_a || i <= max_a / 2)) {
            if (ap[i] != 0) {
                cout << "Impossible" << endl;
                return 0;
            }
        } else {
            if (ap[i] < 2) {
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }
    cout << "Possible" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        try(Scanner sc = new Scanner(System.in)){
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[]values = new int[w];
            for(int i=0;i<values.length;i++){
                values[i] = i+1;

            }
            for(int i=0;i<n;i++){
                String str = sc.next();
                String[]ab = str.split(",");
                int a = Integer.parseInt(ab[0])-1;
                int b = Integer.parseInt(ab[1])-1;
                int[] oldvalues = new int[w];
                System.arraycopy(values,0,oldvalues,0,values.length);
                values[a] = oldvalues[b];
                values[b] = oldvalues[a];
            }
            for(int i=0;i<w;i++){
                System.out.println(values[i]);
            }
        }
    }
}


Measured memory_bytes: 26180
input()
A=[0]+input().split()
H=len(A)
for i in range(1,H):
 print(f'node {i}: key = {A[i]}, {f"parent key = {A[i//2]}, "if i>1 else""}{f"left key = {A[2*i]}, "if 2*i<H else""}{f"right key = {A[2*i+1]}, "if 2*i+1<H else""}')


Measured memory_bytes: 5600
#include<iostream>
using namespace std;
 
int main(){
    int w, h, x, y, r;
    cin>>w>>h>>x>>y>>r;
    if(0<=x-r && x+r<=w && 0<=y-r && y+r<=h){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 1124
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
int main() {
	char s[100001], tmp;
	char dream[6] = "maerd";
	char dreamer[8] = "remaerd";
	char erase[6] = "esare";
	char eraser[7] = "resare";
	bool isDream, isDreamer, isErase, isEraser;
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 0; i < len / 2; i++) {
		tmp = s[i];
		s[i] = s[len - i - 1];
		s[len - i - 1] = tmp;
	}
	for (int i = 0; i < len;) {
		isDream = isDreamer = isErase = isEraser = true;
		for (int j = 0; j < 5; j++) {
			if (s[i + j] != dream[j]) {
				isDream = false;
				break;
			}
		}
		for (int j = 0; j < 7; j++) {
			if (s[i + j] != dreamer[j]) {
				isDreamer = false;
				break;
			}
		}
		for (int j = 0; j < 5; j++) {
			if (s[i + j] != erase[j]) {
				isErase = false;
				break;
			}
		}
		for (int j = 0; j < 6; j++) {
			if (s[i + j] != eraser[j]) {
				isEraser = false;
				break;
			}
		}
		if (isDream || isErase) {
			i += 5;
		} else if (isEraser) {
			i += 6;
		} else if (isDreamer) {
			i += 7;
		} else {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX 100005
#define NIL -1

struct Node {int p,l,r;};

struct Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);
  if(T[u].p == NIL)printf("root, ");
  else if(T[u].l == NIL)printf("leaf, ");
  else printf("internal node, ");
  printf("[");

  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}
int rec(int u,int p){
  D[u] = p;
  if(T[u].r != NIL)rec(T[u].r,p);
  if(T[u].l != NIL)rec(T[u].l,p+1);
}

int main (){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p = T[i].l = T[i].r = NIL;

  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)T[v].l = c;
      else T[l].r = c;
      l=c;
      T[c].p = v;
    }
  }
  for (i=0;i<n;i++){
    if(T[i].p == NIL)r=i;
  }

  rec(r,0);

  for(i=0;i<n;i++)print(i);
  return 0;
}

  
		     



Measured memory_bytes: 6484
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static int a,b;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            a=sc.nextInt();
            b=sc.nextInt();
            if(a==0&&b==0) break;
            for(int i=0;i<a;i++){
                for(int j=0;j<b;j++){
                    if(i==0||i==a-1||j==0||j==b-1) System.out.print("#");
                    else System.out.print(".");
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 35892
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	vector<string> vs = { "Sunny", "Cloudy", "Rainy", "Sunny" };
	cin >> str;
	for (int i = 0; i < 4; i++)
	{
		if (str == vs[i])
		{
			cout << vs[i + 1] << endl;
			break;
		}
	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int min_num = 1000000000;
    int max_num = 0;
    for(int i=0; i < N; i++) {
        int tmp;
        cin >> tmp;
        min_num = min(min_num, tmp);
        max_num = max(max_num, tmp);
    }

    cout << max_num - min_num << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

void max_self(ll& a, ll b) {
	a = max(a, b);
}

int main() {
    int n, w;
    scanf("%d%d", &n, &w);
    vector<ll > dp(w + 1);
    for(int item = 0; item < n; ++item) {
		int weight, value;
		scanf("%d%d", &weight, &value);
		for(int weight_already = w - weight; weight_already >= 0; --weight_already) {
			max_self(dp[weight_already + weight], dp[weight_already] + value);
		}
	}
	ll answer = 0;
	for(int i = 0; i <= w; ++i) {
		max_self(answer, dp[i]);
	}
	printf("%lld\n", answer);
}


Measured memory_bytes: 1024
from collections import deque
from copy import copy,deepcopy
from itertools import permutations,combinations
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

n,m = myinput()
a = list(myinput())

s = sum(a)
th = s/(4*m)

a.sort(reverse=True)
# print(a)

if a[m-1]>=th:
    print("Yes")
else:
    print("No")

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

namespace arc077_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetInt();
            var a = GetIntList();
            var b = new List<int>();

            for(int i = 0; i < N; i++) 
                if (i % 2 == 0) b.Add(a[i]);
                else b.Insert(0, a[i]);

            if (N % 2 == 1) b.Reverse();

            Console.WriteLine(string.Join(" ", b));
        }

        public static string GetStr() => Console.ReadLine();
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());

        public static List<string> GetStrList() => Console.ReadLine().Split(' ').ToList();
        public static List<int> GetIntList() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        public static List<long> GetLongList() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        public static List<double> GetDoubleList() => Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
        public static List<decimal> GetDecimalList() => Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();

    }
}


Measured memory_bytes: 51544
//ALDS1_3_B Queue - Elementary data structures - Stack
#include <iostream>
#include <string>
using namespace std;

class Queue
{
  private:
    static const int MAX = 100005;

  public:
    Queue()
    {
        inisialize();
    }

private:
    int Q[MAX]{};
public:
    int head, tail;

  private:
    void inisialize()
    {
        head = tail = 0;
    }

    bool isFull()
    {
        return head == (tail+1) % MAX;
    }

  public:
    bool isEmpty()
    {
        return head == tail;
    }

    void enqueue(int x)
    {
        if (isFull())
        {
            //error
            throw runtime_error("Overflow");
        }
        Q[tail] = x;
        if ((tail + 1) == MAX)
        {
            tail = 0;
        }
        else
        {
            tail++;
        }
    }

    int dequeue()
    {
        if (isEmpty())
        {
            //error
            throw runtime_error("Underflow");
        }
        int x = Q[head];
        Q[head]=0;
        if ((head + 1) == MAX)
        {
            head = 0;
        }
        else
        {
            head++;
        }
        return x;
    }

    int num()
    {
        int res;
        if (tail >= head) {
            res = tail - head;
        } else {
            res = tail + MAX - head +1;
        }
        return res;
    }

    void print()
    {
        cout << "頭" << head << " 尾" << tail << " 空" << (int)isEmpty() << " 満" << (int)isFull()<<" 数"<< num() << " Q[";

        for (int i = 0; i < MAX; i++)
        {
            cout << Q[i] << " ";
        }
        cout << "]" << endl;
    }
};

int main()
{
    string s[100005];
    int t[100005];
    int num,time;
    Queue q;

    cin >> num >> time;

    for(int i = 0; i < num; i++)
    {
        cin >> s[i] >> t[i];
        q.enqueue(i);
    }

    int id;
    int totalTime = 0;
    while(!q.isEmpty())
    {
        id =q.dequeue();
        if(t[id]<=time) {
            cout << s[id]  << " " << totalTime + t[id] << endl;
            totalTime = totalTime + t[id];
        }
        else
        {
            t[id] -= time;
            q.enqueue(id);
            totalTime += time;
        }

    }
    return 0;
}


Measured memory_bytes: 6764
import sys
input = sys.stdin.readline
from collections import *

X, N = map(int, input().split())
p = list(map(int, input().split()))
s = set(p)
low = X-1000
high = X+1000
d = 10**18

for i in range(low, high+1):
    if i not in s:
        d = min(d, abs(X-i))
    
for i in range(low, high+1):
    if i not in s and abs(X-i)==d:
        print(i)
        exit()

Measured memory_bytes: 68080
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
}


Measured memory_bytes: 256
def main():
    NUM = input()
    
    numary = list(map(lambda x: int(x), input().split()))
    cnt = 0
    for i in range(len(numary)):
        if numary[i] != i + 1:
            cnt = cnt + 1

    if cnt == 0 or cnt == 2:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
def main():
    N, K = (int(i) for i in input().split())
    w = [int(input()) for i in range(N)]
    S = 0
    for i in range(N):
        S += w[i]

    def is_ok(P):
        w_i = 0
        for i in range(K):
            cur = 0
            while w_i < N :
                if cur + w[w_i] <= P:
                    cur += w[w_i]
                    w_i += 1
                else:
                    break
        if w_i == N:
            return True
        else:
            return False

    def binary_search_meguru():
        left = -1
        right = S + 1
        while right - left > 1:
            mid = left + ((right - left) // 2)
            if is_ok(mid): 
                right = mid
            else: 
                left = mid
        return right
    
    print(binary_search_meguru())


if __name__ == '__main__':
    main()


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;

struct edge { int to,cost; };

int main() {
  int N;cin>>N;
  vector<string> SS(N);
  REP(i,N) {
    cin>>SS[i];
    sort(ALL(SS[i]));
  }
  // 最初の文字列に出てくる文字ごとに、最小の数を検索していく
  set<char> cs;
  REP(i,SS[0].size()) cs.insert(SS[0][i]);
  string res;
  for (char c:cs) {
    int tmp = INT_MAX;
    REP(i,N) {
      int cnt = count(ALL(SS[i]),c);
      tmp = min(tmp, cnt);
    }
    REP(i,tmp) res.push_back(c);
  }
  OUT(res);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <numeric>
#include <stdint.h>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> V;

  for (int n=0; n<N; ++n) {
    int v;
    cin >> v;
    V.push_back(v);
  }

  int max_v = 0;

  for (int get = 0; get<=K && get<=N; ++get) {
    for (int get_left = 0; get_left <= get; ++get_left) {
      int get_right = get - get_left;
      vector<int> got_v;

      for (int k = 0; k < get_left; ++k) got_v.push_back(V[k]);
      for (int k = 0; k < get_right; ++k) got_v.push_back(V[N-k-1]);

      sort(got_v.begin(),got_v.end());

      for (int refund = 1; refund<=K-get && refund <= got_v.size(); ++refund) {	
	got_v[refund-1] = max(0,got_v[refund-1]);
      }

      max_v = max(max_v, accumulate(got_v.begin(), got_v.end(), 0));
    }
  }

  cout << max_v << endl;

  return 0;
}

# if 0

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

int main() {
    int N, K; cin >> N >> K;
    vector<ll> v(N); for (int i = 0; i < N; ++i) cin >> v[i];

    ll res = 0;

    for (int i = 0; i <= K; ++i) {
        for (int j = 0; i + j <= K; ++j) {
            if (i + j > N) continue;

            vector<ll> h;
            for (int k = 0; k < i; ++k) h.push_back(v[k]);
            for (int k = 0; k < j; ++k) h.push_back(v[N-k-1]);

            sort(h.begin(), h.end());

            int n = i + j;
            for (int k = 0; k < K - n && k < n; ++k) h[k] = max(0LL, h[k]);

            res = max(res, accumulate(h.begin(), h.end(), 0LL));
        }
    }

    cout << res << endl;
}

#endif


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	long long int n,y;
	scanf("%lld %lld",&n,&y);
	int flag=0;
	long long int i,j;
	for (i=0;i<10000;i++)
	{
		for (j=0;j<20000;j++)
		{
			if ((n-i-j)<0)
				continue;
			if (((n-i-j)*1000 + 5000*j + 10000*i)==y && (n-i-j + i + j)==n)
			{
				flag=1;
				printf("%lld %lld %lld",i,j,n-i-j);
				break;
			}
		}
		if (flag==1)
			break;
	}
	if (flag==0)
		printf("-1 -1 -1");
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

int main(void){
    int P,Q,R;
    cin>>P>>Q>>R;

    int ans=min(P+Q,min(Q+R,R+P));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
using namespace std;
typedef long long LL;
int main(){
    LL a,b,c,k;
    scanf("%d %d %d %lld",&a,&b,&c,&k);
    if(k%2==0)
    printf("%d\n",a-b);
    else
    printf("%d\n",b-a);
}




Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <map>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0;i<(n);++i)

int main() {
  int in(N);

  map<int, int> m;
  m[-1] = 0;
  m[N] = N;
  priority_queue<pii> q;
  rep(i, N) {
    int in(a);
    q.emplace(-a, i);
  }
  ll ans = 0;
  while (!q.empty()) {
    auto p = q.top(); q.pop();
    m[p.second] = p.second;
    ll l = (--m.lower_bound(p.second))->first, r = m.upper_bound(p.second)->first;
    ans += -1LL * (p.second - l) * (r - p.second) * p.first;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11248
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}


signed main(){
  int d,l;
  cin>>d>>l;
  int ans = d/l + d%l;
  cout<<ans<<endl;
  

  

  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define pb push_back
#define mk make_pair
#define ascSort(v) sort(v.begin(), v.end())
#define descSort(v) sort(v.begin(), v.end(), greater<int>())
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define umapi unordered_map<int,int>
#define INF 1000000007
//const int m=998244353;
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>PBDS;

void FIO(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
}



int32_t main(){
	
	//FIO();
	
		int n,m;cin>>n>>m;
		vi a(m);
		int sum=0;
		for(int i=0; i<m; i++){
			cin>>a[i];
			sum+=a[i];
		}
		if(sum>n)
			cout<<"-1\n";
		else
			cout<<n-sum<<"\n";
	
	return 0;
		
}
		
		



Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
//#include"functions.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define INF 1e9
#define LLINF 1e18
#define EPS 1e-5
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORN(a,m,n) for(int a=0;a<m;a+=n)
#define REP(a,m,n) for(int a=m;a<n;a++)
#define REPN(a,m,n,p) for(int a=m;a<n;a+=p)
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdfopen(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define ifopen(a) freopen(a,"r",stdin);
#define ofopen(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int p[100005];
bool b[100005];
bool vis[100005];
priority_queue<int,vector<int>,greater<int> > q[100005];
vector<int> a;
int find(int x){
	return (p[x]==x)?x:(p[x]=find(p[x]));
}
void conn(int x,int y){
	if(find(x)==find(y))return;
	x=find(x);
	y=find(y);
	p[y]=x;
}
int main(){
	//dsu,set
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)p[i]=i;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		conn(x,y);
	}
	int c=0;
	for(int i=0;i<n;i++){
		if(find(i)==i){
			c++;
			b[i]=1;
			//cout<<find(i)<<" "<<i<<endl;
		}
		int r=find(i);
		//cout<<r<<" "<<i<<" "<<a[i]<<endl;
		q[r].push(a[i]);
		//cout<<a[i]<<endl;
	}
	if(c==1){
		cout<<0<<endl;
		return 0;
	}
	if(n<2*(c-1)){
		cout<<"Impossible\n";
		return 0;
	}
	//cout<<c<<endl;
	ll ans=0;
	vector<int> v;
	vector<int> ca;
	for(int i=0;i<n;i++){
		if(b[i]){
			v.pb(q[i].top());
		}
		q[i].pop();
		int s=q[i].size();
		for(int j=0;j<s;j++){
			ca.pb(q[i].top());
			q[i].pop();
			//cout<<0;
		}
	}
	sort(ca.begin(),ca.end());
	for(int i=0;i<c-2;i++){
		v.pb(ca[i]);
	}
	for(int i=0;i<v.size();i++){
		//cout<<v[i]<<endl;
		ans+=v[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7416
a = list(map(int,input().split()))
if a[0] + a[1] == a[2] or a[2] + a[1] == a[0] or a[0] + a[2] == a[1]:
  print('Yes')
else:
  print('No')



  
  
  
  
    
  
  
  
  

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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n;
    cin>>n;
    long long int arr[n+1];
    fill(arr,arr+n+1,0);
    for(long long int i=1;i<=n;i++)
    {
        for(long long int k=i;k<=n;k+=i)
        {
            arr[k]++;

        }
    }
    long long int ans=0;
    for(long long int i=1;i<=n;i++)
    {
        ans+=i*arr[i];
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 81776
using System;

namespace ABC102_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = 0;
            if(a % 2 == 0)
            {
                b = a;
            }
            else
            {
                b = a * 2;
            }
            Console.WriteLine(b);
        }
    }
}


Measured memory_bytes: 11220
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int n = sc.nextInt();
        final int k = sc.nextInt();
        final int[] snuke = new int[n];
        for (int i = 0; i < k; i++) {
            final int d = sc.nextInt();
            for (int j = 0; j < d; j++) {
                final int a = sc.nextInt();
                snuke[a-1]++;
            }
        }

        System.out.println(IntStream.of(snuke).filter(i -> i == 0).count());
    }
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        String s = in.next();
        if (s.contains("RRR")) {
            out.println(3);
        }
        else if (s.contains("RR")) {
            out.println(2);
        }
        else if (s.contains("R")) {
            out.println(1);
        }
        else {
            out.println(0);
        }

        out.close();

    }


    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream i) {
            br = new BufferedReader(new InputStreamReader(i));
            st = new StringTokenizer("");
        }
        public String next() throws IOException {
            if (st.hasMoreTokens()) {
                return st.nextToken();
            }
            else
                st = new StringTokenizer(br.readLine());
            return next();
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public String nextLine() throws IOException {
            if (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
                return nextLine();
            }

            String ret = "";
            while (st.hasMoreTokens()) {
                ret += st.nextToken();
            }
            return ret;
        }
        public int[] nextIntArr(int size) throws IOException {
            int[] arr = new int[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        public long[] nextLongArr(int size) throws IOException {
            long[] arr = new long[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
        public double[] nextDoubleArr(int size) throws IOException {
            double[] arr = new double[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }
    }
}

Measured memory_bytes: 32924
n = int(input())
s = list(input())

result = 0
for i in range(1, n):
    maxLen = min(i, n-i)
    tmp = 0
    for j in range(n-i):
        if s[j] == s[j+i]:
            tmp += 1
        else:
            if result < tmp:
                result = tmp
            tmp = 0
        if tmp == maxLen:
            break
    if result < tmp:
        result = tmp
print(result)


Measured memory_bytes: 41820
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
using namespace std;

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> a(n);
    for (auto& i : a) scanf("%d", &i);
    for (int i = k; i < n; i++)
    {
        printf("%s\n", a[i] > a[i - k] ? "Yes" : "No");
    }
    return 0;
}

Measured memory_bytes: 4048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int num1 = Integer.parseInt(sc.next());
		int num2 = Integer.parseInt(sc.next());

		String answer = "NO";
		if (num1 >= num2 * 2 - 1) {
			answer = "YES";
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> istream& operator>>(istream &is, pair<S, T> &p){ return is >> p.first >> p.second; }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ return os << "[" << p.first << ", " << p.second << "]"; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rof(i, n) for(int i = (n)-1; i >= 0; i --)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
#define Return(x) { Cout(x); return 0; }

// constexpr int MOD = 1e9+7;
#include <queue>

int main(void){
    Cin(int, n);
    
    For(k, 500){
        if(k*(k-1)/2 == n){
            vc<vc<int>> ans(k, vc<int>(k, k-1));
            int x = 0;
            For(i, k-1) for(int j = i; j < k-1; j ++) ans[i][j+1] = ans[j+1][i+1] = ++x;
            Cout("Yes");
            Cout(k);
            For(i, k) Couts(ans[i]);
            return 0;
        }
    }
    Cout("No");
}


Measured memory_bytes: 2176
n = gets.chomp.to_i
input = gets.chomp.split(' ').map(&:to_i)
count = 0
input.each_with_index do |input_item, index|
  count += 1 unless input_item == index + 1
end
if count <= 2
  puts 'YES'
else
  puts 'NO'
end


Measured memory_bytes: 1788
import sys
from operator import itemgetter
from itertools import combinations, takewhile
from math import sqrt

def solve(a: list, sorted_axis: int = -1):
    length = len(a)
    if length <= 3:
        return min((x1-x2)**2+(y1-y2)**2 for (x1, y1), (x2, y2) in combinations(a, 2))

    x_set_len = len(set(x for x, _ in a))
    axis1 = 0 if x_set_len > length/2 else 1

    if sorted_axis != axis1:
        a.sort(key=itemgetter(axis1))

    mid_index = length//2
    left, right = a[:mid_index], a[mid_index:]
    delta = min(solve(left, axis1), solve(right, axis1))

    axis2 = not axis1
    median = a[mid_index][axis1]
    mid_a = sorted([p for _iter in (
        (takewhile(lambda p: median-sqrt(delta) < p[axis1], left[::-1])),
        (takewhile(lambda p: p[axis1] < median+sqrt(delta), right))
    ) for p in _iter], key=itemgetter(axis2))

    for i, (x1, y1) in enumerate(mid_a):
        ub = (x1 if axis1 else y1) + sqrt(delta)
        for x2, y2 in takewhile(lambda p: p[axis2] < ub, mid_a[i+1:]):
            delta = min(delta, (x1-x2)**2+(y1-y2)**2)

    return delta

if __name__ == "__main__":
    N = int(input())
    a = [tuple(map(int, l.split())) for l in sys.stdin.readlines()]
    print(solve(a))


Measured memory_bytes: 108288
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    cout << v[n / 2] - v[n / 2 - 1] << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<long long, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

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

	ll ans = 0;
	if (N % 2 == 0) {
		ll numerator = 5 * 2;
		for (int i = 0; i < 25; ++i) {
			ans += N / numerator;
			numerator *= 5;
			if (N < numerator)break;
		}
	}
	cout << ans << endl;
}

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

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = 998244353;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static long add(long a, long b) {
        return (a + b) % mod;
    }

    static long maxn = 200005;

    static void solve() {
        String s = sn();
        int n = s.length();
        int mask = 1 << (n - 1);
        long ans = 0;
        for (int i = 0; i < mask; i++) {
            long sum = 0;
            int prev = 0;
            for (int j = 0; j < n - 1; j++) {
                if ((i & (1 << j)) == 0) continue;
                long val = Long.parseLong(s.substring(prev, j + 1));
                sum += val;
                prev = j + 1;
            }
            sum += Long.parseLong(s.substring(prev, n));
            ans += sum;
        }
        out.println(ans);
    }
}

Measured memory_bytes: 21204
#include <cstdio>
#include <algorithm>
#define nmax 100005
using namespace std;
int n,a[nmax];
int s[nmax],d[nmax];

int main()
{
    int i,j,k;
    //freopen("date.in","r",stdin);
    scanf("%d",&n);
    for (i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for (i=1;i<=n;i++)
        s[i]=s[i-1]+abs(a[i]-a[i-1]);
    for (i=n;i>=1;i--)
        d[i]=d[i+1]+abs(a[i]-a[i+1]);

    for (i=1;i<=n;i++)
        printf("%d\n",s[i-1]+d[i+1]+abs(a[i-1]-a[i+1]));


    return 0;
}


Measured memory_bytes: 2304
# A 200
N,x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
remain = x
ans = 0
for i in range(len(a)):
    remain -= a[i]
    if i==N-1:
        if remain==0:
            ans += 1
    else:
        if remain>=0:
            ans += 1
        else:
            break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<string>
#define f(n) for(i=0;i<n;i++)
using namespace std;
string b,g;
int l,i,k,o,out;
bool f=true;
int main()
{
	cin>>b;
	l=b.size();
	f(l)
	{
		for(k=0;k<=i;k++)
		{
			for(o=k;o<=i;o++)
			{
				if((b.substr(o,1)!="A")&&(b.substr(o,1)!="T")&&(b.substr(o,1)!="C")&&(b.substr(o,1)!="G"))
				{
					f=false;
				}
			}
			if(f==false)
			{
				f=true;
				continue;
			}
			else
			{
				if(i-k+1>out)
				{
					out=i-k+1;
				}
			}
		}
	}
	cout<<out;
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int p[N];
    for(int i = 0; i < N; i++)
        cin >> p[i];
    
    int wrongTimes = 0;
    for(int i = 0; i < N; i++){
        if(p[i] != i+1){
            wrongTimes++;
        }
    }
    if(wrongTimes <= 2)
        cout << "YES" << "\n";
    else
        cout << "NO" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll,ll> P;

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

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }


int main() {
	int i;
	cin >> i;
	if (i) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
	return 0;
}


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

bool a[26];

int main() {
    string s;
    cin >> s;
    int n = s.size();
    for(int i=0; i<n; i++) {
        a[s[i] - 'a'] = true;
    }
    bool Find = false;
    for(int i=0; i<26 && !Find; i++) {
        if(!a[i]) {
            cout << (char)(i + 'a') << '\n';
            Find = true;
        }
    }
    if(!Find) cout << "None\n";
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool ex[13][1<<(12*2)];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string s,t;
    cin>>s>>t;
    int k=t.size(),tmp=0;
    for(int j=0;j<k;j++){
      tmp*=4;
      if(t[j]=='A') tmp+=0;
      if(t[j]=='C') tmp+=1;
      if(t[j]=='G') tmp+=2;
      if(t[j]=='T') tmp+=3;
    }
    if(s=="insert") ex[k][tmp]=1;
    else cout<<(ex[k][tmp]?"yes":"no")<<endl;
  }
  return 0;
}


Measured memory_bytes: 4544
N,P = list(map(int, input().split()))
a = list(map(int, input().split()))
num_odd = sum([i%2 == 1 for i in a])
num_even = N - num_odd
 
ce = 2 ** num_even
co = 2 ** (num_odd - 1)
if num_odd == 0:
    co = P^1
print(co * ce)

Measured memory_bytes: 9172