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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ABCD = ReadSplitInt();
            var A = ABCD[0];
            var B = ABCD[1];
            var C = ABCD[2];
            var D = ABCD[3];
            if (A + B == C + D) Println("Balanced");
            else if (A + B > C + D) Println("Left");
            else if (A + B < C + D) Println("Right");
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


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

using namespace std;

int a[60],b[60],c[60],d[60];

int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>c[i]>>d[i];
    }

    for(int i=1;i<=n;i++)
    {
        int ans=1000000000;
        int k;
        for(int j=1;j<=m;j++)
        {
            int t=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(t<ans){
                ans=t;
                k=j;
            }
        }
        cout<<k<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,z,w;
  cin>>n>>z>>w;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll cnt1=abs(a[n-1]-w),cnt2=0;
  if(n>=2) cnt2=abs(a[n-1]-a[n-2]);
  cout<<max(cnt1,cnt2)<<endl;
}

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


int main(void){
    int n;
    cin >> n;
    int ans =0;
    if(n%111==0){
        ans = n;
    }
    else{
        ans =  n+111-n%111;
    }
    cout << ans <<endl;
    
    return 0;
}












































Measured memory_bytes: 256
#include<iostream>
using namespace std;
int i,m,n,p,x,t[102];
int sum=0;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	 {cin>>t[i];sum+=t[i];}
	cin>>m;
	for(i=1;i<=m;i++)
	{
		cin>>p>>x;
		cout<<sum-t[p]+x<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    string S; cin >> S;
    S[K-1] = char(S[K-1] -'A' + 'a');
    cout << S << endl;
}

Measured memory_bytes: 256
//package com.beginner.b049;
import java.util.HashMap;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

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

        int N,K,L;
        N = sc.nextInt();
        K =sc.nextInt();
        L = sc.nextInt();

        UnionFind rail = new UnionFind(N);
        UnionFind road = new UnionFind(N);

        for(int i = 0 ;i < K;i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            rail.union(x-1,y-1);
        }

        for(int i = 0 ;i < L;i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            road.union(x-1,y-1);
        }

        //ot if doing as below
//        for(int i=0; i < N; i++){
//            int cnt = 0;
//            for(int j=0; j< N; j++){
//                if(road.isConnected(i,j)&&rail.isConnected(i,j)){
//                    cnt++;
//                }
//            }
//            if(i!=N-1)
//                System.out.print(cnt+ " ");
//            else
//                System.out.println(cnt);
//        }

        TreeMap<Long,Integer> map = new TreeMap<>();

        for(int i=0; i<N; i++){
            long key = (long)road.find(i)*N+rail.find(i);
            Integer cnt = map.get(key);
            if (cnt!=null){
                map.put(key, cnt+1);
            }
            else {
                map.put(key,1);
            }
        }

        for(int i=0; i<N; i++){
            long key = (long) road.find(i)*N+rail.find(i);
            if(i!=N-1)
                System.out.print(map.get(key)+" ");
            else
                System.out.println(map.get(key));
        }


        sc.close();
    }

    private static class UnionFind{
        int sz[];
        int id[];
        int count;

        public UnionFind(int n){
            create(n);
        }

        public void create (int n){
            id = new int[n];
            sz = new int [n];
            for(int i=0;i<n;i++){
                id[i] = i;
                sz[i] = 1;
            }
            count = n;
        }

        public int find(int n){
            int tmp = n ;
            while(tmp!=id[tmp]){
                id[tmp] = id[id[tmp]];
                tmp = id[tmp];
            }

            return tmp;
        }

        public void union(int x,int y){

            int xRoot = find(x);
            int yRoot = find(y);

            if(xRoot!=yRoot){
                if (sz[xRoot]<sz[yRoot]){
                    id[xRoot] = yRoot;
                    sz[yRoot] += sz[xRoot];
                }
                else{
                    id[yRoot] = xRoot;
                    sz[xRoot] += sz[yRoot];
                }
                count --;
            }

        }

        public boolean isConnected(int x, int y){
            return find(x) == find(y) ;
        }

    }

}

Measured memory_bytes: 120856
#include<stdio.h>

int n, c[1000];

int check(int a, int b)
{

    return 0;
}

int main(void)
{
    
    int i, j, k;
    int a, b;

    while( 1 ) {
        scanf("%d %d", &a, &b);
        if(a == 0 && b == 0) break;
        if(a >= b)
            printf("%d %d\n", b, a);
        else
            printf("%d %d\n", a, b);
    }
    
    return 0;
}

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

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

	bool flag = false;
	for (int i = 0; i <= 25; i++) {
		for (int j = 0; j <=14; j++) {
			if (i * 4 + j * 7 == n) flag = true;
		}
		if (flag) break;
	}

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

 	return 0;
}

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

int N, X;
using namespace std;

int gcd(int a, int b) {
    if (b == 0)
        return a;

    return gcd(b, a % b);
}


int main(){
  cin >> N >> X;
  std::vector<unsigned long long> x;
  std::vector<unsigned long long> d;
  for(int i =0; i<N; i++){
   unsigned long long t;
    cin >> t;
    x.push_back(t);
  }
  
  for (int i=0; i<x.size(); i++){
    long long t = x[i] - X;
    if (t<0) t = -t;
    d.push_back( t);
  }
 
  // tのなかの最大公約数をとる
  int _gcd = d[0];
  for (int i=1; i<d.size(); i++){
    _gcd = gcd(_gcd, d[i]);
  }

  cout << _gcd << flush;

}

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int N;
int x[200010], y[200010];

int main(){
	cin>>N;
	unordered_map<int,vector<int> > v;
	set<int> vals;
	int min_val = INF, max_val = -INF;
	REP(i,N){
		cin>>x[i]>>y[i];
		v[x[i]].push_back(i);
		v[y[i]].push_back(i);
		min_val = min(min_val,x[i]);
		min_val = min(min_val,y[i]);
		max_val = max(max_val, x[i]);
		max_val = max(max_val, y[i]);
		vals.insert(x[i]);
		vals.insert(y[i]);
	}
	Int ans = -INF;
	if(true){
		Int Rmin = min_val, Bmax = max_val;
		Int Rmax = -INF, Bmin = INF;
		REP(i,N){
			Rmax = max(Rmax,(Int)min(x[i],y[i]));
			Bmin = min(Bmin,(Int)max(x[i],y[i]));
		}
		ans = max(ans,(Rmax-Rmin)*(Bmax-Bmin));
	}
	if(not (v[min_val].size()==1 and v[max_val].size()==1 and v[min_val][0] == v[max_val][0])){
		Int Bmin = min_val, Bmax = -INF;
		int prev_t = -1;
		bool valid = true;
		for(auto &t:vals){
			Bmin = t;
			if(t==min_val){
				REP(i,N){
					Bmax = max(Bmax,(Int)min(x[i],y[i]));
				}
//				cerr<<"first: "<<Bmin<<" "<<Bmax<<endl;
			}else{
				for(auto &i:v[prev_t]){
					if(!(Bmin<=x[i] and x[i]<=Bmax) and !(Bmin<=y[i] and y[i]<=Bmax)){
						if(x[i]<Bmin and y[i]<Bmin){
							valid = false;
						}else{
							Bmax = INF;
							if(Bmin<=x[i])Bmax = min((Int)x[i], Bmax);
							if(Bmin<=y[i])Bmax = min((Int)y[i], Bmax);
						}
					}
				}
				if(!valid){
					break;
				}
//				cerr<<Bmin<<" "<<Bmax<<endl;
				if(min_val<Bmin and Bmax<max_val)ans = min(ans,(max_val-min_val)*(Bmax-Bmin));
			}
			prev_t = t;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  string S;
  cin>>S;
  
  bool accept1=false;
  bool accept2=false;
  bool accept3=false;
  
  if(S[0]=='A')
    accept1=true;
  
  int count=0;
  int index=0;
  for(int i=2;i<S.size()-1;++i){
    if(S[i]=='C'){
      ++count;
      index=i;
    }
  }
  
  if(count==1)
    accept2=true;
  
  int cnt=0;
  for(int i=1;i<S.size();++i){
    if(S[i]=='A' || S[i]=='B' || S[i]=='C' || S[i]=='D' || S[i]=='E' ||
      S[i]=='F' || S[i]=='G' || S[i]=='H' || S[i]=='I' || S[i]=='J'
      || S[i]=='K' || S[i]=='L' || S[i]=='M' || S[i]=='N' || S[i]=='O' ||
      S[i]=='P' || S[i]=='Q' || S[i]=='R' || S[i]=='S' || S[i]=='T' || 
      S[i]=='U' || S[i]=='V' || S[i]=='W' || S[i]=='X' || S[i]=='Y' || S[i]=='Z')
      ++cnt;
  }
  
  if(cnt==1)
    accept3=true;
  
  if(accept1 && accept2 && accept3)
    cout<<"AC"<<endl;
  else
    cout<<"WA"<<endl;
}


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

class disjoinset {
	public:
		vector<int> rank,p;
	disjoinset (){}
	disjoinset(int size){
	rank.resize(size,0);
	p.resize(size,0);
	for(int i=0; i<size;i++)makeSet(i);
	}
	void makeSet(int x){
	p[x] = x;
	rank[x] =0;
	}
	bool same(int x,int y){
	return findSet(x) == findSet(y);
	}
	void unite(int x,int y){
		link(findSet(x),findSet(y));
	}
	void link(int x,int y){
		if(rank[x] > rank[y]){
		 p[y] = x;
		}else{
		 p[x] = y;
		 if(rank[x]==rank[y] )rank[y]++;
		}
	}
	int findSet(int x){
		if(x!=p[x])p[x] = findSet(p[x]);
		return p[x];
	}

};
 
int main(){
	int n,m,a,b,q;
	int t;
	cin>>n>>m;
	disjoinset ds  = disjoinset(n);
	for(int i=0;i<m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		x--,y--;
		if(!ds.same(x,y) ) ds.unite(x,y);
	}
	int cnt = 0;
	for(int i=0;i<n;i++){
	//	cout<<i<<' '<<ds.rank[i]<<' '<<ds.p[i]<<endl;
		if(ds.p[i]==i)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var a string
	var b string
	fmt.Scan(&a, &b)
	if a == Reverse(b) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define PII pair<int, int>
#define LL long long
using namespace std;
const int MAXN = 1005;
const LL INF = (LL)1e9 + 5;
const LL MOD = 1000000007;

struct Point {
	double x, y;
	Point operator - (const Point &p) const {
		return {x - p.x, y - p.y};
	}
	double len() const {
		return sqrt(x * x + y * y);
	}
};

struct Circle {
	Point c;
	double r;
	
	double dist(const Point &p) const {
		double d = (p - c).len();
		return max(d - r, 0.0);
	}
	double distc(const Circle &cir) const {
		double d = (cir.c - c).len();
		return max(0.0, d - r - cir.r);
	}
};

struct Edge {
	int to;
	double w;
	bool operator < (const Edge &e) const {
		return w > e.w;
	}
};

int N;
double dist[MAXN];
vector<Edge> G[MAXN];
Point sp, tp;
Circle bar[MAXN];
bool vis[MAXN];

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

	cin >> sp.x >> sp.y >> tp.x >> tp.y;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> bar[i].c.x >> bar[i].c.y >> bar[i].r;
		for (int j = 1; j < i; j++) {
			double d = bar[i].distc(bar[j]);
			G[i].push_back({j, d});
			G[j].push_back({i, d});
		}
		
		double d1 = bar[i].dist(sp), d2 = bar[i].dist(tp);
		G[0].push_back({i, d1});
		G[i].push_back({N + 1, d2});
		
		dist[i] = 1e18;
	}
	
	int S = 0, T = N + 1;
	G[S].push_back({T, (sp - tp).len()});
	dist[S] = 0.0;
	dist[T] = 1e18;
	
	priority_queue<Edge> pq;
	pq.push({S, 0.0});
	while (!pq.empty()) {
		Edge e = pq.top();
		pq.pop();
		if (vis[e.to]) continue;
		vis[e.to] = true;
		dist[e.to] = e.w;
		for (Edge &e2 : G[e.to]) {
			if (!vis[e2.to]) {
				pq.push({e2.to, e.w + e2.w});
			}
		}
	}
	
	cout << fixed << setprecision(12) << dist[T] << '\n';

	return 0;
}

Measured memory_bytes: 26496
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        char carr[]=br.readLine().toCharArray();
        int sum=0;
        for(int i=0;i<carr.length;i++)
        {
            sum=sum+(carr[i]-'0');
        }
        pw.println((sum%9==0)?"Yes":"No");
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 36404
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        TreeMap<Long,Integer> map = new TreeMap<Long,Integer>(Comparator.reverseOrder());
        int n = sc.nextInt();
        System.out.println(n % 2 == 0 ? (double)(n/2)/n : (double)(n/2+1)/n);
    }
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    int ans = INF;
    REP(i,N){
        int a; cin >> a;
        int cnt = 0;
        while(a>0 && a%2==0){
            a /= 2;
            cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  ll N;
  cin >> N;
  ll rootN = sqrt(N);
  priority_queue<ll, vector<ll>, greater<ll>> ans;
  for (int i = 1; i <= rootN; i++) {
    if (N % i == 0) {
      ans.push(i + N/i -2);
    }
  }
  cout << ans.top() << endl;
}


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

using namespace std;
typedef long long ll;

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

	int x, y, z;
	cin >> x >> y >> z;
	
	swap(x, y);
	swap(x, z);

	cout << x << ' ' << y << ' ' << z << '\n';

	return 0;
}

/*template < typename T >
long long modexp(T a, T b, T p) {
	// returns a to the power b mod p by modular exponentiation

	long long res = 1;
	long long mult = a % p;
	while (b > 0) {
		if (b & 1) {
			res = (res * mult) % p;
		}
		b >>= 1;
		mult = (mult * mult) % p;
	}

	return res;
}*/

/*int primeModInverse(int a, int n) {
	// returns inverse of a mod n by mod exponentiation, use only if n is prime
	return (int) modexp(a, n - 2, n);
}*/

/*template < typename T >
T gcd(T a, T b) {

	if (b == 0) {
		return a;
	}

	return gcd(b, a % b);

}*/


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

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  };
  ($e:expr => $i:expr; $t:ty) => {
    (0..$i).map(|_| $e.get::<$t>()).collect::<Vec<$t>>()
  };
  ($e:expr => $row:expr, $col:expr; $t:ty) => {
    (0..$i).map(|_| scan!($e => $col; $t)).collect::<Vec<$t>>()
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

trait Writable {
  fn write(&self, sep: &'static str) -> String;
}

impl<T: ToString> Writable for Vec<T> {
  fn write(&self, sep: &'static str) -> String {
    self.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep)
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let (a, _b, s) = scan!(sc; usize, i32, String);
  let hyphen = s.chars().filter(|&c| c == '-').count();
  if hyphen != 1 {
    println!("No");
    return;
  }
  let hyphen_pos = s.chars().position(|c| c == '-').unwrap();
  println!("{}", if a == hyphen_pos { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N, K;
	cin >> N >> K;

	ll ans1 = N % K;
	ll ans2 = K - ans1;


	cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int maxn = 1000005;
const int mod = 998244353;

int main(){
    int s,w;scanf("%d%d",&s,&w);
    if(s<=w) printf("unsafe\n");
    else printf("safe\n");
    return 0;
}




Measured memory_bytes: 3668
#include <stdio.h>
int main(void){
    int N,a,b,c;
    
    scanf("%d",&N);
    
    a=N%10;
    b=(N%100)/10;
    c=N/100;
    
    if(a==7 || b==7 || c==7){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}

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

bool isOK(ll x, ll k, vector<ll>& a){
  ll count = 0;
  ll n = a.size();
  rep(i, n) count += (ll)ceil((double)a[i]/x)-1;
  if (count <= k) return true;
  else return false;
}

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  
  ll left = 0;
  ll right = 1000000000;
  
  while (right - left > 1) {
    ll mid = left + (right - left) / 2;
    if (isOK(mid, k, a)) right = mid;
    else left = mid;
  }
  cout << right << endl;
  
  return 0;
}

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

int main()
{
	string S;
	cin >> S;
	const int n = S.size();
	vector<int> cnt(n, 1);
	for (int i = 0; i + 1 < n; i++) if (S[i] == 'R' && S[i + 1] == 'R') {
		cnt[i + 2] += cnt[i];
		cnt[i] = 0;
	}
	for (int i = n - 1; i > 0; i--) if (S[i] == 'L' && S[i - 1] == 'L') {
		cnt[i - 2] += cnt[i];
		cnt[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		cout << cnt[i] << " \n"[i + 1 == n];
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
//#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string str;
map<P,set<int> >M;
set<int> rec(int L,int R){
	if(M.find(mp(L,R)) != M.end()) return M[mp(L,R)];
	int dep = 0;
	vector<int>cut;
	for(int i=L;i<=R;i++){
		if(str[i] == '(') dep ++;
		else if(str[i] == ')') dep --;
		else if(dep == 0 && (str[i] == '+' || str[i] == '-' || str[i] == '*' || str[i] == '/')){
			cut.pb(i);
		}
	}
	if(cut.empty()){
		//<num> or (<expr>)
		if(str[L] == '('){
			assert(str[R] == ')');
			return M[mp(L,R)] = rec(L+1,R-1);
		}
		else{
			int num = 0;
			for(int i=L;i<=R;i++){
				num = num * 10 + (str[i]-'0');
			}
			set<int>S; S.insert(num);
			return M[mp(L,R)] = S;
		}
	}
	else{
		set<int>ans;
		for(int i=0;i<cut.size();i++){
			set<int>x = rec(L,cut[i]-1);
			set<int>y = rec(cut[i]+1,R);
			for(auto a:x){
				for(auto b:y){
					if(str[cut[i]] == '+') ans.insert(a+b);
					if(str[cut[i]] == '-') ans.insert(a-b);
					if(str[cut[i]] == '*') ans.insert(a*b);
					if(str[cut[i]] == '/') if(b != 0) ans.insert(a/b);
				}
			}
		}
		return ans;
	}
}
int main(){
	while(1){
		cin>>str;
		if(str == "#") return 0;
		M.clear();
		set<int>hoge = rec(0,str.size()-1);
		cout<<hoge.size()<<endl;
	}
}


Measured memory_bytes: 3212
#include <iostream>
#include <string>
using namespace std;
int main(){
    string e,o;
     cin >> e >> o;
    for(int i=0;e[i]!='\0'||o[i]!='\0';i++){
            if(e[i]!='\0')
                cout << e[i];
            if(o[i]!='\0')
                cout << o[i];
        }
        cout << endl;

return 0;

}


Measured memory_bytes: 256
/**
*    created: 06.05.2020 01:55:57
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n, greater<int>());
    int ans = 0;
    rep(i,n){
        if(i%2==0){
            ans += a[i];
        }else{
            ans -= a[i];
        }
    }
    cout << ans << endl;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] in = br.readLine().split(" ");
        int a = Integer.parseInt(in[0]);
        int p = Integer.parseInt(in[1]);

        System.out.println((a * 3 + p) / 2);

        br.close();
    }
}

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        sc.close();

        int ans = 1;

        for (int i = 0; i < n; i++) {
            ans = Math.min(ans * 2, ans + k);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=50001;
const ll INF=1LL<<60;

int main(){
   
    int N;
    ll W;cin>>N>>W;
    vector<vector<ll>> dp(N+1,vector<ll>(10001,INF));
    dp[0][0]=0;
    
    for(int i=1;i<=N;i++){
        ll v,w;cin>>v>>w;
        for(int j=0;j<=10000;j++){
            if(j-v>=0) dp[i][j]=min(dp[i][j],dp[i-1][j-v]+w);
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
        }
    }
    
    int ans=0;
    
    for(int i=0;i<=10000;i++){
        if(dp[N][i]<=W){
            ans=i;
        }
    }
    
    cout<<ans<<endl;
}




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

const int mxn = 1e5+7;

vector<int> adj[mxn];
int dp[mxn];

int dfs(int u) {
	if(dp[u] != -1) {
		return dp[u];
	}
	int h = 0;
	
	for(int v : adj[u]) {
		h = max(h, dfs(v));
	}
	
	return dp[u] = 1 + h;
}

int main() {
	int n, m;
	cin >> n >> m;
	
	memset(dp, -1, sizeof(dp));
	for(int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		ans = max(ans, dfs(i));
	}
	cout << (ans - 1) << "\n";
}


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

using namespace std;

#define int long long
#define  IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF = 1e9;

signed main() {
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<int> r(a),g(b),cc(c);
    for(int i=0;i<a;i++) cin>>r[i];
    for(int i=0;i<b;i++) cin>>g[i];
    for(int i=0;i<c;i++) cin>>cc[i];
    sort(r.rbegin(),r.rend());
    sort(g.rbegin(),g.rend());
    sort(cc.begin(),cc.end());
    multiset<int> sr,sg;
    for(int i=0;i<x;i++) sr.insert(r[i]);
    for(int i=0;i<y;i++) sg.insert(g[i]);
    for(int i=0;i<c;i++) {
        int f=*sr.begin();
        int s=*sg.begin();
        if(f<s) {
            if(cc[i]>f) {
                sr.erase(sr.begin());
                sr.insert(cc[i]);
            }
        } else {
            if(cc[i]>s) {
                sg.erase(sg.begin());
                sg.insert(cc[i]);
            }
        }
    }
    int sum=0;
    for(auto it:sr) sum+=it;
    for(auto it:sg) sum+=it;
    cout<<sum<<"\n";
    return 0;
}

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

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    if (n == 2) {
        if (v[0] == v[1]) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    } else {

        map<int, int> m1, m2;

        for (int i = 0; i < n; i++) {
            if (i % 2 == 0)
                m1[v[i]]++;
            else
                m2[v[i]]++;
        }

        int cnt1 = 0, cnt2 = 0;
        int e1 = -1, e2 = -1;

        for (auto itr = m1.begin(); itr != m1.end(); itr++) {
            if (itr->second > cnt1) {
                cnt1 = itr->second;
                e1 = itr->first;
            }
        }
        for (auto itr = m2.begin(); itr != m2.end(); itr++) {
            if (itr->second > cnt2) {
                cnt2 = itr->second;
                e2 = itr->first;
            }
        }

        if (e1 != e2) {
            cout << n - cnt1 - cnt2 << endl;
        } else {
            m1.erase(e1);
            m2.erase(e2);

            int c1 = 0, c2 = 0;

            for (auto itr = m1.begin(); itr != m1.end(); itr++) {
                if (itr->second > c1) {
                    c1 = itr->second;
                }
            }
            for (auto itr = m2.begin(); itr != m2.end(); itr++) {
                if (itr->second > c2) {
                    c2 = itr->second;
                }
            }

            cout << (n - c1 - cnt2 < n - cnt1 - c2 ? n - c1 - cnt2 : n - cnt1 - c2) << endl;
        }
    }
}

Measured memory_bytes: 5376
#include <iostream>
#include <queue>
#include <map>
#include <array>

using namespace std;

const int kForward = 1;
const int kGain = 2;
const int kLost = 3;

void Solve(double dp[51][5000], int value[51], int board[51], int goal, int roulette[4], int num_roulette){
  double prob_roulette = 1.0/num_roulette;
  dp[0][0] = 1.0;
  
  for(int i=0; i<goal; i++){
	for(int n=0; n<num_roulette; n++){
	  int npos = (i + roulette[n] <= goal) ? i + roulette[n] : goal;
	  if(board[npos] == kForward){
		npos = (npos + value[npos] <= goal) ? npos + value[npos] : goal;
		for(int m=0; m<5000; m++){
		  dp[npos][m] += prob_roulette * dp[i][m];
		}
	  }else if(board[npos] == kGain){
		for(int m=0; m<5000; m++){
		  dp[npos][m+value[npos]] += prob_roulette * dp[i][m];
		}
	  }else if(board[npos] == kLost){
		for(int m=0; m<5000; m++){
		  int nm = (m - value[npos] < 0) ? 0 : m - value[npos];
		  dp[npos][nm] += prob_roulette * dp[i][m];
		}
	  }else{
		for(int m=0; m<5000; m++){
		  dp[npos][m] += prob_roulette * dp[i][m];
		}
	  }
	}
  }
}

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

  while(1){
	double dp[51][5000] = {{0.0}};
	int board[51] = {0};
	int value[51] = {0};
	int roulette[4] = {0};
	int X, Y, Z;
	cin >> X >> Y >> Z;
	if(X == 0){
	  return 0;
	}
	for(int i=0; i<X; i++){
	  cin >> roulette[i];
	}
	
	for(int i=0; i<Z; i++){
	  int N, E, A;
	  cin >> N >> E >> A;
	  board[N] = E;
	  value[N] = A;
	}

	Solve(dp, value, board, Y, roulette, X);

	double sum = 0.0;
	for(int m=1; m<5000; m++){
	  sum += m * dp[Y][m];
	}
	cout << static_cast<int>(sum) << endl;
  }
}

Measured memory_bytes: 5016
def f(X,s,t):
    N=len(s)
    i=0
    c=0
    b=0
    while i<N and s[i]!=X:
        c+=int(t[i])
        i+=1
    #print(c)
    #print(i)
    for k in range(N):
        b+=int(t[k])
    #print(b)
    return b-(c+int(t[i]))
N=int(input())
s=[0]*N
t=[0]*N
for a in range(0,N):
    (s[a],t[a])=map(str,input().split())
X=str(input())
print(f(X,s,t))
        

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var coinarray = ReadInts();
            int[] money = { 1,5,10,50,100,500};

            var moneysum = 0;
            for (int i = 0; i < 6; i++)
            {
                moneysum += coinarray[i] * money[i];
            }
            if (moneysum >= 1000)
            {
                WriteLine(1);
            }
            else
            {
                WriteLine(0);
            }
        }

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

        //最大公約数

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

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

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}



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

int main(int argc, char* argv[]){
  int32_t n;
  std::cin >> n;  

  std::cout << ((n + 1) / 2) * (n / 2) << std::endl;
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 100005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++){
        cin>>a[i];
	}
	bool pos[k+1];
	pos[0] = 0;
	for(int i=1;i<=k;i++){
        pos[i] = 0;
        for(int j=0;j<n;j++){
            if(a[j]<=i){
                if(!pos[i-a[j]]){
                    pos[i] = 1;
                    break;
                }
            }
        }
	}
	if(pos[k]){
        cout<<"First";
	}
	else{
        cout<<"Second";
	}
	return 0;
}


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

int main(){
  int x,n;
  cin>>x>>n;
  if(n==0){
    cout<<x<<endl;
    return 0;
  }
  vector<int>y(n);
  for(int i=0;i<n;i++){
    cin>>y[i];
  }
  for(int j=0;j<=120;j++){
    for(int k=0;k<n;k++){
      if(x-j==y[k]){
        break;
        }
      if(k==n-1){
        cout<<x-j<<endl;
        return 0;
      }
    }
    for(int l=0;l<n;l++){
      if(x+j==y[l]){
        break;
        }
      if(l==n-1){
        cout<<x+j<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
const int N=1e5+10;
const int mod=1e9+7;
int f[N][13],a[N],n;
char s[N];
int main()
{
	scanf("%s",&s);
	n=strlen(s);
	for(int i=0;i<n;i++)
		if(s[i]=='?')a[i+1]=-1;
		else a[i+1]=s[i]-'0';
		f[0][0]=1;
	for(int i=1;i<=n;i++)
		if(~a[i])
		{
			for(int j=0;j<13;j++)
				f[i][(j*10+a[i])%13]=(f[i][(j*10+a[i])%13]+f[i-1][j])%mod;
		}
		else
		{
			for(int k=0;k<10;k++)
				for(int j=0;j<13;j++)
					f[i][(j*10+k)%13]=(f[i-1][j]+f[i][(j*10+k)%13])%mod;
		}
	printf("%d",f[n][5]);
	return 0;
}


Measured memory_bytes: 5760
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const h = str => {
    return str.split('').map(x => {
        switch(x) {
            case 'A':
                return 1;
            case 'C':
                return 2;
            case 'G':
                return 3;
            case 'T':
                return 4;
        }
    })
    .reduce((acc, x, i) => acc + x*Math.pow(4, i+1));
};

line.slice(1, line.length-1).reduce((acc, x) => {
    const cmd = x.split(' ');
    const key = h(cmd[1]);
    switch(cmd[0]) {
        case 'insert':
            acc[key] = true;
            break;
        case 'find':
            console.log(acc[key] ? 'yes' : 'no');
            break;
    }

    return acc;
}, []);



Measured memory_bytes: 278600
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define step(i, f, n, a) for(int (i) = (f); (i) < (n); (i)+=a)
#define rstep(i, f, n, a) for(int (i) = (f); (i) >= (n); (i)-=a)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

int main(){
	int n, s, ans;
	int result = 0;
	gets(n) gets(s)
	rep(i, n+1){
		rep(j, n+1){
			ans = s-(i + j);
			if (ans >= 0 && ans <= n){
				result += 1;
			}
		}
	}
	puts(result)
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long A, long long B, long long C, long long K){
  ll ans=0;
  ans=min(A,K);
  K-=A;
  if(K>0){
    K-=B;
    if(K>0){
      ans-=min(K,C);
    }
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  ll N; cin>>N;
  if(N%2){
    cout<<0<<endl;
    return 0;
  }
  ll k = -1;//5^kで割るのが最高
  ll n1 = N/2;
  while(n1){
    n1 /= 5;
    k++;
  }
  ll res = 0;
  N /= 2;
  for(int i = k; i > 0; i--){
    res += N/(ll)pow(5,i);
  }
  cout<<res<<endl;
}


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

#define PI acos(-1.0)
#define INF 1e18
#define inf 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)

const int N=1e5+10;
typedef long long LL;

int n,m;
int dis[N];
bool vis[N];
vector < pair<int,int> > E[N];

bool dfs(int u){
    vis[u]=1;
    for(auto p : E[u]){
        int v=p.first;
        int d=p.second;
        if(!vis[v]){
            dis[v]=dis[u]+d;
            if(!dfs(v)) return false;
        }
        else if((dis[u]+d)!=dis[v]) return false;
    }
    return true;
}

int main(){
    FAST_IO;
    cin>>n>>m;
    int u,v,w;
    for(int i=1;i<=m;i++){
        cin>>u>>v>>w;
        E[u].push_back(make_pair(v,w));
        E[v].push_back(make_pair(u,-w));
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            if(!dfs(i)) {cout<<"No"<<endl;return 0;}
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

int main() {
    int n;
    cin >>n;
    int arr[n];
    for(int &x:arr)
    cin >>x;
    
    ll dp[n][n];
    memset(dp,0,sizeof(dp));
    for(int l=n-1;l>=0;l--)
    {
        for(int r=l;r<n;r++)
        {
            if(l==r)
            dp[l][r]=arr[l];
            else
            {
                dp[l][r]=max(arr[l]-dp[l+1][r],arr[r]-dp[l][r-1]);
            }
        }
    }
    printf("%lld\n", dp[0][n-1]);
    
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000


int main(){
	
	int N;
	cin>>N;
	
	vector<long long> A(N);
	
	long long sum = 0;
	
	for(int i=0;i<N;i++){
		cin>>A[i];
		sum += A[i];
	}
	long long ans = Inf;
	long long s2 = 0;
	for(int i=0;i<N;i++){
		s2 += A[i];
		sum -= A[i];
		ans = min(ans,abs(s2-sum));
	}
	
	cout<<ans<<endl;
	
	return 0;
	
}

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

using namespace std;

int main()
{
    int n, m;
    int spo[1001], li[1001];
    vector<int> gra(1001);

    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        cin >> spo[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> li[i];
    }

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            if (spo[j] <= li[i]) {
                gra[j]++;
                break;
            }
        }
    }

    cout << distance(gra.begin(), max_element(gra.begin(), gra.end())) + 1 << endl;

}


Measured memory_bytes: 3096
import numpy as np
S = list(input())
N = len(S)
A = []
B = []
for i in range((N-1)//2):
    A.append(S[i])
for j in range((N-1)//2):
    B.append(S[((N+3)//2)+(j-1)])

C = list(reversed(A))
D = list(reversed(B))
E = list(reversed(S))

if np.count_nonzero(np.array(A) == np.array(C)) == np.count_nonzero(np.array(B) == np.array(D)) == len(A) and np.count_nonzero(np.array(S) == np.array(E)) == len(S):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 13308
###
### atcorder test program
###

import sys

### math class
class math:
    ### pi
    pi = 3.14159265358979323846264338

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Prime number search
    def Pnum(self, a):
        if a == 1: return False
        for i in range(2,int(a**0.5)+1):
            if a % i == 0:
                return False
        return True

    ### Circle area
    def caria(self, r):
        return r*r*self.pi

math = math()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#A, B, C = [x for x in input().split()]
#inlist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

#A, B, C = [int(x) for x in input().split()]

a, b = [float(x) for x in input().split()]
print(a*b/3.305785)




Measured memory_bytes: 5588
#include<iostream>
using namespace std;
typedef long long ll;
  
struct Stack {
  ll table[1000];
  ll top;

  void init() {
    top = 0;
  }
  bool isEmpty() {
    return top == 0;
  }
  void push(ll x) {
    top++;
    table[top] = x;
  }
  ll pop(){
    if(isEmpty()) {
      return 0;
    }
    top--;
    return table[top + 1];
  }
};

ll calc(ll x,string op,ll y) {
  if(op=="+") return x+y;
  if(op=="-") return x-y;
  if(op=="*") return x*y;
}

int main(){
  string str;
  ll numA,numB;
  Stack stack;
  stack.init();
  
  while(cin >> str){
    if(str == "+" || str == "-" || str == "*") {
      numA=stack.pop();
      numB=stack.pop();
      stack.push(calc(numB, str, numA));
    }else{
      numA=0;
      for(int i=0; i < (int)str.size(); i++){
        numA *= 10;
        numA += str[i] - '0';
      }
      stack.push(numA);
    }
  }
  cout << stack.pop() << endl;
  return 0;
}


Measured memory_bytes: 3224
#include <stdio.h>

int main()
{
    char a[4],b[4];
    int count=0,i;
    scanf("%s",a);
    scanf("%s",b);
    for(i=0;i<3;i++){
        if(a[i]==b[i]) count++;
    }
    printf("%d\n",count);
    return 0;
}


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

using namespace std;

int main()
{
	int n;
	long long MOD=1000000007;
	long long p=1;
	cin>>n;
	for(int i=1;i<n+1;i++)
	{
		p *= (long long)i;
		p = (long long)p%MOD;
	}
	//cerr<<MOD<<endl;
	cout<<p<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

  

int main(){
  int n,k;
  string s;
  vector<int> t;

  cin >> n >> k >> s;
  int u=1;
  char c = s[0];
  if(s[0] == '0')t.push_back(0);
  rep(i,1,s.size()){
    if(c == s[i])u++;
    else{
      t.push_back(u);
      u=1;
      c = s[i];
    }
  }
  t.push_back(u);
  if(s[n-1]=='0')t.push_back(0);

  rep(i,0,t.size()-1) t[i+1] += t[i];

  int ans=0;

  /*
  for(auto i : t) cout << i << " ";
  cout << endl;
  */

  int l,r;
  int zeros = t.size()/2;
  if(zeros <= k)ans = n;
  else{
    l = 0;
    r = k*2;
    while(r < t.size()){
      int w;
      if(l==0)w = t[r];
      else w = t[r]-t[l-1];
      ans = max(ans,w);
      l+=2;
      r+=2;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1020