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

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

  set<string> se;
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < s.size()-i+1; j++) {
      string str = s.substr(j,i);
      se.insert(str);
    }
  }

  auto itr = se.begin();
  for (int i = 1; i < k; i++) itr++;
  cout << *itr << endl;
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;

    vector<int> b_f(n, 0);
    vector<int> b_b(n, 0);

    int k_t = 0;
    rep(i, n){
        if (s[i] == 'o'){
            k_t++;
            b_f[i] = k_t;
            i+=c;
        } 
        if (k_t >= k || i >= n){
            break;
        }
    }
    k_t = k;
    for (int i = n-1; i >= 0; i--)
    {
        if (s[i] == 'o'){
            b_b[i] = k_t;
            i-=c;
            k_t--;
        }
        if (k_t <= 0 || i < 0){
            break;
        }
    }
    
    // show(b_f);
    // show(b_b);

    rep(i, n){
        if (b_f[i] == b_b[i] && b_f[i] != 0){
            cout << i+1 << endl;
        }
    }
    
}



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

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++){
    string x;
    cin >> x;
    if (x == "Y"){
      cout << "Four";
      break;
    }
    if (i == (N-1)){
      cout << "Three";
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
char matrix[1001][1001];

int solve(char matrix[][1001], int n, int m)
{
	int dp[n + 1][m + 1];
	dp[n][m] =  1;
	for(int i = n; i >= 1; i--){
		for(int j = m; j >= 1; j--){
			if(i == n and j == m)continue;
			if(matrix[i][j] == '#')
				dp[i][j] = 0;
			else {
				dp[i][j]=(((i==n)?0:dp[i+1][j])+((j==m)?0:dp[i][j+1]))%mod;
			}
		}
	}
	return dp[1][1];
}
int main()
{
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++)
			cin >> matrix[i][j];
	}
	cout << solve(matrix, n, m);
	return 0;
}

Measured memory_bytes: 8420
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		
		int output = A*B - A - B + 1;
		
		System.out.println(output);
		
		

	}

}


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

using namespace std;

vector<pair<int, int>> g[100100];
vector<int> col(100100);
vector<bool> vis(100100);
int cnt = 0;

void paint(int s){
    queue<int> q;
    int c = 0;
    set<int> used;
    
    if(vis[s]) return;
    vis[s] = true;
    for(auto v : g[s]){
        if(col[v.second] != -1) used.insert(col[v.second]);
    }
    for(auto v : g[s]){
        if(!vis[v.first]) q.push(v.first);
        if(col[v.second] == -1){
            while(used.find(c) != used.end()) c++;
            col[v.second] = c;
            used.insert(c);
            c++;
        }
    }

    while(!q.empty()){
        int cur = q.front();
        q.pop();
        paint(cur);
    }
    
    return;
}

int main(){
    int n;
    cin >> n;
    col.assign(n, -1);
    vis.assign(n, false);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
    }
    paint(0);
    set<int> t;
    for(int i = 0; i < n - 1; i++) t.insert(col[i]);
    cout << t.size() << '\n';
    for(int i = 0; i < n - 1; i++) cout << col[i] + 1 << '\n';
}

Measured memory_bytes: 60544
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1e9+7
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)
#define inf 1e9+5

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int n;
	cin >> n;
	vi h(n);
	rep(i, 0, n - 1) cin >> h[i];
	vi dp(n, inf);
	dp[0] = 0;
	rep(i, 0, n - 1) {
		for (int j : {i + 1, i + 2}) {
			if (j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	cout << dp[n - 1];
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();


	return 0;
}

Measured memory_bytes: 4720
import numpy as np
import itertools
H,W,K=map(int,input().split())
arr=np.array([list(input()) for _ in range(H)])
ans=0
for h in range(1,H+1):
    for w in range(1,W+1):
        hl=list(itertools.combinations(list(range(H)), h))
        wl=list(itertools.combinations(list(range(W)), w))
        
        for hl_ in hl:
            for wl_ in wl:
                if sum(np.ravel(arr[np.ix_(hl_,wl_)])=='#') == K:
                    ans+=1
print(ans)


Measured memory_bytes: 26884
#include<stdio.h>

int main(void) {
  int N,L[11];
  int max = -1, sum = 0;

  scanf("%d", &N);
  for(int i=0;i<N;i++) {
    scanf("%d", &L[i]);
    sum += L[i];
    max = (max < L[i]) ? L[i] : max;
  }

  int other = sum - max;
  if(other > max) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n,da,dq;
char st[10000];
int main()
{
cin>>n;
for(int i=1; i<=n; i++)
{
    cin>>st[i];
    if(st[i]=='I')dq++;
    else dq--;
    if(dq>da)da=dq;
}
cout<<da<<endl;
return 0;
}

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

const int MOD = 1000000007;
int dp[13][100000 + 1];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin >> s;
    
    dp[0][0] = 1;
    int mult = 1;
    for (int i = 1; i <= s.size(); ++i)
    {
        if (s[s.size() - i] == '?')
        {
            for (int k = 0; k != 10; ++k)
            {
                int val = 1LL * mult * k % 13;
                for (int j = 0; j != 13; ++j)
                    dp[j][i] = (dp[j][i] + dp[(j - val + 13) % 13][i - 1]) % MOD;
            }
        }
        else
        {
            int val = 1LL * mult * (s[s.size() - i] - '0') % 13;
            for (int j = 0; j != 13; ++j)
                dp[j][i] = dp[(j - val + 13) % 13][i - 1];
        }
        
        mult = 10LL * mult % 13;
    }
    
    cout << dp[5][s.size()] << '\n';
    
    return 0;
}

Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    int i = 0;
    bool ok = true;
    int n = s.size();
    reverse(whole(s));
    while (i<n) {
        //debug(i);
        string u = s.substr(i, 7);
        if (u=="remaerd") {
            i += 7;
            continue;
        }
        string x = s.substr(i, 6);
        if (x=="resare") {
            i += 6;
            continue;
        }
        string y = s.substr(i, 5);
        if (y=="maerd" || y=="esare") {
            i += 5;
            continue;
        }
        break;
    }
    
    if (i==n) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3744
from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    inf=10**10
    n=int(readline())
    h=np.array(list(map(int,readline().split())),dtype=np.int64)

    dp=np.full(n,inf,dtype=np.int64)
    dp[0]=0
    for i in range(n):
        nex_end=i+2+1
        dp[i+1:nex_end]=np.minimum(dp[i+1:nex_end],dp[i]+np.abs(h[i]-h[i+1:nex_end]))

    print(dp[-1])

if __name__=="__main__":
    main()

Measured memory_bytes: 22796
//this code is created by Neel11
//YEET!
#include<bits/stdc++.h>

using namespace std;

#define testcases ll t;cin>>t;while(t--)
#define queries ll q;cin>>q;while(q--)
#define ll long long 
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<endl;
#define mod 1000000007





int main(){
	long n;
	cin>>n;

	string s;
	cin>>s;

	loop(i,0,s.size()){

		char x = s[i];
		long y = x;

		y = y-64;

		y = (y+n)%26;

		if(y==0)
			y+=26;

		y +=64;

		x = char(y);
		cout<<x;      
	}
  cout<<endl;
  
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<pii> p(m);
    rep(i,m){
        int l,r;
        cin >> l >> r;
        p[i].first = l;
        p[i].second = r;
    }
    int a_min = 0,a_max = 2e9;
    rep(i,m){
        a_min = max(a_min,p[i].first);
        a_max = min(a_max,p[i].second);
    }
    int ans = a_max - a_min;
    if(ans >= 0)cout << ans + 1 << endl;
    else cout << 0 << endl;
}

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

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

using namespace std;
using lint=long long;

int main(){
	int n; scanf("%d",&n);
	vector<lint> x(n),a(n);
	rep(i,n) scanf("%lld%lld",&x[i],&a[i]);

	lint ans=0,mx=a[n-1];
	for(int i=n-1;i>=0;i--){
		ans=max(ans,mx);
		if(i>0) mx=max(mx+a[i-1]-(x[i]-x[i-1]),a[i-1]);
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3328
import sys


# ## COMBINATION (MOD) ## #
MOD = 10**9 + 7  # , N = 2*10**5 で 0.3s
N_MAX = 10**5  # 問題サイズに合わせて変えておく

fac = [1, 1]  # 元テーブル
facinv = [1, 1]  # 逆元テーブル
inv = [0, 1]  # 逆元テーブル計算用テーブル


for i in range(2, N_MAX + 1):
    fac.append((fac[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    facinv.append((facinv[-1] * inv[-1]) % MOD)


def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    # r = min(r, n-r)
    return fac[n] * facinv[r] * facinv[n - r] % MOD


def main():
    S = int(sys.stdin.readline().rstrip())

    # 数列の最大長さ
    ln_max = S // 3

    ans = 0
    for ln in range(1, ln_max + 1):

        # 長さが ln のときの数列組み合わせ
        d = S - ln * 3

        ans += cmb(d + (ln - 1), ln - 1)  # 残りを数列の各要素に振り分ける
        ans %= MOD

    print(ans)


main()


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

using namespace std;

int main() {
	long long N, M;
	cin >> N >> M;
	vector <long long> id(N + 2, 0);
	for (long long i = 0; i < M; ++i) {
		long long l, r;
		cin >> l >> r;
		++id[l];
		--id[r + 1];
	}


	long long count = 0;
	if (id[0] == M)++count;
	for (long long i = 1; i < id.size(); ++i) {
		id[i] = id[i] + id[i - 1];
		if (id[i] == M)++count;
	}
	cout << count << endl;
	return 0;
}

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



int main(void){
    
    int a,b;
    cin >> a >> b;
    
    //string A = to_string(a);
    //string B = to_string(b);
    //cout << A.size();
    
    int i,count=0;
    
    //cout<<Alen;
    
    for(int j=a;j<=b;++j){
        
        string A = to_string(j);
        int Alen = A.size();
        int countStr=0;
        
        for(i=0;i<Alen;++i){
            if(A[i]==A[Alen-i-1])countStr++;
        }
        
        if(countStr==Alen)count++;
        
    }
    
    cout<<count;
    
    return 0;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;

pair<long long, long long> f(const vector<string> &S, vector<vector<bool>> &check, int h, int w){
    pair<long long, long long> ret = make_pair(0, 0);
    (S[h][w] == '.' ? ret.second : ret.first)++;
    check[h][w] = true;
    int dh[4] = {1, -1, 0, 0};
    int dw[4] = {0, 0, 1, -1};
    for(int i = 0; i < 4; i++){
        int hh = h + dh[i];
        int ww = w + dw[i];
        if(0 <= hh && hh < S.size() && 0 <= ww && ww < S[0].length() && !check[hh][ww]){
            if(S[h][w] != S[hh][ww]){
                auto p = f(S, check, hh, ww);
                ret.first += p.first;
                ret.second += p.second;
            }
        }
    }
    return ret;
}

int main(void){
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i = 0; i < H; i++) cin >> S[i];
    vector<vector<bool>> check(H, vector<bool>(W, false));
    long long ans = 0;
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            if(!check[h][w]){
                // cout << h << " " << w << endl;
                auto p = f(S, check, h, w);
                // cout << h << " " << w << " " << p.first << " " << p.second << endl;
                ans += p.first * p.second;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23040
#include<bits/stdc++.h>
using namespace std;
#define	ll				long long
#define int             long long

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";
long long prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i <= floor(sqrt(n)); i++)
        if (n % i == 0)
            return false;

    return true;
}

int factorial(int n)
{
    int f=1;
    for(int i = 1;i<=n ; i++)
        f = (f*i)%mod;
    return f;
}

int gcd(int a, int b)
{
	return !b ? a : gcd(b, a % b);
}

int lcm(int a, int b)
{
	return (a / gcd(a, b)) * b;
}

int fastExponentiation(int n, int x, int modulo)
{
	int res = 1;
	while(x > 0)
       {
          if(x & 1)
          res = (res*n) % modulo;
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res;
}

int power(int n , int p )
{
	if(p==0)
	   return 1;

	 int res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;

	   	 return res;
}

bool isPowerOfTwo(int n)
{
   	return n && (!(n&(n-1)));
}

bool isSet(int n,int i)
{
	// To check if ith bit is set or not in binary representation of n
   	return n & (1 << i);
}

bool valid_coordinate(ll x,ll y,ll n,ll m)
{
    if(x<0 || y<0)
       return false;

   	else if(x>=n || y>=m)
       return false;

   	else
   		return true;
}

int sod(int n)
{
	int sum=0;
	while(n)
	{
		sum+=(n%10);
		n/=10;
	}
	return sum;
}



void solve()
{
	ll n;
	cin>>n;
	cout<<n*n<<endl;
}

int32_t main()
{

	//int t; cin>>t; while(t--)
	solve();

	return 0;
}


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

string S = "";
string T = "";

bool solve() {
  bool ans = false;
  S = S + S;
  int len = S.length();
  for (int i = 0; i < len; i++) {
    int flag = 0;
    if (S[i] == T[0]) {
      flag++;
      for (int j = i + 1; j < len; j++) {
        if (S[j] == T[j - i]) flag++;
      }
    }
    if (flag == T.length()) {
      ans = true;
      break;
    }
  }
  return ans;
}

int main() {
  cin >> S >> T;
  if (solve()) {
    puts("Yes");
  }
  else puts("No");
  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,ma=0,mb=0,x;
	vll a(100005,0),b(100005,0);
	cin >> n;
	rep(i,n){
		cin >> x;
		if(i%2){
			a[x]++;
			if(a[ma]<a[x]) ma=x;
		}
		else{
			b[x]++;
			if(b[mb]<b[x]) mb=x;
		}
	}
	sort(rall(a));
	sort(rall(b));
	if(ma!=mb) cout << n-a[0]-b[0] << endl;
	else cout << min(n-a[0]-b[1],n-a[1]-b[0]) << endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = NextInt();
            var list = IntList();
            var now = list[0];
            var count = 1;
            for (int i = 1; i < N; i++) {
                if(now <= list[i]) {
                    now = list[i];
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }

    class MyMath {
        public const long mod = 1000000007;

        public static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static List<long> Factor(long n) {
            var list = new List<long>();
            n = DivideToLimit(n, 2, list);
            n = DivideToLimit(n, 3, list);
            long sqrt = Sqrt(n);
            for (int i = 5; i <= n && i <= sqrt; i += 4) {
                n = DivideToLimit(n, i, list);
                i += 2;
                n = DivideToLimit(n, i, list);
            }
            if (n > 1) list.Add(n);
            return list;
        }

        public static long Sqrt(long n) {
            if (n < 0) return 0;
            long a = 0, tmp = 0, b = 0;
            for (int i = 62; i >= 0; i -= 2) {
                tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
                a = a << 1 | tmp;
                n -= (((b << 1) + 1) * tmp) << i;
                b = (b << 1) + tmp + tmp;
            }
            return a;
        }

        static long DivideToLimit(long divisor, long dividend, List<long> list) {
            while (divisor % dividend == 0) {
                list.Add(dividend);
                divisor /= dividend;
            }
            return divisor;
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13396
#include<stdio.h>
#include<string.h>
int main(){
    char a[100],b[100],c[100];
    scanf("%s%s%s",a,b,c);
    int len1 = strlen(a),len2 = strlen(b);
    if(a[len1-1]==b[0] && b[len2-1]==c[0])printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 128
import java.io.*;

class Main {
	public static void main(String args[]) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			int n, money = 100000;
			n = Integer.parseInt(reader.readLine());
			for(int i = 0;i < n;i++) {
				money = money + (money/20);
				int x = money%10, y = money%100/10, z = money%1000/100;
				if(x != 0 || y != 0 || z != 0)
					money+=(1000-(x+y*10+z*100));
			}
			System.out.println(money);
		}
		catch(IOException e) {
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 16864
n, a, b = map(int, input().split())

nsum = 0
ans = 0

for i in range(n):
    tmp = i + 1
    nsum = 0
    while True:
        nsum += tmp  % 10
        tmp = tmp // 10
        if tmp == 0:
            break

    if a <= nsum and nsum <= b:
        ans += (i + 1)


print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    ll cnt = 0, ans = 0;
    
    rep(i, s.length()) {
        if (s[i] == 'W') {
            ans += i - cnt;
            cnt++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

int main(){

    int n,number,menor=1000000001,maior=0;

    scanf("%d",&n);

    for(int i=0;i<n;i++){
        scanf("%d",&number);
        if(number<=menor){
            menor=number;
        }
        if(number>=maior){
            maior=number;
        }
    }
    printf("%d\n",maior-menor);

    return 0;
}


Measured memory_bytes: 128
import heapq
N,M=map(int, input().split())
inl=list(map(int, input().split()))

modi = []
for i in range(M):
    b,c = map(int, input().split())
    modi.append((c,b))

modi.sort(reverse=True)
heapq.heapify(inl)

# print(modi)
for c, b in modi:
    for _ in range(b):
        v = heapq.heappop(inl)
        if v >= c:
            heapq.heappush(inl, v)
            break
        heapq.heappush(inl, c)

print(sum(inl))


Measured memory_bytes: 20984
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let x: usize = sc.cin();
    let y: usize = sc.cin();
    for a in 0..200 {
        for b in 0..200 {
            if a + b == x && 2 * a + 4 * b == y {
                put!("Yes");
                return;
            }
        }
    }
    put!("No");
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 2132
from collections import namedtuple

Store = namedtuple('Store', 'a, b')

N, M = map(int, input().split())

stores = []
for i in range(N):
    a, b = map(int, input().split())
    stores.append(Store(a, b))

stores.sort(key=lambda s: s.a)

m = 0
cost = 0
for store in stores:
    for i in range(store.b):
        m += 1
        cost += store.a
        if m >= M:
            print(cost)
            exit(0)


Measured memory_bytes: 19284
#include <stdio.h>
#include <stdlib.h>
#define min(a,b) (a<b?a:b)

int main(){
  int i,n,k,h[100010];
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }

  int j,x,cost[100010]={0,abs(h[0]-h[1])};

  for(i=2;i<n;i++){
      x=cost[i-1]+abs(h[i]-h[i-1]);
      for(j=1;j<min(k,i);j++){
        x=min(x,cost[i-1-j]+abs(h[i]-h[i-1-j]));
      }
      cost[i]=x;

  }

  printf("%d",cost[n-1]);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
ll N,K;
int main(){
	cin>>N>>K;
	ll ans=0;
	FOR(b,K+1,N+1){
		ans+=(b-K)*(N/b)+max(N%b-K+1,0ll);
		if (K==0){
			ans--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define sp ' '
using namespace std;

int N, a[100], s, res, A;

int main(){
	cin >> N;
	for (int i = 0; i != N; ++i) {
		cin >> a[i];
		s += a[i];
	}
	res = -1;
	A = 0xe869120;
	for (int i = 0; i != N; ++i) {
		if (abs(A - s) > abs(a[i] * N - s)) {
			A = a[i] * N;
			res = i;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    ll ans = t[0];
    for(int i = 1; i < n; i++){
        ll g = __gcd(ans, t[i]);
        ans = (ans / g) * (t[i] / g) * g;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
// C++ 14
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int int
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (*(x.end()-1))

using namespace std;

#define MAX_N 20

Int A, B;

void input() {
  cin >> A >> B;
}

void solve() {
  if (A <= 9 && B <= 9) cout << A * B << endl;
  else cout << -1 << endl;
}

int main() {
  input();
  solve();
}

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

using i64 = int64_t;

constexpr i64 MAX_N = 300002;

vector<i64> divisor(i64 n) {
    vector<i64> res;
    for (i64 i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i)
                res.push_back(n / i);
        }
    }
    return res;
}

i64 prime[MAX_N];
bool is_prime[MAX_N + 1];

i64 sieve(i64 n) {
    i64 p = 0;
    for (i64 i = 0; i <= n; i++)
        is_prime[i] = true;
    is_prime[0] = false;
    is_prime[1] = false;
    for (i64 i = 2; i <= n; i++) {
        if (i%7 != 1 && i%7 != 6)continue;
        if (is_prime[i]) {
            prime[p++] = i;
            for (i64 j = 2 * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
    return p;
}

int main(){
    int n;
    sieve(MAX_N);
    while(cin >> n, n != 1){
        auto d = divisor(n);
        sort(d.begin(), d.end());
        vector<i64> v;
        for(auto e: d){
            if((e%7 == 1 || e%7 == 6) && is_prime[e])v.push_back(e);
        }
        cout << n << ":";
        for(auto e: v){
            cout << " " << e;
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3588
import java.util.*;
public class Main { 
    public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       String o="";
       int n=sc.nextInt();
       int m=sc.nextInt();
      if(n==m)o="Yes";
      else o="No";
      System.out.println(o);
    }
}

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

using namespace std;

int main(){
	int n, x, y, b, p, total, temp;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d%d%d%d", &x, &y, &b, &p);
		if (b >= 5 && p >= 2){
			total = x*b*0.8+y*p*0.8;
			printf("%d\n", total);
		}else {
			total = x*b+y*p;
			if (b >= 5 && p < 2){
				temp = x*b*0.8+y*2*0.8;
				if (temp < total)
					total = temp;
			}
			if (b < 5 && p >= 2){
				temp = x*5*0.8+y*p*0.8;
				if (temp < total)
					total = temp;
			}
			if (b < 5 && p < 2){
				temp = x*5*0.8+y*2*0.8;
				if (temp < total)
					total = temp;
			}
			printf("%d\n", total);
		}
		
	}
return 0;
}

Measured memory_bytes: 1188
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

a, b = gets.chomp.split.map &:to_i
if    (a >= 13)
  puts b
elsif (a >= 6)
  puts b/2
else
  puts 0
end


Measured memory_bytes: 1788
from sys import exit
A = []
for i in range(3):
    A.append(list(map(int,input().split())))

N = int(input())
B = []
for i in range(N):
  B.append(int(input()))

for i in range(3):
  for j in range(3):
    if j == 2 and A[i][j] in B:
      print("Yes")
      exit()
    if A[i][j] in B: pass
    else: break  
for i in range(3):
  for j in range(3):
    if j == 2 and A[j][i] in B:
      print("Yes")
      exit()
    if A[j][i] in B: pass
    else: break  
for i in range(3):
    if i == 2 and A[i][i] in B:
      print("Yes")
      exit()
    if A[i][i] in B: pass
    else: break  
for i in range(3):
    if i == 2 and A[i][2-i] in B:
      print("Yes")
      exit()
    if A[i][2-i] in B: pass
    else: break  
print("No")      


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int main() {
  int N, M;
  cin >> N >> M;
  const int INFTY = 100001;
  
  int distance[N][N];  // 頂点間の距離
  int spath[N][N];  // 最短経路の距離
  priority_queue<P, vector<P>, greater<P>> check[N]; // pair(距離, 頂点番号)
  
  /* 初期化 */
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      distance[i][j] = INFTY;
      spath[i][j] = INFTY;
    }
  }
  for (int i=0; i<M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;  // 頂点番号を0スタート
    b--;
    distance[a][b] = distance[b][a] = c;
  }
  for (int i=0; i<N; i++) {
    spath[i][i] = 0;
    check[i].push(P(0, i));
  }
  
  /* dijkstra */
  for (int i=0; i<N; i++) {
    while (!check[i].empty()) {
      int length = check[i].top().first;
      int vertex = check[i].top().second;
      check[i].pop();
      for (int j=0; j<N; j++) {
        if (distance[vertex][j] == INFTY) continue;  // 辺が存在しない
        if (length + distance[vertex][j] < spath[i][j]) {  //最短経路の発見
          spath[i][j] = length + distance[vertex][j];  // 最短経路の更新
          check[i].push(P(spath[i][j], j));  // 探索候補に追加
        }
      }
    }
  }
  
  /* 解の導出 */
  int ans = 0;
  for (int i=0; i<N; i++) {
    for (int j=0; j<i; j++) {  // 自己ループと重複を除外
      if (distance[i][j] == INFTY) continue;  // 辺が存在しない
      if (spath[i][j] < distance[i][j]) ans++;  // 辺が最短経路でない
    }
  }
  
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)

#define mod 1000000007
typedef long long ll;


ll pomod(ll a,ll b){
    if(b==1) return a;
    if(b%2) return pomod(a*a%mod,b/2)*a%mod;
    else return pomod(a*a%mod,b/2)%mod;
}

int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> cnt(k+1,0);
    for(ll i=k;i>0;i--){
        ll tmp = pomod(k/i,n);
        for(ll j=i*2;j<=k;j+=i){
            tmp=(tmp+mod-cnt[j])%mod;
        }
        cnt[i]=tmp;
    }
    ll ans=0;
    rept(i,1,k+1){
        ans+=cnt[i]*i;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3972
#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 ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
//#define mod 1e18
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii map<int,int>
#define mll map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i = 0;i<n;i++){
		cin>>arr[i];
	}
	
	sort(arr,arr+n);
	//reverse(arr,arr+n);
	
	int ans = 0;
	for(int i = 0;i<k;i++){
		ans = ans+arr[i];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3656
IS=float('inf')

n,t=map(int,raw_input().split())
a=map(int,raw_input().split())
ans=0
chk=1
x=IS
y=0
for i in a:
    if x>i:
        x=i
    elif y<i:
        y=i
    if i-x>chk:
        ans=1
    elif i-x==chk:
        ans+=1
    chk=max(chk,i-x)
print ans


Measured memory_bytes: 11304
#include <bits/stdc++.h>
    using namespace std;
     
	int main(){
      int A,B,C,D;
      cin>>A>>B>>C>>D;
      int L=A+B, R=C+D;
      if(L<R)cout<<"Right"<<endl;
      if(L==R)cout<<"Balanced"<<endl;
      if(L>R)cout<<"Left"<<endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ld l; cin>>l;
    cout<<setprecision(12)<<l*l*l/27;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
i = list(map(int, input().split()))

sumsum = sum(i) 
border = sumsum/4/m

count = 0
for num in i:
    if num >= border:
        count += 1

if count >= m:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 2940
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	ll n, sum = 0, Max=0;
	cin >> n;
	rep(i,n){
		ll c;
		cin >> c;
		sum+=c;
		Max = max(Max, c);
	}
	if((sum-Max) > Max) puts("Yes");
	else puts("No");
 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <vector>
#define LL long long
#define rg register
using namespace std;
const LL MAXN=1000000LL;
LL N,p,tot,ans=1LL;
LL jl[MAXN],num[MAXN];

template<typename T>inline void in(T &a){
	T ch=getchar(),p=1;
	for(a=0;!isdigit(ch);ch=getchar()) if(ch=='-') p=-1;
	for(;isdigit(ch);ch=getchar()) a=a*10+ch-'0';
	a*=p;
}

template<typename T>inline void print(T x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) print(x/10);
	putchar(x%10+'0');
}

inline LL calc(LL a,LL b){
	LL ans=1LL,base=a;
	while(b){
		if(b%2) ans*=base;
		base*=base;
		b/=2LL; 
	}
	return ans;
}

signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	in(N),in(p);

	if(N==1LL){
		print(p),puts("");
		return 0;
	}

	for(rg LL i=2LL;i<=sqrt(p);i++){
		if((p%i)!=0) continue;
		jl[++tot]=i;
		while((p%i)==0) num[i]++,p/=i;
		if(p==1LL) break;
	}
	
	for(rg int i=1;i<=tot;i++){
		if(num[jl[i]]>=N)
			ans*=calc(jl[i],num[jl[i]]/N);
	}
	
	print(ans),puts("");
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}
/*
1 111

3 24

1000000000000 1000000000000
*/

Measured memory_bytes: 2304
#include <cstdio>
int main(){
 int v[101];
 int n,i;
 scanf("%d",&n);
 for(i=0;i<n;i++) scanf("%d",&(v[i]));
 for(i=n-1;i>=1;i--) printf("%d ",v[i]);
 printf("%d\n",v[0]);
 return 0;
};

Measured memory_bytes: 1024
#include <iostream>
#include <array>
#include <vector>
#include <stack>
#include <queue>

const int nmax = 100005;
int n;
const int NIL = -1;

std::vector<int> adjlist[nmax];
std::array<int, nmax> group;

std::stack<int> stk;
std::array<int, nmax> state;

void init()
{
  group.fill(NIL);
  state.fill(0);
}

int next(int v)
{
  for (int i=0; i<adjlist[v].size(); ++i)
    {
      auto v_next = adjlist[v][i];
      if (state[v_next] == 0)
        return v_next;
    }
  return NIL;
}

void dfs_1v(int u, int group_id)
{
  stk.push(u);
  state[u] = 1;
  group[u] = group_id;

  while (!stk.empty())
    {
      auto v = stk.top();
      auto v_next = next(v);

      if (v_next != NIL)
        {
          stk.push(v_next);
          state[v_next] = 1;
          group[v_next] = group_id;
        }
      else
        {
          state[v] = 2;
          stk.pop();
        }
    }
}

void grouping()
{
  init();

  auto group_id = 0;
  for (int i=0; i<n; ++i)
    {
      if (state[i] == 0)
        {
          dfs_1v(i, group_id);
          group_id++;
        }
    }
}

int main ()
{
  int m;
  std::cin >> n >> m;

  for (int i=0; i<m; ++i)
    {
      int s, t;
      std::cin >> s >> t;

      adjlist[s].push_back(t);
      adjlist[t].push_back(s);
    }

  grouping();

  int q;
  std::cin >> q;
  for (int i=0; i<q; ++i)
    {
      int s, t;
      std::cin >> s >> t;
      if (group[s] == group[t] && group[s] != NIL)
        std::cout << "yes\n";
      else
        std::cout << "no\n";
    }
}



Measured memory_bytes: 9564
r, g, b = map(int, input().split())
k = int(input())

def dfs(i , r, g, b):
    if i > k: return False
    if r < g < b: return True
    if dfs(i+1, r*2, g,   b  ): return True
    if dfs(i+1, r,   g*2, b  ): return True
    if dfs(i+1, r,   g,   b*2): return True
    return False

print('Yes' if dfs(0, r, g, b) else 'No')


Measured memory_bytes: 9120
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

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

int main() {
    int a;
    cin >> a;
    cout << a + a*a+a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    long long zmi=2e9,zma=-2e9,wmi=2e9,wma=-2e9;
    cin>>n;
    while(n--){
	    long long x,y;
	    cin>>x>>y;
	    zmi=min(zmi,x+y);
	    zma=max(zma,x+y);
	    wmi=min(wmi,x-y);
	    wma=max(wma,x-y);
    }
    cout<<max(zma-zmi,wma-wmi)<<"\n";
}
 

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>

#define NAME_LENGTH 10

typedef struct {
	char name[NAME_LENGTH+1];
	int remain_time;
} Process;

typedef struct {
	void **list;
	int size;
	int count;
	int head;
	int tail;
} Que;

Que* que_create(int size){
	Que *que;

	que = malloc(sizeof(Que));
	que->list = malloc(sizeof(void*)*size);
	que->size = size;
	que->count = 0;
	que->head = -1;
	que->tail = -1;

	return que;
}

void que_delete(Que *que){
	free(que->list);
	free(que);
}

int que_add_tail(Que *que, void *p){
	int ok = 0;

	if( que->count < que->size ){
		ok = 1;
		que->tail = (que->tail + 1 ) % que->size;
		que->list[que->tail] = p;
		que->count++;
		if( que->count == 1 ){
			que->head = que->tail;
		}
	}

	return ok;
}

void* que_take_head(Que *que){
	void *p = NULL;

	if( que->count > 0 ){
		p = que->list[que->head];
		que->head = (que->head + 1 ) % que->size;
		que->count--;
	}

	return p;
}

int main(int argc, char** argv){
	// Input Pamameter Variable
	Process *list;
	int n,q;
	// Work Variable
	Que *que;
	Process *p;
	int i,curr_time;

	// Input & Create Process List/Que
	scanf("%d%d",&n,&q);
	list = malloc(sizeof(Process) * n);
	que = que_create(n);
	for(i=0;i<n;i++){
		scanf("%10s%d",list[i].name,&list[i].remain_time);
		que_add_tail(que,list+i);
	}

	// Check & Output
	curr_time = 0;
	for(;;){
		// Get Next Process
		p = (Process*)que_take_head(que);
		if( p == NULL ){
			// All Process Finish
			break;
		}
		// Remain Time Check
		if( p->remain_time <= q ){
			// Time Forward
			curr_time += p->remain_time;
			// Process Finish
			p->remain_time = 0;
			// Output
			printf("%s %d\n",p->name,curr_time);
		} else {
			// Time Forward
			curr_time += q;
			// Process Not Finish -> Back To Que Tail
			p->remain_time -= q;
			que_add_tail(que,p);
		}
	}

	// Delete Process List/Que
	free(list);
	que_delete(que);

	return 0;
}

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

using namespace std;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    // freopen("data.in","r",stdin);

    int n; cin >> n;
    string s; cin >> s;

    int val  = 0;
    int ans = 0;

    for(auto &e : s) {
        if(e == 'I')val++;
        else if(e == 'D')val--;
        ans = max(ans,val);
    }

    cout << ans << '\n';

    return 0;
}


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

void solve(long long A, long long B, long long K)
{
    long long m = min(A, K);
    A -= m;
    K -= m;

    m = min(B, K);
    B -= m;
    K -= m;

    cout << A << " " << B << 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 A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long K;
    scanf("%lld", &K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,i,j,x; long int sum=0;
    scanf("%d",&n);
    int arr[n];
    for (i=0;i<n;i++) scanf("%d",&arr[i]);
    for (i=0;i<n;i++) sum=sum+arr[i];
    for (i=0;i<n;i++)
    {
        for (j=i+1;j<n;j++)
        {
            if (arr[i]>arr[j])
            {
                x=arr[i]; arr[i]=arr[j]; arr[j]=x;
            }
        }
    }
printf("%d %d %ld\n",arr[0],arr[n-1],sum);

}



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

int main(){
  int N, M, P, t, s, x;
  while (cin >> N >> M >> P, N||M||P){
    t = 0;
    s = 0;
    for (int i = 0; i < N; ++i){
      cin >> t;
      s += t;
      if (i == M-1) x = t;
    }
    if (x) cout << s*(100-P)/x << endl;
    else cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 2992
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());

        int total = 0;
        int resa=-1;
        int resb=-1;
        int resc=-1;
        for(int a=0;a<=n;a++){
            for(int b=0;b+a<=n;b++){
                int c = n-(a+b);
                total = a*10000 + b*5000 + c*1000;
                if(total==y){
                    resa=a;
                    resb=b;
                    resc=c;
                }
            }
        }
        System.out.println(String.format("%d %d %d", resa, resb, resc));
    }
}

Measured memory_bytes: 22996