akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <cassert>
#include <algorithm>
#include <cstring>
#include <sstream>
using namespace std;

class F{
public:
	int x,y;
	F(int x,int y) : x(x) , y(y) {
		reflesh();
	}
	F(){ x = 0 , y = 1; }	
	void reflesh(){
		int g = __gcd(x,y);
		x /= g , y /= g;
	}
	F operator + (const F &b) const{
		int l = y/__gcd(y,b.y)*b.y;
		F r(x*l/y+b.x*l/b.y,l);
		r.reflesh();
		return r;
	}

	F operator * (const F &b) const{
		F r(x*b.x,y*b.y);
		r.reflesh();
		return r;
	}
	F operator / (const F &b) const{
		return (*this) * F(b.y,b.x);
	}
	string to(){
		stringstream ss;
		ss << x << "/" << y;
		return ss.str();
	}
};

vector<int> X; //@R
vector<int> Y; // Ô²ÆÌcè
int N,M,K,R;
F f(int pos,int m){
	if(R == 0) return F(1,1);
	if(X[pos]==0 && m == 0) return F(0,1);
	if(X[pos]==0 && m){
		for(int i = 0 ; i < N ; i++) if(Y[i]) return f(i,0);
	}
	F ans;
	int c = 0;
	//SÌÌTCYª25 RÌTCYª5 , ~µ¢J[hª2@üÁÄ¢ém¦Í
	for(int i = 0 ; i < N ; i++){
		if(Y[i]){
			F keisu(Y[i],1);
			R--;
			X[pos]--;
			Y[i]--;
			ans = ans + keisu * f(i,m);
			Y[i]++;
			X[pos]++;
			R++;
		}
	}
	return ans / F(R,1);
}

// posÔÚÌRÅAiÔðø¢ÄµÜÁ½ç

/*
	ª©ÁÄ¢é±Æ :
	
	kÌlÉÖíç¸	
	m = 0ÌÆ«A
	m = 1 ÌÆ«1+²aðnÅÁ½àÌÅ éB

	*/

void solve(int n,int k,int m,int r){
	N = n , M = m , K = k;
	X.clear();
	Y.clear();
	for(int i = 0 ; i < n ; i++) X.push_back(k);
	for(int i = 0 ; i < n ; i++) Y.push_back(k);
	R = n*k;
	
	cout << f(0,m).to() << endl;
}

int calc[10200]={};
int answ[10200]={};

bool g[12345]={};

void trueSolve(int n,int k,int m,int r){
	memset(answ,0,sizeof(answ));
	if(m == 1){
		if(n<=2){
			cout << "1." << string(r,'0') << endl;
		}else{
			for(int i = 0 ; i <= n-1 ; i++){
				int d = i?i:1;
				int c = 10;
				for(int j = 0 ; j < 10200 ; j++){
					calc[j] = c / (n*d);
					c %= n*d;
					c *= 10;
				}
				for(int j = 10199 ; j >= 0 ; j--){
					int a = answ[j]	+ calc[j];
					if(a > 9) ++answ[j-1] , a -= 10;
					answ[j] = a;
				}
			}
			cout << "0.";
			for(int i = 0 ; i < r ; i++){
				cout << answ[i];
			}
			cout << endl;
		}
	}else{
		if(n<=1){
			cout << "1." << string(r,'0') << endl;
		}else{
			int d = n;
			int c = 10;
			for(int j = 0 ; j < 10200 ; j++){
				calc[j] = c / n;
				c %= n;
				c *= 10;
			}
			cout << "0.";
			for(int i = 0 ; i < r ; i++){
				cout << calc[i];
			}
			cout << endl;
		}
	}
}
int main(){
	int n,k,m,r;
	while(cin >> n >> k >> m >> r && n){
		trueSolve(n,k,m,r);
	}
	
}

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

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

    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
            ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {

    int N, k, ans; 
    cin >> N >> k;
    ans = 0;
      
    vector<int> price(N);
      for (int i = 0; i < N; i++) {
      cin >> price.at(i);
        }
      
      std::sort(price.begin(), price.end() );
      
   for (int i = 0; i < k; i++) {
        ans = ans + price.at(i);
       }
      cout << ans << endl;
    }

Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int a,b;
    cin>>a>>b;
    if(b%a==0) cout<<a+b;
    else cout<<b-a;
}

Measured memory_bytes: 256
N, K = map(int ,input().split())
S = input()

A = []
t = S[0]
cnt = 1
for i in range(1,N):
	if S[i] == t:
		cnt += 1
	else:
		A.append(cnt)
		t = S[i]
		cnt = 1
A.append(cnt)

if S[0] == "1" and S[-1] == "0":
	A = A + [0]
	N += 1
elif S[0] == "0" and S[-1] == "1":
	A = A[::-1] + [0]
	N += 1
elif S[0] == "0" and S[-1] == "0":
	   A = [0] + A + [0]
	   N += 2

ans = sum(A[:2*K+1])
tmp = ans
tK = 2*K
for i in range((N-1)//2-K):
	ind = 2*i
	tmp = tmp - sum(A[ind:ind+2]) + sum(A[ind+tK+1:ind+tK+3])
	ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,sum=0;
  string s;
  cin>>a>>b;
  cout<<max(a,b)+max(max(a,b)-1,min(a,b))<<'\n';
  return 0;
}


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

using namespace std;


int main(){
    long long max = pow(10,9) + 7;
    long long n, k;
    cin >> n >> k;
    long long sum = 0;
    for(int t = k;t <= n + 1;t++){
        sum += t * (n - t + 1) + 1 % max; 
    }
    cout << sum % max << endl;
    return 0;
}


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

int main(void){
  long long int n, x, a[100010];
  cin >> n >> x;
  for(int i=0;i<n;++i){
    cin >> a[i];
  }
  long long int cnt=0;
  for(int i=1;i<n;++i){
    if((a[i-1]+a[i])>x){
      cnt += ((a[i-1]+a[i])-x);
      a[i] -= ((a[i-1]+a[i])-x);
      if(a[i]<0) a[i] = 0;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  int i;
  int n;
  char c;
};

int solve(int K, string S){
  vector<ST> v;
  rep(i,S.size()){
    int j=i;
    while(j+1<S.size() && S[i] == S[j+1]) j++;
    v.push_back((ST){i,j-i+1, S[i]});
    i=j;
  }

  int M = min(K, (int)v.size());
  int ii = v.size()-1;
  while(M>0 && ii>=0){
    if(v[ii].c == v[v.size()-1].c){
      ;
    }else{
      REP(j,v[ii].i,v[ii].i+v[ii].n){
        char c = (v[ii].c=='L')?'R':'L';
        S[j] = c;
      }
      M--;
    }
    ii--;
  }

  int ret = 0;
  rep(i,S.size()){
    if(S[i] == 'L'){
      if(i>0 && S[i-1] == 'L') ret++;
    }else{
      if(i<S.size()-1 && S[i+1] == 'R') ret++;
    }
  }
  return ret;
}

int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  int ret = solve(K,S);
  reverse(ALLOF(S));
  ret = max(ret, solve(K,S));
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int x = 0;
		int y = 0;
		int z = 0;
		
		Scanner sn = new Scanner(System.in);
		int tempX = sn.nextInt();
		int tempY = sn.nextInt();
		int tempZ = sn.nextInt();
		sn.close();
		
		if(tempY + 2 * tempZ <= tempX){
			if(1 <= tempX && tempX <= Math.pow(10, 8)){
				x = tempX;
			}
			if(1 <= tempY && tempY <= Math.pow(10, 8)){
				y = tempY;
			}
			if(1 <= tempZ && tempZ <= Math.pow(10, 8)){
				z = tempZ;
			}
		}
		try{
			int number = (x - z) / (y + z);
			System.out.println(number);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 23508
// Building a Space Station
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			Point[] points = new Point[n];
			for (int i = 0; i < n; i++) {
				double x = scanner.nextDouble();
				double y = scanner.nextDouble();
				double z = scanner.nextDouble();
				double r = scanner.nextDouble();
				points[i] = new Point(x, y, z, r);
			}
			double[][] costs = new double[n][n];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++) {
					double d = points[i].distance(points[j]);
					costs[i][j] = d;
				}
			boolean[] selected = new boolean[n];
			Arrays.fill(selected, false);
			selected[0] = true;
			double result = 0;
			while (!trueAll(selected)) {
				double cost = Double.MAX_VALUE;
				int dst = 0;
				for (int i = 0; i < n; i++) {
					if (selected[i]) {
						for (int j = 0; j < n; j++) {
							if (!selected[j] && cost > costs[i][j]) {
								cost = costs[i][j];
								dst = j;
							}
						}
					}
				}
				result += cost;
				selected[dst] = true;
			}
			System.out.printf("%.3f", result);
			System.out.println();
		}
		scanner.close();
	}

	static boolean trueAll(boolean[] selected) {
		boolean result = true;
		for (boolean b : selected) {
			result = result && b;
		}
		return result;
	}
}

class Point {
	double x, y, z, r;

	Point(double tx, double ty, double tz, double tr) {
		x = tx;
		y = ty;
		z = tz;
		r = tr;
	}

	public double distance(Point anotherPoint) {
		double dx = this.x - anotherPoint.x;
		double dy = this.y - anotherPoint.y;
		double dz = this.z - anotherPoint.z;
		double d2 = Math.pow(dx, 2) + Math.pow(dy, 2) + Math.pow(dz, 2);
		double d = Math.sqrt(d2);
		double cost = d - this.r - anotherPoint.r;
		return Math.max(cost, 0);
	}
}

Measured memory_bytes: 56268
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int MOD=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}

int main() {
	int a,b;
	cin>>a>>b;
	print((a-1)*(b-1));
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>

using namespace std;

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

long long h, w;
long long mindiff;
long long INF = 10e17;

int main(){
    cin >> h >> w;

    mindiff = INF;

    if(h==2 && w==2) mindiff = 1;

    long long hmi, hma;
    if(h>=3){
        hmi = floor((long double)h/3);
        hma = ceil((long double)h/3);
        mindiff = min(mindiff, hma*w - hmi*w);
    }

    long long wmi, wma;
    if(w>=3){
        wmi = floor((long double)w/3);
        wma = ceil((long double)w/3);
        mindiff = min(mindiff, wma*h - wmi*h);
    }

    long long s1, s2, s3;
    if(h>=3){
        s1 = hmi*w;
        s2 = floor((long double)w/2)*(h-hmi);
        s3 = ceil((long double)w/2)*(h-hmi);
        mindiff = min(mindiff, max({s1, s2, s3})-min({s1, s2, s3}));

        s1 = hma*w;
        s2 = floor((long double)w/2)*(h-hma);
        s3 = ceil((long double)w/2)*(h-hma);
        mindiff = min(mindiff, max({s1, s2, s3})-min({s1, s2, s3}));
    }

    if(w>=3){
        s1 = wmi*h;
        s2 = floor((long double)h/2)*(w-wmi);
        s3 = ceil((long double)h/2)*(w-wmi);
        mindiff = min(mindiff, max({s1, s2, s3})-min({s1, s2, s3}));

        s1 = wma*h;
        s2 = floor((long double)h/2)*(w-wma);
        s3 = ceil((long double)h/2)*(w-wma);
        mindiff = min(mindiff, max({s1, s2, s3})-min({s1, s2, s3}));
    }

    cout << mindiff << endl;
}


Measured memory_bytes: 256
import os, sys, re, math, queue

N = int(input())

nodes = {}
colors = [-1 for _ in range(N+1)]
for _ in range(N-1):
    s = input().split(' ')
    u,v,w = int(s[0]), int(s[1]), int(s[2])
    if u not in nodes:
        nodes[u] = [(v,w)]
    else:
        nodes[u].append((v,w))

    if v not in nodes:
        nodes[v] = [(u,w)]
    else:
        nodes[v].append((u,w))

q = queue.Queue()
f = list(nodes.keys())[0]
q.put((f,0))

while not q.empty():
    cur = q.get()
    colors[cur[0]] = cur[1]
    next = nodes[cur[0]]
    for n in next:
        if colors[n[0]] == -1:
            if n[1] % 2 == 0:
                q.put((n[0], cur[1]))
            else:
                q.put((n[0], (cur[1]+1) % 2))

for i in range(N):
    print(colors[i+1])


Measured memory_bytes: 89884
using System;
using System.Linq;

class B
{
    static void Main()
    {
        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var ps = Enumerable.Range(0, a[0]).Select(i => Console.ReadLine().Split(' ').Select(int.Parse).ToArray()).ToArray();

        var c = Enumerable.Range(0, a[0]).SelectMany(i => Enumerable.Range(i + 1, a[0] - i - 1).Select(j => new { i, j }))
            .Count(_ =>
            {
                var d = Math.Sqrt(Enumerable.Range(0, a[1]).Sum(k => Math.Pow(ps[_.i][k] - ps[_.j][k], 2)));
                return d == (int)d;
            });
        Console.WriteLine(c);
    }
}


Measured memory_bytes: 13524
h, n = map(int, input().strip().split())
# AB = [list(map(int, input().split())) for i in range(n)]

dp=[10**9]*(h+1)

dp[0]=0
for _ in range(n):
    a, b = map(int, input().strip().split())
    for i in range(h):
        ni=min(i+a,h)
        dp[ni] = min(dp[ni],dp[i]+b)
        
print(dp[h])

Measured memory_bytes: 43740
n = int(input())
xl = [list(map(int, input().split())) for i in range(n)]
xl = sorted([[x-l,x+l] for x,l in xl], key = lambda x: x[1])
now = - 10 ** 10
ans = 0
for s,e in xl:
  if s >= now:
    ans += 1
    now = e
print(ans)

Measured memory_bytes: 43560
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    double a,b,c,d=0,e=0,z=0;
    cin>>a>>b>>c;
    c+=0.5;
    z=c;
    while(z>a){
        d++;
        z-=a;
    }
    cout<<d*b;
    return 0;
}


Measured memory_bytes: 3736
# ABC 045: B – 3人でカードゲームイージー / Card Game for Three (ABC Edit)
s = [input() for _ in range(3)]
name = 'ABC'
turn = 0

while 1:
    if len(s[turn]) == 0:
        print(name[turn])
        break
    else:
        if s[turn][0] == 'a':
            s[turn] = s[turn][1:]
            turn = 0
        elif s[turn][0] == 'b':
            s[turn] = s[turn][1:]
            turn = 1
        elif s[turn][0] == 'c':
            s[turn] = s[turn][1:]
            turn = 2

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

int main(){
    string s;
    vector<int> wc(4);
    cin>>s;
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            if(s[i]==s[j]){
                wc[i]++;
            }
        }
    }
    int judge=1;
    for(int i=0;i<4;i++){
        if(wc[i]!=2){
            judge=0;
            break;
        }
    }
    switch(judge){
        case 0: cout<<"No"<<endl;
                break;
        case 1: cout<<"Yes"<<endl;
                break;
    }
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;

}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left, k);
  }
  else{
    return treeSearch(u->right, k);
  }

}

Node treeSuccessor(Node x){
  Node y;

  if(x->right != NIL){
    return (Node)treeMinimum(x->right);
  }

  y = x->parent;

  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }

  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL){
    y = z;
  }
  else{
    y = (Node)treeSuccessor(z);
  }
  
  if(y->left != NIL){
    x = y->left;
  }
  else{
    x = y->right;
  }
  
  if(x != NIL){
    x->parent = y->parent;
  }
  
  if(y->parent == NIL){
    root = x;
  }
  else if(y == y->parent->left){
    y->parent->left;
  }
  else{
    y->parent->right = x;
  }
  
  if(y != z){
    z->key = y->key;
  } 
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else{
    y->right = z;
  }

}

void inorder(Node u){
  
  if(u->left != NIL){
    inorder(u->left);
  }
  printf(" %d", u->key);
  if(u->right != NIL){
    inorder(u->right);
  }
  
}
void preorder(Node u){
  
  printf(" %d", u->key);
  if(u->left != NIL){
    preorder(u->left);
  }
  if(u->right != NIL){
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

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

B = {'z': 0}
for a in A:
    if 1 <= a <= 399:
        B['a'] = 1
    elif 400 <= a <= 799:
        B['b'] = 1
    elif 800 <= a <= 1199:
        B['c'] = 1
    elif 1200 <= a <= 1599:
        B['d'] = 1
    elif 1600 <= a <= 1999:
        B['e'] = 1
    elif 2000 <= a <= 2399:
        B['f'] = 1
    elif 2400 <= a <= 2799:
        B['g'] = 1
    elif 2800 <= a <= 3199:
        B['h'] = 1
    else:
        B['z'] += 1

if 'z' in B:
    print(max(len(B.keys())-1, 1), len(B.keys())-1 + B['z'])
else:
    print(len(B.keys()), len(B.keys()))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(){
  int n,m;
  string s,sf,ss,sfr,ssr;
  cin>>s;
  sf=s.substr(0,(s.size()-1)/2);
  ss=s.substr((s.size()+1)/2,(s.size()-1)/2);
  sfr=sf;
  ssr=ss;
  reverse(all(sfr));
  reverse(all(ssr));
  if(sf==ss && sfr==ssr){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }  
  return 0;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x) - 1 * 100);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>

using namespace std;

int n;
int main(void) {
	cin >> n;
	int tm;
	map<ll, ll> mp;
	rep(i, n) {
		cin >> tm;
		mp[tm]++;
	}
	vector<ll> vc;
	int cnt = 0;
	for(auto kv:mp){
		if (mp[kv.first] > 1) {
			vc.push_back(kv.first);
			cnt++;
		}
	}
	if (cnt < 2) {
		cout << 0 << endl;
	}
	else {
		sort(all(vc));
		if (mp[vc[vc.size() - 1]] >= 4) {
			cout << vc[vc.size() - 1] * vc[vc.size() - 1] << endl;
		}
		else {
			cout << vc[vc.size() - 1] * vc[vc.size() - 2] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 6528
main = 
  let 
    func = do
      line <- getLine
      let 
        [h,w] = map read $ words line :: [Int]
        drawUBLine x 
          | x == w  = do
            putStrLn "#"
          | otherwise = do
            putStr "#"
            drawUBLine (x+1)
        drawLine x 
          | x == 1    = do
            putStr "#"
            drawLine (x+1)
          | x == w    = do
            putStrLn "#"
          | otherwise = do
            putStr "."
            drawLine (x+1)
        drawFrame y
          | y == h    = do
            drawUBLine 1
            putStrLn ""
          | y == 1    = do
            drawUBLine 1
            drawFrame (y+1)
          | otherwise = do
            drawLine 1
            drawFrame (y+1)
        in 
          if h == 0 && w == 0
            then putStr ""
            else do
              drawFrame 1 
              func
    in func



Measured memory_bytes: 4048
import math
from functools import reduce


K = int(input())
res = [[[0] * (K+1) for i in range(K+1)] for j in range(K+1)]


def gcd(numbers):
    global res

    numbers.sort()
    if res[numbers[0]][numbers[1]][numbers[2]] > 0:
        return res[numbers[0]][numbers[1]][numbers[2]]
    else:
        val = reduce(math.gcd, (numbers[0], numbers[1],numbers[2]))
        res[numbers[0]][numbers[1]][numbers[2]] = val
        return val


ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            ans += gcd([a, b, c])

print(ans)


Measured memory_bytes: 137116
#include <stdio.h>

int main(){
    int i,j;
    int H,W;
    
    while(1){
        scanf("%d %d", &H, &W);
        if(H==0 && W==0) break;
        
        for(i=1; i<=H; i++){
            for(j=1; j<=W; j++){
                if(i==1 || i==H){
                    printf("#");
                }
                else{
                    if(j==1 || j==W)
                        printf("#");
                    else 
                        printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
        
    }
    
}



Measured memory_bytes: 1988
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();

		String[] strs = str.split("");
		String out = "No";
		if ((strs[0].equals(strs[1]) && strs[1].equals(strs[2]))
				|| (strs[1].equals(strs[2]) && strs[2].equals(strs[3]))) {
			out = "Yes";
		}
		System.out.println(out);
	}

}


Measured memory_bytes: 23764
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parent=list(range(n+1))
        self.size=[1]*(n+1)
    def find(self,x):
    #根を探す。
    #別なグループ間をつなげた場合は、つなげた先の根に書き換える。
        if self.parent[x]==x:
            return x
        else:
            self.parent[x]=self.find(self.parent[x])
            return self.parent[x]
    def unite(self,x,y):
    #二つのグループをつなげる
    #大きいほうに小さいほうをつなげる。
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return
        else:
            if self.size[x]>=self.size[y]:
                self.parent[y]=x
                self.size[x]+=self.size[y]
            else:
                self.parent[x]=y
                self.size[y]+=self.size[x]
    def cnt(self,x):
    #サイズの取得
        return self.size[self.find(x)]

def main():
    n,m=map(int,input().split())
    u=UnionFind(n)
    for i in range(m):
        x,y,z=map(int,input().split())
        u.unite(x,y)
    ans=[0]*(n+1)
    for i in range(1,n+1):
        x=u.find(i)
        ans[x]=1
    print(sum(ans[1:]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9332
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		String W	 = in.readLine();
//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		int ans = 0;
		
		for(int i = 1;i<=3 ; i++) {
			if(i !=A && i!= B) {
				ans = i;
			}
		}
		



		System.out.println(ans);

	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}



}


Measured memory_bytes: 35624
import sys
N = int(input())
s = ''
s2 = ''
if N == 0:
  print(0)
  sys.exit(0)
while N != 0:
  if N % 2 == 0:
    s += '0'
    N //= (-2)
  if N % 2 == -1 or N % 2 == 1:
    s += '1'
    N //= (-2)
    N += 1
s2 = s[::-1]
print(s2)


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

using namespace std;

int main()
{
    int a;

    for (int i=0; ; i++)
    {
        cin >> a;

        if (a == 0)
            break; 
    
        cout << "Case "  << i+1 << ": " << a << endl;    
    }

    return 0;
}



Measured memory_bytes: 3048
#include <stdio.h>
#include <math.h>

int main(void)
{
  int i,j,k,l,num,count=0,number[10000],flag=0;

  scanf("%d",&num);

  for(l=0;l<num;l++) {
    scanf("%d",&number[l]);
  }
        for(i=0;i<num;i++)
        {
 flag=0;
          if(number[i]==2) flag=0;
 else if(number[i]%2==0) flag=1;
 else{
          for(j=3;j<=sqrt(number[i]);j+=2)
            {
              if(number[i]%j==0)
                        {
                          flag=1;
                          break;
                        }
            }
 }
   if(flag==0)count++;
        }
     



  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 632
from collections import deque
K=int(input())


INF=10**9
res=[INF]*(K)
res[1]=1
q=deque()
q.append(1)
while q:
    r=q.popleft()
    if r==0:
        break
    nr=(r+1)%K
    if res[r]<res[nr]:
        res[nr]=res[r]+1
        q.append(nr)
    nr=(10*r)%K
    if res[r]<res[nr]:
        res[nr]=res[r]
        q.appendleft(nr)
print(res[0])

Measured memory_bytes: 11776
import sys
input = sys.stdin.readline
s = input().strip()
ans = 0
n = len(s)-1

for i in range(2 ** n):
  t = ''
  for j in range(n):
    t += s[j]
    if (i >> j) & 1:
      t += '+'
  else:
    t += s[n]
  ans += eval(t)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FIN ios::sync_with_stdio(0); cin.tie(0)
typedef long long ll;




int main(){
   FIN;

   ll k, s=0;
   cin >> k;
   for( ll i=1 ; i<=k ; ++i ){
      for( ll j=1 ; j<=k ; ++j){
         for( ll l=1 ; l<=k ; ++l){
            s+=__gcd(i,__gcd(j,l));
         }
      }
   }
   cout << s;
   
   return 0;
}

Measured memory_bytes: 3576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int n = in.nextInt();
        int[] a = new int[n];

        a[0] = in.nextInt();
        int first = a[0];
        int second = Integer.MIN_VALUE;

        for (int i = 1; i < n; i++) {
            a[i] = in.nextInt();
            if (a[i] > first) {
                second = first;
                first = a[i];
            } else if (a[i] > second) {
                second = a[i];
            }
        }

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(a[i] == first ? second : first);
            sb.append('\n');
        }
        out.print(sb.toString());
        out.flush();
    }
}


Measured memory_bytes: 46804
package main

import (
	"fmt"
)

func main() {
	var l [4]int
	for i := 0; i < 4; i++ {
		fmt.Scan(&l[i])
	}
	if l[0]*l[1] > l[2]*l[3] {
		fmt.Println(l[0] * l[1])
	} else {
		fmt.Println(l[2] * l[3])
	}
}


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

#define sz(x) (int)(x.size())
#define FOR(i,L,R) for(int i = L; i <= R; i++)
#define int long long

const int N = 1000 + 2, inf = 1e18;

int n, m;
bool mat[N][N];
std::vector<pair<int,int>> g[N * N];

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
 
bool inside(int i, int j){ 
    return i >= 1 && i <= n && j >= 1 && j <= m;
}

int node(int i, int j) {
    return (i - 1) * m + j;
}

void dijkstra(int s, vector<int> & d) {

    d[s] = 0;
    using pii = pair<int, int>;
    priority_queue<pii, vector<pii>, greater<pii>> q;
    q.push({0, s});
    while (!q.empty()) {
        int v = q.top().second;
        int d_v = q.top().first;
        q.pop();
        if (d_v != d[v])
            continue;

        for (auto edge : g[v]) {
            int to = edge.first;
            int len = edge.second;

            if (d[v] + len < d[to]) {
                d[to] = d[v] + len;
                q.push({d[to], to});
            }
        }
    }
}


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

    cin >> n >> m;
    int fx, fy, tx, ty;
    cin >> fx >> fy >> tx >> ty;
    FOR(i,1,n) FOR(j,1,m) {
        char ch;    cin >> ch;
        mat[i][j] = (ch == '.');
    }    

    FOR(i,1,n) FOR(j,1,m) if(mat[i][j]) {
        int u = node(i, j);
        FOR(k,0,3) {
            int ni = i + dx[k];
            int nj = j + dy[k];
            if(!inside(ni, nj)) continue;
            if(!mat[ni][nj]) continue;
            int v = node(ni, nj);
            g[u].push_back({v, 0});
        }
        FOR(ni,i-2,i+2) FOR(nj,j-2,j+2) if(inside(ni, nj) && mat[ni][nj]) {
            if(i == ni && j == nj) continue;
            int v = node(ni, nj);
            g[u].push_back({v, 1});
        }
    }

    int tot = n * m;
    std::vector<int> dist(tot + 5, inf);
    dijkstra(node(fx, fy), dist);

    int ans = dist[node(tx, ty)];
    if(ans >= inf)
        ans = -1;
    cout << ans;
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n; cin >> n;
    bool ok = true;
    rep(i, n) {
        ll a; cin >> a;
        if((a%2) != 0) ok = false;
    }
    if(ok) cout << "second" << endl;
    else cout << "first" << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e5+5;
int a[N],st[N],up[N],dw[N],dr[N],top,n,res,k,fl;
int main(){
	scanf("%d%d",&n,&k);
	fp(i,1,n)scanf("%d",&a[i]);
	st[top=0]=0;
	fp(i,1,n){
		while(top&&a[i]>a[st[top]])--top;
		up[i]=(st[top]<=i-k),st[++top]=i;
	}
	st[top=0]=n+1;
	fd(i,n,1){
		while(top&&a[i]<a[st[top]])--top;
		dw[i]=(st[top]>=i+k),st[++top]=i;
	}
	for(R int l=1,r=2;r<=n;l=r++){
		while(r<=n&&a[r]>a[r-1])++r;
		fp(i,l+k-1,r-1)dr[i]=1;
	}
	fp(i,k,n)if(dr[i])fl=1;
		else if(!(up[i]&&dw[i-k]))++res;
	printf("%d\n",res+fl);
	return 0;
}

Measured memory_bytes: 3328
#include <cstdio>

int main()
{
  int n;
  scanf("%d", &n);
  int a[100];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", a + i);
  }
  int ans = 0;
  for (int i = 0; i < n;)
  {
    int* last = a + i;
    while (*last == a[i]) ++i;
    ans += ((a + i) - last) / 2;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
using namespace std;

int main(){
    int x,y;
    



    for(int i =0;i<3000;++i){
        scanf("%d %d",&x,&y);
        if((x == 0) && (y == 0) )break;
      
      if (x<y) {
          printf("%d %d\n",x,y);
      }
      else
      {
          printf("%d %d\n",y,x);
      }
      
      

        
    }
    
    return 0;
}


Measured memory_bytes: 2596
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scanf("%d %d", &N, &K)

	A := make([]int, N)
	for i := range A {
		fmt.Scanf("%d", &A[i])
		A[i]--
	}

	last := 0
	count := 0
	m := make(map[int]int) // m[city] = count
	history := make([]int, 0)
	m[0] = 0
	history = append(history, 0)

	for count < K {
		next := A[last]
		if past, ok := m[next]; ok {
			cycle := count - past + 1
			offset := (K - past) % cycle
			fmt.Println(history[past+offset] + 1)
			return
		}

		// update
		count++
		m[next] = count
		history = append(history, next)
		last = next
	}

	fmt.Println(last + 1)
}


Measured memory_bytes: 19136
from collections import Counter

n=int(input())
alst=list(map(int,input().split()))

cnt=Counter(alst)
c2=0

for v in cnt.values():
    if v==1:
        continue

    n-=v-1
    if v%2==0:
        c2+=1

print(n if c2%2==0 else n-1)


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

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

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N, a, AMAX = 2e6;
  vector<ll> count(AMAX, 0);
  cin >> N;
  rep(i, N){
    cin >> a;
    count[a]++;
  }
  
  ll ans = N;
  repi(i, 1, AMAX+1){
    if(count[i] == 0) continue;
    if(count[i] >= 2) ans -= count[i];
    count[i] = 0;

    for(ll n=2*i; n<=AMAX; n+=i){
      if(count[n] > 0){
        ans -= count[n];
        count[n] = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 18644
#include <iostream>

using namespace std;

int main() {
    int N, R = 0;
    cin >> N;
    int V[50], C[50];

    for (int i = 0; i < N; i++) cin >> V[i];
    for (int i = 0; i < N; i++) cin >> C[i];

    int tx;
    for (int i = 0; i < N; i++) {
        tx = V[i] - C[i];
        if (tx > 0) {
            R += tx;
        }
    }

    cout << R << endl;
    return 0;
}


Measured memory_bytes: 256
n,a,b = map(int,input().split())
dif1 = abs(a-b)

if(dif1%2==0):
    print(dif1//2)
else:
    dif2 = (a-1) + (b-1) + 1
    dif3 = (n-a) + (n-b) + 1
    print(min(dif2//2,dif3//2))

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

int findSumOfDigits(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n;
  cin >> n;
  int ans = 1000000;
  for(int i = 1; i < n; ++i){
    int total = findSumOfDigits(i) + findSumOfDigits(n - i);
    ans = min(ans, total);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

// #の→に.が来てはいけない
// したがって左半分が'.', 右半分が'#'の並びになればよい

int main(){
    int N,blackcount = 0, whitecount = 0,flag = 0;
    string S;
    cin >> N >> S;
    

    /*
    for(int i = 0; i < N; i++){
        if(flag == 0 && S[i] == '#'){
            flag = 1;
        }
        if(flag == 1 && S[i] == '.'){
            whitecount++;
    }
    }
    flag = 0;

    for(int i = N-1; i >= 0; i--){
        if(flag == 0 && S[i] == '.'){
            flag = 1;
        }
        if(flag == 1 && S[i] == '#'){
            blackcount++;
    }
    }
  
    cout << min(whitecount, blackcount) << endl;
*/

    //上だと.#..##.#が３になってしまう

    //解く方針としては....####の境界となる場所を探索する
    int black[N+1], white[N+1];
 
    black[0]=0;
    white[0]=0;
 
    for(int i=0;i<N;i++){
        if( S[i] == '.' ){   
            white[0]++;
        }
    }
    
    int ans = black[0]+ white[0];
 
    //境界の探索
    //境界より前にある#の個数と.の個数の和の最小値を求めている
    //黒の個数を累積和で持っている
    for(int i=0;i<N;i++){
        if(  S[i] == '#'){
            black[i+1]=black[i]+1;
            white[i+1]=white[i];
        }else{
            black[i+1]=black[i];
            white[i+1]=white[i]-1;
        }
       ans = min(ans,black[i+1]+white[i+1]);
    }
 
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
using ll = long long;

ll n,m,k,a,b,c,d;
string s,t;

int main() {
  cin >> a >> b >> c >> d;
  int cnt=0;
  while(a>0&&c>0){
    cnt%2==0 ? c-=b : a-=d; 
    cnt++;
  }
  cout << (cnt%2==0 ? "No" : "Yes") << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	int n, k;
	cin >> n >> k;
	vector<ll>x(n);
	rep(i, n)cin >> x[i];
	ll ans = 1001001001;
	for(int i=0;i+k-1<n;i++){
	   ll now = min(abs(x[i]) + abs(x[i] - x[i + k - 1]), abs(x[i + k - 1]) + abs(x[i] - x[i + k - 1]));
	   ans = min(ans, now);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n;
long long x[105], y[105], id[205];
long double ans;
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%lld%lld", x+i, y+i);
		id[i] = i;
	}
	sort(id, id+n, [](int a, int b){return atan2(x[a],y[a]) > atan2(x[b], y[b]);});
	rep(i,n) id[i+n] = id[i];
	rep(i,n){
		long double ax = 0, ay = 0;
		for(int j = i; j < i+n && x[id[i]] * y[id[j]] - y[id[i]] * x[id[j]] >= 0; j++){
			ax += x[id[j]]; ay += y[id[j]];
			ans = max(ans,hypot(ax,ay));
		}
	}
	printf("%.20Lf\n", ans);
}

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


int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int t, x;
	cin >> t >> x;

	printf("%.10Lf\n", ((long double)t/x));
	return 0;
}

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

int a[1001],b[1001],c[1001];

int main(){

    int n,m;

    cin >> n >> m;

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

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

    for(int i=0; i<n; i++){
      c[i] = 0;
    }

    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
        if(b[i] >= a[j]){
          c[j]++;
          break;
        }
      }
    }

    int ans = 0,ansnum=0;
    for(int i=0;i<n;i++){
      if(ansnum < c[i]){
        ansnum = c[i];
        ans = i+1;
      }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
	int a, b;
	cin>>a>>b;
	
	int x, y, z, m;
	x= a + b;
	y= a - b;
	z= a * b;
	
	m= max(x,y);
	m= max(z,m);
	
	cout<<m<<endl;
	
}


Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Char
main=do
    [a,b]<-map read.words<$>getLine
    s<-getLine
    putStrLn $ chk 0 a b s
chk i a b []
    | i == (a+b+1) = "Yes"
    | True = "No"
chk i a b (s:ss)
    | i<a && isDigit s = chk (i+1) a b ss
    | i==a && s=='-' = chk (i+1) a b ss
    | i>a && isDigit s = chk (i+1) a b ss
    | True = "No"

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
#define INF 1<<21
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
long long factorial(long long N){
	if(N==0) return 1;
	else return N*factorial(N-1)%(long long)((1e+9)+7);
} 
int main(void) {
   long long N,M;
   std::cin >> N >> M;
   if(N==M){
	   long long temp=factorial(N)*factorial(N)%(long long)((1e+9)+7);
	   std::cout << 2*temp%((long long)((1e+9)+7)) <<std::endl;
   }else if(std::abs(N-M)==1){
	   std::cout << (factorial(N)*factorial(M))%((long long)((1e+9)+7)) <<std::endl;
   }else{
	   std::cout << 0 <<std::endl;
   }
   return 0;
}

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

def Base_10_to_n(X, n=3):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

s = 0
m = 0

f = len(str(n))

for i in range(1, f):
    if i < 3:
        pass
    else:
        s += 3 ** i - 3 * (2 ** i) + 3 

while True:
    l = Base_10_to_n(m)
    flag = [False] * 3
    if len(l) < f:
        l = "0" * (f-len(l)) + l
    k = ""
    for i in range(len(l)):
        if l[i] == "0":
            k += "3"
            flag[0] = True
        elif l[i] == "1":
            k += "5"
            flag[1] = True
        else:
            k += "7"
            flag[2] = True
    #print(k)

    if int(k) <= n:
        if False not in flag:
            s += 1
        m += 1
    else:
        break

print(s)

Measured memory_bytes: 9232
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        String slimes = scanner.nextLine();
        String colors = scanner.nextLine();
        int slime = Integer.valueOf(slimes);
        char[] col = colors.toCharArray();
        int slimecount = 1;
        for(int i = 0; i < slime-1; i++) {
            if (col[i] != col[i+1]) {
                slimecount += 1;
            }
        }
        System.out.println(slimecount);
    }
}


Measured memory_bytes: 26304
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int x,y;
	cin>>x>>y;
	int ans=0;
	if(x==1){
		ans+=300000;
	}
	else if(x==2){
		ans+=200000;
	}
	else if(x==3){
		ans+=100000;
	}
	if(y==1){
		ans+=300000;
	}
	else if(y==2){
		ans+=200000;
	}
	else if(y==3){
		ans+=100000;
	}
	if(ans==600000){
		ans=1000000;
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : aoj2100.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int t, n, h[100];
	cin >> t;
	for(int i = 0;i < t;i++){
		cin >> n;
		int ans1 = 0, ans2 = 0;
		for(int j = 0;j < n;j++){
			cin >> h[j];
			if(j > 0){
				if(h[j - 1] > h[j]){
					ans2 = max(ans2,h[j - 1] - h[j]);
				}else{
					ans1 = max(ans1,h[j] - h[j - 1]);
				}
			}
		}
		cout << ans1 << " " << ans2 << endl;

	}
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  int size = s.size();
  int an = 0;
  int zn = 0;
  
  for(int i = 0;i < size;i ++){
    if(s[i] == 'A'){an = i;break;}
  }
  
  reverse(s.begin(),s.end());
  
  for(int i = 0;i < size;i ++){
    if(s[i] == 'Z'){zn = size - 1 - i;break;}
  }
  
  cout << zn - an + 1 << endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(15);
  int n,a,b;
  cin >> n >> a >> b;
  if(a>b) {cout<<0<<endl;return 0;}
  if(n==1&&a!=b) {cout<<0<<endl;return 0;}
  if(a==b) {cout<<1<<endl;return 0;}
  
  cout << (n-2)*(b-a)+1 << endl;
  return 0;
}


Measured memory_bytes: 256