akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    long long waru = 1000000007;
                     
    long long N,ans=1;
    cin >> N;

    for(int i =1;i<=N;i++){
        ans = ans * i %waru;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

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



Measured memory_bytes: 256
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o A.exe A.cpp 
Execute: ./A
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int L, R, D; 
	cin >> L >> R >> D; 
	int a, b, result; 
	
	if(L % D == 0) 
		a = L/D; 
	else 
		a = L/D + 1; 
		
	b = R/D; 
	
	cout << b - a + 1 << endl; 
	
	return 0; 
} 


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n;
double x;

int main(){
	cin>>n>>x;
	cout<<((ll)(x*100+eps))*n/100<<endl;
}

Measured memory_bytes: 3728
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

ll conb(ll n){
  return n*(n-1)/2;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N, 0);
  vector<int> ball(N, 0);

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

  ll ans;
  for(int i = 0; i < N; ++i){
    ans += conb(ball[i]);
  }

  for(int i = 0; i < N; ++i){
    cout << ans - ball[A[i]] + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	string s;
	cin>>s;
	bool ans=true;
	if(s[0]!='A'){
		ans=false;
	}
	ll cnt=0,cnt2=0;
	for(int i=2;i<s.size()-1;i++){
		if(s[i]=='C'){
			cnt++;
		}
	}
	if(cnt!=1){
		ans=false;
	}
	for(int i=0;i<s.size();i++){
		char c=s[i];
		if(c>='a'){
			continue;
		}
		cnt2++;
	}
	if(cnt2!=2){
		ans=false;
	}
	cout <<(ans? "AC":"WA");
	return 0;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;

vector<vector<ll>> c;

void mk_c(){
    c.resize(3100);
    for(int i=0;i<2100;i++){
        c[i].resize(3100);
        c[i][0]=1;
        c[i][i]=1;
        for(int t=1;t<i;t++){
            c[i][t]=(c[i-1][t-1]+c[i-1][t])%MOD;
        }
    }
}

int main(){
    ll n,k;
    cin>>n>>k;
    n-=k;
    if(n<0){cout<<0<<endl; return 0;}
    //if(n==0){cout<<1<<endl; return 0;}
    mk_c();
    cout<<c[n+k-1][k-1]<<endl;
    
    
    
    
    return 0;
}



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

int main(){
  string s, t;
  cin >> s >> t;
  bool res = false;
  int size = s.size();
  for(int k=0;k<size; k++){
    char st = s[0];
    for(int i=0; i<size-1; i++){
      s[i] = s[i+1];
    }
    s[size-1] = st;
    //cout << s << endl;
    if(s == t){
      cout << "Yes" << endl;
      res = true;
      break;
    }
  }
  if(res == false) cout << "No" << endl;
}
  

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

String S = sc.next();
int count = 0;
int j = 1;
int restricao = 0;

for (int i = 0; i < S.length(); i++) {
restricao++;
if (S.substring(i, j).equals("x")) {
count++;
}
j++;
}

if (restricao >= 1 && restricao <= 15) {
if (count < 8) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}

}

}


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

char getGrade(int m,int f,int r){
	int sum = m + f;
	char grade;
	if (m == -1 || f == -1) {
		grade = 'F';
	}
	else if (80 <= sum) {
		grade = 'A';
	}
	else if (65 <= sum&&sum < 80) {
		grade = 'B';
	}
	else if (50 <=sum&&sum < 65) {
		grade = 'C';
	}
	else if (30 <= sum&&sum < 50) {
		if (50 <= r)grade = 'C';
		else grade = 'D';
	}
	else if (sum < 30) {
		grade = 'F';
	}
	return grade;
}

int main() {
	int m, f, r;
	while (1) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1)break;
		cout << getGrade(m, f, r) << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
length=input()
array=[]
for i in range(int(length)):
  s=input()
  s=s.split(' ')
  array.append([i+1,s[0],s[1]])
  
array=sorted(array,key=lambda x:(x[1],-int(x[2])))
for i in array:
  print(i[0])

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

int main(){
    ll n,a;
    cin >> n >>a;
    
    cout << n*n-a << endl;
    
    return 0;
}



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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// 解説解答
// 各行で横棒全探索
// O(h*w*2^(w-1))でざっくり100*10*1000で間に合う

const int mod = 1e9 + 7;

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

	int h, w, k;
	cin >> h >> w >> k;

	int dp[h+1][w];
	rep(i, h+1) rep(j, w) dp[i][j] = 0;
	dp[0][0] = 1;

	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			for(int k = 0; k < (1 << (w-1)); k++){

				// 2連続横棒のあみだくじは無効なので排除
				bool ok = true;
				for(int l = 0; l <= w-3; l++){
					if((k >> l) & 1 && (k >> l+1) & 1) {
						ok = false;
						break;
					}
				}

				if(!ok) continue;

				if(j-1 >= 0 && ((k >> j-1) & 1)){
					// 左に横棒があるケース
					dp[i+1][j] += dp[i][j-1];
					dp[i+1][j] %= mod;
				}else if(j <= w-2 && ((k >> j) & 1)){
					// 右に横棒があるケース
					dp[i+1][j] += dp[i][j+1];
					dp[i+1][j] %= mod;
				}else{
					// その他（両脇に横棒がない）
					dp[i+1][j] += dp[i][j];
					dp[i+1][j] %= mod;
				}
			}
		}
	}

	cout << dp[h][k-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef pair<pll,int> ppi;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];

    vector<ppi> ta(N), ao(N);
    REP(i, N){
        ta[i] = {{A[i], B[i]}, i};
        ao[i] = {{A[i], B[i]}, i};
    }

    auto f1 = [](ppi a, ppi b){
        ll da = a.fi.fi + a.fi.se;
        ll db = b.fi.fi + b.fi.se;
        if(da > db) return true;
        else if(da < db) return false;
        else{
            if(a.fi.fi > b.fi.fi) return true;
            else return false;
        }
    };
    auto f2 = [](ppi a, ppi b){
        ll da = a.fi.se + a.fi.fi;
        ll db = b.fi.se + b.fi.fi;
        if(da > db) return true;
        else if(da < db) return false;
        else{
            if(a.fi.se > b.fi.se) return true;
            else return false;
        }
    };

    sort(ALL(ta), f1);
    sort(ALL(ao), f2);

    ll t = 0, a = 0;
    int tid = 0, aid = 0;
    vector<bool> ok(N);
    REP(i, N){
        if(i&1){
            while(ok[ao[aid++].se]){}
            a += B[ao[aid-1].se];
            ok[ao[aid-1].se] = true;
        }else{
            while(ok[ta[tid++].se]){}
            t += A[ta[tid-1].se];
            ok[ta[tid-1].se] = true; 
        }
    }
    pr(t-a);
}

Measured memory_bytes: 9600
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val (x, y, z) = readIntList()
    println("$z $x $y")
}

Measured memory_bytes: 36284
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
const int mod = 1e9 + 7;
int32_t main()
{
   int n; cin >> n;
   int sm = 0;
   int prod = 0;
   fr(_,n){
   	int x; cin >> x;

   	prod += x * sm;
   	prod %= mod;
   	sm += x; sm %= mod;
   	// dbg(prod);dbg(sm);nl;
   }
   cout << prod;

}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {

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

Measured memory_bytes: 764
#include <stdio.h>

int main (void)
{
	int a, b, c, cnt;
	
	while (scanf("%d %d", &a, &b) != EOF)
	{
		c = a+b;
		cnt = 0;
		while (c > 0)
		{
			c /= 10;
			cnt++;
		}
		
		printf("%d\n", cnt);
	}
	
	return 0;
}

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

int main(){
	string S, T;
	cin >> S >> T;

	int count = 0;
	for(int i=0;i<S.size();i++){
		if(S.at(i) != T.at(i)) count++;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3924
#include <stdio.h>
  
int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
  
    int i, cnt = 0;
    for( i = a; i <= b; ++i )
        if( c % i == 0 )
            ++cnt;
  
    printf("%d\n", cnt);
  
    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;

ll a,b,k,ans;

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	cin >> k >> a >> b;
	if(1+k <= a||b-a <= 2)ans = k+1;
	else ans = a+(k-a+1)/2*(b-a)+((k-a+1)&1);
	cout << ans;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  ll h,n;cin >> h>>n;
  ll inf = mod;
  vector<ll> a(n),b(n);
  for(ll i=0;i<n;++i)cin>>a[i]>>b[i];
  vector<vector<ll>> dp(6*h+1, vector<ll>(n+1, inf));
  for(ll i=0;i<n+1;++i)dp[0][i] = 0;
  ll out =inf;
  for(ll j=1;j<=6*h;++j){
    for(ll i=1;i<=n;++i){
      if(j-a[i-1]>=0){
        dp[j][i] = min(dp[j-a[i-1]][i] + b[i-1],dp[j][i-1]);
      } else {
        dp[j][i] = dp[j][i-1];
      }
    }
    if(j>=h)out = min(out,dp[j][n]);
  }
  /*for(int i=0;i<=n;++i){
    cout << dp[h][i] << " ";
  }*/
  //cout << endl;
  cout << out << endl;
  return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if ((a+b)%2==1){
    cout << (a+b)/2 + 1 <<endl; 
    }
    else {
      cout << (a+b)/2 <<endl;
    }
}

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

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  int l,r,d;
  cin>>l>>r>>d;
  cout<<r/d-(l-1)/d;
}


Measured memory_bytes: 3632
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

mod = 10**9+7
a.append(float('INF'))
a = a[::-1]
dp = [0] * (n+1)
dp[0] = 1
if a[-1] != 1:
    dp[1] = 1
else:
    a.pop()
for i in range(2, n+1):
    if i == a[-1]:
        a.pop()
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= mod
print(dp[n])

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

#if USE_CP_REDIR
#define CP \
    freopen("input.txt","r", stdin); \
    freopen("output.txt","w", stdout);
#endif

int main()
{
#ifdef CP
    CP;
#endif

    int N,M,K;
    cin >> N >> M >> K;
    vector<int> A(N), B(M);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < M; i++) cin >> B[i];
    vector<long long> pA(A.size()+1, 0LL), pB(B.size()+1, 0LL);
    for(int i = 0; i < N; i++) pA[i+1] = A[i]*1LL + pA[i]; 
    for(int i = 0; i < M; i++) pB[i+1] = B[i]*1LL + pB[i];
    int j = M;
    int res = 0;
    for(int i = 0; i <= N; i++)
    {
        if(pA[i] > K) break;
        while(pB[j] > K - pA[i]) --j;
        res = max(res, i + j);
    }
    cout << res << endl;
}



Measured memory_bytes: 7988
using System;
using System.Linq;
class p
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string[] input = Console.ReadLine().Split(' ');
    int[] arr = new int[N];
    for (int i = 0; i < N; i++) {
      arr[i] = int.Parse(input[i]);
    }
    Console.WriteLine(arr.Max() - arr.Min());
  }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, k, *l;
    cin >> n >> k;
    int i;
    l = new int[n];
    for (i = 0; i < n; i++)
        cin >> l[i];
    
    sort(l, l+n, greater<int>());

    int ans = 0;

    for (i = 0; i < k; i++) {
        ans += l[i];
    }

    cout << ans << endl;

    return 0;
}

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

const int N=2e5+10;
const ll INF=1e18;
ll a[N],s[N];

void solve(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",a+i),s[i]=s[i-1]+a[i];
    ll ans=INF;
    for(int i=1;i<=n;i++){
        ans=min(ans,abs(2*s[i-1]-s[n]));
    }
    printf("%lld\n",ans);
}

int main(){

    solve();
    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  ll ans=0;
  ll pow=1;
  rep(i,60){
    ll one=0, zero=0;
    rep(j,n){
      if((a[j]>>i)&1){
        one++;
      }else{
        zero++;
      }
    }
    
    ans+=(one*zero)%MOD*pow%MOD;
    ans%=MOD;
    pow*=2;
    pow%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;
 	
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	string a;

 	cin>>a;
 	set<char>s;
 	for(auto c : a)s.insert(c);

 	if(sz(s)>1)cout<<"Yes\n";
 	else	cout<<"No\n";
 	
}		


Measured memory_bytes: 256
n,m=gets.split(" ").map(&:to_i)
input = []
while line=gets
  break if line.chomp.empty?
  input<<line.split(" ").map(&:to_i)
end

robots = []
input.each do |pos, len|
  robots << [pos - len, pos + len]
end

ok = []
right = nil
robots.sort {|a,b| a[1] <=> b[1] }.each do |start, fin|
  right = start unless right
  if right <= start
    ok << [start, fin]
    right = fin
  end
end

p ok.length

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

int main(){
    double a,b,x;
    cin>>a>>b>>x;
    double th=a*a*b/2;
    double ans,rad;
    if(x<=th){
        rad=atan(b*b*a/(2*x));
        ans=rad*180/M_PI;
    }else{
        rad=atan(2*(2*th-x)/pow(a,3));
        ans=rad*180/M_PI;
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 384
def main():
    def is_prime(n):
        for i in range(2, int(n ** 0.5) + 1):
            if n % i == 0:
                return False
        return True

    x = int(input())

    if x <= 2:
        print(2)
        return

    if x % 2 == 0:
        x += 1

    while not is_prime(x):
        x += 2

    print(x)


if __name__ == '__main__':
    main()


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

int time (int t, int c, int s, int f) {
  if(t < s) {
    return s - t + c;
  } else {
    int wait = 0;
    for(int i=0;i<f;i++) {
      if((t+i)%f==0) {
        wait = i;
        break;
      }
    }
    return wait + c;
  }
}

int main() {
  int n;
  cin >> n;
  vector<tuple<int, int, int>> train(n-1);

  for(int i=0;i<n-1;i++) {
    int a, b, c;
    cin >> a >> b >> c;
    tuple<int, int, int> t = make_tuple(a, b, c);

    train[i] = t;
  }
  for(int i=0;i<n-1;i++) {
    int result = 0;
    for(int j=i;j<n-1;j++) {
      result += time(result, get<0>(train[j]), get<1>(train[j]), get<2>(train[j]));
    }
    cout << result << endl;
  }

  cout << 0 << endl;
}

Measured memory_bytes: 256
n = int(input())
vs = list(map(int,input().split()))

dic1 = {}
dic2 = {}
for i in range(n):
    if i % 2 == 0:
        if vs[i] in dic1:
            dic1[vs[i]] += 1
        else:
            dic1[vs[i]] = 1
    else:
        if vs[i] in dic2:
            dic2[vs[i]] += 1
        else:
            dic2[vs[i]] = 1

max1_1 = 0
max1_2 = 0
num1_1 = -1
num1_2 = -1
for key in dic1.keys():
    x = dic1[key]
    if x >= max1_1:
        tmp = max1_1
        max1_1 = x
        max1_2 = tmp
        tmp = num1_1
        num1_1 = key
        num1_2 = tmp

    elif x > max1_2:
        max1_2 = x
        num1_2 = key

max2_1 = 0
max2_2 = 0
num2_1 = -1
num2_2 = -1
for key in dic2.keys():
    x = dic2[key]
    if x >= max2_1:
        tmp = max2_1
        max2_1 = x
        max2_2 = tmp
        tmp = num2_1
        num2_1 = key
        num2_2 = tmp

    elif x > max2_2:
        max2_2 = x
        num2_2 = key

if num1_1 != num2_1:
    ans = n - max1_1 - max2_1
else:
    x = max1_1 + max2_2
    y = max1_2 + max2_1
    ans = min(n - x,n - y)
print(ans)


Measured memory_bytes: 88216
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define N 998244353

int main() {
    int n;
    cin >> n;
    long long int v[n];
    long long int max_v = 0;
    long long int array[n];
    for(int i = 0; i < n; i++) array[i] = 0;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        array[v[i]]++;
        max_v = max(max_v, v[i]);
    }

    long long int ans = 1;
    
    for(int i = 1; i <= max_v; i++) {
        //long long int tmp = array[i];
        //long long int tmp2 = array[i-1];
        for(int j = 0; j < array[i]; j++) {
            ans = ans * array[i-1] % N;
        }
    
    }

/*
    if(array[0] == 1 && !v[0]) {
        cout << ans%N << endl;
    }
    else {
        cout << 0 << endl;
    }
*/
    cout << ((!v[0] && array[0] == 1) ? ans : 0) << endl;
    return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
	s = input()
	a = int(s[0:2])
	b = int(s[2:4])
	if 1 <= a and a <= 12:
		if 1 <= b and b <= 12:
			print("AMBIGUOUS")
		else:
			print("MMYY")
	else:
		if 1 <= b and b <= 12:
			print("YYMM")
		else:
			print("NA")

if __name__ == '__main__':
	import sys
	sys.exit(main())


Measured memory_bytes: 2940
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min({6,k-i+1})):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Measured memory_bytes: 5040
import Control.Monad
import qualified Data.Map as Map


main = do
    n <- readLn
    nums <- replicateM n getLine
    print $ Map.size $ Map.filter odd $ countByValue nums


countByValue :: [String] -> Map.Map String Int
countByValue [] = Map.empty
countByValue (x:xs) = Map.insertWith (+) x 1 $ countByValue xs


Measured memory_bytes: 90492
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int a,b,c;
    cin>>a>>b>>c;
    if (a>=b&&a>=c) {
        if (a%2==0) {
            cout<<abs((a/2)*b*c-(a/2)*b*c)<<endl;
        } else {
            cout<<abs((a/2)*b*c-(a/2+1)*b*c)<<endl;
        }
    } else if (b>=a&&b>=c) {
        if (b%2==0) {
            cout<<abs((b/2)*a*c-(b/2)*a*c)<<endl;
        } else {
            cout<<abs((b/2)*a*c-(b/2+1)*a*c)<<endl;
        }
    } else {
        if (c%2==0) {
            cout<<abs((c/2)*b*a-(c/2)*b*a)<<endl;
        } else {
            cout<<abs((c/2)*b*a-(c/2+1)*b*a)<<endl;
        }
    }
}

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N;cin>>N;
	for(int i=0;i<N;i++){
		int a[3];
		cin>>a[0]>>a[1]>>a[2];
		sort(a,a+3);
		if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2])cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
	}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PSET(x,y) fixed<<setprecision(y)<<x
int32_t main(){
    int n;    cin>>n;
    double ans=0;
    for(int i=0;i<n;++i){
        int x;  cin>>x;
        ans+=1/(double)x;
    }
    ans=1/(double)ans;
    cout<<PSET(ans,7);
}

Measured memory_bytes: 256
N, M = map(int,input().split())
ac = [0] * N
wa = [0] * N
for i in range(M):
    p, s = map(str,input().split())
    num = int(p)-1
    if s == 'WA' and ac[num] == 0: 
        wa[num] += 1
    elif s == 'AC' and ac[num] == 0:
        ac[num] += 1

for i in range(N):
    if ac[i] == 0:
        wa[i] = 0

print('{} {}'.format(sum(ac), sum(wa)))

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;

struct PT{
	int x, y, id;
	PT(int _x = 0, int _y = 0, int _id = -1){
		x = _x; y  = _y; id = _id;
	}
};

bool cmp1( PT a, PT b){
	return mp(a.x, a.y) < mp(b.x, b.y);
}
bool cmp2( PT a, PT b){
	return mp(a.y, a.x) < mp(b.y, b.x);
}

struct Edge{
	int u, v;
	ll w;
	Edge(int _u, int _v, ll _w){
		u = _u; v = _v; w = _w;
	}
};

bool cmp3(Edge a, Edge b){
	return a.w < b.w;
}
const int MAXN = 1e5+100;
vector<PT> data;
vector<Edge> edges;

int p[MAXN];


int getParent(int u){
	return u == p[u] ? u : p[u] = getParent(p[u]);	
}

bool merged(int u, int v){
	int pu = getParent(u);
	int pv = getParent(v);
	return pu == pv;
}

void merge(int u ,int v){
	int pu = getParent(u);
	int pv = getParent(v);
	p[pu] = pv;
}

int main(){
	int n;
	cin >> n;
	REP(i,0,n){
		int x, y;
		cin >> x >> y;
		data.pb(PT(x,y,i));
	}
	
	sort(data.begin(),data.end(), cmp1);
	REP(i,1,data.size()){
		int u = data[i-1].id;
		int v = data[i].id;
		edges.pb(Edge(u,v,abs(data[i].x - data[i-1].x)));
	}
	
	sort(data.begin(), data.end(), cmp2);
	REP(i,1,data.size()){
		int u = data[i-1].id;
		int v = data[i].id;
		edges.pb(Edge(u,v,abs(data[i].y - data[i-1].y)));
	}

	sort(edges.begin(),edges.end(), cmp3);
	REP(i,0,n) p[i] = i;
	ll cost = 0;
	REP(i,0,edges.size()){
		if(merged(edges[i].u, edges[i].v)) continue;
		cost += edges[i].w;
		merge(edges[i].u, edges[i].v);
	}
	cout<<cost<<endl;

	return 0;
}


Measured memory_bytes: 8560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

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

struct edge {
    int u, v, cost;
    edge() {}
    edge(int u, int v, int cost) : u(u), v(v), cost(cost) {}
};

bool comp(const edge &e1, const edge &e2) {
    return e1.cost < e2.cost;
}

/* UnionFindTree Begin
  --------------------------------------------------------------------------
*/
class UnionFind {
private:
    int size_;
    vector<int> par, rank;
public:
    UnionFind() : size_(0), par(vector<int>(0)), rank(vector<int>(0)) {}
    UnionFind(int size_) : size_(size_) {
        par.resize(size_), rank.resize(size_);
        rep(i,size_) par[i] = i, rank[i] = 0;
    }
    // 現在のsize_を返す
    int size() { return size_; }
    // 親を返す
    int root(int x) { return (par[x] == x) ? x : par[x] = root(par[x]); }
    // ２つの頂点を連結する
    void unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }
    // 親が同じかを判定する
    bool same(int x, int y) { return root(x) == root(y); }
};
/* UnionFindTree End
  --------------------------------------------------------------------------
*/

int n, a, b;
vector<pair<int, int> > x, y;
vector<edge> e;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &a, &b);
        x.push_back(make_pair(a, i));
        y.push_back(make_pair(b, i));
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    long long ans = 0, cnt = 0, size_ = 0;
    UnionFind uf(n);

    for (int i = 1; i < n; ++i) {
        if (x[i].second != x[i-1].second) {
            e.push_back(edge(x[i-1].second, x[i].second, abs(x[i].first - x[i-1].first)));
            size_++;
        }
        if (y[i].second != y[i-1].second) {
            e.push_back(edge(y[i-1].second, y[i].second, abs(y[i].first - y[i-1].first)));
            size_++;
        }
    }

    edge eg;

    sort(e.begin(), e.end(), comp);

    for (int i = 0; i < size_; ++i) {
        eg = e[i];
        if (!uf.same(eg.u, eg.v)) {
            uf.unite(eg.u, eg.v);
            cnt++;
            ans += eg.cost;
            //cout << eg.cost << " " << eg.u << " " << eg.v << endl;
        }

        if (cnt == n - 1) break;
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 7912
# -*- coding: utf-8 -*-
n = int(input())

tasks = list()
for _ in range(n):
    a, b = map(int, input().split())
    tasks.append((a, b))

sorted_tasks = sorted(tasks, key=lambda x: -x[1], reverse=True)

flag = True
time = 0
for a, b in sorted_tasks:
    time += a
    if time > b:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 76760
import copy

def solve():
    ans = 0
    V = [False] * n
    B = sorted(A)
    maxWeight = B[-1]
    minWeight = B[0]
    T = [None] * (maxWeight + 1)
    for i in range(n):
        T[B[i]] = i
        
    for i in range(n):
        if V[i]:
            continue
        
        cur = i
        S = 0
        m = maxWeight
        an = 0
        while True:
            V[cur] = True
            an += 1
            v = A[cur]
            m = min(m, v)
            S += v
            cur = T[v]
            if V[cur]:
                break
        ans += min(S + (an - 2) * m, m + S + (an + 1) * minWeight)
    
    return ans

n = int(input())
A = list(map(int, input().split()))

ans = solve()
print(ans)











Measured memory_bytes: 6412
#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;

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

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



int main() {
    int N,K;
    cin >> N >> K;
    string s;
    cin >> s;

    s[K-1] = (s[K-1]+0x20);

    cout << s << endl;

}



Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, k, w[100010], ma;
signed main() {
	cin >> n >> k;
	rep(i, n) {
		cin >> w[i];
		ma = max(ma, w[i]);
	}
	int ng = 0, ok = INF;
	while (ng + 1 < ok) {
		int md = (ng + ok) / 2;
		if (md < ma) {
			ng = md;
			continue;
		}
		int cnt = 0, ans = 1;
		rep(i, n) {
			if (cnt + w[i] <= md)cnt += w[i];
			else {
				cnt = w[i];
				ans++;
			}
		}
		if (ans <= k)ok = md;
		else ng = md;
	}
	cout << ok << endl;
}


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

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

  vector<int64_t> players(N);
  vector<int64_t> foods(N);
  for(int i=0; i<N; i++){
    cin >> players.at(i);
  }
  for(int i=0; i<N; i++){
    cin >> foods.at(i);
  }
  
  // 初期割当は以下に基づく：
  // a > 0, b1 > b2 > 0 => a* b1 > a* b2  
  sort(players.begin(), players.end());
  sort(foods.begin(), foods.end(), greater<int64_t>());

  // 二分探索で argmin v s.t. Nop(v) <= K を求める
  int64_t inc= 1LL << 40;
  int64_t exc= -1LL;
  while(abs(inc- exc) > 1){
    int64_t mid= (inc+ exc)/ 2;

    int64_t Kmid= 0;
    for(int i=0; i<N; i++){
      Kmid+= max(players.at(i)- mid/foods.at(i), int64_t(0));
    }

    if(Kmid <= K){ inc= mid; }
    else         { exc= mid; }
  }

  cout << inc << endl;
}

Measured memory_bytes: 6348
fun main(args: Array<String>) {
    readLine()
    val a = readLine()!!.split(' ').map(String::toLong)
    val abs = a.map(Math::abs)
    val absmin = abs.min()!!
    val minusc = a.count { it < 0L }
    var ans = abs.sum()
    if (minusc and 1 == 1) {
        ans = ans - absmin - absmin
    }
    println(ans)
}


Measured memory_bytes: 60184
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s);i<(e);i++)
#define rep(i,n) REP(i,0,n)

int main(void) {
  int P, Q, R;
  cin >> P >> Q >> R;
  cout << min(P + Q, min(Q + R, P + R)) << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        UnionFindTree utf = new UnionFindTree(n);
        int[] friends = new int[n];
        for(int i = 0; i < m; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            utf.union(a,b);
            friends[a]++;
            friends[b]++;
        }
        int[] remains = new int[n];
        for(int i = 0; i < n; i++){
            remains[i] = utf.size(i)-friends[i]-1;
        }
        for(int i = 0; i < k; i++){
            int c = sc.nextInt()-1;
            int d = sc.nextInt()-1;
            if(utf.same(c,d)){
                remains[c]--;
                remains[d]--;
            }
        }
        for(int i = 0; i < n; i++){
            if(i == n-1) System.out.println(remains[i]);
            else System.out.print(remains[i] + " ");
            
        }
    }
}

class UnionFindTree {
	int[] parent;
	int[] rank;
	int[] size;
	
	public UnionFindTree(int size) {
		this.parent = new int[size];
		this.rank = new int[size];
		this.size = new int[size];
		
		for (int i = 0; i < size; i++) {
			makeSet(i);
		}
	}
	
	public void makeSet(int i) {
		parent[i] = i;
		rank[i] = 0;
		size[i] = 1;
	}
	
	public void union(int x, int y) {
		int xRoot = find(x);
		int yRoot = find(y);
		
		if (rank[xRoot] > rank[yRoot]) { 
			parent[yRoot] = xRoot;
			size[xRoot] += size[yRoot];
		} else if(rank[xRoot] < rank[yRoot]) {
			parent[xRoot] = yRoot;
			size[yRoot] += size[xRoot];
		} else if (xRoot != yRoot){
			parent[yRoot] = xRoot;
			size[xRoot] += size[yRoot];
			rank[xRoot]++; 
		}
	}
	
	public int find(int i) {
		if (i != parent[i]) {
			parent[i] = find(parent[i]);
		}
		return parent[i];
	}
	
	public boolean same(int x, int y) {
		return find(x) == find(y);
	}

	public int size(int x) {
		return size[find(x)];
	}
}

Measured memory_bytes: 95852
import java.util.*;

public class Main {
	static int ans;
	static String s;
	static ArrayList<String> sArray;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			s = sc.next();
			if (s.equals("#")) {
				break;
			}
			sArray = new ArrayList<String>();
			char[] sca = s.toCharArray();
			//System.out.println(new String(sca));
			ans = 0;
			decode(sca, 0, 0);
			//encode();
			System.out.println(ans);
			for (int i = 0; i < sArray.size(); i++) {
				System.out.println(sArray.get(i));
			}
		}
	}
	
	public static void decode(char[] sca, int pos, int decodeBit) {
		//System.out.println(new String(sca) + " " + sca[0] + " " + pos + " " + sca.length);
		if (pos == sca.length) {
			if (encode(sca)) {
				ans++;
				sArray.add(new String(sca));
				Collections.sort(sArray);
				if (sArray.size() > 10) {
					sArray.remove(5);
				}
			}
			return;
		}
		decode(sca, pos + 1, decodeBit);
		if (sca[pos] != 'z' && (decodeBit & (1 << (sca[pos] - 'a'))) == 0) {
			//System.out.println(sca[pos]);
			sca[pos]++;
			decode(sca, pos + 1, decodeBit | (1 << (sca[pos] - 1 - 'a')));
			sca[pos]--;
		}
	}
	
	public static boolean encode(char[] sca) {
		char[] tmp = Arrays.copyOf(sca, sca.length);
		for (int i = 1; i <= 25; i++) {
			char c = (char)('a' + i);
			for (int j = 0; j < tmp.length; j++) {
				if (tmp[j] == c) {
					tmp[j]--;
					break;
				}
			}
		}
		//System.out.println(sca);
		if (s.equals(new String(tmp))) {
			return true;
		} else {
			return false;
		}
	}
}

Measured memory_bytes: 161496
s=input()
n=len(s)
ans=[0]*n

for i in range(n-1):
  if s[i]=='R' and s[i+1]=='L':
    ans[i]='lastR'
  elif s[i]=='L' and s[i+1]=='R':
    ans[i]='lastL'
ans[n-1]='lastL'

s=-1
for i in range(n):
  if ans[i]=='lastR':
    r=i
    num_r=i-s
  elif ans[i]=='lastL':
    l=i
    num_l=i-r
    if (num_r-num_l)%2==0:
      k=(num_r+num_l)//2
      ans[r]=k
      ans[r+1]=k
    else:
      k=(num_r+num_l+1)//2
      m=k-1
      if num_r%2==0:
        ans[r]=m
        ans[r+1]=k
      else:
        ans[r]=k
        ans[r+1]=m        
    s=i
    if (r+1)!=l:
      ans[i]=0
for i in range(n):
  print(ans[i])
          

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

int main(){
    int N;
    cin >> N;
    int flag = 0;
    vector<long long> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    for(int i=1;i<N;i++){
        if(A[i] == A[i-1]){
            flag++;
            break;
        }
    }

    if(flag == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 1792
N=int(input())
M=[]
s=0

for i in range(5000):
  s+=i+1
  M.append(i+1)
  if s>=N:
    break
    
M=M[::-1]
for i in range(len(M)):
  if s-M[i]>N:
    M[i]=0
    s-=M[i]
  elif s-M[i]==N:
    M[i]=0
    break

for i in M:
  if i:
    print(i)

Measured memory_bytes: 3444
N,M = map(int,input().split())
box = [1]*N
red = [0]*N
red[0] = 1
for i in range(M):
    a,b = map(int,input().split())
    box[a-1] -= 1
    box[b-1] += 1
    if red[a-1] == 1:
        red[b-1] = 1
    if box[a-1] == 0:
        red[a-1] = 0
print(sum(red))

Measured memory_bytes: 51544
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++)cin >> h[i];
    sort(h.begin(), h.end());

    long long ret = 0;
    for (int i = 0; i < n - k; i++)ret += h[i];
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define SIZE 100100

typedef struct {
	int num;
	int cnt;
} count;

//global variables
int N, a[SIZE];

//prototype declarations
void solve();
int counter(int* base, int n, count* dst);

//input
int main() {
	int i;
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", &a[i]);
	solve();
	return 0;
}

//output
void solve() {
	int i, cnt = 0, k;
	count c[SIZE];
	k = counter(a, N, c);
	for (i = 0; i < k; i++) cnt += c[i].cnt - ((c[i].cnt >= c[i].num) ? c[i].num : 0);
	printf("%d", cnt);
}

//fucntions
int counter(int* base, int n, count* dst) {
	int i, temp, cnt, cur;
	int num_sort(const void* a, const void* b) {
		return ((count*)a)->num - ((count*)b)->num;
	}

	for (i = 0; i < n; i++) dst[i].num = base[i];
	qsort(dst, n, sizeof(count), num_sort);

	temp = dst[0].num - 1;
	cur = -1;
	for (i = 0; i < n; i++) {
		if (temp != dst[i].num) {
			temp = dst[i].num;
			cur++;
			dst[cur].num = temp;
			dst[cur].cnt = 1;
		}
		else {
			dst[cur].cnt++;
		}
	}

	cur++;
	return cur;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N+100), B(N+100), C(N+100);
  for (int i; i < N; i++) cin >> A.at(i);
  for (int i; i < N; i++) cin >> B.at(i);
  for (int i; i < N; i++) cin >> C.at(i);
  int satisfaction = 0;
  for (int i; i < N; i++) {
    satisfaction += B.at(i);
    if (A.at(i+1)-A.at(i) == 1) satisfaction += C.at(A.at(i)-1);
  }
  
  cout << satisfaction << endl;
  
}

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



class Memo {
private:
    int N, M, Q;
    vector<int> a;
    vector<int> b;
    vector<int> c;
    vector<int> d;

    vector<int> x;


public:
    int ans;

    Memo(): x(10) {
        ans = 0;
        cin >> N >> M >> Q;
        for(int i = 0; i < Q; i++) {
            int A, B, C, D;
            cin >> A >> B >> C >> D;
            A--;
            B--;
            a.push_back(A);
            b.push_back(B);
            c.push_back(C);
            d.push_back(D);
        }
    }

    void repeat(int p, int m) {
        if(p == N + 1) {
            int count = 0;/*
            for(int i = 0; i < N; i++) {
                cerr << x[i] << " ";
            }
            cerr << endl;*/
            for(int i = 0; i < a.size(); i++) {
                if(x[b[i]] - x[a[i]] == c[i]) count += d[i];
            }
            ans = max(ans, count);
        } else {
            x[p - 1] = m;
            for(int i = m; i <= M; i++) {
                repeat(p + 1, i);
            }
        }
    }
};

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

    Memo memo;
    memo.repeat(1, 1);

    cout << memo.ans << endl;
}

Measured memory_bytes: 3660
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = in.nextInt();
        String X = in.next();

        int[] ans = new int[200000];
        for (int i = 1; i < 200000; i++) {
            int j = i % Integer.bitCount(i);
            ans[i] = ans[j] + 1;
        }

        int pop = 0;
        for (int n = 0; n < N; n++) if (X.charAt(n) == '1')
            pop++;
        int[] rem0 = new int[N];
        int[] rem1 = new int[N];
        for (int n = 0, i0 = 1, i1 = 1; n < N; n++) {
            if (pop > 1) {
                rem0[n] = i0 % (pop - 1);
                i0 = (i0 * 2) % (pop - 1);
            }
            rem1[n] = i1 % (pop + 1);
            i1 = (i1 * 2) % (pop + 1);
        }
        long sum0 = 0;
        long sum1 = 0;
        for (int n = 0; n < N; n++) if (X.charAt(n) == '1') {
            sum0 += rem0[N - n - 1];
            sum1 += rem1[N - n - 1];
        }
        for (int n = 0; n < N; n++) {
            int sum = 0;
            if (X.charAt(n) == '0') {
                sum = (int) ((sum1 + rem1[N - n - 1]) % (pop + 1));
                out.println(ans[sum] + 1);
            } else {
                if (pop > 1) {
                    sum = (int) ((sum0 - rem0[N - n - 1]) % (pop - 1));
                    out.println(ans[sum] + 1);
                } else {
                    out.println(0);
                }
            }
        }


        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 49572
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 using v_i = vector<int>;
 using v_s = vector<string>;
 const int INF = 2147483647;

 int main(){
     int m1,d1,m2,d2;
     cin >> m1 >> d1 >> m2 >> d2;
     if(d1+1==d2) cout << 0 << endl;
     else cout << 1 << endl;
     return 0;
 }

     //int nin = *max_element(a.begin(),p.end());
    //int nax = *max_element(a.begin(),p.end())-p.begin();
    //int min_index = min_element(p.begin(),p.end())-p.begin();
     //sort(l.begin(),l.end(),greater<int>());
     //stringは",charは'
     //ちょっとあやしかったら立ち止まって考える
     //例外処理はreturn忘れずに
     //文字列連結 文字+="aa" でできる

Measured memory_bytes: 256