akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define int long long

constexpr int INF = 1e18;

void solve(int n, int t, vector<int> &H){
  int maximum = 0, sum = 0, b = INF, bans = 0, tb;

  for(int i = 0; i < n; i++){
    int h, ans = 0;

    //cin>>h;

    h = H[i];

    maximum = max(h, maximum);

    if(sum > t) ans = 1;
    else {

      ans = (t - sum + maximum - 1) / maximum;

      // if( (t - sum + maximum - 1) >= h) ans++;

      tb = t - sum - (t - sum) / maximum * maximum;

       if(tb >= h) ans++;

      if((t-sum) % maximum == 0) ans++;

    }

    cout<<ans<<endl;
    //cout<<ans<<" <> "<<tb<<" ";
    bans = ans;
    sum += h;
  }
  // cout<<endl;
}

signed main(){
  int n, t;
  vector<int> h;

  cin>>n>>t;


  h.resize(n);

  for(int i = 0; i < n; i++){
    cin>>h[i];

  }

  for(int i = t; i <= t; i++){
    //cout<<"t = "<<i<<" ";
    solve(n, i, h);
  }

  return 0;
}



Measured memory_bytes: 3588
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
dif=[]

s=0
ans=0
for g in range(n):
    if a[g]<b[g]:
        s+=b[g]-a[g]
        ans+=1
    elif a[g]>b[g]:
        dif.append(a[g]-b[g])
dif.sort(reverse=True)

if s==0:
    print(0)
    exit()

for l in range(len(dif)):
    s-=dif[l]
    ans+=1
    if s<0:
        break

if s<=0:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 81328
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    int Rcnt = 0;
    int Bcnt = 0;
    for(int i = 0; i < N; i++)
    {
        if (s[i] == 'R') {
            Rcnt++;
        } else {
            Bcnt++;
        }
    }
    if (Rcnt > Bcnt) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 256
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const [n, m] = spi[0].split(' ').map(e => Number(e));

    const h = spi[1].split(' ').map(e => Number(e));
    const bArray = new Array(n).fill(true);

    for (let i = 2; i < m + 2; i++) {
        const [a ,b] = spi[i].split(' ').map(e => Number(e));
        if (h[a - 1] <= h[b - 1]) bArray[a - 1] = false;
        if (h[b - 1] <= h[a - 1]) bArray[b - 1] = false;
    }

    let ans = 0;
    for (let i = 0; i < n; i++) {
        if (bArray[i]) ans++;
    }
    console.log(ans);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  for (int i = 0; i < 5; ++i) {
    int a; scanf("%d", &a);
    if (a) continue;
    printf("%d", i+1);
    return;
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

Measured memory_bytes: 604
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   if(b%a == 0) cout << a+b << endl;
   else cout << b-a << endl;





   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

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

    double S = a * b * sin(C * M_PI / 180.0) / 2;
    printf("%0.5lf\n", S);

    double c = pow(a, 2) + pow(b, 2) - 2 * a * b * cos(C * M_PI / 180.0);
    c = sqrt(c);

    double L = a + b + c;
    printf("%0.5lf\n", L);

    double h = b * sin(C * M_PI / 180.0);
    printf("%0.5lf", h);
}



Measured memory_bytes: 3640
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
d = defaultdict(int)
for a in A:
    d[a] += 1
ans = 0
for v in d.values():
    ans += v*(v-1) //2 

for a in A:
    v = d[a]
    print(ans - (v*(v-1))//2 + ((v-1)*(v-2))//2)


Measured memory_bytes: 26772
#include <iostream>
#include <vector>

using namespace std;

int count(vector<int> s, vector<int> t) {
	int cnt = 0;

	for(int i = 0;i < t.size();i++) {
		for(int j = 0;j < s.size();j++) {
			if(t[i] == s[j]) {
				cnt++;
				break;
			}
		}
	}

	return cnt;
}

int main() {
	int n;
	vector<int> s, t;

	cin >> n;

	s.resize(n);

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

	cin >> n;

	t.resize(n);

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

	int ans = count(s, t);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3188
#include<algorithm>
#include<vector>
#include<cstring>
#include<iostream>
#include<cmath>

using namespace std;

const int mod = 1e9+7;


int main() {
	int n;
	scanf("%d", &n);

	long long a[n][n];
	for(int i=0; i<n; i++) {
		for(int j=0; j<n; j++) {
			scanf("%lld", &a[i][j]);
		}
	}
	const int dp_size = (1<<n);

	int num_bits[dp_size];
	vector<int> masks[n+1];
	num_bits[0] = 0;
	masks[0].push_back(0);
	for(int i=1; i<dp_size; i++) {
		num_bits[i] = num_bits[i>>1]+(i&1);
		masks[num_bits[i]].push_back(i);
	}

	long long mask_value[dp_size];
	memset(mask_value, 0, sizeof mask_value);
	for(int set_bits=2; set_bits<=n; set_bits++) {
		for(auto mask: masks[set_bits]) {
			int first;
			for(int i=0; i<n; i++) {
				if(mask&(1<<i)) {
					first = i;
					break;
				}
			}
			int pre_mask = mask^(1<<first);
			long long add_val = 0;
			for(int i=0; i<n; i++) {
				if(pre_mask&(1<<i)) {
					add_val += a[first][i];
				}
			}
			mask_value[mask] = mask_value[pre_mask] + add_val;
		}
	}

	long long dp[dp_size];
	memset(dp, 0, sizeof dp);
	for(int set_bits=n-1; set_bits>=0; set_bits--) {
		for(auto set_mask: masks[set_bits]) {
			for(int mask = (set_mask+1)|set_mask; mask<dp_size; mask = (mask+1)|set_mask ) {
				int diff_mask = mask^set_mask;
				dp[set_mask] = max(dp[set_mask], dp[mask] + mask_value[diff_mask]);
			}
		}
	}
	printf("%lld\n", dp[0]);
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> Factorial(5e6),Finverse(5e6);
void Cinit(){// limit is 5e6 /// write Cinit&pw /// this takes 792ms at AtCoder
  Factorial[0]=1;
  for(int i=1;i<5e6;i++)Factorial[i]=Factorial[i-1]*i%MOD;
  for(int i=0;i<5e6;i++)Finverse[i]=pw(Factorial[i],MOD-2);
}
int nCk(int n,int k){
  if(n<k)return 1;if(k<0)return 0;
  int res=Factorial[n];
  res*=Finverse[k];res%=MOD;
  res*=Finverse[n-k];res%=MOD;
  return res;
}

signed main(){
  Cinit();
  int h,w,k;cin>>h>>w>>k;
  int ans=0;
  for(int i=1;i<h;i++)ans+=(h-i)*i,ans%=MOD;
  ans*=w;ans%=MOD;ans*=w;ans%=MOD;
  ans*=nCk(h*w-2,k-2);ans%=MOD;
  int ans2=ans;
  swap(h,w);
  ans=0;
  for(int i=1;i<h;i++)ans+=(h-i)*i,ans%=MOD;
  ans*=w;ans%=MOD;ans*=w;ans%=MOD;
  ans*=nCk(h*w-2,k-2);ans%=MOD;
  cout<<(ans+ans2)%MOD<<endl;
}


Measured memory_bytes: 78464
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k,s;
    cin>>k>>s;
    int ans=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(0<=s-i-j&&s-i-j<=k){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

void init(string* s, string* p, int* s_len, int* p_len, string* buf){
  cin >> *s;
  cin >> *p;
  *s_len = s->length();
  *p_len = p->length();
  buf->erase();
}

int main(){

  string s;
  string p;
  string buf;
  int s_len;
  int p_len;
  int buf_len=0;
  bool flg=false;
  
  init(&s, &p, &s_len, &p_len, &buf);
  
  for(int i=0;i<s_len;i++)
    {
      for(int j=0;j<p_len;j++)
        {
          buf_len = i+j;
          if(buf_len>=s_len)
            {
              buf_len%=s_len;
            }
          buf+=s.at(buf_len);
        }
      if(buf == p)
        {
          flg = true;
        }
      buf.erase();
    }

  if(flg==true)
    {
      cout << "Yes" << endl;
    }
  else
    {
      cout << "No" << endl;
    }
}

Measured memory_bytes: 1188
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<map>
#include<set>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

long long gcd(long long x, long long y){
    if(y == 0)return x;
    return gcd(y, x % y);
}

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

int main(){
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    set<ll> st;
    st.insert(1);
    if(is_prime(g)) st.insert(g);
    ll ans = 0;
    for(ll i = 1; i * i <= g; i++){
        if(g % i == 0){
            if(is_prime(i)) ans++;
            if(is_prime(g / i)) ans++;
        }
    }
    if(g == 1) ans--;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main 
{
	static long mod(long l)
	{
		long an = l%m;
		while(an<0)an+=m;
		return an;
	}
	static int mod(int l)
	{
		int an = (int)(l%m);
		while(an<0)an+=m;
		return an;
	}
	static long m;

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		m = sc.nextLong();
		
		HashMap<Long, Integer> inv = new HashMap<>();
		
		
		long score = 0;
		long conback = 0;
		for(int i = 0; i < n; i++)
		{
			long cur = sc.nextLong()%m;
			
			long cura = (0 + conback);
			
			if(inv.containsKey(cura)) inv.put(cura, inv.get(cura)+1);
			else inv.put(cura, 1);
			
			conback = mod(conback-cur);
			
			if(inv.containsKey(conback))
				score += inv.get(conback);
		}
		System.out.println(score);

	}

}


Measured memory_bytes: 60260
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=r;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=r;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int l,i,j,m,nt,mint=inf;
    char s[128];
    scanf("%s",s);
    l=strlen(s);
    for(i = 97;i <= 122;i++){
        m=0;
        nt=0;
        for(j = 0;j < l;j++){
            if(s[j] == i){
                nt=max(nt,m);
                m=0;
            }
            else{m++;}
        }
        nt=max(nt,m);
        mint=min(mint,nt);
    }
    printf("%d\n",mint);
    return 0;
}

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

using namespace std;

using ll = long long;
using Pii = pair<int, int>;

int main() {
    int w, h, n, x, y, a;
    cin >> w >> h >> n;
    
    int l = 0, r = w, b = 0, t = h;
    for (int i = 0; i < n; ++i) {
        cin >> x >> y >> a;
        if (a == 1) {
            l = max(l, x);
        }
        else if (a == 2) {
            r = min(r, x);
        }
        else if (a == 3) {
            b = max(b, y);
        }
        else {
            t = min(t, y);
        }
    }

    cout << max(0, r-l) * max(0, t-b) << endl;

    return 0;
}


Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string C1 = Console.ReadLine();
            string C2 = Console.ReadLine();

            if (C1[0] == C2[2] && C1[1] == C2[1] && C1[2] == C2[0])
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

template<class T>
struct WeightedUnionFind{
	vector<int> par,rnk;
	vector<T> pardiff;

	WeightedUnionFind(int n) : par(n),rnk(n),pardiff(n){
		for(int i = 0;i < n;i++) par[i] = i;
	}

	int find(int x){
		if(x == par[x]) return x;
		int root = find(par[x]);
		pardiff[x] += pardiff[par[x]];
		return par[x] = root;
	}

	bool unite(int x,int y,T w){
		if(same(x,y)) return diff(x,y) == w;
		w = w + weight(x) - weight(y);
		x = find(x); y = find(y);
		if(rnk[x] < rnk[y]) swap(x,y), w = -w;
		if(rnk[x] == rnk[y]) rnk[x]++;
		par[y] = x;
		pardiff[y] = w;
		return true;
	}
	
	inline bool same(int x,int y){
		return find(x) == find(y);
	}

	T diff(int x,int y){
		assert(same(x,y));
		return weight(y) - weight(x);
	}

	T weight(int x){
		find(x);
		return pardiff[x];
	}
};

using ll = long long;

int n,m;

void solve(){
	WeightedUnionFind<ll> wuf(n);
	for(int i = 0;i < m;i++){
		char c[1];
		int a,b;
		scanf("%s %d %d",c,&a,&b); a--;b--;
		if(c[0] == '!'){
			ll w;
			scanf("%lld",&w);
			wuf.unite(a,b,w);
		}else{
			if(!wuf.same(a,b)) puts("UNKNOWN");
			else printf("%lld\n",wuf.diff(a,b));
		}
	}
}

signed main(){
	while(scanf("%d %d",&n,&m),n) solve();
}


Measured memory_bytes: 4436
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <vector>
#define EPS 1e-10
using namespace std;
typedef long long ll;
struct Point{
	double x,y;
	Point(double x = 0,double y = 0): x(x),y(y) {}
	Point operator + (Point p){
		return Point(x + p.x,y + p.y);
	}
	Point operator - (Point p){
		return Point(x - p.x,y - p.y);
	}
	Point operator - (){
		return Point(-x,-y);
	}
	Point operator * (double lambda){
		return Point(x * lambda,y * lambda);
	}
	Point operator / (double lambda){
		return Point(x / lambda,y / lambda);
	}
	Point rot(double theta){
		return Point(cos(theta) * x - sin(theta) * y,
								sin(theta) * x + cos(theta) * y);
	}
	double norm(){
		return x * x + y * y;
	}
	double abs_(){
		return sqrt(norm());
	}
	bool operator == (const Point p)const
	{
		return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
	}
	bool operator < (const Point p)const
	{
		if(abs(x - p.x) < EPS) return y < p.y;
		return x < p.x;
	}
};
typedef Point Vector;
double dot(Vector a,Vector b){
	return a.x * b.x + a.y * b.y;
}
double det(Vector a,Vector b){
	return a.x * b.y - a.y * b.x;
}
typedef vector <Point> Polygon;
double diameter(Polygon po){
	int n = po.size(), minp = 0, maxp = 0;
	for(int i=1;i<n;i++){
		if(po[i] < po[minp]) minp = i;
		if(po[maxp] < po[i]) maxp = i;
	}
	int i = minp, j = maxp;
	double ans = 0.0;
	while(i != maxp || j != minp){
		ans = max(ans,(po[i] - po[j]).abs_());
		if(det(po[(i + 1) % n] - po[i], po[(j + 1) % n] - po[j]) < EPS){
			i = (i + 1) % n;
		}else{
			j = (j + 1) % n;
		}
	}
	return ans;
}
int n; Polygon g;
int main(){
	scanf("%d",&n);
	g.resize(n);
	for(int i=0;i<n;i++) scanf("%lf%lf",&g[i].x,&g[i].y);
	printf("%.10f\n",diameter(g));
	return 0;
}


Measured memory_bytes: 5220
h, w, k = map(int, input().split())

c = [[] for _ in range(h)]

for i in range(h):
    tmp = list(str(input()))
    c[i] = tmp

nh = 1 << h
nw = 1 << w

ans = 0

import copy
for i in range(nh):
    for j in range(nw):
        arr = copy.deepcopy(c)
        for x in range(h):
            if (i >> x) & 1:
                for t in range(w):
                    arr[x][t] = 'r'
        for y in range(w):
            if (j >> y) & 1:
                for t in range(h):
                    arr[t][y] = 'r'
        count = 0
        for x in range(h):
            for y in range(w):
                if arr[x][y] == '#':
                    count += 1
        if count == k:
            ans += 1
print(ans)


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

using namespace std;

int main(){
	int n;
	cin >> n;
	if(n % 1000 == 0){
		cout << "0";
	} else{
		cout << (n / 1000 + 1) * 1000 - n;
	}
	return 0;
}

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

int main(){
    
    int n;
    cin>>n;
    vector<int> ans(2*n);
    for(int i=0;i<2*n;i++){
        cin>>ans[i];
    }
    int out=0;
    sort(ans.begin(),ans.end());
    for(int i=0;i<2*n;i=i+2){
        out=out+ans[i];
    }
    cout<<out;
    return 0;
    
}


Measured memory_bytes: 256
A, B, Q = list(map(int, input().split()))
# もし神社(寺)が1つしかなかった場合に両端に仮想の神社を建築して処理の一貫性を保つ。かりにこれが選ばれても最大のコストなので最終的に最適になることはない。
INF = 10 ** 18

S = [-INF] + [int(input()) for _ in range(A)]+[INF]
T = [-INF] + [int(input()) for _ in range(B)]+[INF]

from bisect import bisect_right
from itertools import product


for q in range(Q):  # 各問に答える
    x = int(input())  # 位置の指定
    s_idx, t_idx = bisect_right(S, x), bisect_right(T, x)
    ans = INF
    # 左右の神社と寺のの組み合わせ
    for s, t in product(S[s_idx - 1:s_idx + 1], T[t_idx - 1:t_idx + 1]):
        t_root = abs(t - x) + abs(s - t)  # 寺から最初に回るルート
        s_root = abs(s - x) + abs(s - t)
        ans = min(ans, t_root, s_root)
    # 最小をとって終わり
    print(ans)

'''
bisect_right

ソートされた順序を保ったまま x を a に挿入できる点を探し当てます。リストの中から検索する部分集合を指定するには、パラメータの lo と hi を使います。デフォルトでは、リスト全体が使われます。x がすでに a に含まれている場合、挿入点は既存のどのエントリーよりも後(右)になります。戻り値は、list.insert() の第一引数として使うのに適しています。a はすでにソートされているものとします。


In[3]: A
Out[3]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

In[4]: bisect.bisect_right(A, 2.5)
Out[4]: 3

In[5]: bisect.bisect_right(A, 3)
Out[5]: 4
'''


Measured memory_bytes: 14092
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=998244353;
const ll N = 2e5+10;



ll mul(ll a,ll b){
    return ((a%mod)*(b%mod)*1LL)%mod;
}

void solve(){
    ll n=0;
    cin>>n;
    map<string,ll>mp;
    for (int i = 0; i < n; i++) {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<mp.size()<<"\n";
    


    

       
}



int main(){

    
        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        ll T=1;
        //cin>>T;
        while(T--){
            solve();
        }
        return 0;

}

Measured memory_bytes: 19272
#include<iostream>
//using namespace std;
#define LEN 100005
using namespace std;
struct pp{
    char name[100];
    int time;
};
pp queue[LEN];
int head, tail;
int isempty()
{
    return head == tail;
}
int isfull()
{
    return (tail+1)%LEN;
}
void enqueue(pp x)
{
    queue[tail]=x;
    tail=(tail+1)%LEN;
}
pp dequeue()
{
    pp x = queue[head];
    head = (head+1)%LEN;
    return x; 
}
int main()
{
    int n,Max_Time,total=0;
    cin>>n;
    cin>>Max_Time;
    for(int i=0;i<n;i++)
    {
        cin>>queue[i].name;
        cin>>queue[i].time;
    }
    head=0;
    tail=n;
   // cnt=0;
    while(head!=tail)
    {
        pp x = dequeue();
        if(x.time<=Max_Time)
        {
            total+=x.time;
            cout<<x.name<<" "<<total<<endl;
        }
        else
        {
            x.time -= Max_Time;
            total += Max_Time;
            enqueue(x);
        }
    }
    return 0;
}


Measured memory_bytes: 13160
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll INF=1000000010;
const ll MOD=1000000007;
const ll LINF=4000000000000000000;
const long double EPS=1e-9;
typedef pair<int,int> P;
ll dp[100010];
int main(){
    int N,M,K;cin>>N>>M>>K;
    ll a[100010];
    for(int i=1;i<=N;i++)cin>>a[i],dp[i]=a[i];
    for(int i=2;i<=K;i++){
        deque<int> deq;
        ll dp2[100010]={};
        for(int j=i;j<=N;j++){
            while(!deq.empty()&&dp[deq.back()]<=dp[j-1])deq.pop_back();
            deq.push_back(j-1);
            dp2[j]=dp[deq.front()];
            while(!deq.empty()&&deq.front()<=j-M)deq.pop_front();
        }
        for(int j=1;j<=N;j++)dp[j]=dp2[j]+a[j]*i;
    }
    ll ans=0;
    for(int i=1;i<=N;i++){
        ans=max(dp[i],ans);
    }
    cout<<ans<<endl;
}

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

int main()
{
  int n,i;
  int x,a,b,c;
  cin >> n;
  
  for(i=1;i<=n;i++){
    x=i;
    a=x/10;
    b=x/100;
    c=x/1000;

    if(x%3==0){
      cout << " " << i;
    }else if(x%10==3){
      cout << " " << i;
    }else if(a%10==3){
      cout << " " << i;
    }else if(b%10==3){
      cout << " " << i;
    }else if(c%10==3){
      cout << " " << i;
    }
  }
  
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	int tate=ty-sy;
	int yoko=tx-sx;
	for(int i=0;i<tate;i++)cout<<'U';
	for(int i=0;i<yoko;i++)cout<<'R';
	for(int i=0;i<tate;i++)cout<<'D';
	for(int i=0;i<yoko+1;i++)cout<<'L';
	for(int i=0;i<tate+1;i++)cout<<'U';
	for(int i=0;i<yoko+1;i++)cout<<'R';
	cout<<'D';
	cout<<'R';
	for(int i=0;i<tate+1;i++)cout<<'D';
	for(int i=0;i<yoko+1;i++)cout<<'L';
	cout<<'U'<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

char ch;
template <typename T>
void read(T& x)
{
    x = 0;
    ch = getchar();
    for (; !isdigit(ch); ch = getchar());
    for (; isdigit(ch); x = x * 10 + (ch ^ 48), ch = getchar());
}

int n, s, ans = 1;
int a[1000010];

int main()
{
    read(n);
    for (int i = 1; i <= n; ++i)
        read(a[i]), s += a[i];
    for (int i = 1; i <= n; ++i)
        ans &= (a[i] < s - a[i]);
    if (ans)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
ll K;

int main(){
	cin >> K;

	ll k = K % 50;

	vector<ll> a(50);
	for(int i=0; i<k; i++){
		a[i] = 50-k+50;
	}
	for(int i=k; i<50; i++){
		a[i] = 49-k;
	}

	for(int i=0; i<50; i++){
		a[i] += K/50;
	}

	cout << 50 << endl;
	for(int i=0; i<50; i++){
		cout << a[i] << (i==49 ? '\n' : ' ');
	}

	return 0;
}


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

int prize(int p){
  if(p==3)return 100000;
  else if(p==2)return 200000;
  else if(p==1)return 300000;
  return 0;
}

int main(){
  int X,Y,ans;
  cin>>X>>Y;
  cout<<prize(X)+prize(Y)+(X==1&&Y==1)*400000<<endl;
}

Measured memory_bytes: 256
(defun perm-number (x n)
  (setf x (reverse x))
  (block outer
    (let ((count 1))
      (labels ((rec (rest pattern)
                 (if rest
                     (loop for item in rest
                           for list = (remove item rest)
                           do  (rec list (cons item pattern)))
                     (if (equal x pattern)
                         (return-from outer count)
                         (incf count)))))
        (rec (loop for i from 1 to n collect i) nil)))))

(let* ((n (read))
       (p (loop repeat n collect (read)))
       (q (loop repeat n collect (read))))
  (format t "~a~%"
          (abs (- (perm-number p n)
                  (perm-number q n)))))


Measured memory_bytes: 15972
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  if(a[0]==a[1] && a[1]==a[2]){
    cout << "Yes" << endl;
  }
  else if(a[1]==a[2]&&a[2]==a[3]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No"  << endl;
  }
}

Measured memory_bytes: 256
<?php
    $slime_cnt = fgets(STDIN);
    $slimes = str_split(fgets(STDIN));
    # $slime = explode('', $slimes);
    # $slime = str_split($slimes);

    $cnt = (int)$slime_cnt;
    for($i=0; $i<=$slime_cnt; $i++){
        if($slimes[$i] == $slimes[$i+1]){
            $cnt = $cnt -1;
        }
    }
    echo $cnt;
?>

Measured memory_bytes: 11000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		System.out.println(k * (long)Math.pow(k - 1, n - 1));
	}
}

Measured memory_bytes: 25172
n = int(input())
s1 = list(input())
s2 = list(input())

MOD = 10**9+7
i = 0
ans = 0
prev_double = True

if s1[0] == s2[0]:
    prev_double = False
    i = 1
    ans = 3
else:
    prev_double = True
    i = 2
    ans = 6

while i < n:
    if s1[i] == s2[i]:
        i += 1
        if prev_double:
            ans *= 1
        else:
            ans *= 2
        prev_double = False
    else:
        i+=2
        if prev_double:
            ans *= 3
        else:
            ans *= 2
        prev_double = True
    ans %= MOD
print(ans)

Measured memory_bytes: 61312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> B(2222222);

int nbB(int k, int start, int end){
    // return the nb of book
    if(B[start]>k){
        return start;
    }
    if(B[end]<=k){
        return end + 1;
    }
    if(start == end || start + 1 == end){
        return start + 1;
    }
    int mid = (start+end) / 2;
    if(B[mid]<=k){
        return nbB(k, mid, end);
    }
    return nbB(k, start, mid);
}

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<M;i++){
        cin >> B[i];
    }
    // sum
    for(int i=1;i<M;i++){
        B[i] = min(K+1, B[i-1]+B[i]);
    }
    for(int i=1;i<N;i++){
        A[i] = min(K+1, A[i-1]+A[i]);
    }
    // solve
    int nb = nbB(K, 0, M-1);
    for(int i=0;i<N;i++){
        if(A[i]>K){
            break;
        }
        int b = nbB(K-A[i], 0, M-1);
        nb = max(nb, i+1+b);
    }
    cout << nb << endl;

    return 0;
}

Measured memory_bytes: 12692
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	int n,w; cin>>n>>w;
	
	vi ds(n+1);
	for(int i=1;i<=w;i++){
		ds[i]+=2;
		for(int j=1,x=i;j*j<=x;j++)
			if(x%j==0){
				ds[j]++;
				if(j*j<x)
				ds[x/j]++;
			}
	}
	printf("%d",w); // f({1..w})=w は常に成立
	
	int cnt=w;
	for(int i=w+1;i<=n;i++){
		ds[i]+=2; cnt++;
		ds[i-w]-=2;
		if(ds[i-w]<2) cnt--;
		
		for(int j=1,x=i-w;j*j<=x;j++){
			if(x%j==0){
				ds[j]--;
				if(ds[j]==1) cnt--;
				if(j*j<x){
					ds[x/j]--;
					if(ds[x/j]==1) cnt--;
				}
			}
		}
		for(int j=1,x=i;j*j<=x;j++){
			if(x%j==0){
				ds[j]++;
				if(ds[j]==2) cnt++;
				if(j*j<x){
					ds[x/j]++;
					if(ds[x/j]==2) cnt++;
				}
			}
		}
		printf(" %d",cnt);
	}
	puts("");
	
	return 0;
}

Measured memory_bytes: 1532
N ,K = map(int, input().split())
S = input()
kirikae = 0
kirikae2 = 0
flag = 0
for i in range(N-1):
    if S[i] != S[i+1]:
        kirikae += 1
kirikae = kirikae - (K * 2)
if kirikae <= 0 :
    kirikae = 0

print(N - 1 - kirikae)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

ll mod = 1000000007;

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> a(21000000);
    for(int i = 0; i < M; i++) cin >> a[i];
    vector<ll> dp(21000000);
    for (int i = 0; i < 21000000; i++) dp[i] = INF;
    for (int i = 0; i < M; i++){
      dp[a[i] - 1] = 0;
    }
      if (a[0] == 1)
        dp[0] = 0;
      else
        dp[0] = 1;
    if ((a[0] == 1 && a[1] == 2)||a[0]==2) dp[1] = 0;
    else  if(a[0]==1 && a[1]!=2)dp[1] = 1;
    else
      dp[1] = 2;
    for (int i = 2; i < N; i++) {
      if (dp[i] == 0) continue;
      else
        dp[i] = (dp[i - 1]%mod + dp[i - 2]%mod)%mod;
    }
    cout << dp[N - 1]%mod << endl;
    return 0;
}

Measured memory_bytes: 331400
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;



int main(void) {
    ll N;
    ll a[MAX], b[MAX], c[MAX];
    cin>>N;
    ll i;
    ll ans=0;
    
    for(i=0; i<N; i++) {
        cin>>a[i]>>b[i];
        ans-=b[i];
        c[i]-=a[i]+b[i];
    }
    sort(c, c+N);
    
    for(i=0; i<N; i++) {
        if(i&1);
        else ans-=c[i];
    }
    
    pt(ans);
    
}






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

int main() {
    int n, m;
    cin >> n >> m;
    int h[n];
    vector<set<int>> tenbou(n);
    // bool tenbou[n][n];
    // rep(i, n){
    //     rep(j, n) tenbou[i][j] == false;
    // }
    rep(i, n){
        cin >> h[i];
    }
    int a[m], b[m];
    rep(i, m){
        cin >> a[i] >> b[i];
        tenbou[a[i]-1].insert(b[i]-1);
        tenbou[b[i]-1].insert(a[i]-1);
        // cout << "a" << endl;
    }
    // for(auto x : tenbou[1]) {
    //     cout << x << "\n";     // 要素を順に表示
    // }

    // rep(i, n){
    //     rep(j, m){
    //         cout << tenbou[i][j];
    //     }
    //     cout << endl;
    // }
    // cout << "a" << endl;
    int num = 0;
    rep(i, n){
        bool check = true;
        for(auto x: tenbou[i]){
            if(h[x] >= h[i]) check = false;
            // cout << "x = " << x << endl;
        }
        // cout << endl;
        if(check){
            // cout << i << endl;
            num++;
        }
    }
    cout << num << endl;


    
}

Measured memory_bytes: 18500
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int i,j,k,n,m,l,count1=0;
void ABC140(void);
void ABC141(void);
void ABC142(void);
void ABC143(void);
void ABC144(void);
void ABC145(void);
void ABC146(void);
void ABC147(void);
void ABC148(void);
void ABC149(void);

int main(void){
    ABC147();
}

void ABC147(){
    string s,s1,s2;
    cin>>s;
    n=s.length()/2;
    s1=s.substr(0,n);
    s2=s.substr(s.length()-n,n);
    cerr<<s1<<" "<<s2<<endl;
    reverse(s2.begin(),s2.end());
    cerr<<s2<<endl;
    for(i=0;i<n;i++){
        if(s1[i]!=s2[i])count1++;
    }
    cout<<count1<<endl;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int a[6],k;

int main(){
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
  sort(a,a+4);
  if(a[4]-a[0]>k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
// abc159_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
bool func(string s, int nS, int nE) {
  for(int i=nS;i<nE;++i) {
    if (s[i]!=s[nE-1-i]) {
      return false;
    }
  }
  return true;
}

int main()
{
  string s;
  bool b1,b2,b3;
  cin>>s;
  int n=(int)s.size();
  // nは必ず奇数
  b1=func(s,0,n);
  b2=func(s,0,(n-1)/2);
  b3=func(s,(n+3)/2-1,n);
  cout<<((b1&&b2&&b3) ? "Yes" : "No")<<endl;
  return 0;
}


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

D={}
for i in range(n):
      if A[i] in D:
            D[A[i]]+=1
      else:
            D[A[i]]=1

ans=0
for i in D:
      if i>D[i]:
            ans+=D[i]
      else:
            ans+=D[i]-i
print(ans)

Measured memory_bytes: 17780
#include <iostream>

using namespace std;

int main()
{
    long long n,mas[51],ans=0;
    cin>>n;
    for(long long i=0; i<n; i++){
        cin>>mas[i];
    }
    for(long long i=0; i<n; i++){
        for(long long j=i+1; j<n; j++){
            ans+=mas[i]*mas[j];
        }
    }
    cout<<ans;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

#define INF 1LL<<60



  int main(){
    double X;
    cin >> X;
    int tmp = (X + 1.07) / 1.08;
    double ans = tmp * 1.08;
    int ans2 = ans;
    if(X == ans2) print(tmp);
    else print(":("); 
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;


main()
{
  int n;
  while( cin >> n, n ) {
    string s;
    cin >> s;

    while( n-- ) {
      string tmp = "";
      char now = s[0];
      int cnt = 1;
      for(int i=1; i<s.size(); i++) {
	if( s[i] == now ) cnt++;
	else {
	  string tmp2 = "";
	  while( cnt ) {
	    tmp2 += ('0' + cnt % 10);
	    cnt /= 10;
	  }
	  for(int j=tmp2.size()-1; j>=0; j--) tmp += tmp2[j];
	  tmp += now;
	  now = s[i];
	  cnt = 1;
	}
      }

      string tmp2 = "";
      while( cnt ) {
	tmp2 += ('0' + cnt % 10);
	cnt /= 10;
      }
      for(int i=tmp2.size()-1; i>=0; i--) tmp += tmp2[i];
      tmp += now;
      s = tmp;
    }

    cout << s << endl;
  }
}

Measured memory_bytes: 3268
input = input()
is_good = True
for i, s in enumerate(input):
    if i > 0 and s == input[i-1]:
        is_good = False
        break
    if i < len(input) -1 and s == input[i+1]:
        is_good = False
        break
if is_good:
    print('Good')
else:
    print('Bad')

Measured memory_bytes: 2940
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	int n;
	cin >> n;

	int x = n * 800;
	int y = (n / 15) * 200;

	cout << x - y << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lolololololol ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int book[12][12];
int cost[12];
int main(){ lolololololol
	int n, m, x; cin>>n>>m>>x;
	for(int i=0; i<n; i++){
		cin>>cost[i];
		for(int j=0; j<m; j++)
			cin>>book[i][j];
	}
	int ans=1e9+69;
	for(int i=0; i<(1<<n); i++){
		int good[m], tmp=0;
		memset(good, 0, sizeof(good));
		for(int j=0; j<n; j++) if((i>>j)&1){
			tmp+=cost[j];
			for(int k=0; k<m; k++)
				good[k]+=book[j][k];
		}
		bool noob=false;
		for(int i=0; i<m; i++){
			if(good[i]<x){noob=true; break;}
		}
		if(!noob){
			ans=min(ans, tmp);
		}
	}
	if(ans==1e9+69) ans=-1;
	cout<<ans<<endl; return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#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 INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  string S;
  cin >> N;
  cin >> S;

  ll E = 0, W = 0;

  REP(i, N) {
    if (S[i] == 'E') {
      E++;
    } else {
      W++;
    }
  }

  ll cnt_E = 0, cnt_W = 0;
  ll ans = INF;

  REP(i, N) {
    ll now;
    if (S[i] == 'E') {
      now = 1;
    } else {
      now = 0;
    }

    ans = min(ans, cnt_W + E - cnt_E - now);

    if (S[i] == 'E') {
      cnt_E++;
    } else {
      cnt_W++;
    }
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;
struct T {
	int x, y, t;
};

const int X[4] = { 0,0,-1,1 }, Y[4] = { -1,1,0,0 };
int H, W, K, x, y, a[800][800], MIN;
char C[800][800];
queue<T>q;

int main() {
	cin >> H >> W >> K;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			a[i][j] = -1;
			cin >> C[i][j];
			if (C[i][j] == 'S') {
				x = i;
				y = j;
			}
		}
	}
	q.push({ x,y,0 });
	while (!q.empty()) {
		T t = q.front();
		q.pop();
		if (a[t.x][t.y] == -1) {
			a[t.x][t.y] = t.t;
			for (int i = 0; i < 4; ++i) {
				int XX = t.x + X[i], YY = t.y + Y[i];
				if (XX < 0 || H <= XX || YY < 0 || W <= YY || C[XX][YY] != '.' || a[XX][YY] != -1)continue;
				q.push({ XX,YY,t.t + 1 });
			}
		}
	}
	MIN = intmax;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (a[i][j] != -1 && a[i][j] <= K) {
				MIN = min({ MIN, i,j,H - 1 - i,W - 1 - j });
			}
		}
	}
	if (MIN == 0)cout << 1 << endl;
	else cout << ((MIN - 1) / K + 2) << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

bool solve(string& s, string& t) {
  map<char, char> mp1, mp2;
  for (int i = 0; i < s.size(); ++i) {
    if (mp1.find(t[i]) == mp1.end()) {
      mp1[t[i]] = s[i];
    } else {
      if (mp1[t[i]] != s[i]) return false;
    }
    if (mp2.find(s[i]) == mp2.end()) {
      mp2[s[i]] = t[i];
    } else {
      if (mp2[s[i]] != t[i]) return false;
    }
  }
  return true;
}

int main() {
  string s, t;
  cin >> s >> t;
  if (solve(s, t)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 776
#! env/bin/local python3
# -*- coding: utf-8 -*-

n, m = map(int, input().split())

pick_up_from_n = n * (n - 1) // 2
pick_up_from_m = m * (m - 1) // 2

print(pick_up_from_m + pick_up_from_n)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b;
    cin >> a >> b;
    if(a%3==0 || b%3==0 || (a+b)%3==0) {
        cout << "Possible" << endl;
    }else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
taro, hanako = 0, 0
for _ in range(n):
    
    data = input().split()
    if data[0] > data[1]:
        taro += 3
    elif data[0] < data[1]:
        hanako += 3
    else:
        hanako += 1
        taro += 1
        
print(taro, hanako)



Measured memory_bytes: 5600
import sys
input = sys.stdin.readline
# 自分の解答(模範解答と同じ)
def answer(N,A):
    dic={key:0 for key in range(1,N+1)}
    for a in A:
        dic[a]+=1
    for ans in dic.values():
        print(ans)



def main():
    N = int(input())
    A = list(map(int,input().split()))
    # answer()
    answer(N,A)

if __name__ == '__main__':
   main()

Measured memory_bytes: 40080
import sys
from sys import stdin,stdout
import math
import time
from functools import lru_cache
from collections import Counter
import heapq
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
try:
    for _ in range(1):
        N,X,T=map(int,input().split())
        time=0
        while(N>0):
            N-=X
            time+=T
        print(time)
except EOFError as e:
    print(e)


Measured memory_bytes: 67744
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main(){
	int n, m;
	pair<int, char>p[100];
	char c[3] = { '0','0','0' };
	cin >> n >> m;
	if (m == 0) {
		if (n != 1) {
			if (n == 3) {
				cout << "100" << endl;
			}
			else if (n == 2) {
				cout << "10" << endl;
			}
			return 0;
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p + m);
	for (int j = 0; j < m; j++) {
		if (p[j].first == p[j + 1].first) {
			if (p[j].second != p[j + 1].second) {
				cout << "-1" << endl;
				return 0;
			}
		}
		if (p[j].first == 1 && p[j].second == '0') {
			if (n != 1) {
				cout << "-1" << endl;
				return 0;
			}
		}
		c[p[j].first-1] = p[j].second;
	}
	if (c[0] == '0') {
		if (n != 1) {
			c[0] = '1';
		}
	}
	for (int k = 0; k < n; k++) {
		cout << c[k];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
int main() {
    int N;
    cin >> N;

    vector<tuple<double, i64, i64>> data(N);
    for(auto &d : data) {
        i64 x, y;
        cin >> x >> y;
        d = make_tuple(atan2(y, x), y, x);
    }
    sort(WHOLE(data));
    double ans = 0;
    double _;
    for(int i = 0; i < N; i++) {
        i64 ty, tx;
        i64 cy, cx;
        tie(_, cy, cx) = data[i];
        i64 ly = 0, lx = 0;
        for(int l = 0; l < N; l++) {
            i64 ry = 0, rx = 0;
            for(int r = 0; l + r < N; r++) {
                i64 y = cy + ly + ry, x = cx + lx + rx;
                ans = max(ans, sqrt(y * y + x * x));
                tie(_, ty, tx) = data[(i - r - 1 + 2 * N) % N];
                ry += ty, rx += tx;
            }
            tie(_, ty, tx) = data[(i + l + 1) % N];
            ly += ty, lx += tx;
        }
    }
    cout << std::fixed << std::setprecision(14) << ans << endl;
    return 0;
}

Measured memory_bytes: 256