akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define SWAP(type,a,b) { type temp = a; a = b; b = temp; }
#define N 100

int main(){
  int i, j, cont=0, n;
  int a[N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(a[j] < a[j-1]){
	SWAP(int,a[j],a[j-1]);
      cont++;
      }
    }
  }


  for(i=0;i<n;i++){
    if (i!=0) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n%d\n",cont);
  return 0;
}
  



Measured memory_bytes: 2124
program main;
var n, u, t, h : integer;
begin
  readln(n);

  // get digits
  u := n mod 10;
  t := (n div 10) mod 10;
  h := n div 100;

  if (u = 7) or (t = 7) or (h = 7) then
    writeln('Yes')
  else
    writeln('No');
end.

Measured memory_bytes: 1368
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int32_t H, W, K;
  cin >> H >> W >> K;
  vector<string> choco(H);
  for (auto& row : choco) {
    cin >> row;
  }
  vector<vector<int>> accum(W,vector<int>(H+1,0));
  for (int w = 0; w < W; w++) {
    int cnt = 0;
    for (int i = 0; i < H; i++) {
      if (choco[i][w] == '1') cnt++;
      accum[w][i+1] = cnt;
    }
  }
  int32_t res = H + W;
  for (int32_t hmap = 0; hmap < (1 << (H-1)); hmap++) {
    using frag_type = pair<pair<int, int>, int>;
    int32_t s = 0;
    int32_t cnt = 0;
    int32_t cur = hmap;
    vector<frag_type> wq;
    int32_t shift = 0;
    while (cur) {
      if ((cur & 1) == 1) {
        int32_t e = shift;
        wq.emplace_back(make_pair(make_pair(s, e), 0));
        cnt++;
        s = e+1;
      }
      cur = cur >> 1;
      shift++;
    }
    wq.emplace_back(make_pair(make_pair(s, H-1), 0));

    int wl = 0;
    while (wl < W) {
      bool retry = false;
      for (int wr = wl; wr < W; wr++) {
        for (auto& frag : wq) {
          frag.second += accum[wr][frag.first.second + 1] - accum[wr][frag.first.first];
          if (frag.second > K) {
            if (wl == wr) {
              cnt = H + W;
              goto NEXT;
            }
           cnt++;
           retry = true;
           break;
          }
        }
        if (retry == true) {
          for (auto& frag : wq) {
            frag.second = 0;
          }
          wl = wr;
          break;
        }
      }
      if (retry == false) {
        break;
      }
    }
    NEXT: 
    res = min(res, cnt);
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    char X,Y;
    cin >>X>>Y;
    if(X==Y){
        cout<<"="<<endl;
    }else if(X<Y){
        cout<<"<"<<endl;
    }else{
        cout<<">"<<endl;
    }



    return 0;
    

}

Measured memory_bytes: 3564
#include<stdio.h>

void gyoretu(int *a, int *b, int n){
    a[0] = b[0];
    int i;

    for(i = 1; b[i]; i++){
        if(b[i - 1] < b[i]){
            a[i] = b[i - 1];
        }
        else{
            a[i] = b[i];
        }
    }
    a[n - 1] = b[n - 2];
}

int suma(int *a, int n){
    int tmp = 0;
    int i;

    for(i = 0; i < n; i++){
        tmp += a[i];
    }

    return tmp;
}

int main(void){
    int n;
    int a[100] = {0};
    int b[100] = {0};
    int i;

    scanf("%d", &n);
    for(i = 0; i < n - 1; i++){
        scanf("%d", &b[i]);
    }

    gyoretu(a, b, n);

    printf("%d", suma(a, n));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = pow(10,9) + 7;
 
string S;
int dp[100005][13];
 
ll solve(int pos, int rem) {
    if(pos == S.size()) return rem == 5;
    if(dp[pos][rem] != -1) return dp[pos][rem];
    ll ans(0);
    if(S[pos] == '?') {
        for(int i(0); i < 10; ++i) {
            ans += solve(pos + 1, (rem * 10 + i) % 13) % mod;
        }
    }
    else ans += solve(pos + 1, (rem * 10 + S[pos] - '0') % 13) % mod;
    return dp[pos][rem] = ans % mod;
}
 
int main() {
	memset(dp, -1, sizeof dp);
    cin >> S;
    cout << solve(0, 0) << endl;
}


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

namespace abc107_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(input[0]);
            int b = Convert.ToInt32(input[1]);

            int c = a - b + 1;

            Console.WriteLine(c);
            Console.Read();
        }
    }
}


Measured memory_bytes: 27396
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,l;
vector<string> str;
vector<int> G[1001];
int aim[1001];
bool used[1001];


bool check(int a,int b){
	for(int i=0;i<l;i++){
		if(str[a][i]!=str[b][l-1-i])return false;
	}
	return true;
}

bool checkme(int a){
	for(int i=0;i<l/2;i++){
		if(str[a][i]!=str[a][l-1-i])return false;
	}
	return true;
}

int main(void){
	scanf("%d%d",&n,&l);
	for(int i=0;i<n;i++){
		string si;
		cin >> si;
		str.push_back(si);
	}
	sort(str.begin(),str.end());
	for(int i=0;i<n;i++){
		if(checkme(i))aim[i]=1;
		for(int j=i+1;j<n;j++){
			if(check(i,j)){
				G[i].push_back(j);
			}
		}
	}
	vector<string> resf;
	vector<string> rest;
	string resm="";
	for(int i=0;i<n;i++){
		if(used[i])continue;
		for(int j=0;j<G[i].size();j++){
			if(!used[G[i][j]]){
				used[i]=true;
				used[G[i][j]]=true;
				resf.push_back(str[i]);
				rest.push_back(str[G[i][j]]);
				break;
			}
		}
		if(!used[i] && aim[i]==1 && resm.size()==0){
			used[i]=true;
			resm+=str[i];
		}
	}
	string res="";
	for(int i=0;i<resf.size();i++){
		res+=resf[i];
	}
	res+=resm;
	for(int i=0;i<rest.size();i++){
		res+=rest[rest.size()-i-1];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3516
#include <stdio.h>
#include <string.h>

int main()
{
	int iInputN;
	char achHanakoCard[100], achTaroCard[100];
	int iCnt;
	int iPointHanako = 0, iPointTaro = 0;
	int iCmpResult;


	scanf("%d", &iInputN);
	for (iCnt = 0; iCnt < iInputN; iCnt++)
	{
		scanf("%s %s", achTaroCard, achHanakoCard);

		// 文字列比較
		iCmpResult = strcmp(achTaroCard, achHanakoCard);
		if (iCmpResult > 0)
		{
			iPointTaro += 3;
		}
		else if (iCmpResult < 0)
		{
			iPointHanako += 3;
		}
		else
		{
			iPointTaro++;
			iPointHanako++;
		}
	}

	printf("%d %d\n", iPointTaro, iPointHanako);

	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  bool findSet(int x,int y){
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,m;
    cin >> n >> m;
    UnionFind uni(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        uni.unite(a,b);
    }
    int ans = 0;
    rep(i,n){
        chmax(ans,uni.size(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3984
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b,c,d;cin>>a>>b>>c>>d;
    cout << max(a*b,c*d) << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int  N; cin >> N;
		if (!N)break;
		int amax = -1;
		int id = 0;
		for (int i = 0; i < N; ++i) {
			int p, d1, d2; cin >> p >> d1 >> d2;
			if (amax < d1 + d2) {

				id = p;
				amax = d1 + d2;
			}

		}
		cout << id<< " "<<amax<< endl;
	}
	
	return 0;
}

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

int main(){
  int n,x;
  string s="YES";
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  for(int i=1;i<n;i++) if(a[i]==a[i+1]||a[i]==a[i-1]){ s="NO"; break;}
  cout << s <<endl;
}

Measured memory_bytes: 1024
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int temp;
    vector<pair<int, vector<int>>> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i].fi;
        for (int j = 0; j < m; j++) {
            cin >> temp;
            b[i].se.pb(temp);
        }
    }

    int msk = (1<<n);
    ll ans = LLONG_MAX;
    for (int i = 0; i < msk; i++) {
        vector<int> u(m);
        ll cost = 0;
        for (int j = 0; j < n; j++) {
            if ((i&(1<<j))) {
                cost += b[j].fi;
                for (int k = 0; k < m; k++) {
                    u[k] += b[j].se[k];
                }
            }
        }
        bool poss = true;
        for (auto y : u) {
            if (y < x) {
                poss = false;
                break;
            }
        }
        if (poss)
            ans = min(ans, cost);
    }

    cout << ((ans == LLONG_MAX) ? -1 : ans ) << "\n";
}



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

int main()
{
    int A, B, T;
    cin >> A >> B >> T;

    int ans = 0;
    for(int i = A; i < T + 0.5; i += A)
    {
        ans += B;  
    }

    cout << ans << endl;
}

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

int main(void){
    string s;
    cin>>s;
    int n=s.size();
    vector<int>cnt(2);
    rep(i, n){
        cnt[s[i]-'0']++;
    }
    int ans=*min_element(cnt.begin(), cnt.end())*2;
    cout<<ans<<endl;

}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  string s;
  cin>>s;
  if(c<d){
    bool f=false; //最後石?
    for(int i=a-1;i<d;i++){
      if(s[i]=='#'){
        if(!f) f=true;
        else{
          cout<<"No"<<endl;
          return 0;
        }
      }
      else f=false;
    }
    cout<<"Yes"<<endl;
    return 0;
  }
  else{
    bool f=false; //最後石?
    for(int i=a-1;i<c;i++){
      if(s[i]=='#'){
        if(!f) f=true;
        else{
          cout<<"No"<<endl;
          return 0;
        }
      }
      else f=false;
    }
    int cn=0;
    bool f2=false;
    for(int i=b-2;i<d+1;i++){
      if(s[i]=='.'){
        cn++;
        if(cn>=3) f2=true;
      }
      else cn=0;
    }
    cout<<(f2?"Yes":"No")<<endl;
  }
}


Measured memory_bytes: 640
def main():
  import sys
  import itertools
  input = sys.stdin.readline
  n=int(input())
  p=int(''.join(input().split()))
  q=int(''.join(input().split()))
  p,q=max(p,q),min(p,q)
  a,b,l=0,0,[str(i) for i in range(1,n+1)]
  for i in itertools.permutations(l):
    i=int(''.join(i))
    if q<i and i<=p:
      a+=1
    if p<i:
      break
  print(a)  
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
/**
 * C - Special Trains
 * https://atcoder.jp/contests/abc084/tasks/abc084_c
 **/
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> c(n), s(n), f(n);
    for(int i=0; i<n-1; i++) cin >> c[i] >> s[i] >> f[i];
    for(int i=0; i<n-1; i++) {
        int tk = 0; // 駅 i に到着した時刻
        // O(500)
        for(int j=i; j<n-1; j++) {
            // O(500)
            if(j==i) {
                tk = s[j] + c[j];
                continue;
            }
            int m = ceil(max((double)tk-s[j], (double)0)/(double)f[j]);
            tk = s[j] + m*f[j] + c[j];
        }
        cout << tk << endl;
    }
    cout << 0 << endl;
    return 0;
}

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

using namespace std;

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

	sort(A.begin(), A.end());
	auto check = [&](Int mid) -> bool {
		Int sum = 0;
		for (int i = 0; i < N; ++i) {
			sum += (A[i] + mid - 1) / mid - 1;
		}
		return sum <= K;
	};
	Int low = 0, high = A.back();
	while (high - low > 1) {
		Int mid = (high + low) / 2;
		(check(mid) ? high : low) = mid;
	}
	cout << high << endl;

	return 0;
}


Measured memory_bytes: 4752
N,S=*$<
t=1
"RGB".chars{t*=S.count _1}
N.to_i.times{|i|0.upto(i/2){a,b,c=S[i],S[i-_1],S[i-_1*2]
a!=b&&b!=c&&c!=a&&t-=1}}
p t

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

typedef struct data
{
	long n;
	long c;
} d;

int main()
{
	long k;
	d s[3];
	int num = 1;
	rep(i, 3)
	{
		cin >> s[i].n;
		s[i].c = num--;
	}
	cin >> k;
	long sum = 0;
	rep(i, 3)
	{
		if (s[i].n < k)
		{
			sum += s[i].n * s[i].c;
			k -= s[i].n;
		}
		else if (s[i].n >= k)
		{
			sum += s[i].c * k;
			k = 0;
		}
		if (k == 0)
			break ;
	}
	cout << sum << endl;
	return (0);
}


Measured memory_bytes: 3632
def solve():
    N = int(input())
    H = list(map(int, input().split()))
    ret = 0
    flag = True
    
    while flag:
        flag = False
        continuous = False
        num_countinuous = 0
        # print(H)
        for i in range(N):
            if H[i] > 0:
                H[i] -= 1
                flag = True
                if not continuous:
                    num_countinuous += 1
                    continuous = True
            else:
                continuous = False
                
        ret += num_countinuous
        
    print(ret)
    
solve()

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int K, T;
int A[100];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> K >> T;
  rep(i, T) cin >> A[i];
  int mx = *max_element(A, A+T);
  int A = mx, B = K - mx;
  if (B >= A-1) {
    cout << 0 << "\n";
  }
  else {
    cout << A-1-B << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce, lru_cache
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())


def is_ok(arg):
    return h[arg][0] <= h[i][0] + d*2

def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

n, d, a = MAP()
h = [LIST() + [0] for i in range(n)]
h = sorted(h, key=itemgetter(0))
attack = 0

ans = 0
for i in range(n):
    bomb = ceil( (h[i][1] - attack) / a )
    if bomb > 0:
        j = min(meguru_bisect(n, i), n-1)
        h[j][2] -= bomb
        attack += bomb*a
        ans += bomb
    attack += h[i][2]*a

print(ans)

Measured memory_bytes: 49744
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <map>
#include <algorithm>
#include <functional>
#include <queue>

int main()
{
	double A = 0, B = 0, ans = 0;
	double C1 = 0, C2 = 0, C3 = 0, C4 = 0;
	std::cin >> A >> B;

	C1 = ceil(A / 0.08);
	C2 = ceil(B / 0.1);

	C3 = floor((A + 1) / 0.08);
	C4 = floor((B + 1) / 0.1);

	if ((C1 <= C2) && (C2 < C3))
	{
		ans = C2;
	}
	else if ((C2 <= C1) && (C1 < C4))
	{
		ans = C1;
	}
	else{
		ans = -1;
	}
	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll f[100010];

void calc(){
    f[0] = 1;
    rep(i, 1, 100010) {
        f[i] = f[i - 1] * i;
        f[i] %= mod;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    calc();
    ll ans = 1;

    int num = 0;
    
    rep(i, N){
        if(i == 0){
            num++;
            continue;
        }
        if(A[i - 1] >= num * 2 - 1){
            num++;
        }
        else{
            ans *= num;
            ans %= mod;
            
        }
//        cout << i <<  "," << A[i] << "," << num << ":" << ans << endl;
    }
    ans *= f[num];
    ans %= mod;
    
    output(ans);
    
    
    return 0;
}

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

using namespace std;

typedef long long ll;

ll MOD = 1000000007;
const ll INF = 1LL<<60;

int main(int, char**) {
	int h, n;
	cin >> h >> n;
	vector<int> A, B;
	for (int i=0; i<n; ++i) {
		int a, b;
		cin >> a >> b;
		A.push_back(a);
		B.push_back(b);
	}
	vector<ll> dp(h + 1, INF);
	dp[0] = 0;

	for (int i=0; i<dp.size(); i++) {
		for(int j=0; j<n; j++) {
			int next_index = min(i + A[j], h);
			dp[next_index] = min(dp[next_index], dp[i] + B[j]);
		}
	}
	cout <<  dp[h] << endl;


	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
#define PI 3.1415926535
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}
char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}
int GetDigit(int num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}
ll enum_divisors(ll N) {
    ll res = 0;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res++;
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res++;
        }
    }
    // 小さい順に並び替える
    return res;
}
//input



//processing



//dpTable
//int dp[100050];
int main(){
    int X;
    cin >> X;
    cout << (X >= 30 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
typedef long long ll;
typedef double ld;
typedef unsigned long long ull;

using namespace std;

const int MX = 307;

ld f[MX + 5][MX + 5][MX + 5];

int main() {
    cin.sync_with_stdio(0), cin.tie(0);
    cout.sync_with_stdio(0), cout.tie(0);
    
    //freopen("demo.in", "r", stdin);
	//freopen("demo.out", "w", stdout);
	
    int n;
    cin >> n;
    int c1 = 0, c2 = 0, c3 = 0;
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        if (x == 1) c1++;
        else if (x == 2) c2++;
        else c3++;
    }

	/*
	f(i,j,k) 表示1个寿司的盘子有i个，2个寿司盘子有j个，3个寿司的盘子有k个的期望值 
	那么转移有四种情况：
	轮到有1个寿司的盘子：f(i-1, j, k) * (i / (i + j + k)) 
	轮到有2个寿司的盘子：f(i+1, j-1, k) * (j / (i + j + k)) 
	轮到有3个寿司的盘子：f(i, j+1, k-1) * (k / (i + j + k)) 
	轮到空盘子：n / (i + j + k)
	*/
    for (int k = 0; k < MX; k++) {
        for (int j = 0; j + k < MX; j++) {
            for (int i = 0; i + j + k < MX; i++) {
                if (i + j + k == 0) continue;
                if (i + j + k > MX) continue;
                ld wait = 1.0 * n / (i + j + k);
                ld pi = 1.0 * i / (i + j + k);
                ld pj = 1.0 * j / (i + j + k);
                ld pk = 1.0 * k / (i + j + k);

                if (i) {
                    f[i][j][k] += pi * f[i - 1][j][k];
                }
                if (j) {
                    f[i][j][k] += pj * f[i + 1][j - 1][k];
                }
                if (k) {
                    f[i][j][k] += pk * f[i][j + 1][k - 1];
                }
                f[i][j][k] += wait;
            }
        }
    }

    cout.precision(11);
    cout << fixed << f[c1][c2][c3] << "\n";
    return 0;
}

Measured memory_bytes: 233728
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;

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

  vector<int> p(n), q(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> q[i];
  }

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    a[i] = i + 1;
  }

  map<vector<int>, int> mp;
  do {
    mp[a] = mp.size();
  } while (next_permutation(a.begin(), a.end()));

  int ans = abs(mp[p] - mp[q]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
long long int md=1e9+7;
int dx[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
101,103,107,109,113,127,131,137,139,149,
151,157,163,167,173,179,181,191,193,197,199,
211,223,227,229,233,239,241,
251,257,263,269,271,277,281,283,293,
307,311,313,317,331,337,347,349,
353,359,367,373,379,383,389,397,
401,409,419,421,431,433,439,443,449,
457,461,463,467,479,487,491,499,
503,509,521,523,541,547,
557,563,569,571,577,587,593,599,
601,607,613,617,619,631,641,643,647,
653,659,661,673,677,683,691,
701,709,719,727,733,739,743,
751,757,761,769,773,787,797,
809,811,821,823,827,829,839,
853,857,859,863,877,881,883,887,
907,911,919,929,937,941,947,
953,967,971,977,983,991,997
};
int y[168];
void fun(int x){
    for(int k=0;k<168&&dx[k]<=x;k++){
        while(x%dx[k]==0){
            y[k]++;
            x/=dx[k];
        }
    }
}
int main(){
    int n;
    long long int ans;
    while(cin>>n){
        ans=1;
        memset(y,0,sizeof(y));
        for(int i=1;i<=n;i++){
            fun(i);
        }
        for(int i=0;i<168;i++){
            if(y[i]!=0){
                ans=ans*(y[i]+1)%md;
            }
        }
        cout<<ans<<endl;
    }
return 0;
}


Measured memory_bytes: 384
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();

    let n: i64 = s.trim().parse().unwrap();
    let mut kouho: Vec<i64> = Vec::new();

    for i in 1..10_000_000 {
        if n%i==0 {
            if n==i {
                kouho.push(n/i+i-1);
            } else {
                kouho.push(n/i+i-2);
            }
        }
    }

    if kouho.is_empty() {
        println!("{}", n-1);
        return;
    }

    kouho.sort();
    println!("{}", kouho[0]);
}

Measured memory_bytes: 4352
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s = chomp(readline())
    q = parseInt(readline())
    front=Vector{String}()
    back=Vector{String}()
    muki=true
    for i in 1:q
        query=split(readline())
        if query[1]=="1"
            muki=!muki
        else
            if (query[2]=="1" && muki) || (query[2]=="2" && !muki)
                push!(front,query[3])
            else
                push!(back,query[3])
            end
        end
    end
    ans=join([reverse(join(front)),s,join(back)])
    if muki
        println(ans)
    else
        println(reverse(ans))
    end
end
main()

Measured memory_bytes: 158196
from itertools import accumulate


def main():
    n = int(input())
    acc = tuple(accumulate(range(1, 42)))  # 10^12 < 2^39

    def count_add(c):
        for accum_index, x in enumerate(acc):
            if c < x:
                return accum_index

    f = 2
    count = 0
    ans = 0
    while n % f == 0:
        n //= f
        count += 1
    ans += count_add(count)

    f = 3
    count = 0
    while 1:
        if n % f == 0:
            n //= f
            count += 1
            continue

        ans += count_add(count)
        f += 2
        count = 0
        if f * f > n:
            break
    if n != 1:
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9104
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a; string s;
    cin>>a>>s;
    if(a >= 3200) {
    	cout<<s;
    } else {
    	cout<<"red";
    }

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	int arry[100];
	int rearr[100];
	while (1) {
		for (int i = 0; i < n; i++) {
			cin >> arry[n - i - 1];
		}

		for (int j = 0; j < n; j++) {
			cout << arry[j];
			if(j != n-1)cout << " " ; 
		}
		cout << endl;
        break;
	}
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
 
ifstream fin("input.in");
long long n,q,a[100001],sum = 0;
long long freq[100001];


int main() {
  cin >> n;
  for(int i = 0; i < 100001; i++){
    freq[i] = 0;
  }
  for(int i = 0; i < n; i++){
    cin >> a[i];
    freq[a[i]]++;
    sum += a[i];
  }
  cin >> q;
  for(int i = 0; i < q; i++){
    long long b,c;
    cin >> b >> c;
    sum += freq[b]*(c-b);
    cout << sum << endl;
    freq[c] += freq[b];
    freq[b] = 0;
  }
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e18;


signed main(){
  int d,e;
  while(cin>>d>>e){
    if(d==0&&e==0)break;
    double ans=1.0*INF;
    rep(i,d+1){
      int tmp=i*i+(d-i)*(d-i);
      double t=abs(pow(tmp,0.5)-e);
      ans=min(ans,t);
    }
    printf("%f\n",ans);
  }

  return 0;
}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
#define maxs 2020202
#define mkp make_pair
#define inf LONG_LONG_MAX
#define ll long long
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
vector< pair<ll,ll> >ed[maxs];
ll dis[maxs],n,m;
bool vis[maxs];
 
void Bellman_Ford(){
    fill(dis,dis+1+n,LONG_LONG_MAX);
    mme(vis,0);
    dis[1]=0;
    int sz;
    ll v,w;
 
    for(int k=1;k<n;k++){//无环
        for(int i=1;i<=n;i++){
           sz = ed[i].size();
           for(int j=0;j<sz;j++){
 
                v=ed[i][j].first,w = ed[i][j].second;
                if(dis[i]==LONG_LONG_MAX)
                    continue;
                if(dis[v]>dis[i]+w)
                    dis[v]=dis[i]+w;
           }
        }
    }
 
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            sz = ed[i].size();
            for(int j=0;j<sz;j++){
                v=ed[i][j].first,w=ed[i][j].second;
                if(dis[i]==inf) continue;
 
                if(dis[v]>dis[i]+w){
                    vis[v]=1;
                    dis[v]=dis[i]+w;
                }
                if(vis[i]){
                    vis[v]=1;
                }
            }
        }
    }
 
    if(vis[n])
    puts("inf");
    else
        printf("%lld\n",-dis[n]);
}
 
int main()
{
    while(~scanf("%lld%lld",&n,&m))
    {
        ll u,v,w;
        for(int i=0;i<=n;i++) ed[i].clear();
 
        for(int i=1;i<=m;i++){
            scanf("%lld%lld%lld",&u,&v,&w);
            ed[u].push_back(mkp(v,-w));
        }
        Bellman_Ford();
    }
    return 0;
}

Measured memory_bytes: 51452
#include <iostream>
#include <string>
#include <sstream>

bool solve(
    int* const a,
    const int n,
    const int i,
    const int m)
{
    if (m < 0) {
        return false;
    }
    if (m == 0) {
        return true;
    }
    if (i == n) {
        return false;
    }

    return solve(a, n, i + 1, m)
        || solve(a, n, i + 1, m - a[i]);
}

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

    int n;
    std::cin >> n;
    std::cin.ignore();

    int a[20];
    {
        std::string buf;
        std::getline(std::cin, buf);
        std::stringstream stream;
        stream << buf;
        for (int i = 0; std::getline(stream, buf, ' '); ++i) {
            a[i] = std::stoi(buf);
        }
    }

    int q;
    std::cin >> q;
    std::cin.ignore();

    int m[200];
    {
        std::string buf;
        std::getline(std::cin, buf);
        std::stringstream stream;
        stream << buf;
        for (int i = 0; std::getline(stream, buf, ' '); ++i) {
            m[i] = std::stoi(buf);
        }
    }

    std::stringstream ret;
    for (int i = 0; i < q; ++i) {
        ret << (solve(a, n, 0, m[i]) ? "yes" : "no") << std::endl;
    }

    std::cout << ret.str();

    return 0;
}

Measured memory_bytes: 3212
def prime(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a





n=int(input(""))
s=0
if(n!=1):
    

    

    t=0
    lista=prime(n)
    #print(lista)
    
    c=lista[0]
    for i in lista:
        if (c==i):
            t+=1
        else:
            k=1
            while(t>=k):
                t-=k
                s+=1
                k+=1
            t=1
            c=i


    k=1
    while(t>=k):
        t-=k
        s+=1
        k+=1
        


            
        
        
    
    


print(s)
    
        
            
            
    
    


Measured memory_bytes: 9228
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int a,b,c;
  cin >> a >> b >> c;
  vector<int> d(3);
  d = {a,b,c};
  sort(RALL(d));
  if(d[0]==d[1]+d[2])
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer V[] = new Integer[N];
        for (int i=0; i<N; i++) {
            V[i] = sc.nextInt();
        }
        Integer C[] = new Integer[N];
        for (int i=0; i<N; i++) {
            C[i] = sc.nextInt();
        }
        int kotae = 0;
        for(int i=0; i<N; i++){
            if(V[i]>=C[i]){
                kotae = kotae + (V[i]-C[i]);
            }
        }
        System.out.println(kotae);
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

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

    map<char,int> D;
    for(int i = 0;i < 4;i++) {
        D[s[i]]++;
    }

    if(D.size() == 2) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    string s;
    cin>>s;
    //1+1+2
    vector<int> abc(3,0);
    rep(i,s.size()){
        if(s[i]=='a') abc[0]++;
        else if(s[i]=='b') abc[1]++;
        else abc[2]++;
    }
    sort(abc.begin(),abc.end());
    if(s.size()==1 || (s.size()==2 && abc[1]==abc[2])){
        cout<<"YES"<<endl;
        return 0;
    }
    if(abc[0]==0 || abc[2]-abc[0]>1){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }


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

    int h = 0, m = n;
    while(m > 0){
        int num = m % 10;
        h += num;
        m /= 10;
    }
    if(n%h==0) cout << "Yes" << ln;
    else cout << "No" << ln;
} 


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n, m; cin >> n >> m;
    if(abs(n-m) > 1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    REP(i, n) ans = ans * (1 + i) % MOD;
    REP(i, m) ans = ans * (1 + i) % MOD;
    if(n == m) ans = ans * 2 % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
using namespace std;

int main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;

  int ans1=0,ans2=0;
  double ans=0;

  for(int i=0;100*a*i<=f;i++){
    int x=100*a*i;
    for(int j=0;x+100*b*j<=f;j++){
      int y=x+100*b*j;
      for(int k=0;c*k<=e*y/100;k++){
        int z=c*k;
        for(int l=0;z+d*l<=e*y/100;l++){
          int w=z+d*l;
          if(y+w==0) break;
          if(y+w<=f&&ans<=100*(double)w/double(y+w)){
            ans=100*(double)w/double(y+w);
            ans1=y+w;
            ans2=w;
          }
        }
      }
    }
  }
  cout<<ans1<<" "<<ans2<<endl;
  return 0;
}


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

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    Niku[] nikus = new Niku[N];
    for (int i = 0; i < N; i++) {
      nikus[i] = new Niku(scanner.nextInt(), scanner.nextInt(), scanner.nextInt());
    }

    double left = 0.d;
    double right = 400_000.d;
    while (right - left > 1e-9) {
      double mid = (right + left) / 2;
      List<Point> intersects = new ArrayList<>();
      for (int i = 1; i < N; i++) {
        for (int j = 0; j < i; j++) {
          intersects.addAll(intersects(nikus[i].loc, mid / nikus[i].c, nikus[j].loc, mid / nikus[j].c));
        }
      }
      for (int i = 0; i < N; i++) intersects.add(nikus[i].loc);
      if (suffice(N, K, nikus, mid, intersects)) {
        right = mid;
      } else {
        left = mid;
      }
    }
    System.out.println(right);
  }

  private static boolean suffice(int n, int k, Niku[] nikus, double mid, List<Point> intersects) {
    for (Point p : intersects) {
      int count = 0;
      for (int i = 0; i < n; i++) {
        if (nikus[i].loc.dist(p) * nikus[i].c < mid + 1e-9) count++;
      }
      if (count >= k) {
        return true;
      }
    }
    return false;
  }

  private static class Niku {
    private final Point loc;
    private final int c;

    private Niku(int x, int y, int c) {
      this.loc = new Point(x, y);
      this.c = c;
    }
  }

  private static List<Point> intersects(Point c1, double r1, Point c2, double r2) {
    List<Point> list = new ArrayList<>();
    double dist = c1.dist(c2);
    double cm = (r1 * r1 - r2 * r2 + dist * dist) / dist / 2;
    Point m = c2.subtract(c1).scale(cm / dist).add(c1);
    double pm = Math.sqrt(r1 * r1 - cm * cm);
    Point mc = c1.subtract(m).scale(pm / cm);
    list.add(mc.rotate(Math.PI / 2).add(m));
    list.add(mc.rotate(-Math.PI / 2).add(m));
    return list;
  }

  public static class Point {
    public final double x;
    public final double y;

    public Point(double x, double y) {
      this.x = x;
      this.y = y;
    }

    public Point scale(double s) {
      return new Point(x * s, y * s);
    }

    public Point subtract(Point another) {
      return new Point(x - another.x, y - another.y);
    }

    public Point add(Point another) {
      return new Point(x + another.x, y + another.y);
    }

    public double dist() {
      return Math.sqrt(x * x + y * y);
    }

    public double distSq(Point another) {
      return (another.x - x) * (another.x - x) + (another.y - y) * (another.y - y);
    }

    public double dist(Point another) {
      return Math.sqrt(distSq(another));
    }

    public Point rotate(double theta) {
      double newX = x * Math.cos(theta) - y * Math.sin(theta);
      double newY = x * Math.sin(theta) + y * Math.cos(theta);
      return new Point(newX, newY);
    }

    @Override public String toString() {
      return "(" + x + ", " + y + ')';
    }
  }
}


Measured memory_bytes: 41452
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
ll mod=1000000007;
using namespace std;


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

	ll l=s.length();

	if(s[l-1]=='s'){
		cout<<s<<"es"<<endl;
	}else{
		cout<<s<<"s"<<endl;
	}
  
}

Measured memory_bytes: 3592
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

#define SIZE(x) (int((x).size()))
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
#define repd(i,r,l) for (int i=(r); i>=(l); i--)
#define rept(i,c) for (__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

#ifndef ONLINE_JUDGE
#define debug(x) { cerr<<#x<<" = "<<(x)<<endl; }
#else
#define debug(x) {}
#endif

void lemon()
{
	string s;
	cin>>s;
	if (s.length()<4 || s[0] != 'Y' || s[1]!='A' || s[2]!='K' || s[3]!='I')
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
}

int main()
{
	ios::sync_with_stdio(true);
	#ifndef ONLINE_JUDGE
		//freopen("","r",stdin);
	#endif
	lemon();
	return 0;
}

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

using namespace std;

#define ll long long

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

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

	vector < ll > gcdl(N, 1);
	vector < ll > gcdr(N, 1);

	gcdl[0] = A[0];
	for (int i = 1; i < N; i++) {
		gcdl[i] = __gcd(gcdl[i - 1], A[i]);
	}

	gcdr[N - 1] = A[N - 1];
	for (int i = N - 2; i >= 0; i--) {
		gcdr[i] = __gcd(gcdr[i + 1], A[i]);
	}

	ll ans = 1;
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			ans = max(ans, gcdr[i + 1]);
		} else if (i == N - 1) {
			ans = max(ans, gcdl[i - 1]);
		} else {
			ans = max(ans, __gcd(gcdl[i - 1], gcdr[i + 1]));
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		int n = sc.nextInt();
		int nn = n;
		while(n != 0) {
			sum += n%10;
			n = n/10;
		}
		if(nn%sum == 0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 22484
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

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

		while (!(line = br.readLine()).equals("0")) {

			int n = Integer.parseInt(line);
			int[] prog, freq;
			prog = new int[n];
			freq = new int[n];

			line = br.readLine();
			StringTokenizer st = new StringTokenizer(line);

			for (int i = 0; i < n; i++) {
				prog[i] = Integer.parseInt(st.nextToken());
			}

			// 出現頻度操作
			int op = 0;
			while (true) {

				// 数え上げ
				boolean[] chk = new boolean[n];

				for (int i = 0; i < n; i++) {
					if (!chk[i]) {
						int f = 1, t = 1;
						int[] idx = new int[n];
						chk[i] = true;
						idx[0] = i;
						for (int j = 0; j < n; j++) {
							if (!chk[j] && prog[i] == prog[j]) {
								chk[j] = true;
								f++;
								idx[t] = j;
								t++;
							}
						}
						for (int j = 0; j < t; j++) {
							freq[idx[j]] = f;
						}
					}
				}
				//
				if (!Arrays.equals(prog, freq)) {
					prog = Arrays.copyOf(freq, n);
					op++;
				} else {
					prog = freq;
					break;
				}
			}
			System.out.println(op);
			for (int i = 0; i < n; i++) {
				if (i != n - 1) {
					System.out.print(prog[i] + " ");
				} else
					System.out.println(prog[i]);
			}
		}
	}
}

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


void solve(long long N, std::vector<long long> A, long long Q, std::vector<long long> B, std::vector<long long> C){
    vector<long long> cnt(MX);
    rep(i,N){
        cnt[A[i]]++;
    }
    long long tot = 0;
    rep(i,MX){
        tot += i * cnt[i];
    }
    rep(i,Q){
        tot -= B[i] * cnt[B[i]];
        tot -= C[i] * cnt[C[i]];
        cnt[C[i]] = cnt[B[i]] + cnt[C[i]];
        cnt[B[i]] = 0;

        tot += C[i] * cnt[C[i]];
        cout << tot << endl;
    }
}

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


Measured memory_bytes: 13500