akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


template<typename T>
class WarshallFloyd {
public:
    int n;
    vector<vector<T>> g;
    WarshallFloyd(int n, T mx):n(n){
        g.assign(n+1, vector<T>(n+1, mx));
        reps(i, 0, n){
            g[i][i] = 0;
        }
    }

    void add(int from, int to, ll cost){
        g[from][to] = cost;
    }

    void build(){
        reps(k, 1, n){
            reps(i, 1, n){
                reps(j, 1, n){
                    g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
                }
            }
        }
    }

    T result(int from, int to){
        return g[from][to];
    }
};


class DCandidatesOfNoShortestPaths {
public:
	void solve(std::istream& in, std::ostream& out) {
	    struct edge{
	        int from, to, cost, id;
	        edge(int from, int to, int cost, int id):from(from),to(to),cost(cost),id(id){}
	    };
        int n, m, a, b, c;
        in >> n >> m;
        WarshallFloyd<ll> wf(n, inf);
        vector<edge> edges;
        rep(i, m){
            in >> a >> b >> c;
            wf.add(a, b, c);
            wf.add(b, a, c);
            edges.push_back(edge(a, b, c, i));
            edges.push_back(edge(b, a, c, i));
        }

        wf.build();

        vector<int> used(m, 0);
        reps(i, 1, n){
            rep(j, edges.size()){
                if(wf.result(i, edges[j].to) == wf.result(i, edges[j].from) + edges[j].cost){
                    used[edges[j].id] = 1;
                }
            }
        }

        int res = 0;
        for(auto const& e : used){
            if(!e) res++;
        }

        out << res << endl;
    }
};


int main() {
	DCandidatesOfNoShortestPaths solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n, h;
  cin >> n >> h;
  vector<ll> a(n), b(n);
  ll maxa = 0;
  REP(i, n)
  {
    cin >> a[i] >> b[i];
    maxa = max(a[i], maxa);
  }
  ll tmp = 0;
  ll cnt = 0;
  std::sort(ALL(b), greater<ll>());
  for (auto val : b)
  {
    if (maxa > val)
      break;
    tmp += val;
    cnt++;
    if (tmp >= h)
    {
      break;
    }
  }
  if (tmp < h)
  {

    cnt += (h - tmp) / maxa;
    cnt += (h - tmp) % maxa == 0 ? 0 : 1;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<string> s(N);
  for(int i=0;i<N;i++)cin>>s[i];
  int M;
  cin>>M;
  vector<string> t(M);
  for(int i=0;i<M;i++)cin>>t[i];
  int q=0;
  for(int i=0;i<N;i++){
    int p=0;
    for(int j=0;j<N;j++){
      if(s[i]==s[j])p++;
    }
    for(int k=0;k<M;k++){
      if(s[i]==t[k])p--;
    }
    q=max(q,p);
  }
  cout<<q<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

typedef int		BOOL;
#define TRUE	1;
#define FALSE	0;

typedef struct Word{
	char	word[31];
	int		page;
}	WORD;

WORD wordArray[100];

void input();
	BOOL is_smaller(WORD, int);
void output();

int main()
{
    input();
    output();
	
	return 0;
}

void input()
{
	int 	cnt1, cnt2;
	WORD	tempWORD;
	
	while(scanf("%s %d", tempWORD.word, &tempWORD.page) != EOF)
		for(cnt1 = 0; cnt1 < 100; cnt1++){
			if(wordArray[cnt1].page == 0){
				strcpy(wordArray[cnt1].word, tempWORD.word);
				wordArray[cnt1].page = tempWORD.page;
				break;
			}
			else if(is_smaller(tempWORD, cnt1)){
				for(cnt2 = 98; cnt2 >= cnt1; cnt2--){
					strcpy(wordArray[cnt2 + 1].word, wordArray[cnt2].word);
					wordArray[cnt2 + 1].page = wordArray[cnt2].page;
				}
				strcpy(wordArray[cnt1].word, tempWORD.word);
				wordArray[cnt1].page = tempWORD.page;
				break;
			}
		}
}

BOOL is_smaller(WORD tempWORD, int cnt)
{
	if(strcmp(tempWORD.word, wordArray[cnt].word) < 0){
		return TRUE;
	}
	else if(strcmp(tempWORD.word, wordArray[cnt].word) == 0){
		if(tempWORD.page < wordArray[cnt].page)
		{
			return TRUE;
		}
		else
		{
			return FALSE;
		}
	}
	else
		return FALSE;

}

void output()
{
	int		output_cnt = 0;
	char	last_print_word[31] = "";

	while(wordArray[output_cnt].page != 0)
	{
		if(strcmp(last_print_word, "") == 0)
		{
			printf("%s\n", wordArray[output_cnt].word);
			strcpy(last_print_word, wordArray[output_cnt].word);
		}
		else if(strcmp(wordArray[output_cnt].word, last_print_word) != 0)
		{
			printf("\n%s\n", wordArray[output_cnt].word);
			strcpy(last_print_word, wordArray[output_cnt].word);
		}
		else
		{
			printf(" ");
		}
		printf("%d", wordArray[output_cnt].page);
		output_cnt++;
	}
	printf("\n");
}

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


int main(){
    string s;
    cin >> s;
    cout << string(s.size(),'x') << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<int>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=100005,M=1<<16|2;
int n,ans,d[N],a[N],dp[M],ycl[M];
vector<PI> v[N];
void dfs(){
	int sum=0; 
	int zt=0;
	For(i,1,n){
		int t=d[i]; if(!t){ans--; continue;};
		if(zt>>t&1)ans--; zt^=1<<t;
	}
	//cout<<" "<<zt<<" "<<dp[zt]<<endl;
	ans-=dp[zt];
}
int main(){
	n=ans=read(); 
	For(i,1,n-1){
		int x=read(),y=read(),t=read();
		d[x]^=t; d[y]^=t;
	}
	For(i,0,(1<<16)-1){
		For(j,0,15)if(i>>j&1)ycl[i]^=j;
	}
	For(i,1,(1<<16)-1){
		for(int j=i;j;j=(j-1)&i)if(!ycl[j])dp[i]=max(dp[i^j]+1,dp[i]);
	}
	dfs();
	cout<<ans<<endl;
}
/*
3
0 1 0
1 2 3

*/

Measured memory_bytes: 6856
#include<bits/stdc++.h>
using namespace std;
string s;int l;
int main() {
	cin>>s;
	l=s.size();
	for(register int i=0; i<l; i++) {
		if(s[i]=='C') {
			for(register int j=i+1; j<l; j++) {
				if(s[j]=='F') {
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int l[2002];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>l[i];
	}
	sort(l,l+n);
	int ans = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int a = l[i]+l[j];
			int id = lower_bound(l,l+n,a)-l;
			int cnt = id-j-1;
			ans+=cnt;
		}
	}
	cout<<ans<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
// 30min
int main(void){
  int n;
  int ans = 1;
  int cnt;
  int max = 0;
  int tmp;

  scanf("%d", &n);

  for(int i = 2; i <= n; i++){
    cnt = 0;
    tmp = i;
    while(tmp % 2 == 0){
      cnt++;
      tmp = tmp / 2;
      if(max < cnt){
	max = cnt;
	ans = i;
      }
    }
  }
    
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    vector<int> cnt(1005, 0);
    int N;
    cin >> N;
    int mi = inf;
    int ma = 0;
    rep(i, N){
        int a;
        cin >> a;
        cnt[a]++;
        mi = min(mi, a);
        ma = max(ma, a);
    }
    
    
    if(mi * 2 == ma){
        if(cnt[mi] != 1){
            output("Impossible");
            return 0;
        }
        for(int i = mi + 1; i <= ma; i++){
            if(cnt[i] < 2){
                output("Impossible");
                return 0;
            }
        }
        output("Possible");
        return 0;
    }
    
    if(mi * 2 - 1 == ma){
        if(cnt[mi] != 2){
            output("Impossible");
            return 0;
        }
        for(int i = mi + 1; i <= ma; i++){
            if(cnt[i] < 2){
                output("Impossible");
                return 0;
            }
        }
        output("Possible");
        return 0;
    }
    
    output("Impossible");
    
    
    return 0;
}

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

using namespace std;

int main() {
  int N, K;

  cin >> N >> K;

  int L[60];
  for (int i = 0; i < N; ++i) {
    cin >> L[i];
  }

  sort(L, L + N, greater<int>());

  int ans = 0;
  for (int i = 0; i < K; ++i) {
    ans += L[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
#include <map>
#include <cstring>
#include <cassert>
#include <random>
 
using namespace std;

const int INF = 1<<29;
 
struct RBST_node{
    int val,ma,mi,size; //値，最小，最大，部分木サイズ
    RBST_node *l_child,*r_child;
     
    RBST_node(int v){
        val=ma=mi=v;
        size=1;
        l_child=r_child=NULL;
    }
};
typedef pair<RBST_node*, RBST_node*> P;
 
RBST_node* update(RBST_node* t){
    t->size = 1;
    t->ma = t->mi = t->val;
    if(t->l_child){
        t->size += t->l_child->size;
        t->ma = min(t->ma,t->l_child->ma);
        t->mi = min(t->mi,t->l_child->mi);
    }
    if(t->r_child){
        t->size += t->r_child->size;
        t->ma = min(t->ma,t->r_child->ma);
        t->mi = min(t->mi,t->r_child->mi);
    }
    return t;
}
 
RBST_node* merge(RBST_node* t1, RBST_node* t2){
    if(!t1) return t2;
    if(!t2) return t1;
     
    int m=t1->size, n=t2->size;
    if(rand() % (m+n) < m){
        t1->r_child = merge(t1->r_child,t2);
        return update(t1);
    }else{
        t2->l_child = merge(t1,t2->l_child);
        return update(t2);      
    }
}
 
int node_size(RBST_node* t){
    if(!t) return 0;
    else return t->size;
}
 
//[,pos) [pos,)のペアに分ける
P split(RBST_node* t,int pos){
    if(!t) return P(NULL,NULL);
    if(node_size(t->l_child)<pos){
        P tmp = split(t->r_child,pos-node_size(t->l_child)-1);
        t->r_child = tmp.first;
        return P(update(t),tmp.second);
    }else{
        P tmp = split(t->l_child,pos);
        t->l_child = tmp.second;
        return P(tmp.first,update(t));
    }
}
 
int lower_bound(RBST_node *t, int val){
    if(!t) return 0;
    if(t->val>val) return lower_bound(t->l_child,val);
    else if(t->val==val) return node_size(t->l_child);
    else return node_size(t->l_child)+1+lower_bound(t->r_child,val);
}
 
RBST_node* insert(RBST_node* t,int val,int pos){
    RBST_node *p = new RBST_node(val);
    P tmp = split(t,pos);
    RBST_node *l = merge(tmp.first,p),*r=tmp.second;
    return merge(l,r); 
}
 
//left:小, right:大 として適切な場所にinsert
RBST_node* insert(RBST_node* t,int val){
    int pos=lower_bound(t,val);
    return insert(t,val,pos);
}
 
RBST_node* erase(RBST_node *t,int pos){
    P tmp = split(t,pos);
    RBST_node *l =tmp.first;
    RBST_node *r = split(tmp.second,1).second;
    return merge(l,r);
}
 
int kth_min(RBST_node *t, int k){
    int cnt=node_size(t->l_child);
    if(cnt==k) return t->val;
    else if(cnt>k) return kth_min(t->l_child,k);
    else return kth_min(t->r_child,k-cnt-1);
}
 

 
int main(void){

    srand(time(NULL));
    RBST_node *root=NULL;

    int n;
    cin>>n;
    vector<int> x(n);
    for(int i=0;i<n;i++) cin>>x[i], root=insert(root,x[i]);

    for(int i=0;i<n;i++){
        root=erase(root,lower_bound(root,x[i]));
        cout<<kth_min(root,(n-1)/2)<<endl;
        root=insert(root,x[i]);
    }
 
    return 0;
 
}

Measured memory_bytes: 21760
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    sc.close();

    int[] k = new int[] {
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

    int ans = k[K - 1];
    System.out.println(ans);
  }
}


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

for i in range(1,n):
    al = max(0,ans[i-1][1] + a[i] - x)
    ans[i][0] = ans[i-1][0] + al
    ans[i][1] = a[i] - al
    
print(ans[n-1][0])

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

using namespace std;

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

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

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

const int N = 200003;

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

int gcd(int a, int b)
{
    if (!b) return a;
    return gcd(b, a % b);
}

int main()
{
    n = gi();
    LL ans = 0;
    for (int i = 1; i <= n; i+=1)
        for (int j = 1; j <= n; j+=1)
            for (int k = 1; k <= n; k+=1)
                ans += gcd(i, gcd(j, k));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=10**9+7
ix=0
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]>a[j]:
      ix+=1
ix=(ix*k)%m
ox=0
for i in range(n):
  for j in range(n):
    if a[i]>a[j]:
      ox+=1
ox=((ox*k*(k-1))//2)%m
print((ix+ox)%m)

Measured memory_bytes: 3188
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  set<int> b;
  for(int i=0; i<N; i++){
    int ai;
    cin >> ai;
    b.insert(ai);
  }
  while(b.size()>1){
    int m=*b.begin();
    set<int> c={m};
    for(int bi: b){
      if(bi%m>0) c.insert(bi%m);
    }
    b = move(c);
  }
  cout << *b.begin() << endl;
  return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N =2000+10;
const int mod=1e9+7;
#define P pair<int, int>

int main()
{
    ll n,x,y,ans;
    cin>>n;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
            x=i;
    }
    y=n/x;
    ans=x+y-2;
    cout<<ans<<"\n";
    return 0;
}


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


int main() {
   char a, b;
  cin >> a >> b;
  string ans = "No";
  if(a == '9' || b == '9') ans = "Yes";
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        if(n<1200) System.out.println("ABC");
        else if(n<2800) System.out.println("ARC");
        else System.out.println("AGC");
    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25212
#include<stdio.h>
using namespace std;
const int rootMaxN = 317; //316 < (10^5)^(1/2) < 317

int main()
{
    int N,Q;
    scanf("%d %d", &N, &Q);

    char s[N];
    scanf("%s", s);

    int count[N];
    int tempCount = 0;
    bool aCharFlag = false;
    
    for(int i = 0; i * rootMaxN < N; i++){
        count[i] = 0;
        tempCount = 0;
        aCharFlag = false;
        //methodに抜き出すべき
        for (int j = 0; j < rootMaxN + 1 && (i * rootMaxN + j < N); j++){//一つ多めに見る
            if (s[i * rootMaxN + j] == 'A'){
                aCharFlag = true;
            }else if (aCharFlag == true && s[i * rootMaxN + j] == 'C'){
                tempCount++;
                aCharFlag = false;
            }else{
                aCharFlag = false;
            }
        }
        count[i] = tempCount;
    }

    int l, r;
    int lBoxNo, rBoxNo;
    int tempTotalCount;
    for (int i = 1; i <= Q; i++){
        scanf("%d %d", &l, &r);
        lBoxNo = (l - 1) / rootMaxN;
        rBoxNo = (r - 1) / rootMaxN;

        tempTotalCount = 0;
      
        if (lBoxNo + 1 >= rBoxNo){ //lBoxNo == rBoxNo || lBoxNo + 1 == rBoxNo
            tempCount = 0;
            aCharFlag = false;
            for (int j = l - 1; j < r; j++){
                if (s[j] == 'A'){
                    aCharFlag = true;
                }else if (aCharFlag == true && s[j] == 'C'){
                    tempCount++;
                    aCharFlag = false;
                }else{
                    aCharFlag = false;
                }
            }
            tempTotalCount = tempCount;
        }else{
            tempCount = 0;
            aCharFlag = false;
            for (int j = l - 1; j <= (lBoxNo + 1) * rootMaxN; j++){
                if (s[j] == 'A'){
                    aCharFlag = true;
                }else if (aCharFlag == true && s[j] == 'C'){
                    tempCount++;
                    aCharFlag = false;
                }else{
                    aCharFlag = false;
                }
            }
            tempTotalCount = tempCount;
            
            for(int j = lBoxNo + 1; j < rBoxNo; j++){
                tempTotalCount += count[j];
            }

            tempCount = 0;
            aCharFlag = false;
            for (int j = rBoxNo * rootMaxN; j < r; j++){
                if (s[j] == 'A'){
                    aCharFlag = true;
                }else if (aCharFlag == true && s[j] == 'C'){
                    tempCount++;
                    aCharFlag = false;
                }else{
                    aCharFlag = false;
                }
            }            
            tempTotalCount += tempCount;
        }

        printf("%d\n", tempTotalCount);
    }
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#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 fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    rep(i,h){
        rep(j,w){
        bool f = false, g = false;
        if(i >= b) f = true;
        if(j >= a) g = true;
        if((f&&g) || ((!f) && (!g))) cout << 0;
        else cout << 1;
        }
        cout << endl;
    }
    return 0;
}


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

#define ll long long 
#define MAXN 200010
#define mod 1000000007

using namespace std;

int ans, n, minn = mod;

int a[MAXN];

int main(){
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++) {
		if (a[i] <= minn) {
			ans += 1;
			minn = a[i];
		}
	}
	cout << ans << endl;
	
	
	return 0;
} 

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

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

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    x = I()
    for a in range(1,1000):
        a5 = a**5
        for b in range(a+1):
            b5 = b**5
            if a5 + b5 == x:
                return JA([a,-b], " ")
            if a5 - b5 == x:
                return JA([a,b], " ")

    return -1


print(main())





Measured memory_bytes: 10848
fun main(args: Array<String>) {
    val s = readLine()!!
    if (!isPalindrome(s)) {
        return println("No")
    } else if (!isPartlyPalindrome(s)) {
        return println("No")
    } else if (!isLatterPartlyPalindrome(s)) {
        return println("No")
    }
    println("Yes")
}

fun isPalindrome(string: String): Boolean {
    for (i in 0 until string.length / 2) {
        if (string[i] != string[string.length - 1 - i]) return false
    }
    return true
}

fun isPartlyPalindrome(string: String): Boolean {
    return isPalindrome(string.substring(0, (string.length - 1) / 2))
}

fun isLatterPartlyPalindrome(string: String): Boolean {
    return isPalindrome(string.substring((string.length + 3) / 2 - 1, string.length))
}

Measured memory_bytes: 33792
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    long long n;
    long long d[50];
    long long ans = 0;

    cin >> n;
    for (long long i = 0; i < n; i++) {
        cin >> d[i];
    }
    for (long long i = 0; i < n; i++) {
        for (long long j = n - 1; j > i; j--) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
A = input()
B = input()
C = input()

x = A[0]

def turn(A, B, C, x):
  if x == 'a':
    if len(A) == 0:
      print('A')
      return
    else:
      y = A[0]
      A = A[1:]
      
  if x == 'b':
    if len(B) == 0:
      print('B')
      return
    else:
      y = B[0]
      B = B[1:]
  
  if x == 'c':
    if len(C) == 0:
      print('C')
      return
    else:
      y = C[0]
      C = C[1:]
  
  return turn(A, B, C, y)

turn(A, B, C, x)

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

int com(const void *a, const void *b){
  return *(int *)b - *(int *)a;
}


int main(){
  int n;
  cin >> n;
  int a[1000];
  rep(i,n){
    cin >> a[i];
  }
  qsort(a,n,sizeof(int),com);
  
  int tmp = -1;
  int answer = 0;
  rep(i,n){
    if(a[i] == tmp) continue;
    tmp = a[i];
    answer++;
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
# coding: utf-8

#A,B = input().split()
A,B,C = map(int, input().split())
K = int(input())

cnt=0
while 1:
    if not A<B:
        B=B*2
        cnt+=1
    else:
        break
    
while 1:
    if not B<C:
        C=C*2
        cnt+=1
    else:
        break
    
if cnt>K:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9172
#include<stdio.h>
int main()
{
int a,b,add,mul,sub;
    scanf("%d %d",&a,&b);
    add=a+b;sub=a-b;mul=a*b;
    if(add>=sub && add>=mul)
    {
        printf("%d",add);
    }
    else if(sub>=add && sub>=mul)
    {
        printf("%d",sub);
    }
    else if(mul>=add && mul>=sub)
    {
        printf("%d",mul);
    }
    else
    {
        printf("0");
    }
return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N,M,T;
vector<int> A,B,C;

pair<int,int> ans[100010];
int in[100010];

void update(int a,int b,int t){
  if(ans[a].first<t) ans[a]=mkp(t,b);
  else if(ans[a].first==t&&ans[a].second>b) ans[a]=mkp(t,b);
}

int main(){
  cin>>N>>M>>T;
  A.resize(M);
  B.resize(M);
  C.resize(M);
  rep(i,M) cin>>A[i]>>B[i]>>C[i];

  vector<int> last(N+1,0);
  for(int i=0;i<M;i++){
    if(C[i]==0) last[B[i]]=0;
    else last[B[i]]=1;
  }
  for(int i=1;i<=N;i++){
    if(last[i]>0){
      A.push_back(T);
      B.push_back(i);
      C.push_back(0);
    }
    if(i!=1) ans[i]=mkp(0,1);
    else ans[i]=mkp(0,2);
  }

  queue<int> Q;
  vector<vector<pair<int,int>>> v(N+1);
  for(int i=0;i<C.size();i++){
    if(C[i]==1){
      Q.push(B[i]);
      in[B[i]]=A[i];
      continue;
    }

    queue<int> nq;
    while(!Q.empty()){
      int t=Q.front();
      Q.pop();
      if(t!=B[i]){
        nq.push(t);
        int a=t,b=B[i];
        if(a>b) swap(a,b);
        int cost=A[i]-max(in[a],in[b]);
        v[a].push_back(mkp(b,cost));
        v[b].push_back(mkp(a,cost));
        //update(a,b,mp[mkp(a,b)]);
      }
    }

    while(!nq.empty()){
      Q.push(nq.front());
      nq.pop();
    }
  }

  vector<int> num(N+1,0);
  for(int i=1;i<=N;i++){
      for(int j=0;j<v[i].size();j++){
          num[v[i][j].first]+=v[i][j].second;
      }
      for(int j=0;j<v[i].size();j++){
          update(i,v[i][j].first,num[v[i][j].first]);
          num[v[i][j].first]=0;
      }
  }

  for(int i=1;i<=N;i++) cout<<ans[i].second<<endl;

  return 0;
}



Measured memory_bytes: 93044
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;cin>>K>>N;
  vector<int> C(2*K-1);
  C[0]=N-K+1;
  for(int i=0;i<2*K-1;++i){
    C[i+1]=C[i]+1;
    cout<<C[i]<<'\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define clr(a, x) memset(a, x, sizeof(a))
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define X first
#define Y second
#define fastin                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;

const int N = 505;
int c[N], s[N], f[N];

int main()
{
#ifndef ONLINE_JUDGE
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);
#endif
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++)
        cin >> c[i] >> s[i] >> f[i];
    for (int i = 0; i < n; i++)
    {
        int cur = 0;
        for (int j = i; j < n - 1; j++)
        {
            if (cur < s[j])
                cur = s[j];
            else
                cur = s[j] + (cur - s[j] + f[j] - 1) / f[j] * f[j];
            cur += c[j];
        }
        cout << cur << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=50+10;
string s;
bool flag;
int main(){
	cin>>s;
	if(s=="AKIHABARA")
		flag=true;
	if(s=="KIHABARA")
	flag=true;
	if(s=="AKIHBARA")
	flag=true;
	if(s=="AKIHABRA")
	flag=true;
	if(s=="AKIHABAR")
	flag=true;
	if(s=="KIHBARA")
	flag=true;
	if(s=="KIHABRA")
	flag=true;
	if(s=="KIHABAR")
	flag=true;
	if(s=="AKIHBRA")
	flag=true;
	if(s=="AKIHBAR")
	flag=true;
	if(s=="AKIHABR")
	flag=true;
	if(s=="KIHBRA")
	flag=true;
	if(s=="KIHBAR")
	flag=true;
	if(s=="KIHABR")
	flag=true;
	if(s=="AKIHBR")
	flag=true;
	if(s=="KIHBR")
	flag=true;
	if(flag==true)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;	
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    int n;
    scan(n);

    int[int] cnt;

    foreach (i ; 0 .. n) {
        int ai;
        scan(ai);
        cnt[ai]++;

        debug {
            writeln(cnt);
        }
    }

    int ans;

    foreach (n, v; cnt) {
        if (v & 1) ans++;
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 11388
#include <algorithm>
#include <climits>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main(){
    int N, M;
    while (cin >> N >> M, N) {
        vector<long long> P(N);
        for (int i=0; i<N; ++i) {
            cin >> P[i];
        }

        vector<long long> score_half(1, 0);
        for (int i=0; i<N; ++i) {
            score_half.push_back(P[i]);
            for (int j=0; j<N; ++j) {
                score_half.push_back(P[i] + P[j]);
            }
        }
        sort(score_half.begin(), score_half.end());

        long long res = 0;
        for (int i=0; i<(int)score_half.size(); ++i) {
            auto it = upper_bound(score_half.begin(), score_half.end(), M - score_half[i]);
            if (it != score_half.begin()) {
                res = max(res, score_half[i] + *(it-1));
            }
        }
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 18892
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int x, y;
  cin >> x >> y;
  if (x == y) dump(0);
  if (y > 0 && x > 0) {
    if (y > x) dump(y-x);
    else dump(x-y+2);
  }
  else if (y > 0 && x < 0) {
    x = -x;
    if (y > x) dump(y-x+1);
    else dump(x-y+1);
  }
  else if (y < 0 && x > 0) {
    x = -x;
    if (y > x) dump(y-x+1);
    else dump(x-y+1);
  }
  else if (y < 0 && x < 0) {
    if (y > x) dump(y-x);
    else dump(x-y+2);
  }
  else if (x == 0) {
    y > 0 ? dump(y) : dump(-y+1);
  }
  else if (y == 0) {
    x > 0 ? dump(x+1) : dump(-x);
  }
  return 0;
}


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

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 10 == 3) {
			cout << " " << i; continue;
		}
		int x = i;
		while (x) {
			x /= 10;
			if (x % 10 == 3) {
				cout << " " << i; break;
			}
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3104
/*
 Educational Dp Contest Atcoder
 
 */

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
//#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define all(x) x.begin(),x.end()

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}

const ll MOD =998244353;
const ll hell=1000000007;
const int INF=1e6;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=405;

ll dp[22][1<<21];int pr[22];int a[22][22];
int setbt[1<<21];
void solve()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];
    pr[0]=1;
    for(int i=1;i<=21;i++)
        pr[i]=pr[i-1]*2;
    dp[0][0]=1;
    for(int i=1;i<(1<<n);i++)
    {
        for(int j=0;j<n;j++)
            if(pr[j]&i)
            {
                setbt[i]=1+setbt[i^pr[j]];
                break;
            }
    }
    for(int i=1;i<=n;i++)
    {
        for(int mask=1;mask<(1<<n);mask++)
        {
            if(setbt[mask]!=i)
                continue;
            for(int j=0;j<n;j++)
                if((mask&pr[j])&&a[i-1][j])
                {
                    dp[i][mask]=(dp[i][mask]+dp[i-1][mask^pr[j]])%hell;
                }
        }
    }
    cout<<dp[n][(1<<n)-1]<<endl;
    
    
}

int32_t main()
{
    
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 319744
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int Inf = 1e9;
const double EPS = 1e-9;



int main()
{
  int h, w ;
  cin >> h >> w ;
  vector<string> str(h) ;
  
  REP(i,h){
    cin >> str.at(i) ;
    cout << str.at(i) <<endl ;
    cout << str.at(i) <<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 REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll mod = 1e9 + 7;

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

  string s;
  cin >> s;
  string a = s.substr(0, 4), b = s.substr(4, 11);
  cout << a + ' ' + b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,pair<int,int>>>v(m),ans(m);
  map<ll,int>cnt;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    v[i].first = a,v[i].second.first = b,v[i].second.second = i;
  }
  sort(all(v));
  rep(i,m){
    ans[i].first = v[i].second.second;
    ans[i].second.first = v[i].first;
    ans[i].second.second = cnt[v[i].first] + 1;
    cnt[v[i].first]++;
  }
  sort(all(ans));
  rep(i,m)printf("%06d%06d\n",ans[i].second.first,ans[i].second.second);
  return 0;
}


Measured memory_bytes: 10112
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------

ll n,m;
ll ans;

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

    ll a,b;
    a=n;
    b=m/2;

    ans=min(a,b);

    n-=ans;
    m-=ans*2;

    a=m/4;

    ans+=a;





    /*
    for(;;){
        if(n && m>=2){
            n--;
            m-=2;
            ans++;
        }else if(m>=4){
            m-=4;
            ans++;
        }else{
            break;
        }
    }*/
    
    cout<<ans<<endl;

    





    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
#define Rep(i, j, k) for(R int i = (j), ED = (k); i >= ED; --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread (buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar (x % 10 | 48);
	}

	inline void wrn ( ll x ) { write (x); putchar (' '); }

	inline void wln ( ll x ) { write (x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn (x), wln (y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	ll n, A, B;
	
	int main() {
		n = read(), 
		
		A = read(), B = read();
		return wln (min (n * A, B)), 0;
	}
	
}

int main()
{
	return Cesare::main();
}

/*

*/






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

int main(){
    ll n;
    cin >> n;
    int rn = (int)sqrt(n);
    // printf("%d\n", rn);
    ll sum = 0;
    for(int i=1;i<=rn;i++){
        if(n%i==0 && (n/i-i!=1) && i!=n/i){
            sum += n/i-1;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	private static String dreamer = "dreamer";
	private static String dream = "dream";
	private static String erase = "erase";
	private static String eraser = "eraser";
			
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] wordList = new String[] {
			eraser, erase, dreamer, dream
		};
		
		String input = sc.nextLine();
		for (String s: wordList) {
			input = input.replace(s, ".");
		}
		
		for (int i = 0; i < input.length(); i++) {
			if (input.charAt(i) != '.') {
				System.out.println("NO");
				return;
			}
		}
		
		System.out.println("YES");
		
	}
	
}


Measured memory_bytes: 16700
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

int main()
{
    string S;
    io >> S;
    if (S[S.size()-1] == 's')
    {
        io << S << "es" << BR;
    }
    else
    {
        io << S << "s" << BR;
    }
    return 0;
}


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

struct edge {
    int from, to;
    string cost;
};

using edges = vector<edge>;

string solve(edges const& es, int s, int t, const int V) {
    vector<string> d(V, "NO");
    d[t] = "";
    for(int i=0; i<6*V; ++i) {
        auto tmp = d;
        for(auto& e : es) {
            if(tmp[e.to] != "NO" && (tmp[e.from] == "NO" || tmp[e.from] > e.cost + tmp[e.to])) {
                tmp[e.from] = e.cost + tmp[e.to];
                if(i >= V && e.from == s) {
                    return "NO";
                }
            }
        }
        d.swap(tmp);
    }
    return d[s];
}

int main() {
    int n, a, s, g;
    while(cin >> n >> a >> s >> g, n) {
        edges es(a);
        for(int i=0; i<a; ++i) {
            cin >> es[i].from >> es[i].to >> es[i].cost;
        }
        cout << solve(es, s, g, n) << endl;
    }
}


Measured memory_bytes: 3712
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String []args)
	{
		Scanner in =new Scanner(new BufferedInputStream(System.in));
		while(in.hasNext())
		{
			BigInteger a = in.nextBigInteger(),b = in.nextBigInteger();
			System.out.println(a.remainder(b));
		}
		in.close();
	}
}



Measured memory_bytes: 26544
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d; cin >> d;
  long n; cin >> n;
  int i = 0;
  if(n == 100) n =101;
    while(i < d){
      n *= 100;
      i++;
    }
  cout << n;
}
  

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
int main(){
  int n,t;
  char str[20];
  scanf("%s",str);
  n=strlen(str);
  for(t=n-1;t>=0;t--){
    printf("%c",str[t]);
  }
  printf("\n");
  return (0);
}

Measured memory_bytes: 524
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const char c[]={"snuke"};
char s[15];int n,m;
int main(){
	scanf("%d%d",&n,&m);
	fp(i,1,n)fp(j,1,m){
		scanf("%s",s);
		bool flag=1;
		fp(k,0,4)if(s[k]!=c[k]){flag=0;break;}
		if(flag)return printf("%c%d\n",j-1+'A',i),0;
	}
	return 233;
}

Measured memory_bytes: 256