akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 17;

int T[maxN], res[maxN];
bool juz[maxN];

void fail()
{
	printf("-1\n");
	exit(0);
}

void ans(int n)
{
	FOR(i, 1, n+1)	
		printf("%d ", res[i]);
	printf("\n");
	exit(0);
}

bool colide(int i)
{	return T[res[i]] == res[i+1];	}

int main()
{
	int n;
	scanf ("%d", &n);
	FOR(i, 1, n+1)
		scanf ("%d", T+i);
	if (n == 2)
		fail();

	int list = 1, mx = 0;
		
	FOR(i, 0, n)
	{
		int v = res[i];
		if (T[v] != list)
			res[i+1] = list;
		else
			res[i+1] = mx == list-1 ? mx+2 : mx+1;
		juz[res[i+1]] = true;
		
		while (juz[list])
			list++;
		mx = max(mx, res[i+1]);
	}
	
	if (res[n] > n)
		res[n] = list;
	
	int i = n;
	while (colide(i-1))
		swap(res[i], res[i-1]), i--;
	sort(res+i+1, res+n+1);
	
	if (!colide(i))
		ans(n);
	if (i <= n-2)
		swap(res[i+1], res[i+2]), ans(n);
		
	assert(i == n-1);
	swap(res[n-2], res[n-1]);
	swap(res[n-2], res[n]);
	if (colide(n-3))
		swap(res[n-2], res[n]);
	ans(n);
	assert(false);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 998244353;

int modpow(int a, int n) {
    int res=1;
    while(n>0) {
        if(n&1) res=res*a%MOD;
        a=a*a%MOD;
        n>>=1;
    }
    return res;
}

int modinv(int a){
    return modpow(a,MOD-2);
}

int cmod(int n, int m){

    int ret=1;
    for(int i=n-m+1; i<=n; i++){
        ret*=i; ret%=MOD;
    }
    for(int i=1; i<=m; i++){
        ret*=modinv(i);
        ret%=MOD;
    }
    return ret;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m,k;cin>>n>>m>>k;
    int res=0;  
    COMinit();

    rep(i,k+1){
        int t=m;
        t*=COM(n-1,i); t%=MOD;
        t*=modpow(m-1,n-i-1); t%=MOD;
        res+=t; res%=MOD;
    }
    
    cout<<res<<endl;
    
}

Measured memory_bytes: 15616
import sys
r_d={"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}
res=[]
for s in sys.stdin:
    l=[r_d[i] for i in s.strip()]
    m=[l[i] if l[i]>=l[i+1] else -l[i] for i in range(len(l)-1)]
    m.extend([l[-1]])
    res.extend([sum(m)])
[print(i) for i in res]



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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 ll a,b,k;
  cin >> a >> b >> k;
 
 if(a<k) cout << 0 << " " << max(0ll,b-(k-a)) << endl;
 else cout << a-k << " " << b << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
        int i,j,h,w;

        while(1){
                scanf("%d %d",&h,&w);
                if(h==0 && w==0) break;

                for(i=1,j=0;i<=h*w;i++,j++){
                        if(j%2==0)
                                printf("#");
                        else
                                printf(".");

                        if(i%w==0){
                                if(w%2==0) j++;
                                puts("");
                        }
                }puts("");
        }
        return 0;
}


Measured memory_bytes: 2612
#include<stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x-r>=0 && y-r>=0 && x+r<=W && y+r<=H){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
	int N, a[100];
	int rate[8] = { 400, 800, 1200, 1600, 2000, 2400, 2800, 3200 };

	cin >> N;
	rep(i, N) cin >> a[i];

	int cnt[9] = { 0 };
	rep(i, N){
		int idx = 8;
		rep(j, 8){
			if( a[i] < rate[j] ){
				idx = j;
				break;
			}
		}
		++cnt[idx];
	}

	int ans = 0;
	rep(i, 8) ans += (cnt[i] > 0);

	cout << max(ans, (int)(cnt[8] > 0)) << " " << ans + cnt[8] << endl;
}


Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from bisect import bisect_left

def main():
    n = II()
    cc = [111,222,333,444,555,666,777,888,999]
    print(cc[bisect_left(cc, n)])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int hasil=0;
    for(int a=0;a<n;a++)
    {
        int l, r;
        cin>>l>>r;
        hasil+=(r-l+1);
    }
    cout<<hasil<<endl;
    return 0;
}


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

int main()
{
    long long sum=0;
    int i,n;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
            continue;
        sum+=i;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3636
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int s[510][510],n,m,Q,l,r,p,q,i,j;
  scanf("%d %d %d\n",&n,&m,&Q);
  for(i=0;i<=n;i++){
    s[0][i]=0;
    s[i][0]=0;
  }
  for(i=0;i<m;i++){
    scanf("%d %d\n",&l,&r);
    s[1][r]++;
    s[l+1][r]--;
  }
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      s[i][j+1]+=s[i][j];
    }
  }
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      s[j+1][i]+=s[j][i];
    }
  }
  for(i=0;i<Q;i++){
    scanf("%d %d\n",&p,&q);
    printf("%d\n",s[p][q]);
  }
  return 0;
}

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

int main() {
    int N,x;
    int a[110];  // 最大 100 個ですが余裕をもたせます
    cin >> N >>x;
    for(int i=0;i<N;i++)cin>>a[i];

    int count =0;
    sort(a, a + N);  // a[0:N] を大きい順にソート
    for(int i= 0 ;i<N;i++){
      if(x>=a[i] ){
        x-=a[i];
        if(i==N-1){
          if(x==0)count++;
        }else count++;

      }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
// Phoenix

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn=2010,inf=1e9+10;

vector<int>v[maxn];
int dp[maxn][maxn],n,k,ans=inf;

void dfs(int u,int par=-1){
    for(int y:v[u]){
	if(y!=par){
	    dfs(y,u);
	    dp[u][0]+=dp[y][0]+1;
	    for(int i=1;2*i<=k;i++)
		dp[u][i]+=dp[y][i-1];
	}
    }
    for(int i=(k+2)/2;i<=k;i++){
	dp[u][i]=inf;
    }
    for(int y:v[u]){
	if(y!=par){
	    for(int i=(k+2)/2;i<k;i++)
		dp[u][i]=min(dp[u][i],dp[u][k-i]-dp[y][k-i-1]+dp[y][i-1]);
	    dp[u][k]=min(dp[u][k],dp[u][0]-dp[y][0]-1+dp[y][k-1]);
	}
    }
    for(int i=1;i<=k;i++){
	dp[u][i]=min(dp[u][i],dp[u][i-1]);
    }
    ans=min(ans,dp[u][k]+n-dp[u][0]-1);
}

int main(){
    cin>>n>>k;
    for(int i=1;i<n;i++){
	int a,b;cin>>a>>b;
	v[a].PB(b);
	v[b].PB(a);
    }
    dfs(1);
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 16256
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#define MAX_INT 2147483647
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
int N, M;
int a, b;
vector <P> v;
void solve() {
	int ans = 0;
	int now = 0;
	scanf("%d %d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d %d", &a, &b);
		v.push_back({ b,a });
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < M; i++) {
		if (now <= v[i].second) {
			now = v[i].first;
			ans++;
		}
	}
	printf("%d\n", ans);
}
int main(int args, char* argv[]) {
	solve();
}

Measured memory_bytes: 1528
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
//#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define izryt bool
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const llint mod=1000000007;
const llint gya=500000004;//mod modで2の逆元
const llint big=1e9+1e8;
const llint red=0xE869120;
const llint pro=1002001;
int main(void){
	int i,j,r,c,x,y,d,l;
	string str;
	cin>>y>>x;
	for(i=0;i<x+2;i++){
		cout<<'#';
	}
	cout<<endl;
	for(i=0;i<y;i++){
		cout<<'#';
		cin>>str;
		cout<<str;
		cout<<'#'<<endl;
	}
	for(i=0;i<x+2;i++){
		cout<<'#';
	}
	cout<<endl;
	return 0;
}

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

namespace AtCoder
{
    public class MainClass
    {

        public static void Main(string[] args)
        {
            checked
            {
                Console.ReadLine();
                var s = Console.ReadLine();
                int r = s.Count(c => c == 'R');
                int b = s.Count(c => c == 'B');

                if (r > b) Console.WriteLine("Yes");
                else Console.WriteLine("No");
            }
        }

    }

    public static class EnumerablePlus
    {
        ///<summary>出力文字列に変換。</summary>
        public static string MkString<T>(this IEnumerable<T> list)
        {
            return list.Aggregate(
                new System.Text.StringBuilder(),
                (a, b) => ((a.Length > 0) ? a.Append(' ') : a).Append(b)
                ).ToString();
        }

        ///<summary>添字付きfor。</summary>
        public static void ForEach<T>(this IEnumerable<T> list, Action<T, int> a)
        {
            int i = 0;
            foreach (var item in list)
            {
                a(item, i);
            }
        }

        ///<summary>指定回数デリゲートを呼び出す。</summary>
        public static IEnumerable<T> Repeat<T>(int n, Func<T> f)
        {
            for (int i = 0; i < n; i++)
            {
                yield return f();
            }
        }
    }

}


Measured memory_bytes: 11220
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Main {

    static final int UNCALC = -1, INF = (int) 1e9;
    static int[] a, b, memo;
    static int n;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int h = sc.nextInt();
        n = sc.nextInt();
        a = new int [n];
        b = new int [n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        memo = new int[h + 1];
        Arrays.fill(memo, UNCALC);
        out.println(dp(h));
        out.flush();
        out.close();
    }

    static int dp(int rem) {
        if (rem <= 0) return 0;
        if (memo[rem] != UNCALC) return memo[rem];
        int min = INF;
        for (int i = 0; i < n; i++)
            min = Math.min(min, b[i] + dp(rem - a[i]));
        return memo[rem] = min;
    }


    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        boolean ready() throws IOException {
            return br.ready();
        }


        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }


        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }

}

Measured memory_bytes: 23124
//MD. HASNAIN ALI (UNSOLVED)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define MAX(a,b) (a>b? a:b)
#define SWAP(a,b) {       \
                    a=a+b;\
                    b=a-b;\
                    a=a-b; }
#define ll long long


int main()
{
    char x[4];
    scanf("%s",&x);
    
    if(strcmp(x,"ABC")==0) printf("ARC\n");
    else printf("ABC\n");
    
    return 0;
}


Measured memory_bytes: 1620
//#define DEB1 //output check function
//#define DEB2 //same output, input from input.txt

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VVI = vector<VI>;


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


#ifdef DEB1
#define DPRINT(x) cout<< #x << "=" << (x) << endl; // print at debug mode
#else
#define DPRINT(x) ;
#endif
#ifdef DEB1
#define DCHECK(x) cout<< "debug check" << #x << endl;
#else
#define DCHECK(x) ;
#endif
 


/*
constant values
*/

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

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9

// Main program
void solve(){
    vector<PAIRLL> p;
    int N;
    cin >> N;
    LL a,b;
    REP(i,N){
        cin >> a >> b;
        p.PB(make_pair(b,a));
    }
    sort(p.begin(), p.end());


    bool flag = 0;
    LL sum = 0;
    REP(i,N){
        sum += p[i].second;
        DPRINT(p[i].first)
        if(sum > p[i].first){
            flag = 1;
        }
    }
    (flag)? cout << "No" << endl : cout << "Yes" << endl;


}



// ----------------------------------------------
int main() {

#ifdef DEB2
    cout << "DEBUG MODE"  << endl;
	ifstream in("input.txt"); //for debug
	cin.rdbuf(in.rdbuf()); //for debug
#endif

	int T=1; 

	for (int i = 0; i < T; ++i) {
		solve();
	}
}

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

long long n,a,b,c,d;

int main()
{
    cin>>n>>a>>b>>c>>d;
    n--;
    for(int i=0;i<=n;i++)
    {
        if(abs(b-a)<=(n-i)*d-i*c&&abs(b-a)>=(n-i)*c-i*d)
        {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;
using P = pair<int, int>;


char A[55][55];
char B[55][55];

ull E = 1000000007;

int main() {
    string S;
    cin >> S;
    size_t apos = S.find('A');
    size_t zpos = S.rfind('Z');
    cout << S.substr(apos, zpos - apos + 1).size() << endl;
}


Measured memory_bytes: 832
import itertools as it

n,m,x=map(int, input().split())
l=[]
check=[0]*(m)
ans=0
for i in range(n):
    a=list(map(int, input().split()))
    ans+=a[0]
    for j in range(m):
        check[j]+=a[j+1]
    l.append(a)

if min(check)<x:
    print('-1')
    exit()


for i in range(1,n+1):
    for p in it.combinations(range(n), i):
        #print(p)
        mon=0
        che=[0]*m
        for j in range(len(p)):
            mon+=l[p[j]][0]
            for k in range(m):
                che[k]+=l[p[j]][k+1]
        #print(che)
        if min(che)>=x:
            ans=min(ans,mon)

print(ans)

Measured memory_bytes: 68720
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           node(a,b,c)                 mp(mp(a,b),c)
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=500005;
int n,m;
vector<int>adj[M];
int vis[M],dis[M];
 main()

{
    fast
    cin>>n>>m;
    f(i,1,m)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v+n);
        adj[u+n].pb(v+2*n);
        adj[u+2*n].pb(v);
    }
    int st,en;
    cin>>st>>en;
    queue<int>q;
    q.push(st);
    vis[st]=1;
    dis[st]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(auto v:adj[u])
        {
            if(vis[v])continue;
            vis[v]=1;
            dis[v]=dis[u]+1;
            q.push(v);
        }
    }
    if(vis[en]==0)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<dis[en]/3<<endl;
    }
    return 0;

}





































Measured memory_bytes: 29364
k,n = map(int,input().split(" "))
alist = list(map(int, input().split(" ")))
glist = []
for i in range(n-1):
  glist.append(alist[i+1]-alist[i])
glist.append(k+alist[0]-alist[n-1])

print(k-max(glist))

Measured memory_bytes: 26420
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string S;
  cin >> N >> S;
  
  vector<int>A(N);
  for (int i = 0; i < N; i++) {
    A.at(i) = S.at(i) - '0';
  }
  
  vector<vector<int>> data(26, vector<int>(N));
  for (int i = 0; i < 26; i++) {
    int count = 0;
    for (int j = 0; j < N; j++) {
      if (A.at(j) == i+49){
        count++;
      }
      data.at(i).at(j) = count;
    }
  }
  
  vector<int>B(N-1);
  for (int i = 0; i < N-1; i++) {
    int count = 0;
    for (int j = 0; j < 26; j++) {
      if (data.at(j).at(i) > 0 && data.at(j).at(N-1) - data.at(j).at(i) > 0){
        count++;
      }
    }
    B.at(i) = count;
  }
  sort(B.begin(), B.end());    
  cout << B.at(N-2) << endl;
}
   

Measured memory_bytes: 3532
eval'H,W,A,B='+`tr ' ' ,`
*f=1
200000.times{f<<f[-1]*-~_1%M=10**9+7}
p (B...W).sum{|i|f[H-A-1+i]*f[A+W-i-2]*(f[H-A-1]*f[i]*f[A-1]*f[W-1-i]).pow(M-2,M)}%M

Measured memory_bytes: 33608
# 2020/04/28
# CODE FESTIVAL 2017 qual - B

# Input
n, m, k = map(int,input().split())

# Calc
ans = 'No'
eflg = False
for i in range(n+1):
    for j in range(m+1):
        pt = i * (m - j) + j * (n - i)
        if pt == k:
            ans = 'Yes'
            eflg = True
            break
    if eflg:
        break

# Output
print(ans)


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

int main(){
	int n,dif;
	cin >> n;
	int* r = new int[n];
	for(int i = 0;i < n; i++){
		cin >> r[i];
	}
	int currentMax = r[1] - r[0];
	int currentMin = r[0];
	for(int i = 1;i < n;i++){
		if(r[i] - currentMin > currentMax)
			currentMax = r[i] - currentMin;
		if(r[i] < currentMin)
			currentMin = r[i];

	}
	
	cout  << currentMax << endl;

	return 0;
}



Measured memory_bytes: 3876
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;


int main(void) {
    long long int N,K;
    cin >> N >> K;

    long long int tmp;

    tmp = N%K;

    if(tmp < K-tmp)
    cout << tmp;
    else
    cout << K-tmp;

    return 0;
}


Measured memory_bytes: 256
import sys
# from heapq import heappop, heappush
from collections import deque
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

N, M = map(int, input().split())
check_lst = [0] * N
lst = [[] for _ in range(N)]
for _ in range(N + M - 1):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    lst[A].append(B) #無向グラフの作成
    check_lst[B] += 1 #その点に入って来る辺が何本あるかを数える

n = check_lst.index(0) #入って来る辺が無いとき、その頂点がスタート
ans = [0] * N #答えのリスト
que = deque()
q_append = que.append
q_append(n) #スタートをqueに入れる
q_left = que.popleft
while que:
    v = q_left()
    for v2 in lst[v]: #頂点vから出る辺について走査
        check_lst[v2] -= 1
        if check_lst[v2] == 0: #最後に出てきたものだけ考える
            q_append(v2)
            ans[v2] = v + 1

print (*ans, sep = '\n')


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

int main() {
	int N;
	cin >> N;
	vector<int> vec (N);
	for(int i = 0;i < N;i++){
		cin >> vec.at(i);
	}
	int friendly = 0;
	for(int i = 0;i < N;i++){
		if(vec.at(vec.at(i)-1)-1 == i){
			friendly++;
		}
	}
	cout << friendly / 2 << endl;
}

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int ans=0;
llint n;
vector<int>v;

map<llint,llint> factorize(int x){
  map<llint,llint>ret;
  int t=x;
  for(int i=2;i*i<=x;i++){
    while(t%i==0){
      t/=i;
      ret[i]++;
    }
  }
  if(t>1)ret[t]++;
  return ret;
}


void solve(){
  cin >> n;
  map<llint,llint>mp;
  int ans=0;
  vector<llint>cnt(105,0);
  for(int i=1;i<=n;i++){
    for(auto p:factorize(i)){
      cnt[p.first]+=p.second;
    }
  }
  for(int i=2;i<105;i++){
    if(cnt[i]>=74)ans++;
  }
  for(int i=2;i<105;i++){
    for(int j=2;j<105;j++){
      if(i!=j && cnt[i]>=2 && cnt[j]>=24)ans++;
    }
  }
  for(int i=2;i<105;i++){
    for(int j=2;j<105;j++){
      if(i!=j && cnt[i]>=4 && cnt[j]>=14)ans++;
    }
  }
  for(int i=2;i<105;i++){
    for(int j=2;j<105;j++){
      for(int k=2;k<j;k++){
        if(i!=j && i!=k && cnt[i]>=2 && cnt[j]>=4 && cnt[k]>=4)ans++;
      }
    }
  }
  cout << ans << endl;
}

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


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

int main(){
    string S;
    cin >> S;
    ll blk_fst = 0, wht_fst = 0;
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S.at(i) == '0') blk_fst++;
            else wht_fst++;
        } else {
            if (S.at(i) == '1') blk_fst++;
            else wht_fst++;
        }
    }
    cout << min(blk_fst, wht_fst) << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	char A[H][W];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	int x[4] = { 1,0,-1,0 };
	int y[4] = { 0,1,0,-1 };
	bool flg = true;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			//A kakutei
			int cnt = 0;
			if (A[i][j] == '#'){
				for (int s = 0; s < 4; s++) {

					if ((j + x[s]) < 0 || (j + x[s]) >= W) {
						continue;
					}
					else if ((i + y[s]) < 0 || (i + y[s]) >= H) {
						continue;
					}
					else {
						if (A[i + x[s]][j + y[s]] == '.') {
							cnt++;
						}
					}

				}
		}

			if (cnt == 4) {
				flg = false;
			}
		}
	}
	if (flg) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30

int main() {
    int h, w; cin >> h >> w;
    V<string> s(h);
    for(int i = 0; i < h; i++) cin >> s[i];

    V<V<int> > cnt(h, V<int>(w));
    for(int i = 0; i < h; i++){
        V<int> d(w);
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#') continue;
            if(d[j]) continue;
            int l = 0;
            while(j + l < w){
                if(s[i][j + l] == '#') break;
                l++;
            }
            for(int k = 0; k < l; k++){
                cnt[i][j + k] += l;
                d[j + k] = 1;
            }
        }
    }
    for(int j = 0; j < w; j++){
        V<int> d(h);
        for(int i = 0; i < h; i++){
            if(s[i][j] == '#') continue;
            if(d[i]) continue;
            int l = 0;
            while(i + l < h){
                if(s[i + l][j] == '#') break;
                l++;
            }
            for(int k = 0; k < l; k++){
                cnt[i + k][j] += l;
                d[i + k] = 1;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            ans = max(ans, cnt[i][j] - 1);
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 22144
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N,T;
    cin >> N >> T;
    int c[1000];
    int t[1000];
    int p = 1001;
    int ans;
    for(int j=0;j<N;j++){
        cin >> c[j];
        cin >> t[j];
        if(t[j] <= T)
        p = min(p, c[j]);
    }
    if(p == 1001) cout << "TLE" << endl;
    else cout << p << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    map<int,int> mp;
    mp[1]=1;
    mp[2]=3;
    mp[3]=1;
    mp[4]=2;
    mp[5]=1;
    mp[6]=2;
    mp[7]=1;
    mp[8]=1;
    mp[9]=2;
    mp[10]=1;
    mp[11]=2;
    mp[12]=1;
    int a,b;
    cin>>a>>b;
    if(mp[a]==mp[b])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>


int main () {
    long long S[10][1001] = {0};
    int m, n, s;
    S[0][0] = 1;
    for (m = 0; m <= 100; m++) {
        for (s = 1000; s - m >= 0; s--) {
            for (n = 9; n; n--) {
                S[n][s] += S[n-1][s-m];
            }
        }
    }
    while ((scanf("%d %d", &n, &s)) == 2 && (n || s)) {
        printf("%lld\n", S[n][s]);
    }

    return 0;
}

Measured memory_bytes: 688
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define infi 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,k;
	cin>>n>>k;
	int a[200002]={};
	int b[200002]={};
	for(int i=1;i<=n;++i)
		cin>>a[i];
	int ch=1;
	while(k&&ch){
		memset(b,0,sizeof(b));
		for(int i=1;i<=n;++i){
			int l=(max(0ll,i-a[i]));
			int r=(min(n,i+a[i]));
			b[l]++;
			b[r+1]--;
		}
		ch=0;
		for(int i=1;i<=n;++i){
			b[i]+=b[i-1];
			if(b[i]!=a[i])
				ch=1;
			a[i]=b[i];
		}
		--k;
	}
	for(int i=1;i<=n;++i){
		cout<<a[i]<<" ";
	}
	#ifdef ANIKET_GOYAL
		// cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
}

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

using namespace std;

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

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

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

	vector<ll> v(3);
	REP(i, 3)cin >> v[i];
	if(v[0] == v[1] && v[1] == v[2]){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

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

  vector<string> S(N);

  for(int i=0; i<N; i++)
    cin >> S.at(i);

  sort(S.begin(), S.end());

  int y=0;

  vector<string> word(300000);

  vector<int> count(300000);

  int n = 0;
  for(int i=0; i<N; i++){
    if(i == N-1 && S.at(i-1)==S.at(i)){
      count.at(n)++;
      word.at(y)=S.at(i);
    }
    else if(i == N-1 && S.at(i-1)!=S.at(i)){
      n++;
      count.at(n)++;
      y++;
      word.at(y)=S.at(i);        
    }
    else if( S.at(i)==S.at(i+1) )
      count.at(n)++;
    else{
      count.at(n)++;
      n++;
      word.at(y)=S.at(i);
      y++;
    }
  }
    int MAX = 0;
    for(int i = 0;i<count.size();i++){
        if(MAX < count.at(i)){
            MAX = count.at(i);
        }
    }
    vector<int> answer(count.size());
    for(int i = 0;i<count.size();i++){
        if(count.at(i) == MAX){
            answer.at(i)++;
        }
    }
    priority_queue<string, vector<string>, greater<string>> pq;
    for(int i = 0;i<count.size();i++){
        if(answer.at(i) == 1){
            pq.push(word.at(i));
        }
    }
  while (!pq.empty()) {
    cout << pq.top() << endl;
    pq.pop(); 
  }
}

Measured memory_bytes: 20596
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll T1,T2,A1,A2,B1,B2;
int main(){
    cin>>T1>>T2>>A1>>A2>>B1>>B2;
    ll abs1=T1*(A1-B1);
    ll abs2=T2*(A2-B2);
    if(abs1+abs2==0){
        cout<<"infinity";
        return 0;
    }
    if(abs1>0){
        abs1*=-1;
        abs2*=-1;
    }
    if(abs1+abs2<0){
        cout<<0;
        return 0;
    }
    cout<<-abs1/(abs1+abs2)*2+(-abs1%(abs1+abs2)!=0);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
if n >= 1800 and n <= 1999:
  print('1')
elif n >= 1600:
  print('2')
elif n >= 1400:
  print('3')
elif n >= 1200:
  print('4')
elif n >= 1000:
  print('5')
elif n >= 800:
  print('6')
elif n >= 600:
  print('7')
elif n >= 400:
  print('8')

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int frq[N];
int rid[N];   
int n , q;

int bit[N + 1];
void update(int id, int val)
{
	for (int i = id; i <= N; i += i & (-i) ) bit[i] += val;
}
 
int get(int id)
{
	int sum = 0;
	for ( int i = id; i > 0; i -= i & (-i) ) sum += bit[i];
	return sum;
}
 
int query(int r)
{
	return get(r);
}
 

void solve()
{

	cin >> n >> q;

    mset(rid, -1); 

	loop(i,0,n)
	{
		cin >> A[i];
	}

	vector<pair<int,pii>> vec;

	loop(i,0,q)
	{
		int l , r;
		cin >> l >> r;
		l--,r--;
		vec.pb({r , {l,i}});
	}

	S(vec);

	// loop(i,0,q)
	// {
	// 	cout << vec[i].ss.ss << " " << vec[i].ss.ff<< " " << vec[i].ff << endl;
	// }
  	
    vector<int> ans(q);

    int j = 0; 

   	loop(i,0,n)
    { 
        if (rid[A[i]] !=-1)update(rid[A[i]], -1); 
        rid[A[i]] = i+1; 
        update(i + 1, 1); 
        while (j < q && vec[j].ff == i) 
        { 
            ans[vec[j].ss.ss] = query(vec[j].ff + 1)-query(vec[j].ss.ff); 
            j++; 
        } 
    } 
 
   	loop(i,0,q)cout << ans[i] << endl; 
	
}			
 	
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 42940
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static int N;

    static void Main(string[] args)
    {
        var s = new Scanner();
        N = s.ReadInt();

        Solve();
    }

    static void Solve()
    {
        ulong x = Convert.ToUInt64(N - 1);
        ulong ans = (1 + x) * (x / 2);
        if (x % 2 == 1)
        {
            ans += (x + 1) / 2;
        }

        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }

    public string ReadStr()
    {
        return this.Next();
    }

    public char ReadChar()
    {
        return this.Next()[0];
    }

    public int ReadInt()
    {
        return int.Parse(this.Next());
    }

    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }

    public long ReadLong()
    {
        return long.Parse(this.Next());
    }

    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }

    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }

    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }

    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}



Measured memory_bytes: 13268
#! python3
# queue.py

from collections import deque

n, q = [int(x) for x in input().split(' ')]

queue = deque([])
for i in range(n):
    inp = input().split(' ')
    queue.append([inp[0], int(inp[1])])

elapsed_time = 0
while True:
    proc = queue.popleft()
    if proc[1] - q <= 0:
        elapsed_time += proc[1]
        print(proc[0], elapsed_time)
    else:
        elapsed_time += q
        queue.append([proc[0], proc[1] - q])
    if len(queue) == 0:
        break


Measured memory_bytes: 13308
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  long int K,i,j,k;
  long int r=0;
  long int g=0;
  long int b=0;
  long int ans=0;
  char S[4001];

  scanf("%ld",&K);
  scanf("%s",S);

  for(i=0;i<K;i++)
  {
    if(S[i]=='R') r++;
    if(S[i]=='G') g++;
    if(S[i]=='B') b++;
  }

  ans = r*g*b;

  for(i=0;i<K;i++)
  {
    for(j=i+1;j<K;j++)
    {
      k=2*j-i;
      if(k<K && S[i]!=S[j] && S[j]!=S[k] && S[k]!=S[i]) ans--;
    }
  }

  printf("%ld\n",ans);

  return 0;
}

Measured memory_bytes: 1740
li = list(map(int,input().split()))
a = li[0]
b = li[1]
c = li[2]

s = []

for i in range(1,a+1):
    if a%i ==0 and b%i==0:
        s.append(i)

l =len(s)
print(s[l-c])
        

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,s,a[3200],dp[3200],result,MOD=998244353;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>s;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++){
		dp[0]++;
		for(int j=s;j>=a[i];j--)
			dp[j]=(dp[j]+dp[j-a[i]])%MOD;
		result=(result+dp[s])%MOD; 
	}
	cout<<result<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
    ll n;
    cin>>n;
    ll ans = n/2 + n%2;
    cout<<ans<<endl;
}

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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n;
    cin>>n;
    double ans=0;
    for(int i=0;i<n;i++){
        double x;
        string s;
        cin>>x>>s;
        if(s=="JPY")ans+=x;
        else ans+=x*380000;
    }
    
    printf("%f",ans);

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<string> s(10);
  s[0] = "pon";
  s[1] = "pon";
  s[2] = "hon";
  s[3] = "bon";
  s[4] = "hon";
  s[5] = "hon";
  s[6] = "pon";
  s[7] = "hon";
  s[8] = "pon";
  s[9] = "hon";

  cout << s[n % 10] << endl;
  return(0);
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int N;
    int alice_sum = 0;
    int bob_sum = 0;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; i++)
        cin >> a[i];
    sort(a, a + N, greater<int>());
    for(int i = 0; i < N; i+=2)
        alice_sum += a[i];
    for(int i = 1; i < N; i+=2)
        bob_sum += a[i];
  	cout << alice_sum - bob_sum << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
na=0
nb=0
for i in range(n):
  a,b=input().split(' ')
  if len(a) <  len(b):
    for i in range(len(a)):
      if a[i]>b[i]:
        na+=3
        break
      elif a[i]<b[i]:
        nb+=3
        break
      elif i==len(a)-1:
         nb+=3
  else:
     for i in range(len(b)):
      if a[i]>b[i]:
        na+=3
        break
      elif a[i]<b[i]:
        nb+=3
        break
      elif i==len(b)-1:
        if len(a) ==len(b):
          na+=1
          nb+=1 
        else:
         na+=3 

print(f"{na} {nb}")


Measured memory_bytes: 5612
N,Y=map(int, input().split())
result = ["-1","-1","-1"]
for i in range(N+1):
    for j in range(N-i+1):
        k = N - (i + j) 
        x = 10000 * i + 5000 * j + 1000 * k
        if Y == x:
            result = [str(i), str(j), str(k)]
            break
print(" ".join(result))


Measured memory_bytes: 3060
import Control.Monad

main :: IO ()
main = do
  [w, h, n] <- getInts
  inputs <- replicateM n getInts
  print $ solve (0, w) (0, h) inputs

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: (Int, Int) -> (Int, Int) -> [[Int]] -> Int
solve (w1, w2) (h1, h2) []
  | w2 - w1 > 0 && h2 - h1 > 0 = (w2 - w1) * (h2 - h1)
  | otherwise = 0
solve (w1, w2) (h1, h2) (l:ls) = solve w' h' ls
  where
    (w', h') = update l
    update [x, y, a]
      | a == 1 = ((max x w1, w2), (h1, h2))
      | a == 2 = ((w1, min x w2), (h1, h2))
      | a == 3 = ((w1, w2), (max y h1, h2))
      | a == 4 = ((w1, w2), (h1, min y h2))
      | otherwise = ((0,0), (0,0))


Measured memory_bytes: 1020
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

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

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


vector<int>G[100010];
bool visit[100010];

void dfs(int p) {
	visit[p] = true;
	for (int i = 0; i < G[p].size(); i++) {
		if (visit[G[p][i]]) continue;
		dfs(G[p][i]);
	}
}



int main(void) {
	int N, M; cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int x, y, z; cin >> x >> y >> z;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (!visit[i]) {
			ans++;
			dfs(i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8960