akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[200010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	int m=MAX(A,A+N);
	bool flag=false;
	int m2=0;
	REP(i,N){
		if(A[i]!=m){
			m2=max(A[i],m2);
		}
	}
	int cnt=0;
	REP(i,N){
		if(A[i]==m){
			cnt++;
		}
	}
	if(cnt>1){
		REP(i,N){
			cout<<m<<endl;
		}
	}
	else{
		REP(i,N){
			if(A[i]==m){
				cout<<m2<<endl;
			}
			else{
				cout<<m<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3200
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
using namespace std;

typedef long long int64;

class BGreedyTakahashi {
 public:
  void solve(std::istream &in, std::ostream &out) {
    int64 a, b, k;
    in >> a >> b >> k;

    int64 tmp = min(a, k);
    a -= tmp;
    k -= tmp;

    tmp = min(b, k);
    b -= tmp;

    out << a << ' ' << b << endl;

  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  BGreedyTakahashi solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <math.h>
#include <cstring>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int ll;

//int dp[MAX];

int gcd(int a,int b){
	if(b == 0)return a;
	return gcd(b,a%b);
}
int lcm(int x, int y)
{
    return (x * y / gcd(x, y));
}

int main(void) {
	int N;cin>>N;
	vector<int> a(N);
	REP(i,N)cin>>a[i];

	int ans = 0;
	REP(i,N)ans += a[i]-1;

	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSumOfGcdOfTuplesEasy solver = new CSumOfGcdOfTuplesEasy();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSumOfGcdOfTuplesEasy {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt();
            long sum = 0;
            for (int i = 1; i <= k; i++) {
                for (int j = 1; j <= k; j++) {
                    for (int l = 1; l <= k; l++) {
                        sum += Arith.gcd(i, Arith.gcd(j, l));
                    }
                }
            }
            out.println(sum);
        }

    }

    static class Arith {
        public static long gcd(long a, long b) {
            if (b == 0) return a;
            return a % b == 0 ? b : gcd(b, a % b);
        }

    }
}



Measured memory_bytes: 36316
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

/*
 * メモ
 * Scanner:nextは空白か改行までの単語
 * String[][] c = new String[h][w];
 * TemplateMain,"template_input.txt"
 * 0.5 == 1.0/2
 */

public class Main {
	
	public static void printlnYN(boolean b){
		if(b) System.out.println("Yes");
		else System.out.println("No");
	}

	public static void main(String[] args) throws IOException {
		
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int san = 0, tyo = 0, ei = 0, don = 0;
		
    	while(true){
    		int n1 = sc.nextInt();
    		int n2 = sc.nextInt();
    		int n3 = sc.nextInt();
    		
    		if(n1 + n2 > n3 && n1 + n3 > n2 && n3 + n2 > n1){
    			san++;
    			int nn1 = n2*n2 + n3*n3 - n1*n1;
    			int nn2 = n1*n1 + n3*n3 - n2*n2;
    			int nn3 = n2*n2 + n1*n1 - n3*n3;
    			
    			if(nn1 == 0 || nn2 == 0 || nn3 == 0) tyo++;
    			else if(nn1 < 0 || nn2 < 0 || nn3 < 0) don++;
    			else ei++;
    			
    		}else break;
    	}
    	
    	System.out.println(san + " " + tyo + " " + ei + " " + don);
	}

}


Measured memory_bytes: 26584
h, w, d = map(int, raw_input().split())
a = [map(int, raw_input().split()) for y in range(h)]
p = {}
for y in range(h):
    for x in range(w):
        p[a[y][x]] = (x, y)
dp = [0] * (h*w + 1)
for i in range(1, d+1):
    for j in range(i+d, h*w+1, d):
        cx, cy = p[j-d]
        nx, ny = p[j]
        dp[j] = abs(nx - cx) + abs(ny - cy) + dp[j-d]
q = input()
for i in range(q):
    l, r = map(int, raw_input().split())
    print(dp[r] - dp[l])

Measured memory_bytes: 25784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define ALL(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main(){
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	int ans;
	if(K >= N){
		ans = X * N;
	} else {
		ans = K * X + (N - K) * Y;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct UnionFind{
  vector<int>data;
  UnionFind(int size){data.assign(size, -1);}
  bool unite(int x,int y){
    x=find(x),y=find(y);
    if(x==y) return false;
    if(data[x]>data[y])swap(x, y);
    data[x]+=data[y];
    data[y]=x;
    return true;
  }
  int find(int k){
    if(data[k]<0)return k;
    return data[k]=find(data[k]);
  }
  int size(int k){
    return -data[find(k)];
  }
};
long N,M,A[1<<17],B[1<<17],i,c;
vector<long> r;
int main(){
  cin>>N>>M;
  UnionFind uf(N);
  for(i=0;i<M;i++)cin>>A[i]>>B[i],--A[i],--B[i];
  r.resize(M);
  for(i=M-1;i>=0;i--){
    r[i]=N*(N-1)/2-c;
    if(uf.find(A[i])!=uf.find(B[i])) {
      c+=uf.size(A[i])*uf.size(B[i]);
      uf.unite(A[i],B[i]);
    }
  }
  for(auto e:r)cout<<e<<endl;
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  char c; cin >> c;
  if(c-'a' <= 26 && c-'a' >= 0) cout << "a" << endl;
  else cout << "A" << endl;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, ans;
ll solve(ll k)
{
	ll ret = n / k;
	ret = ret >> 1;
	return ret;
}	
int main()
{
	scanf("%lld", &n);
	if(n & 1)
	{
		puts("0");
		return 0;
	}
	for(ll k = 5; k <= n; k *= 5)
		ans += solve(k);
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;
using i64 = int64_t;

int main(){
    string s;
    cin >> s;
    int ret = 0;
    for(auto&& c:s){
        if(c == '+')ret++;
        else ret--;
    }
    cout << ret << endl;
    return 0;
}

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

int main()
{
    int N, K;
    cin >> N >> K;

    vector<int> l(N);
    for( int i = 0; i < N; ++i )
        cin >> l[i];

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

    int ans = 0;
    for( int i = 0; i < K; ++i )
        ans += l[N-i-1];

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <typename X> inline X abs(const X &a) {return a < 0 ? -a : a;}
template <typename X> inline X sqr(const X &a) {return a * a;}

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9;
const ld PI = acosl(ld(-1));

mt19937 mt(time(NULL));

string s;

inline bool read() {
	if (!getline(cin, s))
		return false;
	return true;
}

inline void solve() {
	int n = sz(s);
	forn (i, n)
		fore(j, i + 1, n)
			if (s[i] == 'C' && s[j] == 'F')
			{
				puts("Yes");
				return;
			}
			
	puts("No");
}

int main() {
#ifdef SU2_PROJ
	assert(freopen("input.txt", "r", stdin));
	assert(freopen("output.txt", "w", stdout));
#endif

	cout << setprecision(25) << fixed;
	cerr << setprecision(10) << fixed;
	
	assert(read());
	solve();

#ifdef SU2_PROJ
	cerr << "TIME: " << clock() << endl;
#endif
	return 0;
}

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

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

int N;
int A[100005];

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

	cin >> N;

	A[0] = A[N+1] = 0;
	int sum = 0;
	for (int i = 1;i <= N;i++){
		cin >> A[i];
		sum += abs(A[i-1]-A[i]);
	}

	sum += abs(A[N]);

	for (int i = 1;i <= N;i++){
		int ans = sum - abs(A[i-1]-A[i]) - abs(A[i+1]-A[i]) + abs(A[i-1]-A[i+1]);
		cout << ans << endl;
	}

	return 0;

}


Measured memory_bytes: 1664
#!/usr/bin/env python
# coding: utf-8

# In[10]:


N = int(input())
A = sorted(list(map(int, input().split())))


# In[11]:


if N%2 == 0:
    mylist = sorted([i for i in range(1,N,2)]*2)
else:
    mylist = sorted([0] + [i for i in range(2,N,2)]*2)
if A != mylist:
    print(0)
else:
    print(2**(N//2) % (10**9+7))


# In[ ]:






Measured memory_bytes: 20636
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class AtCoder_xab{
  public static void Main(){

    var input = Console.ReadLine().Split();
    int x = int.Parse(input[0]);
    int a = int.Parse(input[1]);

    Console.WriteLine(Math.Max(0,x-a));
    
  }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(void) {
  int i, ans = 0, j, n;
  while(scanf("%d", &n) != EOF) {
    ans = 0;
    for(i = 0; i * n < 600; ++i) ans += n * i * i * n * n;
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n;
long double v[50];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> v[i];
	sort(v, v + n);
	for(int i = 1; i < n; i++) v[i] = (v[i - 1] + v[i]) / 2;
	cout << v[n - 1] << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Integer[] array = new Integer[n];
		for(int i=0;i<n;i++) {
			array[i] = sc.nextInt();
		}
		sc.close();
		int ans = 0;


		Arrays.sort(array);
		int len = Math.min(array.length, k);
		for(int i=0;i<len;i++){
			ans = ans + array[i];
		}


		System.out.println(ans);

	}
}


Measured memory_bytes: 39048
#include<stdio.h>


#define SWAP(type,a,b) { type work = a; a = b; b = work; }

/*
    基準値を選ぶ
*/
long int select_pivot(long  int* array, int begin, int end)
{
    return array[(begin + end) / 2];  // 中央の要素を基準値とする
}


/*
    クイックソート (再帰部分、昇順)
*/
void quick_sort_rec(long int* array, int begin, int end)
{
    long int pivot = select_pivot( array, begin, end );
    int i = begin;
    int j = end;

    while( 1 ){
        while( array[i] < pivot ){ ++i; }  // 基準値以上の値が見つかるまで右方向へ進めていく
        while( array[j] > pivot ){ --j; }  // 基準値以下の値が見つかるまで左方向へ進めていく

        if( i >= j ){ break; }  // 左右から進めてきたiとjがぶつかったらループを終える

        // 基準値の位置よりも左側にあり、基準値よりも大きい値 (array[i]) と、
        // 基準値の位置よりも右側にあり、基準値よりも小さい値 (array[j]) の
        // 位置関係を交換する。
        SWAP( int, array[i], array[j] );

        // 次回に備えて、注目点をずらす
        i++;
        j--;
    }


    // 基準値の位置より左側に要素が２つ以上あれば、
    // その部分についてクイックソートを再帰させる
    if( i - begin >= 2 ){
        quick_sort_rec( array, begin, i - 1 );
    }

    // 基準値の位置より右側に要素が２つ以上あれば、
    // その部分についてクイックソートを再帰させる
    if( end - j >= 2 ){
        quick_sort_rec( array, j + 1, end );
    }
}


void sort(long int* array, int size){
    // 配列全体を対象にする
    quick_sort_rec( array, 0, (int)(size - 1) );
}

void print_array(long int data[], int n){
    for(int i = 0; i < n; i++){
        printf("%ld ", data[i]);
    }
    printf("\n");
}

int main(void){
    int n, k;
    scanf("%d""%d", &n, &k);
    long int h[n], cnt = 0;;
    for(int i = 0; i < n; i++){
        scanf("%ld", &h[i]);
    }
    sort(h, n);
    for(int i = n - k - 1; i >= 0; i--){
        cnt += h[i];
    }
    printf("%ld\n", cnt);
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int a = x2 - x1;
    int b = y2 - y1;
    int x3 = x2 - b;
    int y3 = y2 + a;
    int x4 = x1 - b;
    int y4 = y1 + a;
    printf("%d %d %d %d\n", x3, y3, x4, y4);
}


Measured memory_bytes: 256
n,x = map(int, input().split())
for i,a in enumerate(sorted(map(int, input().split()))):
    x -= a
    if x < 0:
        print(i)
        break
    elif x == 0:
        print(i+1)
        break
else:
    if x == 0:
        print(n)
    else:
        print(n-1)

Measured memory_bytes: 3060
# 2019/08/08

from collections import Counter

input()
a=Counter(list(map(int,input().split())))

x=sorted(list(a.items()),reverse=True)



ans=0
for k,v in x:
    if v<2:continue
    if v>3:
        if ans==0:
            ans=k**2
        else:
            ans*=k
        break
    else:
        if ans==0:
            ans=k
        else:
            ans*=k
            break

print(ans)

Measured memory_bytes: 21404
#include<cstdio>
#include<iostream>

using namespace std;

typedef long long LL;
const int N = 300005;
int n;
LL a[N], ans = 1e18;
char s[N];

int main(){
	scanf("%d", &n);
	scanf("%s", s+1);
	for(int i = 1; i <= n; i++)
		a[i] = 1ll * (s[i] == 'E') + a[i-1];
	for(LL i = 1; i <= n; i++)
		if(i - 1 - a[i-1] + a[n] - a[i] < ans)
			ans = i - 1 - a[i-1] + a[n] - a[i];
	cout << ans;
	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
//const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;



ll dp[103][100010];

int main()
{

    fastread();

    ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;



      cin>>n>>k;


     vector<pll>v;

     v.eb(-1,-1);

     for(i=0; i<n; i++)
     {
         cin>>a>>b;

         v.eb(a,b);
     }
     sort(vll(v));

       for(i=1; i<=n; i++)
       {
           for(j=1; j<=k; j++)
           {

               if(v[i].F>j)
               {
                   dp[i][j]=dp[i-1][j];

               }
             else dp[i][j]=max(dp[i-1][j],dp[i-1][j-v[i].F]+v[i].S);


           }
          // cout<<endl;
       }

       cout<<dp[n][k]<<endl;




}



Measured memory_bytes: 81732
//DEEPANSHU RAWAT
//BTECH/10530/18
 
#include<bits/stdc++.h>
#define ull unsigned long long
#define lld long long int
#define infi LLONG_MAX
#define ninfi LLONG_MIN
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define e endl
#define mod 1000000007
using namespace std ;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lld n;
    cin>>n;
    if(n==7||n==5||n==3)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
}

Measured memory_bytes: 256
n,m = gets.chomp.split.map(&:to_i)
a  = Array.new(m)
b = Array.new(m)
ans = Array.new(n,0)
for i in 0..m-1
  a[i],b[i] = gets.chomp.split.map(&:to_i)
  ans[a[i]-1] += 1
  ans[b[i]-1] += 1
end

puts ans

Measured memory_bytes: 1788
n = int(input())
reds = []
for i in range(n):
    reds.append(tuple(map(int, input().split())))
reds = sorted(reds, key=lambda tup: tup[1], reverse=True)

blues = []
for i in range(n):
    blues.append(tuple(map(int, input().split())))
blues = sorted(blues, key=lambda tup: tup[0])

count = 0
for b in blues:
    paired = None
    for r in reds:
        if b[0] > r[0] and b[1] > r[1]:
            paired = r
            break
            
    if paired is not None:
        reds.remove(paired)
        count += 1

print(count)


Measured memory_bytes: 3064
import itertools

N,M,Q = map(int, raw_input().split())
ABCD = []
for i in range(Q):
    abcd = map(int, raw_input().split())
    ABCD.append(abcd)

S = []
def gen(seq, n):
    if n == N:
        S.append(seq)
        return
    tail = seq[-1]
    for x in range(tail, M+1):
        gen(seq+[x], n+1)

gen([1], 1)

ans = 0
for seq in S:
    m = 0
    for a,b,c,d in ABCD:
        if seq[b-1] - seq[a-1] == c: 
            m += d
    ans = max(ans, m)
print ans

Measured memory_bytes: 86492
from subprocess import*
with open('Main.java','w')as f:f.write(r"""
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int ans = 0;
		int max = Integer.parseInt(sc.next());
		int min = max;
		boolean up = true;
		boolean down = true;
		for (int i = 1; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			if (up) {
				if (a >= max)
					max = a;
				else
					up = false;
			}
			if (down) {
				if (a <= min)
					min = a;
				else
					down = false;
			}
			if (!up && !down) {
				ans++;
				max = a;
				min = a;
				up = true;
				down = true;
			}
		}
		ans++;
		System.out.println(ans);
	}
}
""")
call(('javac','Main.java'))
call(('java','Main'))

Measured memory_bytes: 58148
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define int long long int
    int h,cnt=1,i=1;
    cin>>h;
        while(h!=1)
        {
            h=h/2;
            cnt+=i*2;
            i=i*2;
        }
        //cout<<cnt<<endl;
        //sum=(1 << (cnt)) - 1;
        cout<<cnt<<endl;
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string O, E;
	cin >> O >> E;
	for (int i = 0; i < O.size(); ++i) {
		cout << O[i];
		if (i <= E.size() - 1)
			cout << E[i];
	}
	cout << endl;
	return 0;
}

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

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

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = 99999999;
const int MAX_V = int(2e2) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#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++)

int d[205][205];
int n;
int m, r, ans = IINF;
vector<int> rs;

void warshal_floyd() {
    for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    cin >> n >> m >> r;
    rs.resize(r);
    REP(i, r) cin >> rs[i];
    REP(i, n + 1) { fill(d[i], d[i] + n + 1, IINF); }
    REP(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
    }
    warshal_floyd();
    sort(rs.begin(), rs.end());
    while (1) {
        int t = 0;
        REP(i, r - 1) t += d[rs[i]][rs[i + 1]];
        ans = min(ans, t);
        if (!next_permutation(rs.begin(), rs.end())) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define ld long double
typedef pair<ll,ll> pll;
typedef pair<pll,pll> ppll;
typedef vector <pll> vi;
#define out(x) return cout<<x,0;
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define lc(n) 2*n+1
#define rc(n) 2*n+2
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

int main() {
    FAST;
    ll i, n, k, m, x = 0, y = 0, t, z = 0, ans = 0, j, c = 0;
    cin >> n;
    ll a[10][10];
    fill( a , 0 );
    for ( i = 1 ; i <= n ; i ++ ){
    	string s = to_string(i);
    	a[s[0]-'0'][s[s.size()-1]-'0'] ++;
    }
    for ( i = 0 ; i < 10 ; i ++ ){
    	for ( j = 0 ; j < 10 ; j ++ ){
    		ans += a[i][j]*a[j][i];
    	}
    }
    cout << ans;
}

Measured memory_bytes: 256
N, M = [int(n) for n in input().split()]
A = []
for i in range(N):
  A.append([int(n) for n in input().split()])
b = []
for j in range(M):
  b.append(int(input()))
for k in range(N):
  ans = 0
  for l in range(M):
    ans += A[k][l] * b[l]
  print(ans)



Measured memory_bytes: 6016
#include <iostream>
#include <vector>
using namespace std;
      
int main() {
 int n;
 cin >> n;
 int A[n - 1];

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

 for (int B = n - 1;B >= 0; B--) {
   if (B != 0) {
     cout << A[B] << " "; 
   }
   else
     cout << A[B] << endl;
  
 }


}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,p[100000];
int bfs(){
  bool used[100000]={};
  deque<P> q;
  q.push_front(P(0,0));
  while(!q.empty()){
    int x=q.front().first,c=q.front().second;q.pop_front();
    if(x==n-1)return c;
    if(x<0||n<=x||used[x])continue;
    used[x]=1;
    int nx=x+p[x];
    if(p[x])q.push_front(P(nx,c));
    if(!p[x])
      for(int i=1;i<7;i++)q.push_back(P(x+i,c+1));
  }
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>p[i];
  cout<<bfs()<<endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (i = 0; i < n; i++)

#define M 2000

bool ab[100000], ac[100000], bc[100000];

string a, b, c;

bool match(char c1, char c2)
{
  return (c1 == '?' || c2 == '?' || c1 == c2);
}

int main()
{
  cin >> a >> b >> c;
  int A = a.length(), B = b.length(), C = c.length();
  int i, j;
  rep(i, A) rep(j, B) if (!match(a[i], b[j])) ab[i - j + 50000] = true;
  rep(i, A) rep(j, C) if (!match(a[i], c[j])) ac[i - j + 50000] = true;
  rep(i, B) rep(j, C) if (!match(b[i], c[j])) bc[i - j + 50000] = true;

  int ans = 3 * M;

  for (int i = -2 * M; i <= 2 * M; i++)
  {
    for (int j = -2 * M; j <= 2 * M; j++)
    {
      if (!ab[i + 50000] && !ac[j + 50000] && !bc[j - i + 50000])
      {
        int L = min(0, min(i, j));
        int R = max(A, max(B + i, C + j));
        ans = min(ans, R - L);
      }
    }
  }

  cout << ans << endl;
}


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

int main(){
    double N,K;
    cin >> N >> K;
    double total_pr = 0;
    for(int i=1; i<=N; i++){
        if(i>=K)
            total_pr += 1 / N;
        else{
            int time = ceil(log2(K) - log2(i));
            double pr = pow(0.5,time)/N;
            total_pr += pr;
        }
    }
    cout << setprecision(20) << total_pr << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()                                                      
list_S = list(S)
N1 = 0
list_X =[]
X = list_S.count('.')
list_X.append(X)
    
for color in list_S:
    if list_S[N1] == '.':
        X -= 1
        list_X.append(X)
        N1 +=1
    else:
        X += 1
        list_X.append(X)
        N1 +=1

X = list_S.count('#') 
list_X.append(X)

X_MIN = min(list_X)
print(X_MIN)

Measured memory_bytes: 13032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5+5;
const int mod = 998244353;
inline int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
inline int sub(int a,int b){a-=b;return a<0?a+mod:a;}
inline int mul(int a,int b){return 1ll*a*b%mod;}
int n;
char s[N],tt[N];
int ret;
int ans[N];
int T = 0;
void chk(int d){
	for(int i=0;i<n;i++){
		
		if(s[i]>tt[i]+'0')break;
		if(s[i]<tt[i]+'0')return;
	}
	ans[d]=add(ans[d],1);
}
int nxt[N];
int CNT=0;
int main()
{
	cin >> n;
	scanf("%s",s);
	for(int i=0;i<n;i++)T=T*2+s[i]-'0',T%=mod;
	for(int i=n-1;~i;i--)nxt[i]=s[i]=='1'?nxt[i+1]+1:0;
	for(int i=0;i<n;i++)if(nxt[i])nxt[i+1]=0x3f3f3f3f;
	T=add(T,1);T%=mod;
	// for(int i=0;i<=T;i++){
	// 	int d = i, time = 0;
	// 	while(time==0||d!=i){
	// 		++time;
	// 		int dd = ((d&1)^1)<<29;
	// 		d=dd+(d>>1);
	// 	}
	// 	if(time==20)cout << i << endl,CNT++;
	// }
	// cout << CNT << endl;
	for(int i=3;i<=n;i+=2){
		if(n%i==0){
			int d = n/i;
			// cout << d << endl;
			int t2=0;
			for(int i=0;i<d;i++){
				t2=mul(t2,2);t2=add(t2,s[i]-'0');
				tt[i]=s[i]-'0';
			}
			ans[d]=add(ans[d],t2);
			for(int i=d;i<n;i++)tt[i]=tt[i-d]^1;
			chk(d);
			// cout << ans[d] << endl;
		}
	}
	for(int i=1;i<=n;i++)if(n%i==0&&n/i%2){
		for(int j=i*2;j<=n;j+=i){
			ans[j]=sub(ans[j],ans[i]);
		}
		T=sub(T,ans[i]);
		ret=add(ret,mul(ans[i],i*2));
		// cout << ans[i] << endl;
	}
	// cout << T << endl; 
	ret=add(ret,mul(T,n*2));
	cout << ret << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a % b == 0) cout << -1 << endl;
  else cout << a << endl;
  return 0;
}

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

int main()
{
    int H,W,h,w;
    cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private void execute() throws Exception {
        Scanner sc = new Scanner(System.in);
        double n = Double.parseDouble(sc.nextLine());
        double x = Math.ceil(n / 1.08d);
        double nn = Math.floor(x * 1.08);
        if (n == nn) {
            System.out.printf("%.0f%n", x);
        } else {
            System.out.println(":(");
        }
    }

    public static void main(String[] args) {
        try {
            new Main().execute();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

}

Measured memory_bytes: 23124
#-*- coding:utf-8 -*-

# def print_map(mp):
#     for r in mp:
#         print(['{:2d}'.format(n) for n in r])

H, W = map(int, input().split())
mp = [[] for h in range(H)]
mp_row = [[0 for w in range(W)] for h in range(H)]
mp_col = [[0 for w in range(W)] for h in range(H)]

# True = なし、 False = 障害物
for h in range(H):
    mp[h] = [True if c == "." else False for c in input()]

# 全探索はO(HWHW)となって爆発。
# 縦横でまずカウントするのがよさげ。
# このプログラムはO(HW)だがTLE: カウントしたものの書き込みでO(HHW+HWW)あたりになっている？
# これpythonのforの遅さでTLEしてないか…？

## 横のパネル数
for h in range(H):
    st = 0
    cnt = 0
    for w in range(W):
        if mp[h][w] is False:
            for i in range(st, w):
                mp_row[h][i] = cnt
            cnt = 0
            st = w+1
        elif w == W-1:
            cnt += 1
            for i in range(st, W):
                mp_row[h][i] = cnt
        else:
            cnt += 1

## 縦のパネル数
for w in range(W):
    st = 0
    cnt = 0
    for h in range(H):
        if mp[h][w] is False:
            for i in range(st, h):
                mp_col[i][w] = cnt
            cnt = 0
            st = h+1
        elif h == H-1:
            cnt += 1
            for i in range(st, H):
                mp_col[i][w] = cnt
        else:
            cnt += 1

#print_map(mp_row)
#print()
#print_map(mp_col)

mx = 0
for h in range(H):
    for w in range(W):
        # 重なっている中央を引くのを忘れずに
        mx = max(mx, mp_row[h][w]+mp_col[h][w]-1)
print(mx)


Measured memory_bytes: 138120
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>

#define MOD 1000000007
#define INF (1ll<<60)
typedef long long ll;
using namespace std;
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,-1,1};


int h, w;
string maze[50];
int dist[50][50];
bool reached[50][50];
queue<int> here_x,here_y;

int bfs(int sx, int sy){
    here_x.push(sx);
    here_y.push(sy);
    reached[0][0] = true;
    while(!here_x.empty()){
        int x = here_x.front(); here_x.pop();
        int y = here_y.front(); here_y.pop();
        for (int i = 0; i < 4; i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (!(0 <= nx && nx < w && 0 <= ny && ny < h) || maze[ny][nx] == '#') continue;
            if (reached[ny][nx]) continue;

            reached[ny][nx] = true;
            here_x.push(nx);
            here_y.push(ny);
            dist[ny][nx] = dist[y][x] + 1;
        }
    }
    return dist[h-1][w-1];
}



int main(){
    cin >> h >> w;
    int cnt = 0;
    for (int i = 0; i < h; i++){
        cin >> maze[i];
        for (int j = 0; j < w; j++){
            if (maze[i][j] == '.'){
                cnt++;
            }
        }
    }

    int lowest = bfs(0,0);
    if (reached[h-1][w-1]){
        cout << cnt - lowest -1 << endl;
    } else{
        cout << -1 << endl;
    }


}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)

MOD = 10 ** 9 + 7


def main():
    N = int(input())
    A = list(map(int, input().split()))
    RGB = [1, 0, 0]
    ans = 1
    if A[0] !=0:
        print(0)
        return
    for i in range(1, N):
        a = A[i]
        if a == 0:
            if 0 in RGB:
                j = RGB.index(a)
                RGB[j] += 1
            else:
                print(0)
                return
        elif a not in RGB:
            print(0)
            return
        else:
            k = RGB.count(a)
            ans *= k
            ans %= MOD
            j = RGB.index(a)
            RGB[j] += 1
    z = RGB.count(0)
    if z == 0:
        ans *= 6
        ans %= MOD
    elif z == 1:
        ans *= 6
        ans %= MOD
    else:
        ans *= 3
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  cout<<(a+b+c+d)/60<<endl;
  cout<<(a+b+c+d)%60<<endl;
}



Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int N;
  while(true){
    cin >> N;
    if(N == 0){
      break;
    }
    int time[N][N+1];
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < N+1; ++j){
	cin >> time[i][j];
      }
    }
    int min_time[N][1<<N];
    fill_n((int*) min_time, N*(1<<N), 1<<23);
    for(int i = 0; i < N; ++i){
      for(int b = 0; b < (1<<N); ++b){
	min_time[i][b] = time[i][0];
	for(int j = 0; j < N; ++j){
	  if((b&(1<<j))==0){
	    continue;
	  }
	  min_time[i][b] = min(min_time[i][b], time[i][j+1]);
	}
      }
    }
    /*
    for(int i = 0; i < N; ++i){
      for(int b = 0; b < (1<<N); ++b){
	cout << b << ": " << min_time[i][b] << ", ";
      }
      cout << endl;
    }
    */
    int table[1<<N];
    fill_n(table, 1<<N, 1<<23);
    table[0] = 0;
    for(int i = 0; i < N; ++i){
      table[1<<i] = time[i][0];
    }
    for(int b = 0; b < (1<<N); ++b){
      for(int i = 0; i < N; ++i){
	int t = b |(1<<i);
	if(t == b){
	  continue;
	}
	table[t] = min(table[t], table[b]+min_time[i][b]);
      }
      //cout << table[b] << ",";
    }
    //cout << endl;
    cout << table[(1<<N)-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 5512
#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
int main(){
  int n,l=0;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]!=i+1)
      l++;
  }
  if(l>2)
    cout<<"NO\n";
  else
    cout<<"YES\n";
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

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

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	ll n;
	cin >> n;
	ans = 0;
	for (ll i = 2; i * i <= n; ++i) {
		if(n%i) continue;

		int cur = 0;
		while(n%i==0) {
			n/=i;
			++cur;
		}
	//	cout << cur << '\n';
		int cnt = 1;
		while((cnt+2)*(cnt+1) / 2 <= cur) ++cnt;
		ans += cnt;
	}
	ans += (n>1);

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

// B...a

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

int main(){
    int n;
    cin >> n;
    n--;
    vector<int> c(n), s(n), f(n);
    for(int i=0; i<n; i++) cin >> c[i] >> s[i] >> f[i];

    for(int pos=0; pos<n; pos++){
        int ans = 0;
        for(int i=pos; i<n; i++){
            if(ans < s[i]) ans = s[i];
            if(ans % f[i] != 0) ans += f[i] - (ans % f[i]);
            ans += c[i];
        }
        cout << ans << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#! env python
# -*- coding: utf-8 -*-

import os
import sys

# ac_py.main.py
# Date: 2020/06/07
# Filename: main.py 

__author__ = 'acto_mini'
__date__ = "2020/06/07"


def main():
    a, b = map(int, input().split())
    if (a * b) % 2:
        print("Odd")
    else:
        print("Even")


if __name__ == '__main__':
    main()


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

typedef long long int ll;

int main()
{
    ll a, b;
    cin >> a >> b;

    if(a < b * 2){
        cout << 0;
    }
    else{
        cout << a - b * 2;
    }

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>        // -std=c++11
#define push_quad(a, b, c, d) que.push(make_tuple(a, b, c, d))
using namespace std;

int solve(int i, int j, int k, int cnt) {
    // bfsのふりして、シミュレーションしてるだけになった
    queue<tuple<int, int, int, int>> que;
    push_quad(i, j, k, cnt);
    while (!que.empty()) {
        int A[3], cnt;
        tie(A[0], A[1], A[2], ignore) = que.front();
        cnt = get<3>(que.front());
        que.pop();
        sort(A, A + 3);
        int i = A[0], j = A[1], k = A[2];
        if (i == j && j == k) return cnt;
        if (j - i >= 2) {
            int tmp = (j - i) / 2;  // まとめた
            push_quad(i + tmp * 2, j, k, cnt + tmp);
        } else {
            push_quad(i + 1, j + 1, k, cnt + 1);
        }
    }
    return -1;
}

int main() {
    int i, j, k;
    cin >> i >> j >> k;
    cout << solve(i, j, k, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int w,h;
int G[100][100];
int dx[] = {1,-1,0,0},dy[] = {0,0,-1,1};
int mx;

void dfs(int px,int py,int cnt){
  mx = max(cnt,mx);
  for(int i = 0 ; i < 4 ; i++ ){
    int nx = px + dx[i],ny = py + dy[i];
    if(0 <= nx && nx < w && 0 <= ny && ny < h && G[nx][ny] != 0){
      G[px][py] = 0;
      dfs(nx,ny,cnt+1);
      G[px][py] = 1;
    }
  }
}

int main(){
  while( cin >> w >> h,w + h ){
    for(int i = 0 ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
	cin >> G[j][i];
      }
    }
    mx = 0;
    for(int i = 0 ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
	if(G[j][i] == 1 ){
	  dfs(j,i,1);
	}
      }
    }
    cout << mx << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>

int main(int argc, char const *argv[])
{
	/* code */
	int N,K,D;
	int B=0,b=1,i=0;
	scanf("%d %d",&N,&K);

	  while(N>0){
    B = B + ( N % K ) * b;
    N = N/ K;
    b = b* 10;
    i++;
  }

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    int l=A.size()/2;
    int Alice=0;
    int Bob=0;
    if (N%2==1) {Alice+=A.at(N-1);}
    for(int i=0; i<l; i++){
        Alice+=A.at(2*i);
        Bob+=A.at(2*i+1);
    }
    cout << Alice-Bob <<endl;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define lep(j,n) for(int j=0; j<(n); j++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define leps(j,n) for(int j=1; j<(n); j++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

#define return(Z) re:(Z)

long long h[10000010],x[10000010],z[10000010];

signed main(){

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

    string a,b;
    cin>>a>>b;
    if(a[0]==b[2] && a[2]==b[0] && a[1]==b[1]) cout<<"YES"<<'\n';
    else cout<<"NO"<<'\n';
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class91
    {
        static void Main()
        {
            var st = Console.ReadLine().Split();
            Array.Reverse(st);
            Console.WriteLine(string.Join("", st));
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int q[110][110];
int main()
{
    int n,m;cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            char a;cin>>a;
            if(a=='#')
            {
                q[i+1][j+1]++;q[i+1][j]++;q[i+1][j-1]++;q[i][j+1]++;
                q[i][j]=-9;
                q[i][j-1]++;q[i-1][j+1]++;q[i-1][j]++;q[i-1][j-1]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(q[i][j]<0) cout<<'#';
            else cout<<q[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
function main()
    s = readline()
    if s in ["RSS", "SRS", "SSR", "RSR"]
        println(1)
    elseif s in ["RRS", "SRR"]
        println(2)
    elseif s == "RRR"
        println(3)
    else
        println(0)
    end
end 


main()

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


int main() {
   int n, length, total, j, x;

   cin >> n;
 
   length = 0;
   total = 0;

  for(int i = 1; i <= n; i++){

    length = 0;
    for(int j = i; j > 0; j /= 10){
        length ++;
        
    }

    if(length%2==1){
        total ++;
       
    }
    
    }

    cout << total;
    
}

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

int n, k;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	long long h[n], dp[n];
	for (int i=0; i<n; i++) cin >> h[i];
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i=2; i<n; i++) {
		dp[i] = 0x3f3f3f3f3f3f3f;
		for (int j=1; j<=k && j<=i; j++) {
			dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
			// cout << "check: " << i << " " << "dp result: " << dp[i] << endl;
		}
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#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>

#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>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << a * a - b << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define PI 3.14159265358979323846
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int ncr(int n, int r){
    if(r > n || r < 0){
        return 0;
    }
    int temp = factorial[n]%MOD;
    temp *= powerFunction(factorial[r], MOD-2)%MOD;
    temp %= MOD;
    temp *= powerFunction(factorial[n-r], MOD-2)%MOD;
    temp %= MOD;
    return temp;
}

signed main(){
    int n, m;
    cin >> n >> m;
    factorialFunction(500005);
    int del = 0;
    for(int i=1; n>=i; i++){
        int temp = ((ncr(n, i)%MOD)*(ncr(m, i)%MOD))%MOD;
        temp *= factorial[i];
        temp %= MOD;
        int x = ncr(m-i, n-i)%MOD;
        x *= factorial[n-i]%MOD;
        x %= MOD;
        x *= x;
        x %= MOD;
        temp *= x;
        temp %= MOD;
        if(i%2 == 1){
            del += temp;
            del %= MOD;
        }else{
            del += MOD;
            del -= temp;
            del %= MOD;
        }
    }
    int total = ncr(m, n)%MOD;
    total *= factorial[n];
    total %= MOD;
    total *= total;
    total %= MOD;
    int ans = total;
    ans += MOD;
    ans -= del;
    ans %= MOD;
    cout << ans << endl;
}






Measured memory_bytes: 7544