akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
#include<valarray>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define MAX 200002

int n;
int a;
int b;
int c;
int d;

char buf[MAX];
string s;

bool use[MAX];
queue<int> q;
inline bool reach(int a,int b){
	memset(use,false,sizeof(use));
	q.push(a);
	use[a]=true;
	for(int i=a;i<n;i++){
		if(use[i]==false)continue;
		if(i+1<n&&s[i+1]=='.'){
			use[i+1]=true;
		}
		if(i+2<n&&s[i+2]=='.'){
			use[i+2]=true;
		}
	}
	return use[b];
}


int main(){
	cin>>n>>a>>b>>c>>d;
	scanf("%s",buf);
	s=buf;
	a--;
	b--;
	c--;
	d--;
	while(true){
	if(reach(a,c)){
		if(reach(b,d)){
			if(c>d){
				bool ok=false;
				for(int i=b;i<=d;i++){
					if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
							ok=true;
					}
					
				}
				if(!ok)break;
			}
			puts("Yes");
			return 0;
		}
	}
	break;
	}
	puts("No");
	return 0;
}


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

#define FOR(i, a, b) for(int i = a; i<b; ++i)
#define FR(a, b) for(int i = a; i>=b;--i)
#define _upgrade cin.tie(0); ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define INF 1e9+2137
#define all(x) (x).begin(), (x).end()

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef pair<int, int> iPair;

const int MAX = 1e5+2;
const int M = 1e9+7;

string s;

int d;
ll dp[MAX][101][2];

ll solve(int pos, int rem, bool lo)
{
    if(dp[pos][rem][lo] != -1)
        return dp[pos][rem][lo];

    if(pos == s.size())
    {
        if(rem)
            return dp[pos][rem][lo] = 0;
        else
            return dp[pos][rem][lo] = 1;
    }
    ll res = 0, hi = s[pos]-'0';
    if(lo)
        hi = 9;

    for(int i = 0; i<= hi; ++i)
    {
        bool nl = lo;
        if(!lo && i < hi)
            nl = 1;
        res += solve(pos+1, (rem+i)%d, nl);
        res %= M;
    }
    return dp[pos][rem][lo] = res%M;
}

int main()
{
    _upgrade;
    cin>>s>>d;
    memset(dp, -1, sizeof dp);
    cout<<(solve(0, 0, 0)-1+M)%M;
}


Measured memory_bytes: 158976
#include "bits/stdc++.h"
using namespace std;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int r, d, x;
	
	cin >> r >> d >> x;
	
	for (int i = 0; i < 10; i++) {
			x = r * x - d;
			cout << x << endl;
	}
	
	return 0;
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

const int N = 1e5 + 5;

int h[N], dp[N];
int n, k;

int sol(int idx) {
    int & ret = dp[idx];

    if(ret != -1) return ret;

    if(idx == n - 1) return 0;

    ret = sol(idx + 1) + abs(h[idx] - h[idx + 1]);

    for(int i = 2; i <= k; i++) {
        if(idx + i < n) {
            ret = min(ret, sol(idx + i) + abs(h[idx] - h[idx + i]));
        }
    }
    return ret;
}

int main(){
    fIO

    cin >> n >> k;


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

    memset(dp, -1, sizeof(dp));

    cout << sol(0);
}









Measured memory_bytes: 5760
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var count = 1;
            var min = array[0];
            for (int i = 1; i < N; i++)
            {
                var number = array[i];
                if (number <= min)
                {
                    count++;
                    min = number;
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 34012
/*
author: Apoorv Singh
*/

#include <bits/stdc++.h>
using namespace std;

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define eb emplace_back   
#define aint(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX

int modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

const int M = 1e5 + 10;
int size[M], parent[M], ans;

int find(int x)
{
    while (x != parent[x])
        x = parent[x];
    return x;
}

void unite(int a, int b)
{
    int p = find(a), q = find(b);
    if (p == q)
        return;
    int x, y;
    (size[p] >= size[q]) ? (x = p, y = q) : (x = q, y = p);
    ans -= size[x]*size[y];
    size[x] += size[y];
    size[y] = 0;
    parent[y] = x;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    int n,m;
    cin >> n >> m;
    pii edges[m];
    FOR(i,1,n+1)
    {
        parent[i] = i;
        size[i] = 1;
    }
    FOR(i,0,m)
        cin >> edges[i].F >> edges[i].S;
    ans = (n*(n-1))/2;
    int final[m];
    final[m-1] = ans; 
    FORR(i,m-1,0)
    {
        unite(edges[i].F, edges[i].S);
        final[i-1] = ans;
    }
    FOR(i,0,m)
        cout << final[i] << endl;
    return 0;
}

Measured memory_bytes: 5248
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
using namespace std;
const int N=1e5+5;
int n;
int a[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int ans=0;
	for(int i=2;i<=n;i++)
		if(a[i]==a[i-1]){
			ans++,a[i]=-1;
		}
	printf("%d\n",ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=1e6+5;
ll inf=1e15;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    
    while(t--)
    {
        
        int n,W;
        cin>>n>>W;
        ll ar[n+1][2];
        for(int i=1;i<=n;i++)
            cin>>ar[i][0]>>ar[i][1];
        ll dp[n+1][100005];
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=100004;j++)
                dp[i][j]=inf;
        }
        // for(int i=0;i<=100000;i++)
        // {
        //     dp[0][i]=0;
        // }

            
        dp[0][0]=0;
        for(int i=1;i<=n;i++)
        {
            for(int val=0;val<=100004;val++)
            {
                dp[i][val]=dp[i-1][val];
                if(val-ar[i][1]>=0)
                dp[i][val]=min(dp[i-1][val],dp[i-1][val-ar[i][1]]+ar[i][0]);
            }
        }
        ll res=0;
        for(int i=100000;i>=0;i--)
            {
                if(dp[n][i]<=W)
                {
                    res=i;
                    break;
                }
            }
        cout<<res;
    }

    return 0;
}

Measured memory_bytes: 82540
#include<iostream>

using namespace std;

int digit_count(int x)
{
	int ans = 0;
	while(x>0)
	{
		ans+=(x%10);
		x/=10;
	}
	return ans;
}

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

	cout << (n%digit_count(n)==0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define lei(v) int(v.length())
#define lel(v) ll(v.length())
#define rev(v) reverse(v.begin(),v.end())
#define so(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pa pair
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;
typedef vector<vector<pair<int,int>>> vvp;




int main()
{
    string S;
    cin >> S;
    int n = lei(S);
    int a = 0;
    rep(i,n/2){
        if(S[i] == S[n-i-1]) continue;
        a++;
    }
    out(a);
    
    return 0;
}



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



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

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

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












int main(){
    ll n;
    while(cin >> n, n){
        bool l = false, r = false, f = false;
        ll ans = 0;
        REP(i, n){
            string s;
            cin >> s;
            if(s == "lu") l = true;
            if(s == "ru") r = true;
            if(s == "ld") l = false;
            if(s == "rd") r = false;
            if(!f && l && r){
                f = true;
                ans++;
            }
            else if(f && !l && !r){
                f = false;
                ans++;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; ll k; cin >> n >> k;
	vi a(n), next(n); rep(i, n) cin >> a[i];
	map<int,int> m;
	rep(it, 2) for(int i = n - 1; i >= 0; i--){
		next[i] = m[a[i]];
		m[a[i]] = i;
	}
	k *= n;
	vi ans;
	map<int, ll> memo;
	
	for(int p = 0; k; p = (next[p] + 1) % n){
		if(memo.count(p)) k %= memo[p] - k;
		int d = next[p] > p ? next[p] - p + 1 : next[p] - p + n + 1; 
		if(k >= d){
			memo[p] = k;
			k -= d;
			continue;
		}
		m.clear();
		rep(i, k){
			int x = a[(p + i) % n];
			if(!m[x]){
				++m[x];
				ans.pb(x);
				continue;
			}
			while(1){
				int y = ans.back(); ans.pop_back(); --m[y];
				if(x == y) break;
			}
		}
		break;
	}
	rep(i, ans.size()) cout << ans[i] << (i==ans.size()-1?"\n":" ");
	return 0;
}

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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define fastio    ios::sync_with_stdio(0); cin.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

int inf(0x3fffffff);
int mod(1000000007);
double pi(acos(-1.0));

int32_t main() {
  fastio;
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  rep(i, 5) {
    int x;
    cin >> x;
    if (x == 0) cout << i + 1;
  }


  return 0;
}


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


int main() {
  int h, w, m;
  cin >> h >> w >> m;
  vector<P> bom(m);
  vector<int> row(h), col(w);
  rep(i, h) row[i] = 0;
  rep(i, w) col[i] = 0;
  rep(i, m) {
    int hi, wi;
    cin >> hi >> wi;
    hi--; wi--;
    row[hi]++; col[wi]++;
    bom[i] = make_pair(hi, wi);
  }
  int rowmax = 0, colmax = 0;
  rep(i, h) {
    if (rowmax < row[i]) rowmax = row[i];
  }
  rep(i, w) {
    if (colmax < col[i]) colmax = col[i];
  }

  ll rowmaxnum = 0, colmaxnum = 0;
  rep(i, h) {
    if (row[i] == rowmax) rowmaxnum++;
  }
  rep(i, w) {
    if (col[i] == colmax) colmaxnum++;
  }

  ll maxnum = rowmaxnum * colmaxnum;
  rep(i, m) {
    if (row[bom[i].first] == rowmax && col[bom[i].second] == colmax) {
      maxnum--;
    }
  }

  if (maxnum > 0) {
    cout << rowmax + colmax << endl;
  } else {
    cout << rowmax + colmax - 1 << endl;
  }

  //rep(i, h) cout << row[i] << " "; cout << endl;
  //rep(i, w) cout << col[i] << " "; cout << endl;

  return 0;
}
/*
*/


Measured memory_bytes: 7976
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    if(n%2==1){
      System.out.println("No");
      return;
    }
    String ss = s.substring(n/2,n);
    s = s.substring(0,n/2);
    if(s.equals(ss)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35684
x,y,a,b,c,=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p=p[:x]
q=q[:y]
ans=p+q
ans.sort(reverse=True)
ans=[0]+ans
nowi=x+y
r=[0]+r
nowr=0
while nowr<=c-1 and nowi>0 and r[nowr+1]>ans[nowi]:
  nowi+=-1
  nowr+=1
ans_=0
for i in range(nowi+1):
  ans_+=ans[i]
for j in range(nowr+1):
  ans_+=r[j]
print(ans_)


Measured memory_bytes: 104152
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	d, n := getInt(), getInt()

	if n == 100 {
		n = n + 1
	}
	switch d {
	case 0:
		fmt.Println(n)
	case 1:
		fmt.Println(100 * n)
	case 2:
		fmt.Println(100 * 100 * n)
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <string>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void abc118_b(vector<vector<int>> v) {

    int n = v[0][0];
    int m = v[0][1];

    vector<int> data;

    for (int i = 0; i < m; i++) {
        data.push_back(0);
    }

    for (int i = 1; i <= n; i++) {

        int k = v[i][0];

        for (int j = 1; j <= k; j++) {

            data[v[i][j]-1] += 1;

        }
    }

    int mycnt=0;
    for(int x :data){
        
        if(x==n){
            mycnt+=1;
        }
        
    }
    cout << mycnt << endl;


}

int main() {

    //    vector<vector < string>> vec_arr_result;
    vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata2();

    abc118_b(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}

Measured memory_bytes: 256
import sys

def drawChessBoard(l):
	if 0 in l:
		return
	for i in range(l[0]):
		for j in range(l[1]):
			if i % 2 == 0:
				if j % 2 == 0:
					print('#', end='' if j < l[1] - 1 else '\n')
				else:
					print('.', end='' if j < l[1] - 1 else '\n')
			else:
				if j % 2 == 0:
					print('.', end='' if j < l[1] - 1 else '\n')
				else:
					print('#', end='' if j < l[1] - 1 else '\n')
	print()

l = []
for i in sys.stdin:
	l.append([int(x) for x in i.split()])

for i in range(len(l)):
	drawChessBoard(l[i])


Measured memory_bytes: 7016
#include <iostream>
#include <vector>
#include <array>
#include <queue>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class F> auto recur(F f) {return [f](auto... a){ return f(f, a...);};}
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

using P = array<int, 2>;
const P d4[4] = {
    {1, 0},
    {0, 1},
    {-1, 0},
    {0, -1},
};

int h, w;

bool bc(int x, int y) {
    return 0 <= x && x < w && 0 <= y && y < h;
}
P move(int x, int y, int dir) {
    int nx, ny;
    nx = x + d4[dir][0];
    ny = y + d4[dir][1];
    return P{nx, ny};
}


int main() {
    int k;
    cin >> h >> w >> k;
    //    cout << h << " " << w << " " << k << endl;
    V<string> mp(h);
    int sx = -1, sy = -1;
    for (int i = 0; i < h; i++){
        cin >> mp[i];
        for (int j = 0; j < w; j++) {
            if (mp[i][j] == 'S') {
                sx = j; sy = i;
            }
        }
    }
    auto dist2 = [&](int x, int y) {
        return min(min(x, w-1-x), min(y, h-1-y));
    };
    VV<int> dist = VV<int>(h, V<int>(w, TEN(9)));
    VV<bool> used = VV<bool>(h, V<bool>(w, false));
    queue<P> q;
    q.push(P{sx, sy});
    dist[sy][sx] = 0;
    int ans = TEN(9);
    while (!q.empty()) {
        P p = q.front(); q.pop();
        int x = p[0], y = p[1];
        if (used[y][x]) continue;
        if (dist[y][x] > k) continue;
        used[y][x] = true;
        ans = min(ans, 1+(dist2(x, y)+k-1)/k);
        for (int d = 0; d < 4; d++) {
            auto np = move(x, y, d);
            int nx = np[0], ny = np[1];
            if (bc(nx, ny) == false) continue;
            if (mp[ny][nx] == '#') continue;
            if (dist[ny][nx] < dist[y][x]+1) continue;
            dist[ny][nx] = dist[y][x]+1;
            q.push(P{nx, ny});
        }
    }
    cout << ans << endl;
    return 0;
}




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

ll dp[3005][3005][4];


int main()
{
  ll r,c,k;
  cin>>r>>c>>k;


  ll val[r+5][c+5];
  memset(val,0,sizeof(val));

  for(ll i=0;i<k;i++)
  {
    ll a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    val[a][b]=c;
  }
  for(ll i=0;i<r;i++)
  {
    for(ll j=0;j<c;j++)
    {
      dp[i][j][1]=val[i][j];
    }
  }
  /*for(ll i=0;i<r;i++)
    {
      for(ll j=0;j<c;j++)
      {
        cout<<val[i][j]<<" ";
      }
      cout<<endl;
    }*/


  for(ll j=1;j<c;j++)
  {
    for(k=1;k<4;k++)
    {
      dp[0][j][k]=max(dp[0][j][k],dp[0][j-1][k-1]+val[0][j]);
      dp[0][j][k]=max(dp[0][j][k],dp[0][j-1][k]);
    }
    
  }



  for(ll i=1;i<r;i++)
  {
    for(ll j=0;j<c;j++)
    {

      for(ll k=0;k<4;k++)
      {
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
      }
      dp[i][j][1]=max(dp[i][j][1],dp[i][j][0]+val[i][j]);
      
      if(j!=0)
      for(ll k=1;k<4;k++)
      {
        dp[i][j][k]=max(dp[i][j-1][k],dp[i][j][k]);        
        dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+val[i][j]);
        //dp[i][j][k]=max(dp[i][j][k-1],dp[i][j][k]);
      }
    }
  }
  /*cout<<endl;
  for(ll i=0;i<c;i++)
  {
    for(ll k=0;k<4;k++)
    {
      cout<<dp[1][i][k]<<" ";
    }
    cout<<endl;
  }*/



  ll ans=0;
  for(ll k=0;k<4;k++)
  {
    ans=max(dp[r-1][c-1][k],ans);
  }
  cout<<ans<<endl;
  return 0;

}

Measured memory_bytes: 355576
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
a1 -= b1
a2 -= b2
if a1 < 0:
  a1 *= -1
  a2 *= -1
d = a1 * t1 + a2 * t2
if d > 0:
  print(0)
elif d == 0:
  print('infinity')
else:
  d *= -1
  l = a1 * t1
  if l % d != 0:
    print(l//d*2+1)
  else:
    print(l//d*2)
  #print(a1,a2)
  #print(d,l)

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

int main(){
    string S,T,U;
    int A,B;
    std::cin>>S>>T;
    std::cin>>A>>B;
    std::cin>>U;

    if(S==U){
        A--;
    }else{
        B--;
    }

    std::cout<<A<<' '<<B;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] bridges = new int[m][2];
		for(int i = 0; i < m; i++){
		    bridges[i][0] = sc.nextInt() - 1;
		    bridges[i][1] = sc.nextInt() - 1;
		}
		
		// 計算
		long[] result = new long[m + 1];
		result[m] = (long)n*(n-1)/2;
		UnionFind uf = new UnionFind(n);
		for(int i = m-1; i >= 0; i--){
		    int a = bridges[i][0];
		    int b = bridges[i][1];
		    if(uf.same(a, b)){
		        result[i] = result[i+1];
		        continue;
		    }
		    result[i] = result[i+1] - uf.cnt(a) * uf.cnt(b);
		    uf.union(a, b);
		}

		// 出力
		for(int i = 1; i < m + 1; i++){
		    System.out.println(result[i]);
		}
        
	}
}

class UnionFind {
    int[] parent;
    int[] rank;
	int[] cnt;
    
    UnionFind(int n){
        this.parent = new int[n];
        this.rank = new int[n];
        this.cnt = new int[n];
        for(int i = 0; i < n; i++){
            parent[i] = i;
            rank[i] = 0;
            cnt[i] = 1;
        }
    }
    
    public int find(int i){
        if(i == parent[i]) return i;
        parent[i] = find(parent[i]);
        return parent[i];
    }
    
    public void union(int x, int y){
        int xRoot = find(x);
        int yRoot = find(y);
        if(rank[xRoot] < rank[yRoot]){
            parent[xRoot] = yRoot;
            cnt[yRoot] += cnt[xRoot];
        }else if(rank[xRoot] > rank[yRoot]){
            parent[yRoot] = xRoot;
            cnt[xRoot] += cnt[yRoot];
        }else{
            parent[yRoot] = xRoot;
            rank[xRoot]++;
            cnt[xRoot] += cnt[yRoot];
        }
    }
    
    public boolean same(int x, int y){
        return find(x) == find(y);
    }

    public int cnt(int x){
        return cnt[find(x)];
    }
}


Measured memory_bytes: 102872
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h, w, n;
    cin >> h >> w >> n;
    int cnt;
    cnt = 0;
    int ans;
    ans = 0;
    if(h>=w){
        while(cnt<n){
            cnt+= h;
            ans++;
        }
    }else{
        while(cnt<n){
            cnt+= w;
            ans++;
        }
    }
    cout << ans << endl;
}




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

using namespace std;

int n;
string s;

int p;
int calc()
{
  //cout << p << endl;
  vector<int> vec;
  while(1){
    if(s[p] == '['){
      p++;
      vec.push_back(calc());
      //p++;
    }
    else if(s[p] == ']'){
      sort(vec.begin(), vec.end());
      int ret = 0;
      //for(int i = 0; i < vec.size(); i++) cout << vec[i] << " "; cout << endl;
      for(int i = 0; i <= vec.size()/2; i++) ret += vec[i];
      p++;
      //cout << "*" << ret << endl;
      return ret;
    }
    else{
        int ret = 0;
        while(s[p] != ']'){
          ret *= 10;
          ret += s[p] - '0';
          p++;
        }
        p++;
        //cout << "@" << ret/2+1 << endl;
        return ret/2+1;
    }
  }
}

int main(void)
{
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s;
    s += "]";
    p = 0;
    cout << calc() << endl;
  }
  return 0;
}



Measured memory_bytes: 3208
program atcoder_contest_scheduling
  implicit none
  integer :: d, c(26) = 0, s(26, 365) = 0, t(365) = 0, u(365)
  integer :: m, n, x = 0, y, p, q, i
  real(8) :: t1, t2
  call cpu_time(t1)
  call random_seed_clock()
  read(*,*) d
  read(*,*) c
  read(*,*) (s(:, i), i = 1, d)
  t = [(maxloc(s(:, i), 1), i = 1, d)]
  do i = 1, d
    x = x + s(t(i), i)
  end do
  m = score(x, 1)
  u = t
  do
    p = next_int(365)
    q = next_int(26)
    t(p) = q
    y = x - s(u(p), p) + s(q, p)
    n = score(y, p)
    if (m < n) then
      x = y
      m = n
      u(p) = q
    else
      t(p) = u(p)
    end if
    call cpu_time(t2)
    if (t2 - t1 > 1.975d0) exit
  end do
  write(*,'(i0)') (u(i), i = 1, d)
contains
  integer function score(x, p) result(res)
    integer, intent(in) :: x, p
    integer, save :: mem(0:365) = 0, diff(26, 0:365) = 0
    integer :: i
    do i = p, d
      diff(:, i) = diff(:, i - 1) + c
      diff(t(i), i) = 0
      mem(i) = mem(i - 1) - sum(diff(:, i))
    end do
    res = x + mem(d)
  end
  subroutine random_seed_clock()
    integer :: nseed, clock
    integer, allocatable :: seed(:)
    call system_clock(clock)
    call random_seed(size = nseed)
    allocate(seed(nseed))
    seed = clock
    call random_seed(put = seed)
    deallocate(seed)
  end
  integer function next_int(m) result(res)
    integer, intent(in)  :: m
    real(8) :: r
    call random_number(r)
    res = int(m * r) + 1
  end
end program atcoder_contest_scheduling

Measured memory_bytes: 3076
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T
{
    std::io::Read::bytes(std::io::stdin())
                    .map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>()
                    .parse().ok().unwrap()
}

fn main() {
    let n = read();
    let x: i32 = read();
    let m: Vec<i32> = (0..n).map(|_| read()).collect();

    let sum: i32 = m.iter().sum();
    let min = m.iter().min().unwrap();
    let answer = n + (x - sum) / min;
    
    println!("{}", answer);
}


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

using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;

ll binPow(ll x, ll y, ll md = mod){
    ll res = 1;
    x %= mod;
    while(y){
        if(y & 1){
            res = (res * x) % mod;
        }
        y >>= 1;
        x = (x * x) % mod;
    }
    return res;
}

void solve(){
   string a, b, c;
   cin >> a >> b >> c;
   char now = 'a';
   int index_a = 0, index_b = 0, index_c = 0;
   while(true){
       if(now == 'a'){
           if(a.size() == index_a){
               cout << "A\n";
               break;
           }
           now = a.at(index_a++);
       }
       else if(now == 'b'){
           if(b.size() == index_b){
               cout << "B\n";
               break;
           }
           now = b.at(index_b++);
       }
       else{
           if(c.size() == index_c){
               cout << "C\n";
               break;
           }
           now = c.at(index_c++);
       }
   }
 }

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int p[100010]={0};
int d[100010]={0};
int S[100010];//サイズ用配列 未実験
//for(i=0;i<100010;i++)S[i]=1;
int Find(int a,int b){
  int r,n;
  for(r=++a;p[r];r=p[r]);
  for(;n=p[a];a=n)p[a]=r;
  for(r=++b;p[r];r=p[r]);
  for(;n=p[b];b=n)p[b]=r;
  return a-b?1:0;
}
void Union(int a,int b){
  if(Find(a,b)){
    for(++a;p[a];a=p[a]);
    for(++b;p[b];b=p[b]);
    d[a]<d[b]?(p[a]=b):(p[b]=a);
    if(d[a]==d[b])d[a]++;
    S[a]=S[b]=S[a]+S[b];
  }
}
int main(){
  int n,m,a,b,i;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)scanf("%d",&d[i]);
  for(i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    Union(a,b);
  }
  for(i=a=0;i<n;i++)a+=Find(i+1,d[i]);
  printf("%d\n",n-a);
  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define LL long long
#define REP(i, n) for(int i=0;i<(n);++i)
#define REPA(i, n) for(int i=1;i<(n);++i)
#define lp(i, n) for(int i=-;i<(n);++i)
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define DEKAI ((int)1e9+7)
#define ALL(x) (x).begin(), (x).end()
#define BIT(x) (1<<(x))
#define foreach(i, n) for(auto &i:(n))
using namespace std;

int kai(int x){
    if(x>1)return x * kai(x-1);
    return 1;
}

double func(){
    int low = kai(9);
    int high = 0;
    vector<int> A(9), B(9);
    foreach(i, A)cin>>i;
    foreach(i, B)cin>>i;
    sort(ALL(A));
    do{
        int Acount=0;
        int Bcount=0;
        REP(i, 9){
            if(A[i]>B[i])Acount+=A[i]+B[i];
            else Bcount+=A[i]+B[i];
        }
        high += Acount > Bcount;
    }while(next_permutation(ALL(A)));
    return (double)high / low;
}

int main(){
    int N;
    cin >> N;
    REP(i, N){
        double res = func();
        printf("%.7f %.7f\n", res, 1-res);
    }
    return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    string s; cin >> s;
    int n = s.size();
    int cnt = 0;
    stack<char> st;
    rep(i, n) {
        if(st.empty()) {
            st.push(s[i]);
            continue;
        }
        if(s[i] != st.top()) {
            cnt++;
            st.pop();
        } else {
            st.push(s[i]);
        }
    }
    cout << cnt * 2 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    vector<int> l, r, ans;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'o'){
            l.push_back(i);
            i += c;
            if(l.size() >= k)
                break;
        }
    }
    for(int i = s.size() - 1; i >= 0; i--){
        if(s[i] == 'o'){
            r.push_back(i);
            i -= c;
            if(r.size() >= k)
                break;
        }
    }
    for(int i = 0, j = r.size() - 1; i < l.size() && j >= 0; i++, j--){
        if(l[i] == r[j])
            ans.push_back(l[i] + 1);
    }
    for(auto i : ans)
        cout << i << endl;
    return 0;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll a, b, c; cin >> a >> b >> c;
  ll x = 4 * a * b;
  if (c - (a + b) < 0) {
    cout << "No\n";
    return 0;
  }
  ll y = c * c + (a + b - 2 * c) * (a + b);
  cout << (x < y ? "Yes\n" : "No\n");

  return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;
typedef long long ll;
int main(){
  ll Nra = 0, Nlb = 0, Nab = 0;
  ll N, ret = 0;
  string tmp;
  
  cin >> N;
  for (ll i=0; i<N; i++){
    cin >> tmp;
    for (int j=0; j<tmp.size() - 1; j++){
      if(tmp.substr(j, 2) == "AB") ret++;
    }
    if (tmp.front() == 'B' && tmp.back() == 'A') Nab++;
    else if (tmp.front() == 'B') Nlb++;
    else if (tmp.back() == 'A') Nra++;
  }
  ret += max(Nab - 1, (ll)0);
  if (Nab > 0){
    ret += (int)(Nra > 0) + (int)(Nlb > 0);
    Nra--;
    Nlb--;
  }
  ret += max(min(Nra, Nlb), (ll)0);
  cout << ret << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vec;
typedef std::vector<ld> vecld;
typedef std::vector< std::vector<ll> > vecvec;
typedef std::pair<ll, ll> pr;
typedef std::vector< pr > vpr;

#define tin ll t;cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define sz(a) (ll)((a).size())
#define pb push_back
#define trvect(c,i) for(vector<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trset(c,i) for(set<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trmap(c,i) for(map<ll,ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define present(c,x) ((c).find(x) != (c).end())
#define ff first
#define ss second
#define mp make_pair
#define sq(a) (a)*(a)
#define cube(a) (a)*(a)*(a)
#define cnti(x) (__builtin_popcount(x)) //number of set bits in x
#define mod 1000000007
#define N 100005

ll qpow (ll n, ll m) {
	ll ret = 1;
	while (m) {
		if (m & 1) ret = ret * n % mod;
		n = n * n % mod;
		m >>= 1;
	}
	return ret;
}
ll inv (ll a) {
	return qpow(a, mod - 2);
}

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



int main(){
    
    double r;
    cin>>r;
    double c = 2*M_PI*r;
    cout<<fixed;
    // cout<<M_PI;
    cout<<setprecision(10)<<c<<"\n";
}


Measured memory_bytes: 3784
#include "bits/stdc++.h"
 
typedef long long ll;
using namespace std;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
const int mod2 = 998244353 ;
const int mod = 1e9 + 7;
void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("output.txt", "w", stderr);
    #endif
}
const int N = 2e5 + 5;
vector<int> g[N];
int a[N], dp[N], sz[N], ans[N];
int fac[N],invf[N];
inline int mul(int x, int y) { return (1LL * x * y) % mod; }
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int sub(int x, int y) { return x - y >= 0 ? x - y : x - y + mod; }
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}
void initcombi(int n) {
    for (int i = fac[0] = 1; i <= n; i++) { fac[i] = 1ll * fac[i - 1] * i % mod; }
    invf[n] = power(fac[n], mod - 2);
    for (int i = n; i; i--) { invf[i - 1] = 1ll * invf[i] * i % mod; }
}
 
inline int NCR(int n, int m) {
    if (n < m) { return 0; }
    return 1ll * fac[n] * invf[m] % mod * invf[n - m] % mod;
}

void dfs1(int u, int p) {
	sz[u] = 1;
	dp[u] = 1;
	for(auto it : g[u]) {
		if(it != p) {
			dfs1(it, u);
			sz[u] += sz[it];
			dp[u] = mul(dp[u], dp[it]);
			dp[u] = mul(dp[u], invf[sz[it]]);
		}
	}
	dp[u] = mul(dp[u], fac[sz[u] - 1]);


}
void reroot(int u, int p) {
	ans[u] = dp[u];
	for(auto it : g[u]) {
		if(it == p)	continue;

		int tmp_sz_u = sz[u];
		int tmp_sz_it = sz[it];
		int tmp_dp_u = dp[u];
		int tmp_dp_it = dp[it];

		dp[u] = mul(dp[u], invf[sz[u] - 1]);
		dp[u] = mul(dp[u], fac[sz[it]]);
		dp[u] = mul(dp[u], power(dp[it], mod - 2));

		dp[it] = mul(dp[it], invf[sz[it] - 1]);

		sz[u] -= sz[it];
		sz[it] += sz[u];

		dp[u] = mul(dp[u], fac[sz[u] - 1]);

		dp[it] = mul(dp[it], fac[sz[it] - 1]);
		dp[it] = mul(dp[it], dp[u]);
		dp[it] = mul(dp[it], invf[sz[u]]);

		reroot(it, u);
		dp[it] = tmp_dp_it;
		dp[u] = tmp_dp_u;
		sz[u] = tmp_sz_u;
		sz[it] = tmp_sz_it;
	}
}
int main() {
	io();
	initcombi(200000);
	int n;
	cin >> n;

	for(int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		g[u].eb(v);
		g[v].eb(u);
	}
	dfs1(1, 1);

	reroot(1, -1);
	for(int i = 1; i <= n; i++) 	cout << ans[i] << "\n";

}




Measured memory_bytes: 18676
#include<bits/stdc++.h>
main(){
int n,m[4],p[4]={10,50,100,500},x[4],y[4],k,i=0,q,j;
while(true){std::cin>>n;if(!n){break;}
if(i){printf("\n");}i++;k=0;std::cin>>m[0]>>m[1]>>m[2]>>m[3];
for(j=3;j>=0;j--){k+=m[j]*p[j];}q=k-n;
for(j=3;j>=0;j--){x[j]=q/p[j];q-=x[j]*p[j];y[j]=std::max(0,m[j]-x[j]);}
for(j=0;j<4;j++){if(y[j]){printf("%d %d\n",p[j],y[j]);}}}}

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

int main() {
  int N, A, x;
  cin >> N >> A;
  x = N % 500;
  if (x == 0 ) {
    cout << "Yes" << endl;
  }
  else if ( x != 0 && A >= x) {
    cout << "Yes" << endl;
  }
  else if ( x != 0 && A < x) {
    cout << "No" << endl;
}
}


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

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

	int H,A;
	int i,k;
	int ans=0;
	int ctr=0;

	cin >> H >> A;

	ans=H/A;
	if(H%A!=0) ans++;
	
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,W; cin>>N>>W;
  vii dp(N+1,vi(100001,MOD));
  REP(i,1,N){
    int w,v; cin>>w>>v;
    rep(j,0,v) dp[i][j]=dp[i-1][j];
    dp[i][v]=min(dp[i-1][v],w);
    REP(j,v+1,100000){
      dp[i][j]=min(dp[i-1][j],dp[i-1][j-v]+w);
    }
  }
  int ans=0;
  REP(i,0,100000){
    if(dp[N][i]<=W)
      ans=i;
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 80256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <functional>
#include <queue>

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

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

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    bool flag = false;
    ll lsize = min(s.size(), t.size());
    rep(i, lsize) {
        if (ctoi(s[i]) != ctoi(t[i])) {
            flag = (ctoi(s[i]) < ctoi(t[i]));
            break;
        }
        if (i == lsize - 1) {
            flag = (s.size() < t.size());
            break;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
N = int(input())
A = [-1*int(input()) for _ in range(N)]


def LIS(seq, wider_sense=False):
    from bisect import bisect_left, bisect_right
    f = bisect_right if wider_sense else bisect_left
    N = len(seq)
    INF = 10**18
    dp = [INF] * (N+1)
    for x in seq:
        i = f(dp, x)
        dp[i] = x
    return f(dp, INF-1)


answer = LIS(A, wider_sense=True)
print(answer)


Measured memory_bytes: 7840
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a;
  string b;
  cin >> a >> b;
  if (a < 3200) cout << "red" << endl;
  else cout << b << endl;
}

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

if n < 10:
  print(n)
elif n < 100:
  print(9)
elif n < 1000:
  print(9 + n - 100 + 1)
elif n < 10000:
  print(9 + 900)
elif n < 100000:
  print(9 + 900 + n - 10000 + 1)
elif n < 1000000:
  print(9 + 900 + 90000)


Measured memory_bytes: 2940
N,A,B=map(int,input().split())
x=list(map(int,input().split()))
res=0
for i in range(N-1):
    
    if(B<=(x[i+1]-x[i])*A):
        res+=B
    else:
        res+=(x[i+1]-x[i])*A
print(res)

Measured memory_bytes: 14224
#include <stdio.h>
int main()
{
  int a[100],n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=n-1;i>=0;i--){
    printf("%d",a[i]);
    if(i!=0)printf(" ");
  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 600
def abc084_c():
    from math import ceil
    n = int(input())
    c = [0] * (n - 1)
    s = [0] * (n - 1)
    f = [0] * (n - 1)
    for i in range(n - 1):
        c[i], s[i], f[i] = map(int, input().split())

    for i in range(n - 1):
        time = 0
        for j in range(i, n - 1):
            if time < s[j]:
                time = s[j]
            else:
                time = f[j] * ceil(time/f[j])
            time += c[j]
        print(time)
    print(0)


abc084_c()

Measured memory_bytes: 3064
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;



int main(int argc, char* argv[])
{
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    
    vector<int> h(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &h[i]);
    }

    int l=0, r=INF;
    while(r-l>1) {
        int m=(l+r)/2;
        
        ll cnt=0;
        for(i=0; i<n; i++) {
            ll tmp=MAX(0,((ll)h[i]-(ll)m*b));
            cnt +=(tmp+(a-b)-1)/(a-b);
        }
        if(cnt<=m) {
            r=m;
        }
        else {
            l=m;
        }
    }
    printf("%d\n", r);

    return 0;
}




Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    string S;
    cin >> S;

    REP(i, S.size()) {
        const int c = S[i] - 'A';
        S[i] = (char)(((c + N) % 26) + 'A');
    }

    cout << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

typedef long long ll;

using namespace std;
int main(){
    int N, A, B;
    int ans;
    cin >> N >> A >> B;
    if (A * N < B) {
    	ans = A * N;
    }
    else {
    	ans = B;
    }
    
    cout << ans << endl;

}


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

using namespace std;
int e[100001] = {};
bool used[200001] = {};
int main(){
	int n,m;
	cin >> n >> m;
	
	for(int i = 0;i < m;i++){
		cin >> e[i];
	}
	
	for(int i = m-1;i >= 0;i--){
		if(!used[e[i]]){
			used[e[i]] = true;
			cout << e[i] << endl;
		}
	}
	
	for(int i = 1;i <= n;i++){
		if(!used[i]){
			cout << i << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3692