akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modInv(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modInv(fact))%p;
}

void pushHeap(vector<int>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

int popHeap(vector<int>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  int i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

vector<int> ver;
void dfs(const graph &g,int v){
  ver[v]=1;
  for(auto i:g[v]){
    if(ver[i]!=1)continue;
    dfs(g,i);
  }
}

bool cmp(int a,int b,int c,int d){
  if(a<c && b<d)return true;
  else return false;
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  for(i=0;i<n;i++){
    if(a[i]>i){
      cout<<-1<<endl;
      return 0;
    }
  }
  for(i=1;i<n;i++){
    if(a[i-1]+1<a[i]){
      cout<<-1<<endl;
      return 0;
    }
  }
  ll ans=0;
  for(i=n-1;i>=0;i--){
    if(i==n-1 || a[i]>=a[i+1]){
      ans+=a[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

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

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

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MOD = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-7;


const int MAX = 303;

int DP[MAX][MAX][MAX];
char S[MAX];
int K;

int get(int l, int r, int k)
{
    if (l == r)return 1;
    if (r < l)return 0;
    int& res = DP[l][r][k];
    if (res != -1)return res;
    res = max(res, get(l+1, r, k));
    res = max(res, get(l, r - 1, k));
    if (S[l] == S[r])res = max(res, get(l + 1, r - 1, k) + 2);
    if (k < K)res = max(res, get(l+1, r-1, k+1) + 2);
    return res;
}


int main()
{

    scanf("%s", S);
    scanf("%d", &K);
    int n = strlen(S);
    FILL(DP, -1);
    cout << get(0, n-1, 0) << endl;
    
    
}


Measured memory_bytes: 108928
#include<stdio.h>

int main(void) {
  int maxA=-1, maxB=-1, maxC=-1, tmp, i;

  for(i=0; i<10; i++) {
    scanf("%d", &tmp);
    if(maxA<tmp) {
      maxC = maxB;
      maxB = maxA;
      maxA = tmp;
    }
    else if(maxB<tmp) {
      maxC = maxB;
      maxB = tmp;
    }
    else if(maxC<tmp) {
      maxC = tmp;
    }
  }
  printf("%d\n%d\n%d\n", maxA,maxB,maxC);

  return (0);
}

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


int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int ans = 0;
  int min_xy = min(x, y);
  if (a + b > 2 * c) {
    ans +=  2 * c * min_xy;
  } else {
    ans += (a + b) * min_xy;
  }
  x -= min_xy; y -= min_xy;
  
  if (x > 0) ans += min(a, 2 * c) * x;
  if (y > 0) ans += min(b, 2 * c) * y;
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3544
#include<cstdio>
#include<map>
using namespace std;
 
#define N 100000
#define fs first
#define sc second
typedef pair<int,int> P;

P par[N],x,y,tmp;
int rank[N];

P find(int a){
  if(par[a].fs == a)return par[a];
  tmp = find(par[a].fs);
  return par[a] = P(tmp.fs,tmp.sc + par[a].sc);
}

int main(){
  char c;
  int a,b,w,n,m;
  while(scanf("%d%d",&n,&m),(n||m)){
    for(int i=0;i<n;i++)par[i] = P(i,0);

    for(int i=0;i<m;i++){
      scanf(" %c ",&c);
      if(c=='?'){
	scanf("%d%d",&a,&b);
	a--; b--;
	if(find(a).fs==find(b).fs)printf("%d\n",par[b].sc - par[a].sc);
	else printf("UNKNOWN\n");
      }else{
	scanf("%d%d%d",&a,&b,&w);
	a--; b--;

	x = find(a);
	y = find(b);
	
	if(x.fs!=y.fs){
	  if(rank[x.fs]<rank[y.fs]){
	    par[x.fs] = P(y.fs,y.sc-x.sc-w);
	  }else{
	    par[y.fs] = P(x.fs,x.sc-y.sc+w);
	    if(rank[x.fs] == rank[y.fs])rank[x.fs]++;
	  }
	}
      }
    }
  }
}

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

int main() {
  int N;
  cin >> N;
  string s;
  
  if (N % 10 == 3)
    s = "bon";
  
  else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)
    s = "pon";
  
  else s = "hon";
  
  cout << s << endl;
}


Measured memory_bytes: 3628
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
       for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
       if (par[x] == x) return x;
       return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
       int rx = root(x); //xの根をrx
       int ry = root(y); //yの根をry
       if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
       par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
       int rx = root(x);
       int ry = root(y);
       return rx == ry;
    }
};

int main()
{
    int n, m; cin >> n >> m;
    UnionFind uf(n);
    vint a(m), b(m), c(n, 1);
    rep(i, m) {
        cin >> a[i];
        cin >> b[i];
        a[i]--; b[i]--;
    }

    vll ans;
    ans.push_back((ll)n*(n-1)/2);

    for(int i=m-1; i>0; i--){
        // prvec(c);
        if(uf.same(a[i], b[i])){
            ans.push_back(ans.back());
            continue;
        }
        int ap=uf.par[a[i]], bp=uf.par[b[i]];
        uf.unite(a[i], b[i]);
        ll t;
        t = ans.back() - (ll)c[ap]*c[bp];
        ans.push_back(t);

        c[ap] += c[bp];
        c[bp] = c[ap];
        c[a[i]] = c[ap];
        c[b[i]] = c[ap];
        // c[uf.par[b[i]]] += ap;
    }

    reverse(ALL(ans));
    rep(i, m) pr(ans[i]);
    return 0;}

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

struct test
{
	int num;
	string name;
	int score;

	bool operator<( const test& right ) const {
        return  name.compare(right.name) == 0 ? score > right.score : name.compare(right.name) < 0 ;
    }

};

int main()
{
	int n;
	cin >> n;
	vector<test> v(n);
	for (int i = 0; i < n; i++)
	{
		/* code */
		v[i].num = i + 1;
		cin >> v[i].name >> v[i].score;
	}

	sort(v.begin(),v.end());
	for (int i = 0; i < n; i++)
	{
		cout << v[i].num << endl;
		/* code */
	}
	
	

	
}

Measured memory_bytes: 256
N = int(input())
l = list(map(int,input().split()))
c = 0
for i in range(len(l)):
    for j in range(i+1, len(l)):

        for k in range(j+1, len(l)):
            if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
                    c += 1


print(c)



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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int totolW = s.back() == 'W';
    vi numsW(n);
    for (int i = 0; i < n - 1; ++i) {
        if (s[i] == 'W') {
            ++totolW;
            numsW[i + 1] = numsW[i] + 1;
        } else {
            numsW[i + 1] = numsW[i];
        }
    }
    int ans = 1e9;
    int cur = 0;
    for (int i = 0; i < n; ++i) {
        cur = numsW[i] + (n - totolW) - (i - numsW[i]);
        if (s[i] == 'E') cur -= 1;
        ans = min(cur, ans);
    }
    cout << ans << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();


Measured memory_bytes: 1812
using System;

namespace ABC026A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);


            int c1 = a * b * 1;
            int c2 = a * b * 2;
            int c3 = a * b * 3;

            if (c1 % 2 == 0 && c2 % 2 == 0 && c3 % 2 == 0)
                Console.WriteLine("No");
            else
                Console.WriteLine("Yes");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
#define INF (1<<30)

void solve(){
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    for(int i=0; i<N; i++)
        cin >> v[i] >> w[i];
    
    int MAX_V = 100;
    vector<vector<int>> dp(N+1, vector<int>(MAX_V*N+1,INF));
    
    dp[0][0]=0;
    
    for(int i=0; i<N; i++){
        for(int j=0; j<=MAX_V*N; j++){
            if(j-v[i]>=0)
                dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]);
            else
                dp[i+1][j] = dp[i][j];
        }
    }
    
    int ans = 0;
    for(int j=0; j<=MAX_V*N; j++)
        if(dp[N][j]<=W) ans = max(ans, j);
    
    cout << ans << endl;

    
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}



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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

ll l,a,b,m;

ll modpow(ll a, ll b, ll m){
    ll r = 1;
    a %= m;
    while(b){
        if(b&1)r=r*a%m;
        a=a*a%m;
        b>>=1;
    }
    return r;
}

ll calc1(ll n, ll r){
    if(n<=4){
        ll ret = 0;
        ll x = 1;
        REP(i,n){
            ret += x;
            ret %= m;
            x = x * r % m;
        }
        return ret;
    }else{
        if(n%2==0){
            return calc1(n/2,r)*(1+modpow(r,n/2,m))%m;
        }else{
            return (calc1(n/2,r)*(1+modpow(r,n/2,m))%m + modpow(r,n-1,m)) % m;
        }
    }
}
ll calc2(ll n, ll r){
    if(n<=4){
        ll ret = 0;
        ll x = 1;
        r %= m;
        REP(i,n){
            ret += x*i%m;
            ret %= m;
            x = x * r % m;
        }
        return ret;
    }else{
        ll ret = 0;
        ll n2 = n/2;
        ret += calc2(n2,r)*(1+modpow(r,n2,m))%m;
        ret %= m;
        ret += n2%m*modpow(r,n2,m)%m*calc1(n2,r)%m;
        ret %= m;
        if(n%2==1){
            ret += (n-1)%m*modpow(r,n-1,m)%m;
            ret %= m;
        }
        return ret;
    }
}

ll solve(ll n, ll a, ll b, int len){
    if(n<=0)return 0;
    ll thr = 1;
    REP(i,len)thr *= 10;
    ll ng = -1, ok = n;
    while(ng+1<ok){
        ll x = (ok+ng)/2;
        (a+b*x>=thr ? ok : ng) = x;
    }
    if(ok==n){
        return solve(n,a,b,len-1);
    }
    thr = thr%m*10%m;
    ll n2 = n-ok;
    ll add = modpow(thr,n2,m) * solve(ok,a,b,len-1) % m;
    a = (a + b * (n-1)) % m;
    b = m-b%m;
    add += a * calc1(n2,thr) % m;
    add += b * calc2(n2,thr) % m;
    return add % m;
}

int main(){
    cin>>l>>a>>b>>m;
    ll ans = solve(l,a,b,18);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD= 1000000007;
signed main() {
int n;
cin>>n;
int x[n],y[n];
for(int i=0;i<n;i++){
  cin>>x[i]>>y[i];
}
long double ans=0;
for(int i=0;i<n;i++){
  for(int j=0;j<n;j++){
    ans+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
  }
}
cout << std::setprecision(20)<<ans/n;
return 0;



}


Measured memory_bytes: 256
#nの約数列挙
def devisor(n):
    ans = []
    for i in range(1,int(n**0.5)+2):
        if n%i == 0:
            ans.append(i)
            ans.append(n//i)

    return ans       


N,M = list(map(int,input().split()))
a = devisor(M)
a.sort(reverse = True)

for i in a:
    check = M//i
    if check >= N:
        print(i)
        break
        

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
typedef vector<int> vint;
typedef vector<long long> vlint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<vector<long long>> vlint2;

lint powint(lint x, lint y){
    int ret = 1;
    for (int i=0; i < y; i++) ret *= x;
    return ret;
};

lint mod = 1000000007;
vector<int> dx = {1, 0, 0, -1, 1, 1, -1, -1};
vector<int> dy = {0, -1, 1, 0, 1, -1, 1, -1};

map<char, long long> counter(string s){
    map<char, long long> count;
    rep(i, s.size()){
        count[s[i]] ++;
    }
    return count;
};

int powmod(int x, int y, int m){
    if (y == 0) return 1;
    return ((powint(powmod(x, y>>1, m), 2) % m) * powint(x, (y & 1))) % m;
};

int main() {
    lint n; cin >> n;
    vlint a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));

    lint cnt = 0;
    vlint ans1;
    vlint ans2;
    lint left = 0;
    lint right = n-1;
    while (true){
        if (cnt % 2 == 0){
            ans1.push_back(abs(a[left]));
            cnt ++; left ++;
        }
        else{
            ans1.push_back(abs(a[right]));
            cnt ++; right --;
        }
        if (ans1.size() == n) break;
    }
    ans1.push_back(ans1[0]);

    left = 0; right = n-1; cnt = 0;
    while (true){
        if (cnt % 2 == 1){
            ans2.push_back(abs(a[left]));
            cnt ++; left ++;
        }
        else{
            ans2.push_back(abs(a[right]));
            cnt ++; right --;
        }
        if (ans2.size() == n) break;
    }
    ans2.push_back(ans2[0]);

    lint a1 = 0;
    lint a1_min = abs(ans1[0] - ans1[1]);
    lint a2 = 0;
    lint a2_min = abs(ans2[0] - ans2[1]);

    rep(i, n){
        lint r1 = abs(ans1[i] - ans1[i+1]);
        a1 += r1;
        a1_min = min(a1_min, r1);

        lint r2 = abs(ans2[i] - ans2[i+1]);
        a2 += r2;
        a2_min = min(a2_min, r2);
    }

    cout << max(a1 - a1_min, a2 - a2_min) << endl;
    



}



Measured memory_bytes: 3316
import Control.Monad
--import Control.Applicative
import Data.Functor
import Data.List

judge [m,f,r]
  | m==(-1) || f==(-1) = "F"
  | c>=80 = "A"
  | c>=65 = "B"
  | c>=50 || (c>=30 && r>=50) = "C"
  | c>=30 = "D"
  | otherwise = "F"
  where c = m + f

main = do
    --d <- fmap (map judge . takeWhile (all (==(-1))) . map (map read . words) . lines) $ getContents 
    d <- map judge . takeWhile (any (/=(-1))) . map (map read . words) . lines <$> getContents 
    mapM_ putStrLn d

Measured memory_bytes: 4040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <math.h>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int ll;


int main(){
	string N;cin>>N;
	int a;cin>>a;

	for(int i=0;i<N.size();i+=a)
		cout << N[i];
	cout << endl;


	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def nCr(n, r):
    """ 事前テーブルなし組み合わせ簡易版 """
    from math import factorial

    if n < r: return 0
    # 10C7 = 10C3
    r = min(r, n-r)
    return factorial(n) // (factorial(r) * factorial(n-r))

N, L, R = MAP()
A = LIST()

A.sort(reverse=1)
C = Counter(A)
mx = cnt = 0
for i in range(L, R+1):
    A2 = A[:i]
    avg = sum(A2) / i
    # 平均がまだ最大なら続ける
    if avg >= mx:
        mx = avg
    else:
        break
    C2 = Counter(A2)
    # 最後の要素が複数あるなら交換可
    a = A2[-1]
    # 全体から必要な数を選ぶ通り数
    cnt += nCr(C[a], C2[a])
print(mx)
print(cnt)


Measured memory_bytes: 3316
def find(a,b,c):
    if c<=a+b:
        return b+c
    else:
        temp=a+b+b
        now=c-(a+b)
        if now>0:
            temp+=1
        return temp

a,b,c=list(map(int,input().split(' ')))


print(find(a,b,c))


Measured memory_bytes: 2940
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    r,d,x = map(int, input().split())
    for i in range(10):
        x = r*x-d
        print(x)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
chomp (my $q = readline ARGV);
my @c;
my $max_r = 0;
for (1..$q) {
  chomp (my ($l, $r) = split / /, readline ARGV);
  push @c, [$l, $r];
  $max_r = $r if $max_r < $r;
}

my @p = (2);
sub prime {
  my $m = shift;
  OUTER: for (my $i=3;$i<=$m;$i+=2) {
    my $s = int($i ** .5);
    for (@p) {
      next OUTER if $i % $_ == 0;
      last if $s < $_;
    }
    push @p, $i;
  }
}
prime($max_r);

my %p = ();
@p{@p} = ();

my %r = (0 => 0);
my $rn = 0;
for my $c (1..$max_r) {
  my $m = ($c + 1) / 2;
  $rn++ if exists $p{$c} && int($m) == $m && exists $p{$m};
  $r{$c} = $rn;
}

my $all = '';
for my $c (@c) {
  my ($l, $r) = @$c;
  $all .= ($r{$r} - $r{($l-1)}) . "\n";
}

print $all;


Measured memory_bytes: 41912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
 
int main() {
  int H,W; cin >> H >> W;
  vector<string> board(H);
  for (int i = 0; i < H; i++) cin >> board[i];
  vector<bool> ycheck(H,false);
  vector<bool> xcheck(W,false);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (board[i][j] == '#') ycheck[i] = true;
    }
  }
  for (int j = 0; j < W; j++) {
    for (int i = 0; i < H; i++) {
      if (board[i][j] == '#') xcheck[j] = true;
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (ycheck[i] && xcheck[j]) cout << board[i][j];
    }
    if (ycheck[i]) cout << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
	
	int tapNum;
	int outletNum;
	
	if(B == 1){
		tapNum = 0;
		outletNum = 1;
	}else{
		tapNum = 1;
		outletNum = A;
	}
	
	for(;;){
		if(outletNum >= B){
			break;
		}else{
			outletNum += A-1;
			tapNum++;
		}
	}
	
    System.out.println(tapNum);
  }
}

Measured memory_bytes: 22228
using System;
using System.Collections.Generic;

namespace AtCoder2020Ned
{
    class Program
    {
        static void Main(string[] args)
        {
            var firstInput = Console.ReadLine().ToCharArray();
            var secondInput = Console.ReadLine().ToCharArray();
            var correctCount = 0;

            for (int i = 0; i < firstInput.Length; i++)
            {
                if (firstInput[i] == secondInput[i])
                {
                    correctCount++;
                    continue;
                }
                else
                {
                    Console.WriteLine("No");
                    break;
                }
            }

            if (correctCount == firstInput.Length)
            {
                Console.WriteLine("Yes");
            }

            Console.Read();
        }
    }
}


Measured memory_bytes: 25816
N = int(input())
S = list()
if N==0:
  print(0)
  exit()
elif N>0:
  while N>0:
    S.append(N%2)
    N//=2
  S.append(0)
  S.append(0)
  for i in range(len(S)-1):
    if i%2==1 and S[i]==1:
      S[i+1] += 1
    if S[i]==2:
      S[i]=0
      S[i+1]+=1
else:
  N *= -1
  while N>0:
    S.append(N%2)
    N//=2
  S.append(0)
  S.append(0)
  for i in range(len(S)-1):
    if i%2==0 and S[i]==1:
      S[i+1] += 1
    if S[i]==2:
      S[i]=0
      S[i+1]+=1
  
S.reverse()
while S[0]==0:
  S = S[1:]
ans = ""
for s in S:
  ans += str(s)
print(ans)


Measured memory_bytes: 9276
// abc project main.go
package main

import (
	"fmt"
)

func main() {
	var a int
	var b int
	var c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	if b-a == c-b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
package main

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

func main() {
	a := getString()
	b := getString()
	c := getString()

	fmt.Println(a[0:1] + b[0:1] + c[0:1])
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define SQ(a) (a)*(a)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ll long long int 
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);	cout.tie(NULL);
    ll n;
    cin >> n;
    vi arr(n);
    for (auto &it: arr)
        cin >> it;
    if (n == 1)
    {
        cout << "Yes\n";
        return 0;
    }
    ll minEle = arr[n - 1];
    for (int i = n - 2; i >= 0; i--)
    {
        if (arr[i] > minEle)
        {
            arr[i]--;
            if (arr[i] > minEle)
            {
                cout << "No\n";
                return 0;
            }
            minEle = arr[i];
        }
        else 
        {
            minEle = arr[i];
        }
    }
    cout << "Yes\n";
    return 0;
}

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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }
#define fi first
#define se second
#define mkp std::make_pair
#define V std::vector
#define H std::priority_queue
typedef long long ll;
typedef double ff;
typedef std::pair <int, int> pii;
const int kN = 3e2 + 5, kInf = 0x3f3f3f3f;
const ll kMod = 1e9 + 7, kInfLL = 0x3f3f3f3f3f3f3f3fLL;

int n, m; ll f[kN][kN][kN];
std::vector <pii> C[kN];
void Update(ll &x, ll y) { x = (x + y) % kMod; }
int main() { 
#ifndef ONLINE_JUDGE
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
#endif
	int T = 1; //rd(T);
	while(T--) {
		rd(n, m);
		for(int i = 1; i <= m; ++i) {
			int l, r, x; rd(l, r, x);
			C[r].push_back(mkp(l, x));
		}
		ll ans = 0;
		f[0][0][0] = 1;
		for(int i = 0; i <= n; ++i)
			for(int j = 0; j <= n; ++j)
				for(int k = 0; k <= n; ++k) {
					int p_max = std::max({i, j, k});
					bool flag = true;
					for(auto p : C[p_max])
						if((i >= p.fi) + (j >= p.fi) + (k >= p.fi) != p.se) flag = false;
					if(flag) {
						//printf("f[%d][%d][%d] = %lld\n", i, j, k, f[i][j][k]);
						Update(f[p_max + 1][j][k], f[i][j][k]);
						Update(f[i][p_max + 1][k], f[i][j][k]);
						Update(f[i][j][p_max + 1], f[i][j][k]);
						if(p_max == n) Update(ans, f[i][j][k]);
					}
				}
		printf("%lld\n", ans);
	} return 0;
}

Measured memory_bytes: 222184
n,k = gets.split.map(&:to_i)

ans = 0
# tail = [n,k-1].min
(1..n).each do |i|
  if i >= k
    ans += 1.0/n
  else
    c = (Math.log2(k/i.to_f)).ceil
    ans += 1.0/(n * (2**c))
  end
end

puts ans

Measured memory_bytes: 1916
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
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 (b < a) { a = b; return true; } return false; }

bool p[5010][5010];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	auto inrange = [&](int i, int j) { return i >= 0 && i < 5010 && j >= 0 && j < 5010; };
	for (int N; cin >> N&&N;) {
		vector<int> x(N), y(N); rep(i, 0, N) {
			cin >> x[i] >> y[i];
			p[x[i]][y[i]] = true;
		}
		int ans = 0;
		rep(i, 0, N)rep(j, i + 1, N) {
			int dx = x[i] - x[j],
				dy = y[i] - y[j];
			if (inrange(x[i] - dy, y[i] + dx) &&
				p[x[i] - dy][y[i] + dx] &&
				inrange(x[j] - dy, y[j] + dx) &&
				p[x[j] - dy][y[j] + dx]) {
				chmax(ans, dx*dx + dy*dy);
			}
			if (inrange(x[i] + dy, y[i] - dx) &&
				p[x[i] + dy][y[i] - dx] &&
				inrange(x[j] + dy, y[j] - dx) &&
				p[x[j] + dy][y[j] - dx]) {
				chmax(ans, dx*dx + dy*dy);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 22576
#include<bits/stdc++.h>
using namespace std;
long long n,ans,s,w[100002],v[100002],dp[102][100002];
int main(){
cin>>n>>s;
for(int k=1;k<=n;k++)
    cin>>w[k]>>v[k];
    for(int k=0;k<=s;k++)
        if(w[1]<=k)
        dp[1][k]=v[1];
for(int k=2;k<=n;k++){
for(int i=0;i<=s;i++){
        if(i==0)
        continue;
   dp[k][i]=dp[k-1][i];
    if(w[k]>i)
        continue;

    long long t=dp[k-1][i-w[k]];
    dp[k][i]=max(dp[k-1][i],t+v[k]);
}
}
cout<<dp[n][s];
return 0;
}


Measured memory_bytes: 79360
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m,s,t = LI()
    s -= 1
    t -= 1
    v = [[] for i in range(n)]
    for i in range(m):
        x,y,a,b = LI()
        x -= 1
        y -= 1
        v[x].append((y,a,b))
        v[y].append((x,a,b))
    d = [float("inf")]*n
    d[s] = 0
    q = [(0,s)]
    while q:
        dx,x = heappop(q)
        if d[x] < dx:
            continue
        for y,a,b in v[x]:
            nd = dx+a
            if nd < d[y]:
                d[y] = nd
                heappush(q,(nd,y))
    c = [float("inf")]*n
    c[t] = 0
    q = [(0,t)]
    while q:
        cx,x = heappop(q)
        if c[x] < cx:
            continue
        for y,a,b in v[x]:
            nc = cx+b
            if nc < c[y]:
                c[y] = nc
                heappush(q,(nc,y))
    s = float("inf")
    N = 10**15
    ans = []
    for i in range(n)[::-1]:
        s = min(s,d[i]+c[i])
        ans.append(N-s)
    for i in ans[::-1]:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}

ll a,b;

ll func(ll x)
{

    ll m= floor((a*x)/b);

       ll n=a*floor(x/b);
       return m-n;
}

int main()
{


   ll n;

   cin >> a >> b >> n;
   ll x= func(b-1);
   ll y=func(n);
   if(b-1 <= n) cout << max(x,y);
   else cout << y;
}


Measured memory_bytes: 3580
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll missile[110][10010];
ll missnum[110];
ll sum[110];

int main() {
    while (1) {
        ll n, d;
        cin >> n >> d;
        if (n == 0) {
            break;
        }
        REP(i, 0, n) {
            cin >> missnum[i];
            ll tmp = 0;
            REP(j, 0, missnum[i]) {
                cin >> missile[i][j];
                tmp += missile[i][j];
            }
            sum[i] = tmp;
        }
        plglg sumcp[n];
        bool ok = true;
        while (ok) {
            ok = false;
            REP(i, 0, n) {
                sumcp[i] = plglg(sum[i], i);
            }
            sort(sumcp, sumcp + n);
            reverse(sumcp, sumcp + n);
            plglg top = sumcp[0];
            ll now = top.first;
            REP(i, 0, n) {
                if (i != top.second) {
                    while(sum[i] - missile[i][missnum[i] - 1] >= now - d && missnum[i] > 0) {
                        ok = true;
                        sum[i] -= missile[i][missnum[i] - 1];
                        missnum[i]--;
                    }
                }
            }
            REP(i, 0, n) {
                sumcp[i] = plglg(sum[i], i);
            }
            sort(sumcp, sumcp + n);
            reverse(sumcp, sumcp + n);
            plglg sec = sumcp[1];
            ll tpnum = top.second;
            while (sum[tpnum] - missile[tpnum][missnum[tpnum] - 1] >= sec.first - d && missnum[tpnum] > 0) {
                ok = true;
                sum[tpnum] -= missile[tpnum][missnum[tpnum] - 1];
                missnum[tpnum]--;
            }
        }
        bool ans = true;
        REP(i, 0, n) {
            if (sum[i] != 0) {
                ans = false;
            }
        }
        if (ans) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}



Measured memory_bytes: 3684
N,M=list(map(int,input().split()))
C=list(map(int,input().split()))

dp = [[0]*len(C) for n in range(N+1)] #dp[n][c]

for n in range(1,N+1):
    dp[n][0] = n
    
for n in range(1,N+1):
    for c in range(1,len(C)):
        if C[c] > n:
            dp[n][c]=dp[n][c-1]
        else:
            dp[n][c]=min(dp[n][c-1],dp[n-C[c]][c]+1)
            
print(dp[-1][-1])


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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	u32 n;

	std::cin >> n;

	std::cout << (n*n) << "\n";
	
	return 0;
}

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int mi = min(a, b);
	int ma = max(a, b);
	if(mi < c && c < ma){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
x = input().split(' ')
l = [int(i) for i in x]

c = 0
'''
i = 0

while i+2 < len(l):
    if l[i] == l[i+1]:
        if l[i+1] == l[i+2]:
            print(i)
            c += 1
            i += 2
        else:
            print(i)
            c += 1
            i += 2
    else:
        if l[i+1] == l[i+2]:
            print(i)
            c += 1
            i += 2
'''

boon = False

for i in range(1,n):
    if not boon and l[i] == l[i-1]:
        c += 1
        boon = True
    else:
        boon = False

print(c)


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
    string S;
    cin >> S;
    bool flag=true;
    for(int i=0; i<S.size(); i++){
        if(i%2==0){
            if(S[i]=='R' || S[i]=='U' || S[i]=='D') continue;
            else flag=false;
        }else{
            if(S[i]=='L' || S[i]=='U' || S[i]=='D') continue;
            else flag=false;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";
    

    return 0;
}

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

int main(){
    string SA,SB,SC;
    cin>>SA>>SB>>SC;
    char tern='a';
    rep(i,301){
        if(tern=='a'){
            if(SA.size()==0){
                cout<<'A'<<endl;
                break;
            }
            //cout<<"現在aのターンです"<<endl;
            tern=SA.at(0);
            SA.erase(0,1);
        }else if(tern=='b'){
            if(SB.size()==0){
                cout<<'B'<<endl;
                break;
            }
            //cout<<"現在bのターンです"<<endl;
            tern=SB.at(0);
            SB.erase(0,1);
        }else if(tern=='c'){
            if(SC.size()==0){
                cout<<'C'<<endl;
                break;
            }
            //cout<<"現在cのターンです"<<endl;
            tern=SC.at(0);
            SC.erase(0,1);
        }else{}
    }
return 0;}
/*compile
g++ code.cpp
./a.out
run*/
/*
int f(int x){
    int y=int((x*x+4.0)/8.0);
    return y;
}
*/


Measured memory_bytes: 256
def solve():
 n = int(input())
 query = []
 for i in range(n):
  a,b = (int(i) for i in input().split())
  query.append((a,b))
 ans = True
 query2 = sorted(query, key=lambda x: x[1])

 time = 0
 for i in range(n):
    a,b = query2[i]
    time += a
    if time >b:
      ans = False
 if ans:
  print("Yes")
 else:
  print("No")
solve()

Measured memory_bytes: 76888
N=int(input())
A=list(map(int,input().strip().split()))
B=list(map(int,input().strip().split()))
"""
添字が小さい方の街からどんどん倒していけば良い。
iとi+1を倒して、B[i+1]がまだ余っている場合に、
それをi+2のモンスター倒しに繰り越して利用する。
B[i]が余っている時、その余りをi+2以降のモンスター退治に繰り越さないよう注意
"""
remain=max(0,B[0]-A[0])
mons=min(A[0],B[0])
for n in range(1,N):
    mons+=min(remain+B[n],A[n])
    remain=max(0,B[n]-max(A[n]-remain,0))
mons+=min(remain,A[N])
print(mons)

Measured memory_bytes: 24132
from heapq import heappush, heappop


def solve(k, ax, bx, cx, x, y, z):
    ans = []
    heap = [(-(ax[0] + bx[0] + cx[0]), 0, 0, 0)]
    d = {(0, 0, 0)}

    for _ in range(k):
        s, ai, bi, ci = heappop(heap)
        ans += [-s]

        if (ai+1, bi, ci) not in d and ai+1 < x:
            heappush(heap, (-(ax[ai+1] + bx[bi] + cx[ci]), ai+1, bi, ci))
            d.add((ai+1, bi, ci))
        if (ai, bi+1, ci) not in d and bi+1 < y:
            heappush(heap, (-(ax[ai] + bx[bi+1] + cx[ci]), ai, bi+1, ci))
            d.add((ai, bi+1, ci))
        if (ai, bi, ci+1) not in d and ci+1 < z:
            heappush(heap, (-(ax[ai] + bx[bi] + cx[ci+1]), ai, bi, ci+1))
            d.add((ai, bi, ci+1))

    return ans


if __name__ == "__main__":
    x, y, z, k = map(int, input().split())
    ax = sorted(list(map(int, input().split())), reverse=True)
    bx = sorted(list(map(int, input().split())), reverse=True)
    cx = sorted(list(map(int, input().split())), reverse=True)
    ans = solve(k, ax, bx, cx, x, y, z)
    print(*ans, sep="\n")


Measured memory_bytes: 4848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		char c = scan.next().charAt(0);

		if (Character.isUpperCase(c)) {
			System.out.println("A");
		} else {
			System.out.println("a");
		}

	}

}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int cnt = 0;
  for(int i=0; i<S.size(); i++){
    if(S.at(i) != S.at(S.size()-1-i)){
      cnt++;
    }
  }
  cout << (cnt+1) / 2 << endl;
}

Measured memory_bytes: 256
import numpy as np
from collections import deque

N = int(input())

# ある辺の両端のノードの番号の和(必ず片方のノード番号はわかっているのでこれで通じる)
branch_add = np.zeros(N, dtype="int")

ans = np.zeros(N - 1)

# 頂点から見た辺の個数の計算
appeard = np.zeros(N, dtype="int")

# 2次元配列ではメモリが不足しそうなので多重配列で接続先の辺の情報を記録する
branch_list = [[] for _ in range(N)]

for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    branch_add[i] = a + b
    appeard[a] += 1
    appeard[b] += 1
    # 頂点の接続先の情報
    branch_list[a].append(i)
    branch_list[b].append(i)

# あるノードから一番多く伸びている枝の数が色の数
color_num = np.max(appeard)

start_node = (np.where(appeard == color_num)[0])[0]

# 幅優先探索で色塗りを行う。変数は順番に「色を塗る辺がある頂点、色を塗った辺の番号、その色」
color_queue = deque()

# 最初のノードの色を塗る
for c, i in enumerate(branch_list[start_node]):
    color_queue.append([branch_add[i] - start_node, i, c])
    ans[i] = c

while len(color_queue) > 0:
    next_queue = color_queue.popleft()
    node = next_queue[0]
    colored_branch = next_queue[1]
    color = next_queue[2]
    color_index = 0
    for i in branch_list[node]:
        # 色を塗ったノードは無視
        if i == colored_branch:
            continue
        # 同じ色では塗らない
        if color_index == color:
            color_index += 1
        color_queue.append([branch_add[i] - node, i, color_index])
        ans[i] = color_index
        color_index += 1

print(color_num)

for i in range(N - 1):
    # 色の情報は1から始まることに注意
    print(int(ans[i] + 1))

Measured memory_bytes: 32040
N,M=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]

_A=[0]
sum=0
d={0:1}
key=[0]
for i in range(N):
    sum=(sum+A[i])%M
    try:
        d[sum]+=1
    except KeyError:
        d[sum]=1
        key.append(sum)

count=0
for i in key:
    _count=d[i]

    count+=(_count-1)*_count/2
print(int(count))


Measured memory_bytes: 14252
A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0

flag = False
for i in range(3):
    if sum(A[i]) == 0:
        flag = True

for i in range(3):
    s = A[0][i] + A[1][i] + A[2][i]
    if s == 0:
        flag = True

s = A[0][0] + A[1][1] + A[2][2]
if s == 0:
    flag = True
s = A[0][2] + A[1][1] + A[2][0]
if s == 0:
    flag = True

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <stdio.h>


 int main()
 {
   int a,b,X;
   char op;

  while (1) {

   scanf("%d  %c  %d",&a,&op,&b);

    if(op == '?')break;

    else if (op == '+') {

      X = a+b;
    }
    else if (op == '-'){
      X = a-b;
    }
    else if (op == '*'){
      X = a*b;
    }
    else {
      X = a/b;
    }

    printf("%d\n",X);
  }

return(0);
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	private static int N;
	private static int W;
	private static long[][] dp;
	private static int[] w;
	private static int[] v;
	final static Long INF = Long.MAX_VALUE/100;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		W = sc.nextInt();
		dp = new long[N+1][N*1000+1];
		w = new int[N+1];
		v = new int[N+1];
		w[0] = 0; v[0] = 0;
		for(int i = 1; i <= N; i++) {
			w[i] = Integer.parseInt(sc.next());
			v[i] = Integer.parseInt(sc.next());
		}
		for(int i = 0; i <= N; i++) {
			for(int j = 0; j <= N*1000; j++) {
				dp[i][j] = INF;
			}
		}
		for(int i = 0; i <= N; i++) {
			dp[i][0] = 0;
		}
		for(int i = 1; i <= N; i++) {
			for(int j = 1; j <= N*1000; j++) {
				if(j-v[i] >= 0) {
					dp[i][j] = Math.min(dp[i-1][j], dp[i-1][j-v[i]]+w[i]);
				}else {
					dp[i][j] = dp[i-1][j];
				}
			}
		}

		for(int i = N*1000; i >= 0; i--) {
			if(dp[N][i] <= W) {
				System.out.println(i);
				break;
			}
		}
		sc.close();
	}

}

Measured memory_bytes: 126676
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
ll n,m,ans;
ll a[200005],b[200005];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        cin>>b[n-i+1];
    }
    ll l=1;
    for(int i=1;i<=n;i++){
		if(a[i]!=b[i])continue;
		while(!(a[i]==b[i]&&a[i]!=a[l]&&b[i]!=b[l])){
			l++;
			if(l>n){
				cout<<"No";
				//system("pause");
				return 0;
			}
		}
		swap(b[l],b[i]);
	}
	cout<<"Yes\n";
	for(int i=1;i<=n;i++)cout<<b[i]<<" ";
    return 0;
}


Measured memory_bytes: 6736