akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int n;
	cin >> n;
	int l=10000,r=-1,temp;
	for(int i=0; i<n; i++){
		cin >> temp;
		if(temp<l)l=temp;
		if(r<temp)r=temp;
	}
	cout << r-l << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools

A = [0, 0, 0, 0]
N,A[0],A[1],A[2] = map(int,input().split())
bamboo_list = [int(input()) for n in range(N)]
ans = 10**15

for seq in itertools.product(range(4),repeat=N): ## seq:手元の竹を、どのように使うかのList
  X = [0, 0, 0] ## それぞれのターゲットの竹に使った竹の合計長さ
  Y = [0, 0, 0] ## それぞれのターゲットの竹に利用した竹の本数
  
  for n in range(N):
    if seq[n] != 3:
      X[seq[n]] += bamboo_list[n]
      Y[seq[n]] += 1
  
  ## 竹を一本も使わない、みたいな組み合わせがあった場合はスルーする
  if Y[0]*Y[1]*Y[2] == 0:
    continue
  
  ## このループでの消費MPを計算する
  MP = (sum(Y)-3)*10
  for i in range(3):
    MP += abs(X[i]-A[i])
  
  
  ## 消費MPが最小だった場合、それを答えとして格納する
  if MP < ans:
    ans = MP

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
vector<string>ans;
vector<char>abc;
void dfs(string s,int n){
  if(n == s.size()){
    ans.push_back(s);
    return;
  }
  set<char>cnt;
  rep(i,s.size())cnt.insert(s[i]);
  rep(i,cnt.size() + 1){
    dfs(s + abc[i],n);
  }
}
int main(){
  int n;
  cin >> n;
  rep(i,26)abc.push_back('a' + i);
  dfs("a",n);
  sort(all(ans));
  rep(i,ans.size())cout << ans[i] << endl;
  return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int n;
bool ans = false;

void solve(int s) {
    if (ans) return;
    if (s >= n) {
        if (s == n) ans = true;
        return;
    }
    solve(s+4);
    solve(s+7);
}

int main() {
    cin >> n;
    solve(0);
    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[9] = { 0, 0,0,1,1,1,-1,-1,-1 };
int dyy[9] = { 0, 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

long long power_mod(long long x, long long n, long long m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return power_mod(x * x % m, n / 2, m);
	else
		return x * power_mod(x, n - 1, m) % m;
}

long long power(long long a, long long n) {//aのn乗を計算します。
	long long x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}



long long nCr(long long n, long long r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	long long i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}



const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 10000010;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (ll i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.pb(i);
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}

ll stoL(string s) {
	ll n = s.length();
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += power(10, n - i - 1)*(ll)(s[i] - '0');
	}
	return ans;
}


ll dp[100010];
int h[100100];
signed main() {
	int N; cin >> N;
	int K; cin >> K;
	REP(i, N)cin >> h[i];
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	FOR(i, 2, N) {
		dp[i] = INF;
		FOR(d, i-K,i) {
			if (d < 0)continue;
			dp[i] = min(dp[i], dp[d] + abs(h[i] - h[d]));
		}
	}
	print(dp[N - 1]);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	map<int, int> M;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		int val;
		scanf("%d", &val);
		M[val]++;
	}
	int ans = 0;
	for(auto v : M)
	{
		int val = v.first, cnt = v.second;
		if(cnt >= val) ans += cnt - val;
		else ans += cnt;
	}
	printf("%d\n", ans);
	return 0;
}
		 

Measured memory_bytes: 4736
s=input()
n=len(s)
if all(s[i]==s[n-i-1] for i in range(n)):
    if all(s[i]==s[(n-1)//2-i-1] for i in range((n-1)//2)):
        if all(s[(n+3)//2-1+i]==s[n-i-1] for i in range((n-1)//2)):
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3060
s = input().split('T')
x, y = map(int, input().split())

# x軸方向の移動について
# 1回目の移動はxの正方向のみ
here_x = [len(s[0])]

for i in s[2::2]:
    move = len(i)
    here_x = [i + move for i in here_x] + [i - move for i in here_x]
    here_x = list(set(here_x))

# x軸方向の移動について
# 1回目の移動はxの正方向のみ
here_y = [0]

for i in s[1::2]:
    move = len(i)
    here_y = [i + move for i in here_y] + [i - move for i in here_y]
    here_y = list(set(here_y))

if x in here_x and y in here_y:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3820
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n;
multiset<ll> s;
int main() {
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		auto it = s.lower_bound(a);
		if (it != s.begin()) {
			it--;
			s.erase(it);
		}
		s.insert(a);
	}
	cout << s.size() << endl;
}





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

int main(){
    int W, H, N;
    cin >> W >> H >> N;
    vector<int> x(N, 0);
    vector<int> y(N, 0);
    vector<int> a(N, 0);
    for (int i = 0; i < N; i ++){
        cin >> x.at(i) >> y.at(i) >> a.at(i);
    }
    int x_sa = 0, x_u = W, y_zyo = H, y_ka = 0;
    for (int i = 0; i < N; i ++){
        if (a.at(i) == 1){
            if (x_sa < x.at(i)){
                x_sa = x.at(i);
            }
        }
        if (a.at(i) == 2){
            if (x_u > x.at(i)){
                x_u = x.at(i);
            }
        }
        if (a.at(i) == 3){
            if (y_ka < y.at(i)){
                y_ka = y.at(i);
            }
        }
        if (a.at(i) == 4){
            if (y_zyo > y.at(i)){
                y_zyo = y.at(i);
            }
        }
    }
    if ((x_sa > x_u) || (y_ka > y_zyo)){
        cout << 0 << endl;
    }
    else{
        cout << (x_u - x_sa) * (y_zyo - y_ka) << endl;
    }
    
}
            


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define MAX 200000
#define MAX_P 1000000000
int main(){
  int n,price,min,max_prof=-MAX_P;
  int i,j;

  //要素数の指定
  while(1){
    scanf("%d",&n);
    if((1<n)&&(n<=MAX)) break;
  }
  //要素の入力
  scanf("%d",&min);
  for(i=1; i<n; i++){
    //printf("2\n");
    scanf("%d",&price);
    if((price-min)>max_prof){
      max_prof = price-min;
      //printf("%d\n",max_prof);
    }
    if(min>price){
      min=price;
    }
  }
  //後に入力されたほうから先に入力されたほうの差を求める
  //最大値を更新する

  printf("%d\n",max_prof);
  return 0;
}



Measured memory_bytes: 2140
s = input()
s1 = s[0:(len(s) - 1)//2]
s2 = s[(len(s) + 3 - 1)//2:len(s)]
if s1 == s1[::-1] and s2 == s2[::-1] and s1 == s2:
        print('Yes')
else:
        print('No')

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

int n, ans;

int main() {
  cin >> n;
  vector<int> a(n);
  rep (i, n) {
    cin >> a[i];
  }
  ans = 0;
  rep (i, n) {
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#define llint long long
#define inf 1e18

using namespace std;

string s;
llint dp[1000005][2];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	llint n = s.size();
	reverse(s.begin(), s.end());
	s += "0000";
	
	for(int i = 0; i <= n+2; i++){
		for(int j = 0; j < 2; j++){
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	
	for(int i = 0; i < n+2; i++){
		llint x = s[i]-'0';
		for(int j = 0; j < 2; j++){
			for(int k = 0; k < 10; k++){
				llint d = (j+k+x) % 10, c = (j+k+x)/10;
				dp[i+1][c] = min(dp[i+1][c], dp[i][j] + d+k);
			}
		}
	}
	cout << dp[n+2][0] << endl;
	
	/*for(int i = 0; i <= n+2; i++){
		for(int j = 0; j < 2; j++){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	
	return 0;
}

Measured memory_bytes: 17052
def LI(): return list(map(int,input().split()))
N,D = LI()
X = [LI() for _ in range(N)]
_ans = 0
for i in range(N):
    for j in range(i+1,N):
        temp = 0
        for k in range(D):
            temp += (X[j][k]-X[i][k])**2
        if temp**0.5%1==0:
            _ans += 1
print(_ans)

Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



char p, q;

int main() {
    char res = 'A';
    while ( scanf("%c,%c", &p, &q) != EOF ) {
        char next = res;
        if (res == p) next = q;
        else if (res == q) next = p;
        res = next;
    }
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int leftt[100000+5],rightt[100000+5];
int main ()
{
    int n,k;
    cin >> n >> k;
    int arr[n];
    for(int i =0 ; i<n ; i++)cin>>arr[i];
    //sort(arr,arr+n);
    int r=0, l =0;
    for(int i=0 ; i<n ; i++)
    {
        if (arr[i]>=0)
        {
            int z=1;
            for(int j=i ; j<n ; j++ )
            {
                rightt[z]=arr[j];
                r++;
                z++;
            }
            z=1;
            for(int j=i-1 ; j>=0 ; j--)
            {
                leftt[z]=abs(arr[j]);
                l++;
                z++;
            }
            break;
        }
    }
    if (l==0 && r==0)
    {
int         z=1;
            for(int j=n-1 ; j>=0 ; j--)
            {
                leftt[z]=abs(arr[j]);
                l++;
                z++;
            }
    }
    long long ans=1e18;

    int p1=min(k,r);
    int p2=k-min(k,r);
    while(p1>=0 && p2<=l)
    {
        ans=min(ans,(long long )(rightt[p1]+leftt[p2]*2));
        ans=min(ans,(long long )(rightt[p1]*2+leftt[p2]));
        p1--;
        p2++;
    }

    cout<<ans;

    return 0;
}


Measured memory_bytes: 1024
# -*- coding:utf-8 -*-
'''
def search(t, x, i):
    global X
    if x == X:
        return t
    elif x > X:
        ans1 = search(i, x, i+1)
        ans2 = search(i, x-i, i+1)
        return min(ans1, ans2)
    else:
        ans3 = search(i, x+i, i+1)
        return ans3
'''
X = int(input())
p, i = (0,0)
while True:
    p += i
    i += 1
    if p >= X:
        break
print(i-1)
'''
ans = search(0, 0, 1)
print(ans)
'''

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector <int> a(n);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i%2==1 and a[i]%2==1)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
import java.io.*;
 
class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] points = br.readLine().split(" ");
        double x1 = Double.parseDouble(points[0]);
        double y1 = Double.parseDouble(points[1]);
        double x2 = Double.parseDouble(points[2]);
        double y2 = Double.parseDouble(points[3]);
        double distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
        System.out.println(distance);
    }
}

Measured memory_bytes: 24472
n,m = map(int,input().split())
light = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))

ans = 0
for i in range(1<<n):
  flag = True
  for j in range(m):
    l = light[j][1:]
    count = 0
    for s in l:
      if i & (1<<(s-1)):
        count += 1
    if count%2 != p[j]:
      flag = False
  if flag==True:
    ans += 1
print(ans)

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

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

const long long INF = 1LL << 60;

long long dp[100010];

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

  // init
  for(int i = 0; i < 100010; ++i)dp[i] = INF;

  // initial condition
  dp[0] = 0;

  // main loop
  for(int i = 1; i < n; ++i){
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if(i > 1)chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }

  cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int number1 = scanner.nextInt();
			int number2 = scanner.nextInt();
			if (0 == number2 % number1) {
				System.out.println(number1 + number2);
			} else {
				System.out.println(number2 - number1);
			}
		}
	}
}


Measured memory_bytes: 21844
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

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

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int main()
{
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int count = 0;
  while (a >= b) {
    b *= 2;
    count++;
  }
  while (b >= c) {
    c *= 2;
    count++;
  }
  if (count <= k) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
import java.util.*;
import java.lang.*;

/**
 * OfficialHouse
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][][] list = new int[4][3][10];

        for (int i = 0; i < n; i++) {
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();

            list[b - 1][f - 1][r - 1] += v;
        }

        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    System.out.print(" " + list[i][j][k]);
                }
                System.out.println();
            }
            if (i != 3)
                System.out.println("####################");
        }
    }
}


Measured memory_bytes: 29456
n = int(input())
A = list(map(int, input().split()))
A = sorted(A)
from bisect import bisect_left
ans = 0
for i in range(0, A[-1]+1):
  cnt = bisect_left(A, i+2) - bisect_left(A, i-1)
  ans = max(ans, cnt)
  #print(i, cnt)
print(ans)

Measured memory_bytes: 13964
#include <stdio.h>
#include <iostream>
#include <string>
//#include <cmath>
#include <vector>
// #include <algorithm>
// #include <bits/stdc++.h>
using namespace std;

struct item{
  int a;
  int b;
  string op;
};

int main() {
  vector<item > v;

  item itm;
  do{
    cin >> itm.a >> itm.op >> itm.b;
    v.push_back(itm);
  }while(itm.op != "?");

  for (int i=0; i < v.size()-1; i++) {
    if (v[i].op == "+") {
      cout << v[i].a + v[i].b << endl;
    } else if (v[i].op == "-") {
      cout << v[i].a - v[i].b << endl;
    } else if (v[i].op == "*") {
      cout << v[i].a * v[i].b << endl;
    } else if (v[i].op == "/") {
      cout << v[i].a / v[i].b << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {

    ll H, W;
    cin >> H >> W;

    vector<string> S(H);

    ll count = 0;

    rep(i, H) {
        cin >> S[i];
        rep(j, W) {
            if (S[i][j] == '#') {
                count++;
            }
        }
    }

    if (count == W + H - 1) {
        cout << "Possible";
    }
    else {
        cout << "Impossible";
    }

    return 0;
}


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

using namespace std;

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

#define INF 2ll<<60ll
#define F first
#define S second

int main(){
  ll l,r;
  ll ans=INF;
  scanf("%lld %lld",&l,&r);
  
  if(r-l>=2019){
    printf("0\n");
  }else{
    for(ll i=l;i<r;i++){
      for(ll j=i+1;j<=r;j++){
	if(ans>(i*j)%2019) ans=(i*j)%2019;
      }
    }
    printf("%lld\n",ans);
  }
  
  return (0);
}


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

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0) break;
        
        vector<int> a(n);
        for(int i=0; i<n; i++) cin >> a[i];
        int ans = -1;
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                if(a[i]+a[j] <= m) ans = max(ans, a[i]+a[j]);
            }
        }
        if(ans == -1){
            cout << "NONE" << endl;
        }else{
            cout << ans << endl;
        }   
    }
    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll p[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
        p[i]--;
    }
    ll a[n],b[n];
    for(int i=0;i<n;i++){
        a[i]=n*i+1;
    }
    for(int i=0;i<n;i++){
        b[n-i-1]=n*i+1;
    }
    for(int i=0;i<n;i++){
        a[p[i]]+=i;
    }
    for(int i=0;i<n;i++){
        cout<<a[i]<<" ";
    }
    cout << endl;
    for(int i=0;i<n;i++){
        cout<<b[i]<<" ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>

using namespace std;

typedef long long ll;

int main(){
  ll h, w, n; cin >> h >> w >> n;
  vector<pair<int, int> > SQ;
  for(int i=1;i<=n;i++){
    int a, b; cin >> a >> b;
    for(int ii=0;ii<=2;ii++){
      for(int jj=0;jj<=2;jj++){
        if((a-ii>=1 && b-jj>=1) && (a-ii+2<=h && b-jj+2<=w)){
          SQ.push_back(make_pair(a-ii, b-jj));
        }
      }
    }
  }
  sort(SQ.begin(), SQ.end());
  ll ans[10];
  for(int i=1;i<=9;i++) ans[i]=0;
  ll t=1, sum=0;
  for(int i=1;i<SQ.size();i++){
    if(SQ[i]==SQ[i-1]){
      t++;
    }else{
      ans[t]++;
      sum++;
      t=1;
    }
  }
  if(n >= 1){
    ans[t]++;
    sum++;
  }
  ans[0]=(h-2)*(w-2)-sum;
  for(int i=0;i<=9;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 10092
#include <stdio.h>
int main()
{
    int N, a[101]={0}, i, j, k, key;
    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%d", &a[i]);
    }
    for(i=1; i<N+1; i++){
        for(k=0; k<N; k++){
            printf("%d", a[k]);
            if(k!=N-1) printf(" ");
        }
        printf("\n");
        key=a[i];
        for(j=i-1; j>=0; j--){
            if(a[j]>key){
                a[j+1]=a[j];
            } else {
                a[j+1]=key;
                break;
            }
            if(j==0){
                a[0]=key;
            }
        }
    }
    return 0;
}

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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int s, w;
    cin >> s >> w;    

    w>=s?cout<<"unsafe\n":cout<<"safe\n";

    return 0;
}


Measured memory_bytes: 3652
from collections import deque

n = int(input())
d = deque()
for _i in range(n):
    order = input()
    if order == 'deleteFirst':
        d.popleft()
    elif order == 'deleteLast':
        d.pop()
    else:
        order, key = order.split()
        if order == 'insert':
            d.appendleft(key)
        elif order == 'delete':
            try:
                d.remove(key)
            except ValueError:
                pass
        else:
            raise ValueError('Invalid order: {order}')

print(' '.join(d))



Measured memory_bytes: 69736
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       int n=sc.nextInt();
       int m=sc.nextInt();
       int l=sc.nextInt();
       if(n<=l&&n+m>=l)System.out.println("YES");
       else System.out.println("NO");
    }
    }

Measured memory_bytes: 23124
//
// Created by yuu on 2019-04-27.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;


int main(void){
    int N;
    int C[100],V[100];

    cin>>N;

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

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

    int ans = 0;

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

    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int a, i;
    cin >> a;
    int res = 0;
    for (i=1;i<8;i++){
        if (i % 2 == 1){
            int s = pow(10, i);
            if (s <= a){
                res += s - pow(10, i-1);
                if (a == s) break;
            }else{
                int s = a - pow(10, i-1) + 1;
                if (s > 0) res += s;
                break;
            }
        }
    }
    cout << res << endl;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int sum, n;
    cin >> sum >> n;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        sum -= x;
    }
    
    cout << max(sum, -1) << endl;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n;
  cin >> n;
  int h[n];
  rep (i, n) {
    cin >> h[i];
  }
  int ans = 0;
  int tmp = 0;
  int now = h[0];
  for (int i = 1; i < n; i++) {
    if (now >= h[i]) {
      tmp++;
      ans = max(ans, tmp);
    } else {
      tmp = 0;
    }
    now = h[i];
  }
  P(ans);
  return 0;
}

Measured memory_bytes: 640
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
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 << 62;
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 conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (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;
}
//-----------------------ここから-----------
ll n, m;
vector<ll> a, b;
int main(void){
    cin >> n >> m;
    a.resize(n);
    b.resize(m);
    set<ll> sta, stb;
    bool ok = true;
    rep(i, n) {
        cin >> a[i];
        if(sta.find(a[i]) != sta.end()){
            ok = false;
        }
        sta.insert(a[i]);
    }
    rep(i, m) {
        cin >> b[i];
        if(stb.find(b[i]) != stb.end()){
            ok = false;
        }
        stb.insert(b[i]);
    }

    if(!ok){
        cout << 0 << endl;
        return 0;
    }

    sort(all(a));
    sort(all(b));
    ll ans = 1;
    for(ll i = n * m; i >= 1; i--){
        auto itra = lower_bound(all(a), i);
        auto itrb = lower_bound(all(b), i);
        ll idxa = itra - a.begin();
        ll idxb = itrb - b.begin();
        if(sta.find(i) != sta.end() && stb.find(i) != stb.end()){
            continue;
        } else if(sta.find(i) == sta.end() && stb.find(i) == stb.end()){
            ll tmp = (n - idxa) * (m - idxb) - (n * m - i);
            if(tmp <= 0){
                ok = false;
            }
            ans *= tmp;
            
        } else if(sta.find(i) == sta.end()){
            ll tmp = (n - idxa);
            ans *= tmp;
        } else {
            ll tmp = (m - idxb);
            ans *= tmp;
        }
        ans %= MOD;
        //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n < 600)cout << 8;
    else if(n < 800)cout << 7;
    else if(n < 1000)cout << 6;
    else if(n < 1200)cout << 5;
    else if(n < 1400)cout << 4;
    else if(n < 1600)cout << 3;
    else if(n < 1800)cout << 2;
    else cout << 1;
    cout << endl;
  }

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args)throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] p = new int[n];
    int[] p_sort = new int[n];
    int count = 0;
    String[] str = in.readLine().split(" ");
    for(int i=0; i<n; i++) {
      p[i] = Integer.parseInt(str[i]);
      p_sort[i] = Integer.parseInt(str[i]);
    }
    Arrays.sort(p_sort);
    for(int i=0; i<n; i++) {
       if(p_sort[i] != p[i])
        count += 1;
    }
    System.out.println(count<=2?"YES":"NO");
  }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/15  Problem: 061_abc_d / Link: https://abc061.contest.atcoder.jp/tasks/abc061_d?lang=en  ----- */
/* ------問題------

N 頂点 M 辺の重み付き有向グラフがあります。 
i(1≦i≦M) 番目の辺は 頂点 ai から 頂点 bi を重み ci で結びます。 
このグラフと駒を利用して、次の1人ゲームを行います。

最初、駒を頂点 1 に置いて、プレイヤーのスコアを 0 とします。 
プレイヤーは、次の条件で駒を繰り返し移動させることができます。

頂点 ai に駒があるとき、i 番目の辺を利用して頂点 bi に移動する。移動後にプレイヤーのスコアが ci 加算される。
頂点 N に駒があるときのみ、ゲームを終了できます。 
なお、与えられる有向グラフの上で頂点 1 から頂点 N に移動できることは保障されています。

プレイヤーがゲーム終了時のスコアを出来るだけ大きくするような行動を取ったとき、ゲーム終了時のスコアはいくつになるでしょうか? 
ゲーム終了時のスコアをいくらでも大きくできる場合は inf と出力してください。

-----問題ここまで----- */
/* -----解説等-----

頂点の更新をしていく際に、何度も更新されるものは永遠に増やせることになる。
実際に何度も更新されるかを確認すれば良い。

----解説ここまで---- */


struct Edge {
	LL to, cost;
	Edge(int t, LL c = 0) : to(t), cost(c)
	{}
	bool operator>(const Edge& rhs) const {
		return cost > rhs.cost;
	}
	bool operator<(const Edge& rhs) const {
		return cost < rhs.cost;
	}

};
using Graph = vector< vector<Edge> >;


// precondition: d.size == V
// O(V*E)
// 負閉路が存在するときはfalse,そうでないときはtrue
void BellmanFord(const Graph& G, vector<LL>& d) {
	const int V = G.size();
	//for (int i = 0; i < V; ++i)
	//	d[i] = INF;
	//d[s] = 0;

	for (int lp = 0; lp <= V; ++lp) {
		for (int i = 0; i < V; ++i) {
			for (const auto& e : G[i]) {
				if ( d[e.to] < d[i] + e.cost) {
					d[e.to] = d[i] + e.cost;
				}
			}
		}
	}
}



LL N,M;

LL ans = 0LL;

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

	cin >> N>>M;
	Graph G(N);
	FOR(i, 0, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		G[a].push_back(Edge(b,c));
	}
	VL dist(N, -LINF);
	dist[0] = 0;
	BellmanFord(G, dist);
	VL d2 = dist;
	BellmanFord(G, d2);

	if (d2[N - 1] != dist[N - 1]) {
		cout << "inf" << endl;
	}else
	{
		ans = dist[N - 1];
		cout << ans << "\n";
	}

	return 0;
}


Measured memory_bytes: 384
n=int(input())
A=[]
B=[]
for i in range(n):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
A.sort()
B.sort()
if n%2!=0:
  print(B[n//2]-A[n//2]+1)
else:
  print(B[n//2]+B[n//2-1]-A[n//2]-A[n//2-1]+1)
  

Measured memory_bytes: 25352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
const int maxn = 1e4 +10;

int color[maxn];
stack<int> S;
int main()
{
    int n,m,num;
    scanf("%d%d",&n,&m);
    scanf("%d",&num);
    for(int i=1 ; i<=num; i++){
        scanf("%d",&color[i]);
    }
    int k = 1;
    for(int i=1 ; i<=n; i++){
        if(i%2 == 1)
            for(int j=1 ; j<=m; j++){
                if(color[k]){
                    color[k]--;
                    printf("%d ",k);
                }
                if(!color[k]) k++;
            }
        else{
            for(int j=1 ; j<=m; j++){
                if(color[k]){
                    color[k]--;
                    S.push(k);
                }
                if(!color[k]) k++;
            }
            while(S.size()){
                printf("%d ",S.top());
                S.pop();
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 384
# 2019-11-16 10:55:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 
import re

def main():
    # 左がRで右がLとなっている箇所でそれぞれどちらかにあつまる。10^100 は実質無限なので距離が奇数か偶数かで場合わけ
    s = sys.stdin.readline().rstrip() + 'R' # 後々のループ処理のときのことを考えて最後にRを足しておく
    n = len(s) - 1
    all_occurrences_of_rl = [m.start() for m in re.finditer('RL', s)]
    
    counts = [0 for _ in range(n)]
    left = 0
    for i in range(len(all_occurrences_of_rl)):
        right = all_occurrences_of_rl[i] + 1
        while s[right+1] == 'L': # 次がLだったら右端を拡張していく
            right += 1
        
        r_count = 1 + (all_occurrences_of_rl[i] - left) // 2 + (right - all_occurrences_of_rl[i]) // 2
        l_count = (right - left + 1) - r_count
        counts[all_occurrences_of_rl[i]] = r_count
        counts[all_occurrences_of_rl[i] + 1] = l_count

        left = right + 1
    
    for i in range(n):
        print(counts[i], end=' ')
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 6896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;

int main(){
    ll N; cin >> N;
    vector<ll> A(N),B(N),C(N);
    for(int i=0;i<N;++i){
        cin >> A[i];
    }
    for(int i=0;i<N;++i){
        cin >> B[i];
    }
    for(int i=0;i<N;++i){
        cin >> C[i];
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());

    ll ans = 0;
    for(int i=0;i<N;++i){
        auto a = lower_bound(A.begin(),A.end(),B[i]);
        auto c = upper_bound(C.begin(),C.end(),B[i]);
        ans += (a - A.begin()) * (C.end() - c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
s = gets.chomp
start = -1
ending = -1


s.size.times do |i|
    if start < 0
        if s[i] == 'A'
            start = i
        end
    else
        if s[i] == 'Z'
            ending = i
        end
    end
end
result = ending - start + 1
puts result


Measured memory_bytes: 2172
from itertools import product as pd
from collections import defaultdict as dd
n, m, x = map(int, input().split())
price_dic = {}
#naiyo_dic[book][skill]
naiyo_dic = dd(lambda: dd(lambda: 0))
for i in range(1, n+1):
    A = list(map(int, input().split()))
    price_dic[i] = A[0]
    for j in range(1, m+1):
        naiyo_dic[i][j] = A[j]
#print(price_dic)
#print(naiyo_dic)

def price_and_can(pattern):
    skill = [0] * (m+1)
    skill[0] = 10**5 + 1
    price = 0
    can_do = False
    for i, is_read in enumerate(pattern):
        book_num = i + 1
        if is_read == 1:
            price += price_dic[book_num]
            for j in range(1, m+1):
                skill[j] += naiyo_dic[book_num][j]
    if min(skill) >= x:
        can_do = True
    #print(pattern, skill, min(skill), price, x, can_do)
    return price, can_do

prices = []
for pattern in pd([0, 1], repeat=n):
    val, can_do = price_and_can(list(pattern))
    if can_do:
        prices.append(val)

#print(prices)
if prices == []:
    print(-1)
else:
    print(min(prices))

Measured memory_bytes: 69684
#include <iostream>
#include <string>
#include<stdio.h>
#include <vector>
#include <math.h> 
using namespace std;

long long Gcd(long long a,long long b){
	if(a%b==0)return b;
	return(Gcd(b,a%b));
}
int main (){
	long long A,B;cin>>A>>B;


	vector<long long> cd;
	long long gcd;
	gcd=Gcd(A,B);
	//cout<<"gcdは"<<gcd<<endl;
	cd.push_back(1);
	long long num=gcd;
	for(long long i = 2; i*i<=gcd;++i){
		if(gcd%i)continue;
		cd.push_back(i);
		while(gcd%i==0){
			gcd/=i;
			//cout<<i<<"で割る"<<endl;
		}
	}
	if(gcd != 1) cd.push_back(gcd);
	cout<<cd.size()<<endl;
	
    return 0;
}

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

#define ll long long
#define N 100005
#define mod 1000000007


int main() 
{
    int x,a,b;
    
    cin>>x>>a>>b;
    
    abs(x-a)>abs(x-b)?puts("B"):puts("A");
    
    return 0;
}

Measured memory_bytes: 384
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef std::vector<int> VI;
typedef std::pair<int,int> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

int main()
{
    char s[10];
    scanf("%s",s);
    int ans=0;
    if(s[0]=='R' || s[1]=='R' || s[2]=='R') ans=1;
    if(s[0]=='R' && s[1]=='R') ans=2;
    if(s[1]=='R' && s[2]=='R') ans=2;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R') ans=3;
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3764
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	string s,t,tmp;
	cin >> s >> t;
	bool ans = false;
	int len = s.length();
	rep(i, len) {
		if (s == t) {
			ans = true;
			break;
		}
		s = s.back() + s.substr(0,len-1);
	}

	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = 0;
    for(ll i = a; i <= b; i++){
        if(i % 10 == (i / 10000) % 10 && (i / 10) % 10 == (i / 1000) % 10){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import sys
import datetime
from functools import lru_cache
readline=readline = sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True


def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
ans=[]
def f(s,N):
    if(len(s)==N):
        ans.append(s)
        return
    max_=-1
    for a in s:
        max_=max(max_,ord(a)-ord("a"))
    for a in range(max_+2):
        s1=s+chr(ord(chr(max_+ord("a")))-a+1)
        f(s1,N)

#main
N=int(input())
ans=[]
if N==1:
    print("a")
else:
    f("a",N)
    ans.sort()
    print("\n".join(ans))


Measured memory_bytes: 96728
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID
/*#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define print(o) for(auto it=(o).begin();it!=(o).end();it++) cout<<*it<<" ";
#define vll vector<ll>
#define pb push_back
#define FOR(n) for(ll i=0;i<=n;i++)
#define FORd(n) for(ll i=n;i>=0;i--)
#define FORrd(a,b) for(ll i=a;i>=b;i--)
#define FORr(a,b) for(ll i=a;i<=b;i++)
#define all(x) (x).begin(),(x).end()
#define FIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define ff first
#define ss second
#define w(t) ll t;cin>>t;while(t--)

int main()
{
    ll n,k;
    cin>>n>>k;
    n=n%k;
    while(n>abs(n-k))
    {
        n=abs(n-k);
    }
    cout<<n<<'\n';
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;

int main(){
    int n; cin>>n;
    if(n%2==0){
        cout << n/2 << endl;
    }else{
        cout << n/2 +1 << endl;
    }
}

Measured memory_bytes: 256