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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if( (2 *i) % k != 0){
            continue;
        }
        ll now = (n + i) / k - (i / k);
        ans += now * now;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
ll mod = 1e15;
void solve(){
    ll n ;cin>>n;
    ll arr[n+1];
    ll voo[n+1];
    for(int i=0;i<=n;i++){
        cin>>arr[i];
    }
    ll val = 1;
    for(int i=0;i<=n;i++){
        voo[i]=val;
        val-=arr[i];
        if(val<0){
            cout<<-1<<"\n";
            return;
        }
        if(val!=mod)
            val*=2;
        if(val>=mod){
            val=mod;
        }
    }
    ll ans = 0;
    ll curr = 0;
    for(int i=n;i>=0;i--){
        curr+=arr[i];
        ans+=min(curr,voo[i]);
    }
    cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 5212
from sys import stdin, stdout
import bisect

n = int(stdin.readline().strip())
flag = 0
for i in range(n):
    tmp = int(stdin.readline().strip())
    if tmp % 2:
        flag = 1
        break
if flag:
    stdout.writelines('first\n')
else:
    stdout.writelines('second\n')

Measured memory_bytes: 40300
#include<iostream>
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
 {
	int n;

	cin>>n;

	int d = 0;
	int num = n;
	while(num > 0){
		num = num/10;
		d++;
	}

	// cout<<"d = "<<d<<endl;
	int ans = 0, prev;
	for(int i=1;i<d;i++){
		if(i == 1){
			ans += 9;
			prev = 9;
		} 
		else if(i%2 != 0){
			ans += prev;
		}
		prev = prev*10;
		// cout<<"prev = "<<prev<<endl;
		// cout<<"i = "<<i<<" ans = "<<ans<<endl;
	}
	if(d%2 != 0){
		int temp = pow(10, d-1);
		ans += n-temp+1;
	}

	cout<<ans<<endl;

	return 0;
}

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

int G[20],cnt;

void insertSort(int *a,int n,int g)
{
    for(int i=g;i<n;i++)
    {
        int p=*(a+i),j=i-g;
        while(j>=0&&p<*(a+j))
        {
            *(a+j+g)=*(a+j);
            j-=g;
            cnt++;
        }
        *(a+j+g)=p;
    }
}

void ShellSort(int *a,int n)
{
    int i;
    for( i=0;i<20;i++)
    {
        if(G[i]>n)
            break;
    }
    cout<<i<<endl;
    for(int j=i-1;j>=1;j--)   cout<<G[j]<<" ";
    cout<<G[0]<<endl;

    for(int j=i-1;j>=0;j--)
    {
        insertSort(a,n,G[j]);
    }
} 

int main(int argc, char const *argv[])
{
    for(int i=0;i<20;i++)
    {
        G[i]=(pow(3,i+1)-1)/2;
    }

    int n,*a;  cin>>n;
    a=new int [n];
    for (int i=0;i<n;i++)   cin>>a[i];

    ShellSort(a,n);

    cout<<cnt<<endl;
    for(int i=0;i<n;i++)    cout<<*(a+i)<<endl;

    delete []a;
    //system("pause");
    return 0;
}



Measured memory_bytes: 6944
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,n;
  cin >> a >> b >> c;
  if (a==b && b==c) {
    n=1;
  }
  else if (a==b) {
    n=2;
  }
  else if (b==c) {
    n=2;
  }
  else if (a==c) {
    n=2;
  }
  else {
    n=3;
  }
  cout << n << endl;
}
  

Measured memory_bytes: 256
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        int[] cnt = new int[3];
        for (int i = 0; i < N; i++) {
            if (a[i] % 4 == 0) cnt[0]++;
            else if (a[i] % 2 == 0) cnt[1]++;
            else cnt[2]++;
        }

        if ( (cnt[0] < cnt[2]) && !((cnt[0] + 1 == cnt[2]) && (cnt[1] == 0)) ) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }

        return;
    }

}

Measured memory_bytes: 52328
gets.to_i
S = gets.chomp.chars

h, wk = [0, 0]
S.each{|s|
  if s == '(' then
    wk -= 1
  else
    wk += 1
    if wk == 1 then
      h += 1
      wk = 0
    end
  end
}

puts '(' * h + S.join + ')' * -wk


Measured memory_bytes: 1788
class Modulo
  attr_accessor :num, :mod

  def initialize(mod, init = 0)
    @mod = mod
    @num = init % @mod
    @com_init_max = 0
  end

  def com(n, k, max = nil)
    max = n if max.nil?
    com_init(max) if @com_init_max < max
    return 0 if n < k
    return 0 if n < 0 || k < 0
    @fac[n] * (@finv[k] * @finv[n - k] % @mod) % @mod
  end

  def to_s
    @num.to_s
  end

  def to_i
    @num.to_i
  end

  def com_init(max)
    @com_init_max = max
    @fac = [0] * (max + 1)
    @finv = [0] * (max + 1)
    inv = [0] * (max + 1)
    @fac[0] = 1
    @fac[1] = 1
    @finv[0] = 1
    @finv[1] = 1
    inv[1] = 1;
    2.upto(max) do |i|
      @fac[i] = (@fac[i - 1] * i) % @mod
      inv[i] = @mod - inv[@mod % i] * (@mod / i) % @mod
      @finv[i] = @finv[i - 1] * inv[i] % @mod
    end
  end
end

n, k = gets.chomp.split.map(&:to_i)

modulo = Modulo.new(10**9 + 7)
modulo.com_init(2000)

1.upto(k) do |i|
  p (modulo.com(n - k + 1, i) * modulo.com(k- 1, i - 1)) % (10**9 + 7)
end



Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
long long pow(long long a,long long b)
{
    return b==0?1:a*pow(a,b-1);
}
int main()
{
    int n,p,i,j;
    long long no=0,ne=0;
    cin>>n>>p;
    int a[n+1];
    for(i=0;i<n;i++) 
    {
        cin>>a[i];
        if(a[i]%2) no++;
        else
        ne++;
    }
    long long r=0;
    if(p%2)
    {
        if(no>0)
        r=pow(2ll,no-1+ne);
    }
    else
    {
        if(no>0)
        r=pow(2ll,no-1+ne);
        else
        r=pow(2ll,ne);
    }
    cout<<r;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    int n = s.size();

    bool flag = true;
    for(int i = 0; i < n; i+= 2){
        if(s[i] != 'h' || s[i+1] != 'i'){
            flag = false;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 52;
int before[MAXN], after[MAXN];

int main()
{
    int n, r, p, c;
    while(cin >> n >> r && (n || r))
    {
        for(int i = n; i > 0;i--) before[n - i] = after[n - i] = i;

        rep(j,r)
        {
            cin >> p >> c;
            
            REP(p - 1) after[c + i] = before[i];
            REP(c) after[i] = before[i + p - 1];

            REP(n) before[i] = after[i];
        }


        cout << before[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

// debug
template <class T> ostream& operator<<(ostream &s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n, a, b; cin >> n >> a >> b;
  vector<int> x(n);
  REP (i, n) {
    int p; cin >> p;
    p--;
    x[p] = i;
  }
  vector<vector<int>> dp(n + 1, vector<int>(n + 1, 1e18));
  REP (k, n + 1) dp[0][k] = 0;
  REP (i, n) {
    REP (k, n + 1) {
      if (k > 0) dp[i + 1][k] = dp[i + 1][k - 1];
      if (x[i] < k - 1) {
        chmin(dp[i + 1][k], dp[i][k] + a);
      } else if (x[i] == k - 1) {
        chmin(dp[i + 1][k], min(dp[i][k] + a, dp[i][k - 1]));
      } else {
        chmin(dp[i + 1][k], dp[i][k] + b);
      }
    }
  }
  cout << dp[n][n] << endl;
}


Measured memory_bytes: 195840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  ll check=1;
  check+=n%2;
  mat dp(n+1,vec(check+1,-inf));
  dp[0][0]=0;
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<=check;j++) {
      if(j!=check) {
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]);
      }
      ll cur=dp[i][j];
      if((i+j)%2==0) cur+=a[i];
      dp[i+1][j]=max(dp[i+1][j],cur);
    }
  }
  cout << dp[n][check] << endl;
}

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


int main(void) {

	int A,B,a,b,i;

	scanf("%d %d",&a,&b);
	for(i=0;i<=1250;i++){
        A=i*0.08;B=i*0.1;
        if( A == a && B == b ) {printf("%d",i);return(0);}
	}

	printf("-1");
    return(0);
}



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

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

const int MOD = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;
//    rep(i, n){
//        int a;
//        cin >> a;
//    }

    cout << (n-1+k-2) / (k-1) << endl;

    return 0;
}


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

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

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();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(double x,h; cin >> x >> h, x || h;) {
		double s = x*x;
		s += sqrt(h*h + (x/2)*(x/2)) * x * 2;
		printf("%.7f\n",s);
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.io.ObjectInputStream.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = (long)1e9+7;
	//final static long MOD = 998244353;

	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		slove(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void slove(String[] args) throws Exception{

		String n = nextString();
		int K = nextInt();
		int[] d = nextInts();
		boolean[] D = new boolean[10];
		Arrays.fill(D,true);
		for(int i=0;i<K;i++) {
			D[d[i]]=false;
		}
		int minVal = 0;
		for(int i=0;i<10;i++) {
			if(D[i]) {
				minVal=i;
				break;
			}
		}
		int[] ans = new int[n.length()+1];
		for(int i=n.length()-1;i>=0;i--) {
			int x=(n.charAt(i)-'0')+ans[i+1];
			boolean flg=false;
			int k=x;
			for(;k<10;k++) {
				if(D[k]) {
					flg=true;
					break;
				}
			}
			if(k!=x) {
				for(int idx=i+1;idx<ans.length;idx++) {
					ans[idx]=minVal;
				}
				if(flg) {
					ans[i+1]=k;
				}else {
					ans[i+1]=minVal;
					ans[i]=1;
				}
			}else {
				ans[i+1]=k;
			}
		}
		if(ans[0]!=0) {
			for(int k=1;k<10;k++) {
				if(D[k]) {
					ans[0]=k;
					break;
				}
			}

		}
		int v=0;
		for(int i=0;i<ans.length;i++) {
			v=v*10+ans[i];
		}
		pw.println(v);
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}



Measured memory_bytes: 25428
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(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 modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    string s;
    cin>>s;
    for(char ch:s)
    {
        if(ch=='7')
        {
            cout<<"Yes";
            return;
        }
    }
    cout<<"No\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

int A, B;

/*
int main(){

    cin >> A >> B;

    int sum = A, cnt = 1;
    while(sum < B){
        sum -= 1;
        sum += A;
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}
*/

int main() {
    cin >> A >> B;
    int ans = 0;
    int outlet = 1;
    while (outlet < B) {
   --outlet;
    outlet += A;
    ++ans;
    }
    cout << ans << endl;
    }

Measured memory_bytes: 256
o=->a,n{n<1?1:a**n[0]*o[a,n/2]**2%M}
eval'N,A,B,C='+gets.split*?,
a=o[A*=t=o[A+B,-2+M=10**9+7],N]
b=o[B*=t,N]
f=f=1,*(1..2*N).map{|i|f=f*i%M}
z=0
N.times{|i|z+=(N+i)*f[N+i-1]*o[f[N-1]*f[i],M-2]*(a+b)
z%=M
a=a*B%M
b=b*A%M}
p z*100*o[100-C,M-2]%M

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

typedef pair<int,int> P;
map<P,int> F;
int N;
int X[100001],Y[100001];
int dx[]={-1,0,-1,0};
int dy[]={-1,-1,0,0};
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    int w; cin >> X[i] >> Y[i] >> w;
    F[P(X[i],Y[i])]=w;
  }
  int res = 0;
  for(int i=0;i<N;i++){
    for(int j=0;j<4;j++){
      int x = X[i] + dx[j], y = Y[i] + dy[j];
      int sum = 0;
      for(int k=0;k<4;k++){
        int nx = x - dx[k], ny = y - dy[k];
        if( F.count(P(nx,ny))==1 ) sum+=F[P(nx,ny)];
      }
      res = max( res, sum );
    }    
  }
  cout << res << " / " << 1 << endl;
}

Measured memory_bytes: 8232
#include<iostream>
#include<cmath>
#include<vector>
#include<cstring>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int A = b - a;
    int B = c - b;

    if(A == B) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
// 开始结构的习题练习
#include <cstdio>
int main()
{
    typedef struct
    {
        int height;
        int width;
    } queen;
    queen ans;
    while (scanf("%d%d", &ans.height, &ans.width) != 0)
    {
        if (ans.height == ans.width && ans.height == 0)
            break;
        for (int i = 0; i < ans.height; i++)
        {
            for (int j = 0; j < ans.width; j++)
            {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2600
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 4e18L + 1;
const int IINF = 1e9 + 1;
const int N = 1048576;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#define LOCAL
#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const ll MAX = 1e8;
ll X1, X2, Y1, Y2, n;
pair<ll, ll> pts[N];

int main() {
    #ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #endif
    
    cin >> X1 >> Y1 >> X2 >> Y2 >> n;
    rep (i, 0, n) {
		cin >> pts[i].ft >> pts[i].sd;
		if (X1 > X2) {
			pts[i].ft = MAX - pts[i].ft;
		}
		if (Y1 > Y2) {
			pts[i].sd = MAX - pts[i].sd;
		}
	}
	if (X1 > X2) {
		X1 = MAX - X1;
		X2 = MAX - X2;
	}
	if (Y1 > Y2) {
		Y1 = MAX - Y1;
		Y2 = MAX - Y2;
	}
	sort(pts, pts + n);
	vector<ll> v;
	rep (i, 0, n) {
		ll x = pts[i].ft, y = pts[i].sd;
		if (x < X1 or x > X2 or y < Y1 or y > Y2) {
			continue;
		}
		auto it = lower_bound(all(v), y);
		if (it == v.end()) {
			v.pb(y);
		} else {
			(*it) = y;
		}
	}
	ll fon = SZ(v);
	double pi = M_PI;
	double wyn = (Y2 - Y1 + X2 - X1) * 100.0;
	wyn -= fon * (20.0 - 5.0 * pi);
	if (fon - 1 == min(X2 - X1, Y2 - Y1)) {
		wyn += 10.0 * pi - 20.0 + (20.0 - 5.0 * pi);
	}
	cout << fixed << setprecision(10) << wyn;
		
				
    
}


Measured memory_bytes: 6516
#include<bits/stdc++.h>
#define ll long long
#define Mod 1000000007
#define M 100005
using namespace std;
int n,cnt[26];
char s1[M];
int main(){
	scanf("%d%s",&n,s1+1);
	for(int i=1;i<=n;i++)cnt[s1[i]-'a']++;
	int ans=1;
	for(int i=0;i<26;i++)ans=(ll)ans*(cnt[i]+1)%Mod;
	ans=(ans-1+Mod)%Mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		
		String trimed = input.replace(input.substring(0, 1), "");
		if(trimed.length()==2){
			if(trimed.charAt(0) == trimed.charAt(1)){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#include<bitset>
#include<map>
using namespace std;
inline int re_ad()
{
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-48,ch=getchar();return x*f;
}
inline int ma(int x,int y){return x>y?x:y;}
inline int mi(int x,int y){return x>y?y:x;}
int n,a[200010],A[200010],cnt=0;struct node{int num,ii;}B[200010];
bool cmp(node x,node y){return x.num<y.num;}
inline bool check(int k)
{
	for(register int i=0;i<n-1;i++)
	{
	if(a[n-i]<=k&&a[n-i-1]<=k||a[n+i]<=k&&a[n+i+1]<=k)return true;
	if(a[n-i]>k&&a[n-i-1]>k||a[n+i]>k&&a[n+i+1]>k)return false;
	}
	return a[1]<=k;
}
int main()
{
	n=re_ad();n=n*2-1;
	for(int i=1;i<=n;i++)a[i]=re_ad(),B[i].num=a[i],B[i].ii=i;
	sort(B+1,B+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
	if(B[i].num!=B[i-1].num)++cnt;
	A[cnt]=B[i].num;a[B[i].ii]=cnt;
	}
	int l=1,r=cnt,mid;
	n=n+1>>1;
	while(l<r)
	{
	int mid=l+r>>1;if(check(mid))r=mid;else l=mid+1;
	}
	cout<<A[l]<<endl;return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> num(N);
  for (auto& i : num)
    cin >> i;
  vector<long long int> dp(21, 0);
  dp[num[0]] = 1;
  for (int i = 0; i < N-2; i++) {
    vector<long long int> bnum(21,0);
    for (int j = 0; j < 21; j++) {
      int plus  = j+num[i+1];
      int minus = j-num[i+1];
      if (plus >= 0 && plus <= 20)
        bnum[plus]+=dp[j];
      if (minus>=0 && minus<= 20)
        bnum[minus]+=dp[j];
    }
    for(int j = 0; j < 21; j++){
      dp[j]=bnum[j];
    }
  }
  cout << dp[num[N-1]] << endl;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,m;cin>>n>>m;
    vector<ll>x(n);
    vector<ll>y(m);
    rep(i,n)cin>>x[i];
    rep(i,m)cin>>y[i];
    ll cnt1=0;
    rep(i,m-1){
        cnt1=(cnt1+((i+1)*(m-i-1)*(y[i+1]-y[i]))%inf)%inf;
    }
    ll cnt2=0;
    rep(i,n-1){
        cnt2=(cnt2+((i+1)*(n-i-1)*(x[i+1]-x[i]))%inf)%inf;
    }
    cout<<cnt1*cnt2%inf<<endl;
}

Measured memory_bytes: 1792
from collections import deque
H,W=map(int,input().split())
A=[list(input()) for i in range(H)]
stack=[]
for h in range(H):
    for w in range(W):
        if A[h][w]=="#":
            stack.append([h,w,0])

stack=deque(stack)
value=0
while stack:
    h,w,m=stack.popleft()
    lst=[]
    if h>0:lst.append([-1,0])
    if h<H-1:lst.append([1,0])
    if w>0:lst.append([0,-1])
    if w<W-1:lst.append([0,1])
    n=m+1
    for y1,x1 in lst:
        Y=h+y1
        X=w+x1
        if A[Y][X]==".":
            A[Y][X]="#"
            stack.append([Y,X,n])
            if value<n:
                value=n
print(value)


Measured memory_bytes: 181132
n=int(input())
count=0

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

l=factorization(n) 

for i in range(len(l)):
    m=l[i]
    m2=m[1]
    a=1
    while m2>=a:
        count+=1
        m2-=a
        a+=1
if n==1:
    print(0)
else:
    print(count)


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

using namespace std;

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define fs first
#define sc second

#define ri(X) scanf("%d", &(X))
#define rii(X, Y) scanf("%d%d", &(X), &(Y))
#define riii(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))

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

char s[2020][2020];
int vert[2020][2020];
int hor[2020][2020];
int cnt[2020][2020];

int main(){

	int n,m,q;
	riii(n,m,q);

	for(int i=1; i<=n; i++) {
		scanf("%s", &s[i][1]);
	}

	for(int r=1; r<=n; r++) {
		for(int c=1; c<=m; c++) {
			vert[r][c] = vert[r-1][c] + vert[r][c-1] - vert[r-1][c-1];
			hor[r][c] = hor[r-1][c] + hor[r][c-1] - hor[r-1][c-1];
			cnt[r][c] = cnt[r-1][c] + cnt[r][c-1] - cnt[r-1][c-1];
			
			if(s[r][c]=='1' && s[r-1][c]=='1') vert[r][c]++;
			if(s[r][c]=='1' && s[r][c-1]=='1') hor[r][c]++;
			if(s[r][c]=='1') cnt[r][c]++;
		}
	}

	for(int i=0; i<q; i++) {
		int x1,y1,x2,y2;
		rii(x1,y1);
		rii(x2,y2);

		int nodes = cnt[x2][y2] - cnt[x2][y1-1] - cnt[x1-1][y2] + cnt[x1-1][y1-1];
		int edges = hor[x2][y2] - hor[x2][y1] - hor[x1-1][y2] + hor[x1-1][y1]
				+	vert[x2][y2] - vert[x2][y1-1] - vert[x1][y2] + vert[x1][y1-1];
		int ans = nodes - edges;
		printf("%d\n", ans);
	}

    return 0;
}


Measured memory_bytes: 53504
#include<bits/stdc++.h>
using namespace std;
int main() {
  using LL = long long;
  const LL MOD = 1e9+7;
  int N, M;
  cin >> N >> M;
  vector<LL> S(N), T(M);
  for(auto v: {&S, &T}) for(auto& i: *v) cin >> i;
  vector<vector<LL>> dp(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-1][j] + dp[i][j-1];
    dp[i][j] += (S[i-1]==T[j-1] ? 1 : -dp[i-1][j-1]);
    dp[i][j] %= MOD;
  }
  cout << (1 + dp[N][M] + MOD) % MOD << endl;
}


Measured memory_bytes: 31616
#include<cstdio>
#define int long long
const int mod=1e9+7;
struct Edge{
	int to,nxt;
}edge[10010];
int cnt,head[5010],f[5010][5010],size[5010],tmp[5010],g[5010],n;
void addedge(int x,int y){
	edge[++cnt].to=y;
	edge[cnt].nxt=head[x];
	head[x]=cnt;
}
void dfs(int x,int fa){
	f[x][1]=1;
	size[x]=1;
	for(int i=head[x];i;i=edge[i].nxt){
		int upup=edge[i].to;
		if(upup==fa)continue;
		dfs(upup,x);
		for(int j=1;j<=size[x]+size[upup];j++)
			tmp[j]=0;
		for(int j=1;j<=size[x];j++)
			for(int k=0;k<=size[upup];k++)
				(tmp[j+k]+=f[x][j]*f[upup][k]%mod)%=mod;
		for(int j=1;j<=size[x]+size[upup];j++)
			f[x][j]=tmp[j];
		size[x]+=size[upup];
	}
	for(int i=2;i<=size[x];i+=2)
		(f[x][0]+=mod-f[x][i]*g[i]%mod)%=mod;
}
signed main(){
	g[0]=1;
	scanf("%lld",&n);
	for(int i=2;i<=n;i+=2)
		g[i]=g[i-2]*(i-1)%mod;
	for(int i=1,x,y;i<n;i++){
		scanf("%lld%lld",&x,&y);
		addedge(x,y);
		addedge(y,x);
	}
	dfs(1,0);
	printf("%lld\n",(mod-f[1][0])%mod);
} 

Measured memory_bytes: 92068
while true do
ar=STDIN.gets.split
m =ar[0].to_i
f =ar[1].to_i
r =ar[2].to_i

break if m==-1 && f==-1 && r==-1

grade = 
  if m==-1 || f==-1 then "F"
  elsif m + f >= 80 then "A"
  elsif m + f >= 65 then "B"
  elsif m + f >= 50 then "C"
  elsif (m + f >= 30) && (r >= 50) then "C"
  elsif (m + f >= 30) && (r <  50) then "D"
  elsif m + f < 30 then "F"
  end
puts grade
end

Measured memory_bytes: 8644
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;

namespace ProjectContest
{
    class Test
    {
        static void Main()
        {
            var nl = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
            int n = nl[0], l = nl[1];
            int[] L = new int[n];
            for (int i = 0; i < n; i++)
                L[i] = l + i;
            int sum = L.Sum();
            int min = Math.Abs(L[0]);
            int t = 0;
            for (int i = 1; i < n; i++)
            {
                int now = Math.Min(min, Math.Abs(L[i]));
                t = min == now ? t : i;
                min=now;
            }
            Console.WriteLine(sum-L[t]);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

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

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ull fun(ull n) {
	if (n < 2) {
		return 1;
	} else {
		return n * fun(n - 2);
	}
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8) {
		cout << "Yay!" << endl;
	} else {
		cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

long long int max(long long int a, long long int b){
	if(a > b){
		return a;
	}
	else{
		return b;
	}
}

int main(){
	int N, i, T, A;
	long long int t = 1, a = 1, k;
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d%d", &T, &A);
		k = max((t + T - 1)/T, (a + A - 1)/A);
		t = T * k;
		a = A * k;
	}
	printf("%lld\n", t + a);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

#define ll long long

int n,k;
ll a[212345];

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

  for(int i=k;i<n;i++){
    if(a[i]>a[i-k]) puts("Yes");
    else puts("No");}
  


  return 0;
}


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

using namespace std;


int main()
{
  int n, m;
  cin >> n >> m;
  int l, r;
  int ans1, ans2;
  cin >> ans1 >> ans2;

  for(int i = 0;
      i < m - 1;
      ++i)
    {
      cin >> l >> r;
      if(r < ans1)
        {
          cout << 0 << endl;
          exit(0);
        }
      if(l > ans2)
        {
          cout << 0 << endl;
          exit(0);
        }
      if(ans1 <= l && l <= ans2)
        {
          ans1 = l;
        }
      if(ans1 <= r && r <= ans2)
        {
          ans2 = r;
        }
    }

  cout << ans2 - ans1 + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    int arr[n][m];
    string s[n];
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    int rng=n+m;
    int ans=0;
    //cout<<(1<<rng)<<endl;
    for(int i=0;i<(1<<rng);i++)
    {
        //cout<<i<<endl;
        string s1[n];
        for(int j=0;j<n;j++)
            s1[j]=s[j];
        int ic=i;
        int pos=0;
        int cnt=0;
        while(ic!=0)
        {
            //cout<<"AAA" <<ic<<endl;
            if(ic%2==1)
            {
                int new_pos=pos;
                if(pos>=n)
                {
                    new_pos=pos-n;
                    for(int j=0;j<n;j++)
                        s1[j][new_pos]='.';
                }
                else
                {
                    for(int j=0;j<m;j++)
                    {
                        s1[new_pos][j]='.';
                    }
                }

            }
            pos++;
            ic/=2;
        }
        //cout<<"afa"<<endl;
        for(int x=0;x<n;x++)
        {
            for(int y=0;y<m;y++)
            {
                if(s1[x][y]=='#')
                    cnt++;
            }
        }
        //cout<<"afdfsad"<<endl;
        if(cnt==k)
            ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

int main(void) {
  int i,j,n,rank;
  int card[4][14]={0};
  char sym,z;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%c %c %d",&z,&sym,&rank);
    switch(sym){
    case 'S':card[0][rank]=rank; break;
    case 'H':card[1][rank]=rank; break;
    case 'C':card[2][rank]=rank; break;
    case 'D':card[3][rank]=rank;
    }
  }

  for(i=0;i<4;i++)
    for(j=1;j<=13;j++){
      if(card[i][j]==0)
	switch(i){
	case 0:printf("S %d\n",j); break;
	case 1:printf("H %d\n",j); break;
	case 2:printf("C %d\n",j); break;
	case 3:printf("D %d\n",j);
	}
    }
  return(0);
}

Measured memory_bytes: 596
#!/usr/bin/env python3
N, M = [int(str) for str in input().strip().split()]

divs = []
for i in range(1, int(M**0.5) + 1):
    if M % i == 0:
        divs.append(i)
        if i**2 != M:
            divs.append(M // i)

divs.sort(reverse=True)

for div in divs:
    if M // div >= N:
        print(div)
        exit()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>
#include <cmath>

using namespace std;

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

ll calc(ll b, ll n){
    if(b < 2) return -1;
    if(n < b) return n;
    return calc(b, n/b) + n%b;
}

int main(){
    ll n, s;
    cin >> n >> s;
    ll ans = -1;
    if(n < s) goto fail;
    else if(n == s){
        ans = n+1;
        goto fin;
    }


    ll i;
    for(i = 2; i*i <= n; i++){
        ll x = calc(i, n);
        if(x == s){
            ans = i;
            goto fin;
        }
    }

    ans = LLONG_MAX;
    for(ll p = 1; p * p <= n && p <= s; p++){
        ll b = (n-s)/p + 1;
        ll x = calc(b,n);
        if(x == s){
            ans = min(ans, b);
        }
    }
    if(ans == LLONG_MAX) goto fail;
    else goto fin;

fail:
    cout << -1 << endl;
    return 0;

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define inf 2100000001
bool vis[1005][1005];
int d[1005][1005];
deque<P> q;
string s[1005];
int main(){
	int h,w,ch,cw,dh,dw;
	cin>>h>>w>>ch>>cw>>dh>>dw;
	ch--; cw--; dh--; dw--;
	for(int i=0;i<h;i++){
		cin>>s[i];
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)
		    d[i][j]=inf;
	}
	q.push_back(P(ch,cw));
	d[ch][cw]=0;
	vis[ch][cw]=true;
	while(!q.empty()){
		P a=q.front();
		int x=a.first,y=a.second;
		if(dh==x&&dw==y){
			cout<<d[x][y]<<endl;
			return 0;
		}
		vis[x][y]=true;
		q.pop_front();
		for(int i=-2;i<=2;i++){
			for(int j=-2;j<=2;j++){
				int xx=x+i,yy=y+j;
				if(xx>=0&&xx<h&&yy>=0&&yy<w&&s[xx][yy]=='.'){
					if(vis[xx][yy]) continue;
					if(abs(i)+abs(j)<2){
						q.push_front(P(xx,yy));
					    d[xx][yy]=d[x][y];
					    vis[xx][yy]=true;
					}
					else{
					    if(d[x][y]+1<d[xx][yy]){
						    d[xx][yy]=d[x][y]+1;
						    q.push_back(P(xx,yy));
					    }
				    }
				}
			}
		}
	}
	cout<<"-1"<<endl;
	return 0;
} 

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

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;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

    int k; string s; cin >> k >> s;

    if (k >= s.size()) {
        cout << s << endl;
    } else {
        rep(i,k) {
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}


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

int main(){
  string s0="",s1,s2=""; //s0は前、s1は真ん中、s2は後
  int n,q,f;
  char c;
  bool flag=0;//0なら順番、1なら逆順
  cin>>s1>>n;
  
  REP(i,n){
    cin>>q;
    if(q==1){
      flag=!flag;
    }else{
      cin>>f>>c;
      if(!flag){ //順番
        (f==1?s0:s2)+=c;
      }else{ //逆順
        (f==2?s0:s2)+=c;
      }
    }
  }
  if(!flag){
    reverse(s0.begin(),s0.end());
    cout<<s0+s1+s2;  
  }else{
    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());
    cout<<s2+s1+s0;
  }
}

Measured memory_bytes: 1348
import java.util.*;


public class Main {
	public static void main (String[] args){
		Scanner sc =  new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		if(c-a-b > 0 && 4*a*b < (c-a-b)*(c-a-b)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}	
}

Measured memory_bytes: 22612
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInt >>= print . ( `div` 3 )


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define gcd(x,y) __gcd(x,y)
#define PI 3.14159265
#define count_ones __builtin_popcountl
const int N=1e5+20,MOD=(int)(1e9)+7;
const int oo = 0x3f3f3f3f;
typedef long long ll;
using namespace std;
void boost(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}
/* -------------------------------------- */

/* -------------------------------------- */
int main() {
	boost();
	int n;cin>>n;int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	bool flag=false;
	for(int i=0;i<=n-2;i++){
		if(a[i+1] > a[i]) {
			a[i+1]--;
		}
	}
//	for(int i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
	for(int i=0;i<n-1;i++){
		if(a[i+1]<a[i]){
//			watch(a[i]);watch(a[i+1]);
			flag=true;break;
		}
	}
	cout<<(flag==true ? "No" : "Yes");
}

Measured memory_bytes: 640
def bubble_sort_aoj(nums, len):
    '''バブルソート：隣接項の比較'''
    flag = True
    count = 0
    
    while flag:
        flag = False
        
        for i in range(len - 1, 0, -1):
            if nums[i] < nums[i-1]:
                nums[i], nums[i-1] = nums[i-1], nums[i]
                flag = True
                count += 1
    
    return nums, count

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split(' ')))

    ans = bubble_sort_aoj(A, N)

    print(' '.join([str(x) for x in ans[0]]))
    print(ans[1])


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

int main(){

    int N; cin >> N;
    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];}

    int a,b;
    int cnt = 0;
    int dict[N];for(int i = 0; i < N; i++){dict[i]=i+1;}

    do{
        cnt++;
        if(equal(P, P+N, dict)){a=cnt; /*cout << "a : " << a << endl;*/}
        if(equal(Q, Q+N, dict)){b=cnt; /*cout << "b : " << b << endl;*/}
    }while(next_permutation(dict,dict+N));

    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sn = new Scanner(System.in);
		int N = sn.nextInt();
		long A = 1L,B = 1L;
		for(int i = 0; i < N; ++i){
			long x = sn.nextLong();
			long y = sn.nextLong();
			long A_x = A/x;
			long B_y = B/y;
			A_x += (A%x == 0) ? 0:1;
			B_y += (B%y == 0) ? 0:1;
			long n = Math.max(A_x,B_y);
			A = n*x;
			B = n*y;			
		}
		System.out.println(A+B);
	}
}


Measured memory_bytes: 13424
from itertools import groupby
n,k = [int(x) for x in input().split()]
r,s,p = [int(x) for x in input().split()]
T = input()
a = (n+k-1)//k
klist=[[""]*a for _ in range(k)]
for i in range(k):
  m=0
  klist[i] = T[i::k]
ans = 0
for i in range(k):
  t = list(klist[i])
  for key, value in groupby(t):
    if key=="r":
      ans+=(len(list(value))+1)//2*p
    if key=="s":
      ans+=(len(list(value))+1)//2*r
    if key=="p":
      ans+=(len(list(value))+1)//2*s
print(ans)
    


Measured memory_bytes: 58108
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

const int MAX_N = 2010;
ll fact[MAX_N], finv[MAX_N], inv[MAX_N];

void init_combination(ll p) {
    fact[0] = fact[1] = finv[0] = finv[1] = inv[1] = 1;
    for (int i = 2; i < MAX_N; ++i) {
        inv[i] = inv[p % i] * (p - p / i) % p;
        fact[i] = fact[i - 1] * i % p;
        finv[i] = finv[i - 1] * inv[i] % p;
    }
}

ll comb(int n, int k, ll p) {
    if (n < k || n < 0 || k < 0) return 0;
    return fact[n] * (finv[k] * finv[n - k] % p) % p;
}

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

    ll n, k, p = (ll) 1e9 + 7;
    cin >> n >> k;
    init_combination(p);
    for (ll i = 1; i <= k; ++i) {
        cout << comb(k - 1, i - 1, p) * comb(n - k + 1, i, p) % p << "\n";
    }

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = s[0];
            int Y = s[1];
            //まずは最適解を出す
            int yukiti = 0;
            int higuti = 0;
            int noguti = 0;
            int y = Y;
            while (y > 0)
            {
                if (y >= 10000)
                {
                    y -= 10000;
                    yukiti++;
                }
                else if (y >= 5000)
                {
                    y -= 5000;
                    higuti++;
                }
                else
                {
                    y -= 1000;
                    noguti++;
                }
            }
            //両替phase
            bool find = false;
            while (yukiti + higuti + noguti <= N)
            {
                int n = yukiti + higuti + noguti;

                if (n == N)
                {
                    find = true;
                    break;
                }

                if (N - n >= 4 && higuti > 0)
                {
                    higuti--;
                    noguti += 5;
                }
                else if (N - n >= 1 && yukiti > 0)
                {
                    yukiti--;
                    higuti += 2;
                }
                else
                {
                    break;
                }
            }

            if (find)
            {
                WriteLine(yukiti + " " + higuti + " " + noguti);
            }
            else
            {
                WriteLine("-1 -1 -1");
            }
        }
    }
}


Measured memory_bytes: 13396
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(A: int, B: int, X: int):
    if X-A<=B and X >= A:
        print(YES)
    else:
        print(NO)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(A, B, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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 x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  ll x,y;
  cin>>x>>y;

  cout << (abs(x-y)<=1? "Brown":"Alice") << endl;


}

Measured memory_bytes: 3624