akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertion_sort(int A[], int n, int g)
{
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shell_sort(int A[], int n)
{
    for (int h = 1; ; ) {
        if (h > n) break;
        G.push_back(h);
        h = 3*h + 1;
    }

    for (int i = G.size() - 1; i >= 0; i--) {
        insertion_sort(A, n, G[i]);
    }
}


int main(int argc, char const *argv[])
{
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    cnt = 0;

    shell_sort(A, n);

    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--) {
        printf("%d", G[i]);
        if (i) printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for (int i = 0; i < n; i++) {
        printf("%d\n", A[i]);
    }

    return 0;
}




Measured memory_bytes: 7168
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))

// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"[";
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===


// const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
void inp_mat(ll *arr,ll n,ll m)
{
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
        {
          ll x;cin>>x;
          *((arr+i*m) + j)=x;
        }
}
// syntax for inp_mat inp_mat((ll *)arr,n,m);
// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGEc
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    int t=1;
    // cin>>t;
    while(t--)
    {
         ll n;cin>>n;ll arr[n];inp(arr,n);
      ll x=0;
      f(i,2,n)
      x^=arr[i];
      if((arr[0]+arr[1]-x)%2!=0)
      cout<<"-1";
      else{
        ll y=(arr[0]+arr[1]-x)/2;
        dbg(y);
        if(y>arr[0] or y<0)
        cout<<"-1";
        else{
          ll ind=60;
          ll y1=y;
          ll y2=y;
          while(ind>=0)
          {
            dbg((ll)1<<ind);
            if((x&((ll)1<<ind))!=0)
            {
              if((y1& ((ll)1 <<ind))!=0)
              {
                cout<<"-1";
                return 0;
              }
              if(((ll)1<<ind)+y<=arr[0])
              {
                y+=((ll)1<<ind);
              }
              else
              {
                y2+=((ll)1<<ind);
              }
              
              
            }
            
            
            ind--;

          }
          dbg(y);
          if(y==0 or (y+y2)!=(arr[0]+arr[1]))
          cout<<"-1";
          else
          cout<<arr[0]-y;
        }
      }

    }    
} 

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

int main(){
  string A;
  cin >> A;
  if (A.size() == 2) {
    cout << A << endl;
  }else{
    cout << A[2] << A[1] << A[0] << endl;    
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define FOR(i, n) for(int i = 0; i < (n); i ++)
#define CIN(type, val) type val; cin >> val;
#define COUT(val) cout << (val) << "\n";
using namespace std;

int main(void){
    CIN(int, n);
    vector<int> h(n);
    FOR(i, n) cin >> h[i];
    
    vector<int> dp(100000);
    dp[0] = 0, dp[1] = abs(h[0] - h[1]);
    for(int i = 2; i < n; i ++) dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]));
    
    COUT(dp[n-1]);
}

Measured memory_bytes: 1024
#include<cstdio>
#include<string.h>

using namespace std;

int main(){
	static bool p[1000000];
	memset(p,true,sizeof(p));
	p[0] = false;
	p[1] = false;
	for(int i= 2;i<1000000;i++){
		if(p[i]){
			for(int j=i*2;j<1000000;j+=i){
				p[j] = false;
			}
		}
	}
	int n,ans;
	while(!(scanf("%d",&n)==EOF)){
		ans=0;
		for(int j=2;j<=n;j++){
			if(p[j])ans++;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 2008
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

// 桁数k, 最上位xのlunlun数の個数 ただし0を含む
int numlunlun( int k, int x ){
    if(k==1){
        return 1;
    }else{
        if(x==0){
            return numlunlun(k-1,x) + numlunlun(k-1,x+1);
        }else if(x==9){
            return numlunlun(k-1,x-1) + numlunlun(k-1,x);
        }else{
            return numlunlun(k-1,x-1) + numlunlun(k-1,x) + numlunlun(k-1,x+1);
        }
    }
}

void lunlun( int k, int x, int num ){
    cout << x;
    int tmp(0),tmp2(0);
    if(k==1) return;
    else{
        if(x==0){
            tmp = numlunlun(k-1,x);
            if( tmp >= num ) {
                lunlun(k-1,x,num);
                return;
            }else{
                lunlun(k-1,x+1,num-tmp);
                return;
            }
        }else if(x==9){
            tmp = numlunlun(k-1,x-1);
            if( tmp >= num ){
                lunlun(k-1,x-1,num);
                return;
            }else{
                lunlun(k-1,x,num-tmp);
                return;
            }
        }else{
            tmp = numlunlun(k-1,x-1);
            if( tmp >= num ){
                lunlun(k-1,x-1,num);
                return;
            }
            tmp2 = numlunlun(k-1,x);  
            if( tmp2 >= num - tmp ){
                 lunlun(k-1,x,num-tmp);
                 return;
            }
            else{
                lunlun(k-1,x+1,num-tmp-tmp2);
                return;
            }
        }
    }
}


int main(){
    int K;
    cin >> K;
    ++K;

    int x(0),k(1);
    int num;

    while(true){
        num = numlunlun(k,x);
        if(K > num){
            K -= num;
            if(x==9){
                x = 1;
                ++k;
            }else{
                ++x;
            }
        }else{
            lunlun(k,x,K);
            cout << endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        var sc = new Scanner(System.in);
    
        int a = Integer.parseInt(sc.next());
        int v = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        
        if(v <= w){
            System.out.println("NO");
        }else{
            long x = v-w;
            x *= t;
            if(x >= Math.abs(a-b)){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
    }
}

Measured memory_bytes: 35652
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		
			Scanner scan = new Scanner(System.in);
			int i = 0;
			int a =0;
			Integer b[]=new Integer[10];
		
			
		for(i=0;i<10;i++){
			//System.out.println("????????\?????????????????????");
			a = scan.nextInt();
			b[i]=a;
			
			}	
			
		
		 
		for(int j =0;j<3;j++){
			Arrays.sort(b, Collections.reverseOrder());

			System.out.println(b[j]);

			
		}
		

	
}
}

Measured memory_bytes: 26008
n,y = gets.split.map(&:to_i)

for i in 0..n
  break if y < i*10000 
  for j in 0..(n-i)
    left = y - (i*10000 + j*5000)
    break if left < 0
    if left % 1000 == 0 && left <= (n-i-j)*1000 && left/1000 == n-i-j
      puts "#{i} #{j} #{left/1000}"
      exit
    end
  end
end

puts "-1 -1 -1"

Measured memory_bytes: 1788
while True:
    a = [int(x) for x in input().split()]
    if a[0] == -1 and a[1] == -1 and a[0] == -1:
        break
    if a[0] == -1 or a[1] == -1:
        print("F")
    elif a[0] + a[1] >= 80:
        print("A")
    elif a[0] + a[1] >= 65:
        print("B")
    elif a[0] + a[1] >= 50 or a[2] >= 50:
        print("C")
    elif a[0] + a[1] >= 30:
        print("D")
    else:
        print("F")


Measured memory_bytes: 5604
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
 
#define N 100010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mod 1000000007
#define pii pair <ll, ll>
 
using namespace std;

string s;

int main()
{
	cin >> s;
	
	int ans = 0, cnt = 0;
	
	for(int i = 0; i < s.length(); i++) {
		if(s[i] == 'R') cnt++;
		else {
			ans = max(ans, cnt);
			cnt = 0 ;
		}
	}
	cout << max(ans, cnt);
}


Measured memory_bytes: 3160
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

string pad(int num) {
  string t = to_string(num);
  string pad = "";
  if (t.size() < 6) {
    int diff = 6 - (int) t.size();
    for (int i = 0; i < diff; ++i) {
      pad += '0';
    }
  }
  return pad + t;
}

struct task{
  int year, id;
};

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

  int n, m; cin >> n >> m;
  vector<task> v[101010];
  for (int i = 0; i < m; ++i) {
    int p, y; cin >> p >> y;
    v[p].push_back({y, i + 1});
  }

  vector<string> ans(m + 1);

  for (int i = 1; i <= n; ++i) {
    if (v[i].empty()) continue;
    sort(v[i].begin(), v[i].end(), [](const task &x, const task &y){
      return x.year < y.year;
    });
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < (int)v[i].size(); ++j) {
      ans[v[i][j].id] = pad(i) + pad(j + 1);
    }
  }

  for (int i = 1; i <= m; ++i) {
    cout << ans[i] << '\n';
  }

  return 0;
}

Measured memory_bytes: 12544
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))

    # A,Bそれぞれについて、隣接している値が異なる -> その山の値は確定
    C=[None]*n
    C[0]=A[0]
    for i in range(1,n):
        if(A[i]!=A[i-1]):
            C[i]=A[i]

    for i in range(n):
        if(C[i] and B[i]<C[i]):
            print(0)
            return

    D=[None]*n
    D[-1]=B[-1]
    for i in range(n-2,-1,-1):
        if(B[i]!=B[i+1]):
            D[i]=B[i]

    for i in range(n):
        if(D[i] and A[i]<D[i]):
            print(0)
            return

    ans=1
    for i in range(n):
        if(C[i] or D[i]): continue
        ans*=min(A[i],B[i])
        ans%=MOD

    print(ans)
resolve()

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    scanf("%d" , &n);
    string s = "" , t = "" , ss = "";
    for(int i = 0 ; i < n ; i ++){
            int x; scanf("%d" , &x);
            s += char(x + '0');
            ss += char((i + 1) + '0');
    }

    for(int i = 0 ; i < n ; i ++){
            int x; scanf("%d" , &x);
            t += char(x + '0');
    }


    int a = 0 , b = 0;
    int cnt = 1;
    do {
        if(ss == s)a = cnt;
        if(ss == t)b = cnt;
        cnt ++;
    }while(next_permutation(ss.begin() , ss.end()));

    printf("%d\n" , abs(a - b));
}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    ll a, b, x;
    cin >> a >> b >> x;
    ll cnt = (a == 0 || b == 0);
    cnt += b / x - (((a - 1) > 0) ? a - 1 : 0) / x;
    cout << cnt;
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
a=input()

if a in "SAT":
    print(1)
if a in "SUN":
    print(7)
    
if a in "MON":
    print(6)
if a in "TUE":
    print(5)
    
if a in "WED":
    print(4)
if a in "THU":
    print(3)
if a in "FRI":
    print(2)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
    string s;cin>>s;
    int n=s.size(),a1=0,a2=0;
    for(int i=0;i<n;i++){
        if(i%2==0&&s[i]!='0')a1++;
        if(i%2==1&&s[i]!='1')a1++;
    }
    for(int i=0;i<n;i++){
        if(i%2==0&&s[i]!='1')a2++;
        if(i%2==1&&s[i]!='0')a2++;
    }
    cout<<min(a1,a2)<<endl;
    
    return 0;
}


Measured memory_bytes: 512
while n = gets.to_i
  break if n == 0
  a = []
  sum = Array.new(n, 0)
  n.times{|i|
    a[i] = gets.split.map(&:to_i)
    n.times{|j|
      sum[j] += a[i][j]
      print "%5d" % a[i][j]
    }
    puts "%5d" % a[i].inject(&:+)
  }
  n.times{|j|
    print "%5d" % sum[j]
  }
  puts "%5d" % sum.inject(&:+)
end

Measured memory_bytes: 8816
// AOJ 1242: Area of Polygons
// 2017.12.6 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MIN(a,b) ((a)<=(b)?(a):(b))
#define MAX(a,b) ((a)>=(b)?(a):(b))

typedef struct { int x, y; } PP;
PP p[102];

typedef struct { int l, r; } E;
E e[102];

int cmp(E *a, E *b) { if (a->l - b->l) return a->l - b->l; return a->r - b->r; }

void calc(int i, int y, int *l, int *r)
{
	int d, n, w;

	d = p[i+1].y - p[i].y;
	n = (y - p[i].y)*(p[i+1].x - p[i].x);
	w = p[i].x + n / d;
	if (n % d == 0) *l = w, *r = w;
	else if ((n%d)*d < 0) *l = w-1, *r = w;
	else                  *l = w,   *r = w+1;
}

int main()
{
	int n, m, i, y, ymin, ymax, pre, ans;
	int la, ra, lb, rb;

	while (scanf("%d", &n) && n > 0) {
		scanf("%d%d", &p[0].x, &p[0].y);
		ymin = ymax = p[0].y;
		for (i = 1; i < n; i++) {
			scanf("%d%d", &p[i].x, &p[i].y);
			if      (p[i].y < ymin) ymin = p[i].y;
			else if (p[i].y > ymax) ymax = p[i].y;
		}
		p[n] = p[0];

		ans = 0;
		for (y = ymin; y < ymax; y++) {
			for (m = 0, i = 0; i < n; i++) {
				if ((p[i].y <= y   && p[i+1].y <= y) ||
					(p[i].y >= y+1 && p[i+1].y >= y+1)) continue;
				calc(i, y, &la, &ra), calc(i, y+1, &lb, &rb);
				e[m].l = MIN(la, lb);
				e[m].r = MAX(ra, rb);
				m++;
			}
			qsort(e, m, sizeof(E), cmp);

			for (pre = -10000, i = 0; i < m; i+=2) {
				ans += e[i+1].r - MAX(e[i].l, pre);
				pre = e[i+1].r;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1752
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;
//for (int i = 0; i < N; i++){}

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

    long long sums = 0;
    for(int bit = 0; bit < (1<<(S.size()-1));bit++){
        string sure = "";
        for(long long i = 0; i<(S.size()-1); i++){
            if(1 & (bit >> i)){
                sure += to_string(1 & (bit >> i));
//                cout << (1 & (bit >> i));
            }else{
                sure += "0";
//                cout << 0;
            }
        }
//        cout << endl;
        long long jiku=0;
        string moji = {S[0]};
        for(long long k = 1; k<(S.size()); k++){
            if(sure[k-1] == '0'){
                moji += S[k];
            }else if(sure[k-1] == '1'){
                sums += stoll(moji);
//                cout << moji << endl;
                moji = S[k];
            }
        }
        if(moji !=""){
            sums += stoll(moji);
        }
//        cout << endl;
    }
    cout << sums  << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

ll N,L,a[100010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N>>L;
	rep2(i,1,N+1)cin>>a[i];
	priority_queue<pi,vector<pi>,greater<pi> > Q;
	rep2(i,1,N+1){
		if(a[i]>a[i-1] && a[i]>a[i+1])Q.push(pi(L-a[i],i));
	}
	ll time=0;
	while(sz(Q)){
		pi p=Q.top();Q.pop();
		time=p.fir;
		a[p.sec]=0;
		if(p.sec>=2 && a[p.sec-1] > a[p.sec-2]){
			Q.push(pi(time+L-a[p.sec-1],p.sec-1));
		}
		if(a[p.sec+1] > a[p.sec+2]){
			Q.push(pi(time+L-a[p.sec+1],p.sec+1));
		}
	}
	cout<<time<<endl;
}

Measured memory_bytes: 2448
#include<bits/stdc++.h>
using namespace std;
#define maxn 10010
typedef long long ll;
typedef long double ld;
const ll inF=1e18;
int a,b,c,d;
int main(){
    cin >> a >> b >> c >> d;
    while (a>0&&c>0) {
        c-=b;
        if (c<=0){
                cout << "Yes"<< endl;
                exit(0);
        }
        a-=d;
        if (a<=0){
                cout << "No"<< endl;
                exit(0);
        }
    }
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  string A,B;
  cin>>A>>B;
  for (int i = 0; i < N; i++){
    cout<<A.at(i);
    cout<<B.at(i);
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int n,r;
    cin>>n>>r;
    if(n>=10) cout<<r<<endl;
    else{
        cout<<r+100*(10-n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x,y; cin >> x >> y;
    cout << 3*(x-__gcd(x,y)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll _v):v(normS(_v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ModInt& operator++(int){ return *this=*this+1;}
	ModInt& operator--(int){ return *this=*this-1;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll p[]={a,1,0},q[]={b,0,1};
		while(*q){
			ll t=*p/ *q;
			rep(i,3) swap(p[i]-=t*q[i],q[i]);
		}
		if(p[0]<0) rep(i,3) p[i]=-p[i];
		x=p[1],y=p[2];
		return p[0];
	}
	ModInt inv() const {
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	ModInt pow(ll p) const {
		if(p<0) return inv().pow(-p);
		ModInt a = 1;
		ModInt x = *this;
		while(p){
			if(p&1) a *= x;
			x *= x;
			p >>= 1;
		}
		return a;
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	string s;
	cin >> s;
	int L = 0;
	mint ans = 1;
	for(char c: s){
		if((c == 'B') ^ (L%2 == 0)){
			ans *= L;
			L--;
		}else{
			L++;
		}
	}
	if(L != 0) ans = 0;
	rep1(i,N) ans *= i;
	cout << ans << endl;
}


Measured memory_bytes: 720
#include <iostream>
using namespace std;
int main() 
{
	double w;
	while (std::cin >> w) {
		if (w <= 48.00)
            		cout << "light fly" << endl;
		 else if (w > 48.00 && w <= 51.00)
			cout << "fly" << endl;
		else if (w > 51.00 && w <= 54.00)
            		cout << "bantam" << endl;
		else if (w > 54.00 && w <= 57.00)
            		cout << "feather" << endl;
		else if (w > 57.00 && w <= 60.00)
            		cout << "light" << endl;
		else if (w > 60.00 && w <= 64.00)
            		cout << "light welter" << endl;
		else if (w > 64.00 && w <= 69.00)
            		cout << "welter" << endl;
		else if (w > 69.00 && w <= 75.00)
            		cout << "light middle" << endl;
		else if (w > 75.00 && w <= 81.00)
            		cout << "middle" << endl;
		else if (w > 81.00 && w <= 91.00)
            		cout << "light heavy" << endl;
		else if (w > 91.00)
            		cout << "heavy" << endl;
    }
	return 0;
}



Measured memory_bytes: 3216
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main()
{
	int n, a;
	cin >> n >> a;
	if (a < n % 500)cout << "No" << endl;
	else cout << "Yes" << endl;
}



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

#define josh 0
#define ll long long
#define llu long long unsigned
#define ii pair<int ,int>
#define iii pair<int, ii>
#define all(v) (v).begin(), (v).end()
#define vout(v) for(auto i:v)cout<<i<<" "; cout<<endl;
#define loop(x, n, p) for(int i=x; p>0 ? i<n : i>=n; i+=p)
#define deb(x) cout<<#x<<" "<<x<<endl;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define file(x) if(x=="in")freopen("input.txt", "r", stdin); \
                else{freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}

template <typename T>
void in(T& n){cin>>n;}


template <typename T, typename ... Args>
void read(T& n, Args& ... args){cin>>n; in(args...);}


struct Converter{
template<typename T>
    T toNum(string s, T& n){
        stringstream ss; ss<<s;
        ss>>n;
        return n;
    }
template <typename T>
    string toString(T& n){
        stringstream ss; ss<<n;
        string s; ss>>s;
        return s;
    }

}convert;

struct Prime{

    bool isPrime[10000007]={0};
    std::vector<int> primeContain;

    void sieve(int n){

        memset(isPrime, true, sizeof(isPrime));

        for (int p=2; p*p<=n; p++){
            if (isPrime[p] == true){
                for (int i=p*p; i<=n; i += p)
                    isPrime[i] = false;
            }
        }
        isPrime[0]=0, isPrime[1]=0;
        loop(2, n+7, 1)
            if(isPrime[i])
                primeContain.push_back(i);

    }




}prime;


/*................................let's do it bitch............................................*/




int main(){

    int n, m, cnt=0; read(n, m);
    vector<int>h, vis(n, 0);
    loop(0, n, 1){
        int x; in(x);
        h.push_back(x);
    }

    loop(0, m, 1){
        int x, y; read(x, y);
        vis[x-1]=max(vis[x-1], h[y-1]);
        vis[y-1]=max(vis[y-1], h[x-1]);
    }

    loop(0, n, 1){
        if(h[i]>vis[i])cnt++;
    }

    cout<<cnt;


    return josh;
}















Measured memory_bytes: 14076
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();

            if(H == 0 && W == 0) break;
            else{
                for(int i=0; i<H; i++){
                    for(int j=0; j<W; j++){
                        if(i%2 == 0 && j%2 == 0){
                            System.out.print("#");
                        }else if(i%2 == 1 && j%2 == 1){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }
                    System.out.printf("\n");
                }
                System.out.printf("\n");
            }
        }
    }
}


Measured memory_bytes: 38216
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  unsigned long long a=0;
  char c;
  while (true) {
	c = cin.get();
	if (isdigit(c)) {
      a *= 10;
      a += (c-'0');
    }
    else
      break;
  }
  unsigned long long b=0;
  while (true) {
	c = cin.get();
    if (c == '.')
      continue;
	if (isdigit(c)) {
      b *= 10;
      b += (c-'0');
    }
    else
      break;
  }
  cout << (a * b) / 100 << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
int n,k,ans;
int a[211111];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	int xorsum=0;
	rep(i,n)xorsum^=a[i];
	rep(i,n){
		xorsum^=a[i];
		cout<<xorsum<<" ";
		xorsum^=a[i];
	}
	cout<<endl;
}

Measured memory_bytes: 5132
n = int(input())
m = {}
tot = 0
for a in map(int,input().split()):
  tot += a
  if a not in m:
    m[a]=0
  m[a] += 1
q = int(input())
for step in range(q):
  b,c = map(int,input().split())
  if c not in m:
    m[c] = 0
  if b in m:
    m[c] += m[b]
    tot += m[b]*(c-b)
    m[b] = 0
  print(tot)

Measured memory_bytes: 21832
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>

using namespace std;
int i,N,ans;
vector<char> out(1001);

int main(){
  cin >> N;
  vector<int> input(N);
  for(i=0;i<N;i++){
    cin >> input.at(i);
  }
  ans = 0;
  for(i=1;i<N-1;i++){
    if(input.at(i-1) == input.at(i) && input.at(i) == input.at(i+1)){
      input.at(i) = input.at(i+1) +1;
      ans++;
    } else if(input.at(i-1) == input.at(i)){
      ans++;
    } 
  }
  if(input.at(N-2) == input.at(N-1)){
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = set()
for i in range(n):
    w = str(input())
    if i == 0:
        p = w
        s.add(w)
    else:
        if w[0] != p[-1] or w in s:
            print('No')
            exit()
        else:
            p = w
            s.add(w)
else:
    print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int h,w;
char a[100][100];
bool H[100];//yokoretu
bool W[100];//tateretu
int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>a[i][j];
	for(int i=0;i<100;i++)H[i]=false,W[i]=false;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(a[i][j]=='#')goto lp;
		}
		H[i]=true;
		lp:;
	}
	for(int j=0;j<w;j++){
		for(int i=0;i<h;i++){
			if(a[i][j]=='#')goto lop;
		}
		W[j]=true;
		lop:;
	}
	for(int i=0;i<h;i++){
		if(H[i]==true)continue;
		for(int j=0;j<w;j++){
			if(W[j]==false)cout<<a[i][j];
		}
		cout<<endl;
	}
	return 0;
}

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

int main()
{
    ll n,k;
    cin>>k>>n;
    map<ll,ll>mp;
    ll a[n+1];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll sum=a[n-1]-a[0];
    for(int i=1;i<n;i++)
    {
        sum = min(sum,k-a[i]+a[i-1]);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

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

template<typename T, typename Compare = greater<T> >
inline void chmax(T& t, T f, Compare comp){if(!comp(t, f))t = f;}

int h, w;

string solve(vector<string>& patterns){
    string res = "0";
    set<string> spells;
    rep(x, h)rep(y, w){
        for(int dx=-1; dx<=1; ++dx){
            for(int dy=-1; dy<=1; ++dy){
                string spell = "";  spell += patterns[x][y];
                for(int nx=(x+dx+h)%h, ny=(y+dy+w)%w; nx!=x || ny!=y; (nx+=(dx+h))%=h, (ny+=(dy+w))%=w){
                    spell += patterns[nx][ny];
                    if(!spells.insert(spell).second){
                        chmax(res, spell, [](string& s, string& t){return mp(t.size(), s) < mp(s.size(), t);});
                    }
                }
            }
        }
    }
    return res;
}

int main(){
    while(cin >> h >> w, h|w){
        vector<string> patterns(h);
        rep(i, h)cin >> patterns[i];
        cout << solve(patterns) << '\n';
    }
    return 0;
}

Measured memory_bytes: 33744
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N, M, X;
  cin >> N >> M >> X;
  vector<long> A(M);
  rep (i, M) cin >> A[i];

  long foo = 0;
  long bar = 0;

  rep (i, M) if (A[i] < X) foo++; else bar++;

  cout << min(foo, bar) << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

vector<ll> v;
int n;
ll dp[222222][22];
ll four[22];

ll comp(ll a,ll b){
	ll ret = 0;
	ll mul = (a + b - 1) / b;
	ll tmp = 1;
	while(tmp < mul){
		tmp *= 4;
		ret++;
	}
	return ret;
}

ll dfs(int a, int b){
	if(dp[a][b] != -1)return dp[a][b];
	if(a == n-1)return dp[a][b] = 0;
	ll tmp = comp(four[b]*v[a],v[a+1]);
	if(tmp > 15){
		return dp[a][b] = 15 + (tmp - 15) * (n - a - 1) + dfs(a+1, 15);
	}
	else{
		return dp[a][b] = tmp + dfs(a+1,tmp);
	}
}

vector<ll> seica(){
	REP(i,222222)REP(j,22)dp[i][j] = -1;
	vector<ll> ret(n);
	for(int i = n-1;i >= 0;i--) {
	//	cout << i << endl;
		ret[i] = dfs(i, 0);
	}
	return ret;
}

int main(){
	
	cin >> n;
	four[0] = 1;
	REP(i,20)four[i+1] = four[i] * 4;
	REP(i,n){
		int tmp;cin >> tmp;
		v.EB(tmp);
	}
	
	auto A = seica();
	reverse(ALL(v));
	auto B = seica();reverse(ALL(B));
	
	ll ans = min(2 * A[0], 2 * B[n-1] + n);
	REP(i,n-1){
		ans = min(ans, 2*(A[i+1]+B[i])+(i+1));
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 44528
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long k;
	cin>>k;
	long long x=k/50,y=k%50;
	cout<<50<<endl;
	for(int i=1;i<=50;i++)if(i<=y)cout<<50+x<<endl;else cout<<50+x-y-1<<endl;
	return 0;
}

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

const int mod = 998244353;

int64_t mul(int64_t x, int64_t y) {
    return (x % mod) * (y % mod) % mod;
}

int fib(long long n, int64_t a = 0, int64_t b = 1, int64_t c = 1, int a0 = 0, int a1 = 1) {
    if (n == 0) return a0;
    int na0 = n & 1 ? (a * a0 + b * a1) % mod : a0;
    int na1 = n & 1 ? (b * a0 + c * a1) % mod : a1;
    return fib(n >> 1, (a * a + b * b) % mod, b * (a + c) % mod, (b * b + c * c) % mod, na0, na1);
}

int main() {
    int n;
    int64_t m;
    cin >> n >> m;
    vector<int> inv(1010101);
    inv[1] = 1;
    for (int i = 2; i < 1010101; i++) inv[i] = mul(inv[mod % i], mod - mod / i);
    int ans = fib(m + 2 * (n - 1));
    int C = 1;
    for (int i = 0; i <= n - 2; i++) {
        ans += mul(C, mod - fib(n * 2 - 2 - 2 * i));
        ans %= mod;
        C = mul(C, mul(m - 1 + i + 1, inv[i + 1]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 4224
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,a,b=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=True)
ans=0
for i in range(a):
    ans+=v[i]
ans/=a
print(ans)
if v[0]==v[a-1]:
    count=0
    for i in range(n):
        if v[i]==v[0]:
            count+=1
    cnt=0
    for i in range(a,min(b,count)+1):
        cnt+=cmb(count,i)
    print(cnt)
else:
    count=0
    for i in range(n):
        if v[i]==v[a-1]:
            count+=1
    for i in range(n):
        if v[i]==v[a-1]:
            l=i
            break
    cnt=cmb(count,a-l)
    print(cnt)

Measured memory_bytes: 3700
import java.util.Scanner;

/*
問題文
高八士君は回文が大好きで、回文でない文字列が許せません。高八士君は文字列を
1 回ハグするごとに、文字列から 1 文字を選んで任意の文字に変えることができます。

文字列 S が与えられます。
S を回文にするために必要なハグの最小回数を答えてください。

制約
S は半角英小文字のみから成る文字列
S の長さは 1 以上 100 以下

*/

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        String first = s.substring(0, s.length()/2);
        String secound = s.substring(s.length()/2, s.length());

        int count = 0;
        for (int i = 0; i < s.length()/2; i++) {
            String tempF = String.valueOf(first.charAt(i));
            String tempS = String.valueOf(secound.charAt(secound.length()-i-1));
            if (!tempF.equals(tempS)) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<40;
const ll MOD = 1000000007;

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

  ll a, b;
  cin >> a >> b;
  vector<vector<ll>> v(a, vector<ll>(b));
  REP(i, a) REP(j, b) cin >> v[i][j];

  vector<vector<ll>> g(300, vector<ll>(300, -1));
  // 0~100
  FOR(i, 1, 101) {
    g[i-1][i] = -2;
  }
  // 101~201
  FOR(i, 102, 202) {
    g[i-1][i] = -3;
  }

  // 頂点[0,100]から頂点[101,201]への辺
  REP(x, 101) REP(y, 101) {
    ll ret = 0;
    REP(i, a) REP(j, b) {
      chmax(ret, v[i][j]-(i+1)*x-(j+1)*y);
    }
    g[x][201-y] = ret;
  }

  // 確かめる
  FOR(i, 1, a+1) FOR(j, 1, b+1) {
    ll mi = INF;
    REP(x, 101) REP(y, 101) {
      chmin(mi, i*x+j*y+g[x][201-y]);
    }
    if(v[i-1][j-1] != mi) {
      cout << "Impossible" << endl;
      return 0;
    }
  }

  ll m = 0;
  REP(i, 300) REP(j, 300) {
    if(g[i][j] != -1) m++;
  }
  cout << "Possible" << endl;
  cout << 300 << " " << m << endl;
  REP(i, 300) REP(j, 300) {
    if(g[i][j] == -1) continue;
    if(g[i][j] == -2) cout << i+1 << " " << j+1 << " X" << endl;
    else if(g[i][j] == -3) cout << i+1 << " " << j+1 << " Y" << endl;
    else cout << i+1 << " " << j+1 << " " << g[i][j] << endl; 
  }
  cout << 1 << " " << 202 << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.ArrayList;


public class Main {
	
	static String change(String str){
		StringBuffer sb = new StringBuffer(str);
		str = sb.reverse().toString();
		return str;
	}
	
	public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int m = sc.nextInt();
			for(int i=0;i<=m;i++) {
				String tomas = sc.nextLine();
				ArrayList<String> pettern = new ArrayList<>();
				
				String s = "";
				
				for(int j=0;j<tomas.length()-1;j++) {
					for(int k=0;k<8;k++) {
						switch(k) {
						case 0:
							s = change(tomas.substring(0,j+1)) + change(tomas.substring(j+1,tomas.length()));
							pettern.add(s);
							break;
							
						case 1:
							s = change(tomas.substring(0,j+1)) + tomas.substring(j+1,tomas.length());
							pettern.add(s);
							break;
								
							
						case 2:
							s = tomas.substring(0,j+1) + change(tomas.substring(j+1,tomas.length()));
							pettern.add(s);
							break;
							
						case 3:
							s = tomas.substring(0,j+1) + tomas.substring(j+1,tomas.length());
							pettern.add(s);
							break;
							
						case 4:
							s = change(tomas.substring(j+1,tomas.length())) +  change(tomas.substring(0,j+1)) ;
							pettern.add(s);
							break;
							
						case 5:
							s = tomas.substring(j+1,tomas.length()) + change(tomas.substring(0,j+1)) ;
							pettern.add(s);
							break;
								
							
						case 6:
							s =  change(tomas.substring(j+1,tomas.length())) + tomas.substring(0,j+1) ;
							pettern.add(s);
							break;
							
						case 7:
							s = tomas.substring(j+1,tomas.length()) + tomas.substring(0,j+1) ;
							pettern.add(s);
							break;
							
						}
					}
				}
				//System.out.print(pettern);
				
				for(int l=0;l<pettern.size()-1;l++) {
					for(int n=l+1;n<pettern.size();n++) {
						if(pettern.get(l).equals(pettern.get(n))) pettern.set(n,"A");
					}
				}
				
				int count=0;
				for(int l=0;l<pettern.size();l++) {
				    if(!pettern.get(l).equals("A")) count++;
				}
				
				if(i!=0) System.out.println(count);
				
			}
		}

	}


Measured memory_bytes: 77064
#include <cstdio>
#include <cassert>
#include <algorithm>

int as[100005];

int N,M,V,P;

//check if first k are useable
//check if kth is useable
bool check(int k){
  assert(k>P);
  long long boost=1LL*M*V;
  int thres=as[k-1]+M;
  if(thres<as[P-1]){
    return false;
  }
  for(int i=0;i<N;i++){
    if(i<P-1){
      boost-=M;
    }else{
      boost-=std::min(M,thres-as[i]);
    }
  }
  return boost<=0;
}

int main(){
  scanf("%d %d %d %d",&N,&M,&V,&P);
  for(int i=0;i<N;i++){
    scanf("%d",&as[i]);
  }
  std::sort(as,as+N);
  std::reverse(as,as+N);
  int low=P,high=N+1;
  while(high-low>1){
    int mid=(low+high)/2;
    if(check(mid)){
      low=mid;
    }else{
      high=mid;
    }
  }
  printf("%d\n",low);
}


Measured memory_bytes: 512
n = gets.chomp.to_i
nums = gets.chomp.split.map(&:to_i)

change_count = 0
for i in 0..(n-1) do

   (n-1).downto(1) do |j|
      if nums[j] < nums[j-1]

         temp = nums[j]
         nums[j] = nums[j-1]
         nums[j-1] = temp
         change_count += 1

      end

   end

end

nums.each_with_index do |val, idx|

   if idx == nums.count - 1

      puts val

   else

      print "#{val} "

   end

end
puts change_count

Measured memory_bytes: 8672
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n, p, answer = 1;
    cin >> n >> p;

    ll uk = 2;
    while (uk * uk <= p)
    {
        ll kol = 0;
        while (p % uk == 0) kol++, p /= uk;
        if (kol != 0)
        {
            ll t = kol / n;
            for (ll i = 1; i <= t; i++) answer *= uk;
        }
        uk++;
    }
    if (p != 1 && n == 1) answer *= p;
    cout << answer;
    return 0;
}


Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    import scala.io.StdIn._

//    val N = readLine().toInt
//    val Array(n, ) = readLine().split(" ").map(_.toInt)

    val Array(a, p) = readLine().split(" ").map(_.toInt)

    println((a * 3 + p) / 2)
  }
}

Measured memory_bytes: 25544
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        // suit S', 'H', 'C' and 'D'
        int[] s = new int[13];
        int[] h = new int[13];
        int[] c = new int[13];
        int[] d = new int[13];
        Arrays.fill(s, 0);
        Arrays.fill(h, 0);
        Arrays.fill(c, 0);
        Arrays.fill(d, 0);

        String[] suit;
        scanner.next();
        while (scanner.hasNext()) {
            suit = scanner.nextLine().split(" ");

            switch (suit[0]) {
            case "S":
                s[Integer.parseInt(suit[1]) - 1] = 1;
                break;
            case "H":
                h[Integer.parseInt(suit[1]) - 1] = 1;
                break;
            case "C":
                c[Integer.parseInt(suit[1]) - 1] = 1;
                break;
            case "D":
                d[Integer.parseInt(suit[1]) - 1] = 1;
                break;
            default:
                break;
            }

        }

        output(s, "S");
        output(h, "H");
        output(c, "C");
        output(d, "D");

        scanner.close();
    }

    private static void output(int[] values, String suit) {
        for (int i = 0; i < 13; i++) {
            if (values[i] == 0) {
                System.out.printf("%s %d%n", suit, i + 1);
            }
        }
    }

}



Measured memory_bytes: 26292
#include <iostream>

#define MAX_SIZE (10000)

using namespace std;

int main()
{
    int* x = new int[MAX_SIZE + 1];
    int  size;
 
    for (int i = 0; i < MAX_SIZE + 1; i++) {
         do {
             cin >> x[i];
         } while (x[i] < 0 || x[i] > 10000);

         if (x[i] == 0) {
             size = i;
             break;
         }       
    }
   
    for (int i = 0; i < size; i++) {
         cout << "Case " << i + 1 << ": " << x[i] << endl;
    }

    delete[] x;

    return (0);
}

Measured memory_bytes: 1232