akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define Pi 3.1415926535
#define MOD 1000000007;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << endl;}
void no(){cout << "No" << endl;}

int solve(){
    int n; cin >> n;
    cerr << "error!" << endl;
    vector<string> s(n); rep(i,n) cin >> s[i];
    sort(all(s));
    int ans = n;
    rep(i,n-1){
        if(s[i] == s[i+1]) --ans;
    }

    cout << ans << endl;

    return 0;
}

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


Measured memory_bytes: 9564
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
ans[0]=sum([2*a[i] for i in range(1,n,2)])
ans[0]=sum(a)-ans[0]

for i in range(n-1):
  ans[i+1]=2*a[i]-ans[i]

print(*ans)


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

int main()
{
	int sums[1010];
	int a, b;
	
	for (int i = 0; i < 1010; i++)
	{
		sums[i] = i * (i + 1) / 2;
	}
	cin >> a >> b;
	
	cout << sums[b - a] - b << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        double R = scan.nextDouble();
        System.out.printf("%.6f\n", 2 * Math.PI * R);
    }
}


Measured memory_bytes: 28936
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, S, T):

    MOD = 10**9 + 7
    dp0 = [1] * (M+1)
    for s in S:
        dp1 = dp0[:]
        k = 0
        for j, t in enumerate(T):
            if s == t:
                k += dp0[j]
            dp1[j+1] = (dp0[j+1] + k) % MOD
        dp0 = dp1

    return dp0[-1]


def main():
    N, M = read_int_n()
    S = read_int_n()
    T = read_int_n()
    print(slv(N, M, S, T))


if __name__ == '__main__':
    main()


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

int main(){
   int n;
   cin >> n;
   int max = 0;int sum = 0;
   for(int i =0;i<n;i++){
     int a;
     cin >> a;
     if(a >= max){
       max = a;
        sum += 1;
     }
   }
   cout << sum << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;

class Program
{
    #region Lib

    static int Gcd(int a, int b)
    {
        if (a % b == 0)
            return b;
        else
            return Gcd(b, a % b);
    }

    #endregion

    static void Main()
    {

        var nums = ReadInts();
        var h = nums[0];
        var w = nums[1];

        var map = new char[h + 2][];
        map[0] = map[map.Length - 1] = Empty(w+2).ToArray();
        for (int i = 1; i < map.Length - 1; i++)
        {
            map[i] = E(Console.ReadLine()).ToArray();

        }

        for (int y = 1; y <= h; y++)
        {
            for (int x = 1; x <= w; x++)
            {
                if (map[y][x] == '#')
                    continue;
                map[y][x] = (char)('0' + X(map, y, x));
            }
        }


        for (int y = 1; y <= h; y++)
        {
            for (int x = 1; x <= w; x++)
            {
                Console.Write(map[y][x]);
            }

            Console.WriteLine();
        }
    }


    static int X(char[][] array, int y, int x)
    {
        var ret = 0;
        for (int i = 0; i < 8; i++)
        {
            if (array[y + dirY[i]][x + dirX[i]] == '#')
                ret++;
        }
        return ret;
    }

    static int[] dirX = { -1, -1, -1, 0, 0, 1, 1, 1 };
    static int[] dirY = { -1, 0, 1, -1, 1, -1, 0, 1 };

    static IEnumerable<char> Empty(int w)
    {
        return Enumerable.Repeat('.', w);
    }

    static IEnumerable<char> E(string x)
    {
        yield return '.';
        foreach (var item in x)
        {
            yield return item;
        }
        yield return '.';
    }

    #region Utils
    public static int[] ReadInts()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    #endregion



}






Measured memory_bytes: 13396
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <cmath>      // sqrt
#include <cstdlib>    // exit
#include <algorithm>  // min,max
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define BIG 99999999
#define DBG 0

#define MAXN 100000
int n;
vector<int> l(8);

void bits(list<int> *a, int k, list<int> *excl) {
  forr(i,0,n-1)
    if ((k>>i)%2 == 1 &&
        find(excl->begin(), excl->end(), i) == excl->end())
      a->push_back(i);
}
void bitsg(list<int> *a, int k, int excl) {
  forr(i,0,n-1)
    if ((k>>i)%2 == 1 && ((1 << i) & excl) == 0)
      a->push_back(i);
}

int mpa(int x, list<int> *t) {
  int len = 0;
  int cnt = 0;
  int mn = BIG;
  forall(it, (*t)) {
    len += l[*it];
    cnt += 1;
  }
  int mp = 10 * (cnt-1) + abs(len-x);
  mn = min(mp, mn);
  return mn;
}

int mpb(int x, list<int> *t) {
  int mn = BIG;
  int sz = t->size();
  if (DBG) cout << "* mpa x " << x << " sz " << sz << endl;
  forr(i, 1, pow(2,sz)-1) {
    int len = 0;
    int cnt = 0;
    auto pp = t->begin();
    forr(j, 0, sz-1) {
      if ((i>>j)%2 == 1) {
        len += l[*pp];
        cnt += 1;
      }
      ++pp;
    }
    int mp = 10 * (cnt-1) + abs(len-x);
    mn = min(mp, mn);
  }
  return mn;
}

int main() {
  int a,b,c;
  cin >> n >> a >> b >> c;
  forr(i,0,n-1)
    cin >> l[i];

  int mn = BIG;
  int bmax = pow(2, n) - 1;
  forr(i, 1, bmax-3) {
    list<int> ta;
    list<int> dmy;
    bits(&ta, i, &dmy);
    int va = mpa(a, &ta);
    if (DBG) {
      cout << "i " << i << " va " << va << " ta ";
      forall(it, ta) cout << *it << " ";
      cout << endl;
    }

    forr(j, 1, bmax-1) {
      list<int> tb;
      bits(&tb, j, &ta);
      if (tb.size() == 0) continue;
      int vb = mpa(b, &tb);
      if (DBG) {
        cout << "-j " << j << " vb " << vb << " tb ";
        forall(it, tb) cout << *it << " ";
        cout << endl;
      }
      //list<int> ex;
      //forall(it, ta) ex.push_back(*it);
      //forall(it, tb) ex.push_back(*it);
      int ex = 0;
      forall(it, ta) ex |= 1<<(*it);
      forall(it, tb) ex |= 1<<(*it);

      forr(k, 1, bmax) {
        list<int> tc;
        bitsg(&tc, k, ex);
        if (tc.size() == 0) continue;
        int vc = mpa(c, &tc);
        if (DBG) {
          cout << "--k " << k << " vc " << vc << " tc ";
          forall(it, tc) cout << *it << " ";
          cout << endl;
        }
        int v = va + vb + vc;
        if (DBG && v < mn)
          cout << "mn upd " << v;
        mn = min(mn, v);
      } // forr k
    } // forr j

  }  // forr i
  cout << mn << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,i,k,r=0,g=0,b=0,ans;
  string s;
  cin>>n>>s;
  for(i=0;i<n;i++){
    if(s[i]=='R') r++;
    else if(s[i]=='G') g++;
    else b++;
  }
  ans=r*g*b;
  for(i=0;i<n-2;i++){
    for(k=1;k<(n-i+1)/2;k++){
      if(s[i]!=s[i+k]&&s[i+k*2]!=s[i]&&s[i+k]!=s[i+k*2]) ans--;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  set<ll> nums;

  rep(i, K){
    if(A + i > B) break;
    nums.insert(A + i);
  }
  rep(i, K){
    if(B - i < A) break;
    nums.insert(B - i);
  }

  for(auto it = nums.begin(); it != nums.end(); it++)
    cout << (*it) << endl;
  
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)

Alice = 0
Bob = 0

for i in range(N):
  if i % 2 == 0:
    Alice += a.pop(0)
  else:
    Bob += a.pop(0)

print(Alice - Bob)


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

struct edge { long long to, cost;};
typedef pair<long long, long long> P_dij;

vector<long long> dijkstra(const long long s, const long long n, vector< vector<edge> > const &G){
    vector<long long> d = {};
    long long INF = 10000000000000000;
    d.resize(n);
    for(int i=0; i<n; i++){
        d[i] = INF;
    }
    priority_queue<P_dij, vector<P_dij>, greater<P_dij>> que;
    d[s] = 0;
    que.push(P_dij(0, s));
    while(!que.empty()){
        P_dij p = que.top();
        que.pop();
        long long v = p.second;
        if(d[v] < p.first)continue;
        for(int i=0;i<G[v].size(); i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P_dij(d[e.to], e.to));
            }
        }
    }
    return d;
}

long long i, j, k;
vector< vector<edge> > edge_yen(200001);
vector< vector<edge> > edge_snu(200001);

int main(){
    long long n, m, s, t;
    cin >> n >> m >> s >> t;
    for(i=0; i<m; i++){
        long long u, v, a, b;
        cin >> u >> v >> a >> b;
        edge e1;
        e1.to = v, e1.cost = a;
        edge_yen[u].push_back(e1);
        edge e2;
        e2.to = u, e2.cost = a;
        edge_yen[v].push_back(e2);
        edge e3;
        e3.to = v, e3.cost = b;
        edge_snu[u].push_back(e3);
        edge e4;
        e4.to = u, e4.cost = b;
        edge_snu[v].push_back(e4);
    }

    vector<long long> dist_yen = dijkstra(s, n+1, edge_yen);
    vector<long long> dist_snu = dijkstra(t, n+1, edge_snu);

    long long ans[200001];
    long long Max = 0;
    long long FIRST = 1e15;
    for(i=n; i>=1; i--){
        long long val = FIRST - (dist_yen[i] + dist_snu[i]);
        Max = max(val, Max);
        ans[i] = Max;
    }
    for(i=1; i<=n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 23876
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int A,B,C,D;

	scanf("%d %d %d %d",&A,&B,&C,&D);

	printf("%d\n",max(A*B,C*D));

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
using namespace std;



int main() {
	int n;
	cin >> n;
	int m;
	cin >> m;
	vector<int> h(n);
	vector<pair<int,int>> a(m);
	int cnt = 0;
	vector<int> c(n,0);
	for (int i = 0;i < n;i++)cin >> h.at(i);
	for (int i = 0;i < m;i++)cin >> a.at(i).first>>a.at(i).second;
	for (int i = 0;i < m;i++){
		if (h.at(a.at(i).first - 1) < h.at(a.at(i).second - 1))
			c.at(a.at(i).first - 1)++;
		else if (h.at(a.at(i).first - 1) == h.at(a.at(i).second - 1)) {
			c.at(a.at(i).first - 1)++;
			c.at(a.at(i).second - 1)++;
		}
		else c.at(a.at(i).second - 1)++;

	}
	for (int i = 0;i < n;i++) {
		if (c.at(i) == 0)cnt++;
	}
	cout << cnt << endl;
}

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

typedef long long ll;

using namespace std;

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

    if (a == b) {
        cout << 0;
    } else if (a < b) {
        cout << max(0, b - a - w);
    } else {
        cout << max(0, a - b - w);
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int main(){
  int n;
  int cs=1;
  while(cin >> n, n){
    int field[10][10];
    
    int cnt = 1;
    field[0][0] = cnt++;
    
    int x = 0, y = 0;
    
    while(cnt < n*n){   
      if(x < n-1){
	x++;
	field[y][x] = cnt++;
	//printf("x = %d, y = %d, cnt = %d\n", x, y, cnt-1);
      }
      
      //if(cnt >= n*n) break;
      
      while(0 < x && y < n-1){
	x--, y++;
	field[y][x] = cnt++;
	//printf("x = %d, y = %d, cnt = %d\n", x+1, y+1, cnt-1);
      }
      
      if(y == n-1){
	x++;
	field[y][x] = cnt++;
	//printf("x = %d, y = %d, cnt = %d\n", x+1, y+1, cnt-1);
      }
      
      else{
	y++;
	field[y][x] = cnt++;
	//printf("x = %d, y = %d, cnt = %d\n", x+1, y+1, cnt-1);
      }
      
      while(0 < y && x < n-1){
	x++, y--;
	field[y][x] = cnt++;
	//printf("x = %d, y = %d, cnt = %d\n", x+1, y+1, cnt-1);
      }
      
      if(x == n-1){
	y++;
	field[y][x] = cnt++;
      }
    }
    
    printf("Case %d:\n", cs++);
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++){
	printf("%3d", field[i][j]);
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main() {
	int N;cin>>N;
	vector<int>A(N);
	int maxA1=0, maxA2=0;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		if (A[i] > maxA1)
		{
			maxA2 = maxA1;
			maxA1 = A[i];
		}
		else if (A[i] > maxA2)
		{
			maxA2 = A[i];
		}
	}

	for (int i = 0; i < N; i++)
	{
		if(A[i] != maxA1)cout<<maxA1<<endl;
		else cout<<maxA2<<endl;
	}

	return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int A,B,C,D,E,F;
set<int> v;

int ans_child=0,ans_mother;

int main(){
    cin>>A>>B>>C>>D>>E>>F;
    ans_mother=A*100;
    for(int i=0;A*i*100<=F;i++){
        for(int j=0;0<A*i*100+B*j*100 && A*i*100+B*j*100<=F;j++){
            v.insert(A*i+B*j);
        }
    }
    for(auto water:v){
        int sugerLimit=water*E;
        int suger=0;
        for(int i=0;C*i<=sugerLimit;i++){
            for(int j=0;C*i+D*j<=sugerLimit && water*100+C*i+D*j <= F;j++){
                suger=max(suger,C*i+D*j);
            }
        }
        if(ans_child*(water*100+suger) < suger*ans_mother ){
            ans_child=suger;
            ans_mother=water*100+suger;
        }
    }
    cout << ans_mother << " " <<ans_child<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(x) (((long long)x)%modulo)



int main(){
	int N;
	cin>>N;
	vector<vector<pair<int,int>>> E(N,vector<pair<int,int>>(0));
	for(int i=0;i<N-1;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		E[a].push_back(make_pair(b,c));
		E[b].push_back(make_pair(a,c));
	}
	
	vector<int> ans(N,-1);
	queue<int> que;
	que.push(0);
	ans[0]=0;
	
	while(que.size()!=0){
		int x = que.front();
		que.pop();
		for(int i=0;i<E[x].size();i++){
			int a = E[x][i].first;
			int b = E[x][i].second;
			if(ans[a]!=-1)continue;
			que.push(a);
			if(b%2==0)ans[a]=ans[x];
			else ans[a]=-ans[x]+1;
		}
	}
	
	for(int i=0;i<N;i++){
		cout<<ans[i]<<endl;
	}
	
	return 0;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>data(n,0);
  
  for(int i=0;i<k;i++){
    int num;
    cin>>num;
    for(int j=0;j<num;j++){
      int a;
      cin>>a;
      data.at(a-1)++;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(data.at(i)==0) ans++;
  }
  cout<<ans<<endl;
}
    
    
    


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

//#define fin cin
//#define fout cout

#define leftSon (node << 1)
#define rightSon ((node << 1) | 1)

#define pii pair < int , int >
#define F first
#define S second

using namespace std;

typedef long long ll;

const int inf = 0x3f3f3f3f;
const long long infL = LLONG_MAX;

struct psychotronic_induction {
    int electromagnetic_wave = 7;
};

const int nmax = 1e5 + 10;

int n;
int a[nmax];
string s;

bool ok(int x) {
    int l = x - 1; if (l == 0) l = n;
    int r = x + 1; if (r == n + 1) r = 1;
    int xx; if (a[x] == 1) xx = 1; else xx = 0;
    if (s[x] == 'o')
        return a[l] == a[r] ^ xx;
    return a[l] != a[r] ^ xx;
}

int main()
{
    

    /*
    ifstream fin("input.in");
    ofstream fout("output.out");
    */

    cin >> n >> s; s = ' ' + s;

    for (a[1] = 0; a[1] <= 1; ++a[1])
        for (a[n] = 0; a[n] <= 1; ++a[n]) {

            for (int j = 2; j < n; ++j)
                for (a[j] = 0; a[j] <= 1; ++a[j])
                    if (ok(j - 1)) break;

            if (ok(n-1) && ok(n) && ok(1)) {
                for (int i = 1; i <= n; ++i)
                    (a[i] == 0) ? cout << "S" : cout << "W";
                return 0;
            }
        }

    cout << "-1\n";

    return 0;
}


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

const int N = 1e5 + 10;

int n, m, a[N];
vector<int> g[N];

vector<int> vals;
bool vis[N];
void dfs(int u) {
    if (vis[u]) return;
    vis[u] = 1;
    vals.push_back(a[u]);
    for (auto v : g[u]) dfs(v);
}


int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    int iter = m; while (iter--) {
        int u,v; cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    if (n-m == 1) return cout << 0, 0;

    bool good = n >= 2*(n-m-1);
    if (!good) return cout << "Impossible\n", 0;

    vector<int> rest;
    int deg = 2*(n-m-1);
    long long ans = 0;
    for (int u = 0; u < n; u++) if (!vis[u]) {
        vals.clear();
        dfs(u);
        sort(vals.begin(), vals.end(), greater<int>());

        ans += vals.back();
        vals.pop_back();
        deg--;
        for (auto x : vals) rest.push_back(x);
    }

    sort(rest.begin(), rest.end(), greater<int>());
    while (deg--) {
        ans += rest.back();
        rest.pop_back();
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7420
import java.util.*;
import java.io.*;

public class Main {
		public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
		int N = Integer.parseInt(br.readLine());
		String[] inA = br.readLine().split(" ");
		long[] A = new long[N];
		A[0] = Long.parseLong(inA[0]);
		long[] sum = new long[N];
		sum[0] = A[0];
		
		long ans = 0;
		long C = 1000000007;
		for(int i=1; i<inA.length; i++){
		    A[i] = Long.parseLong(inA[i]);
		    sum[i] = (sum[i-1] + A[i])%C;
		}
		
		for(int a1 = 1; a1<N; a1++){
		    ans += A[a1]*sum[a1-1]%C;
		    ans %= C;
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 62144
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n, x, t = ns()

    ans = n // x
    ans += 1 if n % x else 0
    ans *= t
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9472
#include<bits/stdc++.h>         //可以处理负权边
using namespace std;
const int INF =  0x3f3f3f;
#define rep(i,n) for( i = 0; i < n; i++)
#define rep2(i,n) for(i = n-1; i >= 0; i--)
#define rep3(i,n,m) for(i = m; i < n; i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
typedef long long ll;
const int N = 100000+50;
typedef pair<int, int> P;
typedef vector<P> vctp;
int arry[N] = {0};
int main(){
	string s;
	cin>>s;
	stack<char> p;
	int ans=0;
	for(int i=0;i<s.length();i++){
		if(p.empty())
		    p.push(s[i]);
		else if(s[i]==p.top())
		    p.push(s[i]);
		else{
			p.pop();
			ans++;
		}
	}
	cout<<ans*2<<"\n";
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << 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 n;

int main(){
    cin>>n;
    for(int i=111;i<1000;i+=111){
        if(n<=i){
            out(i);
            return 0;
        }
    }
}

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

using namespace std;

int main() {
    int n, m;

    cin >> n >> m;

    vector<int> t(n);

    for (int j = 0; j < n; ++j) {
        t.at(j) = 0;
    }

    for (int i = 0; i < m; ++i) {
        int a, b;

        cin >> a >> b;
        
        t.at(a - 1)++;
        t.at(b - 1)++;
    }

    for (int k = 0; k < n; ++k) {
        cout << t.at(k) << endl;
    }
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll A, B;
    cin >> A >> B;
    if (A + B < 10)
    {
        cout << A + B << endl;
    }
    else
    {
        cout << "error" << endl;
    }
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

string s;
bool winner()
{
	return(sz(s) % 2 == 0) ^ (s[0] == s[sz(s) - 1]);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> s;

	if(winner())
		cout << "Second\n";
	else
		cout << "First\n";

	return 0;
}

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

struct cmp {
	inline bool operator() (const int &i1, const int &i2)const {
		return i1 > i2;
	}
};

int a[1000005];
int main() {
	int n;
	cin>>n;
	for (int i = 1; i <= n; i++)
		cin>>a[i];
	sort(a + 1, a + 1 + n, cmp());
	for (int i = 1; i <= n; i++)
		if (i + 1 > a[i + 1]) {
			int j = 0;
			for (; a[j + i + 1] == i; j++);
			if ( ( (a[i] - i) & 1) || (j & 1) ) puts("First");
			else puts("Second");
			return 0;
		}
}

Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

#include <complex>
typedef complex<double> P;
#define EPS (1e-10)
#define EQ(x, y) (abs((x)-(y)) < EPS)

const double MAX=INT_MAX/10;
const double NONE=-1;

double cross(P a, P b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}

int is_point_on_line(P a, P b, P c) {
	return EQ( cross(b-a, c-a), 0.0 );
}

int is_intersected_ls(P a1, P a2, P b1, P b2)
{
	if ( (cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS) &&
			(cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS) ) {
		return true;
	}
	return is_point_on_line(a1, a2, b1) ||
		is_point_on_line(a1, a2, b2) ||
		is_point_on_line(b1, b2, a1) ||
		is_point_on_line(b1, b2, a2);
}

struct node{
	int index;
	double cost;
	node(int index, double cost):index(index),cost(cost){}
	bool operator<(const node& other)const {
		return cost>other.cost;
	}
};

typedef vector<double> vd;
typedef vector<vd> vvd;

int main()
{
		cout.precision(16);
	int na,nb;
	cin>>na>>nb;
	
	vector<P> a(na),b(nb);
	REP(i,na){
		int x,y;
		cin>>x>>y;
		a[i]=P(x,y);
	}
	REP(i,nb){
		int x,y;
		cin>>x>>y;
		b[i]=P(x,y);
	}

	if(!is_intersected_ls(a[0],a[1],b[0],b[1])){
		cout<<abs(a[0]-a[1])+abs(b[0]-b[1])<<endl;
	}else{
		double ans=MAX;
		REP(ab,2){
			vector<P> ps;
			int n;
			P fixed_p1,fixed_p2;
			if(ab==0){
				ps=a;
				n=na;
				fixed_p1=b[0];
				fixed_p2=b[1];
			}else{
				ps=b;
				n=nb;
				fixed_p1=a[0];
				fixed_p2=a[1];
			}
			vvd g(n,vd(n,NONE));
			REP(i,n){
				FOR(j,i+1,n){
					if(!is_intersected_ls(fixed_p1,fixed_p2,ps[i],ps[j])){
						g[i][j]=abs(ps[i]-ps[j]);
						g[j][i]=abs(ps[i]-ps[j]);
					}
				}
			}

			int start=0;
			int goal=1;
			priority_queue<node> q;
			q.push(node(start,0));
			vd cost(n,MAX);
			cost[start]=0;
			while(!q.empty()) {
				node cnode = q.top(); q.pop();
				if(cost[cnode.index]<cnode.cost) {
					continue;
				}
				REP(i,n){
					if(i!=cnode.index&&g[cnode.index][i]!=NONE){
						double newcost=cnode.cost+g[cnode.index][i];
						if(cost[i]>newcost+EPS){
							cost[i]=newcost;
							q.push(node(i,newcost));
						}
					}
				}
			}
			ans=min(ans,cost[goal]+abs(fixed_p1-fixed_p2));
		}
		cout<<(ans==MAX?-1:ans)<<endl;
	}
}

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

int main() {
  int N;
  cin>>N;
  int A=N/2;
  double P=1000000*(A+1)/N;
  if(A*2==N){
    cout<<"0.5"<< endl;
  }
  else{
    cout<<P*0.000001<< endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 200003;

int n, m;
int a[N], b[N];
char s[N];

int main()
{
    n = gi();
    LL ans = 0;
    for (int i = 1; i <= n; i+=1) 
        if (i % 3 && i % 5) ans += i;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = [0] * N
for i in range(N): a[i] = int(input())
a.sort()
res = float("inf")
for i in range(N - K + 1):
  res = min(res, a[i + K - 1] - a[i])
print(res)

Measured memory_bytes: 41820
import sys
input = sys.stdin.readline
N,Q=map(int,input().split())
ans=[0]*N
ki=[[] for _ in range(N)]
for i in range(N-1):
 a,b=map(int,input().split())
 ki[a-1].append(b-1)
 ki[b-1].append(a-1)
for i in range(Q):
 p,q=map(int,input().split())
 ans[p-1]+=q
# dfs
stack = [0]
visited = ["False"] * N
while stack:
 ne = stack.pop()
 if visited[ne] == "False":
  visited[ne] = "True"
  for j in ki[ne]:
   if visited[j] == "False":
    ans[j]+=ans[ne]
    stack.append(j)
L=[str(a) for a in ans]
L=' '.join(L)
print(L)

Measured memory_bytes: 66840
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N, X; cin >> N >> X;
    vector<long long> x(N);
    for(int i=0; i < N; i++) cin >> x[i];
    vector<long long> dist(N);
    for(int i=0; i < N; i++) dist[i] = abs(x[i] - X);
    //配列distの最小公倍数を求める
    //dist[0]の値を初めの最小公倍数候補として、
    //以降はiを増やしながらdist[i]と候補との最小公倍数を求めていく
    long long gcd = dist[0];
    for(int i=1; i < N; i++) {
        long long a = dist[i];
        while(1) {
            long long b = gcd % a;
            gcd = a;
            a = b;
            if(b == 0) break;
        }
    }
    cout << gcd << endl;
    return 0;
}


Measured memory_bytes: 1792
import sys
n,m,x,y =  list(map(int,input().split()))
xxx =  list(map(int,input().split()))
yyy =  list(map(int,input().split()))
if x < y:
  for i in range(x+1,y):
    if max(xxx) < i <= min(yyy):
      print("No War")
      sys.exit()
print("War")

Measured memory_bytes: 3060
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(0,len(N),2):
    a = [int(i) for i in N[l].split()]
    b = [int(i) for i in N[l+1].split()]

    hit = 0
    blow = 0
    for i in range(len(a)):
        for j in range(len(b)):
            if a[i] == b[j]:
                if i == j:
                    hit = hit+1
                else:
                    blow = blow+1
    print(hit,blow)



Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main() {

    char c;
    cin >> c;

    cout << (char) (c + 1) << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int mod = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
//////////////////////////////////


int main(){
    int n; cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++) cin >> d[i];
    sort(d.begin(), d.end());
    int m = n/2;
    cout << d[m]-d[m-1] << endl;

    return 0;
}

// EOF


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;



int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n), c(m), d(m);
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, m) cin >> c[i] >> d[i];

  rep(i, n){
    int dis = INF;
    int ans;
    rep(j, m){
      int tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (tmp < dis){
        dis = tmp;
        ans = j + 1;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int A,B,C;cin >> A >> B >> C;
    int X,Y;cin >> X >> Y;
    if(A+B < 2*C){
        cout << A*X + B*Y << endl;
    }
    else{
        int yen = (max(X,Y) == X ? A : B);
        int ans = (yen < 2*C ? yen : 2*C);
        cout << min(X,Y)*2*C + abs(X-Y)*ans << endl;
    }
}

Measured memory_bytes: 256
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

function main()
    X = pread(Int)
    a = 100
    for i in 1:10000
        a = Int(floor(1.01*a))
        if a >= X
            println(i)
            break
        end
    end
end

main()


Measured memory_bytes: 184416
using System;
using System.IO.Pipes;
using System.Runtime.InteropServices.ComTypes;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] str =Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            int ans;
            ans = a * b;
            if (ans % 2 == 0){
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }

        }
    }
}


Measured memory_bytes: 27476
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=9e15;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////


//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  sin(s);sin(t);
  bool OK = true;
  rep(i, s.size()){
    if(s[i] != t[i]) OK =false;
  }
  if(OK) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
#define f(i,a,b) for(i=a;i<b;i++)

using namespace std;

int main() {
  ll n,i,j;
  
  cin>>n;
  
  ll a[n];
  
  for(i=0;i<n;i++)cin>>a[i];
  
  sort(a,a+n);
  
  reverse(a,a+n);
  
  ll s=0;
  if(n%2)
 { for(i=0;i<n/2;i++)s+=a[i];
  for(i=1;i<=n/2;i++)s+=a[i];}
  
  else 
  {
      for(i=0;i<n/2;i++)s+=a[i];
      for(i=1;i<n/2;i++)s+=a[i];
     
  }
  cout<<s;

}

Measured memory_bytes: 5180
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    if (n + 1 != m) cout << "No" <<endl;
    bool flag = true;
    for (int i = 0; i < n; i++) {
        if (s[i] != t[i]) {
            flag = false;
            break;
        }
    }
    if (flag) cout << "Yes" <<endl;
    else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 3612
#!/usr/bin/perl
use Data::Dumper;

my ($n,$m,$k) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @aa = map { $_ - 0 } split(/\s+/,<STDIN>);
my @bb = map { $_ - 0 } split(/\s+/,<STDIN>);

my @sa = ();
$#sa = $n;

my $ia = -1;
my $lst = 0;

$sa[0] = 0;
for(my $i=0;$i<$n;$i++){
  $sa[$i+1] = $sa[$i] + $aa[$i];
  if( $sa[$i+1] <= $k ){
    $ia = $i;
  }
}

if( $ia>=0 ){ $lst = $k - $sa[$ia+1]; }

my $ib = -1;

my @sb = ();
$#sb = $m;

$sb[0] = 0;
for(my $i=0;$i<$m;$i++){
  $sb[$i+1] = $sb[$i] + $bb[$i];
  if( $sb[$i+1] <= $lst ){
    $ib = $i;
  }
}

my $mx = ( $ia + 1 ) + ( $ib + 1 );

for(my $i = $ib; $i<$m; $i++){
  my $c_b = $sb[$i+1];
  next if $c_b > $k;
  while( $ia >= 0 and $sa[$ia+1] > $k - $c_b ){ $ia -- ; }
  my $cur = ( $ia + 1 ) + ( $i + 1 );
  $mx = $cur if( $cur > $mx );
  
  #print "$i $ia $cur\n";
}
print "$mx\n";




Measured memory_bytes: 52856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

struct XORShift {
    unsigned int x, y, z, w, t;

    XORShift(int seed) {
        mt19937 rnd(seed);
        x = rnd();
        y = rnd();
        z = rnd();
        w = rnd();
        t = 1;
    }

    int rand() {
        t = x ^ (x << 11);
        x = y;
        y = z;
        z = w;
        w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
        return w & 0x7fffffff;
    }
} rnd(rand());

constexpr int N = 26;
constexpr int D = 365;
const double TIMELIMIT = 1.95;
int d;
int c[N];
int s[D][N];

struct STATE {
    int contests[D];
    ll score;
};

STATE state;

void init(STATE& state) {
    state.score = 0;
    int last[N];
    fill(last, last + N, -1);
    rep(i, D) {
        int mx = -INF;
        int select;
        rep(j, N) {
            if (s[i][j] > mx) {
                mx = s[i][j];
                select = j;
            }
        }
        state.contests[i] = select;
        state.score += mx;
        last[select] = i;
        rep(j, N) {
            state.score -= c[j] * (i - last[j]);
        }
    }
}

int cnt = 0;

void SA() {
    init(state);
    double starttemp = 9000.0, endtemp = 1.0;
    int startclock = clock();
    while (true) {
        int nowclock = clock();
        if (nowclock - startclock > TIMELIMIT * CLOCKS_PER_SEC) break;
        STATE newstate = state;
        int d = rnd.rand() % D, nc = rnd.rand() % N;
        int pc = newstate.contests[d];
        newstate.score -= s[d][pc];
        newstate.score += s[d][nc];
        int last = d;
        while (last >= 0 && newstate.contests[last] != nc) {
            last--;
        }
        for (int i = d; i < D; i++) {
            if (newstate.contests[i] == nc) break;
            newstate.score += c[nc] * (i - last);
            newstate.score -= c[nc] * (i - d);
        }
        newstate.contests[d] = nc;
        last = d;
        while (last >= 0 && newstate.contests[last] != pc) {
            last--;
        }
        for (int i = d; i < D; i++) {
            if (newstate.contests[i] == pc) break;
            newstate.score -= c[pc] * (i - last);
            newstate.score += c[pc] * (i - d);
        }
        double temp = starttemp + (endtemp - starttemp) *
                                      (nowclock - startclock) /
                                      (TIMELIMIT * CLOCKS_PER_SEC);
        if (exp((newstate.score - state.score) / temp) >
            (rnd.rand() % INF) / (double)INF) {
            state = newstate;
        }
        cnt++;
    }
}

signed main() {
    int t;
    cin >> t;
    rep(i, N) {
        cin >> c[i];
    }
    rep(i, D) {
        rep(j, N) {
            cin >> s[i][j];
        }
    }
    SA();
    rep(i, D) {
        cout << state.contests[i] + 1 << endl;
    }
    /*
    cout << "score : " << state.score << endl;
    cout << "cnt : " << cnt << endl;
    */
    return 0;
}

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

#define MOD 1000000007

using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	int N,D;
    int ans=0;
	cin >> N >> D;
    for(int i=0; i<N; i++){
      long long int x,y;
      long long int s;
      double t;
      cin >> x >> y;
      s = x*x + y*y;
      t = sqrt(s);
      if(t <= D){
        ans++;
      }
    }
    cout << ans;
}

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

using pii = pair<int, int>;

int main() {
    string s, t; cin >> s >> t;
    const int n = s.size(), m = t.size();

    vector<vector<int>> dp(n + 1, vector<int>(m + 1));
    vector<vector<bool>> valid(n + 1, vector<bool>(m + 1));
    vector<vector<pii>> prev(n + 1, vector<pii>(m + 1, make_pair(-1, -1)));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < m; ++j) {
            if(dp[i + 1][j] < dp[i][j]) {
                dp[i + 1][j] = dp[i][j];
                prev[i + 1][j] = make_pair(i, j);
            }
            if(dp[i][j + 1] < dp[i][j]) {
                dp[i][j + 1] = dp[i][j];
                prev[i][j + 1] = make_pair(i, j);
            }
            if(dp[i + 1][j + 1] < dp[i][j] + (s[i] == t[j])) {
                dp[i + 1][j + 1] = dp[i][j] + (s[i] == t[j]);
                prev[i + 1][j + 1] = make_pair(i, j);
                valid[i + 1][j + 1] = (s[i] == t[j]);
            }
        }
    }

    int max_len = 0;
    auto cur = make_pair(0, 0);
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= m; ++j) {
            if(dp[i][j] > max_len) {
                max_len = dp[i][j];
                cur = make_pair(i, j);
            }
        }
    }

    string ans;
    while(cur.first != -1) {
        if(valid[cur.first][cur.second]) {
            ans += s[cur.first - 1];
        }
        cur = prev[cur.first][cur.second];
    }
    reverse(begin(ans), end(ans));
    cout << ans << endl;
}


Measured memory_bytes: 107264
n,k = map(int,input().split())
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))

z = []
for j in a:
    for i in range(len(j)):
        z.append(j[i])

z = len(set(z))


print(n-z)

Measured memory_bytes: 9300
//File Name: arc090_a.cpp
  //Created Time: 2018年02月01日 星期四 22时29分27秒
                                   
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 101;
int a[2][MAXN],f[2][MAXN];

int solve(const int n){
    for(int i(1);i<=n;++i)
        f[0][i] = f[0][i - 1] + a[0][i];
    for(int i(1);i<=n;++i)
        f[1][i] = max(f[1][i - 1], f[0][i]) + a[1][i];
    return f[1][n];
}
int main(){
    int n;
    cin >> n;
    for(int i(0);i<2;++i){
        for(int j(1);j<=n;++j)
            cin >> a[i][j];
    }
    cout << solve(n) << endl;
    return 0;
}


Measured memory_bytes: 256
N,K,Q=map(int,input().split())
a=[]
A=[]

for _ in range(Q):
    a.append(int(input()))

for _ in range(N):
    A.append(int(K))

for n in range(Q):
    A[a[n]-1]+=1
    
for s in range(N):
    if A[s]-Q<1:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 10480
N, K = map(int, input().split())
ans = 0
count = 0
sub = 0

for i in range(1, N+1):
    count = 0
    ans = 1/N


    while i < K:
        i *= 2
        ans *= 0.5
        count += 1
        

    sub += ans

print(sub)


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

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"
const double PI = 3.14159265358979323846;

int main() {
	int N;
	cin >> N;
	N %= 10;
	if (N == 3) {
		cout << "bon" << endl;
	}
	else if (N == 0 || N == 1 || N == 6 || N == 8) {
		cout << "pon" << endl;
	}
	else {
		cout << "hon" << endl;
	}

	return 0;
}



Measured memory_bytes: 3632
import fractions
def main():
    T1, T2 = map(int, input().split())
    f = fractions.gcd(T1, T2)
    T1 //= f
    T2 //= f
    A1, A2 = map(int, input().split())
    B1, B2 = map(int, input().split())
    f = fractions.gcd(fractions.gcd(A1, A2), fractions.gcd(B1, B2))
    A1 //= f
    A2 //= f
    B1 //= f
    B2 //= f

    dif_half = T1*A1 - T1*B1
    dif_full = T1*A1 + T2*A2 - T1*B1 - T2*B2

    if dif_full == 0 or A1 == B1:
        print("infinity")
        return
    elif dif_full * dif_half > 0:   # 増減が入れ替わらない場合は会うことはない
        print(0)
        return
    elif dif_full > 0:
        flg = 1
    else:
        flg = -1

    if flg == 1 and dif_half <= 0:
        ans = 1
    elif flg == -1 and dif_half >= 0:
        ans = 1
    else:
        ans = 0

    ans += (- dif_half // dif_full) * 2 - (- dif_half % dif_full == 0)

    print(ans)

main()

Measured memory_bytes: 5304