akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  string s = stin();
  deque<char> que;
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] == 'B') {
      if(que.empty()) continue;
      que.pop_back();
    } else {
      que.push_back(s[i]);
    }
  }
  while(!que.empty()) {
    cout << que.front();
    que.pop_front();
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

move = [0]
cnt = 0

for i in range(n-1):
  if h[i] >= h[i+1]:
    cnt += 1
    if i == n-2:
      move.append(cnt)
  else:
    move.append(cnt)
    cnt = 0


print(max(move))

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

int main(){
	string str;
	getline(cin,str);

	for(int i = 0; i < str.size(); i++){
		if(str[i] >= 'a' && str[i] <= 'z'){
			str[i] -= ('a'-'A');
			cout << str[i];
		}
		else cout << str[i];
	}
	cout << endl;
}

Measured memory_bytes: 1168
#include <stdio.h>

int main(){
  long int a, b, x;
  scanf("%ld %ld %ld", &a, &b, &x);
  if(a%x != 0){
    printf("%ld\n", b/x - a/x);
  }else{
    printf("%ld\n", b/x - a/x + 1);
  }
  return 0;
}


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

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

int main() {
    int H, W, Ch, Cw, Dh, Dw;
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    --Ch; --Cw; --Dh; --Dw;
    vector<string> S(H);
    rep(h, H) cin >> S[h];

    int INF = 1e9;
    vector<vector<int>> dist(H, vector<int>(W, INF));
    deque<P> q;

    dist[Ch][Cw] = 0;
    q.emplace_back(Ch, Cw);

    while(!q.empty()) {
        int h = q.front().first;
        int w = q.front().second;
        q.pop_front();
        int d = dist[h][w];
        rep(dir, 4) {
            int nh = h + dx[dir];
            int nw = w + dy[dir];
            if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if (S[nh][nw] == '#') continue;
            if (dist[nh][nw] <= d) continue;
            dist[nh][nw] = d;
            q.emplace_front(nh, nw);
        }
        for (int dx=-2; dx<=2; dx++) {
            for (int dy=-2; dy<=2; dy++) {
                int nh = h + dx;
                int nw = w + dy;
                if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
                if (S[nh][nw] == '#') continue;
                if (dist[nh][nw] <= d) continue; 
                dist[nh][nw] = d + 1;
                q.emplace_back(nh, nw);               
            }
        }
    }
    int ans = dist[Dh][Dw];
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10184
import java.util.*;

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

        long ans = n;
        long b = n;

        if (b % k != 0) {
            b = b % k;
            while (true) {
                b = Math.abs(b - k);
                if (ans > b) {
                    ans = b;
                } else {
                    break;
                }
            }
        } else {
            ans = 0;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
/*
 execution in cmd of windows:
 
 
  c
  
  
  p1
 
 */
typedef double dd;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl <<"\n"
#define con continue
#define br break
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
ll mx=INT_MAX;
ll mi=INT_MIN;
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define all(v) v.begin(), v.end()
#define fsort(v) sort(all(v))  
#define rsort(v) sort(v.rbegin(),v.rend())
#define rev(v) reverse(all(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define sumv(v,x) accumulate(v.begin(),v.end(),x);
const ll mod = 1000000007;
const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
#define io { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define cs ll t;cin>>t;while(t--)
#define cs1 ll t;t=1;while(t--)


int main()
{
        io;
        //////////////////////////////////
        cs1{
            ll i,j,k,l,s=0,p=0,q=0,h,w,m;
            cin>>h>>w>>m;
            //ll arr[h+5][w+5];
            vll vr(m),vc(m);
            vpll vx;
            map<pair<ll,ll> ,ll> mi;
            map<ll,ll> mr,mc;
            set<ll> sr,sc;
            for(i=0;i<m;i++){
                ll x,y;
                cin>>x>>y;
                mi[make_pair(x,y)]++;
                mr[x]++;
                mc[y]++;
                sr.insert(x);
                sc.insert(y);
            }
            ll row=-1;
            ll low1=0;
            vll vv;
            for(auto it=sr.begin();it!=sr.end();++it){
                ll val=*it;
                if(mr[val]>low1) {
                    vv.clear();
                    vv.pb(val);
                    low1=mr[val];
                }
                else if(mr[val]==low1) vv.pb(val);
            }
           ll  low2=0;
            vll vvv;
            for(auto it=sc.begin();it!=sc.end();++it){
                ll val=*it;
                if(mc[val]>low2){
                    vvv.clear();
                    vvv.pb(val);
                    low2=mc[val];
                }
                else if(mc[val]==low2) vvv.pb(val);
            }
            for(i=0;i<vv.size();i++){
                for(j=0;j<vvv.size();j++){
                    pair<ll,ll> mx={vv[i],vvv[j]};
                    
                    if(mi[mx]==0){
                        q=1;br;
                    }
                }
                if(q==1) br;
            }
            if(q==1) cout<<low1+low2;
            else cout<<low1+low2-1 nl;
            //cout<<vv.size()<<" "<<vvv.size();
            
        }
        //////////////////////////////////
       
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

int n,ma,mb;
int dp[401][401];
int a[40],b[40],c[40];


int main(){
  scanf("%d %d %d",&n,&ma,&mb);
  REP(i,n){
    scanf("%d %d %d",&a[i],&b[i],&c[i]);
  }
  REP(i,401)REP(j,401) dp[i][j] = INF;
  dp[0][0] = 0;
  REP(i,n)for(int k = 400;k>=0;k--)for(int l = 400;l>=0;l--){
    if(k-a[i]<0 || l-b[i]<0) break;
    if(dp[k-a[i]][l-b[i]] == INF) continue;
    //if(k+a[i]>400 || l+b[i]>400) break;
    dp[k][l] = min(dp[k][l],dp[k-a[i]][l-b[i]]+c[i]);
  }
  int mi = INF;
  for(int i = 1;i<=400;i++){
    if(ma*i>400 || mb*i>400) break;
    if(dp[ma*i][mb*i] == INF) continue;
    mi = min(mi,dp[ma*i][mb*i]);
  }
  if(mi==INF) printf("-1\n");
  else printf("%d\n",mi);
}


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

using namespace std;
#define ll long long
#define f first
#define s second

int main()
{

    ll n;
    cin >> n;
    ll arr[n] ,ans=0 , mn=1e18+5 , m , m2 , lf , rt , tmp , tmp2;
    for (int i=0; i<n; i++)
        cin >> arr[i];


    lf=1e9+5 , lf *= -1 , rt=1e9+5;
    while(rt-lf > 3)
    {
        m = lf + (rt-lf)/3 , m2 = lf +2*(rt-lf)/3;
        tmp=0 , tmp2=0;
        for (int i=0; i<n; i++)
        {
            tmp += abs(arr[i]-(m+i+1));
            tmp2 += abs(arr[i]-(m2+i+1));
        }
        if (tmp < tmp2) rt = m2;
        else lf=m;
    }

    for (lf; lf<=rt; lf++)
    {
        tmp =0;
        for (int i=0; i<n; i++)
        {
            tmp += abs(arr[i]-(lf+i+1));
        }
        mn = min(mn , tmp);
    }
    cout << mn << "\n";

    return 0;
}


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

int main() {
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int ma,man,sec;
    ma = a[0];
    man = 0;
    sec = 0;
    for(int k=1;k<n;k++){
        if(ma<=a[k]){
            sec = ma;
            ma = a[k];
            man = k;
        }else if(sec<=a[k] && ma>a[k])sec = a[k];
    }
    for(int l=0;l<n;l++){
        if(l==man){
            cout << sec << endl;
        }else{
            cout << ma << endl;
        }
    }
}

Measured memory_bytes: 2432
n = int(input())
dishes = []
for _ in range(n):
    a, b = map(int, input().split())
    dishes.append((a+b, a, b))

dishes.sort(key=lambda x: -x[0])

ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += dishes[i][1]
    else:
        ans -= dishes[i][2]

print(ans)

Measured memory_bytes: 25336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int main(){
  int N, R;
  cin >> N >> R;
  if (N>=10){
    cout << R << endl;
  }
  else{
    cout << R + 100*(10-N) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define ordered_set tree<int , null_type,less<int , rb_tree_tag,tree_order_statistics_node_update>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 100000000
// order_of_key and *find_by_order
#define N 10000001
int32_t main() {
	fast;
	int x, n;
	cin >> x >> n;
	int a[n];
	map<int, int > m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		m[a[i]] = 1;
	}
	int dis = 1e18;
	int ans = -1;
	for (int i = -1; i <= 101; i++) {
		if (abs(x - i) < dis and m[i] == 0) {
			dis = abs(x - i);
			ans = i;
		}
	}
	cout << ans;









}

Measured memory_bytes: 3620
n = int(input())
votes = [list(map(int, input().split())) for _ in range(n)]

curr_a, curr_b = 0, 0

for v1, v2 in votes:
    a, b = v1, v2
    i = max(curr_a // v1, curr_b // v2)

    while a < curr_a or b < curr_b:
        a = v1 * i
        b = v2 * i
        i += 1

    curr_a, curr_b = a, b

print(curr_a + curr_b)


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

using namespace std;
typedef long long LL;
const double pi = acos(-1.0);
const double eps = 1e-7;
const LL N = 200010;

LL T,n,m,i,j,k,s[N][2],f[N]={0},t,ans=0;

int main()
{
    scanf("%lld%lld",&n,&m);
    f[1]=1;
    for(i=0;i<m;i++){
        scanf("%lld%lld",&s[i][0],&s[i][1]);
        if(s[i][0]==1)f[s[i][1]]=1;
        else if(s[i][1]==1)f[s[i][0]]=1;
    }
    for(i=0;i<m;i++){
        if(f[s[i][0]]==1&&f[s[i][1]]==0)f[s[i][1]]=2;
        else if(f[s[i][1]]==1&&f[s[i][0]]==0)f[s[i][0]]=2;
    }
    if(f[n]==2)printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    //system("pause");
    return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

vector<bool> prime_table(int n)
{
    vector<bool> prime(n + 1, true);
    if (n >= 0)
        prime[0] = false;
    if (n >= 1)
        prime[1] = false;
    for (int i = 2; i * i <= n; i++)
    {
        if (!prime[i])
            continue;
        for (int j = i + i; j <= n; j += i)
        {
            prime[j] = false;
        }
    }
    return prime;
}

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

    ll N;
    string S;
    cin >> N;

    auto t = prime_table(100000+100);

    for (ll i = N; i < 100000+100; i++) {
        if(t.at(i)==1){
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        Integer n = sc.nextInt();
        Integer k = sc.nextInt();
        double ans = 0;
        for (int i =1;i<=n;i++) {
            int tmp = i;
            int p = 0;
            while (tmp < k) {
                tmp *= 2;
                p++;
            }
            double sum = Math.pow(0.5, p) / n ;
            ans += sum;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<cstdio>
#include<algorithm>
using namespace std;
int N,A[200005],B;
long long Ans;
inline int read(){
	int Res=0;char ch=getchar();
	while (ch>'9'||ch<'0') ch=getchar();
	while (ch>='0'&&ch<='9') Res=Res*10+ch-'0',ch=getchar();
	return Res;
}
inline int _abs(int x){return x<0?-x:x;}
int main()
{
	N=read();
	for (int i=1;i<=N;i++) A[i]=read()-i;
	sort(A+1,A+1+N);B=A[(N+1)/2];
	for (int i=1;i<=N;i++) Ans+=_abs(A[i]-B);
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void){
	int t[8][8];
	int l[8][8];

	t[1][2] = 300; t[1][3] = 500; t[1][4] = 600; t[1][5] = 700; t[1][6] = 1350; t[1][7] = 1650;
	t[2][3] = 350; t[2][4] = 450; t[2][5] = 600; t[2][6] = 1150; t[2][7] = 1500;
	t[3][4] = 250; t[3][5] = 400; t[3][6] = 1000; t[3][7] = 1350;
	t[4][5] = 250; t[4][6] = 850; t[4][7] = 1300;
	t[5][6] = 600; t[5][7] = 1150;
	t[6][7] = 500;

	l[1][2] = 6; l[1][3] = 13; l[1][4] = 18; l[1][5] = 23; l[1][6] = 43; l[1][7] = 58;
	l[2][3] = 7; l[2][4] = 12; l[2][5] = 17; l[2][6] = 37; l[2][7] = 52;
	l[3][4] = 5; l[3][5] = 10; l[3][6] = 30; l[3][7] = 45;
	l[4][5] = 5; l[4][6] = 25; l[4][7] = 40;
	l[5][6] = 20; l[5][7] = 35;
	l[6][7] = 15;

	int in,out,in_t,out_t,t1,t2;

	while(cin >> in && in){
		cin >> t1 >> t2;
		in_t = t1*100+t2;
		cin >> out;
		cin >> t1 >> t2;
		out_t = t1*100+t2;
		if(in > out){
			swap(in,out);
		}
		if(l[in][out] <= 40 && ((1730 <= in_t && in_t <= 1930) || (1730 <= out_t && out_t <= 1930))){
			int tmp = std::ceil((double)(t[in][out] / 2) / 50);
			cout << tmp * 50 << endl;
		}else{
			cout << t[in][out] << endl;
		}
	}
}

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

int main() {
  int a,b,c,d,x,y;
  cin >> a >> b >> c >> d;
  x = c / b;
  if (c % b == 0) x--;
  y = a / d;
  if (a % d == 0) y--;
  if(x <= y){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0035
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            int A = int.Parse(s.Split(' ')[0]);
            int B = int.Parse(s.Split(' ')[1]);

            Console.WriteLine((A - 1) * (B - 1));

        }
    }
}


Measured memory_bytes: 27520
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  ll s;
  cin>>s;
  
  ll x1=0;
  ll y1=0;
  ll x2,x3,y2,y3=0;
  
  ll sm=(ll)(sqrt(s)+0.9999);
  
  
  x2=sm;
  y3=sm;
  
  ll n=sm*sm-s;
  if(n==0){
    x3=0;
    y2=0;
    
  cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
  return 0;
  }
    
  
  for(int i=1;i*i<=n;i++){
    if(n%i==0){
      x3=i;}
  }
  
  y2=n/x3;
  
  
  cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
  return 0;
  
  
  
 
 
}

Measured memory_bytes: 256
#include<cstdio>

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

using namespace std;

const int INF=1<<29;

int main(){
	for(int p,q;~scanf("%d%d",&p,&q);){
		static int mod[1000000];
		rep(i,q)	mod[i]=-1;
		mod[p]=0;

		rep(i,INF){
			p*=10;
			putchar(p/q+'0');
			p%=q;

			if(p==0){	// finite decimal
				putchar('\n');
				break;
			}
			if(~mod[p]){	// repeating decimal
				putchar('\n');
				rep(j,mod[p])		putchar(' ');
				rep(j,i-mod[p]+1)	putchar('^');
				putchar('\n');
				break;
			}
			mod[p]=i+1;
		}
	}

	return 0;
}

Measured memory_bytes: 4636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var a = Input().Select(long.Parse).ToArray();
		
		var sw = new long[n+1];
		for(int i = 1; i < n; i++)
		{
			sw[i] = (sw[i-1] + a[i])%Giri;
		}
		
		long wa = 0;
		for(int i = 0; i < n; i++)
		{
			//Console.WriteLine(sw[n-1] - sw[i]);
			wa += (a[i] * (Giri + sw[n-1] - sw[i])) % Giri;
			wa %= Giri;
		/*
			Console.WriteLine(a[i]);
			for(int j = i+1; j < n; j++)
			{
				wa += (a[i] * a[j])%Giri;
				wa %= Giri;
			}
			*/
		}
		Console.WriteLine(wa);
	}
	
	static int CntReplace(string a, string b)
	{
		int wa = 0;
		for(int i = 0; i < a.Length; i++)
		{
			if(a[i] != b[i])
				wa++;
		}
		return wa;
	}

	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 49352
package main

import (
        "fmt"
)

func solution(a, b int) string {
        out := ""
        switch {
        case a > 0:
                out = "Positive"
        case a < 0 && b > 0:
                out = "Zero"
        case b < 0:
                if (b-a+1)%2 == 0 {
                        out = "Positive"
                } else {
                        out = "Negative"
                }
        }
        return out
}

func main() {
        var a, b int
        fmt.Scan(&a, &b)
        fmt.Println(solution(a, b))
}

Measured memory_bytes: 512
n = int(input())
i = 1
while i <= n:
    x = i
    if x % 3 == 0 or x % 10 == 3:
        print(f" {i}", end='')
    else:
        while x:
            x //= 10
            if x % 10 == 3:
                print(f" {i}", end='')
                break
    i += 1
print()


Measured memory_bytes: 5884
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,k,r,x,y,z,ans=0,ans2=0;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
  cin >> n;
  vLL(p,n);
  SORT(p);
  p[n-1]/=2;
  cout <<SUM(p);
}

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

int main()
{
    string s;
    cin >> s;
    int count[3] = {};
    for (int i = 0; i < 3; i++)
    {
        count[s[i] - 'a']++;
    }
    for (int i = 0; i < 3; i++)
    {
        if (count[i] != 1)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0) break;
			int sum=0,ave,max=0,min=0;
			int[] p=new int[n];
			for(int i=0;i<n;i++){
				p[i]=sc.nextInt();
				if(p[max]<p[i]) max=i;
				if(p[min]>p[i]) min=i;
			}
			for(int i=0;i<n;i++){
				if(i!=max && i!=min) sum+=p[i];
			}
			ave=sum/(n-2);
			System.out.println(ave);
		}
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<long> a(3 *N);
  for(int i = 0; i < 3 * N; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  long long ans = 0;
  for(int i = 1; i < N * 2; i += 2)
    ans += a.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
int N, Q;
const int NQmax = 2e5;
ll S[NQmax], T[NQmax], X[NQmax], D[NQmax];

int main(){
	ios_base::sync_with_stdio(false);
	cin >> N >> Q;
	for(int i=0; i<N; i++) cin >> S[i] >> T[i] >> X[i];
	for(int i=0; i<Q; i++) cin >> D[i];

	vector<pair<int, int> > v;
	for(int i=0; i<N; i++){
		v.push_back({S[i]-X[i], i});
	}
	for(int i=0; i<Q; i++){
		v.push_back({D[i], i+N});
	}
	sort(v.begin(), v.end());

	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
	ll ans = 0;
	for(int i=0; i<N+Q; i++){
		int x = v[i].first;
		int j = v[i].second;
		if(j < N){
			que.push({X[j], j});
		} else {
			j -= N;
			while(!que.empty() && T[que.top().second]-X[que.top().second]<=x) que.pop();
			if(que.empty()){
				cout << -1 << "\n";
			} else {
				cout << que.top().first << "\n";
			}
		}
	}
	return 0;
}


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

#define MOD 1000000007

LL dp[2][400][400];
LL sums[400][400];

LL nshared[400][400];
LL ok[400];
int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int posa[n];
    int posb[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
        posa[a[i]] = i;
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
        b[i]--;
        posb[b[i]] = i;
    }
    int k = n/3;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            nshared[i][j] = 0;
            for(int c = 0; c < n; c++){
                ok[c] = 0;
            }
            for(int c = i; c < n; c++) ok[a[c]]++;
            for(int c = j; c < n; c++) ok[b[c]]++;
            for(int c = 0; c < n; c++){
                if(ok[c] == 2){
                    nshared[i][j]++;
                }
            }
        }
    }
    dp[0][n][n] = 1;
    for(int c = 1; c <= k; c++){
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= n; j++){
                dp[c%2][i][j] = 0;
                sums[i][j] = 0;
            }
        }
        for(int i = n; i >= 0; i--){
            for(int j = n; j >= 0; j--){
                if(j < n) sums[i][j] += sums[i][j+1];
                if(i < n) sums[i][j] += sums[i+1][j];
                if(i < n && j < n) sums[i][j] -= sums[i+1][j+1];

                sums[i][j] += dp[1-c%2][i][j];

                sums[i][j] %= MOD;
                while(sums[i][j] < 0) sums[i][j] += MOD;
                //cout << sums[i][j] << " ";
            }
            //cout << endl;
        }
        //calculate dp[i][j];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(a[i] == b[j]) continue;
                if(nshared[i][j] != nshared[i+1][j+1] + 2){
                    continue;
                }
                LL npairs = nshared[i][j] - (3*c-1);
                if(npairs <= 0) continue;
                dp[c%2][i][j] = (sums[i+1][j+1] * npairs) % MOD;
                //cout << c << " " << i << " " << j << " " << dp[c%2][i][j] << endl;
            }
        }
    }
    LL f = dp[k%2][0][0];
    f %= MOD;
    while(k > 0){
        f = (f * (3*k-1)) % MOD;
        f = (f * (3*k-2)) % MOD;
        k--;
    }
    while(f < 0) f += MOD;
    cout << f << endl;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[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 main()
{
    ll n;
    cin >> n;
    
    for (ll i = 1; i <= n; i++) {
        if (i*(i+1)/2 >= n) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] array = new int[n];
        
        long sum = 0;
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
            sum += array[i];
        }
        
        long count = 0;
        
        Arrays.sort(array);
        
        if (k > n) {
            k = n;
        }
        for (int i = n - 1; i >= n - k; i--) {
            sum -= array[i];
        }
        
        
        
        if (sum < 0) {
            System.out.println(0);
        } else {
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 64388
#include<stdio.h>
int main(){
  int list[100000];
  int n;
  int i,j,k;
  char s[100001];
  scanf("%s",s);
  for(i=0;i<26;i++){
    n=0;
    for(j=0;s[j]!='\0';j++)if(s[j]=='a'+i){list[n]=j+1;n++;}
    for(j=0;j<n;j++)for(k=j+1;k<n;k++)if(list[k]-list[j]+1<(k-j+1)*2){printf("%d %d",list[j],list[k]);return 0;}
  }
  printf("-1 -1");
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#define ld long double

typedef struct {ld x, y;} Vector;
ld rad = 3.141592653589793 * 60.00000000 / 180.00000000;

void koch(int d, Vector p1, Vector p2) {
    if (d == 0) return;
    Vector s, u, t;
    s.x = (2.0*p1.x + 1.0*p2.x) / 3.0;
    s.y = (2.0*p1.y + 1.0*p2.y) / 3.0;
    t.x = (1.0*p1.x + 2.0*p2.x) / 3.0;
    t.y = (1.0*p1.y + 2.0*p2.y) / 3.0;
    u.x = (t.x - s.x) * cos(rad) - (t.y - s.y) * sin(rad) + s.x;
    u.y = (t.x - s.x) * sin(rad) + (t.y - s.y) * cos(rad) + s.y;

    koch(d-1, p1, s);
    printf("%Lf %Lf\n", s.x, s.y);
    koch(d-1, s, u);
    printf("%Lf %Lf\n", u.x, u.y);
    koch(d-1, u, t);
    printf("%Lf %Lf\n", t.x, t.y);
    koch(d-1, t, p2);
}

int main(void) {
    int n;
    scanf("%d", &n);
    Vector a, b;
    a.x = 0.00000000; a.y = 0.00000000;
    b.x = 100.00000000; b.y = 0.00000000;
    printf("%Lf %Lf\n", a.x, a.y);
    koch(n, a, b);
    printf("%Lf %Lf\n", b.x, b.y);
    return 0;
}


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

int main() {
  
  int K;
  cin >> K;
  int sum = 0;
  
  for (int a = 1; a < K + 1; a++) {
    for (int b = 1; b < K + 1; b++) {
      for (int c = 1; c < K + 1; c++) {
        sum += __gcd(a, __gcd(b, c));
      }
    }
  }
  
  cout << sum << endl;
  

}


Measured memory_bytes: 3660
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {
	
	ll N, M, X;
	cin >> N >> M >> X;
	vll A(M);
	rep(i, M) cin >> A[i];

	ll p = lower_bound(all(A), X) - A.begin();
	cout << min(p, M - p)  << endl;
}

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

int main(){
  vector<vector<ll>> dp(100,vector<ll>(64,0));
  // A3 C2 G1 T0
  for(int i=0;i<64;i++){
    if(i!=30 && i!=54 && i!=57)
      dp[2][i]=1;
  }
  int N;
  cin>>N;
  for(int i=2;i<N-1;i++){
    for(int j=0;j<64;j++){
      if(j%16==13){
        for(int k=0;k<4;k++){
          if(k==2) continue;
          dp[i+1][52+k]+=dp[i][j];
          dp[i+1][52+k]%=1000000007;
        }
      }else if(j%16==7){
        for(int k=0;k<4;k++){
          if(k==2) continue;
          dp[i+1][28+k]+=dp[i][j];
          dp[i+1][28+k]%=1000000007;
        }
      }else if(j%16==14){
        for(int k=0;k<4;k++){
          if(k==1) continue;
          dp[i+1][56+k]+=dp[i][j];
          dp[i+1][56+k]%=1000000007;
        }
      }else if(j==49||j==53||j==57||j==61){
        for(int k=0;k<4;k++){
          if(k==2) continue;
          dp[i+1][(j%16)*4+k]+=dp[i][j];
          dp[i+1][(j%16)*4+k]%=1000000007;
        }
      }else if(j>51 && j<56){
        for(int k=0;k<4;k++){
          if(k==2) continue;
          dp[i+1][(j%16)*4+k]+=dp[i][j];
          dp[i+1][(j%16)*4+k]%=1000000007;
        }
      }else{
        for(int k=0;k<4;k++){
          dp[i+1][(j%16)*4+k]+=dp[i][j];
          dp[i+1][(j%16)*4+k]%=1000000007;
        }
      }
    }
  }
  int ans=0;
  for(int i=0;i<64;i++){
    ans+=dp[N-1][i];
    //cout<<i<<" "<<dp[N-1][i]<<endl;
    ans%=1000000007;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#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(v) (v).begin(),(v).end()
#define endl '\n'
#define int long long
const int INF = (1 << 30);
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
void solve(){
    char c, cf1=0, cf2=0;
    int a;
    while(cin >> c){
        if(c == 'C') cf1 = 1;
        if(cf1 && c == 'F') cf2 = 1;
    }
    if(cf2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

    solve();
}



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

typedef long long ll;

const int N = 200005;

int n;
vector<pair<int,int> > adj[N];
int ans[N];

int k = 0;

void dfs(int x,int par,int c){
	int cnt = 1;
	k = max(k,(int)adj[x].size());
	for(auto p:adj[x]){
		int y = p.first,idx = p.second;
		if(y == par)continue;
		if(cnt == c)cnt++;
		ans[idx] = cnt;
		dfs(y,x,cnt);
		cnt++;
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		adj[x].push_back({y,i});
		adj[y].push_back({x,i});
	}
	
	dfs(1,1,0);
	
	cout<<k<<endl;
	for(int i=1;i<n;i++){
		cout<<ans[i]<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 14820
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
#define WHITE 0
#define GRAY 1
#define BLACK 2
typedef long long LL;
const int MAXN = 110;
int n, mapp[MAXN][MAXN], color[MAXN], d[MAXN], f[MAXN], tt;

void dfs_visit(int u) {
	color[u] = GRAY;//参照したことを示す
	d[u] = ++tt; //発見した時間を示す　0からなので足してから
	for(int i = 0; i < n; i++) {
		if(mapp[u][i] == 1 && color[i] == WHITE) {//u,i間に辺があること,iが未探訪を確認
			dfs_visit(i);
		}
	}
	color[u] = BLACK;//uに関して終わったことを示す
	f[u] = ++tt; //終了した時間を示す　足してから

}

void dfs() {
	tt = 0;
	memset(color, 0, sizeof(color));//探訪情報をリセット
	for(int i = 0; i < n; i++) {
		if(color[i] == WHITE) {//未探訪なら探索
			dfs_visit(i);
		}
	}
	for(int i = 0; i < n; i++) {
		printf("%d %d %d\n", i+1, d[i], f[i]);
	}
}

int main() {
	int u, v, k;
	cin >> n;
	memset(mapp, 0, sizeof(mapp));//木情報をリセット
	for(int i = 0; i < n; i++) {
		cin >> u >> k;
		u--; //0から考えているのでノードの番号を1減らす
		while(k--) {
			cin >> v;
			v--;
			mapp[u][v] = 1;//uとvに辺があることを示す
		}
	}
	dfs();
	return 0;
}




Measured memory_bytes: 3276
def main():
  n=int(input())
  ans=0
  for i in range(1,10):
    for j in range(1,10):
      if n==i*j:
        ans=1
        break
    if ans==1:
      break
  if ans==1:
    print("Yes")
  else:
    print("No")

main()

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

int main() {
  int N, c=0;
  cin >> N;
  for(int i=0; i<N; i++){
    string x;
    cin >>x;
    if(x == "Y"){
      c +=1;
    }
  }
  if(0 < c){
    cout << "Four" << endl;
  }
  else
   cout << "Three" << endl;
}

Measured memory_bytes: 256
S = input()
A = ["", ""]
Q = int(input())
b = 0
for _ in range(Q):
    query = input()
    if query[0] == "1":
        b ^= 1
    else:
        F = int(query[2])
        A[b^F-1] += query[4]
ans = A[0][::-1] + S + A[1]
if b:
    ans = ans[::-1]
print(ans)


Measured memory_bytes: 10208
n = int(raw_input())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())
A.sort()
B.sort()
C.sort()
abc = 0
i = 0
j = 0
k = 0
for j in range(n):
    while i < n-1 and A[i+1] < B[j]:
        i += 1
    while k < n-1 and B[j] >= C[k]:
        k += 1
    if A[i] < B[j] and B[j] < C[k]:
        #print i, j, k, (i+1)*(n-k)
        abc += (i + 1) * (n - k)
print abc

Measured memory_bytes: 17712
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> v;
	char put[100];
	while(scanf("%s",put)!=EOF)
	{
	    if(put[0]=='+')
	    {
	        int u=v[v.size()-1]+v[v.size()-2];
	        v.pop_back();v.pop_back();v.pb(u);
	    }
	    else if(put[0]=='-')
	    {
	        int u=0-v[v.size()-1]+v[v.size()-2];
	        v.pop_back();v.pop_back();v.pb(u);
	    }
	    
	  else   if(put[0]=='*')
	    {
	        int u=v[v.size()-1]*v[v.size()-2];
	        v.pop_back();v.pop_back();v.pb(u);
	    }
	    else{v.push_back(atoi(put));}
	}
	cout<<v[0]<<endl;
	return 0;
}


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

ll K;
string str;

signed main(){
    cin >> K >> str;
    if(K>=str.size()) {
        for(int i=0;i<str.size();i++) cout << str[i];
    }
    else {
        for(int i=0;i<K;i++) cout << str[i];
        cout << "...";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb push_back;
#define sp " ";
#define INF 10000000000
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    int n;
    cin>>n;
    vector<pii> a(n),b(n);
    rep(i,n) cin >> b[i].first >> b[i].second;
	rep(i,n) cin >> a[i].first >> a[i].second;
    int ans=0;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    vi usea(n,0);
    vi useb(n,0);
    rep(i,n){
        int x=-1;
        int y=-1;

        rep(j,n){
            if(useb[j]==1||usea[i]==1){
                continue;
            }
            if(a[i].first>=b[j].first){
                if(y<=b[j].second&&b[j].second<=a[i].second){
                    y=b[j].second;
                    x=j;
                }
            }
        }
        if(x!=-1){
            ans++;
            usea[i]=1;
            useb[x]=1;
        }
    }
    out(ans);
}

Measured memory_bytes: 384
S = list(input())
for a in range(8):
  p = [""]*4
  ans = ""
  for b in range(3):
    if(a>>b & 1):
      p[b] = "+"
    else:
      p[b] = "-"
      
  for c in range(4):
    ans += str(S[c]) + str(p[c])
    
  if eval(ans) == 7:
    print(ans + "=7")
    break

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main(void) 
{
	int a, b;
	double S;
	cin >> a >> b;
	S = a * b / 3.305785;
	cout << fixed << setprecision(6) << S << endl;
	return 0;
}


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

using LL = long long;

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

  string ans = "No";
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (abs(a - c) <= d) {
    ans = "Yes";
  }

  if ((abs(a - b) <= d) && (abs(b - c) <= d)) {
    ans = "Yes";
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math


def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"):
    # 駅間をC秒ではしる
    for i in range(N-1):
        cur = 0
        for j in range(i,N-1):
            if cur <= S[j]:
                cur = S[j]
            else:
                cur = -(-(cur-S[j])//F[j])*F[j]+S[j]
            cur += C[j]
        print(cur)
    print(0)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int()] * (N - 1)  # type: "List[int]"
    S = [int()] * (N - 1)  # type: "List[int]"
    F = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        C[i] = int(next(tokens))
        S[i] = int(next(tokens))
        F[i] = int(next(tokens))
    solve(N, C, S, F)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define endl '\n'


class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
		int a, b;
        in >> a >> b;
        if (a <= 5) out << 0 << endl;
        else if (a <= 12) out << b / 2 << endl;
        else out << b << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 256
#! coding:UTF-8
N = int(input())
data = [0]*N
def tra(N):
    data[0] = 1
    for i in range(N-1):
        if (i+2)*data[i] < (10**9+7):
            data[i+1] = (i+2)*data[i]
        else:
            data[i+1] = (i+2)*data[i]%(10**9+7)
    print(data[-1])
tra(N)


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

int main() {
  int a, b, c;

  cin >> a >> b >> c;

  if(a == b){
    if(b == c) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  else if(b == c){
    if(a == b) cout << "No" << endl; 
    else cout << "Yes" << endl;
  }
  else if(a == c){
    if(a == b) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  else cout << "No" << endl;

  return 0;
  
}


Measured memory_bytes: 256
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

res = 0

for i in range(N,0,-1):
    res = max(res, A1[0] + sum(A1[1:i]) + sum(A2[i-1:]))

print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>

using namespace std;

int n;
int H, W;
const char frame = '#';
const char inner = '.';

void solve(){
   
    return;
}

int main(){
    while(1){
        cin >> H >> W;
        if(!(H|W)){ break;}
        for(int i=0;i<H;i++){
            if(!i || !(H-1-i)){
                for(int j=0;j<W;j++){
                    cout << frame;
                }
            }else{
            for(int j=0;j<W;j++){
                if(!j || !(W-1-j)){
                    cout << frame;
                }else{
                    cout << inner;
                }
            }
            }
            cout << endl;

        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3112
from collections import defaultdict
from collections import deque
import sys
input = sys.stdin.readline
dd = defaultdict(list)
pq = defaultdict(int)
 
N, Q = map(int, input().split())
 
for _ in range(N-1):
    a,b = map(int, input().split())
    dd[a].append(b)
    dd[b].append(a)
 
for _ in range(Q):
    p,q = map(int, input().split())
    pq[p] += q
    
answer = [0]*N
queue = deque()
visited = {}
visited[1] = 1
queue.append(1)
 
while queue != deque():
    tmp = queue.popleft()
    answer[tmp-1] += pq[tmp]
    for i in dd[tmp]:
        if not i in visited:
            visited[i] = 1
            queue.append(i)
            answer[i-1] += answer[tmp-1]
            
print(*answer)

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

using namespace std;

int n,m;
int a[1001],b[1001];
int c[1001];
int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int i=0;i<m;i++)scanf("%d",&b[i]);
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			if(a[j]<=b[i]){
				c[j]++;
				break;
			}
		}
	}
	int maxx=0,maxin;
	for(int i=0;i<n;i++){
		if(maxx<c[i]){
			maxx=c[i];
			maxin=i;
		}
	}
	printf("%d\n",maxin+1);
	return 0;
}

Measured memory_bytes: 1200
#!/usr/bin/env python3
import math

N, H = list(map(int, input().split()))
a_list = []
b_list = []

for _ in range(N):
    a, b = list(map(int, input().split()))
    a_list.append(a)
    b_list.append(b)

max_a = max(a_list)
b_list = sorted(b_list, reverse=True)
b_list = [b for b in b_list if b > max_a]
count = 0

while H > 0:
    if b_list:
        H -= b_list.pop(0)
        count += 1
    else:
        count += math.ceil(H / max_a)
        break

ans = count
print(ans)


Measured memory_bytes: 12184
# C - String Transformation

S = list(str(input()))
T = list(str(input()))
l = len(S)
d = set()

ans = 'Yes'
for i in range(l):
    if S[i] != T[i]:
        tmp = S[i]
        if S[i] in d or T[i] in d:
            ans = 'No'
            break
        d.add(T[i])
        for j in range(i, l):
            if S[j] == tmp:
                S[j] = T[i]
            elif S[j] == T[i]:
                S[j] = tmp
    else:
        d.add(T[i])

print(ans)

Measured memory_bytes: 6704
#include<bits/stdc++.h>
using namespace std;
#define NIL 2000000001
typedef struct{
  int p,l,r,key; 
}node;

node tree[500001];
queue<int> q[2];
int root=NIL;

void insert(int key,int i){
  node z={NIL,NIL,NIL,key};
  int x=(root==NIL?NIL:root),y=NIL;
  if(root==NIL)root=i;
  while(x!=NIL){
    y=x;
    if(z.key<tree[x].key){
      x=tree[x].l;
    }else{
      x=tree[x].r;
    }
  }
  z.p=y;
  if(y==NIL){
    tree[0]=z;
  }else if(z.key<tree[y].key){
    tree[y].l=i;
  }else {
    tree[y].r=i;
  }
  tree[i]=z;
}

void print(int n=0){
  if(n==NIL)return;
  q[1].push(tree[n].key);
  print(tree[n].l);
  q[0].push(tree[n].key);
  print(tree[n].r);
}

int find(int key){
  int f=-1,x=root;
  while(x!=NIL){
    if(tree[x].key>key){
      x=tree[x].l;
    }else if(tree[x].key<key){
      x=tree[x].r;
    }else{
      f=x;
      break;
    }
  }
  return f;
}

void del(int k){
  int x=find(k);
  if(x==-1)return;
  if(tree[x].l==NIL&&tree[x].r==NIL){
    
    if(tree[tree[x].p].l==x){
      tree[tree[x].p].l=NIL;
    }else{
      tree[tree[x].p].r=NIL;
    }
    
  }else if(tree[x].l==NIL||tree[x].r==NIL){
    
    if(tree[x].l==NIL){
      if(tree[tree[x].p].l==x){
	tree[tree[x].r].p=tree[x].p;
	tree[tree[x].p].l=tree[x].r;
      }else{
	tree[tree[x].r].p=tree[x].p;
	tree[tree[x].p].r=tree[x].r;
      }
    }else{
      if(tree[tree[x].p].l==x){
	tree[tree[x].l].p=tree[x].p;
	tree[tree[x].p].l=tree[x].l;
      }else{
	tree[tree[x].l].p=tree[x].p;
	tree[tree[x].p].r=tree[x].l;
      }
    }
  }else{
    int dx=tree[x].r;
    while(tree[dx].l!=NIL)dx=tree[dx].l;
    tree[x].key=tree[dx].key;
    if(tree[dx].l==NIL&&tree[dx].r==NIL){
      
      if(tree[tree[dx].p].l==dx){
	tree[tree[dx].p].l=NIL;
      }else{
	tree[tree[dx].p].r=NIL;
      }
      
    }
    else{
      if(tree[dx].l==NIL){
	if(tree[tree[dx].p].l==dx){
	  tree[tree[dx].r].p=tree[dx].p;
	  tree[tree[dx].p].l=tree[dx].r;
	}else{
	  tree[tree[dx].r].p=tree[dx].p;
	  tree[tree[dx].p].r=tree[dx].r;
	}
      }else{
	if(tree[tree[dx].p].l==dx){
	  tree[tree[dx].l].p=tree[dx].p;
	  tree[tree[dx].p].l=tree[dx].l;
	}else{
	  tree[tree[dx].l].p=tree[dx].p;
	  tree[tree[dx].p].r=tree[dx].l;
	}
      }
    }
  }
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string a;
    cin>>a;
    
    if(a[0]=='i'){   
      int k;
      cin>>k;
      insert(k,i);
      
    }else if(a[0]=='f'){
      int key;
      cin>>key;
      cout<<(find(key)>=0?"yes":"no")<<endl;
    }else if(a[0]=='d'){
      int key;
      cin>>key;
      del(key);
    }else{
      print();
      for(int j=0;j<2;j++){
	while(!q[j].empty()){
	  cout<<" "<<q[j].front();
	  q[j].pop();
	}
	cout<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 12296
#include <stdio.h>

int main(void) {

  	int yen;
  	int happiness = 0;
  
  	//reads in money from stdin
  	scanf("%d", &yen);

  	happiness = 2*(yen-(yen%500)) + ((yen%500)-(yen%5));
  	printf("%d", happiness);
  
	return 0;
}

Measured memory_bytes: 128