akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

  for (int i = 0; i < (s.size() - 1) / 2; i++) {
    t.push_back(s.at(i));
  }
  for (int i = (s.size() + 3) / 2 - 1; i < s.size(); i++) {
    u.push_back(s.at(i));
  }
  string tmp1, tmp2, tmp3;
  tmp1 = s;
  tmp2 = t;
  tmp3 = u;
  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());
  reverse(u.begin(), u.end());
  if (tmp1 == s && tmp2 == t && tmp3 == u) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))  
B = list(map(int, input().split()))  

B=B+[0]
counter = 0
for i in reversed(range(1, N+1)):
    dif = A[i] - B[i]
    if dif > 0:
        B[i] += min(dif, B[i-1])
        B[i-1] -= min(dif, B[i-1]) 
    counter += min(A[i], B[i])
counter += min(A[i-1], B[i-1])    
print(counter)

Measured memory_bytes: 18624
billdings = Array.new(4).map{Array.new(3).map{Array.new(10, 0)}}
def printstate(b)
    b.each.with_index(1) do |bill, bill_idx|
        bill.each do |floor|
            floor.each do |room|
                print " " + room.to_s
            end
            puts
        end
        if bill_idx != b.size then puts "#"*20 end
    end
end

n = gets.to_i
n.times do
    b, f, r, v = gets.chomp.split.map(&:to_i)
    billdings[b-1][f-1][r-1]+=v
end

printstate(billdings)


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

int main() {
  string N;
  cin >> N;
  if (N == "SUN") {
      cout << "7" << endl;
  }
  else if (N == "MON") {
      cout << "6" << endl;
  }
  else if (N == "TUE") {
      cout << "5" << endl;
  }
  else if (N == "WED") {
      cout << "4" << endl;
  }
  else if (N == "THU") {
      cout << "3" << endl;
  }
  else if (N == "FRI") {
      cout << "2" << endl;
  }
  else if (N == "SAT") {
      cout << "1" << endl;
  }
  
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
list_A = list(map(int,input().split()))
for _ in range(100):
    min_A = min(list_A)
    list_A.remove(min_A)
    l = np.array([list_A]) % min_A
    lr = list(l.ravel())
    lr.append(min_A)
    list_A = [x for x in lr if x != 0]
    if len(list_A) <= 1:
        break
print(list_A[0])

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

const int inf = 1000000000;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }
    int L = X[0];
    int R = X[0];
    for (int i = 0; i < N; i++) {
        L = min(L, X[i]);
        R = max(R, X[i]);
    }
    int ans = inf;
    for (int i = L; i <= R; i++) {
        int cost = 0;
        for (int j = 0; j < N; j++) {
            cost += (X[j] - i) * (X[j] - i);
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
//
//  main.cpp
//  linear_search
//
//  Created by ???????????? on 2017/10/06.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include <stdio.h>

using namespace std;

bool linear_search(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key){
        i++;
    }
    if (i == n){
        return false;
    }
    return true;
}

int main(int argc, const char * argv[]) {
    int n, i, q, key, ct;
    
    scanf("%d", &n);
    int S[n];
    for(i = 0; i < n; i++){
        scanf("%d", &S[i]);
    }
    
    ct = 0;
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d", &key);
        bool found = linear_search(S, n, key);
        if(found) ct ++;
    }
    cout << ct << endl;
    return 0;
}

Measured memory_bytes: 3144
n=gets.to_i
a=gets.split(" ")
ali,bob=0,0
n.times do |i|
  a[i]=a[i].to_i
end
a.sort!{|x,y|y<=>x}
n.times do |i|
  unless i.odd?
    ali+=a[i]
  else
    bob+=a[i]
  end
end
puts ali-bob

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
ll dp[300000][60]={};
ll dp2[300000][60]={};
int main() {
	ll a,b;
	cin>>a>>b;
	ll r=a*b;
	while(1){
		ll d=a%b;
		if(d==0)break;
		a=b;
		b=d;
	}
	r=r/b;
	cout<<r;
	
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){
  
  int N,T;
  ll t;
  cin >> N;
  vector<ll> vec(N);
  T = 0;
  
  for(int i = 0; i < N; i++){
    cin >> t;
    vec[i] = t;
  }
  
  for(ll i = 0; i < N - 2; i++){
    
    for(ll j = i + 1; j < N - 1; j++){
      
      if(vec[i] != vec[j]){
        
        for(ll k = j + 1; k < N; k++){
          if(vec[i] != vec[k] && vec[j] != vec[k]){
            if((vec[i] + vec[j] > vec[k]) && (vec[i] + vec[k] > vec[j]) && (vec[k] + vec[j] > vec[i])) T++;
          }
        }
      }
    }
  } 
  
  cout << T << endl;
  
}


Measured memory_bytes: 3628
n = int(input())
a = list(map(int, input().split()))
nums = [0] * 100005
for x in a:
    nums[x] += 1
even, odd = [], []
for p in nums:
    if p % 2 == 1 and p > 1:odd.append(p)
    elif p % 2 == 0 and p > 0:even.append(p)
ans = n
for x in odd:
    ans -= x - 1
if len(even) % 2 == 1:
    ans -= 1
for x in even:
    ans -= x - 1
print(ans)

Measured memory_bytes: 20692
import java.util.Scanner;

public class Main { 
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String line = sc.nextLine();
    	int inputNumber = Integer.parseInt(line);
    	String result = "No";
    	for(int i = 1;i<=9;i++) {
    		for(int j = 1;j<=9;j++) {
    			int tmp = i*j;
    			if(inputNumber == tmp) {
    				result = "Yes";
    			}
    		}
    	}
    	System.out.println(result);
    	
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	for (int red = 0; red <= K; red++) {
		for (int green = 0; green <= K; green++) {
			for (int blue = 0; blue <= K; blue++) {
				int a = A, b = B, c = C;
				if (red + green + blue == K) {
					rep(i, red)a *= 2;
					rep(j, green)b *= 2;
					rep(k, blue)c *= 2;
					if (b > a && c > b) {
						cout << "Yes";
						return 0;
					}
				}
			}
		}
	}
	cout << "No";
}

Measured memory_bytes: 3596
import java.util.Scanner;

/**
 * Created on 16/09/24.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int K = sc.nextInt();

        String result = solve(s, K);

        System.out.println(result);
    }

    private static String solve(String s, int K) {
        return solveIter(new StringBuffer(s), K, 0);
    }

    private static String solveIter(StringBuffer s, int K, int idx) {
        if (K == 0) {
            return s.toString();
        }
        if (idx == s.length()) {
            int cint = s.charAt(idx-1) + (K%26);
            cint = cint > 'z' ? cint - ('z' - 'a' + 1) : cint;
            String c = Character.toString((char)cint);
            return s.replace(idx-1, idx, c).toString();
        }

        if (s.charAt(idx) == 'a') {
            return solveIter(s, K, idx+1);
        }

        if ('z' - s.charAt(idx) + 1 <= K) {
            char c = s.charAt(idx);
            return solveIter(s.replace(idx, idx+1, "a"), K - ('z' - c + 1), idx+1);
        }

        return solveIter(s, K, idx+1);
    }
}


Measured memory_bytes: 32556
#include <bits/stdc++.h> 
using namespace std;
int main()
{
    long long x;
    cin>>x;
    long long balance=100,year;
    for(year = 1 ; balance <= x ; year++){
        balance += balance/100;
        if(balance>=x) break;
    }
    cout<<year;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        int H, W;
        cin >> H >> W;
        for(int i=0;i<W+2;i++) cout<<"#";
        cout <<endl;
        vector<string> vec(H);
        for(int i=0; i<H; i++){
            
            cin >> vec.at(i);
            cout << "#" << vec.at(i) << "#" << endl;
        }

        for(int i=0;i<W+2;i++) cout<<"#";

    }

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

public class Main {

    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    long[] as = new long[N+1];
        long[][] dp = new long[N+1][N+1];
	    long[] prefixSum = new long[N+1];

	    for(int i=1; i<=N; ++i) {
	        as[i] = sc.nextLong();
	        prefixSum[i] = prefixSum[i-1] + as[i];
        }

//        d1(dp);

        for(int ij_d=1; ij_d<=N; ++ij_d) {
            for(int i=1; i+ij_d<=N; ++i) {
                int j = i+ij_d;
                dp[i][j] = Long.MAX_VALUE;
//                System.out.printf("%dx%d \n", i, j);
                for(int k=i; k<j; ++k) {
                    dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k+1][j] + (prefixSum[j] - prefixSum[i-1]));
//                    System.out.printf("i,k %d,%d k+1,j %d,%d\n", i, k, k+1, j);
//                    System.out.printf("%d %d+%d\n", dp[i][j], dp[i][k], dp[k+1][j]);
                }
//                dp[i][j] += (prefixSum[j] - prefixSum[i-1]);
//                    System.out.printf("prefixSum %d,%d k+1,j %d,%d\n", i, k, k+1, j);

            }
        }

//        Util.<Long>d0(dp);
//        d1(dp);

	    System.out.println(dp[1][N]);
    }

    public static void d1(long[][] dp) {
        System.out.print("    ");

        for(int j=0; j<dp[0].length; ++j){
            System.out.printf("%3d ", j);
        }
        System.out.println();

        for(int i=0; i<dp.length; ++i){
            System.out.printf("%3d|", i);
            for(int j=0; j<dp[0].length; ++j){
                if(10000 < dp[i][j])
                    System.out.printf("%3d ", -1);
                else
                    System.out.printf("%3d ", dp[i][j]);
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 26708
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;
 
 
int main() {
  string s;
  cin >> s;
  if(s<"a") {
    cout << "A" << endl;
  }
  else {
    cout << "a" << endl;
  }
  

}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
using namespace std;
#define MOD 1000000007
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v) for (auto i : v)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second
#define setp(x) setprecision(x)
#define mset(m, v) memset(m, v, sizeof(m))
static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

//static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//#define int ll

int main() { 
        string s; cin >> s;
        int ans = 0;
        rep(i, s.size() - 1) if (s[i] != s[i + 1]) ans ++;
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 512
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// a + b = a^b + 2*(a&b) = (a|b) + (a&b)

const int MAXN = 60;
const int MOD = 1e9 + 7;
int dp[MAXN+1][2][2];
int n;

int rec(int idx,int carry,int tight){
    int &ans = dp[idx][carry][tight];
    if(ans != -1) return ans;
    if(idx == MAXN) return ans = (carry == 0 && tight == 0);

    int bitn = (n>>idx)&1;
    ans = 0;

    FOR(a,0,1){
        FOR(b,0,a){
            int curbit = (a+b+carry)%2;
            int n_carry = (a+b+carry)/2;
            bool n_tight = tight;
            if(curbit > bitn) n_tight = 1;
            if(curbit < bitn) n_tight = 0;
            ans = (ans + rec(idx+1,n_carry,n_tight))%MOD;
        }
    }
    return ans;
}

void solve(){
    cin>>n;
    MINUS(dp);
    cout<<rec(0,0,0)<<endl;
}

signed main(){

   FastRead;    

    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0, res = 1;
    while (res < b) {
        res += a - 1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

class floating{
    public:
        int ex;
        LL num;
        floating(string str){
            ex=0;
            num=0;
            REP(i, str.size()){
                num*=2;
                num+=str[i]-'0';
            }
        }
        floating(){
            ex=num=0;
        }
};

floating operator+(floating a, floating b){
    floating res;
    a.num|=(LL)1<<52;
    b.num|=(LL)1<<52;
    if(a.ex < b.ex)swap(a, b);
    b.num >>= a.ex - b.ex;
    res.ex=a.ex;
    res.num=a.num+b.num;
    if(res.num>>53){
        ++res.ex;
        res.num>>=1;
    }
    res.num^=(LL)1<<52;
    return res;
}

string tostring(floating a){
    string res = "";
    REP(i, 52){
        res += a.num & ((LL)1<<i) ? "1" : "0";
    }
    REP(i, 12){
        res += a.ex & ((LL)1<<i) ? "1" : "0";
    }
    reverse(ALL(res));
    return res;
}

LL toLL(string str){
    LL res = 0;
    foreach(i, str){
        res<<=1;
        res+=i-'0';
    }
    return res;
}

int main(){
    int x, y, s;
    while(cin>>x>>y>>s && x){
        int ans = 0;
        REPA(i, s){
            REPA(j, s){
                if(i*(100+x)/100+j*(100+x)/100==s){
                    ans=max(ans, i*(100+y)/100+j*(100+y)/100);
                }
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 2988
#include<iostream>
using namespace std;
int main(){

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

if ((A==1 || A==2 ||A==3 ||A==4 || A==5 ||A==6 ||A==7 || A==8 ||A==9 ) && (B==1 || B==2 ||B==3 ||B==4 || B==5 ||B==6 ||B==7 || B==8 ||B==9 )) {
    cout<<A*B<<endl;
}
else{
cout<<-1<<endl;

}




return 0;

}


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

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

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

  int a, b, c;
  while (cin >> a >> b >> c) {
    int diff = c - a;
    if (diff < 0) {
      cout << "NO" << endl;
      continue;
    }
    if (diff <= b) {
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
}


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

vector<pair<int,int>> neighbour[100001];
int color[100001];


void dfs(int now, int prev){
  	for(auto p: neighbour[now]){
    	if(p.first != prev){
        	color[p.first] = p.second %2 ? !color[now] : color[now];
          	dfs(p.first, now);
        }
    }
}
           
int main(){
	int n, u, v, w;
    cin >> n;
	for(int i = 0; i < n - 1 ; i++){
    	cin >> u >> v >> w;
      	neighbour[u].push_back(make_pair(v,w));
      	neighbour[v].push_back(make_pair(u,w));
    }
  	dfs(1,0);
  	for(int i = 1; i <= n; i++){
    	cout << color[i] << endl;
    }
  	return 0;

}

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

int main(){
    int n, d[100000];
    cin >> n;
    for(int i=0;i<n;++i) cin >> d[i];
    sort(d, d+n);

    cout << d[n/2] - d[n/2-1] << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int num;
  string color, cnt = "Three";
  cin >> num;
  
  for (int i=0; i<num; ++i) {
    cin >> color;
    if (color == "Y") {
      cnt = "Four";
      break;
    }
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 3608
#!/usr/bin/env python3
import sys
from itertools import chain


def solve(N: int):
    m = [0] * 100
    for n in range(N + 1):
        s = str(n)
        h = int(s[0])
        l = int(s[-1])
        if l != 0:
            m[h * 10 + l] += 1

    answer = 0
    for h in range(1, 10):
        for l in range(1, 10):
            answer += m[h * 10 + l] * m[l * 10 + h]
    return answer


def main():
    N = int(input())
    answer = solve(N)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9136
import sys
from itertools import accumulate

def solve():
    n, k = map(int, sys.stdin.readline().split())
    a = [int(sys.stdin.readline().rstrip()) - k for i in range(n)]
    s = [0] + list(accumulate(a))

    # 座標圧縮
    s = [(si, i) for (i, si) in enumerate(s)]
    s.sort()

    z = [None] * (n + 1)

    num = -1
    p = -float('inf')

    for i in range(n + 1):
        if s[i][0] > p:
            num += 1

        z[s[i][1]] = num
        p = s[i][0]

    # FenwickTreeで転倒数を数える
    ft = FenwickTree(num + 1)

    ans = 0

    for zi in z:
        ans += ft.psum(zi + 1)
        ft.add(zi, 1)

    print(ans)

class FenwickTree:
    def __init__(self, n):
        self.n = n
        self.b = [0] * (n + 1)

    def add(self, i, x):
        i += 1

        while i <= self.n:
            self.b[i] += x
            i += i & (-i)

    def psum(self, r):
        res = 0

        while r > 0:
            res += self.b[r]
            r -= r & (-r)

        return res

if __name__ == '__main__':
    solve()

Measured memory_bytes: 52216
//32
#include<iostream>

using namespace std;

int pt(int *c,int n,int k){
  int p=0;
  for(int i=0;i<n-k+1;i++){
    int cp=1;
    for(int j=0;j<k;j++){
      cp*=c[i+j];
    }
    p=max(p,cp);
  }
  return p;
}
  
int main(){
  for(int n,k;cin>>n>>k,n|k;){
    int c[100];
    for(int i=0;i<n;i++){
      cin>>c[i];
    }
    int b=pt(c,n,k);
    int cp=0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	swap(c[i],c[j]);
	cp=max(cp,pt(c,n,k));
	swap(c[i],c[j]);
      }
    }
    if(cp<b){
      cout<<"NO GAME"<<endl;
    }else{
      cout<<cp-b<<endl;
    }
  }
  return 0;
}
	  
  

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#define ll long long
using namespace std;
int main() {
	ll N, W, sum = 0,x=0;
	cin >> N >> W;
	vector<ll>w(N + 1, 0);
	vector<ll>v(N + 1, 0);
	vector<vector<ll>>dp(N + 1, vector<ll>(100001, LLONG_MAX));
	dp[0][0] = 0;
	for (ll i = 1; i <= N; i++) {
		cin >> w[i] >> v[i];
		dp[i][0] = 0;
	}
	
	for (ll i = 0; i < N; i++) {
		for (ll j = 0; j < 100001; j++) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			if (j + v[i + 1] <= 100000&&dp[i][j]!=LLONG_MAX) {
				dp[i + 1][j + v[i + 1]] =
					min(dp[i + 1][j + v[i + 1]], dp[i][j] + w[i + 1]);
				
			}
			
		}
	}
	
	for (ll i = 100000; i >=0; i--) {
		if (dp[N][i] <= W) {
			cout << i << endl;
			break;
		}
	}
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int W,A,B;
  cin >> W >> A >> B;

  int ans = 0;
  if(A <= B){
    if(A+W <= B){
      ans = B - A - W;
    } else { 
      ans = 0;
    }
  } else { 
    if(B+W <= A){
      ans = A - B - W;
    } else { 
      ans = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin>>s;
  int ans=0;
  if(s=="SUN") ans=7;
  else if(s=="MON") ans=6;
  else if(s=="TUE") ans=5;
  else if(s=="WED") ans=4;
  else if(s=="THU") ans=3;
  else if(s=="FRI") ans=2;
  else ans=1;
  cout<<ans<<endl;
}


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


using namespace std;

int main() {
    int n;
    double ans;
    
    cin >> n;
    
    if(n % 2 == 0) {
        ans = (double)1/2;
    }else {
        ans = (double)(n+1)/(2*n);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* nichijou */
template<class T,class U>
bool cmax(T & a, const U & b) {return a < b ? a = b, 1 : 0;}
template<class T,class U>
bool cmin(T & a, const U & b) {return b < a ? a = b, 1 : 0;}
/* data type */
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second
/* STL container */
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)(a).size())
#define ALL(a) begin(a), end(a)
#define CLR(a) (a).clear()
#define BK(a) ((a).back())
#define FT(a) ((a).front())
#define DB(a) (a).pop_back()
#define DF(a) (a).pop_front()
#define PB push_back
#define EB emplace_back
/* I gave you my heart and then you turned around. */
void _BG(const char * s) {cerr<<s<<endl;}
template<class T, class ... TT>
void _BG(const char * s,T a, TT...b)
{
    for (size_t c = 0; *s && (c || *s != ','); cerr << *s++)
        c += count(ALL("([{"),*s) - count(ALL(")]}"),*s);
    cerr << " = " << a;
    if (*s) {
        cerr << ", ";
        ++s;
    }
    _BG(s,b...);
}
#ifdef PR3PONY
#define BG(...) do { \
    cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
    _BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)
#else
#define BG(...)
#endif
/* Good Luck && Have Fun ! */
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, std::vector<long long> A)
{

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

    long long sum = 0;

    for (int i = 0; i < N; i++)
    {
        sum += A[i];
    }

    for (int i = 0; i < M; i++)
    {
        if (A[N - 1 - i] * (4 * M) < sum)
        {
            cout << NO << endl;
            return;
        }
    }

    cout << YES << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 256
//R<3S
#include <bits/stdc++.h>
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define int long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>
// #define INT_MAX 1e3
using namespace std;

void solve()
  {
	int n,k;
	cin>>n>>k;
	int a[n];
	rep(i,n)cin>>a[i];
	int dp[n];
	memset(dp,INT_MAX,sizeof dp);
	dp[0]=0;
	repA(i,1,n-1)
	{
		int minm=INT_MAX;
		repA(j,1,k)
		{
			if(j>i)break;
			minm=min(minm,dp[i-j]+abs(a[i]-a[i-j]));
		}
		dp[i]=minm;
	}
	cout<<dp[n-1]<<endl;


  }



signed main()
{
   std::ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}
			

Measured memory_bytes: 5188
#include<iostream>
#include<vector>
#include<functional>
#include<utility>
#include<string>
using u32 = unsigned int;
using u64 = unsigned long long;


class segtree {
	::std::vector<u64> tree;
	u32 size()const {
		return tree.size() >> 1;
	}
public:
	segtree(const u32 size) :tree(size << 1, 0) {}

	u64 fold(u32 first, u32 last)const {
		u64 ret = 0;
		for (first += size(), last += size();first < last;first >>= 1, last >>= 1) {
			if (first & 1)
				ret += tree[first++];
			if (last & 1)
				ret += tree[--last];
		}
		return ret;
	}

	void update(u32 index, u64 value) {
		index += size();
		tree[index] = value;
		while (index >>= 1)
			tree[index] = tree[index << 1] + tree[index << 1 | 1];
	}
};

int main() {
	u32 n, k;
	::std::cin >> n >> k;
	::std::vector<::std::vector<u32>> g(n);
	::std::vector<u32> parent(n), pos(n), next(n, 0), depth(n);
	::std::vector<u64> weight(n, 0), diff(n + 1, 0);
	segtree seg(n);
	{
		::std::vector<::std::vector<u32>> w(n);
		g[0].emplace_back(n);
		w[0].emplace_back(0);
		for (u32 i = 1;i < n;++i) {
			u32 a, b, c;
			::std::cin >> a >> b >> c;
			g[a].emplace_back(b);
			w[a].emplace_back(c);
			g[b].emplace_back(a);
			w[b].emplace_back(c);
		}
		u32 dp = 0;
		::std::function<u32(u32, u32)> dfs0 = [&](const u32 v, const u32 p)->u32 {
			parent[v] = p;
			depth[v] = dp++;
			u32 ret = 1;
			u32 max = 0;
			for (u32 i = 0;i < g[v].size();++i) {
				if (g[v][i] == p) continue;
				weight[g[v][i]] = w[v][i];
				u32 sub = dfs0(g[v][i], v);
				ret += sub;
				if (max < sub)
					max = sub, ::std::swap(g[v].front(), g[v][i]);
			}
			--dp;
			return ret;
		};
		dfs0(0, n);
		u32 t = 0;
		::std::function<void(u32, u32)> dfs1 = [&](const u32 v, const u32 p) {
			pos[v] = t++;
			for (const auto e : g[v]) {
				if (e == p) continue;
				next[e] = (e == g[v].front() ? next[v] : e);
				dfs1(e, v);
			}
		};
		dfs1(0, n);
	}
	::std::function<u64(u64)> get = [k](const u64 v)->u64 {
		return v%k ? v : 0;
	};
	::std::function<u32(u32, u32)> lca = [&](u32 s, u32 t)->u32 {
		while (next[s] != next[t]) {
			if (depth[next[s]] > depth[next[t]])
				s = parent[next[s]];
			else
				t = parent[next[t]];
		}
		return depth[s] < depth[t] ? s : t;
	};
	::std::function<u64(u32, u32)> fold = [&](const u32 l, u32 s)->u64 {
		u64 ret = 0;
		while (next[l] != next[s]) {
			ret += seg.fold(pos[next[s]] + 1, pos[s] + 1);
			s = next[s];
			ret += get(weight[s] + diff[parent[s]]);
			s = parent[s];
		}
		ret += seg.fold(pos[l] + 1, pos[s] + 1);
		return ret;
	};

	for (u32 i = 0;i < n;++i) {
		seg.update(pos[i], get(weight[i]));
	}
	u32 q;
	::std::cin >> q;
	::std::string mes;
	while (q--) {
		::std::cin >> mes;
		if (mes[0] == 'a') {
			u32 x, d;
			::std::cin >> x >> d;
			weight[x] += d;
			diff[x] += d;
			seg.update(pos[x], get(weight[x]));
			if (g[x].size() != 1) {
				const u32 hp = g[x].front();
				weight[hp] += d;
				seg.update(pos[hp], get(weight[hp]));
			}
		}
		else {
			u32 s, t;
			::std::cin >> s >> t;
			const u32 l = lca(s, t);
			::std::cout << fold(l, s) + fold(l, t) << ::std::endl;
		}
	}

	return 0;
}




Measured memory_bytes: 27744
//なにもわからない
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
inline ll getll() {
	ll A = 0;
	if (ci - cn + 24 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int tmp[200001];
void pakuri_sort(int N, int A[]) {
	const int b = 8;
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}
void pakuri_sort2(int N, int A[]) {
	const int b = 8;
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		for (int i = (1 << b) - 2; i >= 0; i--) kazu[i] += kazu[i + 1];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		for (int i = (1 << b) - 2; i >= 0; i--) kazu2[i] += kazu2[i + 1];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	ll N = getint(), K = getll();
	int A[200000], F[200000];
	rep(i, N) A[i] = getint();
	rep(i, N) F[i] = getint();
	pakuri_sort(N, A);
	pakuri_sort2(N, F);

	ll L = -1, R = 1e12;
	while (L + 1 < R) {
		ll M = (L + R) / 2;

		ll kazu = 0;
		rep(i, N) {
			if ((ll)A[i] * F[i] > M) {
				kazu += A[i] - (int)((double)M / F[i]);
				if (kazu > K) break;
			}
		}
		if (kazu > K) L = M;
		else R = M;
	}

	printf("%lld", R);


	Would you please return 0;
}

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

using namespace std;

int main(){
    int n,k,l,d,a,c;

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

    int A[150];
    
    for(int l =1; l <= n; l++){
        A[l] =1;
    }

    for(int i =0 ; i < k ; i++){
        scanf("%d",&d);

        for(int m = 0; m < d; m++){
            scanf("%d",&a);
            A[a] = 0;
        }

    }

    c = 0;
    for(int l =1; l <= n; l++){
        if(A[l] == 1)  c = c+1;
    }

    cout << c << endl;

    return 0;
}

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

int main(){
    while(1 > 0){
        int a,b;
        string op;
        cin >> a >> op >> b;
        if (op == "+"){
            cout << a + b;
        } else if (op == "-"){
            cout << a - b;
        } else if (op == "*"){
            cout << a * b;
        } else if (op == "/"){
            cout << a / b;
        } else {
            break;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3148
s=input()
t=input()
ans=0
if s == t:
  print('Yes')
else:
  for i in range(len(s)):
    s = s[-1] + s[0:-1]
    if s == t:
      ans += 1
  
  if ans == 0:
    print('No')
  else:
    print('Yes')

Measured memory_bytes: 38256
#include <stdio.h>

int main(void)
{
	int h, n, a, i;
	int sum = 0;

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

	for (a = 0; a < n; a++) 
	{
		scanf("%d", &i);
		sum = sum + i;//必殺技の合計値を求める
	}

	if (h <= sum) //必殺技の合計値より敵の体力が低い場合
	{
		printf("Yes\n");
	}
	else //必殺技の合計値より敵の体力が多い場合
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt(), l=sc.nextInt();
        int i,tmp,flag;
        int[] array = new int[11], check = new int[11];
        for(i=0;i<9;i++) check[i]=0;
        for(i=0;i<l;i++){
            array[i] = sc.nextInt();
            check[array[i]]=1;
        }
        for(i=n;;i++){
            tmp = i;
            flag = 1;
            for(;;){
                if(tmp==0) break;
                if(check[tmp%10]==1){
                    flag = 0;
                    break;
                }
                tmp/=10;
            }
            if(flag==1){
                System.out.println(i);
                break;
            }
        }
    }
}

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc =new Scanner(System.in);
		int N = sc.nextInt();
		int[] T = new int[N];
		for(int i = 0; i < T.length; i++) {
			T[i] = sc.nextInt();	
		}
		int M = sc.nextInt();
		int[] P = new int [M];
		int[] X = new int [M];
		for(int i = 0; i < M; i++) {
			P[i] = sc.nextInt();
			X[i] = sc.nextInt();
		}
		int sum = 0;
		for(int i = 0; i < M; i++) {
			int a = P[i];
			int b = T[a - 1];
			T[a - 1] = X[i];
			for(int j = 0; j < N; j++) {
				sum += T[j];
			}
			System.out.println(sum);
			sum = 0;
			T[a - 1] = b;
			
		}

	}

}

Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<vector>

using namespace std;

int main(){
    long long sum = 0;
    long long n = 0;
    cin>>n;

    long long f = n/3;
    long long b = n/5;
    long long fb = n/15;
    sum = n*(n+1)/2;
    sum = sum - 3*(f*(f+1)/2);
    sum = sum - 5*(b*(b+1)/2);
    sum = sum + 15*(fb*(fb+1)/2);
    cout<<sum<<endl;

    return 0;
}


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


int main(){
int N,K,R,S,P;
  cin >> N >> K >> R >> S >>P;
  
  string T;
  cin >> T;
  
ll co=0;
  
  rep(i,N){
    if(i>=K && T.at(i-K)==T.at(i)){
        T.at(i)='j';        
    }
    if(T.at(i)=='r')
      co+=P;
    else if(T.at(i)=='s')
      co+=R;
    else if(T.at(i)=='p')
      co+=S;
  }

  cout << co << endl;
  
}

Measured memory_bytes: 512
<?php

fscanf(STDIN, "%d", $N);
$board_values = array_map("intval", explode(" ", trim(fgets(STDIN))));

$max = 0;
$tmp = 0;
$prev = $board_values[0];

if ($prev == 1) {
    $tmp++;
}

for ($i = 1; $i < count($board_values); ++$i) {

    if ($prev != 1) {
        $tmp = 0;
    }

    if ($board_values[$i] == 1) {
        ++$tmp;
    }
    
    if ($max < $tmp) $max = $tmp;
    $prev = $board_values[$i];

}

echo $max+1, "\n";


Measured memory_bytes: 9300
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
typedef long long ll;
int num[10007];
int main()
{
    int n;
    cin >> n;
    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                int tmp = x * x + y * y  + z * z + x * y + x * z + y * z;
                if(tmp <= 10000) num[tmp]++;
            }
        }
    }
    for (int i = 1; i <= n; i++)
        printf("%d\n", num[i]);
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


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

  vector<int> w(n),e(n);
  if(s[0]=='E'){e[0]=1,w[0]=0;}else{e[0]=0,w[0]=1;}
  for(int i=1; i<n; i++){
    if(s[i]=='E'){e[i]++;}else{w[i]++;}
    e[i]+=e[i-1];
    w[i]+=w[i-1];
  }

  vector<int> wr(n),er(n);
  if(s[n-1]=='E'){er[n-1]=1,wr[n-1]=0;}else{er[n-1]=0,wr[n-1]=1;}
  for(int i=n-2; i>=0; i--){
    if(s[i]=='E'){er[i]++;}else{wr[i]++;}
    er[i]+=er[i+1];
    wr[i]+=wr[i+1];
  }  
  
  int ans=min(er[1],w[n-2]);
  for(int i=1; i<n-1; i++){
    int cur = w[i-1]+er[i+1];
    ans = min(ans,cur);
  }
  cout << ans << endl; 
  return 0;

}


Measured memory_bytes: 5380
package main

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

func main() {
	n := getInt()

	until := int(math.Ceil(math.Sqrt(float64(n))))
	ans := 10
	for i := 1; i <= until; i++ {
		if n%i == 0 {
			ans = min(ans, f(n/i, i))
		}
	}

	fmt.Println(ans)
}

func f(a, b int) int {
	maxLen := max(len(strconv.Itoa(a)), len(strconv.Itoa(b)))
	return maxLen
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

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

var scanner = wordScanner()

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

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a%b==0) puts("-1");
	else
	{
		for(long long i=2*a;;i+=a)
		{
			if(i%b)
			{
				printf("%lld\n",i);
				break;
			}
		}
	}
}

Measured memory_bytes: 128
N = int(input())

flag = 0

for i in range(100):
    if flag == 1:
        break
    for j in range(100):
        if flag == 1:
            break
        tmp = 4*i + 7*j
        if tmp == N:
            print("Yes")
            flag = 1
if flag == 0:
    print("No")

Measured memory_bytes: 38576
from sys import stdin

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

if __name__ == '__main__':
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    print(lcm(A, B))

Measured memory_bytes: 3060
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))
n,p = m()


dp = [0 for i in range(n+1)]
dp[0] = 1
dp[1] = 1
k = []

for i in range(p):
	k = int(input())
	dp[k] = -1

for i in range(2,n+1):
	if dp[i] == -1:
		continue
	elif dp[i-1] == -1 and dp[i-2] == -1:
		continue
	elif dp[i-1] == -1:
		dp[i] += dp[i-2]
	elif dp[i-2] == -1:
		dp[i] += dp[i-1]
	else:
		dp[i] += dp[i-1] + dp[i-2]
print(dp[-1]%(10**9+7))


Measured memory_bytes: 463012
import unittest


class TestA(unittest.TestCase):
    def test_4(self):
        # (actual_value, expected_value)
        self.assertEqual(think(4), 0.5)

    def test_5(self):
        self.assertEqual(think(5), 0.6)

    def test_1(self):
        self.assertEqual(think(1), 1.0)


def solve():
    n = read()
    result = think(n)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    if data % 2 == 0:
        return 0.5
    return ((data + 1) // 2) / data


def write(result):
    print(result)


if __name__ == '__main__':
    # import sys
    # sys.setrecursionlimit(10000)
    # unittest.main()
    solve()

Measured memory_bytes: 5604
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
using namespace std;

int sum[maxn];
int a[maxn];
map<int, int> ma;

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		sum[i] = (sum[i-1] + a[i]) % m;
		ans += ma[sum[i]];
		ma[sum[i]]++;
	}
	printf("%lld\n", ans + ma[0]);
	return 0;
}

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

public class Main {

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

		String str[] = br.readLine().split(" ");

		long n = Long.parseLong(str[0]);
		long m = Long.parseLong(str[1]);

		long ans = (n * m) - (n + (m - 1) + (n - 1) + (m - 2));
		if (ans < 0) {
			ans *= -1;
		}

		System.out.println(ans);
	}
}

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

map<pair<int,int>,long long >m;
vector<pair<int,int> >v;
int main(){
long long n,x,y,ans=0;
cin>>n;
for(long long i=0;i<n;i++){
	cin>>x>>y;
	v.push_back({x,y});
} 
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			x=v[j].first-v[i].first;
			y=v[j].second-v[i].second;
			m[{x,y}]++;
			ans=max(ans,m[{x,y}]);
		}
	}
  cout<<n-ans;	
}



Measured memory_bytes: 384
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
    int N,L;
    cin >> N >> L;
    int eat=0;
    int taste=299;
    int taste_all=0;
    for(int i=1;i<=N;i++)
    {
        if(taste>abs(L+i-1))
        {
            eat=i;
            taste=abs(L+i-1);
        }
        taste_all+=L+i-1;
    }
    cout << taste_all-(L+eat-1) << endl;
    return 0;
}


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


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


int main() {

    long long N;

    cin >> N;
    vector<vector<long long> > dp(100010, vector<long long> (2,0));
    vector<long long> A(N);

    for (long long i = 0;i < N; i++){
        cin >> A[i];
    }
    dp[0][0] = 0;
    dp[0][1] = -1145141919810;
    for (long long i = 0;i < N; i++){
        dp[i + 1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i]);
        dp[i + 1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i]);
    }
    cout << dp[N][0] << endl;
}


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

typedef long long ll;


char str[104];

int main(){
    while(1){
        stack<int> st;
        bool judge = true;

        fgets(str, 104, stdin); 
        if(str[0]=='.')break;
    
        int i=0;
        while(str[i] != '.'){
            if(str[i]=='(' || str[i]=='['){
                st.push(str[i]);
            }else if(!st.empty()){
                if(str[i]==')'){
                    if(st.top() == '('){
                        st.pop();
                    }else{
                        judge = false;
                    }
                }else if(str[i]==']'){
                    if(st.top() == '['){
                        st.pop();
                    }else{
                        judge = false;
                    }
                }
            }else if(st.empty()){
                if(str[i]==')' || str[i]==']') judge = false;
            }
            if(judge==false){
                break;
            }
            i++;
        }
        if(!st.empty()){
            judge = false;
        }
        if(judge){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }

}


Measured memory_bytes: 2976
//13-1 ??????
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main(){
    int L,A,B,C,D;
    cin >> L >> A >> B >> C >> D;
    while(A>0||B>0){
        L--;
        A -= C;
        B -= D;
    }
    cout << L << endl;
    return 0;
}


Measured memory_bytes: 3092