akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);




	int a, b, c, k;
	cin >> a >> b >> c >> k;
	for(int i = 0; i < k; ++i) {
		if(c <= b) {
			c *= 2;
		}
		else if(b <= a) {
			b *= 2;
		}
		if(a < b && b < c) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;//*/
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll unsigned long long
#define maxn 500005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    while (cin >> n) {
        ll mi = 2e18;
        for (ll i = 1 ; i <= sqrt(n) ; i++) {
            if (n % i) {
                continue;
            }
            mi = min(mi, i + n / i);
        }
        cout << mi - 2 << '\n';
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int n=0;
        
        for(int i=a;i<=b;i++)
        if(c%i==0) n++;
        
        System.out.println(n);
        }

    
}


Measured memory_bytes: 26416
#include <iostream>

#define int long long

using namespace std;

const int N = 2e5 + 10;

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    int s, w;
    cin >> s >> w;
    if (w >= s) cout << "unsafe";
    else cout << "safe";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
char a[100005];
int length;
int main() {
	cin>>a;
	length=strlen(a);
	if(a[0]==a[length-1]){
		if(length%2==1) cout<<"Second";
		else cout<<"First";
	}
	else{
		if(length%2==1) cout<<"First";
		else cout<<"Second";
	}
	return 0;
}

Measured memory_bytes: 384
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let a: usize = it.next().unwrap().parse().unwrap();
    let b: usize = it.next().unwrap().parse().unwrap();
    if a <= 9 && b <= 9 {
        println!("{}", a * b);
    } else {
        println!("-1");
    }
}

fn main() {
    run();
}

Measured memory_bytes: 4352
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

bool cmpr(pii a, pii b) { 
    return  (a.ff > b.ff) ; 
}
bool cmpb(pii a, pii b) { 
    return  (a.ss <= b.ss) ; 
} 

bool vis[101];

inline void solve(){
    int n; cin>>n; 
    vector <pii>  red(n), blue(n) ; 
    for (int i=0;i<n;i++) cin >> red[i].ff >> red[i].ss ; 
    for (int i=0;i<n;i++) cin >> blue[i].ff >> blue[i].ss ; 
    sort(all(red),cmpr) ; 
    sort(all(blue),cmpb) ; 
    int ans = 0;
    for (int i=0;i<n;i++){
        for (int j=0;j<n;j++){
            if (red[j].ff < blue[i].ff and red[j].ss < blue[i].ss and !vis[j]) {
                ans++; 
                vis[j] = true; 
                break; 
            }
        }
    }
    co(ans) ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3616
use std::io::*;
use std::str::FromStr;

fn main() {
    let t: f64 = read();
    let x: f64 = read();
    println!("{}", t / x);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main() {
    long a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0) {
        cout << (a + b) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

#define mk make_pair
#define pb push_back
#define sc(t) scanf("%d",&t)
#define sc3(t,u,v) scanf("%d %d %d",&t,&u,&v)
#define sc2(t,u) scanf("%d %d",&t,&u)
#define scL(t) scanf("%lld",&t)
#define scL3(t,u,v) scanf("%lld %lld %lld",&t,&u,&v)
#define scL2(t,u) scanf("%lld %lld",&t,&u)
#define mem(a,i) memset(a,i,sizeof a)
#define pcase(x,y) printf("Case %d: %d\n",x,y)
#define pcase2(x) printf("Case #%d:\n",x)
#define inf 1e18
#define sett(n) (mark[n>>5] |= (1<<(n&31)))
#define check(n) (mark[n>>5]&(1<<(n&31)))
#define endd printf("\n")

int main()
{
    int n,k = 0,u,v,w,cas=1;
    sc(n);
    u = n;
    while(n!=0){
        k += (n%10);
        n = n/10;
    }
    if(u%k==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	int an = 0;
	if (C > A - B) {
		an = C - A + B;
	}
	else {
		an = 0;
	}
	cout << an;
}

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

double sqr(double a) {
    return a * a;
}

double dist(double x, double y) {
    return sqr(x) + sqr(y);
}

bool comp(pair<double, double> a, pair<double, double> b) {
    return atan2(a.first, a.second) < atan2(b.first, b.second);
}

void solve() {
    int n;
    cin >> n;
    vector<pair<double, double> > pt(n);
    vector<double> dpx(n), dpy(n);
    for (int i = 0; i < n; i++)
        cin >> pt[i].first >> pt[i].second;

    sort(pt.begin(), pt.end(), comp);

    double ans = 0.;
    for (int i = 0; i < n; i++) {
        double x = pt[i].first, y = pt[i].second;
        ans = max(ans, sqrt(dist(x, y)));
        for (int k = 1; k < n; k++) {
            int j = (i + k) % n;
            x += pt[j].first;
            y += pt[j].second;
            ans = max(ans, sqrt(dist(x, y)));
        }
    }
    for (int i = 0; i < n; i++) {
        double x = pt[i].first, y = pt[i].second;
        ans = max(ans, sqrt(dist(x, y)));
        for (int k = 1; k < n; k++) {
            int j = (i - k) % n;
            if (j < 0)
                j += n;
            x += pt[j].first;
            y += pt[j].second;
            ans = max(ans, sqrt(dist(x, y)));
        }
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 2868.cc: Hierarchical Calculator
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 60;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N], v0[MAX_N], v1[MAX_N];
ll dp[2][MAX_N + 1];
int ls[2][MAX_N + 1], ps[2][MAX_N + 1], qs[2][MAX_N + 1];

/* subroutines */

inline void p2v(int l, int i0, int j0, int v[]) {
  for (int k = l - 1; k >= 0; k--) {
    v[k] = j0;
    int i1 = ps[i0][j0], j1 = qs[i0][j0];
    i0 = i1, j0 = j1;
  }
}

bool lex_lt(int l, int i0, int j0, int i1, int j1) {
  p2v(l, i0, j0, v0);
  p2v(l, i1, j1, v1);
  for (int i = 0; i < l; i++)
    if (v0[i] != v1[i]) return (v0[i] < v1[i]);
  return false;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  for (int i = 0; i < 2; i++) {
    fill(dp[i], dp[i] + n + 1, 1);
    fill(ps[i], ps[i] + n + 1, -1);
    fill(qs[i], qs[i] + n + 1, -1);
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < i; j++) {
      ll d0 = dp[0][j] * as[i - 1], d1 = dp[1][j] * as[i - 1];
      int l0 = ls[0][j] + 1, l1 = ls[1][j] + 1;
      int p0 = 0, p1 = 1;
      if (d0 < d1) 
	swap(d0, d1), swap(l0, l1), swap(p0, p1);

      if (dp[0][i] < d0 ||
	  (dp[0][i] == d0 &&
	   (ls[0][i] > l0 ||
	    (ls[0][i] == l0 &&
	     lex_lt(l0 - 1, p0, j, ps[0][i], qs[0][i])))))
	dp[0][i] = d0, ls[0][i] = l0, ps[0][i] = p0, qs[0][i] = j;
      if (dp[1][i] > d1 ||
	  (dp[1][i] == d1 &&
	   (ls[1][i] > l1 ||
	    (ls[1][i] == l1 &&
	     lex_lt(l1 - 1, p1, j, ps[1][i], qs[1][i])))))
	dp[1][i] = d1, ls[1][i] = l1, ps[1][i] = p1, qs[1][i] = j;
    }
  }
  //for (int i = 0; i <= n; i++)
  //printf("%d: (%lld,%d,%d,%d) (%lld,%d,%d, %d)\n",
  //i, dp[0][i], ls[0][i], ps[0][i], qs[0][i],
  //dp[1][i], ls[1][i], ps[1][i], qs[1][i]);

  ll maxdp = 1;
  int mini = 0, minl = 0;
  for (int i = 0; i <= n; i++) {
    ll &dpi = dp[0][i];
    int &li = ls[0][i];
    if (maxdp < dpi ||
	(maxdp == dpi &&
	 (minl > li ||
	  (minl == li &&
	   lex_lt(li - 1, 0, i, 0, mini)))))
      maxdp = dpi, mini = i, minl = li;
  }
  //printf("maxdp=%lld, mini=%d, minl=%d\n", maxdp, mini, minl);

  p2v(minl, 0, mini, v0);
  printf("%d\n", minl);
  for (int i = 0; i < minl; i++) printf("%d\n", v0[i]);

  return 0;
}



Measured memory_bytes: 3232
N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = 0
for i in range(0,N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if (A[i]!=A[j]!=A[k]):
        if (A[i]+A[j])>A[k]:
          cnt+=1
        
print(cnt)

Measured memory_bytes: 9200
#include<iostream>

int main(){
	int a,b,c,i,n;
	std::cin>>n;
	for(i=0;i<n;i++){
	std::cin>>a>>b>>c;
	if(a*a==b*b+c*c){
		std::cout<<"YES"<<std::endl;
		}else if(b*b==a*a+c*c){
		std::cout<<"YES"<<std::endl;
		}else if(c*c==b*b+a*a){
		std::cout<<"YES"<<std::endl;
			}else{
			std::cout<<"NO"<<std::endl;
			}
		}
	

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const string Q[2] = {"JOI", "IOI"};

int main(void){
    size_t ind;
    for(string in; cin >> in;)
        rep(i, 2){
            int cnt = 0;
            for(; ~(ind = in.find(Q[i])); cnt++) in[ind] = '.';
            cout << cnt << endl;
        }

    return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <unordered_set>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::unordered_set<std::string> s;
  for (int i = 0; i < n; ++i) {
    std::string item;
    std::cin >> item;
    s.insert(item);
  }

  std::cout << s.size() << std::endl;
}


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

int main() {
int N, A,W,T,R;
cin >> N;
string X;
A=0;
W=0;
T=0;
R=0;
for(int i=0;i<N;i++){
  cin >> X;
if(X=="AC"){
  A++;}
if(X=="WA"){
  W++;}
if(X=="TLE"){
  T++;}
if(X=="RE"){
  R++;}
}
cout<<"AC x "<<A<<endl;
cout<<"WA x "<<W<<endl;
cout<<"TLE x "<<T<<endl;
cout<<"RE x "<<R<<endl;
  
}


Measured memory_bytes: 3624
#include <cstdio>

int main() {
    long long int a, b;
    while (~scanf("%lld %lld", &a, &b)) {
        long long int x = a, y = b;
        while (true) {
            x = x % y;
            if (!x) {
                printf("%lld %lld\n", y, a * b / y);
                break;
            }
            y = y % x;
            if (!y) {
                printf("%lld %lld\n", x, a * b / x);
                break;
            }
        }
    }
}

Measured memory_bytes: 1004
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll n, a, b;
ll vv[111111];

ll det(ll x)
{
	if(n%2==0) return abs(a/2-x);
	if(n%2==1) return min(abs(a/2-x),abs(a/2+1-x));
}

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n; int i;
	for(i=1 ; i<=n ; i++) cin>>vv[i];
	sort(vv+1,vv+n+1); a=vv[n];
	for(i=1 ; i<=n ; i++) if(det(b)>det(vv[i])) b=vv[i];
	cout<<a<<" "<<b; return 0;
}


// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif
    int a,b;
    cin>>a>>b;
    int nb;
    nb=max(10*(a+1),((b+1)*100)/8);
    int test=0;
    for(int i=0;i<nb;i++)
    {

        if ((floor(0.08*i)==a) and (floor(0.1*i)==b))
        {
            cout<<i<<endl;
            test=1;
            break;
        }
    }
    if (test==0)
        cout<<-1;
    return 0;
}


Measured memory_bytes: 256
import copy
N = int(input())
liA = list(map(int,input().split()))
liB = list(map(int,input().split()))
liC = copy.deepcopy(liA)
for i in range(len(liB)):
    if liA[i] >= liB[i]:
        liA[i] = liA[i]-liB[i]
    elif liB[i] - (liA[i]+liA[i+1]) <= 0:
        liA[i+1] = liC[i+1] + liA[i] - liB[i]
        liA[i] = 0
    else:
        liA[i] = 0
        liA[i+1] = 0
print(sum(liC)-sum(liA))

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

int main() {
  int n;
  cin >> n;
  
  int ans = 0;
  
  for(int i = 0; i <= n ; i++) {
    int a;
    cin >> a;
    int min = 0;
    
    while ( a > 1 ) {
      if ( a % 2 == 0 ) {
        min++;
        a/=2;
      }
      else break;
      
    }
    
    if ( i == 0 || ans > min )
      ans = min;
    
        
  }
  cout << ans << endl;
}


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

int main()
{
  string S;
  cin >>S;
  bool ans = true;
  for(int i = 0;i<S.size();i++){
  	if(i % 2 == 0){
  		if(S.at(i)=='L'){
  		  ans = false;
  		  break;
  		}
  	}
  	if(i % 2 == 1){
  		if(S.at(i)=='R'){
  		  ans = false;
  		  break;
  		}
  	}
  }
  if(ans){
  	cout <<"Yes"<<endl;
  }else{
  	cout <<"No"<<endl;
  }
}




Measured memory_bytes: 384
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i
ans = 0
(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      ans += 1 if 500 * i + 100 * j + 50 * k == x  
    end
  end
end

puts ans

Measured memory_bytes: 1788
n = int(input())
h = list(map(int,input().split()))
bh = h[0]


for i in range(1,n):
    if bh>h[i]:
        print("No")
        exit()
    elif h[i]>bh:
        bh = h[i]-1
    else:
        bh = h[i]

print("Yes")

Measured memory_bytes: 20644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	cin>>s;
	if(s[0]==s[2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}









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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


int main(){
  int n;
  cin >> n;
  int ans;
  if (n >= 1800) ans = 1;
  else if (n >= 1600) ans = 2;
  else if (n >= 1400) ans = 3;
  else if (n >= 1200) ans = 4;
  else if (n >= 1000) ans = 5;
  else if (n >= 800) ans = 6;
  else if (n >= 600) ans = 7;
  else ans = 8;

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


Measured memory_bytes: 3632
#include<stdio.h>
int main(){

  int N,a[100],i,flag,alternative,counter=0;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }

  flag=1;
  while(flag){
    flag=0;
    for(i=N-1;1<=i;i--){
      if(a[i]<a[i-1]){
	alternative=a[i];
	a[i]=a[i-1];
	a[i-1]=alternative;
	flag=1;
	counter=counter+1;
      }
    }
  }

  for(i=0;i<N-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[i]);
  printf("%d\n",counter);

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <iomanip>
#include <climits>
#include <string>
#include <sstream>
#include <numeric>
#include <stack>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	int A, B;
	cin >> A >> B;
	rep(ans, 200000) {
		if (ans == 0)
			continue;
		if (ans * 8 / 100 == A && ans * 10 / 100 == B) {
			cout << ans << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

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

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++)
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int N;

	cin >> N;

	int a, b, c;

	a = N % 10;
	b = (N / 10) % 10;
	c = N / 100;

	cout << ((a==7||b==7||c==7) ? "Yes" : "No")<< endl;

	return 0;
}


Measured memory_bytes: 3636
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main()
{
auto ip = readln.split.to!(int[]), w=ip[0], h=ip[1], x=ip[2], y=ip[3], r=ip[4];
if(x >= r && x <= w - r && y >= r && y <= h - r){
	writeln("Yes");
} else {
	writeln("No");
}
}


Measured memory_bytes: 2488
#include<iostream>
#include <string> 
#include <vector>     

#define INF 1000000000
using namespace::std;




long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}

bool c;
int N,C,H, M,K,W,a[10],ltl[26],g,k,X,ans,con,iti[100000];
string S,s,SB,SA,SS,b;

int main() {
	cin >> S;
	con = 0;
	g = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != 'x') {
			s += S[i];
			iti[g] = i;
			g++;
		}
		else {
			X++;
		}
	}

	for (int i = 0; i < s.size(); i++) {
		if (s[i] != s[s.size() - 1 - i]) {
			cout << -1 << endl;
			return 0;
		}
	}

	if (g == 0) {
		cout << 0 << endl;
		return 0;
	}


	S = 'A' + S;
	S = S + 'A';
	int l,r;
	l = r = 0;
	if (g % 2 == 1) {
		for(int i=0;i<=S.size();i++){
			if (S[iti[((g - 1) / 2)] + 1 - l] == 'A' && S[iti[((g - 1) / 2)] + 1 + r] == 'A') {
				break;
			}
			if (S[iti[((g - 1) / 2)] + 1 - l] == S[iti[((g - 1) / 2)] + 1 + r]) {
				l++;
				r++;
			}
			else {
				if (S[iti[((g - 1) / 2)] + 1 - l] =='x') {
					l++;
					ans++;
				}
				if(S[iti[((g - 1) / 2)] + 1 + r] == 'x'){
					r++;
					ans++;
				}
			
			}
		}
	}
	else {
		for (int i = 0; i<S.size()+100000; i++) {

			if (S[iti[((g ) / 2)-1] + 1 - l] == 'A' && S[iti[((g ) / 2)] + 1 + r] == 'A') {
				break;
			}
			if (S[iti[((g ) / 2)-1] + 1 - l] == S[iti[((g ) / 2)] + 1 + r]) {
				l++;
				r++;
			}
			else {
				if (S[iti[((g ) / 2)-1] + 1 - l] == 'x') {
					l++;
					ans++;
				}
				if (S[iti[(g / 2)] + 1 + r] == 'x') {
					r++;
					ans++;
				}

			}
		}
	}


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




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

using namespace std;

int PR[200005];
int PT[200005];
map <int, int> V[200005];

int findR(int i) { 
    if (PR[i] == i) 
        return i; 
    return PR[i] = findR(PR[i]); 
}

int findT(int i) { 
    if (PT[i] == i) return i;
    return PT[i] = findT(PT[i]); 
}

int main() {
	int N, K, L;
	scanf("%d %d %d", &N, &K, &L);
	for (int i = 0; i <= N; ++i) {
		PR[i] = i;
		PT[i] = i;
	}
	while (K--) {
		int p, q;
		scanf("%d %d", &p, &q);
		PR[findR(p)] = findR(q);
	}
	while (L--) {
		int p, q;
		scanf("%d %d", &p, &q);
		PT[findT(p)] = findT(q);
	}
	for (int i = 1; i <= N; ++i) {
		PR[i] = findR(i);
		PT[i] = findT(i);
		V[PR[i]][PT[i]]++;
	}
	for (int i = 1; i <= N; ++i) {
		cout << V[findR(i)][findT(i)] << " ";
	}
	return 0;
}

Measured memory_bytes: 20096
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	string s;
	cin>>s;
	deque<char>sp;
	rep(i,s.length())sp.push_back(s.at(i));
	int q;
	cin>>q;
	bool rev=false;
	rep(i,q){
		int t;
		cin>>t;
		switch (t) {
			case 1:
				if(rev){
					rev=false;
				}else{
					rev=true;
				}
				break;
			case 2:
				int f;
				char c;
				cin>>f>>c;
				switch (f) {
					case 1:
						if(rev){
							sp.push_back(c);
						}else{
							sp.push_front(c);
						}
						break;
					case 2:
						if(rev){
							sp.push_front(c);
						}else{
							sp.push_back(c);
						}
						break;
				}
				break;
		}
	}
	if(rev){
		for(auto it=sp.rbegin();it!=sp.rend();it++)cout<<*it;
	}else{
		each(it,sp)cout<<*it;
	}
	cout<<endl;
}


Measured memory_bytes: 896
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n,m = i2()
ls = []
for _ in range(n):
	a = intl()
	a = a[1:]
	ls.append(a)

for i in range(n-1):
	tmp = []
	for j in ls[i]:
		for k in ls[i+1]:
			if j == k:
				tmp.append(j)
	ls[i+1] = tmp

print( len(ls[-1]) )

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int sum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
signed main() {
    int H,W,C;cin>>H>>W>>C;
    cout<<C*(H/gcd(H,W))*(W/gcd(H,W))<<endl;
}



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

int main(){
    int n;
    cin >> n;
    int ans;
    ans = 1000 - (n % 1000);
    if(ans == 1000) ans = 0;
    cout << ans << endl;
    return 0;
}

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

void make_prime()
{
	int cnt = 0;
	int n = 11;
	while(cnt <= 60)
	{
		bool flag = true;
		for (int i = 2; i*i <= n; ++i)
		{
			if (n % i == 0)
			{
				flag = false;
				break;
			}
		}
		if (flag)
		{
			prime1[cnt] = n;
			cnt++;
		}
		n += 10;
	}
	return;
}

int main()
{
	make_prime();
	int N;
	cin >> N;
	rep(i,N)
	{
		if (i != 0) cout << " ";
		cout << prime1[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
N = int(input())
alpha = ['a','b','c','d','e','f','g','h','i','j']
ans = []

stack = deque(['a'])

while stack:
    if len(stack[-1]) == N:
        break
    s = stack.pop()
    s_list = sorted(list(s))
    index = alpha.index(s_list[-1])
    for i in range(index+2):
        stack.appendleft(s+alpha[i])
    

stack.reverse()
for j in range(len(stack)):
    print(stack[j])



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

N = int(input())
A = list(map(int, input().split()))


flag = 1
count = 0
while flag == 1:
    flag = 0
    for i in range(N - 1, 0, -1):
        if A[i] < A[i - 1]:
            A[i], A[i - 1] = A[i - 1], A[i]
            flag = 1
            count += 1

for i in range(N):
    if i == N - 1:
        print("{0}".format(A[i]))
    else:
        print("{0} ".format(A[i]), end="")

print(count)


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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 1e6;
int n ,W;
ll dp[(int)1e5 + 5];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n >> W;
    ll res = 0;
    for(int i = 1 ; i <= n ; ++i)
    {
        int w , v;
        cin >> w >> v;
        for(int j = W ; j >= 0 ; --j)
        {
            if(j >= w)dp[j] = max(dp[j] , dp[j - w] + v);
            res = max(res , dp[j]);
        }
    }
    cout << res;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Reader.init(System.in);
		StringBuffer output=new StringBuffer("");
		PrintWriter out=new PrintWriter(System.out);
		int n=Reader.nextInt();
		int w=Reader.nextInt();
		long[][] arr=new long[n][2];
		for(int i=0;i<n;i++) {
			arr[i][0]=Reader.nextLong();arr[i][1]=Reader.nextLong();
		}
		long[][] dp=new long[2][w+1];
		dp[1][(int)arr[0][0]]=dp[0][(int) arr[0][0]]=arr[0][1];
		long ans=arr[0][1];
		for(int i=1;i<n;i++) {
			int now=i%2;
			int last=1-now;
			for(int j=0;j+arr[i][0]<=w;j++) {
				if(dp[last][(int) (j)]!=0 || j==0) {
				dp[now][(int) (j+arr[i][0])]=Math.max(dp[last][j]+arr[i][1], dp[last][(int)(j+arr[i][0])]);
				ans=Math.max(ans, dp[now][(int) (j+arr[i][0])]);
				}
			}
			for(int j=0;j<=w;j++) dp[last][j]=dp[now][j];
		}
		output.append(ans);
		out.write(output.toString());
		out.flush();
	}

}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
 
    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
 
    /** get next word */
    static String nextLine() throws IOException{
    	return reader.readLine();
    }
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    
    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}


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

using namespace std;

int N, A, B, C;
typedef long long ll;
const int INFTY = (1 << 30);

ll dfs(vector<int> &L, int a, int b, int c, int l)
{
    ll mp;
    if (l == N)
    {
        mp = abs(a) + abs(b) + abs(c) - 30;
        if (A == a)
            return INFTY;
        if (B == b)
            return INFTY;
        if (C == c)
            return INFTY;
        return mp;
    }
    mp = dfs(L, a, b, c, l + 1);
    mp = min(mp, dfs(L, a - L[l], b, c, l + 1) + 10);
    mp = min(mp, dfs(L, a, b - L[l], c, l + 1) + 10);
    mp = min(mp, dfs(L, a, b, c - L[l], l + 1) + 10);
    return mp;
}

int main()
{
    cin >> N >> A >> B >> C;
    vector<int> L(N);
    for (int i = 0; i < N; i++)
    {
        cin >> L.at(i);
    }

    // 使わない/Aに使用/Bに使用/Cに使用 の4通り  全探索
    cout << dfs(L, A, B, C, 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
constexpr int MOD = 1e9 + 7;
long n, dp[3030][3030];
string s;

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

  dp[1][1] = 1;
  for(int i = 2; i <= n; ++i) {
    for(int j = 2; j <= n; ++j) (dp[i-1][j] += dp[i-1][j-1]) %= MOD;
    for(int now = 1; now <= i; ++now) {
      int L, R;
      if(s[i-2] == '<') L = 1, R = now - 1;
      else L = now, R = i;
      if(L <= R) (dp[i][now] += dp[i-1][R] - dp[i-1][L-1] + MOD) %= MOD;
    }
  }
  
  long ans = 0;
  for(int i = 1; i <= n; ++i) ans = (ans + dp[n][i]) % MOD;
  cout << ans;
  return 0;
}


Measured memory_bytes: 71936
def main():
    n = int(input())
    d = dict()
    for i in range(1, 10001):
        d[i] = 0
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                r = x**2+y**2+z**2+x*y+y*z+z*x
                if r <= 10000:
                    d[r] += 1
    for i in range(1, n+1):
        print(d[i])


main()


Measured memory_bytes: 9700
#include<stdio.h>
#define MAX 100000

int n, k;
long long T[MAX];

int check(long long P)
{
	int i = 0, j;
	for(j = 0; j < k; j++) {
		long long s = 0;
		while(s + T[i] <= P) {
			s += T[i];
			i++;
			if(i == n)
				return n;
		}
	}
	return i;
}

int solve() {
	long long left, right, mid;
	left = 0;
	right = 100000 * 10000;

	while(right - left > 1) {
		mid = (left + right) / 2;
		int v = check(mid);
		if(v >= n)
			right = mid;
		else
			left = mid;
	}
	return right;
}
int main()
{	
	int i;
	long long ans;
	scanf("%d %d", &n, &k);
	for(i = 0; i < n; i++)
		scanf("%lld", &T[i]);
	ans = solve();
	printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  int n;
  ll d;
  cin >> n >> d;
  ll line = pow(d, 2);
  int ans = 0;
  rep(i, n){
    ll a, b;
    cin >> a >> b;
    ll num = pow(a, 2) + pow(b, 2);
    if(num <= line)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
q, n = gets.strip.split.map(&:to_i)
s = gets.strip
pos = n.times.map { gets.strip.split.map { |d| d.to_i - 1} }
t = Array.new(q + 1, 0)

q.times { |i| t[i + 1] = s[i..i+1] == 'AC' ? t[i] + 1 : t[i] }
pos.each { |i, j| puts t[j] - t[i] }


Measured memory_bytes: 11004
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = 1e-9;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int n,l,t,x,w;
std::vector<int> ans;
int main(){
	std::cin>>n>>l>>t;
	lint cnt[2]={};
	rep(i,n){
		std::cin>>x>>w;
		if(w==1){
			ans.push_back((x+t)%l);
			cnt[0]+=(x+t-1)/l;
		}
		else {
			ans.push_back((x-(t%l)+l)%l);
			if(x-t<0){
				cnt[1]+=(std::abs(x-t)-1)/l+1;
			}
		}
	}
	std::sort(all(ans));
	cnt[0]-=cnt[1];
	if(cnt[0]<0){
		cnt[0]+=((-cnt[0])/n+1)*n;
		cnt[0]%=n;
	}
	rep(i,n){
		std::cout<<ans[(i+cnt[0])%n]<<std::endl;
	}
	return 0;
}


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

int N, Q;
char s[200000],t[200000],d[200000];


int BS1(int min, int max)
{
	if (max - min > 1) 
	{
		int check = 0;
		int mid = min + (max - min) / 2;
		int tmp = mid;
		for (int i = 0; i < Q; i++)
		{
			if (s[tmp] == t[i])
			{
				if (d[i] == 'L')
					tmp--;
				else
					tmp++;
			}
			if (tmp == -1)
			{
				check++;
				break;
			}
			if (tmp == N)
			{
				break;
			}
		}

		if (check == 0)
		{
			return BS1(min, mid);
		}
		else
		{
			return BS1(mid, max);
		}
	}
	else
	{
		int check1 = 0;
		int tmp = min;
		for (int i = 0; i < Q; i++)
		{
			if (s[tmp] == t[i])
			{
				if (d[i] == 'L')
					tmp--;
				else
					tmp++;
			}
			if (tmp == -1)
			{
				check1++;
				break;
			}
			if (tmp == N)
			{
				break;
			}
		}

		int check2 = 0;
		tmp = max;
		for (int i = 0; i < Q; i++)
		{
			if (s[tmp] == t[i])
			{
				if (d[i] == 'L')
					tmp--;
				else
					tmp++;
			}
			if (tmp == -1)
			{
				check2++;
				break;
			}
			if (tmp == N)
			{
				break;
			}
		}

		if (check2 == 1)
			return max;
		else if (check1 == 1)
			return min;
		else
			return min - 1;
	}
}

int BS2(int min, int max)
{
	if (max - min > 1)
	{
		int check = 0;
		int mid = min + (max - min) / 2;
		int tmp = mid;
		for (int i = 0; i < Q; i++)
		{
			if (s[tmp] == t[i])
			{
				if (d[i] == 'L')
					tmp--;
				else
					tmp++;
			}
			if (tmp == -1)
			{
				break;
			}
			if (tmp == N)
			{
				check++;
				break;
			}
		}

		if (check == 0)
		{
			return BS2(mid, max);
		}
		else
		{
			return BS2(min, mid);
		}
	}
	else
	{
		int check1 = 0;
		int tmp = min;
		for (int i = 0; i < Q; i++)
		{
			if (s[tmp] == t[i])
			{
				if (d[i] == 'L')
					tmp--;
				else
					tmp++;
			}
			if (tmp == -1)
			{
				break;
			}
			if (tmp == N)
			{
				check1++;
				break;
			}
		}

		tmp = max;
		int check2 = 0;
		for (int i = 0; i < Q; i++)
		{
			if (s[tmp] == t[i])
			{
				if (d[i] == 'L')
					tmp--;
				else
					tmp++;
			}
			if (tmp == -1)
			{
				break;
			}
			if (tmp == N)
			{
				check2++;
				break;
			}
		}

		if (check1 == 1)
			return min;
		else if (check2 == 1)
			return max;
		else
			return max + 1;
	}
}

int main()
{
	cin >> N >> Q;
	for (int i = 0; i < N; i++)
		cin >> s[i];

	for (int i = 0; i < Q; i++)
		cin >> t[i] >> d[i];


	int a = BS1(0, N - 1);
	int b = BS2(0, N - 1);

	cout << b - a - 1;

	return 0;

}

Measured memory_bytes: 768
# coding: utf-8
# Your code here!

while True:
    N = int(input())
    if N == 0:
        break
    
    seq = input()
    cards = []
    for i in range(N):
        cards.append(0)
    yama = 0
    
    for i in range(100):
        id = i % N
        if seq[i] == "M":
            cards[id] = cards[id] + 1
        elif seq[i] == "S":
            yama = yama + cards[id] + 1
            cards[id] = 0
        elif seq[i] == "L":
            cards[id] = cards[id] + yama + 1
            yama = 0

    cards.sort()
    for i in range(N):
        print(cards[i], end=" ")
    print(yama)
    
            
            
            


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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	int n; cin >> n;
	vector<int> a(n);
	for(auto &e : a)cin >> e;
	vector<int> acc(a);
	for(int i = 1; i < n ;i++){
		acc[i] += acc[i-1];
	}
	int ans = 1000000000;
	for(int i = 0; i < n-1; i++){
		ans = min(abs(acc[n-1] - 2*acc[i]), ans);
	}
	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

#define INF 1001001001

int main(){
  int x, y, ans, p00, p01, p10, p11;
  cin >> x >> y;
  int xi = x * (-1);
  int yi = y * (-1);
  p00 = 0;
  p10 = p01 = 1;
  p11 = 2;
  
  if(x <= y) p00 += y - x;
  else p00 = INF;
  if(xi <= y) p10 += y - xi;
  else p10 = INF;
  if(x <= yi) p01 += yi - x;
  else p01 = INF;
  if(xi <= yi) p11 += yi - xi;
  else p11 = INF;
  ans = min(p00, p01);
  ans = min(ans, p10);
  ans = min(ans, p11);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#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 dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll k; cin >> k;
  
  if(k % 2 == 0) cout << k * k /4 << endl;
  else cout << ((k+1)/2) * (k/2) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static bool Solve(string S)
        {
            int N = S.Length;
            for (int i = 1; i < N; ++i) { if (S[i - 1] == S[i]) { return false; } }
            return true;
        }

        static void Main(string[] args)
        {
            Console.WriteLine(Solve(Read()) ? "Good" : "Bad");
        }
    }
}


Measured memory_bytes: 11092
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

struct Store {
    ll A, B;
};

int main() {
    ll N, M;
    cin >> N >> M;
    vector<Store> stores(N);
    for (ll i = 0; i < N; i++) {
        cin >> stores[i].A >> stores[i].B;
    }
    sort(stores.begin(), stores.end(), [](Store& lhs, Store &rhs) {
        return lhs.A < rhs.A;
    });

    ll ans = 0;
    for (const Store& s : stores) {
        if (M <= s.B) {
            //買い切って終わり
            ans += s.A * M;
            break;
        } else {
            ans += s.A * s.B;
            M -= s.B;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
def gets_nums
    gets.split.map{|x| x.to_i}
end
def light(a,b,n)
    b.fill(0)
    0.upto(n-1) do |i|
        l = i-a[i]
        r = i+a[i]+1
        l = 0 if l < 0
        b[l]+=1
        b[r]-=1 if r < n
    end
    flag = a[0]==b[0]
    a[0] = b[0]
    1.upto(n-1) do |i|
        b[i] += b[i-1]
        flag &= (a[i]==b[i])
        a[i] = b[i]
    end
    return flag
end
n, k = gets_nums
a = gets_nums
b = Array::new(n+1)
0.upto(k-1) do |i|
    break if light(a,b,n)
end
puts a.join(" ")


Measured memory_bytes: 35984
n, x = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) == x:
    print(n)
elif sum(a) < x:
    print(n - 1)
else:
    a = sorted(a)
    ans = 0
    for i in range(n):
        if a[i] <= x:
            ans += 1
            x -= a[i]
    print(ans)

Measured memory_bytes: 3064