akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
   int n,k,a[100000],ans,i;

   scanf("%d%d",&n,&k);

   for(i=0;i<n;i++)
      scanf("%d",&a[i]);

   n--; k--;
   if(n%k==0)   ans=n/k;
   else         ans=n/k+1;

   printf("%d\n",ans);

   return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back

using namespace std;

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

const int MAXN = 2e5 + 10;

int a, p;

int main(){
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> a >> p;
	p += a*3;
	cout << p/2 << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;

// 頂点情報を格納するベクタ
struct Edge
{
    int to;
    int cost;
};
std::vector<Edge> v[100009];

// firstが始点から最大距離の頂点、secondが最大距離
std::pair<int, int> max_cost;

void dfs(const int index, const int parent_index, const int total_cost)
{
    //printf("\n頂点%dを調べる\n（親は頂点%d、接点数は%lu、始点からの距離は%d）\n",
    //       index, parent_index, v[index].size(), total_cost);
    
    if(v[index].size() == 1 && parent_index != -1){
        // 接点が親だけの場合は葉なので最大距離を更新する
        if(total_cost > max_cost.second){
            //printf("  -> 最大距離更新（頂点%d/距離%d）\n", index, total_cost);
            max_cost.first = index;
            max_cost.second = total_cost;
        }
    }
    std::vector<Edge>::iterator itr;
    for(itr = v[index].begin(); itr != v[index].end(); ++itr){
        int to = itr->to;
        int cost = itr->cost;
        if(to == parent_index){
            //printf("  -> 頂点%d は親なので飛ばす\n", to);
            continue;
        }
        //printf("  -> 頂点%dと頂点%dとの距離は%d\n", index, to, cost);
        dfs(to, index, total_cost+cost);
    }
    //printf("頂点%dの調査終わり\n\n", index);
}
int main()
{
    int n;
    cin >> n;
    for(int i=0; i<n-1; i++){  // 辺の数は(頂点の数-1)
        int s,t,w;
        cin >> s >> t >> w;
        Edge e;
        e.cost = w;
        e.to = t; v[s].push_back(e);
        e.to = s; v[t].push_back(e);
    }
    for(int i=0; i<n; i++){
        //printf("頂点%dからは ", i);
        std::vector<Edge>::iterator itr = v[i].begin();
        while(itr != v[i].end()){
            //printf("%d(長さ%d), ", itr->to, itr->cost);
            ++itr;
        }
        //printf("に接している\n");
    }
    //printf("\n");

    // 頂点0を始点として深さ優先探索で最大距離を探す
    dfs(0, -1, 0);
    //printf("頂点0から%dへの距離%dが最大\n", max_cost.first, max_cost.second);

    // 頂点0から最大距離の頂点から、更に最大距離を探す
    dfs(max_cost.first, -1, 0);
    //printf("頂点0から%dへの距離%dが最大\n", max_cost.first, max_cost.second);
    printf("%d\n", max_cost.second);
    
    return 0;
}


Measured memory_bytes: 13200
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define range(i, a, b, s) for (int i = (a), __##i = (b); i < __##i; i += (s))
#define down(i, a, b, s) for (int i = (a), __##i = (b); __##i < i; i -= (s))

const ll mod = 1000000007;
const int maxn = 1e5 + 1;

int n, m, a[maxn], dp[maxn];

int main(int argc, char const *argv[]) {
  // freopen("C.txt", "r", stdin);

  while (cin >> m >> n) {
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    range(i, 0, n, 1) {
      cin >> a[i];
      dp[a[i]] = -1;
    }
    // cout << "dp => [";
    // range(i, 0, m + 1, 1) {
    //   if (i) cout << ", ";
    //   cout << dp[i];
    // }
    // cout << "]" << endl;

    range(i, 1, m + 1, 1) {
      if (dp[i] != -1) {
        if (i >= 2 && dp[i - 2] != -1) {
          dp[i] = (dp[i] + dp[i - 2]) % mod;
        }
        if (i >= 1 && dp[i - 1] != -1) {
          dp[i] = (dp[i] + dp[i - 1]) % mod;
        }
      }
    }

    // cout << "dp => [";
    // range(i, 0, m + 1, 1) {
    //   if (i) cout << ", ";
    //   cout << dp[i];
    // }
    // cout << "]" << endl;

    cout << dp[m] << endl;
  }
  return 0;
}

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

#ifdef SG
	#include <debug.h>
#else
	template<typename T> struct outputer;
	struct outputable {};
	#define PRINT(...)
	#define OUTPUT(...)
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
	#define fbegin(...)
	#define fend
	#define pbegin(...)
	#define pend
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb emplace_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef int64_t ll;
typedef uint64_t ull;
typedef uint32_t ui;
typedef uint16_t us;
typedef uint8_t uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

struct Input {
	ll n, a, b, c, d;
	
	bool read () {
		return !!(cin >> n >> a >> b >> c >> d);
	}

	void init (const Input &input) {
		*this = input;
	}
};

struct Data: Input {
	bool ans;
	
	void write () {
		puts(ans ? "YES" : "NO");
	}
};


namespace Main {
	
	struct Solution: Data {
		
		void solve () {
			ans = 0;
			forn (i, n) {
				int j = n - 1 - i;
				ll lb = i * c - j * d;
				ll rb = i * d - j * c;
				if (b - a >= lb && b - a <= rb) {
					ans = 1;
				}
			}
		}
		
		void clear () {
			*this = Solution();
		}
	};
}


Main::Solution sol;

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);

	#ifdef SG
		freopen((problemname + ".in").c_str(), "r", stdin);
//		freopen((problemname + ".out").c_str(), "w", stdout);
		while (sol.read()) {
			sol.solve();
			sol.write();
			sol.clear();
		}
	#else
		sol.read();
		sol.solve();
		sol.write();
	#endif
	
	/*
	int t;
	cin >> t;
	forn (i, t) {
		sol.read();
		sol.solve();
		sol.write();
		sol.clear();
	}
	*/
	
	return 0;
}


Measured memory_bytes: 256
N,M,S=map(int,input().split())
S=min(2500,S)

#O(ElogV)
import heapq
def dijkstra_heap(s):
  #始点sから各頂点への最短距離
  d,used={},{}
  for v in vlist:
    d[v]=float("inf")
    used[v]=True
  d[s]=0
  used[s]=False
  
  edgelist = []
  for e in edge[s]:
    heapq.heappush(edgelist,e)
    
  while len(edgelist):
    minedge = heapq.heappop(edgelist)
    #まだ使われてない頂点の中から最小の距離のものを探す
    if not used[minedge[1]]:
      continue
    v = minedge[1]
    d[v] = minedge[0]
    used[v] = False
    for e in edge[v]:      
      if used[e[1]]:
        heapq.heappush(edgelist,(e[0]+d[v],e[1]))
        
  return d

uvab_list=[]
for i in range(M):
  U,V,A,B=map(int,input().split())
  uvab_list.append((U,V,A,B))
  
cd_list=[]
for i in range(N):
  C,D=map(int,input().split())
  cd_list.append((C,D))
  
vlist=[]
for i in range(1,N+1):
  for j in range(2501):
    vlist.append((i,j))

edge={}
for U,V,A,B in uvab_list:
  for j in range(2501):
    if j-A>=0:
      if not (U,j) in edge:
        edge[(U,j)]=[]    
      edge[(U,j)].append((B,(V,j-A)))
      if not (V,j) in edge:
        edge[(V,j)]=[]
      edge[(V,j)].append((B,(U,j-A)))

for i in range(N):
  C,D=cd_list[i]
  for j in range(2501):
    if not (i+1,j) in edge:
      edge[(i+1,j)]=[]    
    jj=min(2500,j+C)    
    edge[(i+1,j)].append((D,(i+1,jj)))
    
n=len(vlist)
w=len(edge)
res=dijkstra_heap((1,S))
#print(res)

for i in range(2,N+1):
  min_i=float("inf")
  for j in range(2501):
    min_i=min(min_i,res[(i,j)])
    
  print(min_i)

Measured memory_bytes: 175332
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        int n = ReadInt();
        int[] l = ReadInt(n).ToArray();
        int c = 0;
        for (int i = 0; i < n ;i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                for (int k = j + 1; k < n; k++)
                {
                    if (CanMake(l[i], l[j], l[k])) c++;
                }
            }
        }
        Console.WriteLine(c);
    }

    bool CanMake(int a, int b, int c)
    {
        return a != b && b != c && c != a && a + b > c && b + c > a && c + a > b;
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();
    public static string Read() { if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s); return que.Dequeue(); }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());
    public static IEnumerable<string> Read(long n) { for (long i = 0; i < n; i++) yield return Read(); }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}


Measured memory_bytes: 28484
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long dp[1005][1005];
int main()
{
	long long i,j,n,m;
	cin>>n>>m;
	string s[1005];
	for(i=0;i<n;++i)
	 cin>>s[i];
	dp[0][0]=1;
	for(i=1;i<m;++i)
	{
	 if(s[0][i]=='.')
	  dp[0][i]=dp[0][i-1]%mod;
    }
	for(i=1;i<n;++i)
	{
		if(s[i][0]=='.')
	     dp[i][0]=dp[i-1][0]%mod;
    }
	for(i=1;i<n;++i)
	{
		for(j=1;j<m;++j)
		{
			if(s[i][j]=='.')
			{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
			}
		}
	}
cout<<(dp[n-1][m-1])%mod;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const ll mx=100;

ll arr[100000];


int main(){
    ll x;
    for(ll i=1;i<mx;i++)
        for(ll j=1;j<mx;j++)
            for(ll k=1;k<mx;k++){
                x=(i+j+k)*(i+j+k)-i*j-k*j-i*k;
                if(x<=(ll)1e4)
                    arr[(i+j+k)*(i+j+k)-i*j-k*j-i*k]++;
            }
               
   
    ll k;cin>>k;
    for(int i=1;i<=k;i++){
        cout<<arr[i]<<"\n";
    }
}

Measured memory_bytes: 3652
S=input()
sk="keyence"
N=len(S)
Nsk=len(sk)

k=0
ans="NO"
if N>=Nsk:
    for i in range(Nsk):
        temp=S[0:i]+S[N-Nsk+i:]
        if temp==sk:
            ans="YES"
    
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    ll n,C[200001],mod=1e9+7;
    cin>>n;
    rep(i,n) cin>>C[i];
    ll A[200011];
    A[0]=1;
    rep(i,n+1) A[i+1]=2*A[i]%mod;
    sort(C,C+n,greater<ll>());
    ll ans=0,k=A[n-1],l;
    if(n==1) l=0;
    else l=A[n-2];
    rep(i,n) ans=(ans+k*C[i])%mod,k=(k+l)%mod;
    cout<<A[n]*ans%mod;
}

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

int main(void){
  string s, t;
  cin >> s;
  cin >> t;
  int count = 0;
  for(int i = 0; i < 3; i++){
    if(s.at(i) == t.at(i)){
      count++;
    }
  }
  cout << count;
}

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

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

    for(ll i=0;i<n;++i){
        ll flag = 1e9;
        ll num;
        for(ll j=0;j<m;++j){
            ll x = abs(a[i] - c[j]);
            ll y = abs(b[i] - d[j]);
            if(flag > x+y){
                flag = x+y;
                num = j;
            }
        }
        cout<<num+1<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int head=0;
int tail;

typedef struct{
  char name[10];
  int data;
}process;

int isEmpty();
void enqueue(process data);
void dequeue(int);
int size;

process *Q;
process *tmpQ;
process *endtime;

int main(){
  int q;
  int i,j,k=0;
  int time=0;
  int hastime;
  char space;
  int plus=0;

  scanf("%d %d",&size,&q);
  Q = (process *)malloc((size+1) * sizeof(process));

  endtime =  (process *)malloc((size+1) * sizeof(process));
      
  for(i=0;i<size;i++){
    scanf("%s",&Q[i].name);
    scanf("%d",&Q[i].data);
  }
  /*  
  for(i=0;i<size;i++){
    printf("%s %d\n",Q[i].name,Q[i].data);
  }
  */
  Q[size].data = 0;
  strcpy(Q[size].name,"empty"); 
  
 
  int sizekept = size;
  tail = size-1;
  int rest;
  rest = size;
  while(rest!=0){  // 残り個数が０になるまで
    /*
     	for(i=head;i<=size;i++){
	  printf("[%s %d] - ",Q[i].name,Q[i].data);
	}
	printf("//");
	for(i=0;i<head;i++){
	  printf("[%s %d] - ",Q[i].name,Q[i].data);
	}
	printf("\n");
    */
    hastime = Q[head].data;   //今持っている残り時間
    Q[head].data = hastime - q; //時間から指定分マイナス
   
    if(Q[head].data > 0) {   //時間がまだ残っている
	time += q;  
	enqueue(Q[head]);
		dequeue(Q[head].data);
      }     
      else{
	time += hastime;
	
	endtime[k].data = time;
	for(i=0;i<10;i++){
	  endtime[k].name[i] = Q[head].name[i]; 
	}
	//	printf("%s\n",endtime[k].name);	
	dequeue(Q[head].data);
	rest--;        
	//	printf("one item became 0\n");
	k++;
      }
  }
  
  for(i=0;i<sizekept;i++){
    printf("%s %d\n",endtime[i].name,endtime[i].data);
  }
  return 0;
}

void dequeue(int data){

  head = (head+1)%(size+1);
}

void enqueue(process data){

  Q[(tail+1)%(size+1)] = data;
  tail = (tail+1)%(size+1);
}


int isEmpty(){
  if(head==tail) return 0;
  else return 1;
}



Measured memory_bytes: 3296
import sys
input = sys.stdin.readline

A,B,C = map(int,input().split())

def F(A,B,C):
    if any(x&1 for x in [A,B,C]):
        return 0
    if A == B == C:
        return -1
    return 1 + F((A+B)//2,(B+C)//2,(C+A)//2)

answer = F(A,B,C)
print(answer)

Measured memory_bytes: 3064
X, K, D = map(int, input().split())
x = abs(X)
ans = 0
if x < D:
    if K % 2 == 0:
        ans = x
    else:
        ans = x - D
else:
    count = x // D
    if K < count:
        ans = x - D * K
    else:
        if (K - count) % 2 == 0:
            ans = x - D * count
        else:
            ans = x - D * (count + 1)
print(abs(ans))

Measured memory_bytes: 9188
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

int max(int a,int b){
    if(a>b) return a;
    else return b;
}

int main(){
    float  A,B,pA,pB,pA1,pB1;
    int answer;
    cin >> A>>B;
    pA=ceil(A/0.08);
    pA1=ceil(((A+1)/0.08)-1);
    pB=ceil(B/0.1);
    pB1=ceil(((B+1)/0.1)-1);
    if(pA1<pB || pB1<pA) answer = -1;
    else answer = max(pA,pB);
    cout << answer<< endl;
    return 0;
}






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

    int ans = 0;
    int divide = 1;
    int amari = 10;
    for(int i = 1; i < 9; i++){
        int tmp;
        if(i == 1){
          ans += n % amari;  
        }
        else{
            amari *= 10;
            divide *= 10;
            tmp = n % amari;
            ans += tmp / divide;
        }
    }

    if(n % ans == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# +の場合
i = 0
ans = 0
while ans <= 1000000000:
   i += 1
   ans = i**5 - (i-1)**5
# i: 120

# -の場合
i = 0
ans = 0
while ans <= 1000000000:
   i -= 1
   ans = i**5 - (i-1)**5 
# i: -119

n = int(input())
l = [_**5 for _ in range(120)]

for i in range(1,120):
    for j in range(120):
        if l[i] - l[j] == n:
            print(int(l[i]**0.2), int(l[j]**0.2))
            exit()
        if l[i] + l[j] == n:
            print(int(l[i]**0.2), int(-1*l[j]**0.2))
            exit()

Measured memory_bytes: 9392
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=1e9 + 7;
int OO=1e6;
const int N=1e6 + 5;
int arr[N];
bool visit[N];

ll len=3234566667;

ll n,m,k,cnt,SU,idx,MN,MX,T;
ll l,r,mid;
ll a,b,c,d;
vector<pair<int,int>> v;
vector<int> vec;
string str,s,t,ans;

set<ll> st;

void Solve(ll val,int last){
	
	if(val > len)
		return;
	//cerr<<val<<endl;
	st.insert(val);
	
	for(int i=max(last-1,0);i<=min(last+1,9);++i)
		Solve(val*10+i,i);

	
}

int main(){
	
	cin>>n;
	
	for(int i=1;i<10;++i)
		Solve(i,i);
	
	int idx=0;
	ll val;
	for(auto it=st.begin();it!=st.end();it++){
		if(idx<n)
			val=(*it);
		++idx;
	}
	
	cout<<val<<endl;
		
	
	

}









Measured memory_bytes: 4992
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
 
void main()
{
    auto N = readln.chomp.to!long;
    if (N == 2) {
        writeln(1);
        return;
    }
    int res;
    long d;
    for (d = 2; d^^2 < N; ++d) {
        if (N % d == 1) {
            auto dd = (N-1)/d;
            res += d == dd ? 1 : 2;
        }
        if (N % d == 0) {
            auto n = N;
            while (n%d == 0) n /= d;
            if (n % d == 1) {
                ++res;
            }
            auto dd = N / d;
            n = N;
            while (n % dd == 0) n /= dd;
            if (n % dd == 1) {
                ++res;
            }
        }
    }
    if (d^^2 == N) {
        ++res;
    }
    writeln(res+2);
}

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

int main() {
    int n;
    cin >> n;
    vector<int> d;
    d.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;

    return 0;
}


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


int main(){	
	long long R;
	long long B;
	long long G;
	long long N;
	scanf("%lld",&R);
	scanf("%lld",&G);
	scanf("%lld",&B);
	scanf("%lld",&N);
	long long res = 0;
	for (int i=0; i<=N/R; i++) {
		for (int j=0; j<=(N-i*R)/G; j++) {
			if ((N-i*R-j*G)%B == 0) res++;
		}
	}
	cout << res << endl;
	return 0;
}



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

map <int, int> mp;

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		int x; scanf("%d", &x);
		mp[x]++;
	}
	int res = 0;
	while (!mp.empty()){
		map <int, int> :: iterator it = mp.end();
		it--;
		int x = it->first;
		mp[x]--;
		if (mp[x] == 0) mp.erase(x);
		int tot;
		for (tot = 1; tot <= x; tot <<= 1);
		if (mp.count(tot - x)){
			mp[tot - x]--, res++;
			if (mp[tot - x] == 0) mp.erase(tot - x);
		}
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 9600
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
#define ull unsigned long long
#define mp make_pair

using namespace std;
int flag=1;
void dfs(int n)
{
    if(!flag)
        return;
    if(n<=0)
        return;
    if(n%4==0 || n%7==0)
    {
        flag=0;
        cout << "Yes" << endl;
        return;
    }

    if(n<4 || (n>4&&n<7))
    {
        flag=0;
        cout << "No" << endl;
        return;
    }
    dfs(n-4);
    n+=4;
    dfs(n-7);
    n+=7;
}
int main()
{
    int n;
    cin >> n;
    dfs(n);
    if(flag)
    {
        if(n==0)
            cout << "Yes2" << endl;
        else
            cout << "Nos" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int sum = 0;
		for(int i=0; i<n.length(); i++){
			sum += Integer.parseInt(n.substring(i,i+1));
		}
		System.out.println(Integer.parseInt(n)%sum == 0 ? "Yes" : "No");
	}
}


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

using namespace std;

#define int unsigned long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{
    double a;
    double b;
    cin >> a >> b;

    //int b100 = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
    int b100 = (int)(100 * b + 0.1);

    print((int)a * (b100) / 100);
}


Measured memory_bytes: 3668
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){

  int n; cin >> n;
  vector<int>  b(n-1);

  for(int i = 0; i < n-1; i++){
    int temp; cin >> temp;
    b[i] = temp;
  }


  int ans = b[0];
  for(int i = 1; i < n-1; i++){
    ans += min(b[i-1],b[i]);
  }
  ans += b[n-2];

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math

n, h = map(int, input().split())
ba = [tuple(map(int, reversed(input().split()))) for i in range(n)]
ba.sort(reverse = True)

ans = 2000000000

bs = [0]
for i in range(n):
    bs.append(bs[i] + ba[i][0])
    if bs[i + 1] >= h:
        ans = min(ans, i + 1)


for i in range(n):
    b, a = ba[i]

    L = i
    R = n
    while (R - L > 1):
        M = (L + R) // 2
        if ba[M][0] < a:
            R = M
        else:
            L = M
    if h - bs[R] < 0:
        continue
    ans = min(ans, R + math.ceil((h - bs[R]) / a))

print(ans)

Measured memory_bytes: 21364
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vector<ll> c(n);
	for (auto &v : c) {
		cin >> v;
	}

	vector<vector<ll>> places(210000);
	for (int i = 0; i < n; i++) {
		places[c[i]].push_back(i);
	}

	vector<ll> dp(210000);
	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i] += dp[i - 1];
		dp[i] %= MOD;

		int color = c[i - 1];
		int index = lower_bound(places[color].begin(), places[color].end(), i - 1)
			- places[color].begin();

		if (index == 0) {
			continue;
		}

		int j = places[color][index - 1];
		if ((i - 1) - j > 1) {
			dp[i] += dp[j + 1];
			dp[i] %= MOD;
		}
	}

	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 14592
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define REP(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  int n;
  cin >> n;
  vector<ll> a(3 * n);
  for (int i = 0; i < n * 3; i++) cin >> a[i];

  vector<ll> sum1(n * 2 + 1, 0);  //累積和
  priority_queue<ll, vector<ll>, greater<ll>> que1; //小さい方から取り出す

  for (int i = 0; i < n; i++) {
    que1.push(a[i]);
    sum1[i + 1] = sum1[i] + a[i];
  }
  for (int i = n; i < n * 2; i++) {
    ll now = que1.top();
    if (a[i] > now) {
      sum1[i + 1] = sum1[i] + a[i] - now;
      que1.pop();
      que1.push(a[i]);
    } else
      sum1[i + 1] = sum1[i];
  }

  vector<ll> sum2(2 * n + 1, 0);
  priority_queue<ll> que2;  //大きい方から取り出す
  for (int i = 0; i < n; i++) {
    sum2[i + 1] = sum2[i] + a[n * 3 - 1 - i];
    que2.push(a[3 * n - 1 - i]);
  }
  for (int i = n; i < n * 2; i++) {
    ll now = que2.top();
    if (a[n * 3 - 1 - i] < now) {
      sum2[i + 1] = sum2[i] - now + a[n * 3 - 1 - i];
      que2.pop();
      que2.push(a[n * 3 - 1 - i]);
    } else
      sum2[i + 1] = sum2[i];
  }

  ll res = -1e15;
  for (int i = n; i <= n * 2; ++i) {
    res = max(res, sum1[i] - sum2[n * 3 - i]);
  }
  cout << res << endl;
}

Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int a, b, c, d;
  while (scanf("%d %d %d %d", &a, &b, &c, &d) != EOF)
  {
    int turnsTakahashi = c / b + (c % b != 0);
    int turnsAoki = a / d + (a % d != 0);
    printf("%s\n", turnsTakahashi <= turnsAoki ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 3684
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,M = MI()
from collections import defaultdict

d = defaultdict(int)
for i in range(M):
    a,b = MI()
    d[a] += 1
    d[b] += 1

for i in range(1,N+1):
    print(d[i])

Measured memory_bytes: 64820
#include <stdio.h>
int main()
{ char c;
    int s,d,f,g,h,j,k,len;
    scanf("%d",&f);
    g=0;s=0;d=0;h=0;
    for(j=0;j<f;j++) {
        scanf(" %c", &c);


    if(c=='W'){
        g=1;
    } else if(c=='Y'){
        s=1;
    }else if(c=='P'){
        d=1;
    }
    else if(c=='G'){
        h=1;
    }}
    k=g+s+h+d;
    if(k==1){
        printf("One\n");
    } else if(k==2){
        printf("Two\n");
    } else if(k==3){
        printf("Three\n");
    } else if(k==4){
        printf("Four\n");
    }

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int[] antenas = new int[5];
        for (int i = 0; i < 5; i++) {
            antenas[i] = sc.nextInt();
        }

        int k = sc.nextInt();

        for (int i = 0; i < 4; i++) {
            for (int j = i; j < 5; j++) {
                if (Math.abs(antenas[i] - antenas[j]) > k) {
                    System.out.println(":(");
                    return;
                }
            }
        }

        System.out.println("Yay!");
    }
}


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

int main() {
  int n, a, b, c, d, ans=1, ml=0, l=0, num=0;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  for(int i = 0; i < min(c,d); i++){
    if(s[i] == '.')l++;
    else l=0;
    ml = max(ml, l);
    if(l==3) num++;
  }
  if(ml < 3 && d < c) s[min(c,d)-1] = '#';
  else if(num == 1 && ml == 3 && s[b-1]=='.' && s[b-2]=='.' && s[b-3]=='.') s[min(c,d)-1] = '#';
  for(int i = a-1; i < c-2;i++){
    if(i+1 == c)break;
    if(s[i] == '#' && s[i+1] == '#') {
      ans=0;
      break;
    }
  }
  for(int i = b-1; i < d-2;i++){
    if(i+1 == d) break;
    if(s[i] == '#' && s[i+1] == '#') {
      ans=0;
      break;
    }
  }
  if(ans) cout << "Yes";
  else cout << "No";
}

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

int main() {
  int N,K,x,L=0;
  cin >>N >>K ;
 
  for(N;N>0;N--){      
    cin >>x;
   
    if(K>=x){
      if(x<K-x) L+=x;
      else L+=K-x;
    }
   
    if(K<x){
      L+=x-K;
    }
  }
  
  cout <<L*2;
      
}
      


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N;
    cin>>N;
    N=N%10;
    if(N==3)cout<<"bon"<<endl;
    else if(N==0||N==1)cout<<"pon"<<endl;
    else if(N==6||N==8)cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;
vector<vector<int>> a(NMAX);
int ans;
int dfs(int node,int n, bool visit[NMAX]){

  bool all_visit=true;
  int ans=0;
  rep(i,n){
    if (visit[i]==false)all_visit=false;
  }
  if (all_visit) return 1;

  for (int to:a[node]){
    if (visit[to]==true)continue;
  //  cout<<to<<"to"<<node<<"node"<<endl;
    visit[to]=true;
    ans+=dfs(to,n,visit);
    visit[to]=false;


  }
return ans;
cout<<ans<<endl;
  }

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int a1,b1;
    cin>>a1>>b1;

    a1--;b1--;
    a[a1].push_back(b1);
    a[b1].push_back(a1);

  }
  bool visit[NMAX];
  rep(i,NMAX)visit[i]=false;
  visit[0]=true;
  cout<<dfs(0,n,visit);

}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int N;
double A[51];

signed main()
{
  cin >> N;
  REP(n,N) {
    cin >> A[n];
  }

  sort(A, A+N);

  FOR(n,1,N) {
    A[n] = (double)(A[n] + A[n-1])/2.0;
  }
  printf("%.10f\n", A[N-1]);

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

int C[110000];
vector<int> V[110000],ans,ans2;


void dfs(int x,int q){
    if(q==1) ans.push_back(x);
    else ans2.push_back(x);
    C[x]=1;
    bool flag=true;
    int nx;
    for(int next:V[x]){
        if(C[next]==0){
            flag=false;
            nx=next;
        }
    }
    if(flag) return;
    else dfs(nx,q);
}

int main(){
    int N,M;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    dfs(1,1);
    dfs(1,2);
    cout<<(int)ans.size()+(int)ans2.size()-1<<endl;
    reverse(ans2.begin(),ans2.end());
    for(int i=0;i<(int)ans2.size();i++){
        if(i) cout<<" ";
        cout<<ans2[i];
    }

    for(int i=1;i<(int)ans.size();i++){
        cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
}


Measured memory_bytes: 9592
S = input()

if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print("Yes")
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
    print("Yes")
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[2]:
    print("Yes")
else:
    print("No")


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

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

	for (int i = 1; i <= n; i++)
	{
		if (i % 3 == 0)
		{
			cout << " " << i;
		}
		else
		{
			for (int x = i; x != 0; x /= 10)
			{
				if (x % 10 == 3)
				{
					cout <<" "<< i ;
					break;
				}
			}
		}
		
		
	
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main()
{
	int a,b,k,i,j,ans[200];

	scanf("%d%d%d", &a, &b, &k);

	for (i = a; i <= b; i++)
	{
		if (i > a + k - 1 && i < b - k + 1)
			continue;

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

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
#define rp
int main()
{
   string s,t;
   cin>>s>>t;
int   n=s.size();
   s=s+s;
   bool f=false;
   for(int i=0;i<s.size();i++)
   {
       if(t==s.substr(i,n))
        f=true;
   }
   if(f)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
    return 0;

}


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

#define fi first
#define se second

typedef pair<int, int> pii;

const int MAXN = 1e5;

int a[MAXN];
int sum[MAXN][4];

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

	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') a[i+1] = 1;
		if (s[i] == 'G') a[i+1] = 2;
		if (s[i] == 'B') a[i+1] = 3;
	}

	for (int i = n; i >= 1; i--) for (int j = 1; j <= 3; j++) {
		sum[i][j] = (a[i] == j) + sum[i+1][j];
	}

	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (a[i] == a[j]) continue;
			int z = 1^2^3^a[i]^a[j];

			ans += sum[j+1][z];
			if (a[j + j - i] == z) ans--;
		}
	}

	cout << ans << '\n';
}

Measured memory_bytes: 3632
/***************************************** 
****       Solution by SlavicG        ****
*****************************************/
 
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm> 
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n) 
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool checkPrime(int n)
{
    if(n<2) return false;
    for(int x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
int binary_Search_Classic(int n, int arr[],int target){
	int l,r,mid;
	l=0;
	r=n-1;
	while(l<=r){
		mid= l+(r-l)/2;
		if(arr[mid] == target){
			return mid;
		}
		if(arr[mid] < target){
			l=mid+1;
		}else
		{
			r=mid-1;
		}
	}
	return -1;
}
int binary_Search_First_Greater(int n, int arr[],int target){
	int l,r,ans,mid;
	l = 0;
	r = n-1;
	ans=-1;
	while(l<=r){
		mid = l + (r-l)/2;
		if(arr[mid] > target){
			ans=mid;
			r=mid-1;
		}else{
			l = mid+1;
		}
	}
	return ans;
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m; 
    for (int i = 0; i < s.length(); i++) { 
        m[s[i]]++; 
    }
    return m.size(); 
} 
int main()
{
	int n;
	string s,k;
	cin >> s >> k;
	n = s.size();
	int ans=0;
	for(int i = 0;i<n;i++)
	{
		if(s[i] != k[i])ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3920
// Aizu Vol0 0096: Sum of 4 Integers II
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);

#define MAX  1000
#define MAX2 2000
#define MAX4 4000

int main()
{
	char buf[100];
	long long n, ans;
	int k;

	while (gets(buf) != NULL) {
		k = atoi(buf);
		if (k > MAX2) k = MAX4 - k;
		n = k + 1;
		ans = n * (n + 1) * (n + 2) / 6;
		if (k > MAX) {
			n = k - MAX;
			ans -= 2 * n*(n + 1)*(n + 2) / 3;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 528
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  A,V = readint()
  B,W = readint()
  T =readint()[1]

  C = abs(A-B)

  if V*T >= C + T*W
    println("YES")
  else
    println("NO")
  end
  
end

main()

Measured memory_bytes: 160900
N=int(input())
X=list(map(int, input().split()))
sortX=sorted(X)
small=sortX[int(N/2)-1]
big=sortX[int(N/2)]
if small==big:
    for i in range(0,N):
        print(small)
    exit()

for i in range(0,N):
    if X[i]>small:
        print(small)
    else:
        print(big)

Measured memory_bytes: 26772
#include<cstdio>
inline int in();
typedef long long ll;
inline void wr(ll);
int main(int argc,char**argv){
	register int n=in();
	wr(n*1ll*(n-1)/2),putchar('\n');
}
inline int in(){
	register char c=getchar();
	register int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+(c&15);
	return x*f;
}
inline void wr(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x/10ll)wr(x/10ll);
	putchar(x%10ll+'0');
}


Measured memory_bytes: 128
a, b = map(int, input().split())
cnt = 0
for i in range(a, b + 1):
    s = str(i)
    b = True
    for j in range(len(s)):
        if s[j] != s[-j-1]:
            b = False
            break
    if b:
        cnt += 1
print(cnt)


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

int main(void){
    int X,A,B;
    cin>>X;
    if(X==1){
        cout<<"Hello World"<<endl;
        return 0;
    }

    cin>>A>>B;
    cout<<A+B<<endl;
    return 0;
}

Measured memory_bytes: 256
INF_V = 1000*100
N, W = list(map(int, input().split()))
dp = [[W+1]*(INF_V+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    w, v = list(map(int, input().split()))
    for j in range(INF_V-1000+1):
        dp[i+1][j+v] = min(dp[i+1][j+v], dp[i][j] + w)
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
print([i for (i, w) in enumerate(dp[N]) if w <= W][-1])

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

int main(){
  long long A, B;
  cin >> A >> B;
  for(int i = 1; i <= B; i++){
    if((A * i) % B == 0){//Aの倍数がBでわりきれる
      cout << A * i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int a,b,c,d;
   cin >> a >> b >> c;
if (a > b){
   d = b ;
   b = a ;
   a = d ;
}

if (b > c){
   d = c ;
   c = b ;
   b = d ;
}

if (a > b ) {
   d = b ;
   b = a ;
   a = d ;
}
   cout << a << " " << b << " " << c << endl;

}

Measured memory_bytes: 1164
N,K = map(int,input().split())
x = list(map(int,input().split(" ")))

ans = abs(x[0]) + abs(x[K-1] - x[0])
for i in range(N-K+1):
    xl = x[i]
    xr = x[i+K-1]
    tmp = abs(xl) + abs(xr - xl)
    if tmp > abs(xr) + abs(xr - xl):
        tmp = abs(xr) + abs(xr - xl)
    if (ans > tmp):
        ans = tmp
print(ans)

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



//defines...
#define ll long long
#define tata return;
#define pb push_back
#define mp make_pair
#define in insert
#define run ios_base::sync_with_stdio(false);cin.tie(NULL);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define vec vector<ll>
#define setl set<ll>
#define mapl map<ll,ll>
#define shunno cout<<0<<endl;
#define ek cout<<1<<endl;
#define pi 2*acos(0.0)1
#define hobena cout<<-1<<endl;




//typedefs...
typedef pair<ll,ll>pll;

//const..
//const ll fx[]={0,1,0,-1};
//const ll fy[]={1,0,-1,0};
const ll mod=1e9+7;

/*ll ncr(ll n, ll k)
{
    ll res = 1;


    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
*/
 mapl m;
ll f(ll x)
{
    ll a,b;
    while(x>0)
    {
        a=x%10;
        x/=10;
        if(m[a]==1)
            return 0;
    }
    return 1;
}
void oka()
{
    ll n,i,j,k;

    cin>>n>>k;
    ll a[k];
    for(i=0;i<k;i++)
        cin>>a[i],m[a[i]]=1;
    i=n;
    while(1)
    {
        if(f(i)){
            cout<<i<<endl;
            break;
            }
            i++;
    }


}















int main()
{
  // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    run
    ll t;
    t=1;
  //cin>>t;
    while(t--){

    oka();
    }



}



Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    int a, b, c, d; cin >> a >> b >> c >> d;
    int res = a*b > c*d ? a*b : c*d;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,k;
  cin >> a >> b >> k;
  if(k > a){
    b -= (k - a);
    a = 0;
    if (b < 0){
      b = 0;
    }
  }else{
    a -= k;
  }
  cout << a << " " << b << endl;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];

int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    sort(A, A + N);
    ll m = 0;
    vector<pll> ans;

    if (A[0] * A[N - 1] < 0)
    {
        //! 絶対値の和になる
        REP(i, N)
        {
            m += abs(A[i]);
        }

        vector<ll> x, y;
        REP(i, N)
        {
            if (A[i] >= 0)
                x.push_back(A[i]);
            else
                y.push_back(A[i]);
        }

        ll P = x[x.size() - 1];
        ll M = y[y.size() - 1];
        x.pop_back();
        y.pop_back();
        REP(i, x.size())
        {
            ans.push_back(pll(M, x[i]));
            M -= abs(x[i]);
        }
        REP(i, y.size())
        {
            ans.push_back(pll(P, y[i]));
            P += abs(y[i]);
        }
        ans.push_back(pll(P, M));
    }
    else
    {
        ll min = INF;
        REP(i, N)
        {
            m += abs(A[i]);
            min = std::min(min, abs(A[i]));
        }
        m -= 2 * min;
        ll s = A[0];
        if (A[0] < 0)
        {
            s = A[N - 1];
            REP(i, N - 1)
            {
                ans.push_back(pll(s, A[i]));
                s += abs(A[i]);
            }
        }
        else
        {
            REP(i, N - 2)
            {
                ans.push_back(pll(s, A[N - 1 - i]));
                s -= abs(A[N - i - 1]);
            }
            ans.push_back(pll(A[1], s));
        }
    }

    cout << m << endl;
    REP(i, N - 1)
    {
        cout << ans[i].first << " " << ans[i].second << endl;
    }

    return 0;
}

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

using namespace std;

int main(){
  int n, r;
  vector<int> card;
  card.reserve(100);
  while(true){
    cin >> n >> r;
    if(!n && !r) break;
    card.clear();
    // 1 .. n
    for(int i = 1; i <=n ; i++){
      card.push_back(i);
    }

    for(int i = 0; i < r; i++){
      int p, c;

      cin >> p >> c;
      if(n == c) continue;
      
      vector<int>::iterator it = card.end() - p - c + 1;
      
      // temp
      for(int j = 0; j < c; j++){
        card.push_back(*it);
        it++;
      }
      //erase
      card.erase(it  - c, it);
      
      /*
        it = card.begin();
        while(it != card.end()){
        cout << " " << *it;
        it++;
        }
        cout << endl;
      */
    }
    cout << card[n-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1220