akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
	int a,b;
	char op;
	while(op!='?'){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='+'){
			printf("%d\n",a+b);
		}
		if(op=='-'){
			printf("%d\n",a-b);
		}
		if(op=='*'){
			printf("%d\n",a*b);
		}
		if(op=='/'){
			printf("%d\n",a/b);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    double n,p,q,t,x;
    string s,ss;
    vector<ll>v;
    deque<ll>dq;
    cin>>n;
    t=0;
    for(int i=1;i<=n;i++)
    {
       if(i%2==1) t++;
    }

    p=t/n;
    cout<<fixed<<setprecision(10)<<p<<endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
long long c;
long long k;
vector<int> a;
void counter(int n)
{
    if(n==a.size())
    {
        c++;
        if(c==k)
        {
            for(int i:a)
            {
                cout<<to_string(i);
            }
            exit(0);
        }
        else return;
    }
    // if(n>10)
    //     return;
    if(a.empty())
    {
        for(int i=1;i<10;i++)
        {
            a.push_back(i);
            counter(n);
            a.pop_back();
        }
        return ;
        
    }
    for(int i=a.back()-1;i<=a.back()+1 && i<10  ;i++)
    {
        if(i<0)
            continue;
        a.push_back(i);
        counter(n);
        a.pop_back();
    }
    return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    a.clear();
    cin>>k;
    c=0;
    for(int i=1;;i++)
    {
        counter(i);
    }
    return 0;
    
}

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

int main() {
	ll x, y;
	cin >> x >> y;
	ll z;
	if (x % y) {
		z = x;
	} else {
		z = -1;
	}
	cout << z << endl;
	return 0;
}


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

int main(){
  double A,B;
  cin >> A >> B;
  
  double a=A/0.08;
  double c=(A+1)/0.08;
  double b=B/0.1;
  double d=(B+1)/0.1;
  
  if((int)a!=a)
    a=(int)a+1;
  if((int)b!=b)
    b=(int)b+1;
  
  if((int)c!=c)
    c=(int)c;
  else
    c--;
  if((int)d!=d)
    d=(int)d;
  else
    d--;

  
if(d<a || c<b)
  cout << "-1" << endl;
else if(a>=b)
  cout << a << endl;
else 
  cout << b << endl;
    
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n; string s;
    cin >> n >> s;
    ll ans = 0, cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for (int i = 0; i < n; ++i) {
        if(s[i] == 'R') cnt1++;
        else if(s[i] == 'G') cnt2++;
        else if(s[i] == 'B') cnt3++;
    }
    ans = cnt1*cnt2*cnt3;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1, k = i+2; k < n; ++j, k += 2) {
            if((s[i]^s[j]^s[k]) == 87) ans--;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
 
typedef long long ll;
#define INF 1e9
 
 
int main(){
   int N;
   cin >> N;
   vector<int> A(N);
   REP(i, N){
      cin >> A[i];
   }

   int ans = 1, pre = A[0], ktm = 0;
   REP(i, N){
      if(A[i] == pre){

      }
      else if(ktm == 0){
         if(A[i] > pre){
            ktm = 1;
         }
         else{
            ktm = -1;
         }
      }
      else if(ktm == 1){
         if(A[i] < pre){
            ans++;
            ktm = 0;
         }
         else{
            
         }
      }
      else if(ktm == -1){
         if(A[i] > pre){
            ans++;
            ktm = 0;
         }
      }
      pre = A[i];
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin>>s;
    int ans=    INT_MAX;
    for(int i=0;i<=s.size()-3;++i) {
        int x = atoi(s.substr(i,3).c_str());
        ans=min(ans,abs(x-753));
    }
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long Int;

Int n, m, h[2000], w[2000];
Int res;
Int cnt[1080000];
int main(){
	while(true){
		res = 0;
		for(int i = 0;i < 1080000;i++)cnt[i] = 0;
		cin >> n >> m;
		if(n == 0 && m ==0)return 0;
		for(int i = 1;i <= n;i++){
			cin >> h[i];
			h[i] += h[i-1];
		}
		for(int i = 0;i < n;i++){
			for(int j = i+1;j <= n;j++){
				cnt[abs(h[i]-h[j])]++;
			}
		}
		for(int i = 1;i <= m;i++){
			cin >> w[i];
			w[i] += w[i-1];
		}
		for(int i = 0;i < m;i++){
			for(int j = i+1;j <= m;j++){
				res += cnt[abs(w[i]-w[j])];
			}
		}
	cout << res << endl;
	}

}

Measured memory_bytes: 11560
import java.util.*;

class Main{           
    
   public static void main(String[] args){
     
       Scanner sc = new Scanner(System.in);                                                          
       
       int N = sc.nextInt();
       int L[] = new int[2*N];
               
       for(int i = 0;i < 2*N;i++){
           L[i] = sc.nextInt();
       }
       
       Arrays.sort(L);
       
       int ans = 0;
       for(int i = 0;i < 2*N;i+=2){
           ans += Math.min(L[i],L[i+1]);
       }
       
       System.out.println(ans);
       
   }
   
 }

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll n, m;

bool check(string s){
    int n = s.length(), i = 0, j = n - 1;
    while(i < j){
        if(s[i] != s[j])
            return false;
        i++;
        j--;
    }
    return true;
}

void solve(){
    string s;
    cin >> s;
    n = s.length();
    string t = s.substr(0, ((n - 1) / 2));
    string p = s.substr(((n + 3) / 2) - 1, n - ((n + 3) / 2) + 2);
    // trace(s,t,p);
    if(check(s) && check(t) && check(p))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
//typedef long long ll;
long long n,w,a[105],b[105],d[105][100005];
int main(void)
{
  cin>>n>>w;
  for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
  for(int i=1;i<=n;i++){
    for(int j=0;j<=w;j++){
      if(j>=a[i]) 
        d[i][j]=max(d[i-1][j-a[i]]+b[i],d[i-1][j]);
      else d[i][j]=d[i-1][j];
    }
  }
  cout<<d[n][w]<<'\n';
  return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

ll f(ll n){
    return (n * (n+1)) / 2;
}

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        ans += i * f(n/i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        int a, b, c;

        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();

        if (a - b == b -c) {
            out.println("YES");
        } else {
            out.println("NO");
        }
        
        
        sc.close();
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 5000001
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> west(N+1,0),east(N+1,0);
    for(int i=1;i<=N;i++){
        if(S[i-1] == 'E'){
            east[i] += east[i-1]+1;
            west[i] += west[i-1];
        }
        else{
            west[i] += west[i-1]+1;
            east[i] += east[i-1];
        }
    }
    int ans = MAX;
    for(int i=0;i<N;i++){
        int cnt = 0;
            cnt += west[i]+(east[N]-east[i+1]);
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3076
n = int(input())
st = []
for _ in range(n):
    st.append([i for i in input().split()])
x = input()
i = 0
while st[i][0] != x:
    i += 1

i += 1
ans=0
for j in range(i, n):
    ans += int(st[j][1])
print(ans)

Measured memory_bytes: 38384
N=int(input())
d=[[float("inf") for i in range(0,N)] for i in range(0,N)]
for i in range(0,N):
    S=input()
    for j in range(0,N):
        if S[j]=="1":
            d[i][j]=1

for k in range(0,N):
    for i in range(0,N):
        for j in range(0,N):
            if d[i][j]>d[i][k]+d[k][j]:
                d[i][j]=d[i][k]+d[k][j]

ans=0
for i in range(0,N-1):
    for j in range(i+1,N):
        ans=max(ans,d[i][j])
for i in range(1,N-1):
    for j in range(i+1,N):
        if d[i][j]==1 and d[0][i]==d[0][j]:
            ans=-2

print(ans+1)


Measured memory_bytes: 47248
#include <cstdio>
#include <algorithm>

using namespace std;

const int N_MAX = 100;
int N, W;
int w[N_MAX+10], v[N_MAX+10];
int dp[N_MAX+10][10200] = {};

int main() {
  int i, j;
  scanf("%d %d", &N, &W);
  for (i = 0; i < N; i++) {
    scanf("%d %d", &v[i], &w[i]);
  }
  for (i = 0; i < W+1; i++) {
    dp[0][i] = 0;
  }
  for (i = 0; i < N; i++) {
    for (j = 0; j < W+1; j++) {
      if (j < w[i]) {
	dp[i+1][j] = dp[i][j];
      } else {
	dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
      }
    }
  }
  int ans = dp[N][W];
  //for (i = 0; i < N+1; i++) {
  //  for (j = 0; j < W+1; j++) {
  //    printf("%d ", dp[i][j]);
  // }
  //  printf("\n");
  // }
  printf("%d\n", ans);
  return 0;
}



Measured memory_bytes: 6740
#include<stdio.h>
#include<math.h>

void koch(double x1, double y1, double x2, double y2, int n){
  double sx,sy,ux,uy,tx,ty;
  if(n != 0){
    
    sx = (x2 - x1)/3 + x1;
    sy = (y2 - y1)/3 + y1;
    
    tx = 2 * (x2 - x1) / 3 + x1;
    ty = 2 * (y2 - y1) / 3 + y1;
    
    ux = (cos(M_PI/3)*(tx - sx) - sin(M_PI/3)*(ty-sy)) + sx;
    uy = (sin(M_PI/3)*(tx - sx) + cos(M_PI/3)*(ty-sy)) + sy;
    
    koch(x1,y1,sx,sy,n-1);
    koch(sx,sy,ux,uy,n-1);
    koch(ux,uy,tx,ty,n-1);
    koch(tx,ty,x2,y2,n-1);
  }else {
    printf("%f %f\n",x2,y2);
  }
}

int main(){
  int n;
  double x1 = 0.0,y1 = 0.0;
  double x2 = 100.0,y2 = 0.0;

  scanf("%d",&n);
  printf("%f %f\n",x1,y1);
  koch(x1,y1,x2,y2,n);
  return 0;
}

Measured memory_bytes: 640
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string.h>
#include <utility>
#include <queue>
#include <stack>
#include <iomanip>
#include <ctype.h>
#include <map>
#include <set>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <sstream>
#include <math.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <tuple>
#include <cmath>
#include <stdio.h>      /* printf, fgets */
#include <stdlib.h>
#include <fstream>
#pragma comment(linker, "/STACK:67108864")

using namespace std;

typedef long long LL;

#define FOR(i,n) for(int i = 0;i < n;i++)
#define MP make_pair
#define PB push_back
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define CLEAR(a) memset(a, 0, sizeof(a))
#define ERASE(a) memset(a, -1, sizeof(a))
#define INF 2000000000
#define y1 uu1
#define y2 uu2
const double EPS = 1E-12;
const double PI = acos(-1.0);
const LL mod = 1000000007;

using namespace std;


int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  LL h,n,x,k;
  vector<LL>a;
  cin >>n>>k;
  FOR(i,n) {
    cin >> x;
    a.push_back(x);
  }
  sort(ALL(a));
  for (int i = 0;i < min(n,k);i++) {
    a[n-1-i] =0;
  }
  LL s=0;
  FOR(i,n)s+=a[i];
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>                        
#define pb push_back                            
#define mp make_pair                            
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define jonathan ios_base::sync_with_stdio(0)
#define livingston cin.tie(0)
using namespace std;                            
                                                
void yes() {cout << "Yes" << endl;}                                               
void no() {cout << "No" << endl;}                                                        
                                                
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};         
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; 

const int INF = 1e9 + 9;
const long long LINF = 1e18 + 8;
const double EPS = 1e-9;
const long long MOD = 1e9 + 7; //998244353
const double PI = acos(-1);

void solve() {
    int n, t; cin >> n >> t;
    vector<int> a(n + 1, INF), mn(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i] <= a[mn[i - 1]]) mn[i] = i;
        else mn[i] = mn[i - 1];
    }
    int cur = 0;
    int l = 0;
    int res = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] > a[mn[i - 1]]) {
            if (a[i] - a[mn[i - 1]] > cur) {
                cur = a[i] - a[mn[i - 1]];
                l = mn[i - 1];
                res = 1;
            } else if (a[i] - a[mn[i - 1]] == cur) {
                if (mn[i - 1] != l) res++;
            }
        }
    }
    cout << res << endl;
} 

int main() {
    jonathan; 
    livingston;
    solve();
    return 0;
}

Measured memory_bytes: 3980
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

#define N 200100
#define LO 20

//head

int n, k;
int x[N];
int q;
pair<int, ll> ne[N][LO], pr[N][LO];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  rep(i, n) cin >> x[i];
  int j = 0, l = n-1;
  rep(i, n) {
    while(j != n and x[j] < x[i]+k) j++;
    ne[i][0] = {j, j};
    int i_ = n-1-i;
    while(l != -1 and x[l] > x[i_]-k) l--;
    pr[i_][0] = {l, l};
  }
  rep(j, LO-1) rep(i, n) {
    ne[i][j+1] = (ne[i][j].first == n?(pair<int, ll>){n, -1}:(pair<int, ll>){ne[ne[i][j].first][j].first, ne[i][j].second+ne[ne[i][j].first][j].second});
    pr[i][j+1] = (pr[i][j].first == -1?(pair<int, ll>){-1, -1}:(pair<int, ll>){pr[pr[i][j].first][j].first, pr[i][j].second+pr[pr[i][j].first][j].second});
  }
  cin >> q;
  while(q--) {
    int l, r;
    cin >> l >> r;
    l--; r--;
    ll ze = l;
    int now = l;
    int cnt = 1;
    int i = LO-1;
    for(; i >= 0; i--) if(ne[now][i].first <= r) {
      ze += ne[now][i].second;
      now = ne[now][i].first;
      cnt += 1<<i;
    }
    now = r;
    ll us = r;
    i = LO-1;
    for(; i >= 0; i--) if(pr[now][i].first >= l) {
      us += pr[now][i].second;
      now = pr[now][i].first;
    }
    //cout << P(us, ze) << ' ' << cnt << '\n';
    cout << us-ze+cnt << '\n';
  }
}

Measured memory_bytes: 129444
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long sum = 0;
        long max = -1;
        for (int i = 0; i < n; ++i) {
            int a = scanner.nextInt();
            max = Math.max(max, a);
            sum += a;
        }
        sum -= max;
        if (max < sum) {
            System.out.println("Yes");
        } else {
           System.out.println("No");
        }
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
/*ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}*/

/*void decToBinary(ll n)
{
    string s;
int binaryNum[32];
int i = 0;
while (n > 0) {
binaryNum[i] = n % 2;
n = n / 2;
i++;
}
for (int j = i - 1; j >= 0; j--) {
 char c = binaryNum[j] +'0';
 s=s+c;
}
 
 //cout<<s<<endl;
 
 
 
 // for (int j = i - 1; j >= 0; j--)
 // cout<<s[j];
 
sort(s.begin(), s.end());
do {
cout << s << endl;
} while (next_permutation(s.begin(), s.end())); */
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll mindig(ll n){
ll x;
ll ans=mod;
 while(n>0)
        {
            x=n%10;
            ans=min(ans,x);
            n=n/10;
        }
        return ans;
}
ll maxdig(ll n)
{
    ll x;
    ll ans1=-1;
         while(n>0)
        {
            x=n%10;
            ans1=max(ans1,x);
            n=n/10;
        }
        return ans1;
}
 ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 
int main()
{
    fastio;
        
        ll k;
        cin>>k;
        string s;
        cin>>s;
        ll n=s.length();
        if(k>=n)
        cout<<s<<endl;
        else
        {
            for(int i=0;i<k;i++)
            {
                cout<<s[i];
            }
            cout<<"..."<<endl;
        }
        
       
}


Measured memory_bytes: 3640
a = input()
c = 0
e = 0
b = 0
for i in range(len(a)):
    e = int(a[i:i+3])
    c = abs(753-e)
    if i == 0:
        b = c
    if e < 100:
        break
    else:
        b = min(b, c)
print(b)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int h,w;
    cin>>h>>w;
    char c[h][w],ans[2*h][w];
    rep(i,h){
        rep(j,w){
            cin>>c[i][j];
        }
    }
for(int i=0;i<2*h;i++){
        for(int j=0;j<w;j++){
            ans[i][j]=c[i/2][j];
        }
    }
    rep(i,2*h){
        rep(j,w){
            cout<<ans[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3568
import java.util.*

fun main(args: Array<String>) = ABC159D.main()

object ABC159D {
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }

    val N: Int
    val A: List<Int>

    // a -> aがかかれたボールの個数
    val numGroups: Map<Int, Int>

    // a -> aがかかれたボールを選ぶ組み合わせ
    val combinations: Map<Int, Long>
    val combinationSum: Long

    init {
        N = readInt()
        A = readInts()
        numGroups = A.groupBy { it }.mapValues { it.value.size }
        combinations = numGroups.mapValues {
            val n = it.value.toLong()
            n * (n - 1) / 2
        }
        combinationSum = combinations.values.sum()
    }

    fun solve(k: Int): Long {
        // 除いたボールに書かれてる数
        val removedA = A[k-1]
        val n = numGroups[removedA]!!.toLong() -1

        return combinationSum - combinations[removedA]!! + (n * (n - 1) / 2)
    }

    fun main() {
        val results = (1..N).map { k ->
            solve(k)
        }
        println(results.joinToString("\n"))
    }
}

Measured memory_bytes: 111284
//By Don4ick
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qwer1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = (int)1e5 + 228;

using namespace std;

int n, m, col[N];
bool was[N];
vector < pair < int, int > > g[N];

void dfs(int v, int cur)
{
	was[v] = true, col[v] = cur;
	for (auto e : g[v])
	{
		int to = e.first;
		if (was[to] && col[to] != col[v] + e.second)
		{
			cout << "No" << endl;
			exit(0);
		}
		if (!was[to])
			dfs(to, col[v] + e.second);
	}	
}

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	//cout.tie(NULL);

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	scanf("%d%d", &n, &m);
	forn(i, m)
	{
		int v, u, d;
		scanf("%d%d%d", &v, &u, &d);
		g[v].pb({u, d});
		g[u].pb({v, -d});
	}
	//~solve
	forn(i, n)
		if (!was[i])
			dfs(i, 0);
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 11136
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

abc=[list(map(int,input().split())) for i in range(6)]
if abc[4][0]-abc[0][0]>abc[5][0]:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 69020
#include<bits/stdc++.h>
using namespace std;
#define vll vector<ll>tm#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
void solve()
{
	long long n;
	cin>>n;
	long a[n];
	for(long long i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	if(a[0]==0)
	{
		cout<<0;
		return;
	}
	long long ans=1;
	
	long long tm = 1e18;
	
	for(long long i=0;i<n;i++)
	{
		if((tm/ans) >= a[i]) 
		{
			ans*=a[i];
		}
		else
		{
			cout<<-1;
			return;
		}
	}
	cout<< ans << endl;
}
	

int main()
{
    long long q;
    q=1;
    while(q--)
    {
        solve();
    }
}

Measured memory_bytes: 4372
n, m = map(int, input().split())
par = list(range(n))

def find(x):

    while par[x] != x:
        par[x] = par[par[x]]
        x = par[x]

    return x


def union(x, y):
    x1 = find(x)
    y1 = find(y)
    if x1 != y1:
        par[x1] = y1


for j in range(m):
    a, b = map(int, input().split())
    union(a - 1, b - 1)

s = [0 for i in range(n + 1)]

for k in range(n):
    s[find(k)] += 1


print(max(s))


Measured memory_bytes: 18364
#include <iostream>
#include <string>
#include <deque>
#include <cstdlib>

using namespace std;

const long long INF = 1LL << 60;
typedef long long int lli;

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

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

    int a[n];
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        a[i] = tmp;
    }

    lli min_cost[n];
    for (int i = 0; i < n; ++i) min_cost[i] = INF;
    min_cost[0] = 0;

    for (int i = 1; i < n; ++i) {
        for (int j = 1; j < k+1; ++j) {
            if (i - j < 0) break;
            chmin(min_cost[i], abs(a[i] - a[i-j]) + min_cost[i-j]);
        }
    }

    cout << min_cost[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    for(char c : S){
        char k = c + N;
        if(k > 'Z') k = k - 1 - 'Z' + 'A';
        cout << k;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




int main() {
    ll n, h;
    cin >> n >> h;
    ll max_a = 0;
    vector<ll> b(n);
    REP(i, n){
        ll a, t;
        cin >> a >> t;
        max_a = max(max_a, a);
        b[i] = t;
    }
    sort(b.begin(), b.end(), greater<ll>());
    
    ll ans = 0, sum = 0;
    REP(i, n){
        if(max_a > b[i]){
            break;
        }
        sum += b[i];
        ans++;
        if(sum >= h){
            break;
        }
    }
    if(sum < h){
        ans += ((h - sum) % max_a == 0)? (h - sum) / max_a : (h - sum) / max_a + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

const int N = 5e5 + 5;
ll fact[N], inv[N];

void pre()
{
    fact[0] = inv[0] = 1;
    for(ll i=1;i<N;i++)
    {
        fact[i] = (fact[i-1]*i)%M;
        inv[i] = powerm(fact[i],M-2);
    }
}

ll C(ll n,ll r)
{
    ll ans = (fact[n]*inv[r])%M;
    ans = (ans*inv[n-r])%M;
    return ans;
}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	ll n,m; cin>>n>>m;
	pre();
    ll ans = 0;
    for(ll i=0;i<=n;i++)
    {
        ll g = ( C(n,i)*C(m-i,n-i) )%M;
        g = (g*fact[n-i])%M;
        if(i&1) g = -g;
        ans += g;
        ans %= M;
        ans += M;
        ans %= M;
    }
    ll g = (C(m,n)*fact[n])%M;
    ans = (ans*g)%M;
    cout<<ans;

	return 0;
}


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, k, ans = 0;
    cin >> n >> k;
    if(k > (n - 1) * (n - 2) / 2){
        cout << -1 << endl;
    }else{
        int m = n - 1 + ((n - 1) * (n - 2) / 2 - k);
        cout << m << endl;
        for(int i = 2; i <= n; i++){
            cout << 1 << " " << i << endl;
        }
        m -= n - 1;
        for(int i = 2; i <= n; i++){
            for(int j = i + 1; m > 0 && j <= n; j++){
                cout << i << " " << j << endl;
                m--;
            }
            if(m <= 0) break;
        }
    }
    return 0;
}


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

int main() {
    int n, ans;
    cin >> n;
    ans = 0;
    vector<int> vec(n);
    for (int j = 0; j < n; j++){
        cin >> vec.at(j);
    }

    for (int i = 0; i < n; i++){
        if ((i+1)%2 == 1 && vec.at(i)%2 == 1){
            ans += 1;
        }
    }

cout << ans <<endl;

}

Measured memory_bytes: 3596
import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
C=[0]*n
for _ in range(k):
  d=int(input())
  A=[int(i) for i in input().split()]
  for a in A:
    C[a-1]+=1
ans=0
for c in C:
  if c==0:
    ans+=1
print(ans)

Measured memory_bytes: 9192
import math
import bisect
import collections
import itertools
import heapq
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
total = 0
index = 0
for i in range(1, N+1):
    total += i
    if total >= N:
        index = i
        break
diff = total-N
for i in range(1, index+1):
    if diff == i: continue
    print(i)


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int>bo(n);
  for(int i=0;i<n;i++)
    cin >> bo.at(i);
  sort(bo.begin(),bo.end(),greater());
  int ans=0;
  for(int i=0;i<k;i++)
    ans+=bo.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 3548
use proconio::{input, fastout};
use proconio::marker::Chars;
use im_rc::HashMap;

#[fastout]
fn main() {
    input! {
        s: Chars,
    }
    let n = s.len();
    let mod_: usize = 2019;
    let mut t: usize = 0;
    let mut p: usize = 1;
    let mut counter: HashMap<usize, usize> = HashMap::new();
    counter.insert(0, 1);

    for d in 0usize..n {
        let c = s[n - d - 1].to_digit(10).unwrap() as usize;

        t = (t + c * p) % mod_;
        *counter.entry(t).or_insert(0) += 1;
        p = p * 10 % mod_;
    }

    let ans: usize = counter.values().map(|c| c * (c - 1) / 2).sum();

    println!("{:?}", ans);
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<ll> v, w;
  rep(i,N){
    ll x, y;
    cin >> x >> y;
    v.emplace_back(x+y);
    w.emplace_back(x-y);
  }
  sort(ALLOF(v));
  sort(ALLOF(w));

  ll ret = 0;
  ret = max(ret, abs(v[0]-v[v.size()-1]));
  ret = max(ret, abs(w[0]-w[w.size()-1]));

  cout << ret << endl;
  
  return 0;
}



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

int main() {
  int N;
  cin >> N;
  int S = 1;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
    cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  for (int j=1; j < vec.size(); j++){
    if (vec.at(j-1) < vec.at(j))
      S++;
  }
  cout << S << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String slimes = sc.next();
		int numberOfSlimes = 0;
		char lastColour = 0;
		for(int i = 0; i < N; i++) {
			
			char colourAt = slimes.charAt(i);
			if(colourAt == lastColour) {
				
			}else {
				numberOfSlimes++;
			}
			lastColour = colourAt;
			
		}
		System.out.println(numberOfSlimes);

	}

}


Measured memory_bytes: 26392
#include <bits/stdc++.h>
#define N 101
#define mod 1000000007
#define ll long long
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define prob "K"
#define fast ios_base:: sync_with_stdio(1); cin.tie(nullptr); cout.tie(nullptr);
#define io freopen(prob".inp","r",stdin); freopen(prob".out","w",stdout);
using namespace std;
int n,k,a[N],mi=INT_MAX;
bool f[100001];
void read()
{
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>a[i],mi=min(a[i],mi);
}
void solve()
{
    for(int i=0; i<=k-mi; i++)
    {
        if(!f[i])
            for(int j=1; j<=n; j++)
            {
                if(i+a[j]>k)
                    continue;
                f[i+a[j]]=1;
                //cout<<f[i][1]<<'*'<<f[i][2]<<' ';
            }
        // cout<<endl;
    }
    if(f[k])
        cout<<"First";
    else
        cout<<"Second";
}
int main()
{
    fast
 //   io
    read();
    solve();
}


Measured memory_bytes: 384
n = int(input())

S = [False for i in range(13)]
D = [False for i in range(13)]
C = [False for i in range(13)]
H = [False for i in range(13)]


for i in range(n):
    a,b = input().split()
    b = int(b)
    if a == "S":
        S[b-1] = True
    elif a == "D":
        D[b-1] = True
    elif a == "C":
        C[b-1] = True
    elif a == "H":
        H[b-1] = True
        
for i in range(13):
    if S[i] == False:
        print("S "+str(i+1))

for i in range(13):
    if H[i] == False:
        print("H "+str(i+1))
        
for i in range(13):
    if C[i] == False:
        print("C "+str(i+1))
        
for i in range(13):
    if D[i] == False:
        print("D "+str(i+1))

Measured memory_bytes: 7700
#include <bits/stdc++.h> 
using namespace std;
 
int main(){
  
  string s;
  cin>>s;
  if(s=="A" || s=="B" || s=="C" || s=="D" || s=="E" || s=="F" || s=="G" || s=="H" || s=="I" || s=="J" || s=="K" || s=="L" || s=="M" || s=="N" || s=="O" || s=="P" || s=="Q" || s=="R" || s=="S" || s=="T" || s=="U" || s=="V" || s=="W" || s=="Y" || s=="X" || s=="Z" ){
    cout<<"A"<<endl;
  }
  else{
    cout<<"a"<<endl;
  }
  
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int main(){
string s,t;
  cin>>s>>t;
  int count=0;
  for(int i=0;i<s.size();i++)
    if(s[i]==t[i])
      count++;
  cout<<count;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<functional>
using namespace std;

const int dev = 1e9+7;
typedef unsigned long long ull;

typedef vector<int> Edges;
typedef vector<Edges> Graph;
const int N_MAX = 400000;

int checkG[N_MAX];
int checkH[N_MAX];

struct mix{
    int v;
    int Gmark;
    int Hmark;
    mix(int v, int Gmark, int Hmark): v(v), Gmark(Gmark), Hmark(Hmark) {}
    bool operator<(const mix& right)const{
        return Gmark == right.Gmark ? Hmark < right.Hmark : Gmark < right.Gmark;
    }
};

void dfsG(Graph &G, int s, int mark){
    if(checkG[s] != -1) return;
    checkG[s] = mark;
    for (int i=0;i<G[s].size();i++){
        if(checkG[G[s][i]] == -1){
            dfsG(G, G[s][i], mark);
        }
    }
}

void dfsH(Graph &G, int s, int mark){
    if(checkH[s] != -1) return;
    checkH[s] = mark;
    for (int i=0;i<G[s].size();i++){
        if(checkH[G[s][i]] == -1){
            dfsH(G, G[s][i], mark);
        }
    }
}

void Connectivity(Graph &G, Graph &H){
    int N = G.size();
    for(int i=0;i<N;i++){
        checkG[i] = -1;
        checkH[i] = -1;
    }
    for (int i=0;i<N;i++){
        dfsG(G, i, i);
    }
    for(int i=0;i<N;i++){
        dfsH(H, i, i);
    }
    vector<mix> mixes;
    for (int i=0;i<N;i++){
        mix m(i, checkG[i], checkH[i]);
        mixes.push_back(m);
    }
    sort(mixes.begin(), mixes.end());
    vector<int> count(N, 0);
    for(int i=0;i<N;i++){
        count[mixes[i].v] = upper_bound(mixes.begin(), mixes.end(), mixes[i]) - lower_bound(mixes.begin(), mixes.end(), mixes[i]);
    }
    for (int i=0;i<N;i++){
        cout << count[i] << endl;
    }
}

int main(){
    int N, K, L, p, q, r, s;
    cin >> N >> K >> L;
    Graph G(N), H(N);
    for (int i=0;i<K;i++){
        cin >> p >> q;
        p--;q--;
        G[p].push_back(q);
        G[q].push_back(p);
    }
    for (int i=0;i<L;i++){
        cin >> r >> s;
        r--;s--;
        H[r].push_back(s);
        H[s].push_back(r);
    }
    Connectivity(G, H);
    return 0;
}

Measured memory_bytes: 21660
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n+1-i):
        if i * 10000 + j * 5000 + (n-i-j) * 1000 == y:
            print(i, j, n-i-j)
            exit()
else:
    print(-1, -1, -1)

Measured memory_bytes: 40684
N = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
A = [int(input()) for i in range(N)]
greatest = max(A)

if A.count(greatest)==1:
    B = list(set(A))
    B.remove(greatest)
    for i in range(N):
        if A[i] != greatest:
            print(greatest)
        else:
            print(max(B))

else:
    for i in range(N):
        print(greatest)


Measured memory_bytes: 17188
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> l(2 * n), sum(n);
	int ans = 0;
	for (int i = 0; i < 2 * n; i++) cin >> l[i];
	sort(l.begin(), l.end());
	for (int i = 0; i < 2 * n; i += 2) {
		sum[i / 2] = min(l[i], l[i + 1]);
	}
	for (int i = 0; i < n; i++) {
		ans += sum[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 9223372036854775807
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n,a,b;
  cin >> n >> a >> b;
  
  vector <ll>h(n);
  REP(i,n) cin >> h[i];
  
  sort(h.begin(),h.end(),greater<ll>());

  ll ng = 0, ok = MOD;
  while(ok-ng > 1){
    ll check = (ok+ng)/2;
 //   cout << check << ":";
    vector<ll> c;
    c = h;
    REP(i,n){
      c[i] -= check*b;
    }
    int k = 0;
    ll cnt = check;
    while(c[k] > 0 && cnt >= 0 && k<n){
      cnt -= ceil((double)c[k]/(a-b));
      k++;
    }
    if(cnt < 0) ng = check;
    else	    ok = check;
//    cout << ng << " " << ok << endl;
  }
  
  cout << ok << endl;
  
  return 0;
}

Measured memory_bytes: 1792
from collections import deque
n = int(input())
dl = deque()
for _ in range(n):
    cmd = input()
    if ' ' in cmd:
        op,v = cmd.split()
    else:
        op = cmd
    if   op == 'insert'     : dl.appendleft(v) 
    elif op == 'delete'     :
        try: dl.remove(v)
        except ValueError: pass
    elif op == 'deleteFirst': dl.popleft() 
    elif op == 'deleteLast' : dl.pop() 
print(*dl)

Measured memory_bytes: 71696
import sys
N, K = map(int, input().split())

max = (N-1) * (N-2) // 2

if K > max:
    print('-1')
    sys.exit(0)

print(N-1 + max-K)

# print star
for i in range(N - 1):
    print("%d %d" % (i+1, N))

edges = []

for i in range(N-1):
    for j in range(i):
        edges.append([i+1, j+1])

for i in range(max-K):
    print("%d %d" % (edges[i][0], edges[i][1]))


Measured memory_bytes: 41584
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
using namespace std;
 
int main(){
    
    int N,V[100],C[100],ans=0;

    cin >> N;

    for(int i=1;i<=N;i++){
        cin >>V[i];
    }
    for(int i=1;i<=N;i++){
        cin >>C[i];
    }

    for(int i=1;i<=N;i++){
        if((V[i]-C[i])>0){
            ans += (V[i]-C[i]);
        }
    }

        

    cout << ans <<endl;

    return 0;

}

Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut l: Vec<usize> = vec(n, |_| scan(tokens));
    l.sort();
    let mut cnt = 0;
    for i in 0..n {
        for j in i + 1..n {
            let a = binsearch(&l[j + 1..], l[j] - l[i] + 1);
            let b = binsearch(&l[j + 1..], l[i] + l[j]);
            cnt += b - a;
        }
    }
    println!("{}", cnt);
}

fn binsearch(v: &[usize], q: usize) -> usize {
    if v.is_empty() || q <= v[0] {
        return 0;
    }
    let mut a = 0;
    let mut b = v.len();
    while a + 1 < b {
        let c = (a + b) / 2;
        if v[c] < q {
            a = c;
        } else {
            b = c;
        }
    }
    b
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    ll n;
    cin >> n;
    vector<pair<ll, ll>> v;

    int ans = pow(10, 9);
    repd(i, 1, sqrt(n) + 1) {
        if (n % i == 0) {
            v.push_back(make_pair(i, n / i));
        }
    }

    rep(i, v.size()) {
        int temp_a = v[i].first;
        int num_a = 0;
        while (temp_a > 9) {
            temp_a /= 10;
            num_a++;
        }

        int temp_b = v[i].second;
        int num_b = 0;
        while (temp_b != 0) {
            temp_b /= 10;
            num_b++;
        }

        int temp = max(num_a, num_b);
        ans = min(ans, temp);
    }

    cout << ans << endl;

    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 256
import time

class segTree:
    size = 0
    data = []
    __unitElement = 0
    __tree = []
    __totalSize = 0
    
    def __init__(self, inputData):
        self.data = inputData
        tmp = 1
        while tmp < len(inputData):
            tmp *= 2
        self.size = tmp
        self.__totalSize = 2*self.size-1
        self.__tree = [self.__unitElement]*self.__totalSize
        for i in range(len(inputData)):
            self.change(i, inputData[i])
    
    def change(self, i, x):
        self.data[i] = x
        cur = self.size-1+i
        self.__tree[cur] = x
        while True:
            cur = cur-1
            if cur < 0:
                break
            cur = cur//2
            # change this line when needed
            self.__tree[cur] = self.__tree[2*cur+1] + self.__tree[2*cur+2]
  

    def __queryBody(self, i, a, b, left, right):
        if right <= a or b <= left: # no intersection
            return self.__unitElement
        elif a <= left and right <= b:
            return self.__tree[i]
        else:
            mid = (left+right)//2
            child1 = self.__queryBody(2*i+1, a, b, left, mid)
            child2 = self.__queryBody(2*i+2, a, b, mid, right)
            return child1 + child2 # change here if needed
            
    # query about [a,b)
    def query(self, a, b):
        return self.__queryBody(0, a, b, 0, self.size)
        
## definition of segTree ended


n, q = map(int, input().split())
s = segTree([0]*n)  

for _ in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        cur = s.data[x-1]
        s.change(x-1, cur+y)
    else:
        print(s.query(x-1, y))




Measured memory_bytes: 11564
def main():
    S = str(input())

    count = 0
    for s in S:
        if count == 0:
            count = 1
            if (s != "R") & (s != "U") & (s != "D"):
                return "No"
        else:
            count = 0
            if (s != "L") & (s != "U") & (s != "D"):
                return "No"
    return "Yes"

if __name__ == '__main__':
    print(main())

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  vector<ll> list(5);
  for (ll i = 0; i < 5; i++) {
    ll v;
    scanf("%lld", &v);
    list[i] = v;
  }

  for (ll i = 0; i < 5; i++) {
    if (list[i] == 0) {
      cout << i + 1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 3632