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

int main(void){

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

    sort(a.begin(), a.end());
    
    int ans = 0;
    int c = 0;
    int counter = 0;
    for(int i = 0; i < n; i++){
        if(c == a[i]) counter++;
        else if(c != a[i]){
            //cout << i << endl;
            if(c > counter) ans += counter;
            else ans += counter - c;

            c = a[i];
            counter = 1;
        }
    }

    if(c > counter) ans += counter;
    else ans += counter - c;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    start = 0
    cnt = 0
    while 1:
        start += 26 ** cnt
        if start > n:
            start -= 26 ** cnt
            break
        cnt += 1
    ans = ''
    tmp = n - start
    for i in range(cnt):
        ans += chr(ord('a') + tmp % 26)
        tmp //= 26
    print(ans[::-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 61752
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <climits>

#define size_t int

using namespace std;

int main(int argc, char const *argv[]) {
  int A, B, K;
  scanf("%d%d%d", &A, &B, &K);
  for (size_t i = 0; i < K/2; i++) {
    if(A%2) {
      A--;
    }
    B += A/2;
    A /= 2;
    if(B%2) {
      B--;
    }
    A += B/2;
    B /= 2;
  }

  if (K%2) {
    if(A%2) {
      A--;
    }
    B += A/2;
    A /= 2;
  }
  printf("%d %d\n", A, B);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
 
#define rep(i,n) for(int i = 0; i< (n);i++)
#define ic(n) int (n); cin>>(n);
#define SORT(a) sort((a).begin(),(a).end());
#define che(a,string) cout<<string<<":"<<(a)<<endl;
#define ch(a,string) cout<<string<<":"<<(a)<<" ";
using namespace std;
typedef pair<int,int> P;




int main(){

  vector<int> A(3);
  rep(i,3){
	  cin>>A[i];
	}
	SORT(A);
	cout<<A[2]*10+A[1]+A[0]<<endl;
}

	



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include <numeric>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n)cin >> d[i];
    sort(ALL(d));
    d.erase(unique(ALL(d)), d.end());
    cout << d.size();
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(c-(a-b)<=0){
        cout << 0 << endl;
    }else{
        cout << c-(a-b) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if (a==0)
    {
    	cout<<1<<endl;
	}
    if (b==0)
    {
    	cout<<2<<endl;
	}
    if (c==0)
    {
    	cout<<3<<endl;
	}
    if (d==0)
    {
    	cout<<4<<endl;
	}
    if (e==0)
    {
    	cout<<5<<endl;
	}	
}

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

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

	int x = a + b, y = a - b, z = a * b;

	if (x < y)swap(x, y);
	if (x < z)swap(x, z);

	cout << x << endl;

	return 0;
}

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

int main() {
  int a,b,c;cin >> a>>b>>c;
  int rest = a-b;
  cout << max(c-rest, 0) << endl;
  return 0;
}

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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define ff first
#define tcase int _; cin>> _; for( ; _; --_)
#define ss second
#define endl '\n'
const int MAX = 2*(1e5 + 1);
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	for(;exp; exp>>=1){
		if(exp % 2 == 1) total = mod(((mod(total, m)) * (mod(base, m))), m);
		base= mod((mod(base, m) * mod(base, m)), m);
	}
	return total;
}

set<int> adj[MAX];
vector<bool> is(MAX, false);

int dfs(int u){
    int ans = 1;
    is[u] = true;

    for(int v: adj[u])
        if(!is[v]) ans += dfs(v);

    return ans;
}

void solve(){
    int n, m;
    cin >> n >> m;
    
    for(int i = 0; i < m ; ++i){
        int a, b;
        cin >> a >> b;

        adj[a].insert(b);
        adj[b].insert(a);
    }

    int ans = 0;

    for(int i = 1; i <= n ; ++i)
        if(!is[i]) ans = max(ans, dfs(i));

    cout << ans << endl;
}

int32_t main(){
	fastio;
	solve();
	return 0;
}



Measured memory_bytes: 41112
N = int(input())
para = [[i for i in map(int,input().split())] for i in range(N-1)]
dp = [0]*(N)

for i in range(N):
    for j in range(N-i-1):
        if dp[i] >= para[i+j][1] and dp[i]%para[i+j][2] == 0 :
            dp[i] += para[i+j][0]
        elif  dp[i] < para[i+j][1]: 
            dp[i] = para[i+j][1] + para[i+j][0]
        else:
            a = dp[i] // para[i+j][2] 
            dp[i] = (a+1)*para[i+j][2] + para[i+j][0]
    print(dp[i])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int H, W, count_h=0,count_v=0;
      cin >> H >> W;
  
      vector<vector<char>> data(H, vector<char>(W));
      for (int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++){
          cin >> data.at(i).at(j);
        }
      }
      
      vector<bool> judge_h(H,true), judge_v(W,true);
      
      for (int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++){
      		 if(data.at(i).at(j) == '.')
              count_h += 1;
        }
        if(count_h == W)
        	judge_h.at(i) = false;
        count_h = 0;
      }
      
       for (int j = 0; j < W; j++) {
        for(int i = 0; i < H; i++){
      		 if(data.at(i).at(j) == '.')
              count_v += 1;
        }
        if(count_v == H)
        	judge_v.at(j) = false;
         count_v = 0;
      }
      
      for (int i = 0; i < H; i++) {
        if(judge_h.at(i))
         for(int j = 0; j < W; j++){
          if(judge_v.at(j))
            cout << data.at(i).at(j);    
         }
        else
          continue;
        cout << endl;
      }

  }


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

int main(){
    int n;
    std:: cin >> n;
    std:: vector<long long>arr(n+1,0);
    for(int i = 0; i < n; i++){
        std:: cin >> arr[i];
    }

    long long dp[n+2][n+2] = {0};

    for(int i = n-1; i >= 0; i--) 
    {
        for(int j = i; j < n; j++){
            if(i == j){
                dp[i][j] = arr[i];
            }
            else
            {
                dp[i][j] = std::max(arr[i]-dp[i+1][j], arr[j]-dp[i][j-1]);
            }
        }
    }

    std::cout << dp[0][n-1];
    return 0;
}

Measured memory_bytes: 70656
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    ll N=n;
    ll div=0;
    while(N){
        div+=N%10;
        N/=10;
    }
    if(n%div==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3596
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A, B;
	
	cin >> A >> B;

	if (A + B < 10)
	{
		cout << A+B << endl;
	}
	else
	{
		cout << "error" << endl;
	}

	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int n;
	std::cin >> n;
	
	long long int count = 0;
	for (int i = 0; i < n; ++i)
	{
		int l, r;
		std::cin >> l >> r;
		
		count += (r * 1LL - l + 1);
	}
	
	std::cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
	string S;
	int ans = 0;
	cin >> S;

	while(!S.empty()){
		S.pop_back();
		S.pop_back();

		int half_size = S.size()/2;
		// cout <<"half_size:"<<  half_size << endl;
		for(int i=0;i<half_size;++i){
			// cout << S[i] << ' ' << S[half_size + i] << endl;
			if(S[i] != S[half_size + i]) break;
			else if(i == half_size-1) ans = S.size();
		}
		if(ans > 0) break;
	}
	cout << ans << endl;

	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

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

int main() {
    int H, W; cin >> H >> W;
    vector<string> S(H); REP(i, H) cin >> S[i];
    for(int i = 0; i < H; ++i) {
        for(int k = 0; k < W; ++k) {
            if(S[i][k] == '#') cout << '#';
            else {
                int tmp = 0;
                for(int m = 0; m < 8; ++m) {
                    if(i + dx[m] < 0 || i + dx[m] >= H) continue;
                    if(k + dy[m] < 0 || k + dy[m] >= W) continue;
                    if(S[i + dx[m]][k + dy[m]] == '#') tmp++;
                }
                cout << tmp;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
fun main() {
    var(a,b,c,d) = readLine()!!.split(" ").map{it.toInt()}
    while (true) {
        c -= b
        if (c <= 0) {
            println("Yes")
            break
        }
        a -= d
        if (a <= 0) {
            println("No")
            break
        }
    }
}

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

int main(){
    double a,b,c;
    cin>>a>>b>>c;
    c=c*3.14159265358979/180;
    cout<<fixed<<setprecision(10)<<((a*b)/2)*sin(c)<<endl;
    cout<<fixed<<setprecision(10)<<a+b+sqrt(a*a+b*b-2*a*b*cos(c))<<endl;
    cout<<fixed<<setprecision(10)<<(a*b*sin(c))/a<<endl;
}


Measured memory_bytes: 3644
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=3e5+5;
ll ans,L;int x[N],t[N],li[N],ri[N],vis[N],st[N],n,top,pos,tot;
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&L),ans=n;
	fp(i,1,n)scanf("%d",&x[i]);
	fp(i,1,n)scanf("%d",&t[i]);
	fp(i,1,n){
		ans+=t[i]/(L<<1),t[i]%=L<<1;
		if(!t[i])--ans,vis[i]=1;
		else{
			li[i]=(x[i]<<1)>=t[i],ri[i]=((L-x[i])<<1)>=t[i];
			if(!li[i]&&!ri[i])vis[i]=1,t[i]=0;
		}
	}
	pos=1;
	while(pos<n&&!(li[pos]==1&&ri[pos]==0))++pos;
	fp(i,1,pos-1)if(!vis[i]){
		if(!li[i]){
			if(top)--top,--ans;
		}else ++top;
	}
	tot+=top,top=0;
	fd(i,n-1,pos)if(!vis[i]){
		if(!ri[i]){
			if(top)--top,--ans;
		}else ++top;
	}
	tot+=top,ans-=tot>>1;
	if(!ri[n])++ans;
	printf("%lld\n",ans*(L<<1));
	return 0;
}

Measured memory_bytes: 6144
#  愚直に数え上げる方法

import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():

    N = list(map(int, input()))
    K = int(input())

    if K == 1:
        ans = (len(N) - 1) * 9 + N[0]

    elif K == 2:

        if len(N) < 2:
            print(0)
            exit()

        ans = (9 ** 2) * (len(N) - 1) * (len(N) - 2) // 2
        ans += (N[0] - 1) * (len(N) - 1) * 9

        for i in range(1, len(N)):
            if N[i] != 0:
                ans += N[i] + (len(N) - i - 1) * 9
                break

    elif K == 3:

        if len(N) < 3:
            print(0)
            exit()

        ans = (9 ** 3) * (len(N) - 1) * (len(N) - 2) * (len(N) - 3) // 6
        ans += (N[0] - 1) * (9 ** 2) * (len(N) - 1) * (len(N) - 2) // 2

        for i in range(1, len(N) - 1):
            if N[i] != 0:
                ans += (9 ** 2) * (len(N) - i - 1) * (len(N) - i - 2) // 2
                ans += (N[i] - 1) * (len(N) - i - 1) * 9
                for j in range(i + 1, len(N)):
                    if N[j] != 0:
                        ans += N[j] + (len(N) - j - 1) * 9
                        break
                break

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0037
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            if (s == "Sunny")
            {
                Console.WriteLine("Cloudy");
            }
            else if (s == "Cloudy")
            {
                Console.WriteLine("Rainy");
            }
            else
            {
                Console.WriteLine("Sunny");
            }
        }
    }
}


Measured memory_bytes: 25604
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut x: usize = read();
    let mut y = x;
    let n: usize = read();
    let arr: Vec<usize> = (0..=101).collect();
    let p: Vec<usize> = (0..n).map(|_| read()).collect();
    if !p.contains(&arr[x]) {
        println!("{}", x)
    } else {
        for _ in 0..=101 {
            if x == 0 {
            } else {
                x = x - 1;
            }
            y = y + 1;
            if !p.contains(&arr[x]) {
                println!("{}", x);
                break;
            } else if !p.contains(&arr[y]) {
                println!("{}", y);
                break;
            }
        }
    }
}


Measured memory_bytes: 2124
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int n;
int c[100][100];

signed main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			cin >> c[i][j];
	
	int ans = 0;
	for (i = 0; i < n; i++)
		for (j = i + 1; j < n; j++)
			ans += min(c[i][j], c[j][i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main (String[] args) throws IOException {
        double r,x,y;
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String data = reader.readLine();
        r = Double.parseDouble(data);

        x = r * r * Math.PI;
        y = 2 * r * Math.PI;
        
        builder
           .append(String.format("%.6f",x))
           .append(" ")
           .append(String.format("%.6f",y));
        System.out.println(builder);        
    }
}

Measured memory_bytes: 24720
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

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

    int n, k;
    cin >> n >> k;
    LL ans = 0;
    REP(i, n-1){
        ans += ans / (k-1) + 1;
    }

    cout << ans << endl;
}



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

int main() 
{
  int n,total;
  int x=-1,y=-1,z=-1;

  cin >> n >> total;

  for(int i=0; i<=n; i++)
  {
    for(int j=0; i+j<=n; j++)
    {   
      int k = n - ( i + j );
      int sum = 10000*i + 5000*j + 1000*k;
    
      if(sum == total)
      {   
        x=i;
        y=j;
        z=k;
      }   
    }   
  }

  cout << x << " "; 
  cout << y << " "; 
  cout << z << " "; 
  cout << endl;

  return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

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

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 w, h;
  while (cin >> w >> h && w+h) {
    vector<string> a(h);
    REP(i, h) {
      cin >> a[i];
    }
    vector<vector<int>> col(h, vector<int>(w, -1));
    auto cango = [&](int64 y, int64 x) {
      return 0<=y&&y<h&&0<=x&&x<w&&col[y][x]==-1;
    };

    REP(y, h) {
      REP(x, w) {
        if (col[y][x] != -1 || a[y][x] != '.') continue;
        queue<PII> q;
        queue<PII> vis;
        vis.emplace(y, x);
        q.emplace(y, x);
        col[y][x] = 0;
        int touch = 0;
        while (q.size()) {
          int64 ny, nx;
          tie(ny, nx) = q.front(); q.pop();
          REP(k, 4) {
            int64 yy, xx;
            yy = ny + dy[k]; xx = nx + dx[k];
            if (!cango(yy, xx)) continue;
            if (a[yy][xx] == 'W') touch |= 1;
            else if (a[yy][xx] == 'B') touch |= 2;
            else {
              col[yy][xx] = 0;
              q.emplace(yy, xx);
              vis.emplace(yy, xx);
            }
          }
        }
        while (vis.size()) {
          int64 yy, xx;
          tie(yy, xx) = vis.front(); vis.pop();
          col[yy][xx] = touch;
        }
      }
    }
    int64 cnt[2] = {};
    REP(y, h) {
      REP(x, w) {
        if (col[y][x] == 1) {
          cnt[0]++;
        } else if (col[y][x] == 2) {
          cnt[1]++;
        }
      }
    }
    cout << cnt[1] << " " << cnt[0] << endl;
  }
}



Measured memory_bytes: 3192
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define anal         '\n'
#define mod 1000000007
#define fst first
#define sec second
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

const int N = 2e5;
ll n, m, k;
ll a[N + 1], b[N + 1];

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
      
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
      freopen("input.in", "r", stdin);
      freopen("output.in", "w", stdout);
#endif 

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
     
     cin >> n >> m >> k;
     for(int i = 0; i < n; i++){
          cin >> a[i + 1];
          a[i + 1] += a[i];
     } 
     for(int j = 0; j < m; j++){
          cin >> b[j + 1];
          b[j + 1] += b[j];
     }
     int ans = 0;
     for(int i = 0, j = m; i <= n; i++){
             if(a[i] > k){
                  break;
             }
             while(a[i] + b[j] > k) --j;
             ans = max(ans, i + j);
     }
     cout << ans;


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



   

Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,q;cin >> n >> q;
  string s;cin >> s;
  vector<ll> su(n+1);
  su[0] = 0;
  rep(i,n-1){
      if(s[i]== 'A' && s[i+1] == 'C'){
          su[i+1] = 1;
      }
  }
  FOR(i,1,n+1){
      su[i] += su[i-1];
  }
  rep(i,q){
      ll l,r; cin >> l >> r;
      if(r==n){
          cout << su[r] - su[l-1] << endl;
      }else{
          if(s[r-1] == 'A' && s[r] == 'C'){
              cout << su[r] - su[l-1] -1<< endl;
          }else{
              cout << su[r] - su[l-1] << endl;
          }
      }
  }

}

Measured memory_bytes: 1872
def readinput():
    s=input()
    return s

def main(s):
    
    maxlen=0
    templen=0
    for i in range(len(s)):
        if(s[i]=='A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T'):
            templen+=1
        else:
            maxlen=max(maxlen,templen)
            templen=0
        
    return max(maxlen,templen)

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

//int main()
//{
//	string n;
//	int k;
//	cin >> n >> k;
//	//vector<int> h(n);
//	int ans = 0;
//	for (int i = 1; i <= (n); ++i) {
//		//h[i-1] = i;
//		string numstr = to_string(i);
//		int total_count = numstr.length();
//		int zero_count = count(numstr.begin(), numstr.end(), '0');
//		if (total_count - zero_count == k) {
//			ans++;
//		}
//	}
//	//rep(i, n) h[i]=i;
//	//sort(h.begin(), h.end());
//	//k = min(n, k);
//	/*ll ans = 0;
//	rep(i, k) {
//		h.pop_back();
//	}
//	rep(i, h.size()) ans += h[i];*/
//	cout << ans << endl;
//	return 0;
//

//int main()
//{
//	ll n;
//	int k;
//	cin >> n >> k;
//	//vector<int> h(n);
//	ll ans = 0;
//	
//	for (ll i = 1; i <= (n); ++i) {
//		ll temp = i;
//		int count = 0;
//		
//		while (temp > 0) {
//			ll num = temp % 10;
//			if (num != 0) {
//				count++;
//			}
//			temp /= 10;
//			if (count > k) {
//				if (num != 0) {
//					i += 8;
//				}
//				break;
//			}
//		}
//		if (count == k) {
//			ans++;
//		}
//	}
//	//rep(i, n) h[i]=i;
//	//sort(h.begin(), h.end());
//	//k = min(n, k);
//	/*ll ans = 0;
//	rep(i, k) {
//		h.pop_back();
//	}
//	rep(i, h.size()) ans += h[i];*/
//	cout << ans << endl;
//	return 0;
//}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	//bool no = false;
	rep(i, n) {
		cin >> a[i];
		//
		//if (!no) {
		//	if (vector_finder(a, input) == 1) {
		//		no = true;
		//	}
		//}
		//a[i] = input;
	}
	sort(a.begin(), a.end());
	bool no = false;
	rep(i, n-1) {

		if (a[i] == a[i + 1]) {
			no = true;
		}
		if (no) {
			break;
		}
	}
	string ans = no ? "NO" : "YES";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define loop(i,a,B) for (int i = a; i B; i++)
#define loopR(i,a,B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", my_dmp(#__VA_ARGS__, __VA_ARGS__)
void my_dmp(const char*) { cerr << endl; }
template <class T, class... U> void my_dmp(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; my_dmp(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
template <class T, class = typename T::iterator, class = typename enable_if<!is_same<T, string>::value>::type>
ostream& operator<<(ostream& os, T const& v) { os << "{"; for (auto const& x : v) os << " " << x; return os << " }"; }
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S>& p) { return is >> p.first >> p.second; }
struct my_Init { my_Init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } my_init;

template <class T, size_t d, class = typename enable_if<(d == 0)>::type> constexpr auto make_v(T const& x = {}) { return x; }
template <class T, size_t d, class... U, class = typename enable_if<(d > 0)>::type> constexpr auto make_v(size_t n, U... x) { auto val = make_v<T,d-1>(x...); return vector<decltype(val)>(n, move(val)); }
template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> constexpr bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> constexpr bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> constexpr auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
const ll INF = (1LL<<62)-1; // ~ 4.6e18
////////////////////////////////

int32_t main() {
    int n,k; cin >> n >> k;
    vector<int> a(n),f(n); cin >> a >> f;
    sort(all(a));
    sort(allR(f));
    if (sumof(all(a)) <= k) quit(0);

    int l = 0, r = 1e15;
    while (l+1 < r) {
        int m = (l+r)/2;
        int s = 0;
        rep (i,n) {
            if (a[i]*f[i] > m) s += a[i]-m/f[i];
        }
        (s <= k ? r : l) = m;
    }
    cout << r << "\n";
}


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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int a[N];
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int cnt =0;
    int ans =0;
    for(int i=1;i<n;i++){
        if(a[i]<=a[i-1]){
            cnt++;
        }else{
            cnt=0;
        }
        ans=max(cnt,ans);
    }
    // ans=max(ans,cnt);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define INF 1 << 28

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int h, num, i, j, a, b, m;
	cin >> h >> num;
	vector<vector<int>> dp(num + 1, vector<int>(h + 1, INF));
	dp[0][0] = 0;
	rep(i, num) {
		cin >> a >> b;
		rep(j, h + 1) {
			dp[i + 1][j] = min(dp[i][j], min(dp[i + 1][max(0, j - a)], dp[i][max(0, j - a)]) + b);
		}
	}
	cout << dp[num][h] << "\n";
	return 0;
}

Measured memory_bytes: 39424
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N; string S;
    cin >> N >> S;

    if (N % 2) {
        print("No");
        return 0;
    }

    REP(i, N / 2) {
        if (S[i] != S[N / 2 + i]) {
            print("No");
            return 0;
        }
    }

    print("Yes");
    
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define eps 1e-9
#define nmax 200
#define f(c,a,b) for(int c=a; c<=b; c++)

using namespace std;
typedef double db;
struct P{
    db x, y;
    P(){}
    P(db x, db y) : x(x) , y(y) {}
    P operator - (P a){ return P(x-a.x, y-a.y); }
    db times(P a){ return x*a.y-y*a.x; }
    db clen() { return x*x+y*y; }
}po[nmax];

int sign(db x) { return (x<-eps) ? -1 : x>eps; }

int inc(P c1, db r1, P c2, db r2){
    db dis = (c1-c2).clen();
    int x1 = sign( (r1+r2)*(r1+r2)-dis ), x2=sign( (r1-r2)*(r1-r2)-dis );
    //printf("%lf %lf %lf %d\n",r1,r2,dis, x1);
    if(x1 == 0) return 3;
    else if(x1 == -1) return 4;
    else {
        if(x2 == 0) return 1;
        else if(x2 == 1) return 0;
        else return 2;
    }
}

int main(){
    //freopen("owo.in","r",stdin);
    P c1, c2; 
    db r1, r2;
    cin >> c1.x >> c1.y >> r1;
    cin >> c2.x >> c2.y >> r2;
    cout << inc(c1, r1, c2, r2) << endl;
    return 0;
}


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

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

    if(B==1){
        cout << 0 << endl;
        return 0;
    }

    int sum = 1;
    int cnt = 0;
    for(int i=0; i<21; i++){
        sum += A - 1;
        cnt++;
        if(sum >= B) break;
    }

    cout << cnt << endl;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  
  if( ( a * b ) % 2 == 0 )
  {
    cout << "Even" << endl;
  }
  else
  {
    cout << "Odd" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
int main()
{
  int n,a[10000001];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int y=0;
  std::sort(a,a+n);
  for(int i=1;i<n;i++){
    if(a[i-1]==a[i]){
      y=1;
    }
  }
  if(y==1){
    printf("NO\n");
  }
  else{
    printf("YES\n");
  }
  return 0;
}

Measured memory_bytes: 2944
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())

    count = 0
    for i in range(1, n+1, 2):
        dcount = 0
        for j in range(1, i+1, 2):
            if  i % j == 0:
                dcount += 1

        if dcount == 8:
            count += 1

    print(count)


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

int main() {
  
  string S, T;
  cin >> S >> T;
  int C = 0;
  
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) {
      C = C + 1;
    }
  }
  
  cout << C;
  
}

Measured memory_bytes: 3912
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n,k=map(int,input().split())
Sushi=[list(map(int,input().split())) for i in range(n)]
Sushi=sorted(Sushi,key=lambda x: x[1],reverse=True)
ans=0
A=[]
kind=set()
for t,d in Sushi[:k]:
    ans+=d
    if t in kind:
        A.append(d)
    else:
        kind.add(t)
ans+=len(kind)**2
tmp=ans
for t,d in Sushi[k:]:
    if not A:
        break
    if not t in kind:
        tmp+=d-A.pop()+2*len(kind)+1
        kind.add(t)
        ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 30832
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

a, b, c = Is()
print(int(a*b/2))

Measured memory_bytes: 72564
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

/*階乗 a!*/
ll factorial(ll a){return a==1?a:a*factorial(a-1);}

ll permutation(ll n, ll a[n]){
    ll ans=0;
    rep(i,0,n-1){
        ll c=0;
        rep(j,i+1,n) if(a[i]>a[j]) c++;
        ans+=c*factorial(n-i-1);
    }
    return ans;
}

int main(void){
    // char ;
    ll n;
    scanf("%lld",&n);
    ll p[n],q[n];
    rep(i,0,n){
        scanf("%lld",&p[i]);
    }
    rep(i,0,n){
        scanf("%lld",&q[i]);
    }
    ll P=permutation(n,p),Q=permutation(n,q);
    printf("%lld\n",ABS(P-Q));
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int i, j, n, s[10000], q, t[500], cnt = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &s[i]);
  }

  scanf("%d", &q);
  for(j = 0; j < q; j++){
    scanf("%d", &t[j]);
    for(i = 0; i < n; i++){
      if(s[i] == t[j]){
	cnt++;
	t[j] = -1;
      }
    }
  }
  printf("%d\n", cnt);

  return 0;
}

  



Measured memory_bytes: 2108
n = STDIN.gets.to_i

min_digits = n
1.upto(Math.sqrt(n).to_i) do |a|
  if n % a == 0
    b = n / a

    a_digits = 0
    while (a > 0)
      a /= 10
      a_digits += 1
    end
    b_digits = 0
    while (b > 0)
      b /= 10
      b_digits += 1
    end

    bigger_digits = a_digits < b_digits ? b_digits : a_digits

    if bigger_digits < min_digits
      min_digits = bigger_digits
    end
  end
end

puts min_digits


Measured memory_bytes: 1788
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS = 1e-9;
#define rep(i,s,n) for(int i=(s); i < int(n); ++i)

const int N = 101;
const int V = 1e5 + 1;
int v[N], w[N];
int n, wlim;
int tv[N];

int dp[N][V];
const int INF = 0x2fffffff;
const int DEBUG = 0;

int solve(void) {
  dp[0][0] = 0;
  int total_v = 1;
  rep(i, 0, n) {
    total_v += v[i];
  }
  rep(j, 1, total_v) {
    dp[0][j] = INF;
  }
  rep(i, 1, n + 1) {
    rep(j, 0, total_v) {
      int res = dp[i-1][j];
      int val = v[i-1];
      int wei = w[i-1];
      if (val <= j) {
	res = min(res, dp[i - 1][j - val] + wei);
      } else {
	res = min(res, wei);
      }
      if(DEBUG) {
	cout << "dp[" << i << "][" << j << "] = " << res << endl;
      }
      dp[i][j] = res;
    }
  }
  int q = 0;
  rep(i,0,total_v) {
    if (dp[n][i] <= wlim) {
      q = i;
    }
  }
  if(DEBUG) {
    cout << "q = " << q << endl;
  }
  int rem = q;
  int sum = 0;
  for (int i = n; i > 0; --i) {
    int val = v[i-1];
    int wei = w[i-1];
    if (val <= rem && dp[i][rem] - wei == dp[i - 1][rem - val]) {
      // output (i - 1)
      sum += tv[i - 1];
      rem -= val;
    }
  }
  return sum;
}


int main(void) {
  cin >> n >> wlim;
  double max_v = 0.0;
  rep(i, 0, n) {
    cin >> tv[i] >> w[i];
    max_v = max(max_v, (double) tv[i]);
  }
  double k = 60;
  double scale = max(1.0, max_v / (k + 1) / n);
  rep(i, 0, n) {
    v[i] = (int) floor(tv[i] / scale);
  }
  cout << solve() << endl;
}

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

#define MAX 2000000
#define VMAX 10000

using namespace std;

int main()
{
    unsigned short *A, *B;
    int C[VMAX + 1];
    int n, i, j;
    scanf("%d", &n);

    A = (unsigned short *)malloc(sizeof(unsigned short) * n + 1);
    B = (unsigned short *)malloc(sizeof(unsigned short) * n + 1);

    for(i = 0; i < VMAX; i++) C[i] = 0;

    for(i = 0; i < n; i++) {
        scanf("%hu", &A[i+1]);
        C[A[i+1]]++;
    }

    for(i = 1; i <= VMAX; i++) {
        C[i] = C[i] + C[i-1];
    }

    for(i = 1; i <= n; i++) {
        B[C[A[i]]] = A[i];
        C[A[i]]--;
    }

    for(int i = 1; i <= n; i++) {
        printf("%d", B[i]);
        if(i != n) printf(" ");
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 10596
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        ArrayList<Point> red = new ArrayList<>();
        ArrayList<Point> blue = new ArrayList<>();
        boolean[] useRed = new boolean[n];
        for(int i = 0; i < n; i++){
            red.add(new Point(sc.nextInt(),sc.nextInt()));
        }
        for(int i = 0; i < n; i++){
            blue.add(new Point(sc.nextInt(),sc.nextInt()));
        }
        Collections.sort(red);
        Collections.sort(blue);
        int ans = 0;
        for(Point b : blue){
            int now = -1;
            int maxy = -1;
            for(int i = 0; i < n; i++){
                if(useRed[i]) continue;
                Point r = red.get(i);
                if(r.x < b.x && r.y < b.y && maxy < r.y){
                    maxy = r.y;
                    now = i;
                }
            }
            if(now != -1){
                ans++;
                useRed[now] = true;
            }
        }
        System.out.println(ans);
    }
}


class Point implements Comparable<Point>{
    int x,y;
    public Point(int x, int y){
        this.x = x;
        this.y = y;
    }
    
    public int compareTo(Point p){
        if(this.x < p.x){
            return -1;
        }else if(this.x > p.x){
            return 1;
        }else{
            if(this.y > p.y){
                return -1;
            }else if(this.y < p.y){
                return 1;
            }
        }
        return 0;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 21588
N = int(input())
g = [[-1]*N for i in range(N)]
ans=0
for i in range(N):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        g[i][x-1] = y
for i in range(1 << N):
    d=[0]*N
    for j in range(N):
        if (i >> j & 1) == 1:
            d[j] = 1
    ok = True
    for j in range(N):
        if d[j] == 1:
            for k in range(N):
                if g[j][k] == -1:
                    pass
                elif g[j][k] != d[k]:
                    ok = False
    if ok:
        ans = max(ans,d.count(1)) 
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long ba = b - a;
  long long dc = d - c;
  for (long long x = 0; x <= n - 1; x++) {
    long long y = n - 1 - x;
    long long l = -d * x + c * y;
    if (l <= ba && ba <= l + (n - 1) * dc) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			ArrayList<Queue<Integer>> Q = new ArrayList<>();
			int n = sc.nextInt();
			for(int i = 0; i < n; i++) {
				Q.add(new LinkedList<Integer>());
			}
			int qn = sc.nextInt();
			for(int i = 0; i < qn; i++) {
				int q = sc.nextInt();
				switch(q) {  // 文字列に対し switch を使って良い
				case 0 /* enqueue(t)*/: {
					int t = sc.nextInt();
					int x = sc.nextInt();
					Q.get(t).add(x);
					break;  /* break を忘れない */
				}
				case 1 /* front(t) */: {
					int t = sc.nextInt();
					if(!Q.get(t).isEmpty()) {
						System.out.println(Q.get(t).peek());
					}
					break;  /* break を忘れない */
				}
				case 2: /* dequeue(t) */ {
					int t = sc.nextInt();
					if(!Q.get(t).isEmpty()) {
						Q.get(t).remove();
					}
					break;  /* break を忘れない */
				}
				}
			}
		}
	}
}


Measured memory_bytes: 174076
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Summarize count of factor within list -- START --
def summarize_list(l):
  sl=sorted(l)

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res
# Summarize count of factor within list --- END ---

def main():
  n=I()
  l=LI()

  for i in range(n-1):
    l[i+1]+=l[i]

  l=summarize_list(l)

  ans=0
  for a,b in l:
    if a==0:
      ans+=b
      if b>1:
        ans+=b*(b-1)//2
    else:
      if b>1:
        ans+=b*(b-1)//2

  return ans

# main()
print(main())


Measured memory_bytes: 41316
_ = gets.to_i 
a = gets.split.map(&:to_i)
count = 0
a = a.select { |num| num.even? }

a.each do |n|
  count += 1 unless n % 3 == 0 || n % 5 == 0
end

if count > 0
  puts "DENIED"
else
  puts "APPROVED"
end

Measured memory_bytes: 1788
N = int(input())
x = {}
y = {}
h = {}
for i in range(N):
  x[i], y[i], h[i] = map(int, input().split())
  if h[i] != 0:
    x0, y0, h0 = x[i], y[i], h[i]
for cx in range(101):
  for cy in range(101):
    H = h0 + abs(cx - x0) + abs(cy - y0)
    for i in range(N):
      if max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
        break
    else:
      print(cx, cy, H)
      break
    continue
  else:
    continue
  break


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

int main()
{
	int a, b;
	cin >> a >> b;
	if (a >= 13)
	{
		cout << b;
	}
	else if (a >= 6)
	{
		cout << b / 2;
	}
	else
	{
		cout << 0;
	}
	return 0;
}


Measured memory_bytes: 3596