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

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b){

    ll r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a%b;
    }
    return b;
}

int main(){
    ll m, n;
    cin >> m >> n;
    string s, t;
    cin >> s >> t;
    if(m < n){
        string u = s;
        s = t;
        t = u;
        ll o = m;
        m = n;
        n = o;
    }
    if((m/n)*n == m){
        ll d = m/n;
        for(ll a = 0; a < n; a++){
            if(s[d*a] != t[a]){
                cout << -1 << endl;
                return 0;
            }
        }
        cout << m << endl;
    }
    else{
        ll h = n/gcd(m,n)*m;
        ll i = h/m;
        ll j = h/n;
        ll k = i*j/gcd(j,i);
        for(int b = 0; b < h/k; b++){
            if(s[b*j] != t[b*i]){
                cout << -1 << endl;
                return 0;
            }
            if(b == h/k-1){
                cout << h << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int K;
ll A[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> K;
    rep(i, 0, K) cin >> A[i];

    ll L = 2, R = 2;
    rrep(i, K - 1, 0) {
        L = (L + A[i] - 1) / A[i] * A[i];
        if (R < L) {
            printf("-1\n");
            return;
        }

        R = (R / A[i] + 1) * A[i] - 1;
    }

    printf("%lld %lld\n", L, R);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    ll n, k;
    cin >> n >> k;
    cout << min(n % k, k - (n % k));
    return 0;
}

Measured memory_bytes: 256
def solve():
    inf = 1 << 60
    D, G = map(int, input().split())
    p = [0]
    c = [0]
    for i in range(D):
        pi, ci = map(int, input().split())
        p.append(pi)
        c.append(ci)
    sump = sum(p)
    # dp[i][j] = 100i点の問題までで、j問解いて得られる最大の点数
    dp = [[-inf for j in range(sump+1)] for i in range(D+1)]
    dp[0][0] = 0
    for d in range(1,D+1):
        for i in range(sump+1):
            for j in range(p[d]+1):
                if i - j >= 0:
                    dp[d][i] = max(dp[d][i], dp[d-1][i])
                    if dp[d-1][i-j] >= 0:
                        if j != p[d]:
                            dp[d][i] = max(dp[d][i], dp[d-1][i-j] + 100*d*j)
                        else:
                            dp[d][i] = max(dp[d][i], dp[d-1][i-j] + 100*d*j+c[d])
        #print(dp)
    for i in range(sump+1):
        if dp[D][i] >= G:
            return i

print(solve())


Measured memory_bytes: 41712
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] a = new int[N];
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    int ans = -1;
    int left = 0;
    int right = N;
    while(left < right) {
      int med = (left + right) / 2;
      if(a[med] < K) {
        // dp[i][j]はカードiまででカードmedを使わずに総和をjと出来るかを表す
        boolean[][] dp = new boolean[N][K];
        dp[0][0] = true;
        if(med != 0) dp[0][a[0]] = true;
        for(int i = 1; i < N; i++) {
          dp[i][0] = true;
          for(int j = 1; j < K; j++) {
            if(med != i) {
              if(a[i] <= j) {
                dp[i][j] = dp[i - 1][j] || dp[i - 1][j - a[i]];
              } else {
                dp[i][j] = dp[i - 1][j];
              }
            } else {
              dp[i][j] = dp[i - 1][j];
            }
          }
        }
        boolean flg = false;
        for(int j = K - a[med]; j < K; j++) {
          if(dp[N - 1][j]) flg = true;
        }
        if(flg) {
          right = med;
        } else {
          ans = med;
          left = med + 1;
        }
      } else {
        right = med;
      }
    }
    ans++;
    System.out.println(ans);
  }
}

Measured memory_bytes: 207144
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    ll A,B,C; cin>>A>>B>>C;
    if(A+B+1 >= C){
        cout<<B+C<<endl;
        return 0;
    }
    cout<<A+2*B+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;

#define N 310
int dp[N][N];
int ukai[N][N];
int a[N][N] = {0};
    
signed main(){
    
    int n;
    cin >> n;
    rep(i,n) rep(j,n) dp[i][j] = INF;
    rep(i,n) rep(j,n) ukai[i][j] = INF;

    rep(i,n){
        rep(j,n){
            cin >> dp[i][j]; 
            a[i][j] = dp[i][j];
        }
    }

    rep(k,n){
        rep(i,n){
            rep(j,n){
                dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);
            }
        }
    }

    rep(i,n){
        rep(j,n){
            rep(k,n){
                if(i == k || j == k)continue;
                ukai[i][j] = min(ukai[i][j],dp[i][k] + dp[k][j]);
            }
        }
    }
    rep(i,n){
        rep(j,n){
            cerr << dp[i][j] << " "; 
        }
        cerr << endl;
    }
    cerr << endl;
    rep(i,n){
        rep(j,n){
            cerr << ukai[i][j] << " "; 
        }
        cerr << endl;
    }

    int ans = 0;
    rep(i,n){
        for(int j = i+1;j<n;j++){
            if(dp[i][j] != a[i][j]){
                cout << -1 << endl;
                return 0;
            }
            if(ukai[i][j] > dp[i][j]){
                ans += dp[i][j];
            }
        }
    }
    cout << ans << endl;

    

    return 0;   
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://abc118.contest.atcoder.jp/tasks/abc118_a

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

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

	for(int i = 1;;i++){
        int n = sc.nextInt();
        if(n==0){
            break;
        }
                System.out.println("Case "+i+": "+n);

    }
    }
}



Measured memory_bytes: 41432
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int MOD = 1e9+7;
const int INF = 1e9;
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif

string N; int n;
int memo[101][3][2];
int dfs(int keta, int rest, bool lower) {
  // あとrest個数字を選べて、残りketa桁決めれるときの場合の数
  if (memo[keta][rest][lower] != INF)
    return memo[keta][rest][lower];
  if (keta == n && rest > 0)
    return memo[keta][rest][lower] = 0;
  if (keta == n)
    return memo[keta][rest][lower] = 1;

  if (lower) {
    if (rest == 0)
      return memo[keta][rest][lower] = dfs(keta+1, rest, lower);
    return memo[keta][rest][lower] = 9 * dfs(keta+1, rest-1, lower) + dfs(keta+1, rest, lower);
  }

  // まだ未確定
  int D = N[keta] - '0';
  int ans = dfs(keta+1, rest, (D > 0));

  if (rest >= 1)
    fromto(i, 1, D) {
      ans += dfs(keta+1, rest-1, (i < D));
    }
  return memo[keta][rest][lower] = ans;
}

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

  n = N.size();

  rep(i, n+1) rep(j, 3) {
    memo[i][j][0] = INF;
    memo[i][j][1] = INF;
  }
  // まず、Nより桁数が小さい場合をカウントしたい。
  ll ans = 0;
  rep(i, 1, n) {
    if (i < K)
      continue;
    // i桁のときを数える
    ll tmp = 1;
    rep(j, K)
      tmp *= 9;
    // i-1箇所からk-1個選ぶ。
    if (K == 2)
      tmp *= (i-1);
    if (K == 3)
      tmp *= (i-1) * (i-2) / 2;
    ans += tmp;
  }
  ans += ((N[0]-'0')-1) * dfs(1, K-1, true);
  ans += dfs(1, K-1, false);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    ll N, k = 1;
    vector<ll> v;
    cin >> N;
    if(N == 1){
        PRINT("a");
        return 0;
    }else if(N == 2){
        PRINT("b");
        return 0;
    }
    ll n = N;
    while(n > 0){
        v.push_back((n - 1) / k % 26);
        k *= 26;
        n -= k;
    }
    for(int i = v.size() - 1; i >= 0; i--){
        char c;
        c = 'a' + v[i];
        cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3588
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);
        DLunlunNumber solver = new DLunlunNumber();
        solver.solve(1, in, out);
        out.close();
    }

    static class DLunlunNumber {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long x = 10;
            if (n <= 10) {
                out.println(n);
            } else {
                for (int i = 10; i < n; i++) {
                    x = nextRunRun(x);
                }
                out.println(x);
            }


        }

        long nextRunRun(long x) {
            char[] s = Long.toString(x).toCharArray();
            int last = -1;
            for (int i = 1; i < s.length; i++) {
                if (s[i - 1] == s[i] && s[i - 1] < '9') {
                    last = i;
                } else if (s[i - 1] > s[i]) {
                    last = i;
                }
            }

            StringBuilder sb = new StringBuilder();
            if (last == -1) {
                if (s[0] == '9') {
                    sb.append(1);
                    for (int i = 0; i < s.length; i++) {
                        sb.append(0);
                    }
                } else {
                    char c = (char) (s[0] + 1);
                    for (int i = 0; i < s.length; i++) {
                        sb.append(c);
                        if (c > '0') {
                            c--;
                        }
                    }
                }
            } else {
                for (int i = 0; i < last; i++) {
                    sb.append(s[i]);
                }
                char c = (char) (s[last] + 1);
                for (int i = last; i < s.length; i++) {
                    sb.append(c);
                    if (c > '0') {
                        c--;
                    }
                }
            }
            return Long.parseLong(new String(sb));
        }

    }
}



Measured memory_bytes: 41864
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}
int ans = INT_MAX;
int n, m, x;
void solve(int ind,vector<VII>& cost,int sum,VII skills)
{
	bool done = true;
	for(auto ss:skills)
	{
		if(ss<x)
		done = false;
	}
	if(done)
	{
		ans = min(ans, sum);
	}

	if(ind>=n)
	{
		return;
	}
	//pick ind
	VII temp=skills;
	for (int i = 0; i < m;++i)
		temp[i] += cost[ind][i];

	// for(auto xx:temp)
	// 	cout << xx << ' ';
	// cout << endl;
	// for(auto yy:skills)
	// 	cout << yy << ' ';
	// cout << endl
	// 	 << endl;
	solve(ind + 1, cost, sum + cost[ind][m], temp);
	//dont pick ind

	solve(ind + 1, cost, sum, skills);
}
int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> m >> x;
	vector<VII> cost(n);
	for (int i = 0; i < n;++i)
	{
		int c,f;
		cin >> f;
		for (int j = 0; j < m;++j)
		{
			cin >> c;
			cost[i].pb(c);
		}
		cost[i].pb(f);
	}

	solve(0, cost, 0, VII(m, 0));
	if(ans==INT_MAX)
		cout << -1;
	else
		cout << ans;
#ifdef LOCAL
		auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>      /* printf, scanf, NULL */
#include <stdlib.h>
#include <math.h>
#include <iomanip>      // std::setprecision
#include <algorithm>
using namespace std;
int main(void){
    long long x;
    cin >> x;
    long long h;
    h = ceil(sqrt(x));
    while(x % h != 0){
        h --;
    }
    cout << floor(log10(x/h)+1);
    // Here your code !
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int a, b;
    cin >> a >> b;
    cout << max(0, a - b) << endl;
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
S=input()
O=[]
E=[]
flag=0
if n==1:
	print(0)
else:
	c=0
	for i in range(n-1):
		if S[i+1]==S[i]:
			c+=1
		else:
			if flag==0:
				O.append(c)
				c=0
				flag=1
			else:
				E.append(c)
				c=0
				flag=0
	if flag==0:
		O.append(c)
	else:
		E.append(c)
	Osum=sum(O)
	Esum=sum(E)		
	EC=len(E)
	if flag==0:
		print(Osum+Esum+min(EC,k)*2)
	else:
		print(Osum+Esum+min(2*EC-1,2*k))

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

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

    for (int i = 0; i <= s.size(); i++)
    {
        if (i == s.size())
        {
            cout << "Yes" << endl;
            break;
        }
        if (s.at(i) == t.at(i))
        {
            continue;
        }

        cout << "No" << endl;
        break;
    }
}

Measured memory_bytes: 3640
# DSL_1_A.py
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, Q = map(int, input().split())
union_find = UnionFind(N)
for i in range(Q):
    query, x, y = map(int, input().split())
    x = int(x)
    y = int(y)
    if query == 0:
        union_find.union(x, y)
    else:
        print(1 if union_find.same(x, y) else 0)



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

using namespace std;

vector<int> divisor(int x)
{
    vector<int> res;
    for (int i = 1; i <= x; i++) {
        if (x % i == 0) {
            res.emplace_back(i);
        }            
    }
    return res;
}

int main()
{
    int N;
    cin >> N;
    vector<int> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    auto d = divisor(N);
    for (auto& c : d) {
        bool poss = 1;
        for (int i = c; i < N; i += c) {
            bool ok = 1;
            for (int j = 0; j < c; j++) {
                if (S[i + j] != S[i + j - c]) {
                    ok = 0;
                    break;
                }
            }
            if (!ok) {
                poss = 0;
                break;
            }
        }
        if (poss) {
            cout << N / c << endl;
            break;
        }
    }    
    return 0;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    char a, b; cin >> a >> b;

    if (a == 'H') {
        cout << b << endl;
    } else {
        if (b == 'H') {
            cout << 'D' << endl;
        } else {
            cout << 'H' << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T> &vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> xy(n);
  REP(i, n) { cin >> xy[i].first >> xy[i].second; }

  double ans = 0;
  ll count = 0;

  sort(ALL(xy));
  do {
    count++;
    REP(i, n - 1) {
      double dist, x_ij, y_ij;
      int j = i + 1;
      x_ij = pow(xy[i].first - xy[j].first, 2);
      y_ij = pow(xy[i].second - xy[j].second, 2);
      dist = sqrt(x_ij + y_ij);
      ans += dist;
    }
  } while (next_permutation(ALL(xy)));
  ans /= count;
  cout << setprecision(8) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int dp[1005][1005], n, m;
char arr[1005][1005];
ll mod = 1e9 + 7;
int solve(int i, int j) {
	if (i >= n || j >= m ||arr[i][j] == '#' )
		return 0;
	if (i == n - 1 && j == m - 1)
		return 1;
	if (~dp[i][j])
		return dp[i][j];
	return dp[i][j] = ((solve(i + 1, j) % mod) + (solve(i, j + 1) % mod))%mod;
}
int main() {
	IO
	scanf("%d%d", &n, &m);

	memset(dp, -1, sizeof dp);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++){
			scanf(" %c", &arr[i][j]);
		}
	}
	cout << solve(0, 0);

	return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int l[n];
    for(int i=0;i<n;i++)cin >> l[i];
    sort(l,l+n);
    int ans=0;
    for(int i=n-k;i<n;i++)ans+=l[i];
    cout << ans;
}

Measured memory_bytes: 3636
/* Manish Pant - insider_pants, hello_my_friend */
    
#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;

#define F first
#define S second
#define endl "\n"
#define pb push_back

typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; } 

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int N = 2e5 + 5;
int n;
vector<int> v;
vector<vector<int>> segtree(4 * N);

void build(int node = 0, int l = 0, int r = n - 1)
{
    if(l == r)
    {
        segtree[node].pb(v[l] + l);
        return;
    }
    int mid = (l + r) >> 1;
    build(2 * node + 1, l, mid);
    build(2 * node + 2, mid + 1, r);

    merge(segtree[2 * node + 1].begin(), segtree[2 * node + 1].end(), segtree[2 * node + 2].begin(), segtree[2 * node + 2].end(), back_inserter(segtree[node]));
}

int query(int x, int y, int val, int node = 0, int l = 0, int r = n - 1)
{
    if(l > y || r < x || x > y) return 0;
    if(l >= x && r <= y)
    {   
        auto it = upper_bound(segtree[node].begin(), segtree[node].end(), val);
        auto it2 = lower_bound(segtree[node].begin(), segtree[node].end(), val);

        return int(it - it2);
    }
    int mid = (l + r) >> 1;
    return query(x, y, val, 2 * node + 1, l, mid) + query(x, y, val, 2 * node + 2, mid + 1, r);
}

void solve()
{
    build();
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        int mx = max(i, n - i - 1);
        if(v[i] >= mx) continue;

        int diff = mx - v[i];
        ans += query(0, i - v[i] - 1, i - v[i]);

        // cout << i <<"-> ";
        // cout << mx << ' ' << v[i] << endl;
    }
    // ans >>= 1;
    cout << ans << endl;
}

int main()
{
    fast();
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int a; cin >> a;
        v.pb(a);
    }
    solve();
}

Measured memory_bytes: 50456
package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	N := readInt()
	M := readInt()
	V := readInt()
	P := readInt()

	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	p := A[P-1]
	V -= P - 1
	b := A[P-1:]
	for {
		mv := M * V
		for i := 0; i < len(b); i++ {
			t := min(p-b[i], M)
			mv -= t
		}
		if mv > 0 {
			p += (mv + len(b) - 1) / len(b)
		} else {
			break
		}
	}

	result := 0
	for i := 0; i < N; i++ {
		if A[i]+M >= p {
			result++
		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 3968
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
using namespace std;

using ll = long long;
using P = pair<int, int>;

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

    const int  MAX_N = 300000;
    static int a[MAX_N];
    static P   a_idx[MAX_N]; 

    for (int i = 0; i < N; i++) {
        cin >> a[i];

        a_idx[i] = make_pair(a[i], i);    
    }
    sort(a_idx, a_idx + N);

    set<int> set_for_left,  // 負の値を入れる
             set_for_right;
    set_for_right.insert(N);
    set_for_left.insert(1);

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        int val = a_idx[i].first,
            idx = a_idx[i].second,
            left = -(*set_for_left.lower_bound(-idx)),
            right = *set_for_right.lower_bound(idx);

        ans += (ll)(idx - left) * (ll)(right - idx) * val;

        set_for_left.insert(-idx);
        set_for_right.insert(idx);
    }
    cout << ans << endl;

    return 0;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	int x;
	cin >> x;
	cout << "A";
	cout << (x < 1200 ? "B" : "R") << "C";


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,L;
    cin>>n>>L;
    vector<ll> a(n),left(n+1,0);
    for(int i=0;i<n;i++)cin>>a.at(i);
    for(int i=0;i<n;i++)left.at(i+1)+=left.at(i)+a.at(i);//左からの累積和
    bool flag=false;
    int center=0;
    for(int i=2;i<=n;i++){
     if(left.at(i)-left.at(i-2)>=L){
         flag=true;
         center=i;
         break;
     }
    }
if(flag){
    cout<<"Possible"<<endl;
for(int i=0;i<center-2;i++)cout<<i+1<<endl;
for(int i=a.size()-1;i>center-2;i--)cout<<i<<endl;
}
else cout<<"Impossible"<<endl;

}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int a=0;
  string s;
  cin>>s;

  r(i,s.size()){
    if(s.at(i)=='+')a++;
    else a--;
  }
  cout<<a<<endl;


return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(int i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    int n; cin >> n;
    vector<pair<int, int>> p;
    rep(i, n) {
        int x, y; cin >> x >> y;
        p.push_back(make_pair(x, y));
    }
    sort(all(p));
    double ans = 0;
    ll count = 0;
    do {
        count++;
        rep(i, n-1) ans += hypot(p[i].first - p[i+1].first, p[i].second - p[i+1].second);
    }
    while(next_permutation(all(p)));
    cout << setprecision(10) << ans / count << endl;
}

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

int main(){
    int N;
    cin >> N;
    long long A[N+1],B[N];

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

    for(int i = 0; i < N; i++) {
        cin >> B[i];
    }
    
    long long ans;
    for(int i = 0; i < N; i++) {
        if(A[i] <= B[i]){
            //　全員倒す
            ans += A[i];
            B[i] -= A[i];
            A[i] = 0;

            if(A[i+1] <= B[i]){
                //　全員倒す
                ans += A[i+1];
                B[i] -= A[i+1];
                A[i+1] = 0;
            }else{
                ans += B[i];
                A[i+1] -= B[i];
                B[i] = 0;
            }
        }else{
            ans += B[i];
            A[i] -= B[i];
            B[i] = 0;
        }

        if(DEBUG){
            for(int i = 0; i < N+1; i++) {
                cout << A[i] << " ";
            }
            cout << endl;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    for(int i = 0;i < s.size();i++)
    {
        if(s[i] == ',')
        {
            cout << " ";
        }
        else
        {
            cout << s[i];
        }
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
ll dp[1000100][2];


int main(){
    ld h,w,x,y;
    cin>>w>>h>>x>>y;
    cout<<setprecision(10)<<h*w/2.0<<" ";

    if(y==h/2.0 && x==w/2.0){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
    
}

Measured memory_bytes: 3784
n,*a=map(int,open(0))
x=0
c=[0]*30
for i in a:
  x^=i
  c[bin(i^i-1)[::-1].rfind('1')]=1
a=0
for i in range(29,-1,-1):
  if x&2**i:
    if c[i]:
      a+=1
      x^=2**i-1
    else:
      print(-1)
      break
else:
  print(a)

Measured memory_bytes: 47452
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int sum = 0;
    
    if((n-k) >= 0){
      sum += (k*x)+((n-k)*y);
    }else{
      sum += n*x;
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 21460
# Aizu Problem 0031: Weight
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

while True:
    try:
        w = int(input())
    except EOFError:
        break
    b = bin(w)[2:][::-1]
    while len(b) < 10:
        b += '0'
    out = ""
    for k in range(10):
        if b[k] == '1':
            out += str(2**k) + ' '
    print(out[:-1])

Measured memory_bytes: 7716
#include<stdio.h>
int main () {
int a,b,c,tmp;
scanf ("%d %d %d",&a,&b,&c);
if (b<a) {
tmp=b;
b=a;
a=tmp;
}
if (c<b) {
tmp=b;
b=c;
c=tmp;
}
if (b<a) {
tmp=a;
a=b;
b=tmp;
}
printf("%d %d %d\n",a,b,c);

return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>

void trace(int A[], int N){ 
    int i;
    for (i= 0; i < N; i++ ){
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }    
    printf("\n");
}

void insertionSort(int A[], int N){ 
    int j,i,v;
    for (i = 1; i < N; i++){
        v = A[i];
        j = i - 1;
        while( j >= 0 && A[j] > v){ 
            A[j + 1] = A[j];
            j--;
        }   
        A[j + 1] = v;
        trace(A, N); 
    }   
}

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

    trace(A,N);
    insertionSort(A,N);
    
    return 0;

}

Measured memory_bytes: 2664
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,b,c = na()
k = ni()

for i in range(k+1):
    if a >= b:
        b*=2
    elif b >= c:
        c*=2
    else:
        print('Yes')
        exit()

print('No')

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

int main()
{
    int n, k;
    cin >> n >> k;
    cout << k * (int)pow((k - 1), n - 1) << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace::std;
int main()
{
        int a, b;
        cin >> a >> b;
        if( a == b) {
                cout<< "a == b" << endl;
                }
        else {
                if( a < b) {
                        cout << "a < b" << endl;
                        }
        else {
                cout << "a > b" << endl;
                }
        }
}



Measured memory_bytes: 3112
#include <stdio.h>

int check(char a, char b, char c)
{
    if (a != b && a != c && b != c) {
        return 1;
    }
    return 0;
}

int main(void)
{
    int N;
    char S[4001];
    scanf("%d", &N);
    scanf("%s", S);

    // 全てのRGBの順列
    int i;
    int r = 0, g = 0, b = 0;
    for (i = 0; i < N; i++) {
        if (S[i] == 'R') r++;
        if (S[i] == 'G') g++;
        if (S[i] == 'B') b++;
    }
    long long result = r * g * b;

    // 距離が同じでRGBなら除外
    // long long exc = 0;
    // int head, center, tail;
    // for (head = 0; head < N - 2; head++) {
    //     for (center = head + 1; center < N - 1; center++) {
    //         tail = center * 2 - head;
    //         if (tail > N - 1) break;
    //         if (check(S[head], S[center], S[tail])) {
    //             exc++;
    //         }
    //     }
    // }
    int head = 0;
    int center = 1;
    int tail = 2;
    while (head < N - 2) {
        if (check(S[head], S[center], S[tail])) {
            // exc++;
            result--;
        }
        center += 1;
        tail += 2;
        if (tail > N - 1) {
            head++;
            center = head + 1;
            tail = head + 2;
        }
    }

    // printf("%lld\n", exc);
    printf("%lld\n", result);
    return 0;
}

Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;


int main(){
  int i,j;
  int n;
  cin>>n;
  ll l[n],r[n];
  for(i=0;i<n;i++) cin>>l[i]>>r[i];
  sort(l,l+n,greater<ll>());
  sort(r,r+n);
  ll ans=0;
  int p=0;
  ll tem=0;
  while(l[p]>=r[p]){
    ans+=2*(l[p]-r[p]);
    p++;
    if(p!=n) tem=max(tem,ans+max(0ll,max(2*l[p],-2*r[p])));
  }
  cout<<tem<<endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>N>>M>>K;
    vec a(N);
    rep(i,N) cin>>a[i];
    ll SUM = 0;
    rep(i,N) SUM += a[i];
    if(SUM - K <= M){
        cout<<0<<endl;
        return 0;
    }
    sort(ALL(a));
    reverse(ALL(a));
    ll ans = 0;
    rep(i,N) ans += a[i] * (a[i] + 1) / 2;
    int id = 0, last_sum = 0; //最後に回すやつ（これ含む）
    while(a[id] + last_sum <= M){
        last_sum += a[id];
        ans -= a[id] * (a[id] + 1)/2;
        ++id;
    }
    ll border = M - last_sum;
    ll judge = 0;
    Rreps(i, N, id) if(a[i] > border) judge += a[i] - border;
    if(judge <= K){
        K -= a[id] - border;
        ans -= a[id] * (a[id] + 1) / 2;
        ++id;
    }else{
        ans -= border * (border + 1) / 2;
    }
    a.push_back(-1);
    ll num = 1;
    ll now = a[id];
    //cout<<border<<endl;
    //cout<<ans<<endl;
    Rrep(i, now){
        while(a[id + 1] > i) {
            ++id;
            ++num;
        }
        ans -= min(num, K) * (i + 1);
        K -= num;
        if(K <= 0) break;
    }
    cout<<ans<<endl;
}


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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;
ll inv(int x){
    ll now = x;
    ll ret = 1;
    ll p = 1e9 + 5;
    while(p){
        if(p&1){
            ret *= now;
            ret %= mod;
        }
        now *= now;
        now %= mod;
        p >>= 1;
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    while(cin >> n){
        map<int,int>mp;
        vector<ll>v(n);
        for(auto &i:v){
            cin >> i;
        }
        for(auto i:v){
            for(int j = 2 ; j <= sqrt(i) ; j++){
                if(i%j)continue;
                int cnt = 0;
                while(i % j == 0){
                    i /= j;
                    cnt++;
                }
                mp[j] = max(mp[j], cnt);
            }
            if(i >1){
                mp[i] = max(mp[i],1);
            }
        }
        ll tot = 1;
        for(auto i:mp){
            while(i.S--){
                tot *= i.F;
                tot %= mod;
            }
        }
        //cout << tot << endl;
        ll sum = 0;
        for(auto i:v){
            sum += tot * inv(i);
            sum %= mod;
        }
        cout << sum << '\n';
    }
}

Measured memory_bytes: 768
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		int[][] c = new int[3][3];
		Scanner sc = new Scanner(System.in);
		for(i = 0; i < 3; i++) {
			for(j = 0; j < 3; j++) {
				c[i][j] = Integer.parseInt(sc.next());
			}
		}
		sc.close();
		sc = null;
		int a1, a2, a3, b1, b2, b3;
		String ans = "No";
		LABEL:for(a1 = 0; a1 <= 100; a1++) {
			for(a2 = 0; a2 <= 100; a2++) {
				for(a3 = 0; a3 <= 100; a3++) {
					b1 = c[0][0] - a1;
					b2 = c[0][1] - a1;
					b3 = c[0][2] - a1;
					if(a2+b1 == c[1][0] &&
					   a2+b2 == c[1][1] &&
					   a2+b3 == c[1][2] &&
					   a3+b1 == c[2][0] &&
					   a3+b2 == c[2][1] &&
					   a3+b3 == c[2][2]) {
						ans = "Yes";
						break LABEL;
					}
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define lf double
#define gc getchar()
#define mp make_pair
#define ri register int
#define rc register char
#define rb register bool
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)

int n,m;

il int read()
{
    rc ch=gc;ri x=0;rb y=1;
    while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
    if(ch=='-')ch=gc,y=0;
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
    return y?x:-x;
}

int main()
{
	//freopen("A.in","r",stdin);freopen("A.out","w",stdout);
	n=read();m=(n+1)>>1;printf("%.6lf",(lf)m/n);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf

#define sf1(a)			scanf("%d",&a);
#define sf2(a,b)		scanf("%d%d",&a,&b);

#define ll				long long

#define fin             freopen("input.txt","r",stdin);
#define fout            freopen("output.txt","w",stdout);

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a,b;
    cin >> n;
    vector<pair<int,int> > v;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        v.push_back(make_pair(b,a));
    }
    sort(v.begin(),v.end());
    ll int c=0;
    for(int i=0;i<n;i++){
        //cout << v[i].first << " " << v[i].second << endl;
        c+=v[i].second;
        if(c>v[i].first) goto A;
    }
    if(c<=v[v.size()-1].first) cout << "Yes" << endl;
    else A:cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 2420
#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 200001;



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

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;
    string s;
    cin >> s;
    reverse(all(s));

    ll F[2020] ={0};
    F[0] = 1;
    ll tot = 0;

    ll ans = 0;

    ll t = 1;

    trav(ch,s){
        tot += t*(ch-'0');
        tot %= 2019;
        t *= 10;
        t %= 2019;
        ans += F[tot];
        F[tot]++;
    }

    cout << ans << "\n";

    return 0;
}


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

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

const int mod = 1000000007;
const int inf = 1000000007;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;
    vector<int> ans(n);
    // cout << n << endl;
    rep(sv, n) {
        vector<int> d(n, inf);
        queue<int> q;
        d[sv] = 0;
        q.push(sv);
        while(!q.empty()) {
            int v = q.front();
            q.pop();
            int dist = d[v];
            if(v == x && d[y] == inf) {
                q.push(y);
                d[y] = dist + 1;
            }
            if(v == y && d[x] == inf) {
                q.push(x);
                d[x] = dist + 1;
            }
            if(v - 1 >= 0 && d[v - 1] == inf) {
                q.push(v - 1);
                d[v - 1] = dist + 1;
            }
            if(v + 1 < n && d[v + 1] == inf) {
                q.push(v + 1);
                d[v + 1] = dist + 1;
            }
                }
        rep(i, n) {
            ans[d[i]]++;
            //cout << d[i] << ' ';
        }
    }
    //cout << endl;
    rep(i, n) ans[i] /= 2;
    for(int i = 1; i <= n - 1; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 256
//Twitter@KonoLv1 2020年春卒で現在就職活動中！

#include <stdio.h>
int main(void){
    int i,j;            //  ループ文に使用
    int x,y,z;
    int count,count2;   //  カウント用に使用
    char s[256];        //  文字列
    int a,b,c;
    a = b = c = 0;
    
    count = 0;
    count2 = 0;
    
    //  入力処理
    
    scanf("%d %d",&x,&y);
    a = x + y;
    b = x - y;
    c = x * y;
    
    if (a >= b && a >= c){
        printf("%d",a);
    }else if (b >= a && b >= c){
        printf("%d",b);
    }else if (c >= a && c >= b){
        printf("%d",c);
    }

    //  計算処理
    

    //  出力処理

}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
class Program
{
            static void Main(string[] args)
            {
                var input = Console.ReadLine();

                Dictionary<string, int> dicDay = new Dictionary<string, int>();
                dicDay.Add("SUN", 7);
                dicDay.Add("MON", 6);
                dicDay.Add("TUE", 5);
                dicDay.Add("WED", 4);
                dicDay.Add("THU", 3);
                dicDay.Add("FRI", 2);
                dicDay.Add("SAT", 1);

                Console.WriteLine(dicDay[input].ToString());
            }
}

Measured memory_bytes: 13152