akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

func geti() int {
	n, _ := strconv.Atoi(read())
	return n
}

// 10 11 12 => [10, 11, 12]
func getli(size int) []int {
	a := make([]int, size)
	list := strings.Split(read(), " ")
	for i, s := range list {
		n, _ := strconv.Atoi(s)
		a[i] = n
	}
	return a
}

func get2byte(size int) [][]byte {
	a := make([][]byte, size)
	for i := 0; i < size; i++ {
		var low string
		fmt.Scan(&low)
		a[i] = []byte(low)
	}
	return a
}

func transpose(a [][]int) {
	n := len(a)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			a[i][j], a[j][i] = a[j][i], a[i][j]
		}
	}
}

func fact(n, m int) int {
	res := 1
	for i := m + 1; i <= n; i++ {
		res *= i
	}
	return res
}

func perm(n, r int) int {
	if r > n {
		return 0
	}
	return fact(n, n-r)
}

func comb(n, m int) int {
	if m > n {
		return 0
	}
	return fact(n, n-m) / fact(m, 0)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	N := 2019
	s := read()
	m := make([]int, N)
	total := 0
	ten := 1
	for i := 0; i < len(s); i++ {
		n, _ := strconv.Atoi(s[len(s)-1-i : len(s)-i])
		total += (n * ten) % N
		ten = (ten * 10) % N
		m[total%N]++
	}
	sum := m[0]
	for _, v := range m {
		sum += v * (v - 1) / 2
	}
	fmt.Println(sum)
}


Measured memory_bytes: 2424
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int a,b;
    cin>>a>>b;

    cout<<(a+b)/2<<"\n";
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int n;
	cin >> n;
	
	int od = (n + 1) / 2;
	printf("%.14f\n", (double)od / n);
	return 0;
}

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

using namespace std;

typedef long long int Int;

bool color[105] = {false};

int main(void)
{
    int a,b,c;

    cin>>a>>b>>c;
    color[a] = true;
    color[b] = true;
    color[c] = true;

    int sum = 0;
    for(int i = 0;i < 105;i++)
	if(color[i])
	    sum++;

    cout<<sum<<endl;

    return 0;
}


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

using namespace std;


int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != t[i]) {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3892
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

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

typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

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

  ll sum = 0;
  rep(i, n) {
      if ((i+1) % 3 != 0 && (i+1) % 5 != 0)
      {
          sum += i+1;
      }
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 300005;
const ll MOD = 1e9 + 7;
ll a[N];
int main()
{
    // freopen("in.txt", "r", stdin);
    int n;
    while (cin >> n)
    {
        for (int i = 1; i <= n; i++) cin >> a[i];
        ll res = 0;
        for (int i = 0; i < 60; i++)
        {
            ll w = 1ll << i;
            ll cnt0 = 0, cnt1 = 0;
            for (int j = 1; j <= n; j++)
            {
                if (1ll << i & a[j]) cnt1++;
                else cnt0++;
            }
            res = (res + w % MOD * cnt0 % MOD * cnt1 % MOD) % MOD;
        }
        cout << res << endl;
    }
    return 0;
}

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

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int x, n;
    cin >> x >> n;
    int a[n];
    map<int, int> mp;
    for(int i = 0; i<n; i++) {
        cin >> a[i];
        mp[a[i]] = 1;
    }
    if(mp[x] != 1) {
        cout << x;;
        return;
    }
    for(int i = x+1, j = x-1; i<=1000; i++, j--) {
        if(mp[j] != 1) {
            cout << j ;
            return;
        }
        if(mp[i] != 1) {
            cout << i;
            return;
        }
    }
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3632
n, k, q = map(int, input().rstrip().split())
scores = {}
for i in range(q):
    a = int(input().rstrip())
    if scores.get(a):
        scores[a] += 1
    else:
        scores[a] = 1

mv = sum(scores.values())
l = [0 for i in range(n)]
for i in range(n):
    point = k - mv
    if scores.get(i + 1):
        point += scores.get(i + 1)

    r = 'Yes' if point > 0 else 'No'
    print(r)



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

typedef long long ll;

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

    int n; cin >> n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++) cin >> a[i] >> b[i];
    sort(a.begin(),a.end(),greater<int>());
    sort(b.begin(),b.end());
    cout << a[0]+b[0] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
// Problem https://atcoder.jp/contests/abc047/tasks/abc047_b

int solver(int widthlong,int heightlong,vector<int> xpoint,vector<int> ypoint,vector<int> ppoint){
    int result = 0;
    vector<vector<int>> space;
/**     for(int j=0;j<xpoint.size();j++){
        cout << "X:" << xpoint.at(j) << " y:" << ypoint.at(j)  << " p:" << ppoint.at(j);
        cout << endl;
    }**/
    space = vector<vector<int>>(widthlong,vector<int>(heightlong,0));
/**     for(int x=0;x<=widthlong;x++){
        cout << x << ": ";
        for(int y=0;y<=heightlong;y++){
            cout << space.at(x).at(y) << " " ;
        }
        cout << endl;
    }**/
    for(int k=0;k<xpoint.size();k++){
        if(ppoint.at(k)==1){
            for(int x=0;x<xpoint.at(k);x++){
                for(int y=0;y<heightlong;y++){
                    space.at(x).at(y) = 1;
                }
            }
        }
       
        if(ppoint.at(k)==2){
            for(int x=xpoint.at(k);x<widthlong;x++){
                for(int y=0;y<heightlong;y++){
                    space.at(x).at(y)=1;
                }
            }
        }
         if(ppoint.at(k)==3){
            for(int x=0;x<widthlong;x++){
                for(int y=0;y<ypoint.at(k);y++){
                    space.at(x).at(y)=1;
                }
            }
        }
        if(ppoint.at(k)==4){
            for(int x=0;x<widthlong;x++){
                for(int y=ypoint.at(k);y<heightlong;y++){
                    space.at(x).at(y)=1;
                }
            }
        }
 /**        cout << k << " point try" << endl;
        for(int x=0;x<widthlong;x++){
            cout << x << ": ";
            for(int y=0;y<heightlong;y++){
                cout << space.at(x).at(y) << " " ;
            }
            cout << endl;
        }**/
    }
      for(int x=0;x<widthlong;x++){
        for(int y=0;y<heightlong;y++){
      //      cout << space.at(x).at(y) << " " ;
            if(space.at(x).at(y)==0){
                result=result+1;
            }
        }
       // cout << endl;
    }
    return result;
}

int main(void){
    // 基本データの取り出し
    int answer=-1;
    int W,H,N;
    cin >> W >> H >> N;
    // 塗り絵データの初期化
    vector<int> xi(N,0);
    vector<int> yi(N,0);
    vector<int> ai(N,0);
    for(int j=0;j<N;j++){
        cin >> xi.at(j) >> yi.at(j) >> ai.at(j);

    }
    answer = solver(W,H,xi,yi,ai);
    cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long//懒得打那么多long long了
using namespace std;
ll n;
void out(ll x,ll y,ll z){
    printf("%lld %lld %lld\n",x,y,z);
    exit(0);//输出完后直接结束程序
}
void f(){//方法2
    ll c,m;
    for(ll i=1;i<=3500;i++)
        for(ll j=1;j<=3500;j++){
            c=n*i*j;
            m=4*i*j-n*i-n*j;
            if(m>0&&c%m==0)out(i,j,c/m);//判断是否为正整数
        }
}
int main(){
    cin>>n;
    if(n%2==0)out(n,n,n/2);//2的倍数
    if(n%3==0)out(n,n/3*2,n/3*2);//3的倍数
    if((n-3)%4==0)out((n+1)/4,(n+1)*(n+1)/4,(n+1)*(n+1)*n/4);//n-3是4的倍数
    if((n-1)%4==0)f();//n-1是4的倍数
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int k, n;
int l[100];

int main() {
	cin >> n >> k;
	rep(i, n)cin >> l[i];
	sort(l, l + n, greater<int>());
	int lo = 0;
	rep(i, k)lo += l[i];
	cout << lo << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
typedef long long ll;
#define mod 1000000007
template<class T> void add(T &a, T b) { a = (a + b) % mod;}

ll dp[101010][4];
int main() {
  string S;
  cin >> S;
  dp[0][0] = 1;
  rep(i, 0, S.size()) {
    rep(j, 0, 4) {
      if(S[i] == '?') add(dp[i+1][j], dp[i][j] * 3);
      else add(dp[i+1][j], dp[i][j]);
    }
    rep(j, 0, 3) {
      if(S[i] == 'A' + j || S[i] == '?') add(dp[i+1][j+1], dp[i][j]);
    }
  }
  cout << dp[S.size()][3] << endl;
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    int a[4];
    for(int i=0; i<4; i++){
        a[i] = s[i] - '0';
    }
    if(a[0]+a[1]+a[2]+a[3] == 7){
        cout << a[0] << "+" << a[1] << "+" << a[2] << "+" << a[3] << "=7" << endl;
    }else if(a[0]+a[1]+a[2]-a[3] == 7){
        cout << a[0] << "+" << a[1] << "+" << a[2] << "-" << a[3] << "=7" << endl;
    }else if(a[0]+a[1]-a[2]-a[3] == 7){
        cout << a[0] << "+" << a[1] << "-" << a[2] << "-" << a[3] << "=7" << endl;
    }else if(a[0]+a[1]-a[2]+a[3] == 7){
        cout << a[0] << "+" << a[1] << "-" << a[2] << "+" << a[3] << "=7" << endl;
    }else if(a[0]-a[1]-a[2]-a[3] == 7){
        cout << a[0] << "-" << a[1] << "-" << a[2] << "-" << a[3] << "=7" << endl;
    }else if(a[0]-a[1]+a[2]-a[3] == 7){
        cout << a[0] << "-" << a[1] << "+" << a[2] << "-" << a[3] << "=7" << endl;
    }else if(a[0]-a[1]+a[2]+a[3] == 7){
        cout << a[0] << "-" << a[1] << "+" << a[2] << "+" << a[3] << "=7" << endl;
    }else if(a[0]-a[1]-a[2]+a[3] == 7){
        cout << a[0] << "-" << a[1] << "-" << a[2] << "+" << a[3] << "=7" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;static char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,l,t,start=0,k[100005];
int main(void){
	register int i,x,y;
	n=read(),l=read(),t=read();
	for(i=0;i<n;++i){
		x=read(),y=read();
		if(y==1)k[i]=x+t,start+=k[i]/l,k[i]%=l;
		else k[i]=x-t,start+=k[i]/l,k[i]%=l,k[i]<0?k[i]+=l,--start:0;
	}
	start%=n,start+=n,start%=n;
	sort(k,k+n);
	for(i=start;i<n;++i)
		printf("%d ",k[i]);
	for(i=0;i<start;++i)
		printf("%d ",k[i]);
	return 0;
}

Measured memory_bytes: 1536
/* ***************************************
Author        :Scau.ion
Created Time  :2016/11/28 14:21:52 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

LL dp[10000][8];

int main()
{
    dp[0][0]=1;
    for (int j=1;j<=600;++j)
    {
        dp[j][0]=1;
        for (int k=1;k<8;++k)
            dp[j][k]=dp[j-1][k]+dp[j-1][k-1];
    }
    LL n;
    cin>>n;
    string s="";
    for (int j=600;j>=1;--j)
    {
        int cs=0;
        if (dp[j][7]>0)
        {
            cs=n/dp[j][7];
            n%=dp[j][7];
        }
        for (int k=1;k<=cs;++k)
            s="L"+s;
        s="AVITSEF"+s;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 384
a, b = map(int,input().split())
s = input()
l = [False]*a
l1 = [False]*b
l2 = ["1","2","3","4","5","6","7","8","9","0"]
s1 = s[:a]
s2 = s[a+1:]
for k,i in enumerate(s1):
  if i in l2:
    l[k] = True
for k, i in enumerate(s2):
  if i in l2:
    l1[k] = True
if all(l) and all(l1) and s[a] == "-":
  print("Yes")
else:
  print("No")

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

struct Data{

  int weight;
  int s,g;

  bool operator < (const Data& p)const {
    if(weight != p.weight)return weight > p.weight;
    if(s != p.s)return s > p.s;
    return g > p.g;
  }
  
};

int par[100],rank[100];
priority_queue<Data> data;

int find(int x){
  
  if( x == par[x]){
    return x;
  }else{
    par[x]=find(par[x]);
  }
  return par[x];
}
bool same(int x,int y){
  if(find(x) == find(y)){
    return true;
  }else{
    return false;
  }
}
void unite(int x,int y){
  
  int x_oya,y_oya;
  
  x_oya=find(x);
  y_oya=find(y);
  
  if(rank[x_oya] > rank[y_oya]){
    par[x_oya]=par[y_oya];
  }else if(rank[x_oya] < rank[y_oya]){
    par[y_oya]=par[x_oya];
  }else{
    par[y_oya]=par[x_oya];
    rank[x_oya]++;
  }
  
}
int kruskal(void){
  
  Data a;
  int cost=0;
  
  while(!data.empty()){
    a=data.top();
    data.pop();
    if(!same(a.s,a.g)){
      cost+=a.weight;
      unite(a.s,a.g);
    }
  }
  return cost;
  
}
int main(){
  
  int n,weight;
  
  for(int i=0 ; i < 100 ; i++){
    par[i]=i;
    rank[i]=0;
  }
  
  cin >>n;

  for(int i=0 ; i < n ; i++){
    for(int j=0 ; j < n ; j++){
      cin >>weight;
      if(weight == -1)continue;
      data.push((Data){weight,i,j});
    }
  }
  
  cout <<kruskal()<<endl;

  return 0;
}

Measured memory_bytes: 1344
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * ceil_(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

signed main() {
  int W, H, N;
  cin >> W >> H >> N;
  vector<int> X(N);
  vector<int> Y(N);
  rep(i, N) {
    cin >> X[i] >> Y[i];
  }
  int ans = 0;
  rep(i, N - 1) {
    if (X[i] > X[i + 1] and Y[i] > Y[i + 1]) {
      ans -= min(X[i] - X[i + 1], Y[i] - Y[i + 1]);
    } else if (X[i] < X[i + 1] and Y[i] < Y[i + 1]) {
      ans -= min(X[i + 1] - X[i], Y[i + 1] - Y[i]);
    }
    ans += abs(X[i] - X[i + 1]) + abs(Y[i] - Y[i + 1]);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;

ll dat[2<<18], add[2<<18];
int segn = 1;
void init(int n){
	while(segn < n)segn *= 2;
	//for(int i = 0;i < segn*2;i++)dat[i] = inf;
}

void lazy_update(int k, int l, int r){
	dat[k] += add[k]*(r-l);
	add[k*2+1] += add[k];
	add[k*2+2] += add[k];
	add[k] = 0;
}

void update(int a, int b, int x, int k, int l, int r){
	lazy_update(k, l, r);
	if(b <= l || r <= a)return ;
	if(a <= l && r <= b){
		add[k] += x;
		lazy_update(k, l, r);
		return ;
	}
	update(a, b, x, k*2+1, l, (l+r)/2);
	update(a, b, x, k*2+2, (l+r)/2, r);
	dat[k] = dat[k*2+1]+dat[k*2+2];
}

ll get(int a, int b, int k, int l, int r){
	lazy_update(k, l, r);
	if(b <= l || r <= a)return 0;
	if(a <= l && r <= b)return dat[k];
	ll vl = get(a, b, k*2+1, l, (l+r)/2);
	ll vr = get(a, b, k*2+2, (l+r)/2, r);
	return vl+vr;
}

int main(){
	int n, q, c, s, t, x;
	scanf("%d%d", &n, &q);
	init(n);
	for(int i = 0;i < q;i++){
		scanf("%d", &c);
		if(!c){
			scanf("%d%d%d", &s, &t, &x);
			update(s-1, t, x, 0, 0, segn);
		}else{
			scanf("%d%d", &s, &t);
			ll res = get(s-1, t, 0, 0, segn);
			printf("%lld\n", res);
		}
	}
	return 0;
}


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

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

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; }
map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

ll n,m,k,result;
bool flag = false;
string s;
int main() {
    INIT();

    cin >> n;
    for(auto&& x : prime_factor(n)) {
        int i = x.second, cnt = 1;
        while(true) {
            if(i >= cnt) {
                result++;
                i -= cnt;
                cnt++;
            } else {
                break;
            }
        }
    }
    cout << result;
}


Measured memory_bytes: 3656
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#include "bits/stdc++.h"
using namespace std;

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

	if (A > B) {
		cout << 0 << endl;
	}
	else if (N == 1) {
		if (A == B) {
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	else if (N == 2) {
		cout << 1 << endl;
	}
	else {
		cout << (N - 2) * (B - A) + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
int solve()
{
	int n,x,y;
    cin>>n>>x>>y;
    int arr[n] = { 0 };
    int mini = 0;
    rep(i,n)
    {
        rep_a(j,i+1,n)
        {
            mini = INT_MAX;
            mini = min(mini,abs(j - i));
            mini = min(abs(x - 1 - i)+ 1+abs(j - y + 1 ),mini);
            mini = min(abs(y - 1 - i) + 1 + abs(j - x + 1),mini);
            arr[mini]++;
        }
    }
    rep_a(i,1,n)
    {
        
            cout<<arr[i]<<endl;
        
    }
    return 0;
}
int main()
{
    /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else
    #endif */
    solve();
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC<<" Sec\n";
    #endif */
    return 0;
} 

Measured memory_bytes: 384
anslist=(3*5*7,
         3*5*11,
         3*5*13,
        3*5**3,5*3**3,7*3**3)

n=int(input())
cnt=0
for i in range(1,n+1,2):
  if i in anslist:
    cnt+=1
    
print(cnt)
  

Measured memory_bytes: 2940
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

double EPS = 1e-10;

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }
};

struct segment{
  point a,b;
};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

int is_intersected_ls(point a1, point a2, point b1, point b2) {
  return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
         ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

int ccw(point p0, point p1, point p2){
  point a = p1 - p0;
  point b = p2 - p0;
  if(cross(a,b)>EPS)return +1;
  if(cross(a,b)<EPS)return -1;
  if(dot(a,b)<-EPS)return +2;
  if(a.x*a.x+a.y*a.y<b.x*b.x+b.y*b.y)return -2;
  return 0;
}

vector<segment> construct_edge(point* p, int n){
  vector<segment>seg;
  
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      for(int k=0;k<n;k++)
	if(i!=j && i!=k && j!=k)
	  if(ccw(p[i],p[j],p[k])==1){
	    segment temp;
	    temp.a=p[i];
	    temp.b=p[j];
	    seg.push_back(temp);
	    //seg.push_back(make_pair(p[i],p[j]));
	  }
  return seg;
}

int point_contain(vector<segment> ps, point p, int n){
  int cnt=ccw(ps[0].a,ps[0].b,p);

  for(int i=0;i<n;i++)
    if(cnt!=ccw(ps[i].a,ps[i].b,p))return 0;
  
  return 1;
}

int main(void){
  int n;
  point p[3],k,s;
  vector<segment>seg;

  cin >> n;
  while(n--){
    for(int i=0;i<3;i++)
      cin >> p[i].x >> p[i].y;
    
    cin >> k.x >> k.y >> s.x >> s.y;

    seg=construct_edge(p,3);

    if(point_contain(seg,k,3)!=point_contain(seg,s,3))cout << "OK" << endl;
    else cout << "NG" << endl;
    
  }

  return 0;
}

Measured memory_bytes: 956
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> M(N);
    for(int i=0; i<K; i++){
        int d;
        cin >> d;
        vector<int> A(d);
        for(auto& x: A){
            cin >> x; x--;
        }
        for(auto& x: A)  M[x]++;
    }

    ll ans = 0;
    for(auto& x: M){
        if(x == 0) ans++;
    }
    cout << ans << endl;
}

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

int main(){
  int K;
  string S;
  cin >> K >> S;
  int size = S.length();
  
  if (size <= K){
    cout << S << endl;
  }
  else {
    string S_new = S.substr(0,K);
    cout << S_new << "..." << endl;
  }
}

Measured memory_bytes: 3624
A = []

for i in range(3):
    val = list(map(int, input().split()))
    A.append(val)

N = int(input())

b = [int(input()) for i in range(N)]

judge = 0

#斜めがビンゴになる場合
if A[0][0] in b and A[1][1] in b and A[2][2] in b or A[0][2] in b and A[1][1] in b and A[2][0] in b:
    judge += 1

for i in range(3):
    #横がビンゴになる場合
    if A[i][0] in b and A[i][1] in b and A[i][2] in b:
        judge += 1
        break

    #縦がビンゴになる場合
    elif A[0][i] in b and A[1][i] in b and A[2][i] in b:
        judge += 1
        break

if judge >= 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int w[1000],v[1000],W,N,dp[2][10000],dpw[2][10000];

bool solve(int num)
{
	memset(dp,0,sizeof(dp));
	memset(dpw,0,sizeof(dpw));
	scanf("%d",&W);
	if(W==0)
		return false;
	scanf("%d",&N);
	for(int i=0;i<N;i++)
		scanf("%d,%d",&v[i],&w[i]);
	for(int i=0;i<N;i++)
		for(int j=0;j<=W;j++)
		{
			if(j<w[i])
			{
				dp[(i+1)&1][j]=dp[i&1][j];
				dpw[(i+1)&1][j]=dpw[i&1][j];
			}
			else
			{
				int t1=dp[i&1][j], t2=dp[i&1][j-w[i]]+v[i], w1=dpw[i&1][j], w2=dpw[i&1][j-w[i]]+w[i];
				if(t1>t2||(t1==t2&&w1<w2))
				{
					dp[(i+1)&1][j]=t1;
					dpw[(i+1)&1][j]=w1;
				}
				else
				{
					dp[(i+1)&1][j]=t2;
					dpw[(i+1)&1][j]=w2;
				}
			}
		}
		printf("Case %d:\n%d\n%d\n",num,dp[N&1][W],dpw[N&1][W]);
		return true;
}

int main()
{
	for(int i=0;;i++)
		if(!solve(i+1))
			return 0;
}

Measured memory_bytes: 1200
A, B, C, X, Y = map(int, input().split())
cost = 0
if A + B > 2 * C:
    Z = min(X, Y)
    cost += 2 * C * Z
    X -= Z
    Y -= Z
    if X > 0 and A > 2 * C:
        cost += 2 * C * X
        X = 0
    elif Y > 0 and B > 2 * C:
        cost += 2 * C * Y
        Y = 0
cost += A * X + B * Y
print(cost)

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    vector<int64_t> primes;
    static bool isd[1000001];
    for(int i=2;i<=1000000;++i){
        if(isd[i]) continue;
        primes.push_back(i);
        for(int64_t j=2;i*j<=1000000;++j) isd[i*j] = true;
    }
    map<int, int> mp;
    int64_t n;
    cin >> n;

    for(auto p: primes){
        int cnt = 0;
        while(n % p == 0){ ++cnt; n /= p; }
        if(cnt > 0) mp[p] = cnt;
    }
    if(n > 1) mp[n] = 1;

    int64_t ans = 0;
    for(auto m: mp){
        int ok = 1, ng = 41;
        while(ng - ok > 1){
            int mid = (ok + ng) / 2;
            if(mid * (mid + 1) / 2 <= m.second) ok = mid;
            else ng = mid;
        }
        ans += ok;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5196
#include<bits/stdc++.h>
using namespace std;
struct point{
	double x,y;
	point(){}
	point(double _x,double _y){
		x=_x;y=_y;
	}
	inline point operator +(const point &b) const{
		return point(x+b.x,y+b.y);
	}
	inline point operator -(const point &b) const{
		return point(x-b.x,y-b.y);
	}
	inline double operator ^(const point &b) const{
		return (x*b.x)+(y*b.y);
	}
	inline double operator *(const point &b) const{
		return x*b.y-y*b.x;
	}
	inline point operator *(const double &b) const{
		return point(x*b,y*b);
	}
}c[50005],p0,p1;
vector<point> poly;
bool check(point p,point x,point y){
	if((p-x)*(y-x)==0&&min(x.x,y.x)<=p.x&&p.x<=max(x.x,y.x)&&min(x.y,y.y)<=p.y&&p.y<=max(x.y,y.y)) return 1;
	else return 0;
}
struct matrix{
	double xmax,xmin,ymax,ymin;
}a[2];
bool check(point p0,point p1,point p2,point p3){
	a[0].xmax=max(p0.x,p1.x);
	a[0].xmin=min(p0.x,p1.x);
	a[0].ymax=max(p0.y,p1.y);
	a[0].ymin=min(p0.y,p1.y);
	a[1].xmax=max(p2.x,p3.x);
	a[1].xmin=min(p2.x,p3.x);
	a[1].ymax=max(p2.y,p3.y);
	a[1].ymin=min(p2.y,p3.y);
	if(!(a[0].xmax<a[1].xmin || a[1].xmax<a[0].xmin || a[0].ymax<a[1].ymin || a[1].ymax<a[0].ymin)){
		if(((p1-p0)*(p2-p0))*((p1-p0)*(p3-p0))<=0 &&
		   ((p3-p2)*(p1-p2))*((p3-p2)*(p0-p2))<=0) return 1;
		else return 0;
	}
	else return 0;
}
int main(){
	srand(time(0));
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>c[i].x>>c[i].y,
		poly.push_back(c[i]);
	poly.push_back(c[1]);
	int q,res,flag;
	cin>>q;
	for(int i=1;i<=q;++i){
		cin>>p0.x>>p0.y; res=0; flag=0;
		for(int j=0;j<poly.size()-1;++j)
			if(check(p0,poly[j],poly[j+1])){
				puts("1"); flag=1;
				break;
			}
		if(flag) continue;
		p1=point(rand()*rand()+19260817,rand()*rand()+19491001)+p0;
		for(int j=0;j<poly.size()-1;++j)
			res+=check(p0,p1,poly[j],poly[j+1]);
		if(res%2) puts("2");
		else puts("0");
	}
	return 0;
}



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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s.at(i);

    vector<int> dx = {-1, 0, 0, 1}, dy = {0, -1, 1, 0};
    rep(i, h) {
        rep(j, w) {
            if(s.at(i).at(j) == '.') continue;
            int ok = false;
            rep(k, 4) {
                int xi = j + dx.at(k);
                int yi = i + dy.at(k);
                if(0 <= xi && xi < w && 0 <= yi && yi < h && s.at(yi).at(xi) == '#') {
                    ok = true;
                    break;
                }
            }
            if(!ok) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long h = in.nextLong();
            long w = in.nextLong();
            long area = h * w;
            if (h == 1 || w == 1) {
                out.println(1);
            } else {
                out.println(area % 2 == 1 ? area / 2 + 1 : area / 2);
            }
        }
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

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

    }

}


Measured memory_bytes: 22740
N = int(input())
h = [0] + list(map(int, input().split()))

INF = float("inf")
dp = [INF for _ in range(N + 1)]
dp[1] = 0

for i in range(2, N + 1):
    if i == 2:
        dp[i] = abs(h[i] - h[i - 1])
    else:
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[N])


Measured memory_bytes: 13980
#include<bits/stdc++.h>
 
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll unsigned long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cerr << (#x) << " is " << (x) << endl
#define INF 1e13
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
bool check(ll i,ll j,ll n){return (i>=0 && i<n && j>=0 &&  j<n);} //matrix boundary checking
 
 
ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
 
// max({a, b, c, d})
// cout << fixed for removing e notation
 
bool comp(pair<ll, ll>a, pair<ll, ll>b)
{
    if(a.se*b.fi + b.se > b.se*a.fi + a.se) return true;
    else return false;
}
 
void convert(int arr[], int n) 
{ 
    int temp[n+1];
    for(int i=1;i<=n;i++)
        temp[i] = arr[i]; 
    // memcpy(temp, arr, n*sizeof(int)); 
  
    sort(temp+1, temp+n+1);   
    unordered_map<int, int> umap;
    int val = 1; 
    for (int i = 1; i <= n; i++) 
        umap[temp[i]] = val++;
    for (int i = 1; i <= n; i++) 
        arr[i] = umap[arr[i]]; 
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
}

int foo(int a, int b, int c)
{
    return (abs(a-b) + abs(b-c) + abs(a-c));
}


ll getFirstSetBitPos(ll n) 
{ 
    return log2(n & -n) + 1; 
} 

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

    if(2*b >= a) cout << 0 << "\n";
    else cout << a - 2*b << "\n";
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

s = input().rstrip()
N = len(s)
if s[0] == '0' or s[-1] == '1' or s[:-1] != s[:-1][::-1]:
    print(-1)
    exit()
subtree = [[] for _ in range(N+1)]
prev = 1
for i in range(2, N+1):
    if s[i-1] == '1' or i == N:
        subtree[i] = [prev] + [1] * (i-prev-1)
        prev = i

i = 1
def dfs(size):
    global i
    v = i
    for c in subtree[size]:
        i += 1
        print(v, i)
        dfs(c)

dfs(N)

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

#define what_is(x) cout << #x << " is " << x << endl;
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
// #define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define bug(n) {outl(n);return;}
#define pii pair<int,int>
#define lim 9223372036854775805
#define ninf -9223372036854775802
#define M 1000000007
#define eps 1e-9
#define MAX 10
#define N 500001
#define db(a) for(auto it:a) {cout<<it<<" ";}cout<<endl;
ll prime[MAX];
ll fact[MAX];

const long long INF64 = 1e18;
ll vpow(ll a,ll b,ll p){
    if(b==0)
        return 1;
    if(b==1)
            return a;
    ll temp=vpow(a,b/2,p);
    temp*=temp;
    temp%=p;
    if(b%2==0)
        return temp;
    temp=temp*a;
    temp%=p;
    return temp;
}

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


ll inverseMod(ll a,ll b,ll p){
    if(b==0)
        return 1;
    ll temp=vpow(b,p-2,p);
    ll ans=temp*a;
    ans%=p;
    return ans;
}
void sieve()
{
    prime[0] = prime[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}
ll max(ll a, ll b)
{
    return a>b?a:b;
}

void factorial(){
    fact[0]=1;
    fact[1]=1;
    rep(i,2,MAX){
        fact[i]=(fact[i-1]*i);
        // fact[i]%=M;
    }
}
ll rand(ll a,ll b){
    return a+rand()%(b-a+1);
}

void solve(ll ttt){
    double d,t,s;
    cin>>d>>t>>s;
    if(d<=s*t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return;

}

int main(){
    io;
    // sieve();
    // factorial();
#ifndef ONLINE_JUDGE
    //
    //freopen("input1.txt","r",stdin);
    // freopen("output1.txt","w",stdout);
#endif
    ll t=1;
     //cin>>t;
    fix(12);
    rep(q,1,t+1){
         //cout<<"Case #"<<q<<": ";
         solve(q);
    }
    return 0;

}




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

typedef long long ll;

const int MAX_N = 5e5;

int bit[MAX_N + 1], n;

int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int x) {
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
        //cout << i << " ";
    }
    //cout << endl;
}

int main() {
    int Q;
    cin >> n >> Q;
    vector<int> c(n), b(n, -1), l(Q), r(Q);
    vector<vector<int>> ls(n);
    map<pair<int, int>, int> ans;
    rep(i, n) {
        cin >> c[i];
        c[i]--;
    }
    rep(i, Q) {
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
        ls[r[i]].push_back(l[i]);
    }
    rep(i, n) {
        add(i + 1, 1);
        if (b[c[i]] > -1) add(b[c[i]] + 1, -1);
        b[c[i]] = i;
        rep(j, ls[i].size()) {
            ans[make_pair(ls[i][j], i)] = sum(i + 1) - sum(ls[i][j]);
        }
    }
    rep(i, Q) {
        cout << ans[make_pair(l[i], r[i])] << "\n";
    }
}

Measured memory_bytes: 65464
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,K; cin>>N>>K;
    vector<ll> A(N,0);
    vector<ll> F(N,0);
    rep(i,N) cin>>A[i];
    rep(i,N) cin>>F[i];
    sort(all(A));
    sort(all(F),greater<ll>());
    
    ll l=0,r=pw10[12]+1;
    while(r-l>=1){
        ll h=(l+r)/2;
        // 必要な回数の計算
        ll count=0;
        rep(i,N){
            count += max(A[i]-(h/F[i]),0ll);
        }
        
        if(count > K) l=h+1;
                // h以下に解がないような条件=A[h]は条件の否定を満たしている
        else r=h;
    }

    cout<<l<<endl;
}



Measured memory_bytes: 6308
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<int, int>pint;

int main() {
	string s;
	cin >> s;

	int num1 = 10 * (s[0] - '0') + s[1]-'0';
	int num2 = 10 * (s[2] - '0') + s[3]-'0';
	int f1, f2;
	if (1 <= num1 && num1 <= 12)f1 = 1;
	else f1 = 0;
	if (1 <= num2 && num2 <= 12)f2 = 1;
	else f2 = 0;

	if (f1 && f2)cout << "AMBIGUOUS" << endl;
	else if (f1 && !f2)cout << "MMYY" << endl;
	else if (!f1 && f2) cout << "YYMM" << endl;
	else cout << "NA" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100000

struct Info{
	Info(){
		node_id = pre_node = sum_value = 0;
	}

	Info(int arg_node_id,int arg_pre_node,int arg_sum_value){
		node_id = arg_node_id;
		pre_node = arg_pre_node;
		sum_value = arg_sum_value;
	}
	bool operator<(const struct Info &arg) const{
		return sum_value < arg.sum_value;
	}

	int node_id,pre_node,sum_value;
};

int N,M;
int root;
int value[NUM],in_num[NUM],max_value[NUM];
bool is_cicle[NUM];
vector<int> G[NUM];



int main(){

	scanf("%d %d",&N,&M);

	for(int i = 0; i < N; i++)scanf("%d",&value[i]);

	for(int i = 0; i < N; i++)in_num[i] = 0;

	root = 0;
	int from,to;

	for(int loop = 0; loop < M; loop++){
		scanf("%d %d",&from,&to);
		from--;
		to--;
		G[from].push_back(to);
		G[to].push_back(from);
		in_num[from]++;
		in_num[to]++;
	}

	for(int i = 0; i < N; i++)is_cicle[i] = true;

	queue<int> CALC;
	for(int i = 1; i < N; i++){
		if(in_num[i] == 1){
			is_cicle[i] = false;
			CALC.push(i);
		}
	}

	int node_id;
	int next_node,next_value;

	while(!CALC.empty()){
		node_id = CALC.front();
		CALC.pop();

		for(int i = 0; i < G[node_id].size(); i++){
			next_node = G[node_id][i];
			if(is_cicle[next_node] == false || next_node == root)continue;

			in_num[next_node]--;
			if(in_num[next_node] == 1){
				is_cicle[next_node] = false;
				CALC.push(next_node);
			}
		}
	}

	int ans = value[root];
	for(int i = 1; i < N; i++){
		if(is_cicle[i]){
			ans += value[i];
		}
	}

	int maximum = 0;
	for(int i = 0; i < N; i++)max_value[i] = 0;

	priority_queue<Info> Q;
	for(int i = 0; i < N; i++){
		if(!is_cicle[i])continue;

		for(int k = 0; k < G[i].size(); k++){
			next_node = G[i][k];
			if(is_cicle[next_node])continue;

			next_value = value[next_node];
			if(max_value[next_node] < next_value){
				max_value[next_node] = next_value;
				Q.push(Info(next_node,i,next_value));
			}
		}
	}

	Info info;
	while(!Q.empty()){

		info = Q.top();
		Q.pop();

		maximum = max(maximum,info.sum_value);

		if(info.sum_value < max_value[info.node_id]){
			continue;
		}else{
			for(int i = 0; i < G[info.node_id].size(); i++){
				next_node = G[info.node_id][i];
				if(next_node == info.pre_node || is_cicle[next_node] == true)continue;
				next_value = info.sum_value+value[next_node];

				if(max_value[next_node] < next_value){
					max_value[next_node] = next_value;
					Q.push(Info(next_node,info.node_id,next_value));
				}
			}
		}
	}

	printf("%d\n",ans+maximum);

	return 0;
}



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

int main() {
  int A,B;
    cin >> A >> B;
    
    if(A<6) {
      cout << "0" << endl;
    }
    else if(A >=6 && A <= 12) {
      cout << B/2 << endl;
    }
    else {
      cout << B << endl;
    }
}

  

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static int gcd(int num1,int num2) {
        if(num2==0) return num1;
        else return gcd(num2,num1%num2);
    }

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println(A*B);
    }
}


Measured memory_bytes: 35828
#include<bits/stdc++.h>
using namespace std;
int main(){
	bool t = true;
	int mayor = 0 ,  menor = 123;
	int a, b , c , d , e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if((e - a) <= k) cout << "Yay!";
	else cout << ":(";
	return 0;
}

Measured memory_bytes: 256
from collections import deque

N = int(input())

u = [None] * (N - 1)
v = [None] * (N - 1)
w = [None] * (N - 1)
for i in range(N - 1):
    uvw = input().split()
    u[i], v[i], w[i] = int(uvw[0]) - 1, int(uvw[1]) - 1, int(uvw[2])

# adjacency List + distance
# AL[i] = [(j, distance between i and j): j is a neighbor of i]
AL = [[] for _ in range(N)]

for i in range(N - 1):
    AL[u[i]].append((v[i], w[i] % 2))
    AL[v[i]].append((u[i], w[i] % 2))

color = [0] + [-1] * (N - 1) # vertex iの頂点の色 0/1
visited = [False] * N      # vertex iに訪問済みならTrue、まだならFalse
que = deque()   # 探索候補キュー
que.append(0) # vertex 0をキューに追加

while(len(que) > 0):
    current = que.popleft()
    visited[current] = True
    for next, dist in AL[current]:
        if not visited[next]:
            que.append(next)
            color[next] = (color[current] + dist) % 2

for i in range(N):
    print(color[i])

Measured memory_bytes: 79348
import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f
from copy import *
from bisect import *	
from heapq import *
from math import *
from itertools import permutations 
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
def li():
	return [int(x) for x in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def gi():	
	return [x for x in input().split()]
def fi():
	return int(input())
def swap(a,i,j):
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())	
def gh():
	sys.stdout.flush()
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)
def bo(i):
	return ord(i)-ord('a')
		


tt=1


while tt>0:
	tt-=1
	n=fi()
	d={'AC':0,'WA':0,'TLE':0,'RE':0}
	for i in range(n):
		s=input().rstrip()
		d[s]+=1
	for i in d:
		print(i,"x",d[i])	
					





Measured memory_bytes: 78732