akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

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

class bipartite_graph{
	vector<vector<int> > Graph;
	vector<int> used, match;
	int V;
public:
	bipartite_graph(int size) :V(size){
		Graph.resize(V);
		used.resize(V, 0);
		match.resize(V, -1);
	}
	void add_edge(int from, int to){
		Graph[from].push_back(to);
		Graph[to].push_back(from);
	}
	int dfs(int v){
		used[v] = 1;
		for (int i = 0; i < Graph[v].size(); i++){
			int x = Graph[v][i], w = match[x];
			if (w < 0 || !used[w] && dfs(w)){
				match[x] = v;
				match[v] = x;
				return 1;
			}
		}
		return 0;
	}
	int matching(){
		fill(match.begin(), match.end(), -1);
		int res = 0;
		for (int v = 0; v < V; v++){
			if (match[v] >= 0) continue;
			fill(used.begin(), used.end(), 0);
			if (dfs(v)) res++;
		}
		return res;
	}
};

const int N = 110;
int dist[N][N];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(20);

	int n, m, l;
	while (cin >> n >> m >> l, n){
		rep(i, n) rep(j, n) dist[i][j] = i == j ? 0 : 1e9;
		rep(i, m){
			int a, b, c;
			cin >> a >> b >> c;
			dist[a][b] = dist[b][a] = c;
		}
		rep(i, n) rep(j, n) rep(k, n) dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);

		vector<pair<int, int>> v(l);
		rep(i, l){
			int pos, t;
			cin >> pos >> t;
			v[i] = MP(t, pos);
		}
		sort(ALL(v));
	
		bipartite_graph G(l*2);
		rep(i, l) FOR(j, i + 1, l){
			int a = v[i].second, b = v[j].second;
			if (v[i].first + dist[a][b] <= v[j].first) G.add_edge(i, j + l);
		}

		cout << l - G.matching() << '\n';
	}
}

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

int main(){
    typedef pair<int, int> P;
    int n;
    cin >> n;
    vector<vector<P>> node(n);
    int a, b, c;
    for (int i = 1; i < n; i++) {
        cin >> a >> b >> c;
        a--;
        b--;
        node[a].push_back({b, c});
        node[b].push_back({a, c});
    }
    int q, k;
    cin >> q >> k;
    k--;
    queue<int> que;
    vector<long long> distance(n);
    vector<bool> check(n, true);
    que.push(k);
    distance[k] = 0;
    check[k] = false;
    while (que.size() > 0){
        int x = que.front(); que.pop();
        int y = node[x].size();
        for (int i = 0; i < y; i++){
            if (check[node[x][i].first]){
                check[node[x][i].first] = false;
                distance[node[x][i].first] = distance[x] + node[x][i].second;
                que.push(node[x][i].first);
            }
        }
    }
    int s, t;
    for (int i = 0; i < q; i++){
        cin >> s >> t;
        s--;
        t--;
        cout << distance[s] + distance[t] << endl;
    }
}

Measured memory_bytes: 8820
#include <stdio.h>

int main(void){
  int H,W,i,j;
  scanf("%d %d", &H,&W);

  while( H != 0 || W != 0){
    for( j=1; j<=H; j++){
      for( i= 1; i<=W; i++){
        printf("#");
      }
      printf("\n");
     }
     scanf("%d %d", &H,&W);
     printf("\n");
    }
return 0;
}

Measured memory_bytes: 572
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


int n;
lli d;
int qs[500005];

lli dat[500005];
lli np[500005];
lli rp[500005];

int anss[500005];
void init(){
	lli r=d;
	rep(i,n){
		rp[i]=r;
		r = min(r,abs(r-dat[i]));
	}
	rp[n]=r;
}

void solve(){
	lli x=0;
	np[n]=x;
	irep(i,n){
		lli k=dat[i];
		if(k%2==0){
			if(x>=k/2)x=x+k;
		}
		else{
			if(x>=(k-1)/2)x=x+k;
		}
		np[i]=x;
		//printf("%d %lld\n",i,x);
	}
	
	reg(i,1,n){
		if(np[i]>=rp[i-1])anss[i]=0;
		else anss[i]=1;
	}
	
	if(rp[n]!=0)anss[n]=1;
}

int main(void){
	scanf("%d%lld",&n,&d);
	rep(i,n)scanf("%lld",&dat[i]);
	
	init();
	solve();
	int qn;
	scanf("%d",&qn);
	rep(i,qn){
		int q;
		scanf("%d",&q);
		puts(anss[q]?"YES":"NO");
	}
	return 0;
}






Measured memory_bytes: 16256
s = input()
if(len(s) < 5):
    print(0)
else:
    t = [0]*2019
    t[0] = 1
    p = 0
    temp = 0
    temp2 = 1
    for i in range(1,len(s)+1):
        temp2 *= 10
        temp2 %= 2019
        t[(temp + temp2*int(s[-i]))%2019] += 1
        temp += temp2*int(s[-i])
    for i in range(2019):
        p += (t[i]*(t[i]-1))//2
    print(p)

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

namespace contest_Csharp
{
    class Program
    {
        static long power(long a, long b, long modulo)
        {
            long result = 1;
            long buff = a;
            for (long i = 1; i <= b; i *= 2)
            {
                result = result * ((b / i % (2) == 1) ? buff : 1) % modulo;
                buff = (buff * buff) % modulo;
            }
            return result % modulo;
        }
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ')
               .Select(x => int.Parse(x)).ToList();
            var N = vals[0];
            var K = vals[1];
            var sunuke = new int[N];
            for (int i = 0; i < K; i++)
            {
                Console.ReadLine();
                var arr = Console.ReadLine().Split(' ')
                            .Select(x => int.Parse(x));
                foreach (var A in arr)
                {
                    sunuke[A - 1] = 1;
                }
                
            }
            Console.WriteLine(sunuke.Where(x => x == 0).Count());



        }


    }
}


Measured memory_bytes: 28460
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int c = 0;
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    int p = 0;
    while(p < N){
        int x = A[p];
        int f = 0; 
        while(p < N && A[p] == x){
            f++;
            p++;
        }
        if(f%2 == 1) c++;
    }
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 3788
N, Q = gets.split.map &:to_i
S = gets.chomp

b = Array.new(N+1, 0) # 累積和テーブル
N.times do |i|
  if i + 1 < N && S[i] == 'A' && S[i+1] == 'C'
    b[i+1] = b[i] + 1
  else
    b[i+1] = b[i]
  end
end

Q.times do
  l, r = gets.split.map { |i| i.to_i - 1 }
  puts b[r] - b[l]
end

Measured memory_bytes: 15296
#include <stdio.h>
#include <stdlib.h>
#define int long long

int *pro(int N, int *p, int *q){
	int i;
	int *ans = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		ans[i] = p[q[i]];
	}
	return ans;
}

int *power(int N, int *p, int K){
	if(K == 1){
		return p;
	}
	else if(K % 2 == 0){
		return power(N, pro(N, p, p), K / 2);
	}
	else{
		return pro(N, p, power(N, p, K - 1));
	}
}

signed main(){
	int N, M, K, a, tmp, i;
	scanf("%lld", &N);
	int *x = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &x[i]);
	}
	int *p = (int *)malloc(sizeof(int) * (N - 1));
	for(i = 0; i < N - 1; i++){
		p[i] = i;
	}
	scanf("%lld%lld", &M, &K);
	for(i = 0; i < M; i++){
		scanf("%lld", &a);
		tmp = p[a - 2];
		p[a - 2] = p[a - 1];
		p[a - 1] = tmp;
	}
	p = power(N - 1, p, K);
	int *ans = (int *)malloc(sizeof(int) * N);
	ans[0] = x[0];
	for(i = 1; i < N; i++){
		ans[i] = ans[i - 1] + x[p[i - 1] + 1] - x[p[i - 1]];
	}
	for(i = 0; i < N; i++){
		printf("%lld\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 67840
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

int main () {
  int n = in();
  vi d(n);
  rep(i,n) cin >> d[i];
  
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      ans += d[i]*d[j];
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;

vector<int> v;

pair<ull, ull> total(int s) {
    if(s == v.size()) return {1, 0};

    pair<ull, ull> t = {0, 0};
    ull n = 0;

    for(int i = s + 1; i <= v.size(); i++) {
        n *= 10;
        n += v[i - 1];

        pair<ull, ull> m = total(i);

        t.first += m.first;
        t.second += m.second + m.first * n;
    }

    return t;
}

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

    for_each(s.begin(), s.end(), [&](char& c){
        v.push_back(c - '0');
    });

    cout << total(0).second << endl;
}

Measured memory_bytes: 256
from copy import deepcopy as copy
n = int(input())
T = [1]
A = [1]
for i in range(n):
    t, a = map(int, input().split())
    tc = copy(t)
    ac = copy(a)
    if T[-1] > t or A[-1] > a:
        multi = max(T[-1] // t, A[-1] // a) + 1
        t *= multi
        a *= multi
        while t - tc >= T[-1] and a - ac >= A[-1]:
            t -= tc
            a -= ac
    T.append(t)
    A.append(a)
print(T[-1] + A[-1])

Measured memory_bytes: 3572
#include <atcoder/math>
#include <iostream>

using namespace std;
using namespace atcoder;

int main() {
    int t;
    cin >> t;
    while(t--) {
        long long n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;
int main() {
	
	int A=0;
	int B=0;


	cin >> A >> B;
	double ans= (double)(A + B) / 2;

	if (ans - (int)ans>=0.5){
		ans = ans + 1;
	}

	cout << (int)ans<< endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#define dvout if(false) cout
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
void Main()
{
	string S;
	cin>>S;
	bool prev=false;
	vector <int> ans(S.size(), 0);
	int cnt = 0;
	S.push_back('R');
	dout<<S.size()<<endl;
	for(int i = 1; i < S.size(); i++){
		if(prev == (S[i]=='L')){
			cnt++;
		}
		else{
			cnt++;
			dout<<cnt<<"\t";
			if(prev){
				ans[i-cnt] += (cnt+1)/2;
				ans[i-cnt-1] += (cnt)/2;
			}
			else{
				ans[i] += (cnt)/2;
				ans[i-1] += (cnt+1)/2;
			}
			prev = (S[i]=='L');
			cnt = 0;

		}
	}
	dout<<endl<<endl;
	vout(ans);

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

Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    int cur = 0;
    rep(i, 3) {
        if (S[i] == 'R') {
            cur++;
        } else {
            cur = 0;
        }
        ans = max(ans, cur);
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;
#define int long long
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.first<<','<< P.second<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<"]\n";}
#define show(x) cout<<#x<<" : "<<x<<'\n';


signed main(){
	fio;
	int t=1;
	// cin>>t;
	while(t--){
		int n, m;
		cin>>n>>m;
		vector<int> h(n+1, 0);
		for(int i=1; i<=n; i++){
			cin>>h[i];
		}
		vector<vector<int>> e;
		e.resize(n+1);
		for(int i=0; i<m; i++){
			int a, b;
			cin>>a>>b;
			e[a].pb(h[b]);
			e[b].pb(h[a]);
		}
		// show(e);
		int ans=0;
		for(int i=1; i<=n; i++){
			int flag=0;
			for(auto x : e[i]){
				if(h[i]<=x){
					flag=1;
				}
			}
			if(!flag){
				// show(i);
				ans++;
			}
		}
		cout<<ans<<'\n';

	}
}

Measured memory_bytes: 9800
#include <bits/stdc++.h>
using namespace std; 
typedef unsigned long long int ll;
#define pb push_back 
//#define pop pop_back
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define mem1(a) memset(a,-1,sizeof(a))
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define sz size() 
#define len length() 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI 3.14159265358979323846
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll n;cin>>n;ll ans=0;rep(i,1,n+1) if(i%3>0&&i%5>0) ans+=i;cout<<ans;
}


Measured memory_bytes: 3652
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int W,H,x,y,r;
		
		Scanner scan = new Scanner(System.in);

		W= Integer.parseInt(scan.next());
	    H= Integer.parseInt(scan.next());
	    x= Integer.parseInt(scan.next());
	    y= Integer.parseInt(scan.next());
	    r= Integer.parseInt(scan.next());
	    if(0<=x-r&&0<=y-r&&W>=x+r&&H>=y+r) {
	    System.out.println("Yes");
	    }else {
	    	System.out.println("No");
	    }
	    
	}

}

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

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

   string s;
   cin >> s;
   auto ha = s.find("AC");
   puts(std::string::npos != ha? "Yes" : "No");
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    if(str == "Cloudy")
    	cout << "Rainy" << endl;
    else if(str == "Sunny")
    	cout << "Cloudy" << endl;
    else
    	cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define EPS (1.0e-8)

using namespace std;

int main()
{
	double x1, y1, x2, y2, x3, y3, xp, yp;
	double a[2], b[2], A, B;
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
		a[0] = x2 - x1;
		a[1] = y2 - y1;
		b[0] = x3 - x1;
		b[1] = y3 - y1;
		if(fabs(a[0] * b[0] + a[1] * b[1]) != 1) {
			A = (b[1] * (xp - x1) - b[0] * (yp - y1)) / (a[0] * b[1] - b[0] * a[1]);
			B = (a[1] * (xp - x1) - (yp - y1) * a[0]) / (a[1] * b[0] - b[1] * a[0]);
			cout << (((A+B < 1) && (A > 0) && (B > 0)) ? "YES" : "NO") << endl;
		}
	}
}

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

int main()
{
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int res = 0;
	for (int r = 0; r <= N; r += R) {
		for (int g = 0; g <= N; g += G) {
			int b = N - r - g;
			res += (0 <= b && b % B == 0);
		}
	}
	cout << res << endl;
	return 0;
}


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

public class Main {
    public static void main(String []args){
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        ArrayList<Integer>al=new ArrayList<>();
        long ans=0;
        int count[]=new int[(int)1e5+1];
        for (int i = 0; i <n; i++) {
            int a =in.nextInt();
            if(a>n){
                ans++;
            }else{
                al.add(a);
                count[a]++;
            }
        }
        for (int i = 0; i <al.size(); i++){
            if(count[al.get(i)]!=al.get(i)){
                count[al.get(i)]--;
                ans++;
            }
        }
        System.out.println(ans);

    }
}






Measured memory_bytes: 62624
#include<stdio.h>

int main(){
  int A,B,C,k;
  scanf("%d %d %d %d",&A,&B,&C,&k);
  
  int add;
  if(k<=A){
    printf("%d",k);
  }
  else if (k>=A && k<=(A+B)){
    printf("%d",A);
  }
  
  else printf("%d",A-(k-A-B));
  
  return 0;
  }


Measured memory_bytes: 1672
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int N, W;
    cin >> N >> W;

    vll w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    const int MAX_V = 100000;

    //dp[i][j] := 品物i - 1まで選んで価値がj以上のときの重さの最小値
    vvll dp(N + 1, vll(MAX_V + 1, INF));

    dp[0][0] = 0;

    rep(i, N)
    {
        reple(j, 0, MAX_V)
        {
            if (j - v[i] >= 0)
            {
                chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
            }
            
            chmin(dp[i + 1][j], dp[i][j]);
        }
    }

    ll ans = 0;

    reple(j, 0, MAX_V)
    {
        if (dp[N][j] <= W)
        {
            ans = j;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 80256
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val T = sc.nextDouble()
    val X = sc.nextDouble()

    (T / X).toString
  }
}


Measured memory_bytes: 27848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

void solve(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int a=n/2;
  if(n%2!=0)cout<<"No";
  else if(s.substr(0,a)==s.substr(a,a))cout<<"Yes";
  else cout<<"No";
}

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

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

int main() {
	int N;
	cin >> N;
	vector<tuple<string, int , int>> restaurant(N);
	for (int i = 0; i < N; i++) {
		string s;
		int p;
		cin >> s >> p;
		restaurant.at(i) = make_tuple(s, -p, i + 1);
	}

	sort(restaurant.begin(), restaurant.end());
	for (int i = 0; i < N; i++) {
		int tmp = get<2>(restaurant.at(i));
		cout << tmp << endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, L: int):
    taste_max = L + N - 1
    taste_min = L
    if taste_min <= 0 and 0 <= taste_max:
        return (taste_min + taste_max) * N // 2
    elif taste_max < 0:
        return (taste_min + taste_max - 1) * (N - 1) // 2
    else:
        return (taste_min + 1 + taste_max) * (N - 1) // 2


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    print(solve(N, L))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
	int n, k;
	cin >> n >> k;
	double s = 0;
	REP(i, n) {
		double p = 1.0;
		int x = i+1;
		while (x < k) {
			p *= 0.5;
			x *= 2;
		}
		s += p;
	}
	printf("%.12f\n", s / n);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,a[100],i,j,cnt,box;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	cnt=1;	box=0;
	for(i=0;i<=n;i++){
		if(a[i]==1)	cnt++;
		else{
			if(box<=cnt){
				box=cnt;
				cnt=1;
			}
			else	cnt=1;
		}
	}
	printf("%d\n",box);
	return 0;
}



Measured memory_bytes: 2128
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n, a, b = sc.nextLong()
  if ((b - a) % 2 == 0) {
    println((b - a) / 2)
  } else {
    val ans = (a - 1).min(n - b) + 1 + ((b - a - 1) / 2)
    println(ans)
  }
}

Measured memory_bytes: 55424
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define ct count
#define ep empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1.0);
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2,mod); }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }


void replace(string &a,string b){
    int t;
    while((t=a.find(b))!=-1){
        a=a.replace(t,(int)b.size(),"*");
    }
}
signed main() {
    //ifstream cin("E:\\acm dream\\in.in");
	//ofstream cout("E:\\acm dream\\out.out");
	FIO;
    #ifdef err
	double be = clock();
    #endif
    
    string s;cin>>s;
    replace(s,"eraser");
    replace(s,"erase");
    replace(s,"dreamer");
    replace(s,"dream");
    int f=1;
    _sfor(i,s){
        if(i!='*'){
            f=0;
            break;
        }
    }
    puts(f?"YES":"NO");
    
    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string S;
  
  char A, B, C, D;
  
  bool ABflag = false, ACflag = false, ADflag = false, BCflag = false, BDflag = false, CDflag = false, YESflag = false;
  
  cin >> S;
  
  A = S.at(0);
  
  B = S.at(1);
  
  C = S.at(2);
  
  D = S.at(3);
  
  //cout << A << endl;
  
  if( A == B ) {
  
  	ABflag = true;
    
  }
  
  if( A == C ) {
    
    ACflag = true;
    
  } 
  
  if( A == D ) {
    
    ADflag = true;
    
  }
  
  if( B == C ) {
    
    BCflag = true;
    
  }
  
  if( B == D ) {
    
    BDflag = true;
    
  }
  
  if( C == D ) {

    CDflag = true;
    
  }
  
  if(ABflag == true && CDflag == true && ACflag == false && BDflag == false) {
    
    YESflag = true;
    
  }
  
  if(ACflag == true && BDflag == true && ABflag == false && CDflag == false) {
    
    YESflag = true;
    
  }
  
  if(ADflag == true && BCflag == true && ABflag == false && CDflag == false) {
    
    YESflag = true;
    
  }
  
  if(YESflag == true) {
    
    cout << "Yes" << endl;
    
  } else {
    
    cout << "No" << endl;
    
  }
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll MOD=1e9+7;
const ll maxs=1e7+5;
ll INF = 1e18;
const ll lg=22; 

ll fast(ll base , ll expo){
    ll res = 1;
    while(expo>=1){
        if(expo%2) res *= base;
        base *= base;
        expo /= 2;
    }
    return base;
}

void code_idhr_h(){
    ll N; cin>>N;
    ll div_cnt[N+1]; mem(div_cnt , 0);
    for(ll i=1; i<=N; i++)
        for(ll j=1; i*j<=N; j++)
            div_cnt[i*j]++;
    ll ans = 0;
    for(ll i=1; i<=N; i++)
        ans += i * div_cnt[i];
    cout<<ans;
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        mx = INT_MIN;
        code_idhr_h();
    }
    return 0;
}

Measured memory_bytes: 81764
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}



int main(){
	FIO
	
	int n;
	cin >> n;
	int k;
	cin >> k;
	int b[n];
	for(int i = 0; i < k; i++)cin >> b[i];
	sort(b, b + k);
	for(int i = 0; i < (1 << k); i++){
		vector<int> now;
		int rep = 0;
		for(int j = 0; j < k; j++){
			if(i & (1 << j))now.push_back(b[j]), rep += pow(2, b[j]);
		}
		cout << rep << ':';
		for(auto j:now)cout << ' ' << j;
		cout << '\n';
	}
	return 0;
}



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

ll mod = 1e9+7;

int main(){
    ll N;
    ll K;
    cin >> N >> K;
    ll M = 32000;
    vector<ll> dp1(M+3, 0), dp2(M+3, 0);
    
    for (int i = 1; i < M; i++) {
        dp1[i] = i;
    }
    for (int i = 1; i < M; i++) {
        dp2[i] = (N/i)%mod;
    }
    
    
    for (ll i = 1; i < K; i++) {
        vector<ll> dp3(M+1, 0), dp4(M+1, 0);
        
        for (ll j = 1; j < M; j++) {
            dp3[j] = (dp3[j-1] + dp2[j])%mod;
        }
        
        dp4[M] = dp3[N/M];
        
        for (ll j = M-1; j >= 1; j--) {
            dp4[j] = (dp4[j+1] + dp1[j] * (N/j - (N/(j+1))) )%mod;
        }
        
        dp1 = dp3;
        dp2 = dp4;
        
    }
    
    cout << dp2[1] << endl;
    return 0;
}


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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll div = 2;
    ll ans = 0;
    while (div < (ll)1e18 / 5ll) {
        div *= 5;
        ans += N / div;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  string S; cin >> S;
  int N = S.size();
  int K{N};
  for (int i = 0; i < N-1; ++i) {
    if (S[i] != S[i+1]) {
      auto k = i+1;
      auto r = std::max(k, N-k);
      chmin(K, r);
    }
  }
  cout << K << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 512
import math
n = int(input())
count = 0
for i in range(n):
    a = int(input())
    if (a == 2):
        count += 1
    else:
        for j in range(2, math.ceil(math.sqrt(a)) + 1):
            if (a % j == 0):
                break
        else:
            count += 1

print(count)



Measured memory_bytes: 5676
#include<math.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	printf("%d %d\n",a*b,a+b+a+b);
	return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

//struct Point {
//	int x,y;
//};
//long long ccw(const Point& A, const Point& B, const Point& C) { // 시계방향이면 음수 
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
ll a[101];
ll b[101];
int main() { // 골드 1, 플레 1
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// 0 0 10 10 10 23
	int n;
	cin >> n;
	rep(i, n-1) {
		cin >> b[i];
	}
	a[0] = b[0];
	for (int i = 1; i < n - 1; i++) {
		a[i] = min(b[i - 1], b[i]);
	}
	ll ans = 0;
	for (int i = 0; i < n - 1; i++)ans += a[i];
	cout << ans + b[n - 2] << '\n';


}


Measured memory_bytes: 256
n = int(input())
hold = 0
res = 0
for i in range(n):
    a = int(input())
    if i==0:
        res += a//2
        hold = a%2
    else:
        if a < hold:
            res += a
            hold = 0
        else:
            res += hold
            a -= hold
            res += a//2
            hold = a%2
print(res)

Measured memory_bytes: 45208
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef pair<ll,string> Ps;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Ps,vector<Ps>,greater<Ps>> Ps_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod


ll N=0;
vec JUN;
vec FREQ(62);
Ps_queue Q;

ll Ask(string S){
    cout<<"? "<<S<<endl;
    ll x; cin>>x;
    return x;
}

ll Query(string S){
    return N-Ask(S);
}
void init(){
    rep(i,26) JUN.pb('a'+i);
    rep(i,26) JUN.pb('A'+i);
    rep(i,10) JUN.pb('0'+i);
    rep(i,62){
        string S;
        rep(j,128) S.pb(JUN[i]);
        FREQ[i]=128-Ask(S);
    }
    rep(i,62) N+=FREQ[i];
    rep(i,62) if(FREQ[i]){
        string ret;
        rep(j,FREQ[i]) ret.pb(JUN[i]);
        Q.push(mp(FREQ[i],ret));
    }
    return;
}

string merge(string a, string b){
    string ret=a;
    ll C=0;
    ll M=a.size()+b.size();
    rep(i,M){
        string kari=ret;
        kari.insert(kari.begin()+i,b[C]);
        ll A=Query(kari);
        if(A==M) return kari;
        if(A==kari.size()) {
            ret=kari;
            C++;
        }
    }
    return ret;
}

string Solve(){
    init();
    string ret;
    while(true){
        //cout<<Q.size()<<endl;
        Ps a=Q.top(); Q.pop();
        if(Q.empty()) return a.second;
        Ps b=Q.top(); Q.pop();
        Q.push(mp(a.first+b.first,merge(a.second,b.second)));
    }
}
int main(){
    string ans=Solve();
    cout<<"! "<<ans<<endl;
}

Measured memory_bytes: 3800
#include <math.h>
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <iostream>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

void renew(int b, int e, int x, int k, vector<int> &Min,int l,int r,const vector<int> &D)
{
    if (D[r-1]<b || D[l]>e){
        return;
    }
    else if (b<=D[l] && D[r-1]<=e){
        Min[k] = min(Min[k], x);
        return;
    }
    else{
        renew(b, e, x, 2 * k + 1, Min, l, (l + r) / 2, D);
        renew(b, e, x, 2 * k + 2, Min, (l + r) / 2, r, D);
        return;
    }
}
int main()
{
    int N, Q, S, T, X;
    const int inf = 2147483647;
    cin >> N >> Q;
    vector<vector<int>> kouji(N, vector<int>(3));
    FOR(i, 0, N)
    {
        cin >> S >> T >> X;
        kouji[i][0] = S - X;
        kouji[i][1] = T - X - 1;
        kouji[i][2] = X;
    }
    int L = 1;
    while (L<Q){
        L *= 2;
    }
    vector<int> D(L + 1,inf);
    FOR(i,0,Q){
        cin >> D[i];
    }
    const int K = 2 * L - 1;
    vector<int> Min(K,inf);
    int MAXIDX = D[Q - 1];

    FOR(i,0,N){
        if (kouji[i][0]>MAXIDX || kouji[i][1]<0){
                continue;
        }
        renew(kouji[i][0], kouji[i][1], kouji[i][2], 0, Min , 0, L, D);
    }
    FOR(q, L - 1, Q + L - 1)
    {
        int ans = inf;
        int now = q;
        while (now > 0)
        {
            ans = min(ans, Min[now]);
            now = (now - 1) / 2;
        }
        if (ans == inf)
        {
            cout << -1 << endl;
        }
        else
        {
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll N=200005, inf=1e18;
ll f(ll a,ll b,ll x){
	return floor((a*x)/b)-a*floor(x/b);
}
void solve(){
	ll a, b, n;
	cin>>a>>b>>n;
	n>=b-1?cout<<f(a,b,b-1):cout<<f(a,b,n);
}	
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


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

const int maxn = 1e5 + 10;

struct edge {
  int to, w, c;
};
struct query {
  int u, v, x, y;
};
vector<edge> adj[maxn];
query que[maxn];
vector<int> qid[maxn];
int sum[maxn], depth[maxn], parent[maxn][30], n, dist, ncolor[maxn], sumco[maxn];
unordered_map<int, int> ccnt[maxn], csum[maxn];

void dfs(int u, int fa, int d) {
  depth[u] = d;
  parent[u][0] = fa;
  for (auto e : adj[u]) {
    if (e.to != fa) dfs(e.to, u, d + 1);
  }
}

void init() {
  for (int i = 1; i <= 20; ++i) {
    for (int j = 0; j < n; ++j) {
      if (parent[j][i - 1] < 0) parent[j][i] = -1;
      else parent[j][i] = parent[parent[j][i - 1]][i - 1];
    }
  }
}

int lca(int u, int v) {
  if (depth[u] > depth[v]) swap(u, v);
  for (int i = 20; i >= 0; --i)
    if ((depth[v] - depth[u]) >> i & 1) v = parent[v][i];
  if (u == v) return u;
  for (int i = 20; i >= 0; --i) {
    if (parent[u][i] != parent[v][i]) {
      v = parent[v][i];
      u = parent[u][i];
    }
  }
  return parent[u][0];
}

void dfs2(int u, int p) {
  sum[u] = dist;
  for (auto q : qid[u]) {
    ccnt[u][que[q].x] = ncolor[que[q].x];
    csum[u][que[q].x] = sumco[que[q].x];
  }
  for (auto e : adj[u]) {
    if (e.to != p) {
      dist += e.w;
      ++ncolor[e.c];
      sumco[e.c] += e.w;
      dfs2(e.to, u);
      dist -= e.w;
      --ncolor[e.c];
      sumco[e.c] -= e.w;
    }
  }
}

int main() {
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  #endif
  ios::sync_with_stdio(false);
  int q;
  cin >> n >> q;
  for (int i = 0; i < n - 1; ++i) {
    int u, v, w, c;
    cin >> u >> v >> c >> w;
    --u; --v;
    adj[u].push_back((edge){v, w, c});
    adj[v].push_back((edge){u, w, c});
  }
  dfs(0, -1, 0);
  init();
  for (int i = 0; i < q; ++i) {
    int u, v, x, y;
    cin >> x >> y >> u >> v;
    --u; --v;
    que[i] = (query){u, v, x, y};
    qid[lca(u, v)].push_back(i);
    qid[u].push_back(i);
    qid[v].push_back(i);
  }
  dfs2(0, -1);
  for (int i = 0; i < q; ++i) {
    int t1 = sum[que[i].u] - csum[que[i].u][que[i].x] + ccnt[que[i].u][que[i].x] * que[i].y;
    int t2 = sum[que[i].v] - csum[que[i].v][que[i].x] + ccnt[que[i].v][que[i].x] * que[i].y;
    int l = lca(que[i].u, que[i].v);
    int t3 = sum[l] - csum[l][que[i].x] + ccnt[l][que[i].x] * que[i].y;
    cout << t1 + t2 - 2 * t3 << endl;
  }
  return 0;
}

Measured memory_bytes: 65464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

int N, Q;
string S;
const int maxn=500005;
int lazy[4*maxn];
int tree[4*maxn];

void push_down(int u)
{
    if(lazy[u])
    {
        lazy[2*u]=lazy[2*u+1]=lazy[u];
        tree[2*u]=tree[2*u+1]=tree[u];
        lazy[u]=0;
    }
}

void build(int u, int l, int r)
{
    lazy[u]=0;
    //tree[u]=(1<<1);
    if(l==r)
        return ;
    int mid=(l+r)>>1;
    build(2*u,l,mid);
    build(2*u+1,mid+1,r);
}

void update(int u, int l, int r, int tl, int tr, int val)
{
    if(tl<=l&&r<=tr)
    {
        lazy[u]=1;
        tree[u]=(1<<val);
        return ;
    }
    push_down(u);
    int mid=(l+r)>>1;
    if(tr<=mid)  update(2*u,l,mid,tl,tr,val);
    else if(tl>mid) update(2*u+1,mid+1,r,tl,tr,val);
    else
    {
        update(2*u,l,mid,tl,tr,val);
        update(2*u+1,mid+1,r,tl,tr,val);
    }
    tree[u]=tree[2*u]|tree[2*u+1];
}

int query(int u, int l, int r, int tl, int tr)
{
    if(tl<=l&&r<=tr)
    {
        return  tree[u];
    }
    push_down(u);
    int mid=(l+r)>>1;
    if(tr<=mid)  return query(2*u,l,mid,tl,tr);
    else if(tl>mid) return query(2*u+1,mid+1,r,tl,tr);
    else
    {
        int t1=query(2*u,l,mid,tl,tr);
        int t2=query(2*u+1,mid+1,r,tl,tr);
        return t1|t2;
    }
}

int fx(int x)
{
    int ans=0;
    while(x)
    {
        if(x&1) ans++;
        x>>=1;
    }
    return ans;
}

int main()
{
    cin >> N >> S >> Q;
    build(1,1,N);
	for(int i=0;i<N;++i) update(1,1,N,i+1,i+1,S[i]-'a'+1);
    int op;
    while(Q--)
    {
        cin >> op;
        int l, r, idx;
        char ch;
        if(op==1)
        {
            scanf("%d %c\n",&idx,&ch);
            update(1,1,N,idx,idx,ch-'a'+1);
        }
        else
        {
            cin >> l >> r;
            int ans=query(1,1,N,l,r);
            printf("%d\n",fx(ans));
        }
    }
    return 0;
}

Measured memory_bytes: 13188
#include<iostream>
#include<algorithm>
#define INF 999999
using namespace std;
int n, p;
int r, k;
int t;
int s, d, v, cost[110][110];
void warshall_floyd();
int main(){
  cin >> n;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      if(i == j) cost[i][j] = 0;
      else{
	cost[i][j] = INF;
      }
    }
  }
  for(int i = 1; i <= n; i++){
    cin >> r >> k;
    for(int j = 0; j < k; j++){
      cin >> t;
      cost[r][t] = 1;
    }
  }
  warshall_floyd();
  cin >> p;
  for(int i = 0; i < p;i++){
    cin >> s >> d >> v;
    if(cost[s][d] + 1 <= v) cout << cost[s][d] + 1 << endl;
    else cout << "NA" << endl;
  }
}

void warshall_floyd(){
  for(int k = 1; k <= n; k++){
    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= n; j++){
	cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
}

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

int dp[1000+1][1000+1];//dp[i][j]:=Xのi番目までの文字列とYのj番目までの文字列のLCS

int solve(string X,string Y){
    int m=X.size();
    int n=Y.size();

    rep(i,m) dp[i][0]=0;
    rep(j,n) dp[0][j]=0;

    X=' '+X;
    Y=' '+Y;

    for(int i=1;i<=m;i++){
        for (int j=1;j<=n;j++){
                if(X[i]==Y[j])    dp[i][j] = dp[i-1][j-1]+1;
                else        dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    return dp[m][n] ;
}

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

    string X,Y;

    rep(i,n){
        cin>>X;
        cin>>Y;
        cout<<solve(X,Y)<<endl;
    }
    return 0;
}


Measured memory_bytes: 7128