akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  int n ;
  cin >> n ;
  vector<char> col(n) ;
  int count = 0 ;
  
  REP(i,n){
    cin >> col.at(i) ;
  }
  sort(ALL(col)) ;
  
  if(col.at(n-1)=='Y'){
    cout <<"Four"<<endl ;
  }
  else{
    cout <<"Three"<<endl ;
  }

  return 0 ;
}




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

int main(){
    int a, b; cin >> a >> b;
    int n; cin >> n;
    bool d = false;
    for(int i = 0; i < n; i++){
        int s,t; cin >> s >> t;
        if(a<s && s<b) d=true;
        if(a<t && t<b) d=true;
        if(a<=s && t<=b) d=true;
        if(s<=a && b<=t) d=true;
    }
    cout << (d ? 1 : 0) << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<string>

int main(){
    std::string S, T;
    std::cin >> S >> T;
    int num = 0;
    for(int i = 0; i < 3; i++){
        if(S[i] == T[i]) num++;
    }
    std::cout << num << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 10001
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int tot,n,m,a[N];
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;++i){
		a[i]=read(),tot+=a[i];
	}
	int ans=0;
	for(int i=1;i<=n;++i){
		if(a[i]*4*m>=tot)++ans;
	} 
	printf(ans>=m?"Yes\n":"No\n");
//	getchar();
	return 0;
}


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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 100000;

pair<int, int> shop[MAXN + 2];

int main() {
	int N, M;
	cin >> N >> M;
	for(int i = 0; i < N; i++)
		cin >> shop[i].first >> shop[i].second;
	sort(shop, shop + N);
	ll ans = 0;
	for(int i = 0; M > 0 && i < N; i++) {
		int k = min(M, shop[i].second);
		ans += (ll)k * shop[i].first;
		M -= k;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <unordered_map>
#define CALC_BIT 45

typedef long long ll;

using namespace std;

int get_group(vector<int> &arr, int a) {
	if(arr[a]==0) return a;
	int g = get_group(arr,arr[a]);
	arr[a] = g;
	return g;
}

int set_group(vector<int> &arr, int a, int b) {
	int ag = get_group(arr,a);
	int bg = get_group(arr,b);
	if(ag!=bg) arr[ag] = bg;
}

/*
bool is_same(vector<int> &arr, int a, int b) {
	int ag = get_group(arr,a);
	int bg = get_group(arr,b);
	return ag==bg;
}
*/

int main() {
	int n,k,l;
	cin >> n >> k >> l;
	vector<int> road(n+1);
	vector<int> rail(n+1);
	for(int i = 0; i < k; i++) {
		int a,b;
		cin >> a >> b;
		set_group(road,a,b);
	}
	for(int i = 0; i < l; i++) {
		int a,b;
		cin >> a >> b;
		set_group(rail,a,b);
	}

	unordered_map<ll,int> mp(n);
	for(int i = 1; i <= n; i++) {
		ll key;
		key = get_group(road,i);
		key <<= 32LL;
		key += get_group(rail,i);
		//cout << get_group(road,i) << "," << get_group(rail,i) << endl;
		mp[key]++;
	}
	for(int i = 1; i <= n; i++) {
		ll key;
		key = get_group(road,i);
		key <<= 32LL;
		key += get_group(rail,i);
		cout << mp[key] << endl;
	}

	return 0;
}


Measured memory_bytes: 9472
//package Coding;

import java.util.*;
import java.io.*;
 
 
public class Main 
{   
 
	public static void main(String[] args) throws IOException 
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer s=new StringTokenizer(br.readLine());
 
		int n=Integer.parseInt(s.nextToken());
		 s=new StringTokenizer(br.readLine());
		 int a[]=new int[n];
		 HashMap<Integer,Integer>hm=new HashMap<>();
		 
		 for(int i=0;i<n;i++) {
			 a[i]=Integer.parseInt(s.nextToken());
			 if(!hm.containsKey(a[i]))
				 hm.put(a[i], 1);
			 else 
				 hm.put(a[i], hm.get(a[i])+1);
		 }
		 int ans=0;
		 for(int val:hm.keySet()) {
			 if(hm.get(val)>val)
				 ans+=hm.get(val)-val;
			 else if(hm.get(val)<val)
				 ans+=hm.get(val);
		 }
		
			pw.println(ans);
 
		
		pw.close();
 
	}
} 

Measured memory_bytes: 44580
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,m,n,flag;
    cin>>a>>b;
    flag=0;
    for(int i=1;i<=10001;i++)
    {
        m=i*0.08;
        n=i*0.1;
        if(m==a&&n==b)
        {
            cout<<i;
            flag=1;
            break;
        }
    }
    if(flag==0)
    {
        cout<<"-1";
    }
    cout<<endl;
    return 0;
}


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

int main(){
  int n;

  while(cin >> n ,n != -1){
    complex<double> pos(1,0);
    double r;
    for(int i = 0 ; i < n-1 ; i++){
      r = arg(pos);
      pos.real() -= sin(r);
      pos.imag() += cos(r);
    }
    printf("%.5f\n%.5f\n" ,pos.real(),pos.imag());
  }

  return 0;
}

Measured memory_bytes: 1284
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int A, B; cin >> A >> B;
	int ans = max(A+B,max(A-B,A*B));
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<numeric>
using namespace std;
#define ll  long long
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define what_is(x) cerr << #x << " is " << x << endl;
int main()
{
    string str,test1,test2,test3;
    test1=test3=test2="";
    cin >> str;
    int flag=1;
    string s1 = "dream",s2="dreamer",s3="erase",s4="eraser";
    int sz=str.size();
    while(sz>0)
    {
        // what_is(sz);
        if(sz<=4){
        flag=0;break;}
        if(sz>=5)
        for(int i=sz-5;i<sz;i++)
        {
            test1 += str[i];
        }
        if(sz>=7)
        for(int i=sz-7;i<sz;i++)
        {
            test2 += str[i];
        }
        if(sz>=6)
        for(int i=sz-6;i<sz;i++)
        {
            test3 += str[i];
        }
        // what_is(test1);
        // what_is(test2);
        // what_is(test3);
        if(test1 == s1 || test1 == s3)
        sz -= 5;
        else if(test2 == s2)
        sz -= 7;
        else if(test3 == s4)
        sz -= 6;
        else 
        flag=0;
        if(flag == 0)
        break ;
        
        test1="",test2="",test3="";
    }
    if(flag&&sz==0)
    cout << "YES";
    else 
    cout << "NO";
}

Measured memory_bytes: 512
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val d = sc.nextLong()
  val xy = List.fill(n)((sc.nextLong(), sc.nextLong()))
  val ans = xy.count{case (x,y) => x*x + y*y <= d*d}
  println(ans)
}


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

int SumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

  int ans = 0;
  for (int i = 1; i <= N; i++){
    int n = SumOfDigits(i);
    if( n >= A && n <= B )ans += i;
  }
  
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

bool is_prime[10010];
vector<int> p;

void sieve() {
  fill(is_prime, is_prime + 10010, true);
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i < 10010; i++) {
    if (!is_prime[i]) continue;
    p.push_back(i);
    for (int j = 2 * i; j < 10010; j += i) {
      is_prime[j] = false;
    }
  }
}

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

  int m, a, b;
  while (cin >> m >> a >> b, m) {
    int h = 0, w = 0;
    for (int i = 0; p[i] * p[i] <= m; i++) {
      for (int j = i; p[j] * p[j] * a <= m * b; j++) {
        if (a * p[j] > b * p[i] || p[i] * p[j] > m || p[i] * p[j] <= h * w) continue;
        h = p[i];
        w = p[j];
      }
    }
    cout << h << " " << w << endl;
  }

  return 0;
}


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

vector<pair<ll,ll> > to[100010];

int main(){
    ll n,m;
    cin>>n>>m;
    ll a[200010],b[200010],c[200010];
    rep(i,0,m){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;b[i]--;
        to[a[i]].emplace_back(b[i],c[i]);
        to[b[i]].emplace_back(a[i],-c[i]);
    }
    vector<ll> site(n,1e14);
    queue<ll> q;
    rep(i,0,n){
        if(site[i]!=1e14||to[i].size()==0)continue;
        q.push(i);
        site[i]=0;
        while(!q.empty()){
            ll now=q.front();
            q.pop();
            for(auto nx:to[now]){
                ll nxx=nx.first;
                ll v=nx.second;
                if(site[nxx]!=1e14)continue;
                site[nxx]=site[now]+v;
                q.push(nxx);
            }
        }
    }
    ll ok=1;
    rep(i,0,m){
        if(site[b[i]]-site[a[i]]!=c[i])ok=0;
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

    









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

int main(){
  int N;
  string A, B, C;
  cin >> N >> A >> B >> C;
  int count=0;
  for(int i=0; i<N; i++){
    if((A[i]!=B[i])&&(A[i]!=C[i])&&(B[i]!=C[i])){
      count+=2;
    }
    else if((A[i]!=B[i]) || (A[i]!=C[i]) || (B[i]!=C[i])){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

using namespace std;

int main()
{  int n,t,sum=0;
   cin>>n;
    int a[n];
     for(int i=0;i<n;i++)

     {
         cin>>a[i];
     }
        int k;
        cin>>k;
        int a2[n];
        for(int j=0,i=0;j<n,i<n;j++,i++)
        {
            a2[j]=a[i];
        }
        while (k--)
        {
            int p,x;
            cin>>p>>x;
            a[p-1]=x;
            for(int i=0;i<n;i++)
            {
                sum= sum+a[i];
            }
            cout<<sum<<"\n";
            sum=0;
            a[p-1]=a2[p-1];
        }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<bitset>
using namespace std;
bitset<100000010> prime;

void m_pList(){
  prime.set();
  prime[0]=prime[1]=0;
  for(long long i=2;i*i<100000010;i++){
    if(prime[i]){
      for(long long j=i*i;j<100000010;j+=i){
        prime[j]=0;
      }
    }
  }
}

int main(){
  m_pList();
  int ans=0;
  int n,tmp;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>tmp;
    if(prime[tmp]){
      ans+=1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 13368
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

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

    READV(N);
    READV(K);
    READAR(A,N);
    sort(A,A+N);
    ll ans=0;
    ll fact[N];
    fact[0]=1;
    FORI(i,1,N+1)
    {
        fact[i]=(fact[i-1]*i)%MOD;
    }
    FORD(i,N-1,-1)
    {
        if(i>=K-1)
        {
            ll x=(((fact[i]*modInverse(fact[i-K+1]))%MOD)*modInverse(fact[K-1]))%MOD;
            x=(x*A[i])%MOD;
            ans=(ans+x)%MOD;
        }
    }
    FORI(i,0,N)
    {
        if(N-i-1>=K-1)
        {
            ll x=(((fact[N-i-1]*modInverse(fact[N-i-K]))%MOD)*modInverse(fact[K-1]))%MOD;
            x=(x*A[i])%MOD;
            ans=(ans-x+MOD)%MOD;
        }
    }
    cout<<ans<<endl;

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


   
    return 0;
}

Measured memory_bytes: 1792
S = input()
if S == "SUN":
	print(7)
elif S =="MON":
	print(6)
elif S == "TUE":
	print(5)
elif S == "WED":
	print(4)
elif S == "THU":
	print(3)
elif S == "FRI":
	print(2)
else:
	print(1)

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

typedef long long int ll ;

ll gcd(ll aaa,ll bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

ll lcm(ll m,ll n)
{
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}

int main() {	

	int N,sum=0;
	cin >> N;
	int ans = N - 1;
	double a[N],tmp=100,cmp;
	for(int i = 0; i < N; i++) {
		cin >> a[i];
		sum += a[i];
	}
	for(int i = N-1; i >= 0; i--) {
		cmp = abs(sum - a[i]*N);
		if(tmp > cmp) {
			tmp = cmp;
		}
		if(tmp == abs(sum - a[i]*N)){
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

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

const int N = 110;

struct Point {
	double x, y;
	Point(double x = 0, double y = 0): x(x), y(y){}
	inline bool operator < (const Point &rhs) const {
		return atan2(y, x) < atan2(rhs.y, rhs.x);
	}
} p[N];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &p[i].x, &p[i].y);
	}
	sort(p, p + n);
	double ans = 0;
	for (int i = 0; i < n; i++) {
		double x = 0, y = 0;
		int j = i;
		do {
			x += p[j].x, y += p[j].y;
			ans = max(ans, x * x + y * y);
			j++;
			j %= n;
		} while (i != j);
	}
	printf("%.15f\n", sqrt(ans));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {

    int N, K;
    cin >> N >> K;

    vi A(N);
    rep(i, N) {
        cin >> A[i];
    }

    vector<double> B(N);
    rep(i, N){
        B[i] = log(A[i]);
    }

    vector<double> score(N, 1);
    rep(j, K) {
        score[K - 1] += B[K - j];
    }
    for(int i = K; i < N; i++) {
        score[i] = score[i-1] - B[i-K] + B[i];
    }

    for (int i = K; i < N; i++) {
        cout << (score[i-1] < score[i] ? "Yes" : "No") << endl;
    }

}


Measured memory_bytes: 7580
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
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 ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#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;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

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



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

#define  Infile			freopen("input.txt", "r", stdin)
#define  Outfile		freopen("output.txt", "w", stdout)
#define  lowb(a,x) 		lower_bound(a.begin(),a.end(),x)-a.begin();
#define  upb(a,x) 		upper_bound(a.begin(),a.end(),x)-a.begin();
#define  fu(i,a,b)		for(long long i=(a); i<=(b); ++i)
#define  fd(i,a,b)		for(long long i=(a); i>=(b); --i)
#define  fo(i,n)		for(long long i=0; i<(n); ++i)
#define  show(a) 		cout<<"\n-> "<<#a<<" = "<<(a)<<endl;
#define  fix_set(x)		fixed<<setprecision(x)
#define  ms(a)			memset(a, 0, sizeof(a))
#define  all(x)			(x).begin(), (x).end()
#define  pb(x)			push_back(x)
#define  ar(x, n)		(x),(x)+(n)
#define  mp(a,b)		make_pair(a, b)
#define	 fst			first
#define	 snd			second

typedef long long ll;
typedef vector <ll> vtll;

clock_t TimeBegin, TimeEnd;
ll LX[] = {-1,0,0,1,-1,-1,1,1}; // 8 - 4
ll LY[] = {0,-1,1,0,-1,1,-1,1}; 
ll const INF = LLONG_MAX;


inline ll mod(string num, ll Base);
inline ll diMod(ll A, ll B, ll Base);
inline ll fpow(ll a, ll x, ll Base);
inline string toString(ll n);
inline void Tstart();
inline void Tstop();


//Declare Here
ll a, b, t, ans = 0;

//============//

void Solve()
{
	cin >> a >> b >> t;
	fu(i, 0, t)
	{
		if (i%a == 0 && i!= 0)
		{
			ans += b;
		}
	}
	cout << ans;
}


//=============================================================================//

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

	#ifdef RAVENCLAW
		Infile;
		//Outfile;
	#endif
		Solve();

	return 0;
}

//=============================================================================//
//=============================================================================//

inline ll mod(string num, ll Base) 
{ 
    ll res = 0; 
    fo(i, num.length()) 
        res = (res*10 + (ll)num[i] - '0') % Base;
    return res; 
} 

inline ll fpow(ll a, ll x, ll Base)
{
	if(x==0)return 1;	
	if(x&1) 
	{
		return a*fpow(a, x-1, Base)%Base;
	} 
	else
	{
		ll t=fpow(a, x/2, Base);
		return t*t%Base;
	}
}

inline ll diMod(ll A, ll B, ll Base)
{
	//(A/B)%Base
	ll result = (A * fpow(B, Base-2, Base)) % Base; 
	return result;
}

inline string toString(ll n) 
{
	stringstream ss; ss << n;
	return ss.str();
}	

inline void Tstart()
{
	TimeBegin = clock();
}

inline void Tstop()
{
	TimeEnd = clock();
	cout << "\nTime elapsed: " << 1000 * (TimeEnd - TimeBegin) / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

int is_unique(char *);

int main()
{
	char str[105];
	char cpy[105];
	int ans = 300;

	scanf("%s", str);

	for (int i = 'a'; i <= 'z'; i++) {
		int cnt = 0;
		strcpy(cpy, str);

		while (!is_unique(cpy)) {
			cnt++;

			for (int j = 0; j < strlen(cpy) - 1; j++) {
				if (cpy[j + 1] == i) {
					cpy[j] = cpy[j + 1];
				}
			}
			cpy[strlen(cpy) - 1] = '\0';
		}

		ans = min(ans, cnt);
	}

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

	return 0;
}

int is_unique(char *str)
{
	int i = 1;
	while (str[i] != '\0' && str[i] == str[i - 1]) {
		i++;
	}

	if (str[i] == '\0') {
		return 1;
	} else {
		return 0;
	}
}


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

int main(){
  int A,B;
  cin >> A >> B;
  int C=B-A+1;
  if(A<=0 && 0<=B){
    cout << "Zero" << endl;
  }
  else if(0<A || C%2==0){
    cout << "Positive" << endl;
  }
  else{
    cout << "Negative" << endl;
  }
}   

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

int main() {
  string s;
  cin>>s;
  for(int i=0;i<3;i++){
    for(int j=i+1;j<3;j++){
      if(s.at(i)==s.at(j)){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    int cnt = 0;
    for (int j = 1; j <= i; ++j) {
      if (i % j == 0) ++cnt;
    }
    if (cnt == 8) ++ans;
  }
  out(ans);
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	 ll n ;
	 scanf("%lld",&n);
	 vector<ll>v;
	 ll in;
	 ll s = 0;
	 for(int i = 0; i < n ; i++)
	 {
	 	scanf("%lld",&in);
	 	v.push_back(in);
	 	s+= in;
	 }
	 ll pem = n*n+n;
	 pem=pem/2;
	 bool flag = 1;
	 
	 if(s%pem != 0)
	 {
	 	flag = 0;
	 }
	 else
	 pem = s/pem;
	 ll bed[100010];
	 bed[n-1] = v[0] - v[n-1];
	 for(int i = 0 ; i < n-1 ; i++)
	 {
	 	bed[i] = v[i+1] - v[i];
	 }
	 for(int i = 0 ; i < n ; i++)
	 {
	 	if(pem-bed[i] == 0) continue;
	 	if(pem-bed[i] < 0 || (pem-bed[i])%n !=0)
	 	{
	 		flag = 0;
//	 		cout<<pem<<endl;
		}
	 }
	 if(flag) cout<<"YES\n";
	 else
	 cout<<"NO\n";
}

Measured memory_bytes: 1908
#[allow(unused)]
use proconio::marker::*;
use proconio::{fastout, input};
#[allow(unused)]
use std::cmp::{max, min, Reverse};
#[allow(unused)]
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
        q: usize,
        bc: [(i64, i64); q],
    }

    let mut hm = HashMap::new();
    for &v in a.iter() {
        let cnt = hm.entry(v).or_insert(0);
        *cnt += 1;
    }

    let mut sum: i64 = a.iter().sum();
    for &(b, c) in bc.iter() {
        let mut aa = -1;
        if let Some(cnt) = hm.get_mut(&b) {
            aa = *cnt;
            *cnt = 0;
        }
        if aa != -1 {
            let cnt = hm.entry(c).or_insert(0);
            *cnt += aa;
            sum = sum - b * aa + c * aa;
        }
        println!("{}", sum);
    }
}


Measured memory_bytes: 9628
#include<iostream>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    
    int seki = a * b;
    
    if(seki % 2 == 0) {
        cout << "Even" << endl;;
    } else {
        cout << "Odd" << endl;;
    }
  
    return 0;
}

Measured memory_bytes: 256
for _ in[0]*int(input()):
 a=list(map(int,input().split()))
 b=[a[0]];c=[0]
 for e in a[1:]:
  if e>b[-1]:b+=[e]
  elif e>c[-1]:c+=[e]
  else:print('NO');break
 else:print('YES')


Measured memory_bytes: 5592
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace PastQuestions
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new Input(Console.In));
        }

        public void Solve(Input input)
        {
            var a = input.ReadLine;
            Console.WriteLine(a.Count(c => c == '1'));
        }
    }

    public class Input
    {
        private TextReader Stream { get; }
        private char Separator { get; }
        private Queue<string> InputStream { get; }

        public Input(TextReader stream, char separator = ' ')
        {
            Stream = stream;
            Separator = separator;
            InputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (InputStream.Count != 0) return InputStream.Dequeue();
                string[] tmp = Stream.ReadLine().Split(Separator);
                for (int i = 0; i < tmp.Length; ++i)
                    InputStream.Enqueue(tmp[i]);
                return InputStream.Dequeue();
            }
        }

        public string ReadLine => Stream.ReadLine();
        public int ReadInt => int.Parse(Read);
        public long ReadLong => long.Parse(Read);
        public double ReadDouble => double.Parse(Read);
    }
}


Measured memory_bytes: 11220
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    println!("{}",a*(a+1)/2)
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   string s;
   cin >> s;
   for(int i=0;i<s.size();i+=2){
      cout << s[i];
   }
   return 0;
}

Measured memory_bytes: 512
import math

n = int(input())

def compare_digits(a, b):
    return max(len(str(a)), len(str(b)))

ans_min = len(str(n))
for a in range(1, int(math.sqrt(n)) + 1):
    if n % a == 0:
        ans = compare_digits(a, int(n / a))
        if ans < ans_min:
           ans_min = ans

print(ans_min)


Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
    string a, b, c;
    cin >> a >> b >> c;
    
    if(a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second

void print_vec(const vector<int> &v)
{
    FOR(i, 0, v.size()-1) {
        if (i != 0) {
            cout << " ";
        }
        cout << v.at(i);
    }
    cout << endl;
}

int main() {
    int n;
    vector<int> v;
    cin >> n;
    int inp;
    REP(i, n) {
        cin >> inp;
        v.push_back(inp);
    }
    sort(ALL(v));

    double tot = v[0];
    FOR(i, 1, n-1) {
        tot = (tot + v[i]) / 2;
    }
    cout << tot << endl;

    return 0;
}

Measured memory_bytes: 256
import itertools

d = [int(input()) for _ in range(5)]
s = []
min = 999
for i in itertools.permutations(range(5)):
    s.append(i)
for x in s:
    tmp = 0
    for y in x:
        tmp += d[y]
        if y != x[-1] and d[y]%10 != 0:
            tmp += 10 - tmp%10
    if tmp < min:
        min = tmp

print(min)


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve():
    from collections import defaultdict
    H, W, M = map(int, input().split())
    hcount = defaultdict(int)
    wcount = defaultdict(int)
    bombs = set()
    for _i in range(M):
        h, w = map(int, input().split())
        hcount[h] += 1
        wcount[w] += 1
        bombs.add((h, w))

    maxh = max(hcount.values())
    maxw = max(wcount.values())
    hs = [k for k in hcount if hcount[k] == maxh]
    ws = [k for k in wcount if wcount[k] == maxw]
    if len(hs) * len(ws) > M:
        return maxh + maxw
    for h in hs:
        for w in ws:
            if (h, w) not in bombs:
                return maxh + maxw
    return maxh + maxw - 1


def main():
    print(solve())


# tests
T1 = """
2 3 3
2 2
1 1
1 3
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
3
"""

T2 = """
3 3 4
3 3
3 1
1 1
1 2
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
3
"""

T3 = """
5 5 10
2 5
4 3
2 3
5 5
2 2
5 4
5 3
5 1
3 5
1 4
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
6
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 219780
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;
int main(){
    int h[30],ans=1;
    int n;bool flag=true;
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>h[i];
    for(int i=1;i<n;i++)
    {
        for(int j=i-1;j>=0;j--)
        {
            if(h[i]<h[j])
            flag=false;
        }
        if(flag==true)
        ans++;
        flag=true;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//~ #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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define st first
#define nd second

using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set =
	tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
#define shandom_ruffle random_shuffle
 
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;

ll A, B, C, D;
map<ll, ll> memo;

ll Solve(ll N) {
	if (N == 0) { return 0; }
	if (memo.count(N)) { return memo[N]; }
	ll ans = 1e18;
	if (N < 3e9) { ans = N * D; }

	for (int p = -1; p <= 1; ++p) {
		ll x = N + p;
		if (x < 0 || x % 2 != 0) { continue; }
		ll y = x / 2;
		if (y < N) {
			ans = min(ans, abs(p) * D + A + Solve(y));
		}
	}

	for (int p = -2; p <= 2; ++p) {
		ll x = N + p;
		if (x < 0 || x % 3 != 0) { continue; }
		ll y = x / 3;
		if (y < N) {
			ans = min(ans, abs(p) * D + B + Solve(y));
		}
	}

	for (int p = -4; p <= 4; ++p) {
		ll x = N + p;
		if (x < 0 || x % 5 != 0) { continue; }
		ll y = x / 5;
		if (y < N) {
			ans = min(ans, abs(p) * D + C + Solve(y));
		}
	}

	debug() << imie(N) << imie(ans);
	return memo[N] = ans;
}

void Test() {
	ll N;
	cin >> N >> A >> B >> C >> D;
	memo.clear();

	cout << Solve(N) << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(11);
	cerr << fixed << setprecision(6);

	int t;
	cin >> t;

	while (t--) {
		Test();
	}
}


Measured memory_bytes: 4440
// Author: wlzhouzhuan
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rint register int
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define per(i, l, r) for (rint i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

inline void ckmin(int &a, int b) {
  if (a > b) a = b;
}
inline void ckmax(int &a, int b) {
  if (a < b) a = b;
}

const int N = 100005;
int p[N], q[N], r[N];
int x, y, a, b, c;
multiset <int> S;
long long ans = 0;
 
int main() {
  scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
  rep(i, 1, a) p[i] = read(); sort(p + 1, p + a + 1);
  rep(i, 1, b) q[i] = read(); sort(q + 1, q + b + 1);
  rep(i, 1, c) r[i] = read(); sort(r + 1, r + c + 1);
  for (rint i = a; i >= a - x + 1; i--) S.insert(p[i]), ans += p[i];
  for (rint i = b; i >= b - y + 1; i--) S.insert(q[i]), ans += q[i];
  for (rint i = c; i >= 1; i--) {
    auto it = S.begin();
    if (*it <= r[i]) {
      ans += r[i] - (*it);
      S.erase(it);
      S.insert(r[i]);
    } else {
      break;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 9856
#include<stdio.h>
main(){
  int n,i;
  int a[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  i=n-1;
  while(1){
    printf("%d",a[i]);
    if(i==0) break;
    printf(" ");
    i--;
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

main(){

char c;
int a,b,e;

while(1){

 scanf("%d %c %d",&a,&c,&b);

 if(c=='+'){
 e = a + b;
 }
 else if(c=='-'){
 e = a - b;
 }
 else if(c=='*'){
 e = a * b;
 }
 else if(c=='/'){
 e = a / b;
 }
 else{
 break;
 }
 
 printf("%d\n",e);
}
 
return 0;
}


Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		long n, m, k;

		Scanner in = new Scanner(System.in);

		while (in.hasNext()) {
			n = in.nextInt();
			m = in.nextInt();

			k=Math.max(n, m);
			m=Math.min(n, m);
			n=k;
				
			System.out.println(gcd(n, m) + " "
					+ (n * m) / gcd(n, m));
		}
	}

	private static long gcd(long n,long m){

		if(m==0) return n;
		else return gcd(m, n%m);
		
	}

}

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

int main(){
  int h, w; cin >> h >> w;
  char grid[h+2][w+2];

  for(int i=0; i<=h+1; i++){
    for(int j=0; j<=w+1; j++){
      if(i==0 || i==h+1 || j==0 || j==w+1){
        grid[i][j] = '#';
        continue;
      }
      cin >> grid[i][j];
    }
  }

  for(int i=0; i<=h+1; i++){
    for(int j=0; j<=w+1; j++) cout << grid[i][j];
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3


def solv(n, ls, rs):
    n = min(rs) - max(ls) + 1
    return max(n, 0)


if __name__ == '__main__':

    n, m = map(int, input().split())
    ls = []
    rs = []
    for _ in range(m):
        li, ri = map(int, input().split())
        ls.append(li)
        rs.append(ri)

    ans = solv(n, ls, rs)

    print(ans)


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

int main() {
  int A,B;
  int i = 0;
  cin >> A >> B;
  while (i < 1011) {
    	if (A <= i * 8 / 100 && i * 8 / 100 < A + 1 &&
            B <= i * 10 / 100 &&  i * 10 / 100 < B + 1) {
          		cout << i << endl;
          		break;
        }
    	i++;
  }
  if (i == 1011) {
    	cout << -1 << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, K: int, C: int, S: str):

    L = []
    c = 0
    for i, d in enumerate(S):
        if d == "o" and c == 0:
            L.append(i)
            c = C
        elif c > 0:
            c -= 1
    R = []
    c = 0
    for i, d in enumerate(S[::-1]):
        if d == "o" and c == 0:
            R.append(N-i-1)
            c = C
        elif c > 0:
            c -= 1

    if len(L) != K:
        print()
        return
    for l, r in zip(L, R[::-1]):
        if l == r:
            print(l+1)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, C, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22384
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned x){
  int s=0;
  char f[10];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned long long x){
  int s=0;
  char f[21];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(double x){
  printf("%.15f",x);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
template<class S, class T> inline S divup_L(S a, T b){
  return (a+b-1)/b;
}
int H;
int W;
int N;
int main(){
  rd(H);
  rd(W);
  rd(N);
  wt_L(divup_L(N,max_L(H, W)));
  wt_L('\n');
  return 0;
}
// cLay varsion 20200119-1

// --- original code ---
// int H, W, N;
// {
//   rd(H,W,N);
//   wt(N /+ max(H,W));
// }


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void copy_matrix(vector <vector <char>> &a, vector<vector <char>> &b) {
    for (int i = 0; i < a.size(); ++i) {
        for (int j = 0; j < a[0].size(); ++j) {
            b[i][j] = a[i][j];
        }
    }
}
void color(vector <vector <char>> &b, int row, int col, int tot_row, int tot_col) {
    for (int i = 0; i < tot_row; ++i) {
        if (row & (1 << i)) {
            for (int j = 0; j < tot_col; ++j) {
                b[i][j] = '$';
            }
        }
    }
    for (int i = 0; i < tot_col; ++i) {
        if (col & (1 << i)) {
            for (int j = 0; j < tot_row; ++j) {
                b[j][i] = '$';
            }
        }
    }
}
int cnt(vector <vector <char>> &b, int k) {
    int ans = 0;
    for (int i = 0; i < b.size(); ++i) {
        for (int j = 0; j < b[0].size(); ++j) {
            if (b[i][j] == '#') {
                ++ ans;
            }
        }
    }
    return ans;
}
int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector <vector <char>> a(n, vector <char> (m, '@'));
    vector <vector <char>> b(n, vector <char> (m, '@'));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            char x;
            cin >> x;
            a[i][j] = x;
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        for (int j = 0; j < (1 << m); ++j) {
            copy_matrix(a, b);
            color(b, i, j, n, m);
            if (cnt(b, k) == k) {
                ++ans;
            }
        }

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

Measured memory_bytes: 3584
from operator import itemgetter
n = int(input())
red = [tuple(map(int, input().split())) for _ in range(n)]
blue = [tuple(map(int, input().split())) for _ in range(n)]
red.sort(key=itemgetter(1), reverse=True)
blue.sort()
red_flag = [False] * n
for i in range(n):
    pair_red_index = float('inf')
    for j in range(n):
        if not (red_flag[j]) and red[j][0] < blue[i][0] and red[j][1] < blue[i][1]:
            pair_red_index = j
            break
    if pair_red_index != float('inf'):
        red_flag[pair_red_index] = True
print(red_flag.count(True))

Measured memory_bytes: 3188
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		i = s.length();
		boolean f = true;
		int ss = 0;
		String[] t = {"dream","dreamer","erase","eraser"};
		while(i>0) {
			boolean f2 = false;
			for(j=0;j<t.length;j++) {
				ss = i - t[j].length();
				if(ss>=0) {
					if(s.substring(ss, i).equals(t[j])) {
						f2 = true;
						i=ss;
						break;
					}
				}
			}
			if(!f2) {
				f = false;
				break;
			}
		}
		String ans=f?"YES":"NO";
		System.out.println(ans);
	}
}


Measured memory_bytes: 28124
#include<iostream>
using namespace std;
int main() {
	int s;
	cin >> s;

	int h = 0;
	int m = 0;
	if (s >= 60) {
		m = s / 60;
		s = s % 60;
	}
	if (m >= 60) {
		h = m / 60;
		m = m % 60;
	}

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}


Measured memory_bytes: 3100
function Main(input) {
  input = input.split("\n").map(x => parseInt(x, 10));
 
  var n = input[0];
  var p = input.slice(1, n + 1);
 
  var top = p.reduce((x, y) => Math.max(x, y))
  var sum = p.reduce((x, y) => x + y)
 
  console.log(sum - (top / 2))
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int i,j,l,c,ans=inf,m;
    char s[101];
    chin(s);
    l=strlen(s);
    for(j='a';j<='z';j++){
        m=c=0;
        rep(i,l){
            if(s[i]==j){
                m=max(m,c);
                c=0;
            }
            else c++;
        }
        m=max(m,c);
        ans=min(ans,m);
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;

signed main() {
  int N;
  cin >> N;
  
  set<int> ans;
  ans.insert(N);
  if( N > 2 ) ans.insert(N-1);
  for( int i = 2; i <= sqrt(N); i++ ){
    if( N%i == 0 ){ //もしNの約数だったら
      int A = N;
      while( A%i == 0 ) A /= i;
      if( A%i == 1 ) ans.insert(i);
      A = N;
      int B = N/i;
      while( A%B == 0 ) A /= B;
      if( A%B == 1 ) ans.insert(B);
    }
  }
  
  //N-1の約数はすべて当てはまる
  N--;
  for( int i = 1; i <= sqrt(N); i++ ){
    if( N%i == 0 ){
      if( i != 1 ) ans.insert(i);
      if( N/i != 1 ) ans.insert(N/i);
    }
  }
  
  cout << ans.size() << endl;
}



Measured memory_bytes: 256