akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		out.println(Math.min(a * n, b));
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

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

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

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

Measured memory_bytes: 21204
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

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

struct Data {
	int a, e, r;
	Data() {}
	Data(int a, int e, int r) : a(a), e(e), r(r) {}
};

int dp[101][101];
Data data[100];

int main() {
	int d, n;
	while (scanf("%d %d", &d, &n), d || n) {
		REP(i, n) {
			int a, e, r;
			scanf("%d %d %d", &a, &e, &r);
			data[i] = Data(a, e, r);
		}
		
		fill(dp[0], dp[d + 1], INF);
		dp[0][0] = 0;
		REP(i, d) REP(j, 101) {
			if (dp[i][j] == INF) continue;
			REP(k, n) {
				if (j < data[k].r) continue;
				dp[min(d, i + data[k].a)][min(100, j + data[k].e)] = 
					min(dp[min(d, i + data[k].a)][min(100, j + data[k].e)], dp[i][j] + 1);
			}
		}
		int ans = INF;
		REP(i, 101) ans = min(ans, dp[d][i]);
		if (ans == INF) puts("NA");
		else cout << ans << endl;
	}
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int lcm(int a, int b){
    if(a < b) swap(a, b);

    while(b != 0){
        int t = a;
        a = b;
        b = t%b;
    }

    return a;
}

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

    int ans = a[0];
    for(int i=1; i<N; i++) ans = lcm(ans, a[i]);
    cout << ans << endl;
}

Measured memory_bytes: 640
N, K = map(int, input().split())

ans, saidai, saisyo = 0, 0, 0
for i in range(1, N+2):
    saisyo += i-1
    saidai += N-i+1
    if i >= K:
        ans += (saidai - saisyo + 1)
    
print(ans%(10**9+7))


Measured memory_bytes: 9136
n = int(input())
S = []
ans = 0
numA = 0
numB = 0
numBA = 0
for _ in range(n):
    s = input()
    ans += s.count("AB")
    if s[-1] == "A":
        if s[0] == "B":
            numBA += 1
        else:
            numA += 1
    elif s[0] == "B":
        numB += 1

if numBA == 0:
    ans += min(numA, numB)
else:
    if numA > 0:
        if numB > 0:
            ans += numBA + 1 + min(numA - 1, numB - 1)
        else:
            ans += numBA
    else:
        if numB > 0:
            ans += (numBA - 1) + 1
        else:
            ans += numBA - 1

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int cnt[200001];
int main(void){
    int n,i,max=0;
    scanf("%d",&n);
    char s[n][11];
    for(i=0;i<n;i++) scanf("%s",&s[i]);
    qsort(s,n,11,strcmp);
    cnt[0]=1;
    for(i=1;i<n;i++){
        if(strcmp(s[i-1],s[i])==0) cnt[i]=cnt[i-1]+1;
        else{
            cnt[i]=1;
            if(cnt[i-1]>max) max=cnt[i-1];
        }
    }
    if(cnt[n-1]>max) max=cnt[n-1];
    for(i=0;i<n;i++){
        if(cnt[i]==max) printf("%s\n",s[i]);
    }
}

Measured memory_bytes: 4884
#include <cstdio>
#include <cstring>

using namespace std;

int main () {
	char s[16] = {'C', 'O', 'D', 'E', 'F', 'E', 'S', 'T', 'I', 'V', 'A', 'L', '2', '0', '1', '6'}, a[16];
	scanf("%s", &a);
	int cnt = 0;
	for (int i = 0; i < 16; i++) {
		if (s[i] != a[i])
			cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
#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)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double Pi = acos(-1);
const ll mod=1e9+7;

int main(){
    int n;
    cin >>n;
    int a[n];
    int b[1000000+1]={0};
    int c=0;
    rep(i,n) cin >>a[i];
    sort(a,a+n);
    rep(i,n){
        if(a[i]==c){
            b[a[i]]=1;
            continue;
        }
        for(int j=2;a[i]*j<=1000000;j++){
            b[a[i]*j]=1;
        }
        c=a[i];
    }
    int ans=0;
    rep(i,n){
        if(b[a[i]]==0) ans++;
    }
    cout << ans <<endl;
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    set<string> st;
    string s;
    int n;
    cin >> n;
    while (n--) {
        cin >> s;
        st.insert(s);
    }
    cout << sz(st) << endl;
    return 0;
}


Measured memory_bytes: 19236
#include <stdio.h>

int main(){
	int n,flag=0;
	int a[1005];
	
	scanf("%d",&n);
	
	for (int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	for (int i=0;i<n;i++){
		if(a[i]%2==0){
//			printf("guusuu hantei %d \n",a[i]);
			if(a[i]%3!=0 && a[i]%5!=0){
//				printf("3 amari %d \n",a[i]%3);
//				printf("5 amari %d \n",a[i]%5);
				flag = 1;
			}
		}
	}
	
	if (flag!=1){
		printf("APPROVED");
	}
	else printf("DENIED");
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 #define mod 1000000007
using namespace std;
 
typedef long long ll;
 set<ll> st[2005];
 set<ll> st1[2005];
 ll arr[2005][2005];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,m;
    cin>>n>>m;
    string s;
    vector<string> v;
    for(int i=1;i<=n;i++){
        cin>>s;
        for(int j=0;j<s.size();j++){
            if(s[j]=='#'){  st[i].insert(j+1); }
        }
        st[i].insert(0); st[i].insert(m+1);
        v.push_back(s);
    }
    
    set<ll> ::iterator it;
    // for(int i=1;i<=n;i++) {
    //     for(it=st[i].begin();it!=st[i].end();it++) cout<<*it<<" ";
    //     cout<<endl;
    // }
    for(int i=0;i<v.size();i++){
        for(int j=0;j<m;j++){
            if(v[i][j]=='.'){
                ll val=j+1;
                st[i+1].insert(j+1);
                it=st[i+1].find(j+1);
                ll ans=*it;
                it--;
                ll left=ans-1-*it;
                it++;
                it++;
                left+=*it-ans-1;
                it--;
                st[i+1].erase(it);
                arr[i+1][j+1]=left;
            }
        }
    }
    // for(int i=1;i<=n;i++){for(int j=1;j<=m;j++) cout<<arr[i][j]<<" ";
    // cout<<endl; }
    vector<string> v1;
    for(int i=0;i<m;i++){
        s=""; 
        for(int j=0;j<n;j++){
             s+=v[j][i];
             if(v[j][i]=='#'){  st1[i+1].insert(j+1); }
        }
      
        st1[i+1].insert(0); st1[i+1].insert(n+1);
        v1.push_back(s);
     }
    // for(int i=0;i<v1.size();i++) cout<<v1[i]<<endl;
    // for(int i=1;i<=m;i++) {
    //     for(it=st1[i].begin();it!=st1[i].end();it++) cout<<*it<<" ";
    //     cout<<endl;
    // }
     for(int i=0;i<v1.size();i++){
        for(int j=0;j<n;j++){
            if(v1[i][j]=='.'){
                st1[i+1].insert(j+1);
                it=st1[i+1].find(j+1);
                 ll ans=*it;
                it--;
                  ll left=ans-1-*it;
                it++;
                it++;
                left+=*it-ans-1;
                it--;
                st1[i+1].erase(it);
                arr[j+1][i+1]+=left;
            }
        }
    }
    ll fin=INT_MIN;
    for(int i=1;i<=n;i++){for(int j=1;j<=m;j++) fin=max(arr[i][j],fin); //cout<<arr[i][j]<<" ";
    cout<<endl; }
    cout<<fin+1<<endl;
    
    
    
}

Measured memory_bytes: 411776
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

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

int main() {
	string s;cin>>s;
	map<char, int> mp;
	rep(i,s.size()){
		mp[s[i]]++;
	}
	bool can = true;
	if((mp['S'] == 0 && mp['N'] > 0 ) || (mp['N']==0 && mp['S']>0))can = false;
	if((mp['W'] == 0 && mp['E'] > 0 ) || (mp['E']==0 && mp['W']>0))can = false;
	cout << (can? "Yes": "No") << endl;
}



Measured memory_bytes: 384
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinIntArr()
	for idx, val := range list {
		if val == 0 {
			fmt.Printf("%d\n", idx+1)
			break
		}
	}
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

int main() {
  int n;
  cin >> n;
  vector<long long> A(n+1), B(n);
  for (int i = 0; i < n + 1; ++i) cin >> A[i];
  for(int i = 0; i < n; ++i) cin >> B[i];
  long long int count=0;
  for (int i = 0; i < n; ++i) {
      count += min(A[i], B[i]);
      B[i] -= min(A[i], B[i]);
      count += min(A[i+1], B[i]);
      A[i + 1] -= min(A[i + 1], B[i]);
  }
  cout << count << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define int long long
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n,k;
vector<vector<int>> g(100000+5);
int num[100000+5];
vector<vector<pair<int,int>>> lr(100000+5);
int root;

void dfs1(int now,int par,int depth){
    if (num[now]!=-1){
        if ((num[root]+depth)%2!=num[now]%2){
            cout << "No" << endl;
            exit(0);
        }
    }
    for (auto nx: g[now]){
        if (nx==par) continue;
        dfs1(nx,now,depth+1);
    }
}

pair<int,int> dfs2(int now,int par){
    int l=-1e9;
    int r=1e9;
    for (auto nx: g[now]){
        if (nx==par) continue;
        pair<int,int>tmp=dfs2(nx,now);
        l=max(l,tmp.fi-1);
        r=min(r,tmp.se+1);
    }
    if (l>r){
        cout << "No" << endl;
        exit(0);
    }
    if (num[now]!=-1){
        if (l<=num[now] && num[now]<=r){
            lr[now].pb(make_pair(num[now],num[now]));
        }
        else{
            cout << "No" << endl;
            exit(0);
        }
    }
    else lr[now].pb(make_pair(l,r));
    return lr[now][0];
}

void dfs3(int now,int par,int val){
    int l=lr[now][0].fi;
    int r=lr[now][0].se;
    if (l<=val+1 && val+1<=r){
        num[now]=val+1;
        val=val+1;
    }
    else if (l<=val-1 && val-1<=r){
        num[now]=val-1;
        val=val-1;
    }
    for (auto nx: g[now]){
        if (nx ==par) continue;
        dfs3(nx,now,val);
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    cin >> k;
    fill(num,num+n,-1);
    int v,p;
    rep(i,k){
        cin >> v >> p;
        v--;
        num[v]=p;
    }
    root=v;
    dfs1(root,root,0);
    dfs2(root,root);
    dfs3(root,root,num[root]);
    cout << "Yes" << endl;
    rep(i,n) cout << num[i] << endl;
}


Measured memory_bytes: 22016
import sys
while True:
    a=[]
    for i in range(3):
        z=str(input())
        if z=="0":
            sys.exit()
        a.append(z)
    A,B,C=a[0],a[1],a[2]
    A=A[1:]+B[0]
    B=B[1:]+C[0]
    C=C[1:]
    print(A.count("A"), A.count("B"))
    print(B.count("A"), B.count("B"))
    d,e=C.count("A"),C.count("B")
    if d>e:
        d+=1
    else:
        e+=1
    print(d,e)


Measured memory_bytes: 5568
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string col="RGBPYE";

int rx[2][6]={
	{0,-1,-1,0,1,1},
	{0,-1,-1,0,1,1},
};

int ry[2][6]={
	{-1,0,1,1,1,0},
	{-1,-1,0,1,0,-1},
};

int fx[2][3]={
	{-1,0,1},
	{-1,0,1},
};

int fy[2][3]={
	{0,-1,0},
	{-1,-1,-1},
};

int h,w;
int fie[51][51];

void print(){
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(fie[h-1-i][j]==-1){
				printf(".");
			}else{
				printf("%c",col[fie[h-1-i][j]]);
			}
		}
		printf("\n");
	}
}

void rotate(int cx,int cy){
	for(int i=0;i<6;i++){
		int nx=cx+rx[cx%2][i];
		int ny=cy+ry[cx%2][i];
		if(nx<0 || nx>=w || ny<0 || ny>=h)return;
	}
	int n0x=cx+rx[cx%2][0];
	int n0y=cy+ry[cx%2][0];
	int tmp=fie[n0y][n0x];
	for(int i=5;i>=0;i--){
		int n1x=cx+rx[cx%2][i];
		int n1y=cy+ry[cx%2][i];
		int n2x=cx+rx[cx%2][(i+1)%6];
		int n2y=cy+ry[cx%2][(i+1)%6];
		fie[n2y][n2x]=fie[n1y][n1x];
	}
	int n1x=cx+rx[cx%2][1];
	int n1y=cy+ry[cx%2][1];
	fie[n1y][n1x]=tmp;
}

bool fall(int cx,int cy){
	for(int i=0;i<3;i++){
		int nx=cx+fx[cx%2][i];
		int ny=cy+fy[cx%2][i];
		if(nx>=0 && nx<w && ny>=0 && ny<h){
			if(fie[ny][nx]!=-1)return false;
		}
	}
	swap(fie[cy][cx],fie[cy-1][cx]);
	return true;
}

int cnt[2501];
int type[51][51];
bool used[51][51];

void dfs(int cx,int cy,int k){
	cnt[k]++;
	type[cy][cx]=k;
	used[cy][cx]=true;
	for(int i=0;i<6;i++){
		int nx=cx+rx[cx%2][i];
		int ny=cy+ry[cx%2][i];
		if(nx>=0 && nx<w && ny>=0 && ny<h){
			if(fie[ny][nx]==fie[cy][cx] && !used[ny][nx]){
				dfs(nx,ny,k);
			}
		}
	}
}

void process(){
	bool flag=true;
	while(flag){
		flag=false;
		bool flag2=true;
		while(flag2){
			flag2=false;
			for(int i=1;i<h;i++){
				for(int j=0;j<w;j++){
					if(fie[i][j]!=-1 && fall(j,i)){
						flag2=true;
					}
				}
			}
		}
		memset(cnt,0,sizeof(cnt));
		memset(used,false,sizeof(used));
		int sz=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(fie[i][j]!=-1 && !used[i][j]){
					dfs(j,i,sz++);
				}
			}
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(fie[i][j]!=-1 && cnt[type[i][j]]>=3){
					fie[i][j]=-1;
					flag=true;
				}
			}
		}
	}
}

int main(void){
	scanf("%d%d",&h,&w);
	memset(fie,-1,sizeof(fie));
	for(int i=0;i<h;i++){
		string s;
		cin >> s;
		for(int j=0;j<w;j++){
			for(int k=0;k<6;k++){
				if(col[k]==s[j]){
					fie[h-1-i][j]=k;
				}
			}
		}
	}
	process();
	int q;
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		rotate(a,b);
		process();
	}
	print();
	
	return 0;
}



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

long long int N, fact[10010101], ifact[10010101], ans;
constexpr long long int M = 1000000007, m = 79133769, n = 536396504, mask = 1073741823;

inline long long int MR(long long int A){
    long long int ret((A + M * (m * A & mask)) >> 30);
    return ret - (ret >= M) * M;
}

inline long long int Prod(long long int lhs, long long int rhs){
    return MR(MR(lhs * rhs) * n);
}

int main(){
    scanf("%lld", &N);
    *fact = 1;
    for(int i = 1; i < N; ++i){
        fact[i] = Prod(fact[i - 1], i);
    }
    long long n = M - 2, r = fact[N - 1];
    ifact[N - 1] = 1;
    while(n){
        if(n & 1){
            ifact[N - 1] = ifact[N - 1] * r % M;
        }
        n /= 2;
        r = r * r % M;
    }
    for(int i = N - 1; i > 0; --i){
        ifact[i - 1] = Prod(ifact[i], i);
    }
    ans = fact[N - 1] * (N - 1);
    for(int i = N / 2; i < N - 1; ++i){
        ans += M - Prod(Prod(fact[i], fact[i - 1]), ifact[i * 2 - N]);
    }
    ans %= M;
    cout << ans << endl;
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
//head

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

    ll x;
    cin >> x;
    for(int i = -1000; i <= 1000; i++) {
        for(int j = -1000; j <= 1000; j++) {
            if(pow(i,5) - pow(j,5) == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

    return 0;
}


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

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

ll lcm(ll a ,ll b){
  if(a<b){
    swap(a,b);
  }
  return a/gcd(a,b)*b;
}
int main() {
  int n;
  cin >>n;
  vector<ll>a(n);
  for(int i=0;i<n;i++){
    cin >>a.at(i);
  }
  ll ans=a.at(0);
  for(int i=0;i<n;i++){
    ans = lcm(a.at(i),ans);
  }
  cout << ans;
}

Measured memory_bytes: 764
#include <stdio.h>

int n,A[50];

int solve(int i,int m){
  if(m == 0) return 1;
  if(i >= n) return 0;
  int res = solve(i + 1,m) || solve(i + 1,m - A[i]);
  return res;
}

int main(){
  int q,M,i;

  scanf("%d",&n);
  for(i = 0; i < n; i++)
     scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&M);
    if(solve(0,M)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

vector<pair<long long, long long>> prime_foctorize(long long N) {
  vector<pair<long long, long long>> res;
  for (long long i = 2; i * i <= N; i++) {
    if (N % i != 0) continue;
    long long ex = 0;
    while (N % i == 0) {
      ex++;
      N /= i;
    }
    res.push_back({i, ex});
  }
  if (N != 1) res.push_back({N, 1});
  return res;
}

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

  long long X = __gcd(A, B);
  const auto &pf = prime_foctorize(X);
  cout << pf.size() + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// 型エイリアス
using pii = pair<int, int>;
using tisb = tuple<int, string, bool>;
using vi = vector<int>;
using vii = vector<vi>;

const int LEN = 100005;

struct Process{
  char name[100];
  int t;
};

Process Q[LEN];
int head, tail, n;


void enqueue(Process x){
  Q[tail] = x;
  tail = (tail+1)%LEN;
}

Process dequeue(){
  Process x = Q[head];
  head = (head+1)%LEN;
  return x;
}

int main(){
  int q; cin >> n >> q;
  int elaps = 0, c;
  Process u;

  for(int i=1; i<=n; ++i) cin >> Q[i].name >> Q[i].t;
  head=1;
  tail=n+1;

  while(head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else printf("%s %d\n", u.name, elaps);
  }
}


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

int main()
{
  int N, M, C; cin >> N >> M >> C;
  int ans = 0;
  int count = 0;
  
  vector<int> B(M);
  for (int i = 0; i < M; i++)
  {
    cin >> B[i];
  }

  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < M; j++)
    {
      cin >> A[i][j];
    }
  }

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < M; j++)
    {
      ans += A[i][j] * B[j];
    }
    ans += C;
    if (ans > 0)
    {
      count++;
    }
    ans = 0;
  }

  cout << count << endl;

}

Measured memory_bytes: 256
n,k = gets.chomp.split.map(&:to_i)
r,s,p = gets.chomp.split.map(&:to_i)
t = gets.chomp

a = Array.new(k).map{Array.new(n/k)}

for i in 0..n-1
    a[i%k][i/k] = t[i]
end
w = [0,0,0]
for i in 0..k-1
    flag = 0 #前に負けてたら１
    for j in 0..a[i].length-1
        if flag == 1 || j==0
            if a[i][j] == 's'
                w[0] += 1
            elsif a[i][j] == 'p'
                w[1] += 1
            else
                w[2] += 1
            end
            flag = 0
        else
            if a[i][j-1]==a[i][j]
                flag = 1
                next
            end
            if a[i][j] == 's'
                w[0] += 1
            elsif a[i][j] == 'p'
                w[1] += 1
            else
                w[2] += 1
            end
        end
    end
end

ans = w[0]*r+w[1]*s+w[2]*p

puts ans

Measured memory_bytes: 15740
using System;
using System.Linq;

namespace ABC045
{
    class B
    {
        static void Main(string[] args)
        {

            var sa = Console.ReadLine().ToList();
            var sb = Console.ReadLine().ToList();
            var sc = Console.ReadLine().ToList();

            char c = sa[0];
            sa.RemoveAt(0);
            //Console.WriteLine(string.Join(',', sa));
            for (int i = 0; 0 <= sa.Count && 0 <= sb.Count && 0 <= sc.Count; i++)
            {
                if (c == 'a' && sa.Count == 0) { Console.WriteLine('A'); return; }
                if (c == 'b' && sb.Count == 0) { Console.WriteLine('B'); return; }
                if (c == 'c' && sc.Count == 0) { Console.WriteLine('C'); return; }

                if (0 < sa.Count && c == 'a') { c = sa[0]; sa.RemoveAt(0); }
                if (0 < sb.Count && c == 'b') { c = sb[0]; sb.RemoveAt(0); }
                if (0 < sc.Count && c == 'c') { c = sc[0]; sc.RemoveAt(0); }
            }
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#include <cstring>
#define int long long
using namespace std;
char s[12];
int l,ans;
void dfs(int x,int sum,int tmp)
{
	if(x==l){
		ans+=tmp+sum;
		return;
	}
	if(x!=0) dfs(x+1,s[x]-'0',tmp+sum);
	dfs(x+1,sum*10+s[x]-'0',tmp);
}
signed main()
{
	cin>>s;
	l=strlen(s);
	dfs(0,0,0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl

//ここから編集する


int main() {
    string o,s;
    cin >> o >> s;
    if(o.size() == s.size()){
        rep(i,0,o.size()){
            cout << o[i] << s[i];
        }
    }else{
        rep(i,0,s.size()){
            cout << o[i] << s[i];
        }
        cout << o[o.size()-1];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MAX_N 2000000
using namespace std;
int K;
int N;
int A[MAX_N];
int ans;
int main() {
  cin >> K >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i >= 1) {
      ans = max(ans, A[i] - A[i - 1]);
    }
  }
  ans = max(ans, A[0] + (K - A[N - 1]));
  cout << K - ans << endl;;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n;
int ac, wa, tle, re;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		if (s == "AC")ac++;
		else if (s == "WA")wa++;
		else if (s == "RE")re++;
		else tle++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
}

Measured memory_bytes: 3632
from collections import deque


def main():
    """K の正の倍数の 10 進法での各桁の和としてありうる最小の値を求めてください。

    2 ≤ K ≤ 10^5

    min: 1が1つと他が0 -> 10^n, e.g.: 5*2, 25*4
    10倍しても元のKと和は変わらない
    1-9倍とは限らない?: 入力例 2　11111=41×271, 4+1=5では？
    """
    K = int(input())

    ans = sum_digits(K)
    for i in range(2, 10):
        ans = min(ans, sum_digits(K * i))

    print(ans)


def sum_digits(n):
    return sum(map(int, list(str(n))))


def main2():
    import sys

    debug = sys.argv[-1] == "debug"
    K = int(input())

    q = deque([1])
    inf = float("inf")
    dp = [inf for _ in range(K)]
    dp[1] = 0

    # 01BFS
    # cost 0 の辺の遷移は deque の先頭に要素を追加
    # cost 1 の辺の遷移は deque の末尾に要素を追加
    while q:
        idx = q.popleft()
        x = dp[idx]
        m1 = (idx * 10) % K
        m2 = (idx + 1) % K
        if dp[m1] > x:
            dp[m1] = x
            q.appendleft(m1)
        if dp[m2] > x + 1:
            dp[m2] = x + 1
            q.append(m2)

        if debug:
            print((m1, m2), dp, q, file=sys.stderr)
            print("-" * 10, file=sys.stderr)

    print(dp[0] + 1)


if __name__ == '__main__':
    main2()


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

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

		if (s == "0")break;

		int sum = 0;

		for (char c : s) {
			sum += (c - '0');
		}

		cout << sum << endl;
	}

	return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,a,b;
  cin>>n>>a>>b;
  vector<Int> p(n);
  for(Int i=0;i<n;i++) cin>>p[i];

  vector<Int> r(n);
  for(Int i=0;i<n;i++) r[--p[i]]=i;

  vector<Int> dp(n*2+2,0);

  const Int INF = 1e18;  
  for(Int i=0;i<n;i++){
    vector<Int> nx(n*2+2,INF);
    Int k=r[i]*2+1;
    Int tmp=INF;
    for(Int j=0;j<n*2+2;j++){      
      if(j==k) chmin(nx[j],tmp);
      chmin(tmp,dp[j]);
      if(j&1) continue;
      chmin(nx[j],tmp+(j<k?b:a));
    }
    swap(dp,nx);
  }
  
  cout<<*min_element(dp.begin(),dp.end())<<endl;
  return 0;
}


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

#define pb       push_back
#define all(a)   a.begin(), a.end()
#define mp       make_pair
#define ll	long long

using namespace std;
const int MAX = 1e5+9;
string s,t;
int main(){
	cin >> s >> t;
	for(int i=0; i<s.length(); i++){
		if(s[i] == t[0]){
      string ss =  s.substr(i, s.length()) +  s.substr(0,i);
      if(ss == t){
        cout << "Yes" << endl;
        return 0;
      }
    }
	}
  cout << "No" << endl;
	return 0;
}

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

int main(void){
int a,b,c;
cin >> a;
cin >> b;
cin >> c;
int i = 0;
    for(int x = a ; x <= b ; x++){
        if(c % x == 0){
            i++;
        }
        else{
        }
   }
cout << i << endl;
}




Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read()
{
	ll re=0,flag=1;
	char ch=getchar();
	while(ch>'9'||ch<'0')
	{
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
ll n;
ll m=200000;
struct BIT
{
	ll a[200010];
	void clear()
	{
		memset(a,0,sizeof(a));
	}
	ll lowbit(ll x)
	{
		return x&(-x);
	}
	void add(ll x,ll val)
	{
		for(; x<=m; x+=lowbit(x)) a[x]+=val;
	}
	ll sum(ll x)
	{
		ll re=0;
		for(; x>0; x-=lowbit(x)) re+=a[x];
		return re;
	}
} T;
struct ele
{
	ll val,num;
} a[100010];
ll w[100010];
bool cmp1(ele l,ele r)
{
	return l.val<r.val;
}
bool cmp2(ele l,ele r)
{
	return l.num<r.num;
}
ll x[100010];
ll lim;
bool check(ll val)
{
	ll i;
	ll sum=0,re=0;
	T.clear();
	for(i=1; i<=n; i++)
	{
		if(a[i].val<val) x[i]=-1;
		else x[i]=1;
	}
	T.add(100000,1);
	for(i=1; i<=n; i++)
	{
		sum+=x[i];
		re+=T.sum(sum+100000);
		T.add(sum+100000,1);
	}
	return re>=(lim/2+lim%2);
}
int main()
{
	ll i;
	n=read();
	lim=n*(n+1)/2;
	for(i=1; i<=n; i++) a[i].val=read(),a[i].num=i;
	sort(a+1,a+n+1,cmp1);
	for(i=1; i<=n; i++) w[i]=a[i].val;
	sort(a+1,a+n+1,cmp2);
	ll l=1,r=n,mid;
	while(l<r)
	{
		mid=(l+r)>>1;
		mid++;
		if(check(w[mid])) l=mid;
		else r=mid-1;
	}
	printf("%lld\n",w[l]);
}


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

int main(){
	int a,b,c;
	cin>>a;
	cin>>b>>c;
	int e=0;
	int f=0;
	int g=0;
	for(int i=0;i<a;i++){
		int d[100];
		cin>>d[i];
		if(d[i]<=b){
			e++;
		}
		if(d[i]>b&&d[i]<=c){
			f++;
		}
		if(d[i]>c){
			g++;
		}
	}
	int h=min({e,f,g});
	cout<<h<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a, ll mod) { return modpow(a, mod - 2, mod); }

ll modnCr(ll n, ll r, ll mod) {
  ll ans = 1;
  FOR(i, 1, n + 1) { ans = (ans * i) % mod; }
  ll inv = 1;
  FOR(i, 1, r + 1) { inv = (inv * i) % mod; }
  FOR(i, 1, n - r + 1) { inv = (inv * i) % mod; }
  ans = (ans * modinv(inv, mod)) % mod;
  return ans;
}

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

  vl mid(h - a);
  mid[0] = 1LL;
  FOR(i, 1, h - a) {
    mid[i] = ((mid[i - 1] * (b + i - 1)) % MOD * modinv((ll)i, MOD)) % MOD;
  }

  ll ans = 0LL;
  ll cur = (mid[0] * modnCr(h + w - b - 2, w - b - 1, MOD)) % MOD;
  ans += cur;
  for (ll i = h - a - 1; i >= 1LL; i--) {
    cur = (cur * (a + i)) % MOD;
    cur = (cur * modinv(w - b - 1 + a + i, MOD)) % MOD;

    ans = (ans + (cur * mid[h - a - i]) % MOD) % MOD;
  }
  cout << ans << endl;
}


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

using namespace std;

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


int main() {
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a > b && b != 1 || a == 1 && b != 1) {
        cout << "Alice" << endl;
    } else if (b > a && a != 1 || b == 1 && a != 1) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

LL D[10005];
LL L[10005];

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	LL n, x;
	cin >> n >> x;
	for(int i = 1; i <= n; i++){
		cin >> L[i];
	}
	
	LL ans = 0;
	for(int i = 1; i <= n+1; i++){
		//cout << "Current i: " << i << '\n';
		D[i] = D[i-1] + L[i-1];
		//cout << "current D[i]: " << D[i] << '\n';
		if(D[i] <= x){
			ans++;
			//cout << "Current ans: " << ans << '\n';
		}
	}

	cout << ans << '\n';



	
	
	return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N, K;

int main() {
  cin >> N >> K;
  if (N%K == 0) cout << 0 << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

const int MaxN = 1e6;
int n, a[MaxN], i, j, sum, vis;

int main()
{
	while(cin >> n)
	{
		for(i = 0; i < n; i++)
			cin >> a[i];
		sum = abs(a[i - 1]);
		for(i = 0; i < n; i++)
		{
			if(i - 1 < 0) a[i - 1] = 0;
			sum += abs(a[i] - a[i - 1]);
		}
		vis = sum;
		for(i = 0; i < n; i++)
		{
			sum = vis;
			if(i == 0)
			{
				sum -= abs(a[i]);
				sum -= abs(a[i] - a[i + 1]);
				sum += abs(a[i + 1]);
			}
			else if(i == (n - 1))
			{
				sum -= abs(a[n - 1]);
				sum -= abs(a[n - 2] - a[n - 1]);
				sum += abs(a[n - 2]);
			}
			else
			{
				sum -= abs(a[i] - a[i - 1]);
				sum -= abs(a[i] - a[i + 1]);
				sum += abs(a[i - 1] - a[i + 1]);
			}
			cout << sum << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  int X, Y, Z;
  cin >> X >> Y >> Z;
  cout << Z << " " << X << " " << Y << endl;

  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	ll n, a, b;
  	cin >> n >> a >> b;
  	vll x(n);
  	rep(i,n) cin >> x[i];
  
	ll ans = 0;
  	rep(i,n-1){
    	ans += min((x[i+1]-x[i])*a, b);
    }
  
  	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    int su=0;
    for(int i=0;i<s.size();i++)
        su=(su*10+s[i]-'0')%9;
    if(su==0) cout<<"Yes\n";
    else cout<<"No\n";
}


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

int main(){
	int N;
	cin >> N;
	vector<vector<int>> xy(N,vector<int>(N,-1));
	for(int i=0; i<N; i++){
		int A;
		cin >> A;
		for(int j=0; j<A; j++){
			int x, y;
			cin >> x >> y;
			xy.at(i).at(x-1)=y;
		}
	}

	int ans=0;
	for(int i=0; i< (1<<15) ; i++){
		bitset<15> bit(i);
		bool flag = true;
		int cnt=0;
		for(int k=0; k<N; k++){
			if(bit.test(k)){
				cnt++;
				for(int j=0; j<N; j++){
					if(xy.at(k).at(j) == -1) continue;
					if(xy.at(k).at(j) != bit.test(j) ){
						flag = false;
					}
				}
			
			}
		}
		if(flag){
			ans = max(ans,cnt);
		}

		if( i==pow(2,N)-1 ) {
			break;
		}
	}

	cout << ans << endl;
	
}


Measured memory_bytes: 4096
#include<stdio.h>

int n, A[200];
int solve(int , int);

int main(){

  int i, m[200], q, a;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++)
    scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i = 0 ; i < q ; i++){
    scanf("%d",&m[i]);
    a = solve(0,m[i]);
    if(a == 0)
      printf("yes\n");
    if(a == 1)
      printf("no\n");
  }
  return 0; 

}
int solve(i,m){

  int res = 0;

  if(m == 0) return 0;
  if(i >= n) return 1;
  if(res == solve(i+1,m))
    return res;
  if(res == solve(i+1,m-A[i]))
    return res;
}

Measured memory_bytes: 580
import fractions
N=int(input())
A=list(map(int, input().split()))

MOD=10**9+7

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

g=A[0]
for i in range(1, N):
    g = g*A[i]//fractions.gcd(g, A[i])
ans=0
g%=MOD
for i in range(N):
  ans+=g*modinv(A[i],MOD)
  ans%=MOD
print(ans)

Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))

typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
//#define int long long

int n,m,a,b,c;
string str;


inline void solve(){
  cin >>a >> b>>c;
  int i=0;
  int x = gcd(a,b);
  while(i!=c){
    if(a%x==0 && b%x==0){
      i++;
      if(i==c) break;
    }
    x--;
  }
  cout << x fin;

}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N,M; vpii P; priority_queue<int> Q; queue<pii> R;
void input(){
    cin>>N>>M;
    rep(i,N){
        int a,b; cin>>a>>b; P.emplace_back(make_pair(a,b));
    }
    return;
}

void solve(){
    SORT(P);
    rep(i,N){  
        R.emplace(P[i]);
    }
    // while(!R.empty()){
    //     cout<<R.front().first<<" "<<R.front().second<<"\n";
    //     R.pop();
    // }
    ll ans=0;
    rrep(i,1,M+1){
        while (R.front().first==i && !R.empty()){
            Q.emplace(R.front().second);
            R.pop();
        }
        if(!Q.empty()){
            ans+=Q.top();
            Q.pop();
        }
    }
    cout<<ans<<endl;
    return;
}

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

Measured memory_bytes: 2932