akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  char s[n+1];
  scanf("%s", s);
  int ans = 0;
  for (int i=1; i<n-1; i++) {
    int alph[26] = {0}, cnt = 0;
    for (int j=0; j<i; j++) alph[s[j]-'a']++;
    for (int j=i; j<n; j++) {
      if (alph[s[j]-'a']!=0) {
        cnt++;
        alph[s[j]-'a'] = 0;
      }
    }
    ans = (ans < cnt) ? cnt : ans;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
struct R{int c,t;}a[200050];
bool cmp(R a,R b){return a.t>b.t;};
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].c,&a[i].t);
	sort(a+1,a+n+1,cmp);
	long long t=a[1].t;
	for(int i=1;i<=n;i++)
		t=min(t-a[i].c,1ll*a[i].t-a[i].c);
	if(t<0)puts("No");
	else puts("Yes");
}

Measured memory_bytes: 1792
a = input()
b = len(list(a))
c = int(a)
d = ''

if b % 2 == 0:
    d = '9' * (b // 2)
    print('0'.join(d))

else:
    if b == 1:
        print(a)
    else:
        d = '9' * (b // 2)
        d = '0'.join(d)
        d = int(d + '0')
        print(c - d)

Measured memory_bytes: 3060
x = int(input())
if x < 100:
    print(0)
else:
    s = x//100
    r = x%100
    s5 = r//5
    r5 = r%5
    if r == 0:
        print(1)
    else:
        if r5 == 0:
            if s5 <= s:
                print(1)
            else:
                print(0)
        else:
            if s5+1 <= s:
                print(1)
            else:
                print(0)




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

int main(){
    int n;
    cin>>n;
    int count_max=0;
    int max=1;      // 求める整数

    for(int i=1; i<n+1; i++){
        int count=0;
        int j=i;
        while(j%2==0){
            j/=2;
            count++;
        }
        if(count>count_max){
            count_max=count;
            max=i;
        }
    }

    cout<<max<<endl;
}

Measured memory_bytes: 256
while True:
  try:
    line = map(int, raw_input().split(","))
  except:
    break
  sum = 0
  rail = []
  for x in line[0:10]:
    sum += x
    rail.append(sum)
  cross = sum * (line[10] * 1.0 / (line[10] + line[11]))
  for i, length in enumerate(rail):
    if cross <= length:
      print i+1
      break

Measured memory_bytes: 4228
let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m

module IntTripleMap = Map.Make (struct
  type t = int * int * int
  let compare = compare
end)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let m =
    Array.fold_left (fun m a ->
      IntTripleMap.fold (fun (r, g, b) n m ->
        let m =
          if r <> a then m else 
          IntTripleMap.add (r + 1, g, b) 
          (n +^
            try IntTripleMap.find (r + 1, g, b) m
            with Not_found -> 0) m in
        let m =
          if g <> a then m else 
          IntTripleMap.add (r, g + 1, b) 
            (n +^
              try IntTripleMap.find (r, g + 1, b) m
              with Not_found -> 0) m in
        let m =
          if b <> a then m else 
          IntTripleMap.add (r, g, b + 1) 
            (n +^
              try IntTripleMap.find (r, g, b + 1) m
              with Not_found -> 0) m in
        m) m IntTripleMap.empty) (IntTripleMap.singleton (0, 0, 0) 1) as_ in
  Printf.printf "%d\n" @@
  IntTripleMap.fold (fun _ -> ( +^ )) m 0



Measured memory_bytes: 5376
N = int(input())
ans = 0
if N < 7:
    print(1)
    exit()
elif N < 12:
    print(2)
    exit()

if N%11 > 6:
    ans += 2
elif N % 11 < 7 and N % 11 != 0:
    ans += 1
print((N//11)*2+(ans))

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

int main()
{
    int num1, num2, num3;
    
    cin >> num1 >> num2 >> num3;
    if (num1 < num2){
        if(num2<num3){
            cout << "Yes" << '\n';
        }else{
           cout << "No" << '\n'; 
        }
        
    }else{
        cout << "No" << '\n';
    }
   
   
   
   
   
    
    return 0;
}


Measured memory_bytes: 3080
fn read() -> (i32, i32) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let vec: Vec<i32> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (n, m) = read();
    println!("{}", (n - 1) * (m - 1))
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  double a, b;
  cin >> a >> b;
  double p, q, r;
  cin >> p >> q >> r;
  double res = b + (b * p - (b - a) * q) / (q + r);
  cout << fixed << setprecision(15) << res << '\n';
}



Measured memory_bytes: 3308
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int n;
    cin >> n;
    
    int ans = -1;
    
    int x = n/1.08;
    int y = (n+1)/1.08;
    
    
    if (x*1.08 >= n && x*1.08 < n+1){
        ans = x;
    }
    
    if (y*1.08 >= n && y*1.08 < n+1){
        ans = y;
    }

    if (ans == -1){
        cout << ":(" << endl;
    }
    else {
        cout << ans  << endl;
    }
}


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

using namespace std;

using ll = long long;

//1-indexであることに注意
template <typename T>
struct BIT {
    int n;
    vector<T> data;
    int n_msb;

    BIT(int n) : n(n), data(n + 1, 0) {
        n_msb = 1;
        while (n_msb <= n) n_msb <<= 1;
        n_msb >>= 1;
    }

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

    void add(int i, T x) {
        while (i <= n) {
            data[i] += x;
            i += i & -i;
        }
    }

    // sum(i) >= val となる最小のiを返す
    // ただし、sum(i)は広義単調増加すると仮定
    int lower_bound(T val) {
        if (val <= 0) return 0;

        int res = 0;
        for (int k = n_msb; k > 0; k >>= 1) {
            if (res + k <= n && data[res + k] < val) {
                val -= data[res + k];
                res += k;
            }
        }
        return res + 1;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> l(n), r(n);
    vector< vector<int> > v(m + 1);
    for (int i = 0; i < n; i++) {
        cin >> l[i] >> r[i];
        v[r[i] - l[i] + 1].push_back(i);
    }

    BIT<int> b(m + 1);
    int cnt = n;
    for (int d = 1; d <= m; d++) {
        int ans = cnt;
        if (d > 1) {
            for (int i = d; i <= m; i += d) {
                ans += b.sum(i);
            }
        }

        cout << ans << "\n";

        for (int i : v[d]) {
            b.add(l[i], 1);
            b.add(r[i] + 1, -1);
            cnt--;
        }
    }
    return 0;
}

Measured memory_bytes: 9088
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <stdlib.h>
#include <algorithm>
#include <limits.h>
#include <string>
#include <iostream>

using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, l = 0, mini=LLONG_MAX;
	long long N, K, x[100000];
	cin >> N >> K;
	for (i = 0; i < N; i++) {
		cin >> x[i];
	}

	for (i = 0; i < N-K+1; i++) {
		if ((x[i] < 0) && (x[K - 1 + i] > 0))
			ans = 2 * min(llabs(x[i]), llabs(x[K + i - 1])) + max(llabs(x[i]), llabs(x[K + i - 1]));
		else if (x[i] >= 0)
			ans = llabs(x[K + i - 1]);
		else
			ans = llabs(x[i]);

		if (mini > ans)
			mini = ans;
	}

	cout << mini << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;

int main(){
    int n;
    cin>>n;
    int arr[n];
    int k=1;
    int ans=0;
    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        if(a==k) {
            k++;
            ans++;
        }
    }
    if(ans>0) cout<<n-ans;
    else cout<<-1;
}

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

#define N 150000
#define MAX 1500000

int main(void) {
  int n;  //数列の長さ（要素の数）
  long sum1 = 0;  //奇数番目の要素の合計値
  long sum2 = 0;  //偶数番目の要素の合計値
  long tmp; //1, -1の繰り返し計算用temp
  long lcount = 0;  //奇数+, 偶数-のパターン
  long rcount = 0;  //奇数-, 偶数+のパターン
  long a[N]; //入力各要素（数字）
  char input[MAX];  //入力文字列
  int i = 0,j = 0;  //for文用（jは使ってない）
  int cp = 0,tcp = 0; //tp, input用の何文字目かを示すカウンタ
  char tp[12];  //入力処理用のtemp
  tp[12] = '\0';  //初期化
  fgets(input, MAX, stdin);
  n = atoi(input);  //nに入力を受け取る

  fgets(input, MAX, stdin);  //各要素を受け取る

  //printf("%s\n",input);
  for(i = 0; i < n;  i++){
    while(input[cp] != ' ' && input[cp] != '\n'){ //スペースまで入力を切る
      tp[tcp] = input[cp];
      tcp++;
      cp++;
    }
    tp[tcp] = '\0';
    tcp = 0;
    cp++;
    a[i] = atoi(tp);
    //printf("i:%d tp:%s a[%d]:%d\n",i,tp,i,a[i]);

  }
  //init
/*  for(i = 0; i < n; i++){ //要素を偶奇番目毎に足し合わせる
    if(i % 2 == 0) sum2 += a[i];
    else sum1 += a[i];
    //printf("%d %d %d %d\n",i,a[i],sum1,sum2 );
  }*/
  tmp = 0;
/*  if(sum1 == sum2){
    if(a[0] < 0){
      sum1++;
    }else{
      sum2++;
    }
  }*/
  for(i = 0; i < n; i++){ //偶数番目が-1以下になるまで引いて操作カウントをインクリメント
      if(i % 2 == 0){
        tmp += a[i];
        if(tmp > -1){
          lcount += tmp + 1;
          tmp = -1;
          //printf("hoge1\n" );
        }
      } else {  //奇数番目が1以上になるまで足して操作カウントをインクリメント
        tmp += a[i];
        if(tmp < 1){
          lcount += 1 - tmp;
          tmp = 1;
          //printf("hoge2\n" );
        }
      }
  }
  tmp = 0;
  for(i = 0; i < n; i++){ //奇数番目が-1以下になるまで引いて操作カウントをインクリメント
      if(i % 2 == 1){
        tmp += a[i];
        if(tmp > -1){
          rcount += tmp + 1;
          tmp = -1;
          //printf("hoge3\n" );
        }
      } else {  //偶数番目が1以上になるまで足して操作カウントをインクリメント
        tmp += a[i];
        if(tmp < 1){
          rcount += 1 - tmp;
          tmp = 1;
          //printf("hoge4\n" );
        }
      }
  }
  printf("%ld\n",lcount > rcount?rcount:lcount);  //l>rならr, そうでないならl（rの砲方が小さいならr）
  return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	int a;
	int price[N];
	int sum=0;
	int tmp;
	for (int i = 0; i < N; i++) {
		cin >> a;
		price[i] = a;
	}

	for (int i = 0; i < N-1;i++) {
		for (int j = N-1; j >= i+1;j--) {
			if (price[j]<price[j-1]) {
				tmp = price[j];
				price[j] = price[j - 1];
				price[j - 1] = tmp;
			
			}
			
		}
	
	}

	for (int i = 0; i < K;i++) {
	
		sum += price[i];
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	int ans=0;
	cin >>s;
	if(s[1]=='B'){
		s[1]='R';
	}else{
		s[1]='B';
	}
	cout<<s<<endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int x = scan.nextInt() / 50;
		int count = 0;
		for(int i=0; i<=a; i++){
			for(int j=0; j<=b; j++){
				for(int k=0; k<=c; k++){
					if(10*i + 2*j + k == x){
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 35788
#include <bits/stdc++.h>
using namespace std;
 
typedef long long               ll;
typedef long double             ld;
 
 
#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define pii              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(ll i=ll(a);i<ll(b);i++)
#define forn(i,a,b)      for(ll i=ll(a);i>ll(b);i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807
 
ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
} 
 
ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}
 
void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

int solve()
{
	int n;
	si(n);
	int ara[2][n];
	forr(i,0,2) forr(j,0,n) si(ara[i][j]);
	forr(i,1,n)
	{
		ara[0][i]+=ara[0][i-1];
		ara[1][n-i-1]+=ara[1][n-i];
	}
	
	int ans=-1;
	forr(i,0,n)
	{
		int temp=ara[0][i]+ara[1][i];
		ans=max(ans,temp);
	}
	pi(ans);
	
	return 0;
}
	
 
int main()
{   
 
//    racecar;
//    cout<<fixed<<setprecision(6);
//    fileio();
    solve();
}
 
 
 
///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n


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

using namespace std;

double dp[301][301][301];

double sushi(int n, int x, int y, int z){
	if(x==0 && y==0 && z==0){
		return 0;
	}

	if(x<0 || y<0 || z<0){
		return 0;
	}

	if(dp[x][y][z] > -0.9){
		return dp[x][y][z];
	}

	double res = n + x*sushi(n, x-1, y, z) + y*sushi(n, x+1, y-1, z) + z*sushi(n, x, y+1, z-1);
	return dp[x][y][z] = res/(x+y+z);
}

int main(){
	memset(dp, -1, sizeof(dp));

	int n;
	cin >> n;

	int a[n];
	int ones=0, twos=0, threes=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		switch(a[i]){
			case 1:
				ones++;
				break;
			case 2:
				twos++;
				break;
			case 3:
				threes++;
				break;
		}
	}

	cout << setprecision(10) << sushi(n, ones, twos, threes);
	return 0;
}

Measured memory_bytes: 216872
/**
 *    author:  tourist
 *    created: 27.01.2020 01:09:52       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long r, b;
  cin >> r >> b;
  auto Count = [&](long long p, long long q, long long bound) {
    long long sx = 0;
    long long sy = 0;
    long long cnt = 0;
    for (long long x = 0; x * p <= bound; x++) {
      long long y = (bound - x * p) / q;
      sx += x * (y + 1);
      sy += y * (y + 1) / 2;
      cnt += y + 1;
    }
    return make_tuple(sx, sy, cnt);
  };
  auto Test = [&](long long p, long long q) {
    bool inv = false;
    if (p < q) {
      swap(p, q);
      swap(r, b);
      inv = true;
    }
    long long low = 0, high = 1;
    while (true) {
      auto got = Count(p, q, high);
      if (get<0>(got) * p + get<1>(got) * q > r * p + b * q) {
        break;
      }
      low = high;
      high <<= 1;
    }
    while (low + 1 < high) {
      long long mid = (low + high) >> 1;
      auto got = Count(p, q, mid);
      if (get<0>(got) * p + get<1>(got) * q > r * p + b * q) {
        high = mid;
      } else { 
        low = mid;
      }
    }
    auto got = Count(p, q, low);
    long long sx = get<0>(got);
    long long sy = get<1>(got);
    long long cnt = get<2>(got);
    long long s = sx * p + sy * q;
    long long add = (r * p + b * q - s) / high;
    long long x = 0;
    while ((high - x * p) % q != 0) {
      ++x;
    }
    sx += x * add + q * (add * (add - 1) / 2);
    long long y = (high - x * p) / q;
    while (y >= p) {
      x += q;
      y -= p;
    }
    sy += y * add + p * (add * (add - 1) / 2);
    cnt += add;
    if (sx <= r && sy <= b) {
      cout << cnt - 1 << '\n';
      exit(0);
    }
    bool ret = (sx > r) ^ inv;
    if (inv) {
      swap(r, b);
    }
    return ret;
  };
  long long p0 = 0, q0 = 1;
  long long p1 = 1, q1 = 0;
  while (true) {
    long long low = 0, high = 1;
    while (true) {
      if (!Test(p0 + high * p1, q0 + high * q1)) {
        break;
      }
      low = high;
      high <<= 1;
    }
    while (low + 1 < high) {
      long long mid = (low + high) >> 1;
      if (!Test(p0 + mid * p1, q0 + mid * q1)) {
        high = mid;
      } else {
        low = mid;
      }
    }
    p0 += low * p1;
    q0 += low * q1;
    p1 += p0;
    q1 += q0;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	//iとjはループ変数、heightは縦の長さ、widthは横の長さ
	int i, j;
	int height, width;

	//heightとwidthがともに0ならループ終了
	while((height != 0) || (width != 0)){
		scanf("%d %d", &height, &width);
		//heightかwidthが0ならば何も出力しない
		if((height > 0) && (width > 0)){
			for(i = 0; i < height; i++){
				for(j = 0; j < width; j++){
					if((i % 2) == 0){
						if((j % 2) == 0){
							printf("#");
						}
						else{
							printf(".");
						}
					}
					else{
						if((j % 2) == 0){
							printf(".");
						}
						else{
							printf("#");
						}
					}
				}
				printf("\n");
			}
			printf("\n");
		}
	}

	return 0;
}


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

int main(){
    int Alice = 0, Bob = 0, N;
    cin >> N;

    vector<int> card(N);
    for (int i = 0; i < N; i++){
        cin >> card.at(i);
    }
    sort(card.begin(), card.end());
    reverse(card.begin(), card.end());

    for (int i = 0; i < N; i += 2){
        Alice += card.at(i);
    }
    for (int i = 1; i < N; i += 2){
        Bob += card.at(i);
    }
    cout << Alice - Bob << endl;

}

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

int N;
int forans[4] = {10,50,100,500};

int charge_coins(int n) {
  int num = 0,a[4];
  for(int i = 0; i < 4; i++ ) {
    a[i] = n / forans[3-i];
    n -= a[i]*forans[3-i];
	num += a[i];
  }
  return num;
}

int solve(int n) {
  int ans[4];
  int input[4];
  int payment, charge,reduction_coins;
  int reduction_coins_max = -1000;
  for(int i = 0; i < 4; i++ ) {
    cin >> input[i];
  }
  for(int i = 0; i < input[0]+1; i++ ) {
    for(int j = 0; j < input[1]+1; j++ ) {
      for(int k = 0; k < input[2]+1; k++ ) {
        for(int m = 0; m < input[3]+1; m++ ) {
		  payment = 500*m + 100*k + 50*j + 10*i;
		  charge = payment - n;
		  if(charge < 0) continue;
		  reduction_coins = i + j + k + m - charge_coins(charge);
		  if(reduction_coins_max < reduction_coins) {
		    ans[0] = i;
			ans[1] = j;
			ans[2] = k;
			ans[3] = m;
			reduction_coins_max = reduction_coins;
		  }
        }
      }
    }
  }
  
  for(int i = 0; i < 4; i++ ) {
    if(ans[i] != 0) cout << forans[i] << ' ' << ans[i] << endl;
  }
  return 0;
}

int main() {
  cin >> N;
  while(N != 0) {
    solve(N);
	cin >> N;
	if(N != 0) cout << endl;
  }
}


Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 100010;
typedef long long LL;

int a1[N], a2[N], a3[N], a[N], n;
bool vis[N];

int bl[N], br[N], f[N], tg0[N], tg1[N];

void add(int *b, int x, int c) { for (; x <= n; x += x & (-x)) b[x] += c;}
int query(int *b, int x) { int ret = 0; for (; x > 0; x -= x & (-x)) ret += b[x]; return ret;}

int main()
{
	scanf("%d", &n);
	Rep(i, n) scanf("%d", &a1[i]);
	Rep(i, n) scanf("%d", &a2[i]);
	Rep(i, n) scanf("%d", &a3[i]);
	Rep(i, n) {
		if (a2[i] == a1[i] + 1 && a3[i] == a2[i] + 1 && !(a3[i] % 3)) 
			a[i] = a3[i] / 3;
		else if (a2[i] == a1[i] - 1 && a3[i] == a2[i] - 1 && !(a1[i] % 3)) 
			a[i] = a1[i] / 3, f[i] = 1;
		else {printf("No\n"); return 0;}
		if ((a[i] & 1) != (i & 1) || vis[a[i]]) { printf("No\n"); return 0;}
		vis[a[i]] = true;
		//printf("%d %d %d\n", i, a[i], f[i]);
	}
	
	LL n0 = 0, n1 = 0, t1 = 0, t0 = 0;
	
	for (int i = 1; i <= n; i += 2) add(br, a[i], 1);
	for (int i = 1; i <= n; i += 2) {
		add(br, a[i], -1);
		int tmpl = query(bl, n) - query(bl, a[i]), tmpr = query(br, a[i]);
		f[i] ^= ((tmpl + tmpr) & 1), n1 += tmpl;
		if (f[i]) t1 ++;
		add(bl, a[i], 1);
	}
	
	memset(bl, 0, sizeof(bl)); memset(br, 0, sizeof(br));
	for (int i = 2; i <= n; i += 2) add(br, a[i], 1);
	for (int i = 2; i <= n; i += 2) {
		add(br, a[i], -1);
		int tmpl = query(bl, n) - query(bl, a[i]), tmpr = query(br, a[i]);
		f[i] ^= ((tmpl + tmpr) & 1), n0 += tmpl;
		if (f[i]) t0 ++;
		add(bl, a[i], 1);
	}
	
	if ((n1 & 1) == (t0 & 1) && (n0 & 1) == (t1 & 1)) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}
/*
5
9 6 15 12 1
8 5 14 11 2
7 4 13 10 3
*/

Measured memory_bytes: 2944
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        boolean[] sieve = sieve(100000 + 10);
        int[] like = new int[100000 + 10 + 1];
        like[0] = 0;
        like[1] = 0;
        like[2] = 0;
        for (int i = 3; i < 100000 + 10; i += 2) {
            if (sieve[i] == true && sieve[(i + 1) / 2] == true) {
                like[i] = like[i-2] + 1;
            } else {
                like[i] = like[i-2];
            }
        }

        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();

            int ans = 0;
            if (l == 1) ans = like[r];
            else ans = like[r] - like[l - 2];
            System.out.println(ans);
        }
    }

    public static boolean[] sieve(int n) {
        final boolean[] sieve = new boolean[n+1];
        sieve[0] = false;
        sieve[1] = false;
        sieve[2] = true;

        for (int i = 3; i <= n; i += 2) {
            sieve[i] = true;
        }

        for (int i = 3; i * i <= n; i += 2) {
            if (sieve[i]) {
                for (int j = i * 2; j <= n; j += i) {
                    sieve[j] = false;
                }
            }
        }

        return sieve;
    }
}


Measured memory_bytes: 64216
import sys 
from functools import reduce
from math import gcd
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 10 ** 9 + 7
N = int(readline())
A = list(map(int,readline().split()))
lcm = reduce(lambda x,y:x*y//gcd(x,y),A)
ans = 0
ans = sum(lcm//x for x in A)
print(ans%mod)

Measured memory_bytes: 10516
// https://atcoder.jp/contests/abc106/tasks/abc106_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

vector<int64_t> divisor(int64_t n) {
    vector<int64_t> ret;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    int cnt = 0;
    for (int i = 105; i <= N; i += 2) {
        auto t = divisor(i);
        cnt += t.size() == 8;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3584
import java.util.*;

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

        if(a >= 3200)
            System.out.println(s);
        else
            System.out.println("red");
        
    }
}

Measured memory_bytes: 21844
#include<iostream>
#define MOD 1000000007
using namespace std;

int main(){
    long long n,k;
    cin>>n>>k;
    long long cnt=0;
    for(long long i=k;i<=n+1;i++){
        long long min=(i-1)*i/2;
        long long max=(2*n-i+1)*i/2;
        cnt+=max-min+1;
        cnt%=MOD;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3636
import scala.annotation.tailrec

object Main extends App {

  import scala.io.StdIn._
  solve
  @tailrec
  def solve: Unit = {
    val n = readLine.trim.toInt
    if (n == 0) return
    var edges = List.tabulate(n){_ ⇒
      val Array(a, b, c) = readLine.trim.split(' ').map(_.toInt)
      (a, b, c)
    }
    val citySize = edges.flatMap{i ⇒ List(i._1, i._2)}.max + 1
    val minDistance: Array[Array[Long]] = Array.tabulate(citySize){f ⇒
      Array.tabulate(citySize){t ⇒ if (f == t) 0L else Int.MaxValue.toLong}
    }
    for ((a, b, c) ← edges){
      minDistance(a)(b) = math.min(minDistance(a)(b), c)
      minDistance(b)(a) = math.min(minDistance(b)(a), c)
    }
    for (k ← 0 until citySize; i ← 0 until citySize; j ← 0 until citySize if minDistance(i)(j) > minDistance(i)(k) + minDistance(k)(j)){
      minDistance(i)(j) = minDistance(i)(k) + minDistance(k)(j)
    }
    println(minDistance.indices.minBy(i ⇒ minDistance(i).sum).let{i ⇒ s"$i ${minDistance(i).sum}"})
    solve
  }

  implicit class Extention[T](value :T){
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 44632
#include<iostream>

using namespace std;

int ans = 0;
void dfs(int n,int s,int d){
	if (s < 0) return;
	if (s == 0 and n == 0){
		ans++;
		return;
	}
	if (n == 0) return;	
	d++;
	if (d == 10)return;
	//???????????´???
	dfs(n-1,s-d,d);
	//?????°????????£?????´???
	dfs(n,s,d);
return;
}

int main(){
	int n,s; cin >> n >> s;
	while (!(n == 0 and s == 0)){
		dfs(n,s,-1);
		cout << ans << endl;
		ans = 0;
		cin >> n >> s;
	}

return 0;
}

Measured memory_bytes: 2980
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#pragma comment(linker,"/STACK:102400000,102400000")
#define INF 0x3f3f3f3f
#define maxm 1500
typedef long long ll;
using namespace std;
int mp[maxm][maxm]{0};
int t[maxm][maxm]{0};
int calRectangle(int (&vec)[maxm],int w,int time)
{
    int result=0;
    stack<int> stk;
    vec[w+1]=0;
    //if(true){for(int i=1;i<=w;i++)cout<<vec[i]<<" ";cout<<endl;}
    for(int i=1;i<=w+1;)
    {
        if(stk.empty()/*Stuck is empty*/||vec[stk.top()]<=vec[i]/*The list upper*/)
        {
            stk.push(i);/*Stuck <- i(pointer)*/
            i++;
        }
        else
        {
            int temp=stk.top();/*Save the topStuck pointer*/
            stk.pop();/*Find the former pushed pointer*/
            result=max(result,vec[temp]*(stk.empty()?(i-1):(i-stk.top()-1)));
            //i--;/*Keep the value of i(i--++=1)*/
        }
    }
    //cout<<result<<endl;
    return result;
}
int main()
{
    int h,w,pt,res=0;
    cin>>h>>w;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            cin>>mp[i][j];
    for(int j=1;j<=w;j++)
    {
        pt=1;
        for(int i=1;i<=h;i++)
            if(!mp[i][j])
                t[i][j]=pt++;
            else
            {
                t[i][j]=0;
                pt=1;
            }
    }
    //for(int i=1;i<=h;i++){for(int j=1;j<=w;j++)cout<<t[i][j]<<" ";cout<<endl;};
    for(int i=1;i<=h;i++)
        res=max(res,calRectangle(t[i],w,i));
    cout<<res<<endl;
    return 0;
}
//Do not use memset !



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

using namespace std;

short A[2000001],B[2000001];
int C[10002];

int main(){
    int n;
    int max = 0;
    scanf("%d",&n);
    
    for (int i = 0; i < 10002; i++) {
        C[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        scanf("%d",&A[i]);
        if (A[i] > max) {
            max = A[i];
        }
        C[A[i]]++;
    }
    for (int i = 1; i <= max; i++) {
        C[i] += C[i-1];
    }
    for (int i = 0; i < n; i++) {
        B[C[A[i]]-1] = A[i];
        C[A[i]]--;
    }
    for (int i = 0; i < n-1; i++){
        printf("%d ",B[i]);
    }
    printf("%d\n",B[n-1]);
    
    return 0;
}

Measured memory_bytes: 9044
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
from functools import lru_cache, reduce
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# ここから書き始める
n = int(input())
t = list(map(int, input().split()))
m = int(input())
total = sum(t)
ans = [0] * m
for i in range(m):
    p, x = map(int, input().split())
    ans[i] = total - t[p - 1] + x
for i in range(m):
    print(ans[i])

Measured memory_bytes: 5056
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int main() {
  vector<int> R[100000];
  queue<int> Q;
  int n,m,s,t,q;
  int visit[100000];

  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> s >> t;
    R[s].push_back(t);
    R[t].push_back(s);
  }
  
  for(int j=0;j<n;j++) visit[j] = 0;
  for(int i=0;i<n;i++){
    if(visit[i] == 0){
      Q.push(i);
      while(Q.empty() == false){
	int u = Q.front();
	Q.pop();
	visit[u] = 1;
	for(int j=0;j<R[u].size();j++){
	  int v = R[u][j];
	  if(visit[v]==0)Q.push(v);
	}
	R[u].clear();
	R[u].push_back(i);
      }
    }
  }
    
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> s >> t;
    if(R[s][0] == R[t][0]) cout << "yes" << endl;
    else cout << "no" << endl;
  }


  return 0;
}

Measured memory_bytes: 7156
#include<bits/stdc++.h>
const int maxn=85,maxs=6400;
using namespace std;
int i,j,k,n,m;
int a[maxn][maxn];
bool s[maxn][maxn][maxs*2+1];
int main(){
	cin>>n>>m;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++){
			int S;
			scanf("%d",&S);
			a[i][j]-=S;
			a[i][j]=abs(a[i][j]);
		}
	s[1][1][maxs+a[1][1]]=1;
	s[1][1][maxs-a[1][1]]=1;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++){
			if(i+j==2)continue;
			for(k=0;k<=maxs*2;k++){
				if(k-a[i][j]>=0)
					s[i][j][k] |= (s[i-1][j][k-a[i][j]]|s[i][j-1][k-a[i][j]]);
				if(k+a[i][j]<=maxs*2)
					s[i][j][k] |= (s[i-1][j][k+a[i][j]]|s[i][j-1][k+a[i][j]]);
			}
		}
	int ans=1e9;
	for(i=0;i<=maxs*2;i++)
		if(s[n][m][i])ans=min(ans,abs(i-maxs));
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    cout << (N + 1) / 2 << endl;
    return 0;
}

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

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

if(x <= 599) cout << "8" << endl;
else if(x <= 799) cout << "7" << endl;
else if(x <= 999) cout << "6" << endl;
else if(x <= 1199) cout << "5" << endl;
else if(x <= 1399) cout << "4" << endl;
else if(x <= 1599) cout << "3" << endl;
else if(x <= 1799) cout << "2" << endl;
else if(x <= 1999) cout << "1" << endl;

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> pl;


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

  int cnt=0;
  for(int i=0;i<n;i++){
    int h;
    cin>>h;
    if(h>=k)
    cnt++;
  }
  cout<<cnt<<endl;

}


Measured memory_bytes: 256
N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 0 and temp != 1:
        arr.append([temp, 1])

    if not arr and n != 0 and n != 1:
        arr.append([n, 1])

    return arr

arr = factorization(N)
ans = 0
for i in range(len(arr)):
    for j in range(arr[i][1]):
        if j / 2 * (j + 3) + 1 <= arr[i][1] < (j + 1) / 2 * (j + 4) + 1:
            ans += j + 1
            break

print(ans)

Measured memory_bytes: 63120
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;
int main()
{
  int n,w;
  for(;cin>>n>>w,n;)
    {
      double ans=0.01;
      int v[n];
      int elia[w];
      int mmax=0;
      int last=0;
      memset(elia,0,sizeof(elia));
      for(int i=0;i<n;i++)
	{
	  cin>>v[i];
	  elia[v[i]/w]++;
	  mmax=max(mmax,elia[v[i]/w]);
	  last=max(last,v[i]/w);
	  //  cerr<<mmax<<"# #"<<last<<endl;
	}
      int cnt=last;
      for(int i=0;cnt>0;i++)
	{
	  //	  cerr<<cnt<<" "<<((double)last-1)<<" "<<elia[i]<<" "<<(double)mmax<<endl;
	  ans+=(cnt/((double)last))*(elia[i]/(double)mmax);
	  cnt--;
	}

      cout<<ans<<endl;

    }
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

struct node {
    int depth;
    node *l, *r;
    node(int d) : depth(d), l(nullptr), r(nullptr) {}
};

node *add_char(node *v, char c) {
    if (c == '0') {
        if (v->l != nullptr) {
            return v->l;    
        } else {
            v->l = new node(v->depth + 1);
            return v->l;
        }
    } else {
        if (v->r != nullptr) {
            return v->r;
        } else {
            v->r = new node(v->depth + 1);
            return v->r;
        }
    }
}

node *add_string(node *v, string s) {
    for (char c: s) {
        v = add_char(v, c);
    }
    return v;
}

i64 grundy(i64 k) {
    for (int i = 0;; i++) {
        if ((k >> i) & 1) {
            return i64(1) << i;
        }
    }
}

int main() {
    i64 n, l;
    cin >> n >> l;
    node *root = new node(0);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        add_string(root, s);
    }

    vi ps;
    function<void(node*)> dfs = [&](node *v) {
        if (v->l && v->r) {
            dfs(v->l);
            dfs(v->r);
        } else if (v->l == nullptr && v->r == nullptr) {
            return;
        } else {
            if (v->l) {
                dfs(v->l);
                ps.push_back(l - v->depth);
            } else {
                dfs(v->r);
                ps.push_back(l - v->depth);
            }
        }
    };

    dfs(root);

    // for (i64 p: ps) {
    //     cout << p << endl;
    // }

    i64 x = 0;
    for (i64 p: ps) {
        x ^= grundy(p);
    }

    cout << (x ? "Alice" : "Bob") << endl;
}

Measured memory_bytes: 10872
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
  string s;
  while (getline(cin, s), s != "0"){
    int sum = 0;
    for (int i = 0; i < s.size(); i++){
      sum += (s[i] - '0');
    }

    cout << sum << endl;
  }
}

Measured memory_bytes: 1184
# n
# t x y

n = gets.to_i
t = []
x = []
y = []

t << 0
x << 0
y << 0
n.times do 
  t_temp, x_temp, y_temp = gets.split
  t << t_temp.to_i
  x << x_temp.to_i
  y << y_temp.to_i
end

def move_enable?(t_from, t_to, x_from, x_to, y_from, y_to)
  t_dif = t_to - t_from
  x_dif = (x_to - x_from).abs
  y_dif = (y_to - y_from).abs
  if t_dif < x_dif + y_dif
    return false
  elsif t_dif == x_dif + y_dif
    return true
  elsif ( t_dif - (x_dif + y_dif) ).even?
    return true
  else
    return false
  end
end

flag = "No"
n.times do |i|
  flag_temp = move_enable?(t[i], t[i+1], x[i], x[i+1], y[i], y[i+1])
  break unless flag_temp
  flag = "Yes" if i == n-1
end

puts flag


Measured memory_bytes: 16952
#include<iostream>
using namespace std;
  
int main(){
  int n;
  int I[1001],P[1001],Q[1001],R[1001],C[1001];
    
  while(cin >> n ,n){
    for(int i=0;i<n;i++){
      cin >> I[i] >> P[i] >> Q[i] >> R[i];
      C[i] = P[i]*4 + Q[i]*9 + R[i]*4;
    }
    cin >> P[n] >> Q[n] >> R[n] >> C[n];
      
    int ans = 0;
    for(int i=0;i<n;i++){
      if(P[i]<=P[n] && Q[i]<=Q[n] && R[i]<=R[n] && C[i]<=C[n]){
    cout << I[i] << endl;
    ans++;
      }
    }
    if(!ans)cout << "NA\n";
  }
}


Measured memory_bytes: 3124
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

a, b = get_ints

ax = a.to_s * b
bx = b.to_s * a

if ax > bx
  puts bx
else
  puts ax
end


Measured memory_bytes: 14308
#include<iostream>
#include<algorithm>
using namespace std;
int t[101],n,maxm;
int main(){
  for(int i=0;i<101;i++)t[i]=0;
  maxm=0;
  while(cin>>n){
    t[n]++;
    maxm=max(maxm,t[n]);
  }
  for(int i=1;i<=100;i++){
    if(maxm==t[i])cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
// https://atcoder.jp/contests/abc132/tasks/abc132_b
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, p: [i32; n]
    };

    let mut count = 0;
    for i in 1..n-1 {
        let mut ve = vec![p[i-1], p[i], p[i+1]];
        ve.sort();
        if ve[1] == p[i] {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include <stdio.h>
int n, m, x, s[100];
int main() {
	while(scanf("%d%d", &n, &m), n + m) {
		for(int i = 0; i < m; i++) scanf("%d", s + i);
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) scanf("%d", &x), s[j] -= x;
		}
		int f = 1;
		for(int i = 0; i < m; i++) {
			if(s[i] < 0) f = 0;
		}
		puts(f ? "Yes" : "No");
	}
}

Measured memory_bytes: 2472
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)

void ayush(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

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

ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
ll mulmod(ll a, ll b, ll mod) 
{ 
    ll res = 0; 
    a = a % mod; 
    while (b > 0) 
    { 
        if (b % 2 == 1) res = (res + a) % mod; 
        a = (a * 2) % mod; 
        b /= 2; 
    }  
    return res % mod; 
} 

int main(){
    ayush();
    fastio;

    ll t; t=1;
    while(t--){
        ll A; cin>>A;
        string s="";
    while(A>0){
        int n = A%26;
        if(n==0){ s += 'z'; A=A/26-1;} 
        else{s += n-1+'a';
        A=A/26;}
    }
    reverse(s.begin(),s.end());
    cout<<s;
    }   
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

int main() {

    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for (int i = L; i <= R; i++) {
        if (i % d == 0) ans++;
    }

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

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
int sub(int a,int b){a-=b;return a<0?a+mod:a;}
int mul(int a,int b){return (ll)a*b%mod;}
int qpow(int a,int b){int ret=1;for(;b;b>>=1,a=mul(a,a))if(b&1)ret=mul(ret,a);return ret;}
/* math */
int n;

typedef pair<int,int> edge;

bool ban[110][110];

int main()
{
	cin>>n;
	if(n%2==0){
		for(int i=1;i<=n;i++)ban[i][n-i+1]=1;
		cout<<(n*(n-1))/2-(n/2)<<endl;
		for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)if(!ban[i][j])cout<<i<<" "<<j<<endl;
	}else{
		for(int i=1;i<=n-1;i++)ban[i][n-i]=1;
		cout<<(n*(n-1))/2-(n-1)/2<<endl;
		for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)if(!ban[i][j])cout<<i<<" "<<j<<endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;


int main()
{
	int n, a, b; cin >> n >> a >> b;
	cout << min(b, n * a) << endl;
}


Measured memory_bytes: 256