akhauriyash/Code-Regression huggingface dataset:
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    string s;
    cin >> s;
    if(s.size() == 2){
        cout << s << endl;
    } else {
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    int acc = 0;
    for(char c: s) {
        acc += (c-'0');
        acc %= 9;
    }
    if (acc % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;


const int NMAX = 1000;
const int MMAX = 2000;
ll inf = 1LL << 50;

ll d[NMAX];

int n, m;
int a[MMAX], b[MMAX];
ll c[MMAX];

void shortest_path(int s)
{
	for (int i = 0; i < n; ++i) d[i] = inf;
	d[s] = 0;
	for (int i = 0; i < n - 1; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			if (d[a[j] - 1] == inf) continue;
			if (d[b[j] - 1] > d[a[j] - 1] + c[j])
			{
				d[b[j] - 1] = d[a[j] - 1] + c[j];
			}
		}
	}
}


int main()
{

	cin >> n >> m;


	for (auto i = 0; i < m; ++i)
	{
		cin >> a[i] >> b[i] >> c[i];
		c[i] = -c[i];
	}

	shortest_path(0);
	ll ans = -d[n - 1];
	bool negative[NMAX];
	for (int i = 0; i < n; ++i) negative[i] = false;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (d[a[j] - 1] == inf) continue;
			if (d[b[j] - 1] > d[a[j] - 1] + c[j])
			{
				d[b[j] - 1] = d[a[j] - 1] + c[j];
				negative[b[j] - 1] = true;
			}
			if (negative[a[j] - 1] == true) negative[b[j] - 1] = true;
		}
	}

	if (negative[n - 1])
		cout << "inf" << endl;
	else cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
# define ll long long
# define endl "\n"
# define str string
# define vll vector<ll>
# define pb push_back
# define mll map<ll,ll>
# define mp make_pair
# define ff first
# define ss second
# define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x,y,z;
    cin>>x>>y>>z;
    ll ans;
    if(x>0){
        ll k=x/z;
        ll k1=x%z;
        if(y<k){
            ans=x-y*z;
        }
        else{
            y-=k;
            if(y%2==0){
                ans=k1;
            }
            else{
                ans=k1-z;
            }
        }
    }
    else{
        x=x*-1;
        ll k=x/z;
        ll k1=x%z;
        if(y<k){
            ans=x-y*z;
        }
        else{
            y-=k;
            if(y%2==0){
                ans=k1;
            }
            else{
                ans=k1-z;
            }
        }
    }
    cout<<abs(ans);
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define N 25
using namespace std;
int n,a[N],l[N],r[N];
bool used[N];

void dfs(int x,int z){
  if(z==0)cout<<' '<<x;
  if(l[x]!=-1)dfs(l[x],z);
  if(z==1)cout<<' '<<x;
  if(r[x]!=-1)dfs(r[x],z);
  if(z==2)cout<<' '<<x;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    cin>>l[a[i]]>>r[a[i]];
    if(l[a[i]]!=-1)used[l[a[i]]]=true;
    if(r[a[i]]!=-1)used[r[a[i]]]=true;
  }
  for(int i=0;i<n;i++)
    if(!used[i])cout<<"Preorder"<<endl,dfs(i,0),cout<<endl;
  for(int i=0;i<n;i++)
    if(!used[i])cout<<"Inorder"<<endl,dfs(i,1),cout<<endl;
  for(int i=0;i<n;i++)
    if(!used[i])cout<<"Postorder"<<endl,dfs(i,2),cout<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const LL inf=1000000000000000ll;
int a[2000],b[2000],nex[2000],g[105],S,T,n,w[105],d[105],f[105],m;
LL c[2000],ans;
void add(int x,int y,LL z){
	a[++m]=x; b[m]=y; c[m]=z;
	nex[m]=g[x]; g[x]=m;
	a[++m]=y; b[m]=x; c[m]=0;
	nex[m]=g[y]; g[y]=m;
}
int spfa(){
	for (int i=1;i<=T;++i) f[i]=-1;
	f[S]=1; d[1]=S; int l=1,r=2;
	while (l<r){
		for (int i=g[d[l]];i;i=nex[i])
		if (c[i]&&f[b[i]]==-1){
			f[b[i]]=f[d[l]]+1;
			d[r++]=b[i];
		}
		++l;
	}
	return f[T]!=-1;
}
LL flow(int x,LL F){
	if (x==T) return F;
	LL use=0,w;
	for (int i=g[x];i;i=nex[i])
	if (c[i]&&f[b[i]]==f[x]+1){
		w=flow(b[i],min(F-use,c[i]));
		c[i]-=w; c[i^1]+=w; use+=w;
		if (use==F) return F;
	}
	if (!use) f[x]=-1;
	return use;
}
int main(){
	scanf("%d",&n); m=1;
	for (int i=1;i<=n;++i) scanf("%d",&w[i]);
	S=n+1; T=n+2;
	for (int i=1;i<=n;++i)
	if (w[i]>0) add(S,i,w[i]),ans+=w[i];
	else add(i,T,-w[i]);
	for (int i=1;i<=n;++i)
	for (int j=i+i;j<=n;j+=i)
		add(j,i,inf);
	while (spfa()) ans-=flow(S,inf);
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
	string s;

	cin >> s;

	ll sum = 0;
	rep(i,s.length()){
		sum += (s[i]-'0');
	}
	//cout << sum << endl;
	if(sum % 9 == 0) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 3724
#include<iostream>

using namespace std;

int main()
{
    long long int a, b, c,d,x,y, re;
    cin >> a >>b >> c >>d;
    a*c>a*d? x=a*c: x=a*d;
    b*c>b*d? y= b*c: y= b*d;
    x>y? re=x: re=y;
    cout << re;
}


Measured memory_bytes: 3584
# INF = float("inf")
import sys,bisect
sys.setrecursionlimit(15000)

st = []
ar = 0
while True:
   n = int(sys.stdin.readline())
   if n == 0:
     break
   a = [int(sys.stdin.readline()) for _ in range(n)]
   ml = mg = a[0]
   #print(a)
   for i in range(1,n):
     ml = max(ml+a[i],a[i])
     mg = max(mg,ml)
     #print(ml,mg,a[i])
   print(mg)



Measured memory_bytes: 5676
#include <bits/stdc++.h>
#define long long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
int main()
{
    fastio;
    long n;
    cin >> n;
    n--;
    long s = 0;
    for (long i = 1; i <= n; i++)
    {
        s += n/i;
    }
    cout << s;
}


Measured memory_bytes: 3656
//tenka1_2018_a.cpp
//Sat Oct 27 20:31:57 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (s.size()==2){
		cout << s << endl;
	}else {
		cout << s[2] << s[1] << s[0] << endl;
	}
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    string s="";
    ll n;
    cin>>n;
    while(n>0)
    {
        n--;
        s+='a'+n%26;
        n=n/26;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
   
  
}
    
int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int A,B,M;cin >> A >> B >> M;
    vector<int> a(A),b(B);
    for (int i = 0; i < A; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < B; i++) {
        cin >> b[i];
    }
    int ans = INF;
    for (int i = 0; i < M; i++) {
        int x,y,c;cin >> x >> y >> c;
        x--,y--;
        chmin(ans, a[x] + b[y] - c);
    }
    sort(ALL(a));
    sort(ALL(b));
    chmin(ans, a[0] + b[0]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
h, w = map(int, input().split())
s = [input() for i in range(h)]

if h == 1:
    if w == 1:
        if s[0][0] == "#":
            print("No")
            exit()
    else:
        for j in range(w):
            if s[0][j] == ".":
                continue
            else:
                if j == 0:
                    if s[0][1] == ".":
                        print("No")
                        exit()
                if j == w-1:
                    if s[0][w-2] == ".":
                        print("No")
                        exit()
                else:
                    if s[0][j-1] == "." and s[0][j+1] == ".":
                        print("No")
                        exit()

elif w == 1:
    for i in range(h):
        if s[i][0] == ".":
            continue
        else:
            if i == 0:
                if s[1][0] == ".":
                    print("No")
                    exit()
            elif i == h-1:
                if s[h-2][0] == ".":
                    print("No")
                    exit()
            else:
                if s[i- 1][0] == "." and s[i+1][0] == ".":
                    print("No")
                    exit()

else:
    for i in range(h):
        for j in range(w):
            if s[i][j] == ".":
                continue
            else:
                if i == 0:
                    if j == 0:
                        if s[0][1] == "." and s[1][0] == ".":
                            print("No")
                            exit()
                    elif j == w-1:
                        if s[0][w-2] == "." and s[1][w-1] == ".":
                            print("No")
                            exit()
                    else:
                        if s[i][j-1] == "." and s[i][j+1] == "." and s[i+1][j] == ".":
                            print("No")
                            exit()

                elif i == h-1:
                    if j == 0:
                        if s[h-1][1] == "." and s[h-2][0] == ".":
                            print("No")
                            exit()
                    elif j == w-1:
                        if s[h-1][w-2] == "." and s[h-2][w-1] == ".":
                            print("No")
                            exit()
                    else:
                        if s[h-1][j-1] == "." and s[h-1][j+1] == "." and s[h-2][j] == ".":
                            print("No")
                            exit()

                elif j == 0:
                    if s[i-1][0] == "." and s[i][1] == "." and s[i+1][0] == ".":
                            print("No")
                            exit()

                elif j == w-1:
                    if s[i-1][w-1] == "." and s[i][w-2] == "." and s[i+1][w-1] == ".":
                            print("No")
                            exit()

                else:
                    if s[i][j-1] == "." and s[i-1][j] == "." and s[i+1][j] == "." and s[i][j+1] == ".":
                            print("No")
                            exit()

print("Yes")



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

using namespace std;

int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    long long ans=0ll;
    int mn=1e9+5;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        ans+=a[i];
        if(a[i]>b[i]){
            mn=min(mn,b[i]);
        }
    }
    cout<<ans-(mn==1e9+5?ans:mn)<<endl;
    return 0;
}

Measured memory_bytes: 3800
s = input()
if s in ['KIHBR','KIHBRA','KIHBAR','KIHBARA','KIHABR','KIHABRA','KIHABAR','KIHABARA','AKIHBR','AKIHBRA','AKIHBAR','AKIHBARA','AKIHABR','AKIHABRA','AKIHABAR','AKIHABARA']:
    print('YES')
else:
    print('NO')

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

cnt = [[0]*10 for _ in range(10)]

for i in range(1,n+1):
    check = str(i)
    head = int(check[0])
    tail = int(check[-1])
    cnt[head][tail] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j]*cnt[j][i]
        
print(ans)

Measured memory_bytes: 73360
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt
    val kusi = io.StdIn.readLine().split(' ').map(_.toInt)
    val sortKusi = kusi.sorted
    var res = 0
    for (i <- 0 until n) res += sortKusi(i*2)
    println(res)
  }
}

Measured memory_bytes: 21580
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  string s;
  cin >> s;
  rep(i , 3){
    if(s[i] == '9'){
      s[i] = '1';
    }
    else{
      s[i] = '9';
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {
	static final int r = 1000000000 + 7;

	public static int solve(int s) {
		int ans = 0;
		int dp[] = new int[s + 1];
		dp[0] = 1;
		for (int i = 3; i <= s; ++i) {
			int tmp = dp[i - 1] + dp[i - 3];
			tmp %= r;
			dp[i] = tmp;
		}
		ans = dp[s];
		return ans;
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		sc.close();
		int ans = solve(s);
		System.out.println(ans);
	}
}


Measured memory_bytes: 35332
N,W = map(int,input().split())
w = []
v = []
for i in range(N):
    x,y = map(int,input().split())
    w.append(x)
    v.append(y)

dp = [[0]*(W+1) for j in range(N+1)] # DPテーブルの作成

for i in range(N):
    for j in range(W+1):
        if j < w[i]: # 選ばない時
            dp[i+1][j] = dp[i][j]
        else: # 選ぶ時
            dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i])

print(dp[N][W])

Measured memory_bytes: 147208
#include<iostream>

using namespace std;
int main()
{
    string S;
    cin>>S;
    if(S=="SUN")
        cout<< 7 <<endl;
    else if(S=="MON")
        cout<< 6 <<endl;
    else if(S=="TUE")
        cout<< 5 <<endl;
    else if(S=="WED")
        cout<< 4 <<endl;
    else if(S=="THU")
        cout<< 3 <<endl;
    else if(S=="FRI")
        cout<< 2 <<endl;
    else if(S=="SAT")
        cout<< 1 <<endl;


        return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};
 
int main(){
    int a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  int T, A;
  cin >> T >> A;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  vector<pair<double, int>> Temp(N);
  for (int i = 0; i < N; i++) {
    double temp = (double)T - H[i] * 0.006;
    Temp[i] = make_pair((double)abs(temp - A), i);
  }
  sort(begin(Temp), end(Temp));

  cout << Temp[0].second + 1 << endl;
  return 0;
}


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

int c[16], a[16][16], n, m, x;
bool v[16];
int ans = 2e9;

void checkSol() {
    for(int j = 1; j <= m; j++) {
        int total = 0;
        for(int i = 1; i <= n; i++)
            if(v[i]) total += a[i][j];
        if(total < x) return;
    }

    int cost = 0;
    for(int i = 1; i <= n; i++)
        if(v[i])
            cost += c[i];

    ans = min(ans, cost);
}

void backtracking(int k) {
    for(int i = 0; i <= 1; i++) {
        v[k] = i;
        if(k == n) {
            checkSol();
        } else {
            backtracking(k+1);
        }
    }
}

int main() {
    cin >> n >> m >> x;
    for(int i = 1; i <= n; i++) {
        cin >> c[i];
        for(int j = 1; j <= m; j++)
            cin >> a[i][j];
    }

    for(int j = 1; j <= m; j++) {
        int total = 0;
        for(int i = 1; i <= n; i++)
            total += a[i][j];
        if(total < x) {
            cout << -1;
            return 0;
        }
    }

    backtracking(1);
    cout << ans;
}


Measured memory_bytes: 3652
import java.io.*;
import java.util.*;


public class Main{ 

	public static void main(String args[]){
		
		Scanner scan = new Scanner(System.in);
		DiceExtend d01 = new DiceExtend(scan.nextLine());
		Dice d02 = new Dice(scan.nextLine());
		if(d01.rollAllPattern(d02))
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}
class DiceExtend extends Dice{
	public DiceExtend(String line){
		super(line);
	}
	public void printTop(){
		System.out.println(this.top);
	}
	public boolean rotateCheck(Dice d){
		for(int j=0;j<4;j++){
			rotate();
			if(equalFace(d))
				return true;
		}
		return false;
	}
	public boolean rollAllPattern(Dice d){
		for(int i=0; i<4;i++){
			roll('N');
			if(rotateCheck(d))
				return true;
		}
		roll('W');
		if(rotateCheck(d))
			return true;		
		roll('E');
		roll('E');		
		if(rotateCheck(d))
			return true;		
		return false;				
	}
	
}
class Dice{
	int top;
	int back;
	int right;
	int left;
	int front;
	int bottom;
	public Dice(String line){
		String[] face = line.split(" ");
		top = Integer.parseInt(face[0]);
		back = Integer.parseInt(face[1]);
		right = Integer.parseInt(face[2]);		
		left = Integer.parseInt(face[3]);
		front = Integer.parseInt(face[4]);
		bottom = Integer.parseInt(face[5]);
	}
	void rotate(){
		int tmp = front;
		front = right;
		right=back;
		back = left;
		left = tmp;
	}
	public void roll(char c){
		int tmp = top;
		switch(c){
			case 'N':
				top = back;
				back=bottom;
				bottom = front;
				front = tmp;
				break;
			case 'E':
				top = left;
				left = bottom;
				bottom = right;
				right = tmp;
				break;
			case 'S':
				top = front;
				front = bottom;
				bottom = back;
				back = tmp;
				break;
			case 'W':
				top = right;
				right = bottom;
				bottom = left;
				left = tmp;
				break;
		}
	}
	boolean equalFace(Dice d){
		if(this.top == d.top && 
		   this.bottom==d.bottom &&
		   this.right == d.right &&
		   this.left == d.left &&
		   this.front == d.front &&
		   this.back == d.back)
			return true;
		else
			return false;
	}

}

Measured memory_bytes: 17336
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int H = sc.nextInt();
    int W = sc.nextInt();
    for (int i = 0; i < H; i ++) {
      for (int j = 0; j < W; j ++) {
        if (sc.next().equals("snuke")) {
          char c = (char)('A' + j);
          System.out.println(c + "" + (i + 1));
          return;
        }
      }
    }
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, l, t;
    cin >> n >> l >> t;
    vi x(n), w(n);
    rep(i, n) cin >> x[i] >> w[i];
    vpii y(n);
    rep(i, n) {
        int s = (w[i]==1?1:-1);
        y[i].first = (x[i] + s * (t % l)) % l;
        if (y[i].first<0) y[i].first = (l+y[i].first)%l;
        y[i].second = w[i];
    }
    vi rev;
    rep(i, n) if (w[0] != w[i]) rev.pb(x[i]);
    ll cnt = (ll)(sz(rev)) * (t / l) * 2;
    int x0 = (w[0]==1?x[0]:x[0]+l);
    for (int val : rev) {
        int dis = (w[0]==1?val-x0:x0-val);
        if (dis<=(t%l)*2) ++cnt;
        if ((ll)dis+l<=(ll)(t%l)*2) ++cnt;
    }
    int i2 = (w[0]==1?cnt%n:(n+(-cnt)%n)%n);
    int y0 = y[0].first;
    rep(i, n) y[i].second *= -1;
    VSORT(y);
    rep(i, n) y[i].second *= -1;
    int y0i = 0;
    while (y[y0i].first!=y0||y[y0i].second!=w[0]) ++y0i;
    vi ans(n);
    rep(i, n) ans[(i2+i)%n] = y[(y0i+i)%n].first;
    rep(i, n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 5488
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
l.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = l[0][2] + abs(i - l[0][0]) + abs(j - l[0][1])
        for k in range(N):
            tmp = max(h - abs(i - l[k][0]) - abs(j - l[k][1]), 0)
            if tmp != l[k][2]:
                break
            elif k == N-1:
                X = i
                Y = j
                H = h
print(X,Y,H)

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    map<int, int> ev;
    map<int, int> od;
    for(int i=0; i<n; i++) {
        if(i%2) od[v[i]]++;
        else ev[v[i]]++;
    }
    
    pair<int, int> odb1, odb2, evb1, evb2;
    odb1 = odb2 = evb1 = evb2 = mk(0, 0);

    for(auto& p: od) {
        if(p.second > odb1.second) {
            odb2 = odb1;
            odb1 = p;
        } else if(p.second > odb2.second) {
            odb2 = p;
        }
    }
    for(auto& p: ev) {
        if(p.second > evb1.second) {
            evb2 = evb1;
            evb1 = p;
        } else if(p.second > evb2.second) {
            evb2 = p;
        }
    }

    int res = 0;
    if(odb1.first == evb1.first) {
        res = min((n/2-odb1.second)+(n/2-evb2.second), (n/2-odb2.second)+(n/2-evb1.second));
    } else {
        res = (n/2-odb1.second) + (n/2-evb1.second);
    }

    cout << res << endl;
    return 0;
}

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

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  vector<int> s(N+1, 0);
  s[0] = 0;
  for(int i = 1; i <= N; i++){
    if(S[i-1] == 'W'){
      s[i] += 0 + s[i-1];
    }else{
      s[i] += 1 + s[i-1];
    }
  }
  int ans = 999999;
  int sum;
  for(int i = 1; i <= N; i++){
    sum = 0;
    if(i == 1){
      sum = s[N]  - s[i];
    }else if(i == N){
      sum = N-1 - s[N-1];
    }else{
      sum = s[N] - s[i] + i-1 - s[i-1];
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1796
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcount((unsigned int)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    ll N = s.size();
    ll pn = N/2; ll gn = N-pn;
    ll ans = 0;
    rep(i, N){
        if(i < gn){
            if(s[i] == 'p') ans--;
        }
        else{
            if(s[i] == 'g') ans++;
        }
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <map>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;
long long int INF = 1000000007;




int main() {
  int N,M;
  cin >> N >> M;
  int a[M],b[M],c[M];
  for(int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  int d[N][N];
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      d[i][j] = INF;
    }
  }
  for(int i = 0; i < N; i++) {
    d[i][i] = 0;
  }
  for(int i = 0; i < M; i++) {
    d[a[i]-1][b[i]-1] = c[i];
    d[b[i]-1][a[i]-1] = c[i];
  }
  for(int k = 0; k < N; k++) {
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) {
        d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
      }
    }
  }
  int count = 0;
  for(int i = 0; i < M; i++) {
    for(int j = 0; j < N; j++) {
      for(int k = 0; k < N; k++) {
        if(d[j][k] == d[j][a[i]-1] + c[i] + d[b[i]-1][k]) {
          count++;
          j = N;
          break;
        }
      }
    }
  }
  cout << M - count << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define dsc [](int a,int b)->bool {return a>b;}
#define pb push_back
#define test int t; cin>>t;
#define MOD 1000000007LL
#define all(x) (x).begin(),(x).end()

using namespace std;

ll nxt() { ll x; cin>>x; return x; }

int main()
{
    #ifndef ONLINE_JUDGE
        fio
    #endif
    IOS

    ll n = nxt();
    (n == 0) ? (cout<<1<<endl) : (cout<<0<<endl);

    return 0;
}


Measured memory_bytes: 3616
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int t = 0;
    for(;sc.hasNext();)t += sc.nextInt();
    out.printf("%d%n%d%n", t / 60, t % 60);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17180
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC__


int main() {   
    char b; std::cin >> b;
    char ans;
    switch (b) {
    case 'A':ans = 'T'; break;
    case 'C':ans = 'G'; break;
    case 'G':ans = 'C'; break;
    case 'T':ans = 'A'; break;
    }
    std::cout << ans << std::endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  string s;
  long long k;
  cin>>s>>k;

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


Measured memory_bytes: 256
#include <iostream>

typedef long long ll;

using namespace std;

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

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

int main()	{
  ll n;
  cin >> n;
  ll a[n] = {0};
  for (int i = 0; i < n; i++)	{
    cin >> a[i];
  }
  ll ans = 1;
  for (int i = 0; i < n; i++)	{
    ans = lcm(ans, a[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
from collections import deque

n,k = map(int, input().split())
al = list(map(int, input().split()))

val_cnt = {}
val_cnt[0] = 1
val_q = deque([0])
if k == 1:
    print(0)
    exit()

ans = 0
curr_sum = 0
for i in range(n):
    curr_sum += al[i]
    curr_sum %= k
    val = (curr_sum - (i+1))%k
    val_cnt.setdefault(val,0)
    ans += val_cnt[val]
    val_cnt[val] += 1
    val_q.append(val)
    if len(val_q) >= k:
        poped = val_q.popleft()
        val_cnt[poped] -= 1

print(ans)

Measured memory_bytes: 123052
#include<bits/stdc++.h>
#define N 2005
using namespace std;
int n,a[N],b[N],sl[N],sr[N];
char s1[N],s2[N];
struct T
{
	int x,y;
}s[N];
bool cmp(T x,T y)
{
	return x.x==y.x?x.y<y.y:x.x<y.x;
}
void biu()
{
	puts("-1");
	exit(0);
}

int main()
{
	scanf("%s%s",s1+1,s2+1);
	n=strlen(s1+1);
	for (int i=1;i<=n;i++)
		if (s2[i]=='1')
		{
			for (int j=1;j<=n;j++)
			{
				a[j]=s1[(i+j-2)%n+1]-'0';
				b[j]=s2[(i+j-2)%n+1]-'0';
			}
			break;
		}
	if (b[1]==0)
	{
		for(int i=1;i<=n;i++)
			if (s1[i]=='1') biu();
		puts("0");
		return 0;
	}
//	puts("ok");
	int Ans=100000000;
	b[n+1]=1;
	sl[1]=0;sr[n+1]=0;
	for (int i=2;i<=n;i++)
		if (b[i]) sl[i]=0;
		else sl[i]=sl[i-1]+1;
	for (int i=n;i>=1;i--)
		if (b[i]) sr[i]=0;
		else sr[i]=sr[i+1]+1;
	for (int i=0;i<n;i++)
	{
		int cnt=0;
		for (int j=1;j<=n;j++)
			if (a[j]!=b[(j+i-1)%n+1])
				s[++cnt]=(T){sl[j],sr[j]};
		if (cnt==0) {Ans=min(Ans,i);continue;}
		sort(s+1,s+cnt+1,cmp);
		int now=0;
		for (int j=cnt;j>=0;j--)
		{
			Ans=min(Ans,cnt+s[j].x+now+min(s[j].x+abs(now-i),now+abs(s[j].x-(n-i))));
			now=max(now,s[j].y);
		}
	}
	printf("%d\n",Ans);
}

Measured memory_bytes: 384
import java.util.Scanner;

//Hyper Rock-Scissors-Paper
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		String[] s = {"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun"};
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			boolean[] u = new boolean[15];
			for(int i=0;i<n;i++){
				String t = sc.next();
				for(int j=0;j<15;j++)if(s[j].equals(t))u[j]=true;
			}
			boolean[] win = new boolean[15], lose = new boolean[15];
			for(int i=0;i<15;i++){
				if(!u[i])continue;
				for(int j=i+1;j<=i+7;j++){
					int k = j%15;
					if(!u[k])continue;
					lose[k] = true;
					win[i] = true;
				}
			}
			String res = "Draw";
			for(int i=0;i<15;i++)if(u[i]&&!lose[i]&&win[i])res=s[i];
			System.out.println(res);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

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

namespace ConsoleApplication1
{
    struct Player
    {
        internal int id;
        internal double time;
    }

    class Competition
    {
        StringBuilder sb;
        Player[] list1, list2, list3;
        List<Player> final;

        public Competition()
        {
            sb = new StringBuilder();

            list1 = new Player[8];
            list2 = new Player[8];
            list3 = new Player[8];
            final = new List<Player>();
        }

        public void Solve()
        {
            MakeList(list1);
            MakeList(list2);
            MakeList(list3);

            final = final.OrderBy(p => p.time).ToList();

            for (int i = 0; i < 2; i++)
            {
                sb.AppendLine(final[i].id + " " + final[i].time);
            }
            Console.Write(sb);
        }

        private void MakeList(Player[] list)
        {
            for (int i = 0; i < 8; i++)
            {
                string[] input = Console.ReadLine().Split(' ');

                Player temp;
                temp.id = int.Parse(input[0]);
                temp.time = double.Parse(input[1]);

                list[i] = temp;
            }

            list = list.OrderBy(p => p.time).ToArray();

            for (int i = 0; i < 2; i++)
            {
                sb.AppendLine(list[i].id + " " + list[i].time);
                final.Add(list[i + 2]);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Competition c = new Competition();
            c.Solve();
        }
    }
}

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

int main(void)
{
    int A, B;
    cin >> A >> B;

    if (A >= 13) {
        cout << B << endl;
    }
    else if (A >= 6 && A <= 12) {
        cout << B / 2 << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>

int main(void){
 char str[4];
 scanf("%s", str);
 int max = 0;
 int count = 0;
 
for(int i = 0; i < 3; i++){
  if(str[i] == 'R'){
    count++;
  }else{
    count = 0;
  }
  if(max<count){
    max = count;
  }
}
printf("%d", max);
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int ky[] = {0, 3, 5, 7};
  int ans = 0;
  for (int a1 = 0; a1 < 4; a1 ++) {
    for (int a2 = (a1 == 0 ? 0 : 1); a2 < 4; a2 ++) {
      for (int a3 = (a2 == 0 ? 0 : 1); a3 < 4; a3 ++) {
        for (int a4 = (a3 == 0 ? 0 : 1); a4 < 4; a4 ++) {
          for (int a5 = (a4 == 0 ? 0 : 1); a5 < 4; a5 ++) {
            for (int a6 = (a5 == 0 ? 0 : 1); a6 < 4; a6 ++) {
              for (int a7 = (a6 == 0 ? 0 : 1); a7 < 4; a7 ++) {
                for (int a8 = (a7 == 0 ? 0 : 1); a8 < 4; a8 ++) {
                  for (int a9 = (a8 == 0 ? 0 : 1); a9 < 4; a9 ++) {
                    int ok = 0;
                    int kj = 0;
                    kj *= 10;
                    kj += ky[a1];
                    kj *= 10;
                    kj += ky[a2];
                    kj *= 10;
                    kj += ky[a3];
                    kj *= 10;
                    kj += ky[a4];
                    kj *= 10;
                    kj += ky[a5];
                    kj *= 10;
                    kj += ky[a6];
                    kj *= 10;
                    kj += ky[a7];
                    kj *= 10;
                    kj += ky[a8];
                    kj *= 10;
                    kj += ky[a9];
                    ok |= 1 << a1;
                    ok |= 1 << a2;
                    ok |= 1 << a3;
                    ok |= 1 << a4;
                    ok |= 1 << a5;
                    ok |= 1 << a6;
                    ok |= 1 << a7;
                    ok |= 1 << a8;
                    ok |= 1 << a9;
                    if (kj <= N && ok >= 14) ans ++;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  ll n,h;
  cin >> h >> n;
  ll x,s = 0;
  rep(i,n){
    cin >> x;
    s += x;
  }
  cout << (s >= h ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3600
A, B, M=map(int, input().split())

alist=list(map(int, input().split()))
blist=list(map(int, input().split()))

cost=min(alist)+min(blist)

for i in range(M):
  x, y, c=map(int, input().split())
  x-=1
  y-=1
  cost=min(cost, alist[x]+blist[y]-c)
  
print(cost)

Measured memory_bytes: 18612
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int dp[110][10010];

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

    int n,w;
    cin>>n>>w;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++)cin>>v[i].first>>v[i].second;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(j-v[i-1].second>=0)dp[i][j]=max(dp[i-1][j],dp[i-1][j-v[i-1].second]+v[i-1].first);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;

}


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

using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	if(n%2==0){
		if(k<=n/2)cout<<"YES";
		else cout<<"NO";
	}
	else {
		if(k<=(n+1)/2)cout<<"YES";
		else cout<<"NO";
	}
	
	return 0;
}

Measured memory_bytes: 256
n = gets.strip.to_i
c = 0
c += n if n > 0 && n <= 9
c += 9 if n > 9
c += (n - 99) if n > 99 && n <= 999
c += 900 if n > 999
c += (n - 9999) if n > 9999 && n <= 99999
c += 90000 if n > 99999
puts c

Measured memory_bytes: 1788
def input_from_console():
    r, d, x2000 = map(int, input().split())
    return r, d, x2000


def solve(r, d, x2000):
    x_prev = x2000
    x_list = []
    for i in range(10):
        x = r * x_prev - d
        x_list.append(x)
        x_prev = x
    return x_list


def main():
    r, d, x2000 = input_from_console()
    x_list = solve(r, d, x2000)
    print('\n'.join(map(str, x_list)))


if __name__ == "__main__":
    import sys
    if sys.gettrace():  # If in debug mode or not.
        check_cases()
    else:
        main()

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,n,m=0,x;
	char a[200001];
	scanf("%s",a);
	for(i=0;i<strlen(a);i++){
		if(a[i]=='A' && m==0){
			n=i+1;
			m=1;
		}
		if(a[i]=='Z'){
			x=i+1;
		}
	}
	printf("%d\n",x-n+1);
	return 0;
}

Measured memory_bytes: 384
/*💚💚💚 ITS A SLOW PROCESS BUT QUITING WONT SPEED IT UP 💚💚💚*/

#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <complex>
#include <cctype>
using namespace std;

/*-------------define----------------------------*/
#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ceilval(a,b)    (a+b-1)/ b
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define cf(x)            ll x; cin>>x; while(x--)

/*---------------bak****i end-----------------------*/


void zaroorat()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}
typedef pair<int, int> pairs;

int main()

  {
    zaroorat()  ;

    ll n;
    cin>>n;
    ll cnt=0;
    for(int i=1;i<n;i++){
      if(n%i==0){
        cnt+=n/i-1;
      }else{
        cnt+=n/i;
      }
    }
    cout<<cnt<<endl;




    return 0;
}


Measured memory_bytes: 3648
import math
(n,k),a,f = [list(map(int, s.split())) for s in open(0)]

a.sort(reverse=True)
f.sort()

low = 0
high = 0
for x, y in zip(a,f):
    high = max(high, x*y)

while high != low:
    test = int((high + low) // 2)
    tmp = 0
    for x, y in zip(a,f):
        tmp += max(0, x - math.floor(test / y))
        if tmp > k:
            low = test + 1
            break
    else:
        high = test
print(high)

Measured memory_bytes: 108476
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <math.h>
using namespace std;
typedef long long int ll;

ll dp[50050];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	vector<int> a(m);
	for(int i=0;i<m;i++){
		cin >> a[i];
	}
	for(int i=0;i<=n;i++){
		dp[i]=1e9;
	}
	dp[0]=0;
	for(int i=0;i<=n;i++){
		for(int j=0;j<m;j++){
			if(i+a[j]<=n){
				dp[i+a[j]]=min(dp[i+a[j]],dp[i]+1);
			}
		}
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    vector<vector<ll>> g(n);
    REP(i, n-1) {
        ll u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    vector<ll> vs(a);
    sort(ALL(vs));
    vs.erase(unique(ALL(vs)), vs.end());
    REP(i, n) a[i] = lower_bound(ALL(vs), a[i]) - vs.begin();

    vector<ll> ans(n);
    auto dfs = [&](auto &&self, ll v, ll p, vector<ll> &dp) -> void {
        ll idx = lower_bound(ALL(dp), a[v]) - dp.begin();
        ll hold = dp[idx];
        dp[idx] = a[v];
        ans[v] = lower_bound(ALL(dp), INF) - dp.begin();
        for(auto to: g[v]) if(to!=p) {
            self(self, to, v, dp);
        }
        dp[idx] = hold;
    };
    vector<ll> dp(n, INF);
    dfs(dfs, 0, -1, dp);

    REP(i, n) cout << ans[i] << "\n";

    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

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

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,p;
  cin >> n;
  rep(i,n){
    cin >> k >> p;
    cout << ((k % p)? k%p : p) <<endl;
  }
  return 0;
}

Measured memory_bytes: 3192
n=int(input())
x=list(map(int,input().split()))

x.sort()

psum=0
for i in range(len(x)):
    psum=psum+(x[0]-x[i])**2
#    print(psum)
pmin=psum    
for j in range(x[0]+1,x[len(x)-1]):
    psum=0
    for i in range(len(x)):
        psum=psum+(j-x[i])**2
#        print(psum)
    if pmin>psum:
        pmin=psum
print(pmin)            


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  int i,j,n,min,r;
  int a[100];
  int flag=1, count=0;

  scanf("%d",&n);

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

  for(i=0; i<n; i++){
    min = i;
    for(j=i; j<n; j++)
      if(a[j]<a[min])
	min = j;
    r=a[i];
    a[i]=a[min];
    a[min]=r;
    if(min!=i)
      count++;
    
  }
  for(i=0; i<n-1; i++)
    printf("%d ",a[i]);
  
  printf("%d\n%d\n",a[i],count);
  
  return 0;
}



Measured memory_bytes: 2140