akhauriyash/Code-Regression huggingface dataset:
#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 all( x ) ( x ).begin(), ( x ).end()
typedef long long lint;
using namespace std;

int main( void ){
	
	lint i,j,k;
	lint n;
	lint a[2][100];
	lint max, cnt;
	lint pi,pj;
	
	max = 0;
	cnt = 0;
	
	cin >> n;
	
	rep(i,2){
		rep(j,n){
			cin >> a[i][j];
		}
	}
	
	rep(i,n){
		pi = 0;
		pj = 0;
		cnt= 0;
		while( pj < n ){
			cnt += a[pi][pj];
			if( pj == i && pi == 0 ){
				pi++;
			}else{
				pj++;
			}
		}
		if( max < cnt ){
			max = cnt;
		}
	}
	
	cout << max << endl;
	
	return 0;
	
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    double a, b, x;
    cin >> a >> b >> x;
    double s = x / a;
    double ans = 0;
    if (s <= a * b / 2) {
        double w = 2 * s / b;
        ans = atan2(b, w);
    } else {
        double h = (2 * a * b - 2 * s) / a;
        ans = atan2(h, a);
    }
    cout << ans / M_PI * 180 << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
string s;
int main(void){
    cin>>n;
    cin>>s;
    if(n%2==0){
        for(int i=0;i<n/2;i++){
            if(s[i]!=s[i+n/2]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iomanip>

using namespace std;


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

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

  sort(A.begin(), A.end());
  
  vector<int> cnt(1000001, 0);
  for(int i=0; i<N; ++i)
    ++cnt[A[i]];

  int ans = 0;
  vector<bool> dp(1000001, true);
  for(int i=0; i<N; ++i)
  {
    if(dp[A[i]] && (cnt[A[i]] == 1))
      ++ans;
    if(dp[A[i]])
    {
      for(int j=A[i]; j<=1000000; j+=A[i])
        dp[j] = false;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 8012
# 奇数だと0にならない
# 偶数のとき、10とか200とか3450とかのときにそれぞれ1つ、2つ、1つずつ0が増える

# ↑ とかいうのを本番中に考えていたがこれは頭が悪かった 悪すぎたかもしれません
# 10が出ればいいのではなく2と5で割り切れる云々を考えればよかったらしい は？？？？
# 2はどうせたくさんでてくるので5だけ数える
# 5の登場回数なので5の乗数はその数ぶん数える
# 5, 25, 125, 625... で割った商

n = int(input())
ans = 0
if n % 2 == 1:
    print(0)
    exit()
n //= 2  # この帳尻合わせよくわかってない
for i in range(1, 27):  # 5**25 < 10**18 < 5**26
    ans += n // (5 ** i)
print(ans)



Measured memory_bytes: 2940
n=int(input())
l=list(map(int,input().split()))
final=[0]*n
for i in range(1,n):
  if i==1:
    final[i]=abs(l[i]-l[i-1])
  else:
    final[i]=min(final[i-1]+abs(l[i]-l[i-1]),final[i-2]+abs(l[i]-l[i-2]))
print(final[-1])    

Measured memory_bytes: 20304
#include<stdio.h>

#include<stdio.h>
int main(void)
{
	int H, W, i, n;
	while (1)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)break;
		for (i = 0; i < H; i++)
		{
			for (n = 0; n < W; n++)
			{
				if (i == 0 || i == H - 1 || n == 0 || n == W - 1)
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1000
N = int(input())
A = list(map(int ,input().split()))
MOD = 10**9+7

sum = 0
for i in range (N):
    sum += A[i] % MOD

ans = 0
for i in range(N):
    sum -= A[i]
    ans += (A[i] * sum) % MOD

ans = ans % MOD
print(ans)

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

constexpr int MAX = 1000001;

int main() {
    vector<bool> is_prime(MAX, true);
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<MAX; ++i) {
        if(is_prime[i]) {
            for(int j=i+i; j<MAX; j+=i) {
                is_prime[j] = false;
            }
        }
    }
    int n, x;
    while(cin >> n >> x, n) {
        vector<int> v(n);
        for(int i=0; i<n; ++i) {
            cin >> v[i];
        }
        vector<bool> dp(x+1, false);
        dp[0] = true;
        for(int i=0; i<n; ++i) {
            for(int j=0; j+v[i]<=x; ++j) {
                dp[j+v[i]] = dp[j+v[i]] || dp[j];
            }
        }
        int res = 0;
        for(int i=x; i>=1; --i) {
            if(dp[i] && is_prime[i]) {
                res = i;
                break;
            }
        }
        if(res == 0) {
            cout << "NA" << endl;
        } else {
            cout << res << endl;
        }
    }
}


Measured memory_bytes: 3160
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	a := readInt()
	b := readInt()
	c := readInt()
	l := []int{a, b, c}
	var i int
	var m int
	i, m = max(l)
	l = append(l[:i], l[i+1:]...)
	fmt.Println((m * 10) + l[0] + l[1])
}

func max(ns []int) (index, max int) {
	max = math.MinInt64
	for i, n := range ns {
		if n > max {
			index = i
			max = n
		}
	}
	return
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
 		int a_num = b - a - 1;
      	int a_val = 0;
      	int ans;
      
      	for(int i = 1;i <= a_num;i++) a_val += i;
      	ans = a_val - a;
          
      	System.out.println(ans);
        
	}
}


Measured memory_bytes: 35732
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
  a=list(map(int,input().split()))
  score=0
  for j in range(m):
    score+=a[j]*b[j]
  if score+c>0:
    ans+=1
print(ans)


Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define fi first
#define se second
const int inf = 1e9;

signed main(){
	int w, a, b;
	scanf("%lld%lld%lld", &w, &a, &b);
	int ans = min(abs(b+w-a), abs(b-(a+w)));
	if(a <= b && b <= a+w)printf("0\n");
	else printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int num(){
    char s[11];
    int i, n;
    for(i=0; i<sizeof(s); i++){
        s[i] = getchar();
        if(s[i] == ' ' || s[i] == '\n'){
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}
void sort(int x[], int n){
    int y, i, j;
    for(i=n; i>1; i--){
        for(j=0; j<=i-2; j++){
            if(x[j] < x[j+1]){
                y = x[j];
                x[j] = x[j+1];
                x[j+1] = y;
            }
        }
    }
}
int main(void){
    int n, i;
    int a[100];
    int ans=0, e=0, b=0;
    
//    a[0] = 3;
//    a[1] = 1;
//    a[2] = 2;
//    for(i=0; i<3; i++){
//        printf("%d", a[i]);
//    }
//    printf("\n");
//    
//    sort(a, 3);
//    for(i=0; i<3; i++){
//        printf("%d", a[i]);
//    }
//    printf("\n");
    
    n = num();
    for(i=0; i<n; i++){
        a[i] = num();
    }
    
    sort(a, n);
    
    for(i=0; i<n; i+=2){
        e += a[i];
    }
    for(i=1; i<n; i+=2){
        b += a[i];
    }
    ans = e-b;
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 128
H, W, K = map(int, input().split())
C = [input().rstrip() for _ in range(H)]

ans = 0

# 0行以上塗りつぶすすべての場合: 2^H通り
# 2進数で考えるとやりやすい
# 例えば、3行ある場合
#   000: 1行も塗らない
#   001: 1行目を塗る
#   010: 2行目を塗る
#   011: 1,2行目を塗る
#   ...
#   111: すべて塗る
# というふうに
for i_bits in range(1 << H):
  
  # 列についても同様の考え方
  for j_bits in range(1 << W):
    
    # すべてのマスについて、黒を数える
    cnt = 0 # 黒の個数
    for i in range(H):
      for j in range(W):
        
        # マスがある行も列も塗られていない場合に
        # 1の左シフトを使っている
        #   1をn個左シフト（1 << n）すると、2進数では1の右に0がn個
        #   1 << 3 = (0b) 1000
        #   これを使う
        # 例：i_bitsが10001のとき、3行目（i=2）は塗られているか？をビットAND演算で調べる
        #     10001
        #   &)00100
        #   -------
        #     00000
        #   結果が0なので塗られていない
        # j_bitsについても同様に確かめる
        if (i_bits & (1 << i)) == 0 and (j_bits & (1 << j)) == 0:
          
          # 黒ならば
          if C[i][j] == "#":
            cnt += 1
            
    if cnt == K:
      ans += 1
      
print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
//ノート　isupperで大文字の判定　islowerで小文字の判定
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int a,b,c,d;
    std::cin >> a>>b>>c>>d;
    if(abs(c-a)<=d||abs(b-a)<=d&&abs(c-b)<=d)std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
    
}

Measured memory_bytes: 256
n,a,b,c=gets.split.map(&:to_i)
l=[]
ss=[]
n.times do
  ss << gets.chomp
end
n.times do |i|
  s=ss[i]
  if s=="AB"
    if a<b||(a==b&&i<n-1&&ss[i+1]=="AC")
      a+=1
      l << "A"
      b-=1
      if b<0
        puts "No"
        exit
      end
    else
      b+=1
      l << "B"
      a-=1
      if a<0
        puts "No"
        exit
      end
    end
  elsif s=="BC"
    if b<c||(b==c&&i<n-1&&ss[i+1]=="AB")
      b+=1
      l << "B"
      c-=1
      if c<0
        puts "No"
        exit
      end
    else
      c+=1
      l << "C"
      b-=1
      if b<0
        puts "No"
        exit
      end
    end
  elsif s=="AC"
    if c<a||(c==a&&i<n-1&&ss[i+1]=="BC")
      c+=1
      l << "C"
      a-=1
      if a<0
        puts "No"
        exit
      end
    else
      a+=1
      l << "A"
      c-=1
      if c<0
        puts "No"
        exit
      end
    end
  end
end
puts "Yes"
puts l

Measured memory_bytes: 29352
#include<bits/stdc++.h>
using namespace std;
int main()
{
         string a;
         cin>>a;
         int c=0,i;
         for(i=0;i<a.size();i++)
        {
           if(a[i]=='7') c++;
        }

         if(c>0) cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
// Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){
		string srv;
		cin >> srv;

		if(srv=="0")
			break;

		int ptA = 0;
		int ptB = 0;
		for(int i=1; i<srv.size(); i++){
			if(srv[i]=='A'){
				ptA++;
			}
			else{
				ptB++;
			}
		}

		if(ptA>ptB){
			ptA++;
		}
		else{
			ptB++;
		}

		cout << ptA << ' ' << ptB << '\n';
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
using namespace std;
#define ll long long int

int main() {
    string str;
    cin>>str;
    ll ans=0;
    for(ll i=0;i<str.length();i++)
    {
        ans=ans+(str[i]-'0');
    }
    if(ans%9==0)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;
    ll N, M;
    string S, T;


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

ll solve(){
    if(S[0] != T[0])return -1;
    ll g = gcd(N, M);
    int a = N/g;
    int b = M/g;
    for(int i = 1; i < g; i++){
        if(S[i*a] != T[i*b])return -1;  
    }    
    return g*a*b;


}


int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);

    cin >> N >> M;
    cin >> S >> T;
    cout << solve() << "\n";
    return 0;
}

Measured memory_bytes: 640
def c_grid_repainting(H, W, Grid):
    is_visited = [[False] * W for h in range(H)]
    delta = [(-1, 0), (1, 0), (0, -1), (0, 1)]  # 上下左右

    def bfs(r, c):
        if Grid[r][c] == '.':
            return
        if is_visited[r][c]:
            return
        q = [(r, c)]
        while q:
            h, w = q.pop()
            for dh, dw in delta:
                nh, nw = h + dh, w + dw
                if 0 <= nh < H and 0 <= nw < W and Grid[nh][nw] == '#' and not is_visited[nh][nw]:
                    is_visited[r][c] = True
                    is_visited[nh][nw] = True
                    q.insert(0, (nh, nw))
    for h in range(H):
        for w in range(W):
            bfs(h, w)
    for h in range(H):
        for w in range(W):
            if Grid[h][w] == '#' and not is_visited[h][w]:
                return 'No'
    return 'Yes'

H,W = [int(i) for i in input().split()]
Grid = [input().strip() for _ in range(H)]
print(c_grid_repainting(H, W, Grid))

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl A(N + 1, 0);
  vl B(N, 0);
  REP(i, N + 1) cin >> A[i];
  REP(i, N) cin >> B[i];
  ll res = 0;
  ll ans = 0;
  REP(i, N) {
    if (A[i] <= B[i] + res) {
      res = min(B[i], B[i] + res - A[i]);
      ans += A[i];
    } else {
      ans += B[i] + res;
      res = 0;
    }
  }
  ans += min(A[N], res);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1920
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;

ll N,M,Q;
ll cnt[502][502];
ll usr[502];
ll rui[502][502];
ll Qu[502][502];


int main(){
    cin>>N>>M>>Q;
    rep0(i,M){
        int L,R;
        cin>>L>>R;
        rui[L][R]++;
        rui[L][N+1]--;
        usr[R]++;
        }
        for(int L=1;L<=N;L++){
            for(int R=L;R<=N;R++){
                cnt[L][R]=cnt[L][R-1]+rui[L][R];
            }
        }
        Qu[1][N]=M;
        for(int i=N;i>=2;i--){
            Qu[1][i-1]=Qu[1][i]-usr[i];
        }
        for(int R=N;R>=1;R--){
            for(int L=1;L<=R-1;L++){
                Qu[L+1][R]=Qu[L][R]-cnt[L][R];
            }
        }
        rep0(i,Q){
            int p,q;
            cin>>p>>q;
            cout<<Qu[p][q]<<endl;
        }

    
      return 0;
}

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

int main () {
  int N, K;
  string S;
  cin >> N >> S >> K;
  
  char a = S[K-1];
  for (int i = 0; i < N; i++) {
    if (S[i] != a) {
      S[i] = '*';
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
n = int(input())
hs = list(map(int, input().split()))
hs.append(0)

ans = 0
ok = False
while not ok:
    ok = True
    for l in range(n):
        if hs[l] > 0:
            for r in range(l, n + 1):
                if hs[r] == 0:
                    ans += 1
                    ok = False
                    break
                else:
                    hs[r] -= 1
            break

print(ans)

Measured memory_bytes: 3064
<?php

$string = trim(fgets(STDIN));

$parts = explode(" ", $string);

$count = $parts[0];
$low = $parts[1];
$high = $parts[2];

        $can_take = 0;
for ($i = 0; $i < $count; $i++)
{
    $class  = trim(fgets(STDIN));
    
    if (($class < $low) || ($class >= $high))
    {
        $can_take++;
    }
}

echo $can_take . "\n";

Measured memory_bytes: 3576
#include<stdio.h>
int main()
{
	int i,a,w1=0,w2=0,w3=0,k1=0,k2=0,k3=0;
	for(i=0;i<10;i++){
		scanf("%d",&a);
		if(w3<a){
			w3=a;
			if(w2<a){
				w3=w2;
				w2=a;
				if(w1<a){
					w2=w1;
					w1=a;
				}
			}
		}
	}
	for(i=0;i<10;i++){
		scanf("%d",&a);
		if(k3<a){
			k3=a;
			if(k2<a){
				k3=k2;
				k2=a;
				if(k1<a){
					k2=k1;
					k1=a;
				}
			}
		}
	}
	printf("%d %d\n",w1+w2+w3,k1+k2+k3);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<sstream>
#include<queue>
#include<deque>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

int check(vi prod){
	
	int max = -1;
	for (int i = 0; i < prod.size(); i++) {
		string str = to_string(prod[i]);	
		bool flag = true;
		for (int j = 1; j < str.size(); j++) {
			if (str[j] - str[j-1] != 1 ) {
				flag = false;
			}
		}
		if (flag) {
			max = prod[i];
		}
	}

	return max;
}

void printv(vi v){
	for(int i = 0; i < v.size(); i++){
		cout << v[i] << " ";
		}cout << endl;
		return ;
		}
int main() {
	
	int n; cin >> n;
	vi a(n);
	vector<int> prod;

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

	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			prod.pb(a[i] * a[j]);	
		}
	}

	
	sort(prod.begin(),prod.end());
	//printv(prod);
	cout << check(prod) << endl;
	return 0;
}

Measured memory_bytes: 6792
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,m = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	f = zeros(Int,n)
	d = Dict{Int,Int}()
	for i in 1:n
		if haskey(d,a[i])
			d[a[i]] += 1
		else
			d[a[i]] = 1
		end
	end
	for i in keys(d)
		for j in 0:d[i]-1
			if i-j>0
				f[i-j] += 1
			end
		end
	end
	s = 0
	for i in 1:n
		if f[i] == 0
			s += 1
		end
	end
	for i in 1:m
		x,y = readline() |> split |> parseMap
		if a[x]-d[a[x]]+1>0
			f[a[x]-d[a[x]]+1] -= 1
			if f[a[x]-d[a[x]]+1] == 0
				s += 1
			end
		end
		d[a[x]] -= 1
		if haskey(d,y)
			d[y] += 1
		else
			d[y] = 1
		end
		a[x] = y
		if y-d[y]+1>0
			if f[y-d[y]+1] == 0
				s -= 1
			end
			f[y-d[y]+1] += 1
		end
		println(s)
	end
end

main()


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


int main(){
	int n,k,a,cnt=0;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> a;
		if(k<=a) cnt++;
	}
	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e9 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=2019;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(), x.end()

int__ main() {
	fast;

	int n; cin >> n;
	map<int,int> mp;

	int ans = 0;
	for(int i=0;i<n;i++) {
		int x; cin >> x;
		ans += mp[i-x];

		mp[i+x]++;
	}

	cout << ans << endl;

}

Measured memory_bytes: 26336
import sys
 
class TreeNode:
    def __init__(self, val):
        self.val = val
        self.left = self.right = None
    
    def __eq__(self, other):
        return self.val == other.val
 
class BST:
    def __init__(self):
        self.root = None
     
    def insert(self, node):
        def helper(root):
            y, x = None, root
            while isinstance(x, TreeNode):
                y = x
                if node.val < x.val:
                    x = x.left
                else:
                    x = x.right
            if y is None:
                root = node
            elif node.val < y.val:
                y.left = node
            else:
                y.right = node
            return root
             
        self.root = helper(self.root)
 
    def find(self, val):
        def helper(root):
            if root is None:
                return None
            elif root.val == val:
                return root
            elif val < root.val:
                return helper(root.left)
            else:
                return helper(root.right)
        return helper(self.root)
        
    def delete(self, val):
        node = TreeNode(val)
        def findMin(root):
            while root.left is not None:
                root = root.left
            return root
        
        def helper(root, node):
            if root is None:
                return None
            elif root == node:
                if root.left is None:
                    root = root.right
                elif root.right is None:
                    root = root.left
                else:
                    tmp = findMin(root.right)
                    root.val = tmp.val
                    rr = helper(root.right, TreeNode(tmp.val))
                    root.right = rr
                return root
            else:
                if node.val < root.val:
                    root.left = helper(root.left, node)
                else:
                    root.right = helper(root.right, node)
                return root

        helper(self.root, node)

    def inorder(self):
        def helper(root):
            return [] if root is None else helper(root.left) + [root.val] + helper(root.right)
        return helper(self.root)
 
    def preorder(self):
        def helper(root):
            return [] if root is None else [root.val] + helper(root.left) + helper(root.right)
        return helper(self.root)
 
if __name__ == '__main__':
    q = sys.stdin.readline()
    q = int(q)
    bst = BST()
    for _ in range(q):
        tmp = sys.stdin.readline()
        if tmp.startswith('print'):
            print ' ' + ' '.join(map(lambda x: str(x), bst.inorder()))
            print ' ' + ' '.join(map(lambda x: str(x), bst.preorder()))
        elif tmp.startswith('insert'):
            _, val = tmp.split()
            node = TreeNode(int(val))
            bst.insert(node)
        elif tmp.startswith('find'):
            _, val = tmp.split()
            print ('yes' if bst.find(int(val)) is not None else 'no')
        else:
            _, val = tmp.split()
            bst.delete(int(val))

Measured memory_bytes: 200200
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int q; cin >> q;
    multimap<string,int> m;
    rep(i ,q){
        int man; cin >> man;
        string key;
        int x;
        decltype(m)::iterator itr;
        decltype(m)::iterator itr1;
        decltype(m)::iterator itr2;
        switch (man)
        {
            case 0:
                cin >> key >> x;
                m.insert(make_pair(key,x));
                break;
            case 1:
                cin >> key;
                itr1 = m.lower_bound(key);
                itr2 = m.upper_bound(key);
                itr = itr1;
                for(; itr!=itr2;++itr){
                    cout << itr->second << endl;
                }
                break;
            case 2:
                cin >> key;
                m.erase(key);
                break;
            case 3:
                string l , r;
                cin >> l >> r;
                itr1 = m.lower_bound(l);
                itr2 = m.upper_bound(r);
                itr = itr1;
                for(;itr!=itr2;++itr){
                    cout << itr->first << " " << itr->second << endl;
                }
                break;
        }
    }
}


Measured memory_bytes: 24704
/*
@Author
   Sujeet Kushwaha
*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false)
#define fast_input cin.tie(NULL)
#define fast_output cout.tie(NULL)
#define vi vector<long long int> 
#define pb push_back
#define mp make_pair
#define pp pop_back
#define iter vector<int>::iterator
#define pa pair<long long int ,long long int> 
#define f(a,b) for(int a=0;a<b;a++)
#define mod 1000000007
#define F first
#define S second
#define sett set<long long int>
#define um unordered_map<ll,ll>
// ll powmod(ll a, ll b)
// {
//     ll res = 1;
//     while (b) {
//         if (b&1) {
//             res *= a;
//             res %= mod;
//         }
//         b >>= 1;
//         a = (a * a) % mod;
//     }

//     return res;
// }

// ll modInv(ll a)
// {
//     return powmod(a, mod - 2);
// }
// int fastread(){
//     int x=0;
//     int c = getchar_unlocked();
//     while(c<48)
//         c = getchar_unlocked();
//     while(c>=48){
//         x = x*10 + (c - 48);
//         c = getchar_unlocked();
//     }
//     return x;
// }
void solve()
{
   string s,t;
  cin>>s>>t;
  t=t+s;
  cout<<t;
}
int main() {
	fast;
	fast_input;
	fast_output;
	//ll t;
	//cin>>t;
	//while(t--)
	//{
	  solve();
	//}
	return 0;
}


Measured memory_bytes: 256
D = int(input())
C = list(map(int,input().split()))
L = [0 for _ in range(26)]
S = []
for _ in range(D):
    S.append(list(map(int,input().split())))

def calc(ans, select, n):
    for i,l in enumerate(L):
        if i != select:
            ans -= C[i] * (n-L[i])
        else:
            L[i] = n
    return ans

V = []
ans = 0
for i in range(D):
    select = int(input())-1
    ans += S[i][select]
    ans = calc(ans, select, i+1)
    print(ans)


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

/*

POJ2503
AtCoder Regular Contest 068 A
AtCoder Regular Contest 068 B
51nod1307
AtCoder Regular Contest 068 C
Codeforces 760
*/

int main()
{
    LL n;
    scanf("%lld",&n);
    LL res,x;
    res=n/11LL*2;
    x=n%11L;
    if(x)
    {
        if(x>6) res+=2LL;
        else res+=1LL;
    }
    printf("%lld\n",res);
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int Q;

int T[202020],A[202020],B[202020];
ll S[202020];
vector<ll> As;

template<class V, int ME> class BIT {
public:
	V bit[1<<ME],val[1<<ME];
	V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	void add(int e,V v) { val[e++]+=v; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
	void set(int e,V v) { add(e,v-val[e]);}
	int lower_bound(V val) {
		V tv=0; int i,ent=0;
		for(i=ME-1;i>=0;i--) if(tv+bit[ent+(1<<i)-1]<val) tv+=bit[ent+(1<<i)-1],ent+=(1<<i);
		return ent;
	}
};
BIT<ll,20> num,tot;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>Q;
	As.push_back(-1<<30);
	As.push_back(1<<30);
	
	for(i=1;i<=Q;i++) {
		cin>>T[i];
		if(T[i]==1) {
			cin>>A[i]>>B[i];
			As.push_back(A[i]);
		}
		S[i]=S[i-1]+B[i];
	}
	
	sort(ALL(As));
	As.erase(unique(ALL(As)),As.end());
	for(i=1;i<=Q;i++) {
		if(T[i]==1) {
			A[i]=lower_bound(ALL(As),A[i])-As.begin();
			num.add(A[i],1);
			tot.add(A[i],As[A[i]]);
		}
		else {
			x=num(1<<19);
			
			if(x==0) {
				cout<<S[i]<<endl;
				continue;
			}
			else {
				y=(x+1)/2;
				r=num.lower_bound(y);
				ll ret=S[i];
				y=num(r-1);
				ll su=tot(r-1);
				ret+=1LL*y*As[r]-su;
				y=num(1<<19)-num(r);
				ret+=tot(1<<19)-tot(r)-1LL*y*As[r];
				cout<<As[r]<<" "<<ret<<endl;
			}
		}
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 22644
N, L = map(int, input().split())

APS = [L + i - 1 for i in range(1, N + 1)]

tstall = sum(APS)
TSTL = []
for nn in range(N):
    tst = APS[nn]
    TSTL.append((abs(tst), tstall - tst))

R = sorted(TSTL, key=lambda x: x[0])[0][1]

print(R)


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 10000005;
int A[MAX_N];

int main2() {
  int N = nextLong();
  ll ans = 0;
  for (ll k = 1; k <= N; k++) {
    ans += k * A[k];
  }
  cout << ans << endl;
  return 0;
}

int main() {

  for (int i = 1; i < MAX_N; i++) {
    for (int j = i; j < MAX_N; j += i)
      ++A[j];
  }


#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 42820
S = input()
if S == 'SUN':
    ans = 7
elif S == 'MON':
    ans = 6
elif S == 'TUE':
    ans = 5
elif S == 'WED':
    ans = 4
elif S == 'THU':
    ans = 3
elif S == 'FRI':
    ans = 2
elif S == 'SAT':
    ans = 1

print(ans)

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

int main(){ 
  char x;
  cin >> x;
  x = (x - 'a') + 1 + 'a';
  cout << x << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
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; }

int main(){

	lli num=0;

	REP(i,0,3){
		lli tmp;
		cin>>tmp;
		num*=10;
		num+=tmp;
	}

	if(num%4==0){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>

int main(){
	int A=0, B=0, T=0, time=0, sum=0;
  	char str[10];
  
  	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d %d", &A, &B, &T);
  	
  	sum = T/A * B;
  
  	printf("%d", sum);
  
 	return 0; 
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

#define ll long long
const int maxN = 100005;
const ll INF = 1000000000000000000LL;

class TaskB {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int n;
		cin >> n;
		vector<ll> nums(n);
		for(int i = 0; i < n; i++){
			cin >> nums[i];
			if(nums[i] == 0){
				cout << 0 << endl;
				return;
			}
		}
		ll ans = 1;
		for(int i = 0; i < n; i++){
			if(ans > INF/nums[i]){
				cout << -1 << endl;
				return;
			}
			ans *= nums[i];
		}
		cout << ans << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskB solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  


    int x,y,z;
    cin>>x>>y>>z;
    if(x==y&&x!=z)
        cout<<"Yes\n";
    else if(x==z&&x!=y)
        cout<<"Yes\n";
    else if(y==z&&x!=y)
        cout<<"Yes\n";
    else
    {
        cout<<"No";
        
    }
    
} 



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	string s;
	cin >> s;
	if (s.substr(0, 4) == "YAKI") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map <int, int> mp;
set <int> s;

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s.insert(a);
        mp[a]++;
    }
    int res = 0;
    for(auto it = s.begin(); it != s.end(); it++) {
        if(mp[*it] < *it) {
            res += mp[*it];
        }
        else {
            res += mp[*it] - *it;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
vector<ll> takahashi;
vector<ll> aoki;
bool custom_1(int a, int b) {
  if(takahashi[a] - aoki[b] == takahashi[b] - aoki[a]) return (takahashi[a] > takahashi[b]);
  else return (takahashi[a] - aoki[b] > takahashi[b] - aoki[a]);
}
bool custom_2(int a, int b) {
  if(aoki[a] - takahashi[b] == aoki[b] - takahashi[a]) return (aoki[a] > aoki[b]);
  else return (aoki[a] - takahashi[b] > aoki[b] - takahashi[a]);
}
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
  int n;
  cin >> n;
  takahashi.resize(n);
  aoki.resize(n);
  rep(i, n) {
    cin >> takahashi[i] >> aoki[i];
  }
  vector<int> taka(n);
  vector<int> ao(n);
  iota(taka.begin(), taka.end(), 0);
  iota(ao.begin(), ao.end(), 0);
  sort(taka.begin(), taka.end(), custom_1);
  sort(ao.begin(), ao.end(), custom_2);
  vector<bool> used(n);
  int t = 0;
  int a = 0;
  ll taka_total = 0LL;
  ll ao_total = 0LL;
  rep(i, n) {
    if(i % 2 == 0) {
      for(int j=t;j<n;j++) {
        if(used[taka[j]]) continue;
        else {
          t = j + 1;
          used[taka[j]] = true;
          taka_total += takahashi[taka[j]];
          break;
        }
      }
    }
    else {
      for(int j=a;j<n;j++) {
        if(used[ao[j]]) continue;
        a = j + 1;
        used[ao[j]] = true;
        ao_total += aoki[ao[j]];
        break;
      }
    }
  }

  cout << taka_total - ao_total << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
char str[333];
int n,k,dp[333][333][333][2],ans;
void add(int &x,int y)
{
	x+=y;
	if (x>=mod) x-=mod;
}
int main()
{
	scanf("%s",str);
	n=strlen(str);scanf("%d",&k);
	k=min(k,n);str[n]='0';
	dp[0][0][0][0]=1;
	for (int i=0;i<=n;i++)
	{
		for (int j=i;j<=n;j++)
		{
			for (int s=0;s<=k;s++)
			{
				for (int p=0;p<2;p++)
				{
					if (!dp[i][j][s][p]) continue;
					for (int r=0;r<2;r++)
					{
						if (r && p) continue;
						if (str[i]=='0')
						{
							if (!r) add(dp[i+1][j+1][s][0],dp[i][j][s][p]);
							else if (s+1<=k) add(dp[i][j+1][s+1][0],dp[i][j][s][p]);
						}
						else
						{
							if (!r) add(dp[i+1][j][s][1],dp[i][j][s][p]);
							else add(dp[i+1][j+1][s][0],dp[i][j][s][p]);
						}
					}
				}
			}
		}
	}
	for (int i=0;i<=k;i++) 
	{
		add(ans,dp[n][n][i][0]);
		add(ans,dp[n][n][i][1]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 121640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()

int main () {
  vector<string> vec;
  int h, w, count;
  cin >> h >> w;

  REP(i, h) {
    string input;
    cin >> input;
    vec.push_back(input);
  }

  REP(i, h) {
    REP(j, w) {
      if(vec[i][j] == '.') continue;
      count = 0;

      if(j - 1 >= 0 && vec[i][j - 1] == '#') count++;
      if(j + 1 < w && vec[i][j + 1] == '#') count++;
      if(i - 1 >= 0 && vec[i - 1][j] == '#') count++;
      if(i + 1 < h && vec[i + 1][j] == '#') count++;

      if(count == 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i,j,k;
  int n;
  scanf("%d",&n);
  int L[150];
  int ans = 0;
  for(i=0;i<n;++i){
    scanf("%d",&L[i]);
  }
  
  for(i=0;i<n;++i){
    for(j=0;j<n-1;j++){
      int a = L[j], b = L[j+1];
      if(a<b){
        L[j]=b;
        L[j+1]=a;
      }
    }
  }
  
  for(i=0;i<n;++i){
    for(j=i+1;j<n;++j){
      for(k=j+1;k<n;++k){
        if(L[i]>=L[j]+L[k])continue;
        if(L[i]==L[j])continue;
        if(L[j]==L[k])continue;
  		ans++;      
      }
    }
  }
  
  printf("%d\n",ans);
}


Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int a,p;
	cin>>a>>p;
	
	p+=(a*3);
	
	cout<<p/2<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
//smart phone coding ><
int main(void){
	int n;
	scanf("%d",&n);
	char str[n][11];
	for(int i = 0;i < n;i++)scanf("%s",str[i]);
	qsort(str,n,11,strcmp);
	unsigned count_array[200000] = {};
	for(int i = 0; i < n - 1;i++)
	    if(!strcmp(str[i],str[i + 1])){
	    	count_array[i]++;
	    	count_array[i + 1] += count_array[i];
	    	count_array[i + 1]++;
	    	}
	 unsigned max = 0;
	 for(int i = 0;i < n;i++)if(count_array[i] > max)
	    	max = count_array[i];
	    	
	 for(int i = 0;i < n;i++)if(count_array[i] == max)
	    	puts(str[i]);
	    	
	  return 0;
}

Measured memory_bytes: 4884
def main():
    # S = input()
    N = int(input())
    # S = list(map(int, input().split(' ')))
    # print(S, W)
    # a = int(N[-1])

    if 400<= N <=599:
        print('8')
    elif 600<= N <=799:
        print('7')
    elif 800<= N <=999:
        print('6')
    elif 1000<= N <=1199:
        print('5')
    elif 1200<= N <=1399:
        print('4')
    elif 1400<= N <=1599:
        print('3')
    elif 1600<= N <=1799:
        print('2')
    elif 1800<= N <=1999:
        print('1')
    

main()

Measured memory_bytes: 61748
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b)
	{
		cout<<c<<endl;
	}
	if(a==c)
	{
		cout<<b<<endl;
	}
	if(b==c)
	{
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int A[N]; rep(i,N) cin >> A[i];
    int now=1;
    int cnt=0;
    rep(i,N){
        if(A[i] == now){
            cnt++; 
            now++;
        }
    }
    if(cnt==0) cout << -1 << endl;
    else cout << N-cnt << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main() {
    int n, a[1005];
    while (1) {
        scanf("%d", &n);
        if (n == 0) break;
        double avg = 0;
        for (int i = 0; i < n; i++) {
            scanf("%d", &a[i]);
            avg += a[i];
        }
        avg /= n;
        double tt = 0;
        for (int i = 0; i < n; i++)
            tt += (a[i] - avg) * (a[i] - avg);
        tt /= n;
        printf("%.4lf\n", sqrt(tt));
    }
}


Measured memory_bytes: 2112