akhauriyash/Code-Regression huggingface dataset:
#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(){
  std::string S, T;
  std::cin >> S >> T;

  std::cout << T << S << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()

typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

bool edge[8][8];
bool visited[8];
int cnt = 0;
int n,m;


void init(){
    rep(i,n) visited[i] = 0;
    visited[0] = true;
}

bool check(){
    bool ans = 1;
    rep(i,n){
        if(!visited[i]) ans = 0;
    }
    
    return ans;
}

void dfs(int x){
    visited[x] = 1;
    if(check()) {
        cnt++;
        visited[x] = false;
        return;
    }
    
    rep(i,n){
        if(edge[x][i] and !visited[i]){
            dfs(i);
        }
    }
    visited[x] = false;
    
    return;
}



int main(){
    cin >> n >> m;
    
    rep(i,m){
        int x,y;
        cin >> x >> y;
        
        edge[x-1][y-1] = edge[y-1][x-1] = 1;
    }
    
    init();
    dfs(0);
    
    cout << cnt << endl;
}






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

// 小数点以下桁数
// fixed << setprecision(i)

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

int main()
{
  int n, max_h = 0, flag = 0, h;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> h;
    flag = max(flag, max_h - h);
    max_h = max(max_h, h);
  }
  cout << (flag <= 1 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3552
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N, max=0;
	
	cin >> N;
	
	int A[N];
	
	for(int i=0; i<N; i++)
		cin >> A[i];
	
	
	
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			if(abs(A[i]-A[j]) > max){
				max = abs(A[i]-A[j]);
			}
		}
	}
	
	cout << max;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>

using namespace std;

int memo[100][100];
int memo2[100][100][2];
char s[100][100];
int h, w;

int search(int i, int j) {

	if (memo[i][j] != -1) return memo[i][j];

	if (i == h - 1 && j == w - 1) return int(s[i][j] == '#');
	else if (i == h - 1) {
		memo[i][j] = search(i, j + 1) + (s[i][j] == '#');
		return memo[i][j];
	}
	else if (j == w - 1) {
		memo[i][j] = search(i + 1, j) + (s[i][j] == '#');
		return memo[i][j];
	}
	else {
		int tmp = search(i, j + 1);
		memo[i][j] = search(i + 1, j);
		if (tmp < memo[i][j])memo[i][j] = tmp;
		memo[i][j] += int(s[i][j] == '#');
		return memo[i][j];
	}

	return -1;
}

int search2(int i, int j, int pre_flag) {
	if (memo2[i][j][pre_flag] != -1) return memo2[i][j][pre_flag];
	int flag = (s[i][j] == '#');

	if (i == h - 1 && j == w - 1) {
		memo2[i][j][pre_flag] = flag * !pre_flag;
		return memo2[i][j][pre_flag];
	}
	else if (i == h - 1) {
		memo2[i][j][pre_flag] = search2(i, j + 1, flag) + flag * !pre_flag;
		return memo2[i][j][pre_flag];
	}
	else if (j == w - 1) {
		memo2[i][j][pre_flag] = search2(i + 1, j, flag) + flag * !pre_flag;
		return memo2[i][j][pre_flag];
	}
	else {
		int tmp = search2(i, j + 1, flag);
		memo2[i][j][pre_flag] = search2(i + 1, j, flag);
		if (tmp < memo2[i][j][pre_flag])memo2[i][j][pre_flag] = tmp;
		memo2[i][j][pre_flag] += flag * !pre_flag;
		return memo2[i][j][pre_flag];
	}

	return -1;
}

int main() {

	cin >> h >> w;
	for (int i=0; i < h; i++) {
		for (int j=0; j < w; j++) {
			cin >> s[i][j];
			memo[i][j] = -1;
			memo2[i][j][0] = -1;
			memo2[i][j][1] = -1;
		}
	}
	cout << search2(0, 0, 0) << endl;

	//for (int i = 0; i < h; i++) {
	//	for (int j = 0; j < w; j++) {
	//		cout << s[i][j];
	//	}
	//	cout << endl;
	//}
	//cout << "~~~~~~~~" << endl;
	//for (int i = 0; i < h; i++) {
	//	for (int j = 0; j < w; j++) {
	//		cout << memo[i][j];
	//	}
	//	cout << endl;
	//}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    int root;
    cin >> root;
    if (root != 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<long long> v(n);
    v[0] = 1;
    int ma = 0;
    for (int i = 1; i < n; i++) {
        int d;
        cin >> d;
        v[d]++;
        ma = max(ma, d);
    }

    if (v[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    long long ret = 1;
    for (int i = 1; i <= ma; i++) {
        for (int j = 0; j < v[i]; j++) {
            ret *= v[i - 1];
            ret %= 998244353;
        }
    }

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

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
#include<bitset>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}

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

int main(){
  ll N;
  cin>>N;
  ll T[N];
  for(ll i=0; i<N; ++i){
    cin>>T[i];}
    ll ans=T[0];
    for(ll i=0; i<N; ++i){
    ans=lcm(ans,T[i]);
    }
    cout<<ans<<endl;
}

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

int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int k,p;
        cin >> k >> p;
        if(k%p==0) cout << p << endl;
        else cout << k%p <<endl;
    }
    return 0;
}



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

using namespace std;

int main(){

    int n;
    string s[50];
    int t[50];
    string x;
    long long int ans = 0;

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> s[i] >> t[i];
    }

    cin >> x;

    int f_sleep = 0;
    for(int i = 0; i < n; i++){
        if(f_sleep){
            ans += t[i];
        }
        if(!x.compare(s[i])){
            f_sleep = 1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
import math
n,d=list(map(int,input().split()))
x=[list(map(int,input().split())) for i in range(n)]
count=0
tmp=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(d):
            tmp+=pow(x[i][k]-x[j][k],2)
        distance=math.sqrt(tmp)
        if distance.is_integer()==True:
            count+=1
        tmp=0
print(count)

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

int main() {
  int A, a, B, j, x;
  x=0;//回文数の総数
  cin >> A >> B;
  a=A;
  j=B-A+1;
  for(int i=0; i<j; i++){
    if(a%10 == a/10000){
      if(a/10%10 == a/1000%10){
        x++;
      }
    }
    a++;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<int> a(1e5+2);
    rep(i, n) {
        int tmp_a;
        cin >> tmp_a;
        ++a[tmp_a];
    }
    int max_num = 0;
    rep(i, 1e5) {
        max_num = max(max_num, a[i] + a[i+1] + a[i+2]);
    }
    cout << max_num << endl;
    return 0;
}


Measured memory_bytes: 640
from functools import reduce

def gcd(x, y):
    if x >= y:
        while y != 0:
            x, y = y, x % y
        return x
    else:
        while x != 0:
            y, x = x, y % x
        return y


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers)

n = int(input())
l = []

for i in range(n):
    a = int(input())
    l.append(a)

print(lcm(*l))

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
    long long a = rng();
    return a;
}

int a, b, m, mina, minb;
int v[100002], v2[100002];
int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> a >> b >> m;
    for(int i = 1; i <= a; ++i)
    {
        cin >> v[i];
        if(i == 1)
            mina = v[i];
        else
            mina = min(mina, v[i]);
    }
    for(int i = 1; i <= b; ++i)
    {
        cin >> v2[i];
        if(i == 1)
            minb = v2[i];
        else
            minb = min(minb, v2[i]);
    }
    int ans = mina + minb;
    for(int i = 1; i <= m; ++i)
    {
        int aa, bb, cc;
        cin >> aa >> bb >> cc;
        ans = min(ans, v[aa] + v2[bb] - cc);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
l,r=map(int,input().split())
s=[]
i=0
j=0
if (r-l)>4038:
    while i!=(r-l)+1 and i!=2019:
        while j!=(r-l)+1 and j!=2019:
            s.append(((l+i)*(l+j))%2019)
            j+=1
        j=0
        i+=1
    print(min(s))
else:
    while i!=(r-l)+1:
        while j!=(r-l)+1:
            if i!=j:
                s.append(((l+i)*(l+j))%2019)
            j+=1
        j=0
        i+=1
    #print(s)
    print(min(s))

Measured memory_bytes: 130660
using System;
using System.Collections.Generic;
using static Assistant.Input;
using System.Linq;
using Assistant;
using System.Text;

namespace Temp20200521
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = ReadInt;
            int q = ReadInt;

            BIT bit = new BIT(n);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < q; i++)
            {
                if (ReadInt == 0)
                {
                    int k = ReadInt;
                    bit.Add(k, k, ReadInt);
                }
                else
                {
                    sb.AppendLine(bit.Sum(ReadInt, ReadInt).ToString());
                }
            }

            Console.Write(sb);
        }


    }

    class BIT
    {
        long[] bit0, bit1;  //1-indexed
        int n;
        public BIT(int n)
        {
            bit0 = new long[n + 1];
            bit1 = new long[n + 1];
            this.n = n;
        }

        public long Sum(int l, int r)
        {
            long ret = 0;
            ret += Sum(bit0, r) + Sum(bit1, r) * r;
            ret -= Sum(bit0, l - 1) + Sum(bit1, l - 1) * (l - 1);
            return ret;
        }

        long Sum(long[] bit, int i)
        {
            long s = 0;
            while (i > 0)
            {
                s += bit[i];
                i -= i & -i;
            }
            return s;
        }

        public void Add(int l, int r, int a)
        {
            Add(bit0, l, -a * (l - 1));
            Add(bit1, l, a);
            Add(bit0, r + 1, a * r);
            Add(bit1, r + 1, -a);
        }

        void Add(long[] bit, int i, int a)
        {
            while (i <= n)
            {
                bit[i] += a;
                i += i & -i;
            }
        }
    }

}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
}



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

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    vector<pair<ll,ll>> xl;
    for(int i=0; i<n; i++){
        ll x,l;
        cin >> x >> l;
        xl.push_back(make_pair(x+l,x-l));
    }
    sort(xl.begin(),xl.end());
    ll now = -1000000100;
    for(int i=0; i<n; i++){
        if(now > xl.at(i).second) continue;
        ans++;
        now = xl.at(i).first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
import sys
import itertools

N = int(input())

d = 0
for a in range(1, N):
    for b in range(1, N):
        ab = a * b
        if ab > N or N-ab==0:
            break
        for c in range(N-ab, N):
            if ab + c == N:
                d += 1
            if ab + c > N:
                break
print(d)

Measured memory_bytes: 73480
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h> 
typedef  long long ll;
#define length 100000+3000 //10万
#define kw_len 10+2
int main(){
    int N,K,i,j,M,D;
    ll sum=0;
    scanf("%d%d",&M,&D);
    for(i=3;i<=M;i++){
        for(j=22;j<=D;j++){
            N=j/10;
            K=j-(N*10);
            if((N*K)==i){
                sum++;
            }
            if(N>=i){
                break;
            }
        }
    }
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 128
(defun a-s ()
  (let* ((n (read))
         (k (read))
         (q (read))
         (lose-line q))
    (setf as (make-array n :initial-element k))
    (dotimes (i q)
      (incf (aref as (1- (read)))))
    (dotimes (i n)
      (if (> (aref as i) lose-line)
          (format t "~a~%" "Yes")
          (format t "~a~%" "No")))))

(a-s)

Measured memory_bytes: 58212
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	A = int(input())
	B = int(input())
	C = int(input())
	D = int(input())
	
	ans = min(A,B) + min(C,D)
		
	print(ans)
			
	
if __name__ == "__main__":
	main()


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL N, K;
int bb[4010][4010];
int ww[4010][4010];

int bacc[4010][4010];
int wacc[4010][4010];
int bsum(int x1, int y1, int x2, int y2){
  return bacc[y2][x2] - bacc[y2][x1] - bacc[y1][x2] + bacc[y1][x1];
}
int wsum(int x1, int y1, int x2, int y2){
  return wacc[y2][x2] - wacc[y2][x1] - wacc[y1][x2] + wacc[y1][x1];
}

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

  cin >> N >> K;

  int K2 = K * 2;
  REP(i,N){
	int x, y;
	char c;
	cin >> x >> y >> c;
	x %= K2;
	y %= K2;
	if(c == 'B'){
	  bb[y][x]++;
	  bb[y+K2][x]++;
	  bb[y][x+K2]++;
	  bb[y+K2][x+K2]++;
	}
	else{
	  ww[y][x]++;
	  ww[y+K2][x]++;
	  ww[y][x+K2]++;
	  ww[y+K2][x+K2]++;
	}
  }

  REP(y,K2*2) REP(x,K2*2){
	bacc[y+1][x+1] += bb[y][x] + bacc[y+1][x] + bacc[y][x+1] - bacc[y][x];
	wacc[y+1][x+1] += ww[y][x] + wacc[y+1][x] + wacc[y][x+1] - wacc[y][x];
  }

  int ans = 0;
  REP(y1,K2) REP(x1,K2){
	int x2 = x1 + K, y2 = y1 + K;
	int sum = bsum(x1, y1, x2, y2) + bsum(x2, y2, x2+K, y2+K);
	sum += wsum(x2, y1, x2+K, y2) + wsum(x1, y2, x2, y2+K);

	//cout<<x1<<","<<y1<<":"<<sum<<endl;
	maxi(ans, sum);
  }
  cout << ans << endl;

  return 0;
}


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

#define rep(i, ns, ne) for (ll i = ns; i < ne; ++i)

ll N;
Vl a;
Vl b;

void input() {
  cin >> N;
  a.resize(N);
  b.resize(N);
  int x, y;
  rep(i, 0, N) {
    cin >> x >> y;
    a[i] = x + y;
    b[i] = x - y;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
}

void solve() {
  cout << max(a.back() - a.front(), b.back() - b.front()) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  input();
  solve();
  getchar();
  return 0;
}

Measured memory_bytes: 6336
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int a, b, c; cin >> a >> b >> c;
    rep(i, 1000000){
        if((a*(i+1))%b == c){
            pr("YES");
            return 0;
        }
    }

    pr("NO");
    return 0;}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  ll N = nextLong();
  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }


  ll M = N / 2;
  ll ans = 0;
  while (M > 0) {
    ans += M / 5;
    M /= 5;
  }
  cout << ans << endl;


  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

int main(){
	while(1){
		string Previous;
		cin >> Previous;
		if(Previous == "-") break;
		
		int m;
		cin >> m;
		vector<int> h;
		for(int i = 0; i < m; i++){
			int g;
			cin >> g;
			h.push_back(g);
		}
		
		char After[200];
		int n = Previous.size();
		for(int i = 0; i < m; i++){
			for(int j = h[i]; j < n; j++) After[j-h[i]] = Previous[j];
			for(int j = 0; j < h[i]; j++) After[n-h[i]+j] = Previous[j];
			for(int j = 0; j < n; j++) Previous[j] = After[j];
		}
		
		for(int i = 0; i < n; i++) cout << After[i];
		cout << endl;
	}
		
	return 0;
}	

Measured memory_bytes: 1228
// Sakhiya07 - Yagnik Sakhiya

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 200005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    char c;
    cin >> c;
    if(c>='a')   cout<<'a';
    else         cout<<"A";    
}

int main()
{
    FAST;
    ll t = 1;
   // cin >> t;
    while(t--)
    {
        solve();
    }
}

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

int main (){
  int K, A, B;
  cin >> K >> A >> B;
  
  bool can=false;
  for (int i = A; i <= B; i++){
    if (i % K ==0){
      can = true;
      break;
    }
  }
  
  if (can) {
    cout << "OK" << endl;
  }
  else {
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3680
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline().strip()

def C(first, last, ndigs, N):
    ans = 0
    curr = first * 10 ** (ndigs - 1) + (last if ndigs > 1 else 0)
    incs = 0
    while curr <= N and incs < 10 ** (ndigs - 1):
        ans += 1
        curr += 10
        incs += 10
    return ans

def solve(N: int):
    ndigs = len(str(N))
    ans = 0
    for ndigsA in range(1, ndigs + 1):
        for ndigsB in range(1, ndigs + 1):
            for first in range(1, 10):
                for last in range(1, 10):
                    if (ndigsA > 1 and ndigsB > 1) or first == last:
                        ans += C(first, last, ndigsA, N) * C(last, first, ndigsB, N)
    print(ans)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40688
#include <stdio.h>

int main(){
	double n;
	int a[6]={};
	int c;
	scanf("%d", &c);
	int i;
	for(i=0;i<c;i++){
		scanf("%lf", &n);
		if(n<165){
			a[0]+=1;
		}else if(n<170){
			a[1]+=1;
		}else if(n<175){
			a[2]+=1;
		}else if(n<180){
			a[3]+=1;
		}else if(n<185){
			a[4]+=1;
		}else{
			a[5]+=1;
		}
	}
	int j;
	for(i=0;i<6;i++){
		printf("%d:", i+1);
		for(j=0;j<a[i];j++){
			printf("*");
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 644
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    A=list(map(int,input().split()))
    S=[0]*(N+1)
    d=defaultdict(int)
    d[0]+=1
    ans=0
    for i in range(N):
        S[i+1]=(S[i]+A[i])%M
        ans+=d[S[i+1]]
        d[S[i+1]]+=1
    print(ans)

if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO() \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 
 
int main() {
    int n, w;
    cin >> n >> w;
    vi wt(n), v(n);
    for (int i = 0; i < n; ++i) {
        cin >> wt[i] >> v[i];
    }
    ll dp[100010];
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < n; ++i) {
        for (int j = w - wt[i]; j >= 0; --j) {
            dp[j + wt[i]] = max(dp[j + wt[i]], dp[j] + v[i]);
        }
    }
    ll ans = 0;
    for (int i = 0; i <= w; ++i)    ans = max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7) PRI("YES");
	else PRI("NO");
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int N, A, B;
  cin >> N >> A >> B;

  int64_t ans = 0;
  for (int i = 1; i <= N; ++i) {
    int n = i;
    int sum = 0;
    while (n > 0) {
      sum += n % 10;
      n /= 10;
    }
    if (A <= sum && sum <= B) {
      ans += i;
    }
  }
  cout << ans << '\n';
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
ll dp[105][2];
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin>>a[i];

	dp[0][0] = 1;
	rep(i,n){
		if(a[i] % 2) {
			dp[i+1][0] = dp[i][0];
			dp[i+1][1] = dp[i][1] * 3 + dp[i][0] * 2;
		}
		else{
			dp[i+1][0] = dp[i][0] * 2;
			dp[i+1][1] = dp[i][1] * 3 + dp[i][0];
		}
	}
	cout << dp[n][1] << endl;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s.back() << endl;
    
    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] odd = scanner.nextLine().split("");
        String[] even =  scanner.nextLine().split("");
        StringBuffer ans = new StringBuffer();
        for (int i = 0; i < odd.length; i++) {
            ans.append(odd[i]);
            if (even.length > i) {
                ans.append(even[i]);
            }
        }
        System.out.println(ans.toString());
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;


int main(void){
	int x,y,z,k;
	cin>>x>>y>>z>>k;
	ll a[x],b[y],c[z],bc[y*z],e[k*k];
	rep(i,x)cin>>a[i];
	rep(i,y)cin>>b[i];
	rep(i,z)cin>>c[i];
	rep(i,y){
		rep(j,z){
			bc[i*z+j]=b[i]+c[j];
		}
	}
	
	sort(a,a+x);
	sort(bc,bc+y*z);
	//rep(i,x)cout<<i<<":"<<a[i]<<endl;
	//rep(i,y*z)cout<<i<<":"<<bc[i]<<endl;
	int tmp1=k,tmp2=k;
	if(x<tmp1)tmp1=x;
	if(y*z<tmp2)tmp2=y*z;
	//cout<<"tmp1="<<tmp1<<endl;
	//cout<<"tmp2="<<tmp2<<endl;
	rep(i,tmp1){
		rep(j,tmp2){
			e[i*tmp2+j]=a[x-1-i]+bc[y*z-1-j];
		}
	}
	sort(e,e+tmp1*tmp2);
	//rep(i,tmp1*tmp2)cout<<i<<":"<<e[i]<<endl;

	//rep(i,x)cout<<a[x-1-i];
	rep(i,k)cout<<e[tmp1*tmp2-1-i]<<endl;

	return 0;
}


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

int main(){
  string S;
  cin >> S;
  int L=S.size();
  int cnt=0;
  char t;
  for(int i=0; i<L-1; i++){
    if(S.at(i)==S.at(i+1)){
      cnt++;
      if(S.at(i+1)=='0') S.at(i+1)='1';
      else S.at(i+1)='0';
    }
  }
  int ans = min(cnt, L-cnt);
  cout << ans << endl;
}

Measured memory_bytes: 512
import sys
S= input()
x = len(S)
odd = ['R','U','D']
even = ['L','U','D']
for i in range(x):
  if i%2 == 0:
    if S[i] not in odd:
      print('No')
      sys.exit()
  else:
    if S[i] not in even:
      print('No')
      sys.exit()
print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
   ll x,y,c=0;
   cin>>x>>y;
   
   if(x>=0&&y>=0&&x<y)
   {
    cout<<y-x<<endl;
   }
   else if(x>=0&&y>=0&&x>y)
   {
    if(y==0)
      cout<<x-y+1<<endl;
    else
      cout<<x-y+2<<endl;

   }
    
  else if(x>=0&&y<0)
  {
    
     if(abs(y)>=x)
    {
      cout<<abs(y)-abs(x)+1<<endl;
    }
    else
    {
      cout<<abs(x)-abs(y)+1<<endl;
    }
    
  }
  else if(x<0&&y>=0)
  {  
    if(y==0)
    {
      cout<<abs(x)<<endl;
    }
    else if(abs(x)>=y)
    {
      cout<<abs(x)-abs(y)+1<<endl;
    }
    else
    {
      cout<<abs(y)-abs(x)+1<<endl;
    }
  }
  else if(x<0&&y<0)
  {
    if(y<x)
    {
      cout<<abs(y)-abs(x)+2<<endl;
    }
    else
    {
      cout<<abs(x)-abs(y)<<endl;
    }
  }


}
return 0;
}


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

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

Measured memory_bytes: 9596
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 200020
#define INF 1000001000
using namespace std;
int read(){
	int nm=0,fh=1; int cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
int tot,n,m,pos[M],L[M][21],R[M][21],V[40],rt;
int RF[M<<3],LF[M<<3],G[M],D[M],MAXN;
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++) pos[i]=read(),D[i]=pos[i]-pos[i-1],G[i]=-(INF<<1);
	while(m) V[tot++]=m,m>>=1; tot++;
	for(int k=0;k<tot;k++){
		for(int i=1;i<=n;i++){
			R[i][k]=max(R[i-1][k]-1,1);
			while(i+R[i][k]<=n&&D[i+R[i][k]]<=V[k]) R[i][k]++;
		}
		for(int i=n;i;i--){
			L[i][k]=max(L[i+1][k]-1,1);
			while(i-L[i][k]>0&&D[i-L[i][k]+1]<=V[k]) L[i][k]++;
		}
	} MAXN=(1<<tot);
	for(int i=2;i<MAXN;i+=2){
		for(int k=1;k<tot;k++){
			int w=(1<<k); if(!(i&w)) continue;
			LF[i]=max(LF[i],LF[i^w]+R[LF[i^w]+1][k]);
			RF[i]=max(RF[i],RF[i^w]+L[n-RF[i^w]][k]);
		} LF[i]=min(LF[i],n),RF[i]=min(RF[i],n);
	}
	for(int k=0;k<MAXN;k+=2) G[LF[k]]=max(G[LF[k]],RF[(MAXN-2)^k]);
	for(int i=n-1;i>=0;i--) G[i]=max(G[i],G[i+1]);
	for(int i=1;i<=n;i++) puts(G[i-L[i][0]]+R[i][0]+i-1>=n?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 45952
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // double
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647

int main() {
  kyun;
  int n;
  cin >> n;
  vi data(n);
  rep(i,n) cin >> data[i];
  vi ans(n,inf);
  rep(i,n) {
      auto itr = lower_bound(all(ans), data[i]);
      int iter = itr - ans.begin();
      ans[iter] = data[i];
  }
  int ret = 0;
  rep(i,n) if(ans[i] != inf) ret++;
  cout << ret;
  hinata;
}


Measured memory_bytes: 3636
package main

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

type Scanner struct {
	innerScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := new(Scanner)
	innerScanner := bufio.NewScanner(os.Stdin)
	innerScanner.Split(bufio.ScanWords)
	sc.innerScanner = innerScanner
	return sc
}

func (sc Scanner) scan() {
	sc.innerScanner.Scan()
}

func (sc Scanner) next() string {
	return sc.innerScanner.Text()
}

func (sc Scanner) nextInt() int {
	sc.scan()
	i, _ := strconv.Atoi(sc.next())
	return i
}

func (sc Scanner) nextFloat() float64 {
	sc.scan()
	f, _ := strconv.ParseFloat(sc.next(), 64)
	return f
}

func main() {
	sc := NewScanner()
	A := sc.nextInt()
	B := sc.nextInt()
	ans := A * B - (A + B - 1)
	fmt.Println(ans)
}

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

int main()
{
    int N,M;
    vector<stack<int>> room;
    
    cin >> N >> M;
    room.resize(N+1);
    int a,b;
    /*rep(i,N+1){
        rep(j,N+1){
            room[i][j]=false;
        }
    }*/
    rep(i,M){
        cin >> a>>b;
        room[a].push(b);
        room[b].push(a);
    }
    vector<int> visit;
    visit.resize(N+1);
    visit[0]=0;
    rep(i,N+1){
        visit[i]=0;
    }
    int now_room;
    queue<int> q;
    q.push(1);
    int count=0;
    while(!q.empty()){
        now_room=q.front();
        q.pop();
        while(!room[now_room].empty()){
            int next_room=room[now_room].top();
            room[now_room].pop();
            if(visit[next_room]==0){
                q.push(next_room);
                visit[next_room]=now_room;
            }
        }

        
    }
    bool result=true;
    for(int i=2;i<=N;++i){
        if(visit[i]==0){
            result=false;
            break;
        }
    }
    if(result){
        cout << "Yes" << endl;
        for(int i=2;i<=N;++i){
            cout << visit[i] << endl;
        }
    }else{
        cout << "No" << endl;
    }


}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    string s;
    int x, y;
    cin >> s >> x >> y;
    int x0 = 0, y0 = 0;
    int idx = 0;
    while (idx < SZ(s)) {
        if (s[idx] == 'T') break;
        x0++;
        idx++;
    }
    vector<PII> V;
    while (idx < SZ(s)) {
        int cnt = 0;
        while (idx < SZ(s) && s[idx] == 'T') {
            cnt++;
            idx++;
        }
        int cntF = 0;
        while (idx < SZ(s) && s[idx] == 'F') {
            cntF++;
            idx++;
        }
        V.pb({cnt, cntF});
    }
    VI hor, ver;
    bool horiz = 1;
    REP(i, SZ(V)) {
        if (horiz) {
            if (V[i].first % 2 == 1) {
                horiz = 0;
                ver.pb(V[i].second);
            } else {
                hor.pb(V[i].second);
            }
        } else {
            if (V[i].first % 2 == 1) {
                horiz = 1;
                hor.pb(V[i].second);
            } else {
                ver.pb(V[i].second);
            }
        }
    }
    int offset = 8000;
    int dp[SZ(hor) + 1][16000];
    memset(dp, -1, sizeof(dp));
    dp[0][offset] = 1;
    FOR(i, 1, SZ(hor)) {
        FOR(j, 0, 15999) {
            if (dp[i - 1][j] == 1) {
                dp[i][j - hor[i - 1]] = 1;
                dp[i][j + hor[i - 1]] = 1;
            }
        }
    }
    int dp1[SZ(ver) + 1][16000];
    memset(dp1, -1, sizeof(dp1));
    dp1[0][offset] = 1;
    FOR(i, 1, SZ(ver)) {
        FOR(j, 0, 15999) {
            if (dp1[i - 1][j] == 1) {
                dp1[i][j - ver[i - 1]] = 1;
                dp1[i][j + ver[i - 1]] = 1;
            }
        }
    }
    if (dp[SZ(hor)][x - x0 + offset] == 1 && dp1[SZ(ver)][y - y0 + offset] == 1) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    cout << endl;

}

Measured memory_bytes: 250496
# coding: utf-8
# Your code here!

for i in range(4) :
   t, n = map(int, input().split())
   if t == 1:
      print(n * 6000)
   elif t == 2:
      print(n * 4000)
   elif t == 3:
      print(n * 3000)
   else:
      print(n * 2000)



Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;

int main()
{
	ll N, M;
	ll ans = 0;
	cin >> N >> M;
	if (N >= M/2)
	{
		ans += M / 2;
	}
	else
	{
		ans += N;
		M -= 2 * N;
		N = 0;
		ans += M / 4;
	}

	cout << ans;
}


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

using namespace std;

int a[100001],ans,n;
int dispo=1;
bool c[100001];

int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        if(dispo==2){
            printf("%d",ans);
            return 0;
        }else if(c[dispo]==1){
            puts("-1");
            return 0;
        }
        c[dispo]++;
        dispo=a[dispo];
        ans++;
    }
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T>
constexpr T INF = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T, typename U> istream& operator>>(istream& in, pair<T, U>& a) { cin >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& in, vector<T>& a) { for (T& x : a) cin >> x; }

void LOG(const int& x) { cerr << x << "\n"; }
void LOG(const vector<int>& a) { for (int x : a) cerr << x << " "; cerr << "\n"; }

int ceil(int a, int b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }

#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

class UnionFind { private: vector<int> par; vector<int> rnk; int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); } public: UnionFind(int size) { par.resize(size); rnk.resize(size); REP(i, size) par[i] = i, rnk[i] = 0; } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rnk[x] < rnk[y]) { par[x] = y; } else { par[y] = x; if (rnk[x] == rnk[y]) rnk[x]++; } } bool same(int x, int y) { return find(x) == find(y); } };

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

i64 d(i64 a) {
  return log10(a) + 1;
}

signed main() {
  i64 n;
  cin >> n;
  i64 r = INF<i64>;
  for (i64 a = 1; a * a <= n; a++) {
    if (n % a) continue;
    i64 b = n / a;
    r = min(r, max(d(a), d(b)));
  }
  cout << r << endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python3

from heapq import heappop, heappush

h, w = list(map(int, input().split()))

map_list = [list(str(input())) for _ in range(h)]

ans = 0
for h1 in range(h):
    for w1 in range(w):
        D = [[False]*w for i in range(h)]
        Q = [(0, (h1, w1))]
        while Q:
            q = heappop(Q)
            qh, qw = q[1][0], q[1][1]
            if qh < 0 or qh >= h or qw < 0 or qw >= w:
                continue
            if map_list[qh][qw] == "#":
                continue
            if D[qh][qw]:
                continue
            D[qh][qw] = True
            ans = max(q[0], ans)
            heappush(Q, (q[0]+1, (qh+1, qw)))
            heappush(Q, (q[0]+1, (qh-1, qw)))
            heappush(Q, (q[0]+1, (qh, qw+1)))
            heappush(Q, (q[0]+1, (qh, qw-1)))
print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    ll int n;
    cin>>n;
    ll int w=1,x=1,y=1,i;
    if(n<=1)
    	{cout<<0;exit(0);}
    ll int val,ans;
    for(i=1;i<=n;i++)
    {
    	w=((w%MOD)*(10%MOD))%MOD;
    	x=((x%MOD)*(9%MOD))%MOD;
    	y=((y%MOD)*(8%MOD))%MOD;
    }
   // cout<<w<<" "<<y<<" "<<x<<endl;
    val=((2*x)%MOD-y%MOD)%MOD;
    ans=(w-val+MOD)%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

int N;
int t[110],v[110];
double vmax[40010];
int sumt[110];
double ans;
int main() {
    cin>>N;
    REP(i,0,N){
        cin >> t[i];
        sumt[i+1] = sumt[i] + t[i];
    }
    REP(i,0,N) cin>>v[i];
    REP(i,0,sumt[N]*2+1) vmax[i]=inf;
    REP(i,0,N) {
        REP(j, sumt[i]*2, sumt[i+1]*2+1) {
            vmax[j] = min<double>(vmax[j], v[i]);
        }
    }
    vmax[0] = 0;

    REP(i,1,sumt[N]*2+1){
        vmax[i] = min<double>(vmax[i], vmax[i-1] + 0.5);
    }

    vmax[sumt[N]*2]=0;
    RREP(i,0,sumt[N]*2){
        vmax[i] = min<double>(vmax[i], vmax[i+1] + 0.5);
    }
    REP(i,1,sumt[N]*2+1){
        ans += (vmax[i] + vmax[i-1]);
    }
    ans/=4;
    printf("%.4lf\n", ans);
    return 0;
}

Measured memory_bytes: 512