akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = 998244353;
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b); 
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
void rmult(int &a, int b)
{
	a=mult(a,b);
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}
	
int dp[3333][3333];
int a[3333];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,s; cin>>n>>s;
	init(5555);
	for(int i=0;i<n;i++) cin>>a[i];
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=s;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=a[i-1]) dp[i][j]=add(dp[i][j],mult(inv[2],dp[i-1][j-a[i-1]]));
		}
	}
	int ans=mult(dp[n][s],pow2[n]);
	cout<<ans<<'\n';
	
}


Measured memory_bytes: 42780
#include<stdio.h>
#define N 200000
int main(){
  int n, i;
   int A[N+1];
   scanf("%d", &n);
   for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);

   for ( i = 1; i <= n; i++ ) {
     printf("node %d: key = %d, ", i, A[i]);
     if ( i/2 >= 1 )printf("parent key = %d, ", A[i/2]);
     if ( i*2 <= n ) printf("left key = %d, ", A[i*2]);
     if ( i*2+1 <= n ) printf("right key = %d, ", A[i*2+1]);
     printf("\n");
   }
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin>>k;
  string s;
  cin>>s;
  int l=s.length();
  if(k>=l)cout<<s<<endl;
  else{
   
    for(int i=0;i<k;i++){
      cout<<s[i];
    }
    cout<<"..."<<endl;
  }
}


Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <vector>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

constexpr int MAX = 1e5 + 1;

int f(vector<pair<int, int>>&, int, int, int);

int dp[1000][4096];

int main() {
	memset(dp, -1, sizeof(dp));

	int n, m;
	cin >> n >> m;

	int t = pow(2, n) - 1;

	vector<pair<int, int>> k(m);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		int ti = 0;
		for (int j = 0; j < b; ++j) {
			int c;
			cin >> c;
			ti += 1 << (c - 1);
		}

		k[i] = make_pair(a, ti);
	}

	int ans = f(k, 0, 0, t);
	cout << (ans >= MAX ? -1 : ans);

	return 0;
}

int f(vector<pair<int, int>>& k, int i, int s, int t) {
	if (i == k.size()) {
		if (s == t) {
			return 0;
		}

		return MAX;
	}

	if (dp[i][s] != -1) {
		return dp[i][s];
	}
	
	int a = f(k, i + 1, s | k[i].second, t) + k[i].first;
	int b = f(k, i + 1, s, t);

	return dp[i][s] = min(a, b);
}


Measured memory_bytes: 16384
n = int(input())
a = list(map(int,input().split()))
S = sum(a)
sum =[0]*n
sum[0] = a[0]
su =0
ar =0

min = 10**20

for i in range(1,n):
    sum[i] = sum[i-1] + a[i]
    su = sum[i-1]
    ar = S - su
    if abs(su-ar) < min:
        min = abs(su-ar)

print(min)


Measured memory_bytes: 76752
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,k,s;
    cin>>n>>k>>s;
    for(int i=0;i<k;i++){
        cout<<s<<" ";
    }
    for(int i=k;i<n;i++){
        if(s==INF)cout<<1<<" ";
        else cout<<s+1<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

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

  ll ans = 0;  // お気に入りの数の総和
  for(ll i=1; i*i <= N; ++i) {
    if (N % i == 0) {
      // (Nの約数)-1が候補
      // 大きい方の約数だけ
      ll m = N/i - 1;
      if (m != 0 && N / m == N % m) ans += m;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int a,b,c=0;
  scanf("%d",&a);
  for(int i=1; i<=a; i+=2){
    b=0;
    for(int j=1; j<=i; j++){
      if(i%j==0){b++;}
    }
    if(b==8){c++;}
  }
  printf("%d",c);
  return 0;}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}
int main(){
  ll a,v,b,w,t;
  cin >> a >> v >> b >> w >>t;
  ll dis=max(a-b,b-a);
  bool ans=1;
  if(v-w<=0){
    cout << "NO" << endl;
    return 0;
  }
  if(dis>(v-w)*t)ans=0;
  if(ans)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3640
N=int(input())
for a,b,c in [[int(i) for i in input().split(" ")] for k in range(N)]:
    if b*b+c*c==a*a:
        print("YES")
    elif a*a+c*c==b*b:
        print("YES")
    elif a*a+b*b==c*c:
        print("YES")
    else:
        print("NO")



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

const int N = 110;

int n, m;
int a[N];

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++ i){
		scanf("%d", &a[i]);
	}
	if (m == 1){
		if (a[0] == 1){
			printf("1\n1\n1\n");
			return 0;
		}
		printf("%d\n2\n%d 1\n", a[0], a[0] - 1);
		return 0;
	}
	if (m == 2){
		if (a[1] == 1){
			printf("%d %d\n1\n%d\n", a[0], a[1], a[0] + a[1]);
			return 0;
		}
		printf("%d %d\n2\n%d %d\n", a[0], a[1], a[0] + 1, a[1] - 1);
		return 0;
	}
	for (int i = 1; i < m - 1; ++ i){
		if (a[i] & 1){
			if (a[0] % 2 == 0){
				std::swap(a[0], a[i]);
			}
			else if (a[m - 1] % 2 == 0){
				std::swap(a[i], a[m - 1]);
			}
			else{
				printf("Impossible\n");
				return 0;
			}
		}
	}
	for (int i = 0; i < m; ++ i){
		printf("%d%c", a[i], " \n"[i == m - 1]);
	}
	if (a[m - 1] == 1){
		printf("%d\n", m - 1);
		for (int i = 0; i < m - 1; ++ i){
			printf("%d%c", i ? a[i] : a[i] + 1, " \n"[i == m - 2]);
		}
		return 0;
	}
	printf("%d\n", m);
	for (int i = 0; i < m; ++ i){
		printf("%d%c", i == m - 1 ? a[i] - 1 : i ? a[i] : a[i] + 1, " \n"[i == m - 1]);
	}
	return 0;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

#define EXACT 0
#define SMALLER 1

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

	auto N=in(),M=in();
	vll A=vecin(N);
	vll B(60,0),C(60,0);
	REP(i,N){
		ll V=A[i],index=0;
		while(V){
			if(V&1ll){
				B[index]++;
			}
			index++;
			V/=2ll;
		}
	}
	ll V=M,index=0;
	while(V){
		if(V&1ll){
			C[index]++;
		}
		index++;
		V/=2ll;
	}
	reverse(ALL(B));
	reverse(ALL(C));

	vvll dp(61,vll(2,-(1ll<<60)));
	dp[0][0]=0;
	REP(i,60){
		ll cost_zero = B[i];
		ll cost_one = N-B[i];
		if(C[i]){
			chmax(dp[i+1][EXACT],dp[i][EXACT]*2ll+cost_one);
			chmax(dp[i+1][SMALLER],dp[i][EXACT]*2ll+cost_zero);
			chmax(dp[i+1][SMALLER],dp[i][SMALLER]*2ll+cost_one);
			chmax(dp[i+1][SMALLER],dp[i][SMALLER]*2ll+cost_zero);
		}
		else{
			chmax(dp[i+1][EXACT],dp[i][EXACT]*2ll+cost_zero);
			chmax(dp[i+1][SMALLER],dp[i][SMALLER]*2ll+cost_one);
			chmax(dp[i+1][SMALLER],dp[i][SMALLER]*2ll+cost_zero);
		}
	}
	out(max(dp[60][0],dp[60][1]));
	return 0;
}


Measured memory_bytes: 1024
//https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_a
 
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println((N-2)*180);
    }
}

Measured memory_bytes: 21076
function main (input) {
	var input = input.split(' ');
	var A = parseInt(input[0], 10);
	var B = parseInt(input[1], 10);
	var C = parseInt(input[2], 10);
	var x = parseInt(input[3], 10);
	var y = parseInt(input[4], 10);
	var priceA = 0;
	var priceB = 0;
    var priceC = 0;
    var price = [];

	priceA = x * A + y * B;
    price.push(priceA);
    priceB = x > y ? C * 2 * y + A * (x - y) : C * 2 * x + B * (y - x);
	price.push(priceB);
    priceC = x > y ? C * 2 * x : C * 2 * y;
    price.push(priceC);
    console.log(Math.min.apply(null, price));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(void){
  long long N, C, K;
  cin >> N >> C >> K;
 
  vector<long long> t(N);
  for(int i=0; i<N; i++) cin >> t[i];
  sort(t.begin(), t.end());
  
  int start = t[0];
  int bus = 0;
  int customer = 1;
  for(int i=1; i<N; i++){
     if(t[i] - start > K || customer == C){
  		//cout << t[i] << "\n";
		start = t[i];
        customer = 1;
		bus++;
     }else{
		customer++;
     }
	
  }//for
  if(customer > 0) bus++;
     cout << bus << "\n";
}//main


Measured memory_bytes: 3912
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h,w=LI()
  ans=[]

  h1=h//3
  h2=(h-h1)//2
  h3=h-(h1+h2)
  ans.append(max(h1,h2,h3)*w-min(h1,h2,h3)*w)

  w1=w//3
  w2=(w-w1)//2
  w3=w-(w1+w2)
  ans.append(max(w1,w2,w3)*h-min(w1,w2,w3)*h)

  mn=inf
  for i in range(1,h):
    a1=w*i
    w1=w//2
    a2=w1*(h-i)
    w2=w-w1
    a3=w2*(h-i)
    mn=min(mn,max(a1,a2,a3)-min(a1,a2,a3))
  ans.append(mn)

  mn=inf
  for i in range(1,w):
    a1=h*i
    h1=h//2
    a2=h1*(w-i)
    h2=h-h1
    a3=h2*(w-i)
    mn=min(mn,max(a1,a2,a3)-min(a1,a2,a3))
  ans.append(mn)

  return min(ans)

# main()
print(main())


Measured memory_bytes: 10636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int solve1(int n,int k){
	while(n%k&&n>=k) n=1ll*n*(k-1)/k;
	if(n<k) return 0;
	return n/k;
}
int solve2(int n,int k){
	while(n>k&&n%k){
		int p=n-1ll*n*(k-1)/k;
		int l=0,r=n/p+1;
		auto check=[&](int x){
			int m=n-1ll*x*p;
			return m-1ll*m*(k-1)/k==p;
		};
		while(l+1<r){
			int mid=l+r>>1;
			if(check(mid)) l=mid;
			else r=mid;
		}
		n-=r*p;
	}
	if(n<k) return 0;
	return n/k;
}
int main(){
	int n;
	read(n);
	int ans=0;
	for(int i=1;i<=n;i++){
		int a,k;
		read(a);read(k);
		if(k<=100000) ans^=solve1(a,k);
		else ans^=solve2(a,k);
	}
	if(ans) puts("Takahashi");
	else puts("Aoki");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long 
#define ull unsigned long long

double pi=acos(-1.0);
double n; 

int main()
{
	cin>>n;
	printf("%.20lf\n",2*n*pi); 
	return 0;
} 

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

int main() {
int x;
  for(int i=1;;i++) {
    cin >> x;
    
  if(x==0){
    break;
  
   }
   cout<< "Case "<< i << ": "<<  x  <<endl;
    } 
  return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int dfs(int i,int p,bool a,bool b,bool c){
  int ans = 0;
  if(a&&b&&c&&p<=n)ans++;
  if(i<9){
    ans += dfs(i+1, 10*p+3, true, b, c);
    ans += dfs(i+1, 10*p+5, a, true, c);
    ans += dfs(i+1, 10*p+7, a, b, true);
  }
  return ans;
}
int main(){
  cin>>n;
  int ans = dfs(0,0,false,false,false);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[input() for i in range(n)]
b=[input() for i in range(m)]
r=any([k[j:j+m] for k in a[i:i+m]]==b for i in range(n-m+1) for j in range(n-m+1))
print("Yes" if r else "No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int dp[10000005];
int32_t main(){
    fast;
    int n,k;
    cin>>n>>k;
    memset(dp,0,sizeof(dp));
    vector<int> p(n);
    for(int i=0;i<n;i++)
        cin>>p[i];
    for(int i=0;i<=k;i++){
        for(int j=0;j<n;j++)
            if(i>=p[j] && dp[i-p[j]]==0){
                dp[i]=1;break;
            }
    }
    if(dp[k])
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}

Measured memory_bytes: 81764
import math
S = input()
a = (['1'] + ['0']) * (len(S)//2)
if (len(S) % 2 == 1):
  a += ['1']
ans = 0
for i in range(len(S)):
  if (S[i] != a[i]):
    ans += 1

if (len(S) - ans <= ans):
  print(len(S) - ans)
else:
  print(ans)


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	char s[n];
	cin>>s;
	int countr=0,countw=0;
	int tr=0,tw=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R')
		tr++;
		else
		tw++;
	}
	for(int i=0;i<n;i++){
		if(i<tr && s[i]=='W')
		countw++;
		if(i>(n-1-tw) && s[i]=='R')
		countr++;
	}
	cout<<min(countw,countr);
	return 0;
}


Measured memory_bytes: 3844
#[allow(dead_code)]
fn main() {
    let s = i::s();
    let mut g = 0;
    let mut p = 0;
    let mut score = 0;
    for c in s {
        if p + 1 <= g {
            p += 1;
            score += if c == 'g' { 1 } else { 0 };
        } else {
            g += 1;
            score += if c == 'g' { 0 } else { -1 };
        }
    }
    println!("{}", score);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
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 dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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; }
// template end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c;
    in >> a >> b >> c;

    if(a <= c and c <= b){
        out << "Yes" << endl;
    }else{
        out << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define maxn 1000000
#define LL long long
LL fac[maxn+5],inv[maxn+5];
LL C(int n,int m){
	return fac[n]*inv[m]%mo*inv[n-m]%mo;
}
void Pre(int p,LL a[],int n){
    a[0]=fac[1]=a[1]=1;
    for(int i=2;i<=n;i++){
    	fac[i]=1ll*fac[i-1]*i%p;
        a[i]=1ll*(p-p/i)*a[p%i]%p;
    }
    for(int i=2;i<=n;i++)a[i]=a[i]*a[i-1]%p;
}
int main(){
	Pre(mo,inv,maxn);
	int x,y;scanf("%d%d",&x,&y);
	if((x+y)%3)return puts("0"),0;
	if(y>2*x||x>2*y)return puts("0"),0;
	int t=(x+y)/3;
	x-=t,y-=t;;
	printf("%lld",C(x+y,x));
	return 0;
}

Measured memory_bytes: 16380
# input
n = int(input())
A = list(map(int, input().split()))

if n % 2 == 0:
    for i in range(n - 1, 0, -2):
        print(A[i], end = " ")
    for j in range(0, n - 1, 2):
        print(A[j], end = " ")
else:
    for i in range(n - 1, -1, -2):
        print(A[i], end = " ")
    for j in range(1, n - 1, 2):
        print(A[j], end = " ")

Measured memory_bytes: 25744
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> $1 = new ArrayList<>();
		ArrayList<Integer> $2 = new ArrayList<>();
		ArrayList<Integer> $3 = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			$1.add(sc.nextInt());
		}
		for(int i = 0; i < n; i++) {
			$2.add(sc.nextInt());
		}
		for(int i = 0; i < n; i++) {
			$3.add(sc.nextInt());
		}
		$1.sort(null);$2.sort(null);$3.sort(null);
		long ans = 0L;
		for(int i = 0; i < n; i++) {
			int s = $2.get(i);//中央を全探索
			long ok1 = 0L;
			long ok3 = 0L;
			//lower_bound
			ok1 = Collections.binarySearch($1, s, (Integer x, Integer y) ->  (x.compareTo(y) >= 0 ? 1 : -1));
			ok1 = ok1 >= 0 ? ok1 : ~ok1;
			//upper_bound
			ok3 = ~Collections.binarySearch($3, s, (Integer x, Integer y) ->  (x.compareTo(y) > 0 ? 1 : -1));
			ok3 = ok3 >= 0 ? ok3 : ~ok3;
			ok3 = $3.size() - ok3;
			//System.out.println(String.format("%sのとき$1は%s  $3は%s", s,ok1,ok3));
			ans += ok1 * ok3;
			//System.out.println(ans);
		}
		System.out.println(ans);
	}
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = (n-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

const int MAX_V = 100005;
vector<int> to[MAX_V];
bool seen[MAX_V];


int dfs(int s){
    seen[s] = true;
    if(to[s].empty()) return 1;
    else return dfs(to[s][0]) + 1;
}

int main(){
    int n, k; cin>>n>> k;
    int R, S, P; cin>>R>>S>>P;
    string t; cin >> t;

    for(int i = 0; i < n-k; i++){
        if(t[i] == t[i+k]){
            to[i].push_back(i+k);
        }
    }

    long ans = 0;
    rep(i, n){
        if(!seen[i]){
            int res = (dfs(i) + 1) / 2;
            int po;
            if(t[i] == 'r') po = P;
            else if(t[i] == 's') po = R;
            else po = S;
            ans += po * res;
        }
    }

    cout << ans << endl;
}

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

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

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

    vector<long long> dp(n, 0);
    long long max_sell = A[n-1];
    long long max_value = 0;
    for(int i = n-2; i >= 0; i--){
        //cout << n-2 << endl
        dp[i] = max(dp[i], max_sell - A[i]);
        max_sell = max(max_sell, A[i]);
        max_value = max(max_value, dp[i]);
    }

    /*for(int i = 0; i < n; i++){
        cout << i << " " << dp[i] << endl;
    }*/

    int cost = 0;
    for(int i = 0; i < n; i++){
        if(dp[i] == max_value) cost++;
    }

    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 1792
data = input()
data = data.split(" ")

n_large = int(data[0])
t_large = int(data[1])

data = input()
data = data.split(" ")
ts = []
for d in data:
	ts.append(int(d))

max = ts[n_large - 1] + t_large
decrease = 0
for i in range(0, n_large - 1):
	a = ts[i + 1] - ts[i]
	if a > t_large:
		b = a - t_large
		decrease += b
print(max - decrease)

Measured memory_bytes: 26836
import sys
import collections
import bisect
import math
import time


def main():
    n = input()
    if len(n) == 1:
        print(int(n))
        return

    if len(n) - list(n).count("0") >= 2:
        print(sum(list(map(lambda x: int(x), list(n)))))
        return

    if n[0:2] == "10":
        print(10)
        return

    print(n[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9460
def abc():
    n = int(input())
    ans = 1
    max_cnt = 0
    for i in reversed(range(1, n + 1)):
        cnt = 0
        tmp = i
        while True:
            if tmp % 2:
                break
            tmp //= 2
            cnt += 1
        if cnt > max_cnt:
            max_cnt = cnt
            ans = i
    print(ans)


abc()


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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> cnt(N, 1);
  vector<bool> red(N, false);
  red[0] = true;
  REP(i,M) {
    int x, y;
    cin >> x >> y; x--; y--;
    if(red[x]) {
      if(cnt[x] == 1) {
        red[x] = false;
      }
      red[y] = true;
    }
    cnt[x]--;
    cnt[y]++;
  }
  int res = 0;
  REP(i,N) res += red[i];
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}
ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (ll j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}



int main() {
	ll n, k;
	cin >> n >> k;
	ll a = 0,b=0;
	if (k % 2 == 0) {
		for (ll i = 1; i <= n; i++) {
			if (i % k == 0 ) {
				a++;
			}
			if (i % k == k/2 )b++;
		}
	}
	else {
		for (ll i = 1; i <= n; i++) {
			if (i % k == 0) {
				a++;
			}
		}
	}
	ll ans = a * a * a + b*b*b;
	cout << ans << endl;
	return 0;
}













Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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





///////////////////////////


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

	ll ans = 0;

	repn(i, 9) {
		rep(j, 10) {
			rep(k, 10) {
				ll N = 10001 * i + 1010 * j + 100 * k;
				if (A <= N && N <= B) { ans++;}
			}
		}
	}

	cout << ans;

	system("PAUSE");

}


Measured memory_bytes: 504
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int[] imos = new int[N];
		for(int i=0;i<N;++i) imos[i] = 0;
		for(int i=0;i<N;++i){
			char muki = S.charAt(i);
			if(muki=='E'&&i!=(N-1)){
				imos[i+1]++;
			}else if(muki=='W'&&i!=0){
				imos[0]++;
				imos[i]--;
			}
		}
		
		int ans = imos[0];
		//System.out.print(imos[0]+" ");
		for(int i=1;i<N;++i){
			imos[i] += imos[i-1];
			if(imos[i]>ans) ans = imos[i];
			//System.out.print(imos[i]+" ");
		}
		//System.out.println();
		System.out.println(N-1-ans);
		return;
	}
}

Measured memory_bytes: 29072
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    ans = 0
    suma = a[-1]
    for i in range(n - 2, -1, -1):
        ans += a[i] * suma
        suma = (suma + a[i]) % mod
    print(ans % mod)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 31612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#ifdef PAPITAS
	#define DEBUG 1
#else
	#define DEBUG 0
#endif
#define _DO_(x) if(DEBUG) x

int main()
{
	ios::sync_with_stdio(false);cin.tie(NULL);
	int n;
	cin >> n;
	int arr[n];
	ll a = 0, b = 0, sa = 0, sb = 0;
	for(int i = 0; i< n; i++){
		cin >> arr[i];
	}
	for(int i = 0; i < n; i++){
		sa += arr[i];
		sb += arr[i];
		if(i%2 == 0){
			if(sa <= 0){
				a += 1 - sa;
				sa = 1;
			}
			if(sb >= 0){
				b += sb + 1;
				sb = -1;
			}
		}else{
			if(sa >= 0){
				a += sa + 1;
				sa = -1;
			}
			if(sb <= 0){
				b += 1 - sb;
				sb = 1;
			}
		}
	}
	cout << min(a, b);
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
unordered_set<ll> s;
vector<ll> ans;
void build(){
    queue<ll> q;
    q.push(1LL);
    q.push(2LL);
    q.push(3LL);
    q.push(4LL);
    q.push(5LL);
    q.push(6LL);
    q.push(7LL);
    q.push(8LL);
    q.push(9LL);
 
    while(sz(q)){
        ll a = q.front();
        s.insert(a);
        q.pop();
        if(sz(s) <= 100000)
        for(int i = 0; i <= 9; i++){
            if(abs(a % 10 - i) <= 1 && a * 10 + i <= 3234566667){
                ll nw = a * 10 + i;
                s.insert(nw);
                q.push(nw);
            }
        }
    }
}
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    build();
    fori(i, s)
        ans.pb(*i);
    sort(all(ans));
    int k, q;
    //cin >> q;
    //w(q){
        cin >> k;
        cout << ans[k - 1] << '\n';
    //}
    //cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}   

Measured memory_bytes: 6564
from collections import deque
S = input()
d = deque()
for s in S:
  if len(d) == 0:
    d.append(s)
  elif s == "T":
    if d[-1] == "S":
      d.pop()
    else:
      d.append(s)
  elif s == "S":
    d.append(s)
print(len(d))

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003;

int main(){
    
    int N,L;cin>>N>>L;
    vector<ll> A(N);
    bool flag=false;
    int a=-1;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(A[i]>=L){
            flag=true;
            a=i+1;
        }
    }
    if(flag){
        cout<<"Possible"<<endl;
        for(int i=1;i<=N-1;i++){
            if(a==i) continue;
            cout<<i<<endl;
        }
        if(a!=N) cout<<a<<endl;
    }else{
        for(int i=1;i<N;i++){
            if(A[i-1]+A[i]>=L){
                flag=true;
                a=i;
            }
        }
        if(flag){
            cout<<"Possible"<<endl;
            for(int i=1;i<a;i++){
                cout<<i<<endl;
            }
            for(int i=N-1;i>=a;i--){
                cout<<i<<endl;
            }
        }else cout<<"Impossible"<<endl;
    }
}


Measured memory_bytes: 1664
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from bisect import insort_left

def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    
    if sum(A) < sum(B):
        print(-1)
        exit()

    ok = []
    ng_cnt = 0
    ng_num = 0
    for i in range(N):
        if A[i] - B[i] >= 0:
            ok.append(A[i] - B[i])
        else:
            ng_cnt += 1
            ng_num += B[i] - A[i]
    ok.sort()

    ans = ng_cnt

    while ng_num > 0:
        ans += 1
        ng_num -= ok.pop()

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 73648
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();
        int d = sc.nextInt();
        
        int i,x=0;
        for(i = l;i <= r;i++){
            if(i % d == 0){
                x++;
            }
        }
        System.out.println(x);

        
    }
}

Measured memory_bytes: 35776
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, a;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a % 2 || a % 3 == 0 || a % 5 == 0) continue;
        cout << "DENIED\n";
        return 0;
    }
    cout << "APPROVED\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int check(int p, int n, int k, int w[] )
{
	int i = 0;
	for( int j = 0; j < k; j++ ){
		int s = 0;
		while( s + w[i] <= p ){
			s += w[i];
			i++;
			if( i == n ){
				break;
			}
		}
	}
	return i;
}

int main(void)
{
	int n, k, i;
	scanf( "%d %d", &n, &k );
	int w[n];
	for( i= 0; i < n; i++ ){
		scanf( "%d", &w[i] );
	}
	
	int right = 100000 * 10000, left = 0, mid;
	
	while( right - left > 1 ){
		mid = (right+left) / 2;
		int v = check(mid, n, k, w);
		if( v >= n ){
			right = mid;
		}else{
			left = mid;
		}
	}
	
	printf( "%d\n", right );
	
	return 0;
}


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

int main(void){
  int num;
  while(cin>>num,num){
    int cnt = 0;
    for(int i = 0 ; i <= num ; i ++){
      int now = i;
      if(now/5){
	while(now%5==0){
	  cnt ++;
	  now /= 5;
	}
      }      
    }
    cout<<cnt<<endl;
  }
} 

Measured memory_bytes: 1160
#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=5e18;

ll gcd(ll a,ll b) {
  if(b==0) {
    return a;
  }
  else {
    return gcd(b,a%b);
  }
}

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

int main() {
  ll a,b,k;
  cin >> a >> b >> k;
  vec ans=divisor(gcd(a,b));
  sort(ans.rbegin(),ans.rend());
  cout << ans[k-1] << endl;
}

Measured memory_bytes: 256
import collections
def myAnswer(N:int,A:list)-> None:
   dic = collections.Counter(A)
   total =0
   for value in dic.values():
      total += value * (value -1) //2
   for a in A:
      print(total - (dic[a]-1))


def modelAnswer():
   return
def main():
   N = int(input())
   A = list(map(int,input().split()))
   myAnswer(N,A[:])
if __name__ == '__main__':
   main()

Measured memory_bytes: 25892
N = list(map(str,input()))
n = 3

for i in range(8):
    PlusMinus = ["-"] * 3
    for j in range(3):
        if ((i >> j) & 1):
            PlusMinus[n - j - 1] = "+"
    if eval(N[0] + PlusMinus[0] + N[1] + PlusMinus[1] + N[2] + PlusMinus[2] + N[3]) == 7:
        print(N[0] + PlusMinus[0] + N[1] + PlusMinus[1] + N[2] + PlusMinus[2] + N[3] + "=7")
        break

Measured memory_bytes: 3064
#include <stdio.h>
void sort(int *card)
{
	int i, j, temp;
	
	for (i = 0;i < 5;i++) {
		for (j = 0;j < 4-i; j++) {
			if (card[j] < card[j+1]) {
				temp = card[j];
				card[j] = card[j+1];
				card[j+1] = temp;
			}
		}
	}
}

int main(void)
{
	int number[5];
	scanf("%d %d %d %d %d", &number[0] ,&number[1], &number[2], &number[3], &number[4]);
	sort(number);
	printf("%d %d %d %d %d\n", number[0] ,number[1], number[2], number[3], number[4]);
	return 0;
}

Measured memory_bytes: 0
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from operator import itemgetter

N,M = map(int,readline().split())
m = map(int,read().split())
AB = sorted(zip(m,m),key=itemgetter(1))

answer = 0
x = 0
for a,b in AB:
    if a <= x:
        continue
    x=b-1
    answer += 1

print(answer)

Measured memory_bytes: 26808
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        css: [[i64; 10]; 10],
        a_ss: [[i64; w]; h],
    }
    let mut costs = vec![std::i64::MAX; 10];
    costs[1] = 0;
    let mut deque = std::collections::VecDeque::new();
    deque.push_back((1, 1));
    while let Some((cur, _prev)) = deque.pop_front() {
        for next in 0..10 {
            if css[next][cur] + costs[cur] < costs[next] {
                deque.push_back((next, cur));
                costs[next] = css[next][cur] + costs[cur];
            }
        }
    }
    let mut count = 0i64;
    for a_s in a_ss {
        for a in a_s {
            if a != -1 {
                count += costs[a as usize];
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2576
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		double T = sc.nextDouble();
		int now = 0;
		int ans = 0;
		for (int i = 1; now <= T; i++) {
			now = A * i;
			ans = B * (i - 1);
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

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

    vector<int> a;

    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        a.push_back(x);
    }

    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        int k;
        cin >> k;
        printf("%lld\n",lower_bound(a.begin(), a.end(), k)-a.begin());
    }
    return 0;
}


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

#ifdef DEBUG
#include "debug.h"
#endif

using namespace std;

#define mp make_pair
#define mt make_tuple
#define all(a) (a).begin(), (a).end()
#define rep(i, a, b) for (int (i) = (a); (i) < (b); ++(i))
#define sz(a) ((int)(a).size())
#define make_unique(a) (a).resize(unique(all((x))) - (x).begin())

typedef long long ll;

template<typename T> inline bool mmin(T& a, const T &b) { return a < b ? (a = b, true) : false; }
template<typename T> inline bool mmax(T& a, const T &b) { return a > b ? (a = b, true) : false; }

const int maxn = 1 << 19;
int a[maxn];

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    for (int i = 0; i < (1 << n); ++i) {
        cin >> a[i];
    }
    int res = a[0] + a[1];
    cout << res << '\n';
    for (int i = 2; i < (1 << n); ++i) {
        int m1 = a[0], m2 = 0;
        for (int mask = i; mask > 0; mask = (mask - 1) & i) {
            if (a[mask] > m1) {
                m2 = m1;
                m1 = a[mask];
            } else if (a[mask] > m2) {
                m2 = a[mask];
            }
        }
        res = max(res, m1 + m2);
        cout << res << '\n';
    }
    
    return 0;
}

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


int main(){
    while(true){
        int H, W;
        cin >> H >> W;
        if(H==0&&W==0) break;
        for(int row=0; row<H; row++){
            for(int col=0; col<W; col++){
                if((row+col)%2==0){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
    int r,c;
    int sheet[10000] = {0};
    int i, j;
    int lsum;
    int sum[101] = {0};
    
    scanf("%d %d", &r, &c);
    for (i = 0; i < r; i++)
    {
        for (j = 0; j < c; j++)
        {
            scanf("%d", &sheet[i * c + j]);
        }
    }
    for (i = 0; i < r; i++)
    {
        lsum = 0;
        for (j = 0; j < c; j++)
        {
            lsum += sheet[i * c + j];
            sum[j] += sheet[i * c + j];
            printf("%d ", sheet[i * c + j]);
        }
        sum[c] += lsum;
        printf("%d\n", lsum);
    }
    for (j = 0; j < c; j++)
    {
        printf("%d ", sum[j]);
    }
    printf("%d\n", sum[c]);

    return 0;
}


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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;

  if (a < b) {
    string ans = "";
    for (int i = 0; i < b; ++i) {
      ans += (a + '0');
    }
    cout << ans << endl;
  } else {
    string ans = "";
    for (int i = 0; i < a; ++i) {
      ans += (b + '0');
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 256