akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int a,b,c,x;
    int count = 0;
    cin >> a >> b >> c >> x;
    vector<int> v;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                v.pb(500*i + 100*j + 50*k);
            }
        }
    }
    rep(i,v.size()){
        if(v[i] == x) count++;
    }
    cout << count << endl;
} 

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

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  string s;cin>>s;
  int n=s.size();
  for(int i=0;i<=n/2;i++){
    if(s[i]=='b'&&s[n-1-i]!='d')fin("No");
    if(s[i]=='d'&&s[n-1-i]!='b')fin("No");
    if(s[i]=='p'&&s[n-1-i]!='q')fin("No");
    if(s[i]=='q'&&s[n-1-i]!='p')fin("No");
  }
  fin("Yes");
}


Measured memory_bytes: 512
import sys,math
input = sys.stdin.readline

n,k = map(int,input().split())
a = [int(i) for i in input().split()]
f = [int(i) for i in input().split()]
a.sort()
f.sort(reverse=True)
c = [(i*j,j) for i,j in zip(a,f)]
m = max(c)

def is_ok(arg):
    # 条件を満たすかどうか？問題ごとに定義
    chk = 0
    for i,j in c:
      chk += math.ceil(max(0,(i-arg))/j)
    return chk <= k


def bisect_ok(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義
    ng = 最小の値-1 ok = 最大の値+1 で最小
    最大最小が逆の場合はng ok をひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
  
print(bisect_ok(-1,m[0]+1))

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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 200200;
const long long Q = 100000001;
const long long mod = 1e9 + 7;
const long long MAGIC = 30;

using namespace std;

int a, b;

void solve()
{
        cin >> a >> b;
        for(int i = 3, x = 1, y = 3; ; i++){
                if(x >= a && y >= b && x - a == y - b){
                        cout << x - a << "\n";
                        break;
                }
                x = y;
                y += i;
        }
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("maze.in");
        //fout("maze.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 256
import queue
K = int( input() )

q = queue.Queue()

ret = K
number_of_operations = 9
for i in range( 1, number_of_operations + 1 ):
  q.put( i )

while number_of_operations < K:
  i = q.get()
  k = i % 10 
  if k != 0:
    ret = 10 * i + k - 1
    q.put( ret )
    number_of_operations += 1
    if number_of_operations == K:
      break
  ret = 10 * i + k
  q.put( ret )
  number_of_operations += 1
  if number_of_operations == K:
    break

  if k != 9:
    ret = 10 * i + k + 1
    q.put( ret )
    number_of_operations += 1

print( ret )

Measured memory_bytes: 6624
//1次元いもす法の基本的な問題
#include<iostream>

using namespace std;

typedef long long ll;

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

ll N,T;

ll c[100010];

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

    rep(i,N) {
        ll l,r;//時間lに入店、時間rに出店
        cin >> l >> r;
        r--;//[l,r)にする
        c[l]++;
        c[r+1]--;
    }

    rep(i,T) {
        c[i+1] += c[i];
    }

    ll ans = 0;
    rep(i,T+1) {
        ans = max(ans,c[i]);
    }

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



Measured memory_bytes: 3872
n = int(input())
a = list(map(int, input().split()))
p = 1
maxp = 10 ** 18
overFlag = False
if 0 in a:
  p = 0
else:
  for i in range(n):
    p *= a[i]
    if p > maxp:
      overFlag = True
      break
if overFlag == True:
    print('-1')
else:
  print(p)
  

Measured memory_bytes: 21648
s=input()
l,r=0,len(s)-1
ans=0
while l<r:
    if s[l]==s[r]:
        l+=1
        r-=1
    elif s[l]=="x": 
        l+=1
        ans+=1
    elif s[r]=="x":
        r-=1
        ans+=1
    else:
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long double ld;
#define s second
#define f first
int main()
{	
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    {	lli n,p;
    	cin>>n;
    	p=n;
    	map<lli,lli> m;
    	for(lli i=2;i*i<=n;i++)
    	{	if(p%i==0)
    		{	m.insert({i,0ll});
    			while(p%i==0)
    				{p=p/i;m[i]++;}
    		}
    	}
    	if(p!=1)
    		m.insert({p,1ll});
    	lli ans=0;
    	for(auto it=m.begin();it!=m.end();it++)
    	{	lli temp=1;
    		while(temp<=it->second)
    			{ans++;it->second-=temp;temp++;}
    	}
    	cout<<ans<<endl;
    }
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back


int main()
{
    int i,j;
    int n,s;
    cin>>n>>s;
    ll x[n+1];
    ll p[n+1];
    vector<int> a;
    vector<int> b;
    for(i=1;i<=n;i++)
    {

        cin>>x[i];
        cin>>p[i];

    }

    for(i=1;i<=n;i++)
    {
        if(x[i]<s)
            a.pb(i);
        else
            break;



    }
    for(j=n;j>=i;j--)
        b.pb(j);

    vector<ll> ans;
    int u=0,v=0;

    for(i=0;i<n;i++)
    {

        if(u==a.size())
            break;
        if(v==b.size())
            break;


        if(p[a[u]]>=p[b[v]])
        {

             ans.pb(x[b[v]]);

             p[a[u]]+=p[b[v]];
             v++;

        }
        else{

             ans.pb(x[a[u]]);

             p[b[v]]+=p[a[u]];
             u++;



        }





    }

    if(u!=a.size())
for(i=u;i<a.size();i++)
    ans.pb(x[a[i]]);
     if(v!=b.size())
for(i=v;i<b.size();i++)
    ans.pb(x[b[i]]);


    ans.pb(s);


    ll val=0;
    for(i=n;i>=1;i--)

    {

        val=val+abs(ans[i]-ans[i-1]);





    }



        cout<<val<<endl;

    return 0;
}


Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

using ipair = pair<int, int>;

ll INF = 1e16+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}

ll dfs(int N, ll X){
  if(N==0) return 1;

  // N-1バーガー
  ll length = (1LL << (N+1))-3;  
  ll patty = (1LL << N)-1;  
  ll center = length+2;

  if(X==1) return 0;
  else if(X < center) return dfs(N-1, X-1); // 真ん中以下
  else if(X == center) return patty+1; // 真ん中
  else if(X <=center+length) return patty+1+dfs(N-1, X-(length+2));
  else return 2*patty+1; // ちょうどレベルNバーガー全体
}

int main(){
  int N;
  ll X;
  cin >> N >> X;
  cout << dfs(N, X) << endl;

  return 0;
}


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

int main()
{
    int H, W;
    
    for (int i = 0; ; i++) {
        scanf("%d %d", &H, &W);
        if (H == 0 and W == 0) break;
        
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                putchar('#');
            }
            putchar('\n');
        }
        putchar('\n');
    }
}



Measured memory_bytes: 3152
#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>
using namespace __gnu_pbds;
using namespace std;


#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz(x)           (int)x.size()
#define db(x)           cout<<x<<"\n";

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

	
//////////////////////////////code//////////////////////////////

void solve()
{
   // cout << "-------------------" << "\n";
    
    int n;
    cin>>n;
    
    vi arr(n+1);
    
    for(int i=1;i<=n;i++) cin>>arr[i];
    
    int dp[n+1][n+1]={0},pre[n+1]={0};
    
    
    for(int i=1;i<=n;i++)  pre[i] = pre[i-1] + arr[i];
    
    for(int i=0;i<n;i++)
    dp[i][i] = 0;
    
    for(int len = 2;len <= n; len++)
    {
        for(int i=1;i<=n-len+1;i++)
        {
            int j = i + len - 1;
            dp[i][j] = inf;
            
            for(int k = i+1; k<=j;k++)
            {
                dp[i][j] = min(dp[i][j] , dp[i][k-1] + dp[k][j] + pre[j]-pre[i-1]);
            }
        }
    }
    
    //matrixprint(dp,0,0,n,n);
    
    cout<<dp[1][n]<<"\n";
  
 

  //  cout << "-------------------" << "\n";

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

    int t = 1;
   // cin >> t;

    while (t--)
        solve();

}

// check out for following mistakes-
// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only
// is using prime sieve make sure it fits
// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values


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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int gcd(int a,int b) {
    if(b == 0)
        return a;

    return gcd(b, a % b);
}

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

    vector<int> A(N);

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

    vector<int> L(N+1,0);
    for(int i = 0;i < N;i++) {
        L[i+1] = gcd(L[i],A[i]);
    }
    vector<int> R(N+1,0);
    for(int i = N - 1;i >= 0;i--) {
        R[i] = gcd(R[i+1],A[i]);
    }

    int ans = 0;
    for(int i = 0;i < N;i++) {
        int l = L[i];
        int r = R[i+1];
        ans = max(ans,gcd(l,r));
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1408
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, k := scanInt(), scanInt()
	type sushi struct{ t, d int }
	s := make([]sushi, n)
	for i := range s {
		s[i].t, s[i].d = scanInt(), scanInt()
	}

	sort.Slice(s, func(i, j int) bool { return s[i].d > s[j].d })
	sumD := 0
	mt := make(map[int]bool, n)
	src := make([]sushi, 0, k)
	for i := 0; i < k; i++ {
		sumD += s[i].d
		if mt[s[i].t] {
			src = append(src, s[i])
			continue
		}
		mt[s[i].t] = true
	}
	ts := len(mt)

	dst := make([]sushi, 0, len(s)-k+1)
	for i := k; i < len(s); i++ {
		if !mt[s[i].t] {
			mt[s[i].t] = true
			dst = append(dst, s[i])
		}
	}

	ans := sumD + ts*ts
	for i := range src {
		if i >= len(dst) {
			break
		}
		sumD += -src[len(src)-i-1].d + dst[i].d
		ts++
		if v := sumD + ts*ts; v > ans {
			ans = v
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7464
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cstdlib>
#define ll long long
#define lowbit(x) (x&(-x))
using namespace std;

int ans,h,n,a,b,f[20007];

int main(){
    memset(f,0x7f,sizeof f);
    ans=f[0];f[0]=0;
    scanf("%d%d",&h,&n);
    for (int i=1;i<=n;++i){
        scanf("%d%d",&a,&b);
        for (int V=a;V<=20000;++V){
            f[V]=min(f[V],f[V-a]+b);
            if (V>=h) ans=min(ans,f[V]);
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define PI 3.14159265358979
#define ll long long
using namespace std;



int main()
{
	int n;
	string test;
	cin >> n >> test;
	bool flag = true;

	if (n % 2) {
		printf("No");
	} else {
		for (int i = 0; i < n / 2; i++) {
			if (test[i] != test[i + n / 2]) {
				flag = false;
				break;
			}
		}
		printf("%s", flag ? "Yes" : "No");
	}

	return 0;
}



Measured memory_bytes: 256
N=int(input())

a=[]
for i in range(20):
    if N%26==0:
        s=26
        N=int(N/26)-1
    else:
        s=int(N%26)
        N=int(N/26)
    
    a.append(s)
    if N<1:
        break

a=a[::-1]
for i in range(len(a)):
    a[i]=chr(a[i]+96)

print("".join(a))

Measured memory_bytes: 9112
#include <bits/stdc++.h>
    using namespace std; 
     
    int numOfDigits;  
    int numOfQueries; 
    int myIndex;
    int foo; 
    int lowestIndex; 
    char * myNumber;
    char value; 
    bool isPossible;  
     
    int main() {
        scanf("%d %d", &numOfDigits, &numOfQueries);
        lowestIndex = numOfDigits + 1; 
        
        myNumber = (char*) malloc(numOfDigits * sizeof(char)); 
     
        for (int i = 0; i < numOfDigits; i++) {
            myNumber[i] = 'a'; 
        }
     
        isPossible = true; 
     
        for (int i = 0; i < numOfQueries; i++) {
            scanf("%d %d", &myIndex, &foo);
     
            value = foo + '0'; 
            myIndex--;  
            lowestIndex = min(myIndex, lowestIndex); 
     
            if (myNumber[myIndex] != 'a') {
                isPossible = (myNumber[myIndex] == value); 
            }
     
            myNumber[myIndex] = value; 
     
            if (!isPossible) break; 
        }
        
        if (isPossible && myNumber[0] == '0') {
            isPossible = (numOfDigits == 1); 
        }

        if (isPossible) {
            if (lowestIndex != 0 && numOfDigits != 1) {
                myNumber[0] = '1'; 
            } else if (numOfDigits == 1 && myNumber[0] == 'a') {
                myNumber[0] = '0';
            }
     
            for (int i = 1; i < numOfDigits; i++) {
                if (myNumber[i] == 'a') {
                    myNumber[i] = '0'; 
                }
            }
     
            printf("%s\n", myNumber); 
        } else {
            printf("-1\n");
        }
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mk make_pair
#define all(c) (c).begin(),(c).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define debug2(x,y) cerr<<"("<<#x<<","<<#y<<") = ("<<x<<","<<y<<")\n";
#define debugM(x,n,m) rep(i,0,n){ rep(j,0,m) cerr<<x[i][j]<<" ";cerr<<endl;}
#define debugV(x,n) rep(i,0,n){cerr<<x[i]<<" ";}cerr<<endl; 
#define pi 3.14159265358979323846264338
typedef pair<int,int> ii;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
const int MOD = 1e9+7;

int main(){
	int n,a,b;
	while(cin>>n>>a>>b){
		int dx,dy;
		dx = n-a;
		dy = n-b;
		if(dx <0 || dy < 0) puts("0");
		else printf("%d\n",(dx+1)*(dy+1));
	}
	return 0;	
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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


int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> c(n);
    vector<pair<int, int>> ans(m);
    rep(i, m){
        int pi, year;
        cin >> pi >> year;
        pi--;
        c[pi].push_back(make_pair(year, i));
    }
    rep(i,n){
        sort(all(c[i]));
        rep(j, c[i].size()){
            int id = c[i][j].second;
            ans[id] = make_pair(i+1, j+1);
        }
    }
    rep(i,m){
        printf("%06d%06d\n", ans[i].first, ans[i].second);
    }
    return 0;
}

Measured memory_bytes: 9508
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a; 
	int b, w ,d ;
	scanf("%d%d%d",&w,&a,&b);
	if(b>(a+w))
	d=b-(a+w);
	else if(a>b+w)
	d=a-(b+w);
	else
	d=0;
	printf("%d",d);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int ans = 0;
    if (2 * C < A + B)
    {
        if (X >= Y)
        {
            ans += 2 * C * Y;

            if (2 * C < A)
            {
                ans += 2 * C * (X - Y);
            }
            else 
            {
                ans += A * (X - Y);
            }
        }
        else if (X < Y)
        {
            ans += 2 * C * X;

            if (2 * C < B)
            {
                ans += 2 * C * (Y - X);
            }
            else 
            {
                ans += B * (Y - X);
            }
        }
    }
    else
    {
        ans = A * X + B * Y;
    }

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

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

int main(){
    int n;
    int t[110000],x[110000],y[110000];
    cin>>n;
    t[0]=x[0]=y[0]=0;
    for(int i=0;i<n;i++)cin>>t[i+1]>>x[i+1]>>y[i+1];

    bool can=true;
    for(int i=0;i<n;i++){
        int dt=t[i+1]-t[i];
        int dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
        if(dt<dist)can=false;
        if(dist%2!=dt%2)can=false;
    }

    if(can)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){
	char c;
	int cnt = 0;
	rep(i,0,6){
	    cin >> c;
	    if(c == '1')cnt++;
	}
	P(cnt);

	return  0;
}

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

#define MOD (1000000000+7)
#define MAX 100000

int N;
int A[MAX];
int s[MAX];

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

	long long ans = 1;
	if( N % 2 ) {
		for( int i = 0; i < N; i += 2 ) {
			if( i == 0 ) {
				if( s[i] != 1 ) {
					ans = 0;
					break;
				}
			}
			else {
				if( s[i] != 2 ) {
					ans = 0;
					break;
				}
			}
		}
	}
	else {
		for( int i = 1; i < N; i += 2 ) {
			if( s[i] != 2 ) {
				ans = 0;
				break;
			}
		}
	}
	if( ans == 1 ) {
		for( int i = 0; i < N / 2; i++ ) {
			ans = ans * 2 % MOD;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    int x=min({a,b,c});
    int z=max({a,b,c});
    int y=a+b+c-x-z;
    int cnt=z-y;
    x+=cnt;
    cnt+=(z-x+1)/2;
    x+=(z-x+1)/2*2;
    if(x!=z)cnt++;
    cout<<cnt<<endl;
}


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

int main(){
    cin>>n;
    string s; cin>>s;
    int r[n]={},g[n]={},b[n]={};
    for(int i=n-2;i>=0;i--){
        r[i]=r[i+1];
        g[i]=g[i+1];
        b[i]=b[i+1];
        if(s[i+1]=='G')
            g[i]++;
        else if(s[i+1]=='B') b[i]++;
        else r[i]++;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
         //   cout<<s[i]<<" "<<s[j]<<" ";
            if(s[i]!=s[j]){
                char Target;
                if(s[i]=='R' && s[j]=='G' || s[j]=='R' && s[i]=='G' ) Target='B',ans+=b[j];
                else if(s[i]=='R' && s[j]=='B' || s[j]=='R' && s[i]=='B') Target='G',ans+=g[j];
                else if(s[i]=='B' && s[j]=='G' || s[j]=='B' && s[i]=='G') Target='R',ans+=r[j];
                int k=j+(j-i);
                if(k<n && s[k]==Target) ans--;
            }
        //    cout<<ans<<" ";
        }
    }
    cout<<ans;
    return 0;
}


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

int main() {
	int n = 0, m = 0;
	cin >> n >> m;
	int a[100][100] = { {0} };
	for (int i = 0;i < n;i++) {
		for(int j = 0;j < m;j++) {
			cin >> a[i][j];
		}
	}
	int b[1000] = { 0 };
	for (int i = 0;i < m;i++)
		cin >> b[i];

	int c[100] = { 0 };
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < m;j++) {
			c[i] += a[i][j] * b[j];
		}
		cout << c[i] << endl;
	}
}

Measured memory_bytes: 3124
#include <stdio.h>
#define num_element 190
int main(void)
{
	int i,n,m;
	char array[num_element];
	char a[2];
	char b[2];
	char input[2];
	while(1)
	{
		for(i=0;i<num_element;i++)
		{
			array[i] = i;
		}
		scanf("%d",&n);
		if(n == 0)return 0;
		for(i=0;i<n;i++)
		{
			scanf("%s %s",a,b);
			array[a[0]] = b[0];
		}
		scanf("%d",&m);
		for(i=0;i<m;i++)
		{
			scanf("%s",input);
			printf("%c",array[input[0]]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 576
#include <iostream>
#include <vector>
#include <string>

typedef long long ll;
const ll MOD = (ll)1e9 + 7;

// ------------------------------------------------------
// ModInt, Combination
// ------------------------------------------------------
template <ll MOD>
class ModInt {

public:
  ll val;

  // Constructor
  ModInt(ll v = 0) : val(v % MOD) {
    if (val < 0) val += MOD;
  };

  // Unary
  ModInt operator +() const {return ModInt(val); }
  ModInt operator -() const {return ModInt(MOD - val); }

  ModInt pow(ll n) const {
    ll result = 1LL;
    ll a = val;
    while (n > 0) {
      if (n & 1) result = result * a % MOD;
      a = a * a % MOD;
      n >>= 1;
    }
    return result;
  }

  ModInt inv() const {
    return pow(MOD-2);
  }

  // Assignment, Compound
  ModInt& operator = (const ModInt& x) { if (this != &x) {val = x.val;}          return *this; }
  ModInt& operator +=(const ModInt& x) { if ((val += x.val) >= MOD){val -= MOD;} return *this; }
  ModInt& operator -=(const ModInt& x) { if ((val -= x.val) <  0LL){val += MOD;} return *this; }
  ModInt& operator *=(const ModInt& x) { val = val * x.val % MOD;                return *this; }
  ModInt& operator %=(const ModInt& x) { val %= x.val;                           return *this; }
  ModInt& operator /=(const ModInt& x) { *this *= x.inv();                       return *this; }

  // Arithmetic
  ModInt operator +(const ModInt& x) const { return ModInt(*this) += x; }
  ModInt operator -(const ModInt& x) const { return ModInt(*this) -= x; }
  ModInt operator *(const ModInt& x) const { return ModInt(*this) *= x; }
  ModInt operator %(const ModInt& x) const { return ModInt(*this) %= x; }
  ModInt operator /(const ModInt& x) const { return ModInt(*this) /= x; }

  // Increment, Decrement
  ModInt& operator ++()    { val += 1; return *this;}
  ModInt& operator --()    { val -= 1; return *this;}
  ModInt  operator ++(int) { ModInt before = *this; ++(*this); return before;}
  ModInt  operator --(int) { ModInt before = *this; --(*this); return before;}

  // Compare
  bool operator ==(const ModInt& b) const { return val == b.val; }
  bool operator !=(const ModInt& b) const { return val != b.val; }
  bool operator < (const ModInt& b) const { return val <  b.val; }
  bool operator <=(const ModInt& b) const { return val <= b.val; }
  bool operator > (const ModInt& b) const { return val >  b.val; }
  bool operator >=(const ModInt& b) const { return val >= b.val; }

  friend std::ostream& operator <<(std::ostream& os, const ModInt& x) { return os << x.val; }
};

template <int MOD>
class Combination {
  using mint = ModInt<MOD>;

public:
  explicit Combination(ll N) : MAX_V(N), fact(MAX_V + 1) {
    fact[0] = 1;
    for (ll i = 1; i <= MAX_V; i++) {
      fact[i] = fact[i-1] * i;
    }
  }

  mint comb(ll a, ll b) const {
    return a < b ? mint(0) : fact[a] / fact[a-b] / fact[b];
  }
private:
  ll MAX_V;
  std::vector< mint > fact;
};

using mint = ModInt<MOD>;

int main()
{
  ll N, M;
  std::cin >> N >> M;

  // C(N, 2)
  // C(M, 2)
  const Combination<MOD> C(1000);

  mint ans = C.comb(N, 2) + C.comb(M, 2);
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

int n, X, Y, Z, a, b ;
int A[N] ;

signed main() {
	scanf("%d%d%d", &n, &a, &b) ;
	rep(i, 1, n) scanf("%d", &A[i]) ;
	rep(i, 1, n) {
		if (A[i] <= a) X++ ;
		if (a < A[i] && A[i] <= b) Y++ ;
		if (A[i] > b) Z++ ;
	}
	printf("%d\n", min(min(X, Y), Z)) ;
}

/*
Ð´´úÂëÊ±Çë×¢Òâ£º
	1.ll£¿Êý×é´óÐ¡£¬±ß½ç£¿Êý¾Ý·¶Î§£¿
	2.¾«¶È£¿
	3.ÌØÅÐ£¿
	4.ÖÁÉÙ×öÒ»Ð©
Ë¼¿¼ÌáÐÑ£º
	1.×î´óÖµ×îÐ¡->¶þ·Ö£¿
	2.¿ÉÒÔÌ°ÐÄÃ´£¿²»ÐÐdp¿ÉÒÔÃ´
	3.¿ÉÒÔÓÅ»¯Ã´
	4.Î¬»¤Çø¼äÓÃÊ²Ã´Êý¾Ý½á¹¹£¿
	5.Í³¼Æ·½°¸ÊÇÓÃdp£¿Ä£ÁËÃ´£¿
*/


Measured memory_bytes: 256
H, W, K = map(int, input().split())
S = [[0]*(W+1) for _ in range(H+1)]
for i in range(1, H+1):
    tmp = list(input())
    for j in range(1, W+1):
        S[i][j] = int(tmp[j-1])


INF = float("inf")
ans = INF

cum = [[0]*(W+1) for _ in range(H+1)]
for i in range(1, H+1):
    for j in range(1, W+1):
        cum[i][j] = cum[i-1][j] + cum[i][j-1] - cum[i-1][j-1] + int(S[i][j] == 1)



for i in range(1<<(H-1)):
    to_cut = []
    tmp = 0
    for j in range(H-1):
        if (i>>j)&1:
            tmp += 1
            to_cut.append(j+1)
    to_cut.append(H)
    blocks = []
    for i in range(len(to_cut)):
        if i == 0:
            blocks.append(cum[to_cut[0]][W])
        else:
            blocks.append(cum[to_cut[i]][W] - cum[to_cut[i-1]][W])
    # print(to_cut, blocks)
    dic = {i: 0 for i in range(1, H+1)}
    ptr = 0
    for i in range(1, H+1):
        if i <= to_cut[ptr]:
            dic[i] = ptr
        else:
            ptr += 1
            dic[i] = ptr
    # print(dic)
    length = len(blocks)
    tmp_sum = [0]*length
    w = 1
    last_cut_pnt = 0
    is_all_bad = 0
    while w <= W:
        for i in range(1, H+1):
            tmp_sum[dic[i]] += int(S[i][w]==1)
        is_over_k = 0
        for i in range(1, H+1):
            if tmp_sum[dic[i]] > K:
                is_over_k = 1
                break
        
        if is_over_k:
            tmp_sum = [0]*length
            tmp += 1
            if last_cut_pnt == w:
                is_all_bad = 1
                break
            last_cut_pnt = w
        else:
            w += 1

    if is_all_bad:
        continue
    else:
        ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 74624
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"

const int N = 1e5 + 5;

int n;
int a[N], dp[N];

int findAns(int i){
    if(i > n){
        return 1e9;
    }

    if(i == n){
        return 0;
    }

    int &ans = dp[i];
    if(ans != -1){
        return ans;
    }

    ans = min(findAns(i + 1) + abs(a[i] - a[i + 1]), findAns(i + 2) + abs(a[i] - a[i + 2]));
    return ans;
}

int32_t main(){
   IOS;
   memset(dp, -1, sizeof(dp));

   cin >> n;

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

   cout << findAns(1);

}


Measured memory_bytes: 7512
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	ans := 0
	for i := a; i <= b; i++ {
		if c % i == 0 {
			ans++
		}
	}
	fmt.Println(ans)
}



Measured memory_bytes: 1108
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;

int main() {
    int R,G,B,N; cin>>R>>G>>B>>N;
    long ans = 0;
    for (int r = 0; r*R<=N; r++) {
        for (int g = 0; r*R+g*G <= N; g++) {
            if ((N - (r*R+g*G)) % B == 0)
                ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;
#define MOD 1000000007LL

struct numb{
  int num;
  ll zero, one;
  numb(){}
  numb(int a, ll b, ll c){num = a; zero = b; one = c;}
};

int main(){
  ll N, K;
  cin >> N >> K;
  vi counter(40, 0);
  ll zeroans = 0LL;
  for(int i = 0; i < N; i++){
    ll A;
    cin >> A;
    zeroans += A;
    for(int j = 0; j < 40; j++){
      if((A >> j) & 1) counter.at(j)++;
    }
  }
  if(K==0){
    cout << zeroans << endl;
    return 0;
  }

  vector<numb> num(40);
  ll n = 1LL;
  for(int i = 0; i < 40; i++){
    if(counter.at(i) > N/2){ //半分以上が1
      num.at(i) = numb(0, n * counter.at(i), n * (N-counter.at(i))); //理想, 0のとき, 1のとき
    }
    else{
      num.at(i) = numb(1, n * counter.at(i), n * (N-counter.at(i)));
    }
    n *= 2LL;
  }
  vi saidai(40, 0);
  int NN = 0;
  for(int i = 0; i < 40; i++){
    if((K >> i) & 1){
      NN = i;
      saidai.at(i)++;
    }
  }

  // K != 0のとき（K == 0のときはX == 0のときが答え）
  vvll dp(NN+1, vll(2, 0));
  dp.at(NN).at(0) = num.at(NN).one;
  dp.at(NN).at(1) = num.at(NN).zero;
  for(int i = NN; i >= 1; i--){
    ll x = max(num.at(i-1).zero, num.at(i-1).one);
    chmax(dp.at(i-1).at(1), dp.at(i).at(1) + x);
    if(saidai.at(i-1) == 1){
      chmax(dp.at(i-1).at(1), dp.at(i).at(0) + num.at(i-1).zero);
      chmax(dp.at(i-1).at(0), dp.at(i).at(0) + num.at(i-1).one);
    }
    else{
      chmax(dp.at(i-1).at(0), dp.at(i).at(0) + num.at(i-1).zero);
    }
  }
  ll answer = max(dp.at(0).at(0), dp.at(0).at(1));
  for(int i = NN+1; i < 40; i++){
    answer += num.at(i).zero;
  }
  cout << answer << endl;
}

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

int main(){
  bool f; 
  string s,pass;
  cin >> s >> pass;
  for(int i=0;i<s.size()-pass.size()+1;i++){
    f = true;
    for(int j=0;j<pass.size();j++){
      if(s[i+j] != pass[j] && pass[j] != '_'){ f = false; break; }
    }
    if(f) break;
  }
  cout << (f ? "Yes" : "No") << endl;
}
      
      


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

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    lli N, A, B;
    cin >> N >> A >> B;
    vector<lli> h(N);
    REP (i, 0, N) cin >> h[i];
    lli l = 0;
    lli r = 1LL << 31;
    lli ans = r;
    while (l <= r) {
        lli mid = (l + r) / 2;
        lli cnt = 0;
        REP (i, 0, N) {
            if (h[i] > mid * B) {
                cnt += (h[i] - mid * B + A - B - 1) / (A - B);
            }
        }
        if (cnt <= mid) {
            ans = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    ll cnt[n], a[n];
    fill(cnt, cnt+n, 0);
    for (int i=0; i<n; i++) {
        cin >> a[i];
        a[i]--;
        cnt[a[i]]++;
    }
    ll sum = 0;
    for (auto &ci:cnt) sum += ci * (ci-1) / 2;
    for (auto &ai:a) {
        cout << sum - cnt[ai] + 1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string.h>
#include <algorithm>
#include <climits>

#define M 20
#define lengthof(x) (sizeof(x)/sizeof(*(x)))

int c[M];
int sum[256];
int bsum[256];

using namespace std;

int main(void)
{
	int n,m;
	int x;
	int i1,i2,i3;
	int minn;
	int temp;

	while(1){
		cin>>n>>m;
		if(n+m==0) break;

		memset(bsum,-1,sizeof(bsum));
		bsum[128]=0;

		for(i1=0;i1<m;i1++){
			cin>>c[i1];
		}

		for(i1=0;i1<n;i1++){
			cin>>x;
			fill((int*)sum,(int*)(sum+lengthof(sum)),INT_MAX);
			for(i2=0;i2<256;i2++){
				if(bsum[i2]!=-1){
					for(i3=0;i3<m;i3++){
						temp=i2+c[i3];
						if(temp<0) temp=0;
						if(255<temp) temp=255;

						sum[temp]=min(sum[temp],bsum[i2]+(temp-x)*(temp-x));
					}
				}
			}

			for(i2=0;i2<256;i2++){
				if(sum[i2]<INT_MAX) bsum[i2]=sum[i2];
				else bsum[i2]=-1;
			}
		}

		minn=sum[0];
		for(i1=0;i1<256;i1++){
			if(minn>sum[i1]) minn=sum[i1];
		}

		cout<<minn<<endl;

	}
	return 0;
}

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

int mi = 10;

int sum;

signed main() {

    int a[6];
    for ( int i = 0; i < 5; i++ ) {
        cin >> a[i];
        int la = a[i] % 10;
        if ( la != 0 ) mi = min ( mi, la );
        else la = 10;
        sum += a[i] + (10-la);
    }
    cout << sum-10+mi << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#define fi first
#define se second
#define pb push_back
#define last(s) (s)[(s).length()-1]
#define all(a) (a).begin(),(a).end()
#define elif else if
#define left asdasd
#define next zaza
#define prev azaz
#define cclear cout<<flush;
#define x0 kerker
#define y0 lolik
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
using namespace std;
 
using llong = long long;
using ld = long double;
using ii = pair<int,int>;
using ull = unsigned long long;
using ll = pair<llong, llong>;
 
const llong over999 = 1e12;
const llong md = 1e9+7;
const ld eps = 1e-9;
const ld Pi = acos(-1);
 
/**/

int ans = 1e9, n;

int sum (int x){
    int ans = 0;
    for(;x;x/=10)ans+=x%10;
    return ans;
}

int32_t main() {
    kchay;
    
    cin >> n;
    
    for(int i = 1; i < n; i++){
        ans = min(ans, sum(i) + sum(n-i));
    }
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand((unsigned)time(NULL));
  ll N;
  cin >> N;
  ll ans = 0LL;
  for(ll i = 0; i < N; i++){
    ans += (i+1LL) * (N-i);
  }
  for(int i = 0; i < N-1; i++){
    ll u, v;
    cin >> u >> v;
    if(u < v) swap(u, v);
    ans -= (N - u + 1) * v;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 510;
const int maxm = 2e5+5;
int A[maxn][maxn];

void update(int T[], const int n, int i, const int val)
{
    if (i > 0) {
        while (i < n) {
            T[i] += val;
            i += (i & -i);
        }
    }
}

int query(const int T[], int i)
{
    int sum = 0;
    if (i > 0) {
        while (i > 0) {
            sum += T[i];
            i -= (i & -i);
        }
    }
    return sum;
}

int main()
{
    int n,m,q;
    while (cin >> n >> m >> q) {
        memset(A,0,sizeof(A));
        FOR(i,0,m) {
            int a,b; cin >> a >> b;
            FOR(j,b,n+1)
                update(A[j],n+1,a,1);
        }
        FOR(_,0,q) {
            int a,b; cin >> a >> b;
            const int ans = query(A[b],b) - query(A[b],a-1);
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<set>

using namespace std;

int main(){
  int n;
  cin>>n;
  int a[123],b[123];
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  multiset<int> m;
  int nnew=0;
  for(int i=1;i<=31;i++){
    for(int j=0;j<n;j++){
      if(a[j]==i){
	m.insert(b[j]);
      }
    }
    if(!m.empty()){
      nnew++;
      m.erase(m.begin());
    }
    m.erase(i);
  }
  cout<<nnew*100+(31-nnew)*50<<endl;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    string a, b, c;
    cin >> a>> b >> c;
   
    if (a[a.size()-1] == b[0] && b[b.size()-1]==c[0]) 
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll=long long;

int main(){
    ll n;
    cin >> n;
    int a[100005] = {};
    int b[100005] = {};
    for(int i = 0; i < n/2; i++){
        int x, y;
        cin >> x >> y;
        a[x]++, b[y]++;
    }
    int amax=0, bmax=0, ai, bi;
    for(int i = 0; i < 100005; i++){
        if(amax<a[i]) amax = a[i], ai = i;
        if(bmax<b[i]) bmax = b[i], bi = i;
    }
    sort(a, a+100005, greater<int>());
    sort(b, b+100005, greater<int>());
    if(ai == bi) cout << min(n-a[0]-b[1], n-a[1]-b[0]) << endl;
    else cout << n - a[0] - b[0] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef vector<int> ivec;
typedef vector<string> svec;

//int a[100010];
const double PI=3.14159265358979323846;
int main(){
	double n=0;
	cin>>n;
	
	cout<<PI*n*2<<endl;
} 


Measured memory_bytes: 3780
#include "bits/stdc++.h"
using namespace std;

//template
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define repr(i,n) for(ll i=n;i>0;i--)
#define all(v) v.begin(),v.end()
#define in cin>>
#define out cout<<
#define en <<endl
const ll INF = 10000000000000;

int main()
{
	ll a, b;
	in a >> b;
	out a* b <<" "<< (a + b) * 2 en;
}



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

typedef long long s64;

const int MaxN = 300;
const int M = 1000000007;

inline int add(int a, const int &b)
{
	a += b;
	return a >= M ? a - M : a;
}

int n, m;
vector<pair<int, int>> rest[MaxN + 1];

int f[MaxN + 1][MaxN + 1];
int g[MaxN + 1][MaxN + 1];

int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		int l, r, x;
		cin >> l >> r >> x;

		rest[r].emplace_back(l, x);
	}

	f[0][0] = 1;

	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j <= i; ++j)
			for (int k = 0; k <= i; ++k)
				g[j][k] = f[j][k], f[j][k] = 0;

		for (int j = 0; j < i; ++j)
			for (int k = 0; k < i; ++k)
			{
				if (!g[j][k])
					continue;

				int v = g[j][k];
				f[j][k] = add(f[j][k], v);
				f[i - 1][k] = add(f[i - 1][k], v);
				f[j][i - 1] = add(f[j][i - 1], v);
			}

		for (int j = 0; j <= i; ++j)
			for (int k = 0; k <= i; ++k)
			{
				if (!f[j][k])
					continue;

				for (auto p : rest[i])
				{
					int l = p.first;
					if (1 + (l <= j) + (l <= k) != p.second)
					{
						f[j][k] = 0;
						break;
					}
				}
			}
	}

	int res = 0;
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= n; ++j)
			res = add(res, f[i][j]);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
ll cnt[26];
signed main() {
	string s;
	cin >> s;
	rep(i, s.size())cnt[s[i] - 'a']++;
	rep(i, 26) {
		if ((s.size() - 1) / 3 + 1 < cnt[i]) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 512
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [k, x] <- getIntList
  putStrLn $ if k * 500 >= x then "Yes" else "No"


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n,m; cin>>n>>m;
  vector<string> a(n);
  rep(i,n) cin>>a[i];
  vector<string> b(m);
  rep(i,m) cin>>b[i];

  rep(i,n-m+1) rep(j,n-m+1) {
    bool is_match = true;
    rep(y,m) {
      rep(x,m) {
        if (a[i+y][j+x]!=b[y][x]) {
          is_match = false;
          break;
        }
      }
      if(!is_match) break;
    }
    if (is_match) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}

int main()
{
  solve();
  return 0;
}


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

int main(){

  int i,m,s,e,x,y;

  cin >> i >> m >> s >> e;

  x = i + m + s + e;

  cin >> i >> m >> s >> e;

  y = i + m + s + e;

  cout << max(x,y) << endl;

}

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



ll N;




int main(){
	cin >> N;
	
	ll result = 0;
	for ( ll x = (ll)sqrt((double)N); ; x-- ){
		if ( N % x == 0 ){
			result = x-1 + N/x-1;
			break;
		}
	}
	
	cout << result << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define FASTER ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

int main()
{
    FASTER;

    LL n, N;
    cin >> n;
    N = n;
    int sum = 0;
    while(n){
        sum += (n % 10);
        n /= 10;
    }
    if(N % sum == 0) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256