akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    if len(s)==2:
        print(s)
    else:
        print(s[::-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            Console.WriteLine(s.Replace("2017", "2018"));
        }
    }
}


Measured memory_bytes: 25876
def abc():
    a1, a2, a3 = map(int, input().rstrip().split())
    costs = list()
    costs.append(abs(a1 - a2))
    costs.append(abs(a1 - a3))
    costs.append(abs(a2 - a3))
    costs.sort()
    print(costs[0] + costs[1])


abc()


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>

using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
long long int euc(long long int x,long long int y)
{
    while(x%y!=0 && y%x!=0)
    {
        if(x>y)x=x%y;
        else if(x<y)y=y%x;
    }
    if(x>y)return y;
    else return x;
}

int main()
{
    long int n;
    long long int x;
    long long int za[100005]={};
    long long int xx;
    scanf("%ld %lld\n",&n,&x);
    REP(i,n)
    {
        scanf("%lld",&xx);
        za[i]=(xx-x)*((xx-x>0)*2-1);
    }
    for(int i=n-2;i>=0;i--)
    {
        za[i]=euc(za[i],za[i+1]);
        za[i+1]=0;
    }
    printf("%lld\n",za[0]);
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var K, A, B int
	fmt.Scan(&K, &A, &B)
	for i := A; i <= B; i++ {
		if i%K == 0 {
			fmt.Println("OK")
			return
		}
	}
	fmt.Println("NG")
}


Measured memory_bytes: 1752
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  long long int A = 0,B = 0,C = 0,D = 0;
  cin >> A >> B >> C >> D;
  long long int a = 0,b = 0,c = 0,g = 0,l = 0;
  long long int aa = 0,bb = 0,cc = 0,dd = 1;
  aa = C,bb = D;
  while(dd != 0){
    cc = aa/bb;
    dd = aa%bb;
    aa = bb;
    bb = dd;
  }
  l = aa;
  a = B/C;
  b = B/D;
  g = C*D/l;
  c = B/g;
  //cout << g << endl;
  //cout << a << b << c << endl;
  long long int answer = B - (a + b - c);
  a = (A - 1)/C;
  b = (A - 1)/D;
  //g = C*D/l;
  c = (A-1)/g;
  //cout << a << b << c << endl;
  answer = answer - (A - (a + b - c));

  cout <<  answer  + 1 << endl;
}

/*#include<bits/stdc++.h>
using namespace std ;
#define rep(i,N) for(int i = 0 ; i <(N) ; i++)
typedef long long ll;


ll f(ll x , ll C , ll D){
  ll res = x ;
  res -= x/C ;
  res -= x/D ;
  res += x/lcm(C,D) ;
  return res ;
}


int main(){
  ll A , B  ;
  ll C , D ;
  cin >> A >> B >> C >> D ;

  ll ans = f(B, C ,D) - f(A-1,C,D) ;
  cout << ans << endl ;
  return 0 ;

}*/


Measured memory_bytes: 3600
#include<stdio.h>
int main(void)
{
	int n,m,z[100],t,i,j;
	scanf("%d %d", &n, &m);
	for(i=0; i<n; i++)
	scanf("%d", &z[i]);
	for(i=1; i<=m; i++)
	{
		for(j=0; j<n-1; j++)
		{
			if(z[j]%i>z[j+1]%i)
			{
				t=z[j];
				z[j]=z[j+1];
				z[j+1]=t;
			}
		}
	}
	for(i=0; i<n; i++)
	printf("%d\n", z[i]);
	
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll x(n);
    ll ans = LONG_LONG_MAX;
    rep(i,n) cin>>x[i];
    FOR(i,1,100){
        ll sum=0;
        rep(j,n){
            sum+=(i-x[j])*(i-x[j]);
        }
        chmin(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i != n // i:
                divisors.append([i, n//i])
            else:
                divisors.append([i, i])
    return divisors


n = int(input())
d = make_divisors(n)[-1]
print(len(str(max(d[0], d[1]))))


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int Y = stdIn.nextInt() / 1000;
		
		int ans10 = -1;
		int ans5 = -1;
		int ans1 = -1;
		
		for(int i = 0; i <= N; i ++) {
			for(int j = 0; j <= N - i; j ++) {
				if(10 * i + 5 * j + (N - i - j) == Y) {
					ans10 = i;
					ans5 = j;
					ans1 = N - i - j;
					break;
				}
			}
		}
		
		System.out.println(ans10 + " " + ans5 + " " + ans1);
	}
}

Measured memory_bytes: 22612
w = int(raw_input())
n = int(raw_input())
a = []
for i in range(n):
  a.append(map(int, raw_input().split(',')))
r = range(1,w + 1)
for i in a:
  tmp = r[i[0] - 1]
  r[i[0] - 1] = r[i[1] - 1]
  r[i[1] - 1] = tmp
for i in r:
  print i

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

using namespace std;

typedef long long int64;

int main()
{
  int64 N, A, B, C, D, dist;
  cin >> N >> A >> B >> C >> D;

  dist = B - A;
  
  int64 l_a, r_a, l_b, r_b;
  for (int i = 0; i < N; ++i) {
    l_a = C * i;
    r_b = D * i;
    l_b = C * (N - i - 1);
    r_a = D * (N - i - 1);

    if (l_a - r_a <= dist && dist <= r_b - l_b) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>
#include<cmath>
#include<queue>

typedef long long ll;
using namespace std;
#define mod 10007
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
    ll n,k;cin >> n >> k;
    ll g;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    g=(n-2)/(k-1)+1;
    cout << g << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,i,sum=0;
    cin>>n;
    for(i=1;i<=n;i++){
        if(i%3!=0   && i%5!=0  )
            sum+=i;
        }
   cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>

using namespace std;

int grid[256][256];
int hor[256][256],ver[256][256],ske1[256][256],ske2[256][256];

int main()
{
	for(int n;scanf("%d ",&n),n;){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++)	grid[i][j]=getchar()-'0';
			getchar();
		}

		for(int i=0;i<n;i++){
			hor[i][0]=grid[i][0];
			ver[0][i]=grid[0][i];
			ske1[0][i]=ske2[0][i]=grid[0][i];
			ske1[i][0]=grid[i][0];
			ske2[i][n-1]=grid[i][n-1];
		}

		for(int i=0;i<n;i++){
			for(int j=1;j<n;j++){
				hor[i][j]=grid[i][j]?hor[i][j-1]+1:0;
				ver[j][i]=grid[j][i]?ver[j-1][i]+1:0;
			}
		}

		for(int i=1;i<n;i++){
			for(int j=1;j<n;j++){
				ske1[i][  j  ]=grid[i][  j  ]?ske1[i-1][j-1]+1:0;
				ske2[i][n-j-1]=grid[i][n-j-1]?ske2[i-1][n-j]+1:0;
			}
		}

		int lmax=0;
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)
			lmax=max(lmax,max(max(hor[i][j],ver[i][j]),max(ske1[i][j],ske2[i][j])));
		printf("%d\n",lmax);
	}

	return 0;
}

Measured memory_bytes: 0
//
//  main.cpp
//  atcoderdemo
//
//  Created by apple on 2019/6/29.
//  Copyright © 2019 apple. All rights reserved.
//

#include <iostream>
#include <string.h>
#include <queue>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int sum[maxn];
int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    sort(a+1,a+n+1);
    cout << a[n/2+1] - a[n/2];
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end(),[](int x,int y){return x>y;});
	int I;
	for(int i=0;i<n;i++) if(i+1<=a[i]) I=i;
	int num=0;
	for(int i=I+1;i<n;i++) if(a[i]==I+1) num++;
	if(num%2==1||(a[I]-I-1)%2==1) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}

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

int main(){
    string a,b;
    cin >> a >> b;
    int cnt=a.length();
    int cnt2=b.length();
    int flag=0;
    for(int i=0;i<cnt;i++)
        if(a[i]!=b[i])
            flag=1;
    if(flag)
        cout << "No";
    else
        cout << "Yes";
}


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

int main(){
  int N,K,W=0;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    int X;
    cin >> X;
    if(X<=K-X){
      W+=2*X;
    }
    else{
      W+=2*(K-X);
    }
  }
  cout << W << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
using ll = long long;
 
int main() {
    int n;
    cin >> n;
    while(n>10){
        n =n%10;
    }
    if(n==3)
    cout << "bon" << endl;
    else if(n==0||n==1||n==6||n==8)
    cout << "pon" << endl;
    else
    {
        cout << "hon" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;
  
  vector<string> C(h);
  
  for (int i = 0; i < h; i++) {
    cin >> C.at(i);
  }

  vector<string> A(2*h);
  
  int s = 0;
  
  for (int i = 0; i < 2*h; i++) {
    s = i / 2;
    A.at(i) = C.at(s);
    cout << A.at(i) << endl;

  }
  
 
 
}
        

Measured memory_bytes: 3648
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll i;
    cin >> i;
    int cou = 1;
    ll x = 26;
    while(i) {
        if(i > x) {
            i -= x;
            x *= 26;
            cou++;
        } else {
            x = i;
            break;
        }
    }

    x--;


    string s;
    rep(i, cou) {
        s += char('a' + x%26);
        x /= 26;
    }

    reverse(all(s));
    cout << s << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <queue>
#define ll long long int
#define inf 3e18+1
#define all(v) (v).begin(),(v).end() 
#define N 200005
#define F first
#define S second
using namespace std;
ll mod=1e9+7;
int main()
{
    // added the two lines below 
    ios_base::sync_with_stdio (false); 
    cin.tie(NULL);
    cout.tie(0);    
    ll test=1;//cin>>test;
    while(test--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
    }
    return 0;
}




Measured memory_bytes: 3596
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var x1 = int.Parse(line[0]);
        var y1 = int.Parse(line[1]);
        var w1 = int.Parse(line[2]);
        var h1 = int.Parse(line[3]);
        line = Console.ReadLine().Trim().Split(' ');
        var x2 = int.Parse(line[0]);
        var y2 = int.Parse(line[1]);
        var w2 = int.Parse(line[2]);
        var h2 = int.Parse(line[3]);
        var xmax = Max(x1 + w1, x2 + w2);
        var ymax = Max(y1 + h1, y2 + h2);
        var map = new bool[xmax, ymax];
        for (int i = 0; i < h1; i++)
            for (int j = 0; j < w1; j++)
                map[j + x1, i + y1] = true;
        var count = 0;
        for (int i = 0; i < h2; i++)
            for (int j = 0; j < w2; j++)
                if (map[j + x2, i + y2]) count++;
        var ans = h1 * w1 + h2 * w2 - 2 * count;
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 17928
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n % 2 == 0) {
			System.out.println(n / 2 - 1);
		}else if (n % 2 == 1) {
			System.out.println(n / 2);
		}
	}
}

Measured memory_bytes: 35864
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define int ll

using namespace std;

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

const int INF = 1e9 + 7;
int a, b, c, d;

int n(int x) {
	return b/x - (a-1)/x;
}

int32_t main()
{
	IO_OP;
	
	cin >> a >> b >> c >> d;
	cout << b-a+1 - n(c) - n(d) + n(c*d/__gcd(c, d)) << endl;
}



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

bool func(string s) {
  if (s.size() % 2 == 1) {
    return false;
  }
  int tmp = s.size()/2;
  string t = s.substr(0, tmp), u = s.substr(tmp, tmp);
  if (t == u) {
    return true;
  }
  else {
    return false;
  }
}

int main() {
  string s;
  cin >> s;
  int ans;
  while (true) {
    s.pop_back();
    if (func(s)) {
      ans = s.size();
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())

hour = (60 * H + M) / 2
minute = 6 * M
degree = abs(hour - minute)
nijou = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(degree))
print(math.sqrt(nijou))


Measured memory_bytes: 9496
import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y  = sc.nextInt();
    int z  = sc.nextInt(); 
    boolean b = true;
    for(int i = y; i <= z; i++)
    {
      if(i % x == 0)
        b = false;
    }
    if(b == false)
      System.out.println("OK");
    else
      System.out.println("NG");
  }
}


Measured memory_bytes: 35552
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    int k;
     cin>> k;
     if(k&1)
     print((k+1)/2*(k/2));
     else
     {
         print((k/2*(k/2)));
     }
     
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, W, H;
  cin >> N >> W >> H;
  vector<int> x(N), y(N);
  for (int i = 0; i < N; i++){
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }
  vector<vector<int>> id1(H);
  vector<vector<int>> id2(W);
  for (int i = 0; i < N; i++){
    id1[y[i]].push_back(i);
    id2[x[i]].push_back(i);
  }
  vector<vector<int>> E(N);
  for (int i = 0; i < H; i++){
    if (id1[i].size() > 1){
      for (int j = 1; j < id1[i].size(); j++){
        E[id1[i][0]].push_back(id1[i][j]);
        E[id1[i][j]].push_back(id1[i][0]);
      }
    }
  }
  for (int i = 0; i < W; i++){
    if (id2[i].size() > 1){
      for (int j = 1; j < id2[i].size(); j++){
        E[id2[i][0]].push_back(id2[i][j]);
        E[id2[i][j]].push_back(id2[i][0]);
      }
    }
  }
  vector<bool> used(N, false);
  vector<int> cc(4, 0);
  int cnt = 0;
  for (int i = 0; i < N; i++){
    if (!used[i]){
      used[i] = true;
      cnt++;
      queue<int> Q;
      Q.push(i);
      vector<bool> ok(4, false);
      while (!Q.empty()){
        int v = Q.front();
        Q.pop();
        if (y[v] == 0){
          ok[0] = true;
        }
        if (y[v] == H - 1){
          ok[1] = true;
        }
        if (x[v] == 0){
          ok[2] = true;
        }
        if (x[v] == W - 1){
          ok[3] = true;
        }
        for (int w : E[v]){
          if (!used[w]){
            used[w] = true;
            Q.push(w);
          }
        }
      }
      for (int j = 0; j < 4; j++){
        if (ok[j]){
          cc[j]++;
        }
      }
    }
  }
  if (cnt == 1){
    cout << N - 1 << endl;
  } else {
    cout << N - 1 + cnt - *max_element(cc.begin(), cc.end()) << endl;
  }
}


Measured memory_bytes: 11496
#include <iostream>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    ll n;   cin >> n;
    if(n%2){
        cout << 0 << endl;
    }else{
        ll ans = 0;
        for(ll i = 10; i <= n; i *= 5)  ans += n/i;
        cout << ans << endl;
    }
}


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

int main(){
  string s;
  cin >> s ;
  int ans = 0;
  for(int i=0;i<4;i++){
    if(s[i] == '+')ans += 1;
    if(s[i] == '-')ans -= 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	cout << n/3 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int m = 0;
  REP(i, 4){
    int n; cin >>n;
    m += n;
  }
  cout <<m / 60 <<endl <<m % 60 <<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
	int a[4] = {0};

	while(scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF ) {

	int b[4] = {0};
	int i, j, k, hit = 0, blow = 0;

	for(i = 0; i < 4; i++){
		scanf("%d", &b[i]);
		for(j = 0; j < 4; j++)
			if(b[i] == a[j]){
				if(i == j)
					hit++;
				else
					blow++;
				break;
			}
	}

	printf("%d %d\n", hit, blow);

	}
	return 0;

}

Measured memory_bytes: 596
#include <cstdint>
#include <iostream>

using namespace std;

int64_t f(int64_t n, int64_t x) {
  return n == -1 ? 0 : n / x + 1;
}

int main() {
  int64_t a, b, x;
  cin >> a >> b >> x;
  cout << f(b, x) - f(a - 1, x) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+10;
ll n,m,k,p;
ll x[N],id[N],sta[N],ans[N],vis[N];
int main(){
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) scanf("%lld",&x[i]),id[i]=i;
	for(ll i=n;i>=1;i--) x[i]-=x[i-1];
	scanf("%lld%lld",&m,&k);
	for(ll i=1;i<=m;i++) scanf("%lld",&p),swap(id[p],id[p+1]);
	for(ll i=1;i<=n;i++){
		if(!vis[i]){
			ll cnt=0;
			for(ll j=i;!vis[j];j=id[j]) sta[++cnt]=j,vis[j]=1;
			for(ll j=1;j<=cnt;j++) ans[sta[j]]=x[sta[(j+k-1)%cnt+1]];
		}
	}
	for(ll i=1;i<=n;i++) ans[i]+=ans[i-1],printf("%lld.0\n",ans[i]);
}

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

signed main(){
  int n,m=0;cin>>n;
  vector<int> a(n+1,0),ball(n+1,0),ans(0);
  rep(i,n)cin>>a[i+1];

  for(int i=n;0<i;i--)
  {
    int cnt=1,sum=0;
    while(cnt*i<=n){
      sum^=ball[i*cnt];
      cnt++;
    }

    if(sum!=a[i]){
      m++;
      ball[i]=1;
      ans.push_back(i);
    }
  }

  cout<<m<<endl;
  rep(i,m)cout<<ans[i]<<" ";
  cout<<endl;
}

Measured memory_bytes: 3064
n = int(input())
d = { }
for _ in range(n):
  s = input()
  if s not in d:
    d[s] = 0
  d[s] += 1

  
max_cnt = max(d.values())

max_keys = [s for s, i in d.items() if i == max_cnt]

max_keys.sort()
for k in max_keys:
  print(k)


Measured memory_bytes: 35352
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    map<pair<int,int>,int> mp;
    for(int i = 1;i <= n;i++)
    {
        int a = i % 10;
        int x = i;
        while(x >= 10)
        {
            x /= 10;
        }
        int b = x;
        pair<int,int> p = make_pair(a,b);
        mp[p]++;
    }
    long long int ans = 0;
    for(int i = 1;i <= n;i++)
    {
        int a = i % 10;
        int x = i;
        while(x >= 10)
        {
            x /= 10;
        }
        int b = x;
        pair<int,int> p = make_pair(b,a);
        ans += mp[p];
    }
    cout << ans << "\n";

    return 0;
}

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

using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using ull = unsigned long long;

#define NL '\n'
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sii(x, y) scanf("%d%d",&x, &y)
#define sll(x, y) scanf("%lld%lld",&x, &y)

#define xx first
#define yy second
#define ins insert
#define mp make_pair
#define pb push_back
#define mdx ((l+r)>>1)
#define ldx ((idx<<1))
#define rdx ((idx<<1)|1)
#define sz(x) x.size()
#define pi 2.0*acos(0.0)
#define sqr(x)  ((x) * 1ll * (x))
#define all(x) (x).begin(),(x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define file_in(); freopen("input.txt", "r", stdin);
#define file_out(); freopen("output.txt", "w", stdout);
#define file_err(); freopen("serr.txt", "w", stderr);
#define rep(ii,aa,bb) for(ll (ii)=ll(aa);(ii)<(ll)(bb);++(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define _runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

template<class T> T setbit(T n, T pos){n=n|(1<<pos); return n;}
template<class T> T checkbit(T n, T pos){n=n&(1<<pos); return n;}
template<class T> T gcd(T a, T b ) {return b<=0?a:gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return ((a / gcd(a,b) ) * b);}





const int mxx = 1e5+9;
int n, a[mxx], dp[mxx];

int fun(int pos){
	if(pos + 1 == n) return 0;
	if(dp[pos] == -1){
		dp[pos] = (abs(a[pos+1]-a[pos]) + fun(pos + 1));
		if(pos + 2 != n) dp[pos] = min(dp[pos], (abs(a[pos+2]-a[pos]) + fun(pos + 2)));
	}
	return dp[pos];
}

int main(){
	mem(dp, -1);
	cin >> n; rep(i, 0, n) cin >> a[i];
	cout << fun(0) << NL;
}

Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	char a;
	cin >> a;
	if(a >= 'A' && a <= 'Z'){
		cout << 'A';
	}
	else{
		cout << 'a';
	}
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
 int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a>=b*pow(2,k)){
    cout<<"No"<<endl;
    return 0;
  }
 while(a>=b){
   b*=2;
   k--;
 }
 if(b>=c*pow(2,k)){
   cout<<"No"<<endl;
   return 0;
 }
  cout<<"Yes"<<endl;  
return 0;
}

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

int main() {
        int n;
        cin >> n;
        string c;
        cin >> c;
        int num_w = count(c.begin(), c.end(), 'R');
        string sub = c.substr(0, num_w);
        cout << count(sub.begin(), sub.end(), 'W') << endl;
}

Measured memory_bytes: 3752
package main

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

func main() {
	N := ReadInt()
	f := make([]int, N+1)
	for x := 1; x*x < N; x++ {
		for y := 1; y*y < N; y++ {
			for z := 1; z*z < N; z++ {
				v := x*x + y*y + z*z + x*y + y*z + z*x
				if v <= N {
					f[x*x+y*y+z*z+x*y+y*z+z*x]++
				}
			}
		}
	}
	for i := 1; i <= N; i++ {
		fmt.Println(f[i])
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1992
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
ls = [A,B,C,D,E]

last = -1
amari = 10
tmp = -1
for i in range(5):
    if ls[i] %10 != 0:
        if amari > ls[i] % 10:
            amari = ls[i] % 10
            tmp = i
        ls[i] += 10 -ls[i] % 10

print(sum(ls)-(10-amari))


Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 文字列の入力
        String[] s1 = sc.next().split("");
        String[] s2 = sc.next().split("");
        String[] s3 = sc.next().split("");
        
		String s1First = s1[0].toUpperCase();
        String s2First = s2[0].toUpperCase();
        String s3First = s3[0].toUpperCase();
    
		// 出力
		System.out.println(s1First + s2First + s3First);
	}
}


Measured memory_bytes: 21716
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(m)]

# create graph
g = []
for i in range(n):
    g.append(set())

for i in range(m):
    g[l[i][0]-1].add(l[i][1]-1)
    g[l[i][1]-1].add(l[i][0]-1)

# search
ans = 0
for i in range(n):
    if len(g[i]) == 0:
        ans += 1
        continue
    else:
        flag = True
        gt = tuple(g[i])
        for j in range(len(g[i])):
            if h[i] <= h[gt[j]]:
                flag = False
                break
        if flag:
            ans += 1

print(ans)


Measured memory_bytes: 63620
#define _GLIBCXX_DEBUG
#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()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;


int main(){
  string s, t;
  cin >> s >> t;
  reverse(ALL(t));
  if (s == t) cout << "YES\n";
  else cout << "NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  double ans = (double)w*h/2;
  int ans2 = 0;
  if(w==x*2 && h==y*2) ans2 = 1;
  cout << fixed << setprecision(6) << ans << " " << ans2 << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M =N % 10 ;
        String S="";
        switch(M){
          case 2:
          case 4:
          case 5:
          case 7:
          case 9:
            S="hon";
            break;
          case 0:
          case 1:
          case 6:
          case 8:
            S="pon";
            break;
          case 3:
            S="bon";
            break;
        }
      System.out.println(S);
	}
  
      
}

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

int main(){
  int a[5];
  rep(i,5){
    cin >> a[i];
    if(a[i] == 0){
      cout << i + 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3532
#include <stdio.h>
#define N 100

int main(){
  int key,i,j,k,num;
  int A[N];
  scanf("%d",&num);
  for(i=0;i<num;i++)scanf("%d",&A[i]);

  for(k=0;k<num;k++){
    printf("%d",A[k]);
    if(k!=num-1) printf(" ");
  }
  printf("\n");
  
  for(i=1;i<num;i++){
    key=A[i];
    j=i-1;
    
    while(j>=0&&A[j]>key){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=key;
    for(k=0;k<num;k++){
      printf("%d",A[k]);
      if(k!=num-1) printf(" ");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#define endl '\n'
#define ll long long

using namespace std;

int main(void)
{
        cin.tie(NULL); ios_base::sync_with_stdio(false);
        int N; cin >> N; vector<int> vec(N, 0);
        for(int i = 0; i < N; i++) cin >> vec[i];
        int ret = INT_MAX;

        for(int i = -100; i <= 100; i++)
        {
                int temp = 0;
                for(int j = 0; j < vec.size(); j++)
                {
                        temp += (vec[j] - i) * (vec[j] - i);
                }
                ret = min(ret, temp);
        }
        cout << ret << endl;

        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	int n, d, x;
	cin >> n >> d >> x;
	int ans = 0;
	for (int i = 0;i < n;i++) {
		int a;
		cin >> a;
		for (int j = 0;j*a + 1 <= d;j++) {
			ans++;
		}
	}
	cout << ans + x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
int a,b;
int main(){ _;
  cin>>a>>b;
  int ans = max(max(a+b,a-b),a*b);
  cout<<ans<<endl;

  return 0;
}


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

int main()
{
	long long n ;
	long long G = 0 ;
	map <string , long long> name ;
	string str ;
	cin >> n ;
	while(n --)
	{
		cin >> str ;
		sort(str.begin() , str.end()) ;
		name[str] ++ ;
		if(name[str] > 1)
		{
			G += name[str] - 1 ;
		}
	}
	cout << G << endl ;
	return 0 ;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  ll A[N];
  vector<ll> S;
  rep(i,N) {
    cin >> A[i];
    if(i-A[i]>0) S.push_back(i-A[i]);
  }
  sort(S.begin(), S.end());
  ll ans=0;
  rep(i,N-1)
    ans+=upper_bound(S.begin(), S.end(),i+A[i])-lower_bound(S.begin(), S.end(),i+A[i]);
  cout << ans << endl;
}

Measured memory_bytes: 6820
#include<stdio.h>

int main(void){
    int a,b,c;
    if(scanf("%d %d %d", &a, &b, &c) == 3);
    if(a<=c && c<=b){
        printf("Yes\n");
    }else if(b<=c && c<=a){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int ans;
int main()
{
      int a[100001],n;
      cin>>n;
      for(int i=1;i<=n;i++)
      {
             cin>>a[i];
             if(a[i]%2==1)   ans++;
      }
     if(ans%2==1)   cout<<"NO"<<endl;
     else                cout<<"YES"<<endl;
      return 0;
}

Measured memory_bytes: 640
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
// clang-format on

int main() {
  int n = in();
  auto v = in(vector<int>(n));
  make_heap(all(v));
  rep(i, n) cout << ' ' << v[i];
  cout << endl;
}



Measured memory_bytes: 4552
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CLOOP        while (true)
#define FLOOP(i, n)  for (int i = 0; i < (n); i++)
#define FOR(i, f, l) for (int i = (f); i < (l); i++)
#ifdef DEBUG
#define DUMP(var)   cerr << "[DEBUG] " << #var << ": " << var << endl
#else
#define DUMP(var)
#endif

#define LL long long

using namespace std;

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

    int n, x, t;
    cin >> n >> x >> t;

    cout <<  ((n+(x-1))/x)*t << endl;

    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ers erase
#define ins insert
#define F first
#define S second
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;


using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;


const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MAXN = 2e5 + 10;
const ll INF = 1e18;
ll H, W, n;
map<pll, int> ma;
ll ans[10];

ll isval(int x, int y){
	return (x >= 1 && x <= H && y >= 1 && y <= W);
}
ll te(int x, int y){
	ll Cnt = 0;
	ll f = 1;
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			if (ma.count({i + x, j + y}) == 1) Cnt ++;
			f &= isval(i + x, i + y); 
		}
	}
	if (f!= 0) ans[Cnt] ++;
	
	
	
	
}



ll solve(ll x, ll y){
	//cout << x << ' ' << y << '\n'; 
 	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			te(x - i, y - j);
		}
	}
	
	
}
pll a[MAXN];


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> H >> W >> n;
	ll t, t1;
	for (int i = 0; i < n; i++) cin >> t >> t1, ma[{t, t1}] = 1, a[i] = {t, t1};
	for (int i = 0; i < n; i++) solve(a[i].F, a[i].S);
	ll Cnt = (H - 2) * (W - 2);
	ll Sum = 0;
	for (int i = 1; i < 10; i++) Sum += ans[i] / i;
	cout << Cnt - Sum << '\n';
	for (int i = 1; i < 10; i++) cout << ans[i] / i << '\n';
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/





Measured memory_bytes: 10112
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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




bool check(int lt, int mid, int rt, std::string &lcond, std::string &cond, std::string & rcond){
    //true: 左側
    if((mid - lt) % 2){
        if(lcond == cond) return true;
        return false;
    }else{
        if(lcond == cond) return false;
        else true;
    }
}

int main(){
    int N; std::cin >> N;
    int lt(0), rt(N-1), mid;
    std::string lcond, rcond, cond;
    std::cout << lt << std::endl;
    std::cin >> lcond;
    if(lcond == "Vacant") return 0;
    std::cout << rt << std::endl;
    std::cin >> rcond;
    if(rcond == "Vacant") return 0;
    for(int j(0); j < 18; ++j){
        mid = (lt + rt) / 2;
        std::cout << mid << std::endl;
        std::cin >> cond;
        if(cond == "Vacant") return 0;
        if(check(lt, mid, rt, lcond, cond, rcond)){
            rt = mid; rcond = cond;
        }else{
            lt = mid; lcond = cond;
        }
    }
    return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <array>
#include <algorithm>
#include <cstdlib>

int main()
{
    std::array<long long, 3> X;
    for (int i = 0; i < 3; ++i)
    {
        std::cin >> X[i];
        if (X[i] % 2 == 0)
        {
            std::cout << 0 << std::endl;
            return EXIT_SUCCESS;
        }
    }
    std::sort(X.begin(), X.end());
    std::cout << X[0] * X[1] << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();

	}

	final long MODULO = 1_000_000_000 + 7;
	final long[][] A = { { 1, 0, 1 }, { 2, 1, 2 }, { 1, 1, 2 } };
	final long[][] B = { { 1, 0, 0 }, { 2, 1, 0 }, { 1, 1, 1 } };

	void solve(long n, int m, int[] x) {
		long[][] a = { { 1 }, { 2 }, { 1 } };
		if (m == 0)
			a = mul(pow(A, n - 1), a);
		else {
			a = mul(pow(A, x[0] - 1), a);
			a = mul(B, a);
		}
		for (int i = 1; i < m; ++i) {
			a = mul(pow(A, (x[i] - 1) - x[i - 1]), a);
			a = mul(B, a);
		}
		if (m > 0)
			a = mul(pow(A, (n - 1) - x[m - 1]), a);
		System.out.println(a[2][0]);
	}

	void run() throws IOException {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int m = sc.nextInt();
		int[] x = new int[m];
		for (int i = 0; i < m; ++i) {
			x[i] = sc.nextInt();
		}
		solve(n, m, x);
	}

	long[][] mul(long[][] a, long[][] b) {
		long[][] ret = new long[a.length][b[0].length];
		for (int i = 0; i < a.length; ++i) {
			for (int j = 0; j < b[i].length; ++j) {
				for (int k = 0; k < a[i].length; ++k) {
					ret[i][j] = (ret[i][j] + a[i][k] * b[k][j]) % MODULO;
				}
			}
		}
		return ret;
	}

	long[][] pow(long[][] a, long n) {
		long[][] ret = new long[a.length][a.length];
		for (int i = 0; i < ret.length; ++i) {
			ret[i][i] = 1;
		}
		long[][] pow = new long[a.length][a.length];
		for (int i = 0; i < a.length; ++i) {
			for (int j = 0; j < a[i].length; ++j) {
				pow[i][j] = a[i][j];
			}
		}
		for (; n > 0; n >>= 1, pow = mul(pow, pow)) {
			if (n % 2 == 1) {
				ret = mul(ret, pow);
			}
		}
		return ret;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 149340
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int n, m;
	cin >> n >> m;
	int d[55] = {};
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		d[--x]++;
		d[--y]++;
	}
	for (int i = 0; i < n; i++) {
		cout << d[i] << endl;
	}
	return 0;

}




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

int main()
{
    string s, t;
    cin >> s >> t;

    int ans = 0;
    rep (i, 3)
        if (s[i] == t[i])
            ans++;

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

Measured memory_bytes: 256
import sys
N, M = map(int, input().split())

lis_A = []
lis_B = []

for _ in range(N):
    A, B = map(int, input().split())
    lis_A.append(A)
    lis_B.append(B)

c = zip(lis_A, lis_B)
sorted_c = sorted(c)
lis_A, lis_B = zip(*sorted_c)


cost  = 0
count  = 0

while True:
    if N == 1:
        print(lis_A[0] * lis_B[0])
        sys.exit()


    for i in range(len(lis_A)):
        if (lis_B[i] + count) <= M:
            cost = (lis_A[i]*lis_B[i]) + cost
            count = lis_B[i] + count
        else:
            cost = (((M - count) * lis_A[i]) + cost)
            print(cost)
            sys.exit()
        

Measured memory_bytes: 26920
#include<iostream>
#include<iomanip>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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;}
const long long INF = 1LL << 60;
typedef pair<int, int> P;


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

    ll res = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] < b[i]) {
            res += a[i];
            b[i] -= a[i];
            if (a[i+1] < b[i]) {
                res += a[i+1];
                a[i+1] = 0;
            } else {
                res += b[i];
                a[i+1] -= b[i];
            }
        } else {
            res += b[i];
        }
    }
    cout << res << "\n";

}

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

int main(){
    int n,k;cin >> n >> k;
    
    int rank=1;
    while(1)
    {
        if(n==0)
        {
            break;
        }
        else if( ( pow(k,rank-1) <= n) && ( n < pow(k,rank) ) )
        {
            break;
        }
        rank++;
    }

    cout << rank << endl;

    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int dp[100001];
    dp[0] = 0;
    fill(dp+1,dp+100001,10000);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= i; j *= 6)
            dp[i] = min(dp[i],dp[i-j]+1);
        for(int j = 1; j <= i; j *= 9)
            dp[i] = min(dp[i],dp[i-j]+1);
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 100001
#define MAX_A 100001
#define INF   1000000000000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll A[MAX_N];
ll B[MAX_N];

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

    ll N, M;
    cin >> N >> M;

    priority_queue<ll> pq1[MAX_A];
    priority_queue<P>  pq2;   

    ll maxA = 0;
    for(ll i = 0; i < N; i++) {
      cin >> A[i] >> B[i];
      pq1[ A[i] ].push( B[i] );
      maxA = max(A[i], maxA);
    }

    ll ans = 0;
    for(ll i = 1; i <= M; i++) {
      
      if (!pq1[i].empty()) {
	ll bonus = pq1[i].top();
	pq1[i].pop();
	pq2.push( P(bonus, i) );
      }

      if (pq2.empty()) continue;
      P p = pq2.top();
      pq2.pop();
      ans += p.first;

      if (!pq1[ p.second ].empty()) {
	ll bonus = pq1[ p.second ].top();
	pq2.push( P(bonus, p.second) );
	pq1[ p.second ].pop();
      }
    }
    
    cout << ans << endl;
    return 0;
}
    


Measured memory_bytes: 10804