akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ld w,h,x,y; cin>>w>>h>>x>>y;
    cout<<w*h/2<<" "<<(x==w/2 && y==h/2 ? 1 : 0)<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, t int
	fmt.Scan(&n, &t)

	listC := make([]int, n)
	listT := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&listC[i], &listT[i])
	}

	num := 0
	minC := 1000
	for i := 0; i < n; i++ {
		if minC > listC[i] && listT[i] <= t {
			num = i
			minC = listC[i]
		}
	}
	if listT[num] <= t {
		fmt.Println(listC[num])
	} else {
		fmt.Println("TLE")
	}
}


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

#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	int tot = 1, ans = 0;
	while (tot < b) {
		tot = tot - 1 + a;
		++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int W, Q, wid[120], loc[120];
bool b[120];

int main() {
  while (cin>>W>>Q, W) {
    memset(b, false, sizeof b);
    memset(wid, -1, sizeof wid);
    memset(loc, -1, sizeof loc);

    rep(i,Q) {
      char c;
      cin >> c;
      if (c == 's') {
        int id, w;
        cin>>id>>w;
        rep(j,W-w+1) {
          bool ok = true;
          if(b[j]) continue;
          if(!b[j]) {
            rep(k,w) if (b[j+k]) ok = false;
          }
          if (ok) {
            rep(k,w) b[j+k] = true;
            wid[id] = w, loc[id] = j; break;
          }
        }
        if (wid[id] == -1) {
          puts("impossible");
        } else {
          //printf("--------------%d\n",loc[id]);
          printf("%d\n",loc[id]);
        }
      } else if (c == 'w'){
        int id;
        cin>>id;
        rep(j,wid[id]) b[loc[id]+j] = false;
      }
      //rep(j,W) printf("%c",b[j]?'1':'0'); puts("");
    }
    puts("END");
  }
  return 0;
}

Measured memory_bytes: 0
n,a,b=map(int,input().split(" "))
sum=0
total=0
tmp=0

for num in range(1,n+1):
  tmp=num
  while(True):
    if num == 0:
      break
    sum+=num%10
    num/=10
    num=int(num)
    
  if sum>=a and sum<=b:
    total+=tmp
    
  sum=0
  
print(total)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const int N=1e5+5;
const int mod=1e9+7;
int32_t main() {
    IOS
int n,sum=0;
    cin>>n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin>>v[i];
      v[i]-=i-1;
    }
    sort(v.begin(),v.end());
    int ans=0;
    sum=v[((n+1)/2)-1];

    for (int i = 0; i < n; ++i) {
        ans+=abs(v[i]-sum);
    }
    cout<<ans;
}

Measured memory_bytes: 1792
n = input()
d = map(int, raw_input().split())
m = input()
t = map(int, raw_input().split())

from collections import defaultdict
dic = defaultdict(int)
for di in d:
    dic[di] += 1
for ti in t:
    if dic[ti] <= 0:
        print "NO"
        exit()
    else:
        dic[ti] -= 1

print 'YES'



Measured memory_bytes: 35440
#include<iostream>
using namespace std;
const int MOD = 1000000007;


int mul(int a, int b) {
    return 1LL * a * b % MOD;
}


int modpow(int p, int n) {
    if (n == 0) return 1;
    int t = modpow(p, n / 2);
    return n % 2 == 0 ? mul(t, t) : mul(t, mul(t, p));
}


int X, Y;

void read() {
    cin >> X >> Y;
}


void work() {
    int n1 = 0, n2 = 0;
    int curX = 0, curY = 0;
    
    while (curX <= X && curY <= Y ) {
        if (X - curX == (Y - curY) * 2) {
            n2 = Y - curY;
            break;
        }
        ++n1;
        curX += 1;
        curY += 2;
    }

    if (curX > X || curY > Y) {
        cout << 0 << endl;
        return;
    }


    int N = n1 + n2;
    int K = n1;
    
    // nCk(N, K)
    int ans = 1;
    for (int i = N, j = K; i > N - K; --i, --j) {
        // ans = ans * n / k;
        ans = mul(ans, i);
        ans = mul(ans, modpow(j, MOD - 2));
    }
    cout << ans << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
ll N, K;

/*==================================================*/
/*function*/

/*==================================================*/

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

    ll sum = 0LL;
    //REP(b, K+1, N+1){
    for(ll b = K+1; b <= N; b++){
        ll tsum = 0LL;

        ll tmp = 1LL;
        if(K == 0) tmp = 0LL;

        tsum += ( N / ( max(0LL,(K-1)) +(b-K)+ /*((K-1 + 1) / 2)*/tmp ) ) * (b - K);

        ll t = N % ( max(0LL,(K-1)) +(b-K)+ /*((K-1 + 1) / 2)*/tmp );

        if(t <= max(0LL,(K-1))){

        }else if(max(0LL,(K-1)) < t && t <= max(0LL,(K-1)) +(b-K)){
            tsum += t - max(0LL,(K-1));
        }else{
            tsum += t;
        }

        sum += tsum;
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    P = map(int, input().split())

    Kcost = [min(row, N - 1 - row, clm, N - 1 - clm) for row in range(N) for clm in range(N)]

    Sitting = [1] * (N * N)
    Kcount = 0


    def Kcheck(qsn, cdsn):
        if Kcost[cdsn] > Kcost[qsn] + Sitting[qsn]:
            Kcost[cdsn] = Kcost[qsn] + Sitting[qsn]
            queue.append(cdsn)


    for sn in P:
        csn = sn - 1
        Kcount += Kcost[csn]
        Sitting[csn] = 0
        queue = [csn]

        while queue:
            qsn = queue.pop()
            div, mod = divmod(qsn, N)
            if mod: Kcheck(qsn, qsn - 1)
            if mod != N - 1: Kcheck(qsn, qsn + 1)
            if div: Kcheck(qsn, qsn - N)
            if div != N - 1: Kcheck(qsn, qsn + N)

    print(Kcount)

if __name__ == '__main__':
    main()


Measured memory_bytes: 131480
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
char s[110][110];
int dp[110][110];

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

int main() {
	int n;
	cin >> n;
	int m = n - 2;
	int ans = 0;
	if (keta(n) != keta(m)) {
		int one = n % 10;
		int target = (n - one) / 2;
		int res = 0;
		while (target > 0) {
			res+=target % 10;
			target /= 10;
		}
		ans = res * 2 + one;
	}
	else {
		while (n > 0) {
			ans += n % 10;
			n /= 10;
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

    double x, JPY_sum=0, BTC_sum=0;
    string u;

    for(int i=0; i<N; i++){
        cin >> x >> u;
        if(u[0]=='J') JPY_sum += x;
        else BTC_sum += x;
    }

    double sum = 380000.00000000 * BTC_sum;

    sum += JPY_sum;

    printf("%.7lf\n", sum);

    return 0;
}

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

vector<int> to[200000];
vector<int> ans;

void dfs(int v, int p=-1) {
    for (int u : to[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);        
    }

    ans.resize(N);
    for (int i = 0; i < Q; ++i) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x; 
    }
    dfs(0);
    for (int i = 0; i < N; ++i) cout << ans[i] << endl;
    
    return 0;
}

Measured memory_bytes: 23680
#include<iostream>

#define endl '\n'

using namespace std;

const int MAXN=2e5+3;
int height[MAXN];
long long beauty[MAXN],dp[MAXN],tree[4*MAXN];

void update(int ind, int tl, int tr, int pos, long long val){
    if(tl==tr){
        tree[ind]=val;
    }else{
        int mid=(tl+tr)/2;
        if(pos<=mid){
            update(2*ind,tl,mid,pos,val);
        }else{
            update(2*ind+1,mid+1,tr,pos,val);
        }
        tree[ind]=max(tree[2*ind],tree[2*ind+1]);
    }
}

long long get_max(int ind, int tl, int tr, int l, int r){
    if(l>r){
        return -1e18;
    }
    if(tl==l and tr==r){
        return tree[ind];
    }
    int mid=(tl+tr)/2;
    return max(get_max(2*ind,tl,mid,l,min(mid,r)),get_max(2*ind+1,mid+1,tr,max(l,mid+1),r));
}

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

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

    for(int i=0;i<n;++i){
        long long prev=get_max(1,0,n,0,height[i]);
        dp[height[i]]=prev+beauty[i];
        update(1,0,n,height[i],dp[height[i]]);
    }

    long long res=0;
    for(int i=0;i<n;++i){
        res=max(res,dp[height[i]]);
    }
    cout<<res<<endl;

return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long N, std::string S){
    int ans = 0;
    // debug(S);
    rep(i, N - 2) {
        // debug(i);
        if (S.substr(i, 3) == "ABC") ans++;
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long N;
    cin >> N;
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();        
        
        int N, M;
        {int[] a = r.ii(); N = a[0]; M = a[1];}
        
        int[][] work = new int[N+1][2];
        work[0][0] = 100001;
        for(int i = 1; i < N+1; i++)
            work[i] = r.ii();
            
        Arrays.sort(work, (x, y) -> -x[0]+y[0]);
        
        long ans = 0;
        
        PriorityQueue<Integer> heap = new PriorityQueue<>((x, y) -> -x+y);        
        int size = 0;
        
        for(int i = Math.min(M-1, N-1), j = N; i >= 0; i--){            
            while(i+work[j][0] <= M){
                heap.add(work[j][1]);
                j--;
                size++;
            }
            if(size > 0){
                ans += heap.poll(); 
                size--;
            }
        }
        
        println(ans);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 47432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll N;
vector<string> S;

int main()
{
    cin >> N;
    S = vector<string>(N);
    REP(i, N)
    {
        cin >> S[i];
    }

    map<string, ll> c;
    ll m = 0;
    REP(i, N)
    {
        ++c[S[i]];
        if (c[S[i]] > m)
        {
            m = c[S[i]];
        }
    }
    vector<string> ans;
    set<string> used;
    REP(i, N)
    {
        if (c[S[i]] == m and used.find(S[i]) == used.end())
        {
            ans.push_back(S[i]);
            used.insert(S[i]);
        }
    }
    SORT(ans);
    REP(i, ans.size())
    {
        OUT(ans[i]);
    }
}

Measured memory_bytes: 37744
import math

def main():
    N = int(input())
    ans_list = []
    temp =int(math.sqrt(N) // 1)

    for i in range((temp + 1)):
        if i == 0:
            continue
        elif (N % i) != 0:
            continue
        elif (N % i) == 0:
            ans_list.append([i, N/i])
    result =ans_list[len(ans_list) - 1][1]

    j = 1
    while True:
        result = result // 10
        if result == 0:
            return j
        j += 1

print(main())


Measured memory_bytes: 3188
k, n = input().split()
k = int(k)
n = int(n)

a = input().split()
a = list(map(lambda n:int(n), a))

max_d = 0
for i in range(0, len(a)-1):
    max_d = max(max_d, a[i+1]-a[i])

max_d = max(max_d, k-a[n-1]+a[0])
print(k-max_d)

Measured memory_bytes: 26444
#include<bits/stdc++.h>
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
#define all(x) x.begin(),x.end()
ll mob=1000000007;
using namespace std;
int main()
{ 
int h,n;
cin>>h>>n;
int a[n][2];
FOR(i,n)cin>>a[i][0]>>a[i][1];
ll dp[h+2];
FOR(i,h+2) dp[i]=1000000007;
dp[0]=0;
for(int i=0;i<h+1;i++)
{
  for(int j=0;j<n;j++)
  { if(i+a[j][0]<=h)
    dp[i+a[j][0]]=min(dp[i+a[j][0]],dp[i]+a[j][1]);
    else
    {
        dp[h+1]=min(dp[h+1],dp[i]+a[j][1]);
    }
  }
}

cout<<min(dp[h],dp[h+1]);



return 0;
}













Measured memory_bytes: 384
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N,M;
int32_t X[100000];
int32_t diff[100000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> M;
	out
		<< std::fixed << std::setprecision(9) <<
		double(N) / M << endl;
	return 0;
}
#endif


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 P = pair<int,int>;

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

  long ac=0, wa=0, tle=0, re=0;
  for (long i=0; i<n; i++) {
    string sbuff;
    cin >> sbuff;

    if (sbuff=="AC") {
        ac++;
    } else if (sbuff=="WA") {
        wa++;
    } else if (sbuff=="TLE") {
        tle++;
    } else if (sbuff=="RE") {
        re++;
    }
  }   
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  
  return 0;
}

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

signed main(){
	int n,x,ans=0;
	cin >> n >> x;
	vector<int> a(n);
	for(auto &it : a) cin >> it;
	for(int i = 0;i<n-1;i++){
		int dif = a[i]+a[i+1]-x;
		if(dif>0){
			int p = max(0ll,dif-a[i+1]);
			int q = min(dif,a[i+1]);
			a[i]-=p;
			a[i+1]-=q;
			ans+=p+q;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 1024
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int R = sc.nextInt();
		
		out.println(R * 2 * Math.PI);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private String join(String delimiter, int[] a) {
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < a.length; i++) {
			sb.append(a[i]);
			sb.append(delimiter);
		}
		return sb.substring(0, Math.max(sb.length() - delimiter.length(), 0));
	}

	@SuppressWarnings("unused")
	private String join(String delimiter, long[] a) {
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < a.length; i++) {
			sb.append(a[i]);
			sb.append(delimiter);
		}
		return sb.substring(0, Math.max(sb.length() - delimiter.length(), 0));
	}

	@SuppressWarnings("unused")
	private int max(int[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		int candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate > arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private long max(long[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		long candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate > arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private int min(int[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		int candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate < arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private long min(long[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		long candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate < arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private long[] nextLongArray(Scanner sc, int n) {
		long[] result = new long[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextLong();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int digit(ll n){
    int d = 0;
    while(n > 0){
        n /= 10;
        d++;
    }
    return d;
}

int main() {
    ll n; cin >> n;
    int ans = INT_INF;
    for(ll i = 1LL; i * i <= n; i++){
        if(n % i == 0){
            ll j = n / i;
            int d = max(digit(i), digit(j));
            ans = min(ans, d);
        }
    }
    cout << ans << endl;
}


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

int main() {
  int h,w,n;cin>>h>>w>>n;
  int an[n];rep(i,n)cin>>an[i];
  int ni = 0;
  rep(i,h){
    int sn[w];
    rep(j,w){
      an[ni]--;
      sn[j] = ni+1;
      if (an[ni] == 0) ni++;
    }
    if (i%2==1) reverse(sn,sn+w);
    cout << sn[0];
    rep(i,w-1) cout << " " << sn[i+1]; 
    cout << endl;
  }
}


Measured memory_bytes: 384
//============================================================================
// Name        : abc132_d.cpp
// Author      : abb
// Version     :
// Copyright   : [My copyright notice]
// Description : Hello World in C++, Ansi-style
//============================================================================

/*
 D - Blue and Red Balls

 実行時間制限: 2 sec / メモリ制限: 1024 MB

 配点 : 400 点

 問題文
 K 個の青いボールと N-K 個の赤いボールがあります。同じ色のボールは区別が不可能です。すぬけ君と高橋君はこれらのボールで遊んでいます。
 まず、すぬけ君が、N 個のボールを左から右に一列に並べます。
 次に、高橋君は、これらのうち K 個の青いボールのみを回収します。高橋君は、1 回の操作で連続して並ぶ青いボールを何個でも回収することができます。高橋君は、常に K 個の青いボールを回収するのにかかる操作の回数が最小になるように行動します。
 K 個の青いボールを回収するために高橋君がちょうど i 回操作をする必要があるボールの並べ方は何通りあるでしょうか。 1 ≤ i ≤ K をみたす i それぞれについて答えを計算し、 10^9+7 で割った余りを答えてください。

 制約

 ・1 ≤ K ≤ N ≤ 2000
 */
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

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

/** 法．10^9+7. */
const ll MOD = 1000000007;
/** 階乗テーブルのインデックス数．10^5 より少し大きいくらい． */
const ll TABLELEN = 101010;

/** 階乗．f[i] = i! mod MOD. */
ll f[TABLELEN];
/** 階乗の逆元．finv[i] = f[i]^(-1) = (i!)^(-1). */
ll finv[TABLELEN];
/** 整数の逆元．inv[i] = i^(-1). */
ll inv[TABLELEN];

/**
 * 階乗とその逆元のテーブルを初期化する．
 */
void init_fact_table(ll tablelen = TABLELEN) {
	f[0] = f[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rep(i, 2, tablelen)
	{
		f[i] = (f[i - 1] * i) % MOD;
		// MOD を法として， i^(-1) ≡ -(MOD % i)^(-1) * (MOD / i).
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

/**
 * 組み合わせ数を計算する．
 * @param n
 * @param k
 * @return nCk を表す整数．
 */
ll combination(int n, int k) {
	if (n < k)
		return 0;
	if (n < 0 || k < 0)
		return 0;
	// n!/(k!(n-k)!) mod MOD
	return f[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

/**
 * エントリポイント．
 * @return 0.
 */
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;

	init_fact_table(n);
	for (int i = 1; i <= k; ++i) {
		// i 回の操作が必要 => 取りたい球(合計 K 個)が i 箇所に挿入されている
		// => (n-k+1箇所のうち) i 箇所の選び方 × (k個の球の) i 箇所への分け方
		// => (n-k+1箇所のうち) i 箇所の選び方 × (k-1箇所のうちの) i-1 箇所の選び方
		cout << combination(n - k + 1, i) * combination(k - 1, i - 1)  % MOD << endl;
	}
	return 0;
}


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

using P = pair<int, int>;

class union_find {
public:
    union_find(int n, vector<int> const& a)
        : par_(n, -1),
          a_(a)
    {}
    void init(int n) {
        par_.assign(n, -1);
        a_.assign(n, -1);
    }

    int root(int x) {
        return par_[x] < 0 ? x : par_[x] = root(par_[x]);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) {
            return false;
        } else {
            if(par_[x] < par_[y]) {
                par_[x] += par_[y];
                par_[y] = x;
                a_[x] = min(a_[x], a_[y]);
            } else {
                par_[y] += par_[x];
                par_[x] = y;
                a_[y] = min(a_[y], a_[x]);
            }
            return true;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par_[root(x)];
    }

    int get(int x) {
        return a_[root(x)];
    }

private:
    std::vector<int> par_;
    vector<int> a_;
};

using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    map<string, int> idx;
    vector<int> v(N);
    for(int i=0; i<N; ++i) {
        string a;
        int x;
        cin >> a >> x;
        idx[a] = i;
        v[i] = x;
    }
    union_find uf(N, v);

    int M;
    cin >> M;
    for(int i=0; i<M; ++i) {
        string s, t;
        cin >> s >> t;
        uf.unite(idx[s], idx[t]);
    }

    int res = 0;
    for(int i=0; i<N; ++i) {
        res += uf.get(i);
    }
    cout << res << endl;
}


Measured memory_bytes: 3752
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(x: usize, y: usize)->usize{
    if y == 0{
        return x
    }
    gcd(y, x % y)
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut ans = a[0];
    for i in 1..n{
        ans = gcd(ans, a[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#include <time.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;


int main(int argc, char* argv[])
{
    int n; ll d,a;
    scanf("%d%lld%lld", &n, &d, &a);
    vector<pair<ll,ll> > z;
    int i;
    for(i=0; i<n; i++) {
        ll x,h;
        scanf("%lld%lld", &x, &h);
        z.push_back(make_pair(x,h));
    }
    sort(z.begin(),z.end());

    vector<ll> s(n);
    ll cnt=0;
    for(i=0; i<n; i++) {
        if(i>0) s[i]+=s[i-1];
        ll x=z[i].first;
        ll h=z[i].second;
        h-=cnt*a;
        h+=s[i]*a;
        if(h>0) {
            ll cnt0=(h-1+a)/a;
            int k=lower_bound(z.begin(),z.end(),make_pair(x+d*2,(ll)LINF))-z.begin();
            if(k<n) s[k]+=cnt0;
            cnt+=cnt0;
        }
    }
    printf("%lld\n", cnt);


    return 0;
}


Measured memory_bytes: 6512
#include<algorithm>
#include<cstdio>
using namespace std;
const int mod=998244353;
int K,n,sl,fh,cnt,res,ans[2010],C[4010][4010];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	K=rd();n=rd();
	for(int i=0;i<=n+K;++i) C[i][0]=C[i][i]=1;
	for(int i=1;i<=n+K;++i)
		for(int j=1;j<i;++j)
		{
			C[i][j]=C[i-1][j]+C[i-1][j-1];
			if(C[i][j]>=mod) C[i][j]-=mod;
		}
	for(int i=2;i<=K+1;++i)
	{
		res=0;cnt=i/2;
		for(int j=0,x=1;2*j<=n&&j<=cnt;++j,x=mod-x) res=(res+1ll*x*C[cnt][j]%mod*C[n-j*2+K-1][K-1])%mod;
		printf("%d\n",ans[i]=res);
	}
	for(int i=K;i>1;--i) printf("%d\n",ans[i]);
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

bool m(string s, int result) {
  vi v;
  v.pb(s[0] - '0');
  char op;
  FOR(i, 1, SZ(s)) {
    if(i%2) {
      op = s[i];
    } else {
      if(op == '*') {
        v[SZ(v)-1] *= s[i] - '0';
      } else {
        v.pb(s[i] - '0');
      }
    }
  }
  int res = 0;
  REP(i, SZ(v)) {
    res += v[i];
  }

  return res == result;
}

bool l(string s, int result) {
  char op;
  int res = s[0] - '0';
  FOR(i, 1, SZ(s)) {
    if(i % 2) {
      op = s[i];
    } else {
      if(op == '+') {
        res += s[i] - '0';
      } else {
        res *= s[i] - '0';
      }
    }
  }
  return res == result;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  string s; cin >> s;
  int result; cin >> result;

  bool M = m(s, result);
  bool L = l(s, result);
  if(M && L) {
    cout << "U" << endl;
  } else if(M) {
    cout << "M" << endl;
  } else if(L) {
    cout << "L" << endl;
  } else {
    cout << "I" << endl;
  }
}




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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  vector<bool> v(101, false);
  v[a] = 1;
  v[b] = 1;
  v[c] = 1;
  
  cout << accumulate(v.begin(), v.end(), 0) << endl;
}

Measured memory_bytes: 3548
#include<stdio.h>  
 int main()    
{    
	int n,sum=0,p,m;    
	scanf("%d",&n);  
	p=n;  
	while(n>0)    
		{    
		m=n%10;    
		sum=sum+m;    
		n=n/10;    
		}    
	if(p%sum!=0) printf("No\n");
	else printf("Yes\n");
	
	return 0;  
} 

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> a = {1,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,36,216,49,343,100,1000,121,144,169,196,225,256,289,324,361,400,441,484,529,576,676,784,841,900,961,1200};
  sort(a.begin(),a.end());
  int n;
  cin >> n;
  for(int i = 0;i<a.size();i++){
    if(a[i]>n){
      cout << a[i-1] << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;
    cin >> k;
    cout << arr[k-1] << endl;
}

Measured memory_bytes: 768
// Elementary data structures - Stack
// hhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A
using System;
using System.Linq;
using System.Collections.Generic;
 
namespace ALDS1_3_A {
    class Program {
        public Program() {}
         
        public static void Main() {
            new Program().Calc();
        }
         
        void Calc() {
            var input = Input.Split(' ');
            var stack = new Stack<int>();
            int a, b;
            foreach (var str in input) {
                switch (str) {
                    case "+":
                        a = stack.Pop();
                        b = stack.Pop();
                        stack.Push(a + b);
                        break;
                    case "-":
                        a = stack.Pop();
                        b = stack.Pop();
                        stack.Push(b - a);
                        break;
                    case "*":
                        a = stack.Pop();
                        b = stack.Pop();
                        stack.Push(a * b);
                        break;
                    case "/":
                        a = stack.Pop();
                        b = stack.Pop();
                        stack.Push(b / a);
                        break;
                    default:
                        stack.Push(int.Parse(str));
                        break;
                }
            }
            Output(stack.Pop().ToString());
        }
         
        String Input {
            get {
                return Console.ReadLine();
            }
        }
         
        void Output(String str) {
            Console.WriteLine(str);
        }
    }
}

Measured memory_bytes: 10148
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
mod = 10 ** 9 + 7

dp = [0] * (1 << n)
dp[0] = 1

for i in range(1, 1 << n):
    k = bin(i).count("1")
    for j in range(n):
        if i >> j & 1 and a[k - 1][j]:
            dp[i] += dp[i ^ (1 << j)]
    dp[i] %= mod
print(dp[(1 << n)-1])


Measured memory_bytes: 59372
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (100000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long N, A, B, xs[MAX_N];
  scanf("%ld %ld %ld", &N, &A, &B);
  for (int i = 0; i < N; i++) {
    scanf("%ld", &xs[i]);
  }

  // solve
  long ans = 0;
  for (long i = 1; i < N; i++) {
    const long cost_walk = A * (xs[i] - xs[i - 1]);
    const long cost_teleport = B;
    ans += min(cost_walk, cost_teleport);
  }
  printf("%ld\n", ans);

  return 0;
}


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

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

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

  int n = s.size();
  if(s.at(n-1)=='s') cout << s << "es";
  else cout << s << 's';
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")
using P = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
using ll = long long;
const int dx4[4] = {1,0,-1,0};
const int dy4[4] = {0,1,0,-1};
const int dx8[8] = {-1,0,1,1,1,0,-1,-1};
const int dy8[8] = {1,1,1,0,-1,-1,-1,0};

ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}

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

  double l;
  cin >> l;
  double h = l/3;
  double ans = h*h*h;
  printf("%.10f", ans);
}

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

const ll DENOMI = 1000000007;

int main()
{
	int n, m;
	cin >> n >> m;
	auto s = vector<int>(n);
	auto t = vector<int>(m);
	for(auto&& ss : s) cin >> ss;
	for(auto&& tt : t) cin >> tt;
	auto dp = vector<vector<ll>>(n + 1, vector<ll>(m + 1));
	for(auto i = 1; i <= n; ++i){
		for(auto j = 1; j <= m; ++j){
			dp[i][j] = dp[i][j - 1];
			if(s[i - 1] == t[j - 1]){
				dp[i][j] = (dp[i][j] + dp[i - 1][j - 1] + 1) % DENOMI;
			}
			dp[i][j - 1] = (dp[i][j - 1] + dp[i - 1][j - 1]) % DENOMI;
		}
	}
	ll ans = 1;
	for(auto i = 1; i <= n; ++i){
		ans = (ans + dp[i][m]) % DENOMI;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A%2==0 || B%2==0 || C%2==0)puts("0");
  else cout<<min({A*B,B*C,C*A})<<endl;
}

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

using namespace std;

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

const int INF = 1e9 + 7;

int main()
{
	IO_OP;
	
	int a, b;
	cin >> a >> b;
	cout << max(a+b, max(a-b, a*b)) << endl;	
	
}



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

using namespace std;

int main() {

    string S, T;
    cin >> S >> T;

    int number = T.length();

    if(S + T[number - 1] == T) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int w,h,n;
    cin>>w>>h>>n;
    int minx=0,maxx=w,miny=0,maxy=h;
    for(int i=0;i<n;i++)
    {
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1)
        {
            minx=max(minx,x);
        }
        if(a==2)
        {
            maxx=min(maxx,x);
        }
        if(a==3)
        {
            miny=max(miny,y);
        }
        if(a==4)
        {
            maxy=min(maxy,y);
        }
    }
    int x=(maxx-minx);
    int y=(maxy-miny);
    int area=x*y;
    if(x<0 || y<0)
    {
        area=0;
    }
    cout<<area;
  	return 0;
}







Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string s;
    cin>>s;
    
    bool ok = true;
    
    for(ll i = 0; i < s.size(); i++){
        if(i%2 == 1 && s[i] == 'R')ok = false;
        if(i%2 == 0 && s[i] == 'L')ok = false;
    }
    if(ok)puts("Yes");
    else puts("No");
       
    return 0;
}



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


int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++) cin >> a[i]; 
    string judge = "APPROVED";
    for(int i=0; i<n; i++){
        if ((a[i]%2 == 0)&&(!(a[i]%3==0||a[i]%5==0))) judge = "DENIED";
    }
    cout << judge << endl;
}

Measured memory_bytes: 256
k = int(input())

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

Sum = 0

# 一種類の数字が出てくるパターン
for i in range(k):
    Sum += gcd(i+1, i+1, i+1)

# 二種類の数字が出てくる場合 -> 各パターンは3通りあるはず
for i in range(k-1):
    for j in range(i+1, k):
        Sum += gcd(i+1, j+1, j+1)*3

# 二種類の数字が出てくる場合 
for i in range(k-1):
    for j in range(i+1, k):
        Sum += gcd(i+1, i+1, j+1)*3
        
# 三種類の数字が出てくる場合
for i in range(k-2):
    for j in range(i+1, k-1):
        for m in range(j+1, k):
            Sum += gcd(i+1, j+1, m+1)*6
            
print(Sum)

Measured memory_bytes: 9640
import scala.io.StdIn
object Main extends App {
  val N = StdIn.readLine().toInt
  val list = for {
    a <- 1 to N - 1
    b = N - a
  } yield a.toString.toList.map(_.asDigit).sum + b.toString.toList.map(_.asDigit).sum
  println(list.min)
}


Measured memory_bytes: 64020
#include <bits/stdc++.h>
using namespace std;
template<class T> void read (T & x) {
  int c = getchar(), f = 1; x = 0;
  while(!isdigit(c)) {if (c == '-') f = -f; c = getchar();}
  while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
  x *= f;
}
typedef long long LL;
const int MAXN = 200005;
LL pre[MAXN], a[MAXN]; 
LL ans;
int n;
map<LL, int> m;
int main(void) {
  read(n);m[0] = 1;
  for(int i = 1; i <= n; ++i) {
    read(a[i]), pre[i] = pre[i-1] + a[i];
    ans += m[pre[i]];
    ++m[pre[i]];
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

const int INF = 1e9;

int main(){

    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int j = 0; j < N; j++){
        cin >> B[j];
    }

    int ans = INF;
    int com = pow(2, N);
    for(int i = 0; i < com; i++){
        int sum = 0;
        vector<pair<int, int>> even;
        vector<pair<int, int>> odd;
        for(int j = 0; j < N; j++){
            if(i & (1 << j)){
                if(j % 2 == 0){
                    odd.push_back(make_pair(B[j], j));
                }
                else{
                    even.push_back(make_pair(B[j], j));
                }
                sum++;
            }
            else{
                if(j % 2 == 0){
                    even.push_back(make_pair(A[j], j));
                }
                else{
                    odd.push_back(make_pair(A[j], j));
                }
            }
        }

        if(sum % 2 == 1){
            continue;
        }

        if((int)even.size() != ceil(N / 2.0) || (int)odd.size() != N / 2){
            continue;
        }

        sort(even.begin(), even.end());
        sort(odd.begin(), odd.end());

        vector<pair<int, int>> v(N);
        for(int j = 0; j < ceil(N / 2.0); j++){
            v[2 * j] = even[j];
        }
        for(int j = 0; j < N / 2; j++){
            v[2 * j + 1] = odd[j];
        }

        bool isOk = true;
        for(int j = 1; j < N; j++){
            if(v[j - 1].first > v[j].first){
                isOk = false;
                break;
            }
        }

        if(!isOk){
            continue;
        }

        int cnt = 0;
        for(int j = 0; j < N; j++){
            for(int k = j + 1; k < N; k++){
                if(v[j].second > v[k].second){
                    cnt++;
                }
            }
        }

        ans = min(ans, cnt);
    }

    if(ans == INF){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 384
// mai iss duniyaa ka sbse bada chutiyaaa huu

#include<bits/stdc++.h> 
#include <chrono> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl '\n'
#define p_b push_back
#define m_p make_pair
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
using namespace std::chrono; 

template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less_equal<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;

char alphabet[26] = {'a','b','c','d','e','f','g','h','i',
       'j','k','l','m','n','o','p','q','r','s','t','u','v',
       'w','x','y','z'};

// rectangle intersection
// x5 = max(x1, x3);
// y5 = max(y1, y3);
// x6 = min(x2, x4);
// y6 = min(y2, y4); 

const int mx = 500005;

// char get_next(char c) {
// 	for(int i=0; i<25; i++) if(c == alphabet[i]) return alphabet[i+1];
// 	return 'a';
// }

// struct no {
// 	int l, r, id;
// }q[mx];

// int bl[mx];
// int col[mx];
// int mp[mx];

// void get_blocks(int n) {
// 	int sqroot = sqrt(n)+1;
// 	for(int i=0; i<=n; i++) bl[i] = i/sqroot;
// }
// bool mo_sort(no a, no b) {
// 	return bl[a.l] == bl[b.l] ? a.r < b.r : bl[a.l] < bl[b.l];
// }
// int diff = 0;
// void add(int id) {
// 	if(!mp[col[id]]) diff++;
// 	mp[col[id]]++;
// }
// void rem(int id) {
// 	mp[col[id]]--;
// 	if(mp[col[id]] == 0) diff--;
// }
int32_t main() {
 	fastIO;
	int tc;
	// cin >> tc;
	tc = 1;
	while(tc --) {
		int n, k;
		cin >> n >> k;
		int a[n];
		for(int i=0; i<n; i++) cin >> a[i];
		int l = 1, r = 1e9+5;
		while(l < r) {
			int md = (l + r) / 2;
			int tot = 0;
			for(int i=0; i<n; i++) {
				if(a[i] % md == 0) tot += a[i] / md;
				else tot += a[i] / md + 1;
				tot--;
 			}
			if(tot <= k) r = md;
			else l = md+1;
		}
		cout << l << endl;
  	}     
}



Measured memory_bytes: 5192
#include<bits/stdc++.h>
#define rep(j,n) for(int i=j;i<n;i++)
#define pb push_back
#define MX_N 100001
#define INF 10000000;
#define f first
#define s second
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long unsigned int llui;
typedef long long int ll;

int main(){
	int n;
	cin >> n;
	if(n<1200)cout << "ABC";
	else if(n<2800)cout << "ARC";
	else cout << "AGC";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256