akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <string.h>
#include <iostream>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <random>
using namespace std;
typedef long long ll;
const int INF = 987654321;
const int MAX_N = 3e5 + 2, MAX_X = 1e6 + 2;

int main()
{
	string s;
	cin >> s;
	if (s.back() == 's')cout << s << "es";
	else cout << s << "s";
}

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

void solve() {
    int n;
    std::cin >> n;
    std::vector<int> ans(n, -1);

    int m;
    std::cin >> m;
    while (m--) {
        int i, c;
        std::cin >> i >> c;
        --i;
        if (ans[i] != -1 && ans[i] != c) {
            std::cout << "-1" << std::endl;
            return;
        }
        ans[i] = c;
    }

    if (n > 1 && ans[0] == 0) {
        std::cout << -1 << std::endl;
        return;
    }

    for (int i = 0; i < n; ++i) {
        std::cout << (ans[i] != -1 ? ans[i] : n > 1 && i == 0 ? 1 : 0);
    }
    std::cout << std::endl;
}

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

    solve();

    return 0;
}


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int i = -1;
        if(a>b){
            i = b;
        }else{
            i = a;
        }
        int count = 0;
        while(true){
            if(a%i==0&&b%i==0){
                count++;
            }
            if(count == k){break;}
            i--;
        }
        System.out.println(i);
        sc.close();
    }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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);}

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

Measured memory_bytes: 384
var input: string = require('fs').readFileSync('/dev/stdin', 'utf8');
var inputLines: string[] = input.trim().split("\n");
var parts = inputLines[0].split(" ");

var A = parseInt(parts[0]);
var B = parseInt(parts[1]);
var C = parseInt(parts[2]);
var cans = new Set();
cans.add(A);
cans.add(B);
cans.add(C);
console.log(cans.size);

Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	int r,g,b;
	cin >> r >> g >> b;
	int num=r*100+g*10+b;
	if(num%4)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;	
}

Measured memory_bytes: 3576
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

// CHECK THE LIMITS
typedef long long ll;

static const int NMAX = 1e5;
const int MX = 1000001;
int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;

    vector<bool> bad(n+1);
    vector<int> dist(n+1,MX);
    vector<int> nxt(n+1);
    for(int i =0 ; i<= n; ++i)
    {
        if(s[i] == '1')
            bad[i] = true;
    }
    priority_queue<pair<int,int>> pq;
    pq.push({0,-1*n});
    for(int i = n-1; i>= 0; --i)
    {
        if(bad[i])
            continue;
        while(!pq.empty() && -1*pq.top().second > i+m)
        {
            pq.pop();
        }
        if(!pq.empty())
        {
            pair<int,int> cur = pq.top();
            dist[i] = -1*cur.first + 1;
            nxt[i] = -1*cur.second - i;
        }
        pq.push({-1*dist[i], -1*i});
    }
    if(dist[0] >= MX)
    {
        cout << -1 << '\n';
        return 0;
    }
    int x = 0;
    while(x < n)
    {
        cout << nxt[x] << " ";
        x += nxt[x];
    }

    return 0;
}

Measured memory_bytes: 2296
def main():
    n = int(input())
    a = list(map(int,input().split()))
    res = [0 for i in range(n)]
    lres = []
    for i in range(n,0,-1):
        l = []
        flag = 0
        t = i*2
        while t <= n:
            flag = flag ^ res[t-1]
            t = t+i
        if a[i-1] != flag:
            res[i-1] = 1
            lres.append(str(i))

    print(len(lres))
    if len(lres) != 0:
        print(" ".join(lres))

main()

Measured memory_bytes: 17208
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;

//////検証する数,超えられない数////
long long cine(long long a, long long b) {
	if (a <= b) {
		return a;
	}
	else {
		return b;
	}
};
//vector型の初期化
void vec_initialize(vector<ll>& a, const ll N) {
	ll c;

	for (int i = 0; i < N; i++) {

		cin >> c;
		a.push_back(c);

	}

};
void vec_pair_initialize(vector<pair<ll, ll>>& a, const ll N) {
	ll c, d;
	for (int i = 0; i < N; i++) {
		cin >> c >> d;
		a.push_back(make_pair(c, d));
	}
};
bool Pinching_In(ll a, ll x, ll b) {

	if (a <= x && x <b) {


		return true;
	}
	return false;
}
int main() {
	ll dx[4] = { 1,-1,0,0 };
	ll dy[4] = { 0,0,1,-1 };
	ll H, W;
	cin >> H >> W;
	vector<string>s;
	string c;
	for (int i = 0; i < H; i++) {
		cin >> c;
		s.push_back(c);
	}
	for (ll i = 0; i < H; i++) {
		for (ll j = 0; j < W; j++) {
			if (s[i][j] == '#') {
				for (ll k = 0; k < 4; k++) {
					if (Pinching_In(0, i + dx[k], H) && Pinching_In(0, j + dy[k], W)) {

						if (s[i + dx[k]][j + dy[k]] == '#') {

							break;
						}

					}
					if (k == 3) {


						cout << "No";
						return 0;
					}
				}
			}
		}

	}
	cout << "Yes";
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
  
    int n,a[1000],max,min,i;
      
     scanf("%d",&n);
  
     for(i=0;i<n;i++){
         scanf("%d",&a[i]);
     }
     
     max=a[0];   min=a[0];
  
     for(i=0;i<n;i++){
         if(max<a[i])      max=a[i];
         else if(min>a[i]) min=a[i];
     }  
    
     printf("%d",max-min);
  
     return 0;
}  

Measured memory_bytes: 1660
program main
  implicit none
  character(len=100000) :: S
  integer :: n1,n0
  integer :: N,tmp
  integer :: i
  read(*,'(A)') S
  N=len(trim(S))
  n1 = 0
  do i = 1,N
     read(S(i:i),*) tmp
     if (tmp == 1) n1 =n1+1
  end do
  n0=N-n1
  if (n1==n0) then
     write(*,'(i0)') N
  else 
     write(*,'(i0)') min(n1,n0)*2
  end if
end program main


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n; cin >> n;
  cout << n * n;

  

  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]
ans = []
d = {}
for i in s:
    try: d[i] += 1
    except KeyError: d[i] = 1
mx = 0
for value in d.values():
    if value > mx: mx = value
for key, value in d.items():
    if value == mx:
        ans.append(key)
for v in sorted(ans):
    print(v)


Measured memory_bytes: 38316
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::{i32, i64, i128, u32, u64, u128, f64};
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!(
        n: usize,
    );
    let k = 1000000007;
    let ans = {
        let mut v = Vec::new();
        for p in [10, 9, 8].iter() {
            let mut buf = 1i64;
            for _ in 0..n { buf = (buf * p) % k; }
            v.push(buf)
        }
        v[0] - 2*v[1] + v[2]
    };
    println!("{}", ans.rem_euclid(k));
}



Measured memory_bytes: 2196
# 各評定のボーダー値を定義
border_a = 80
border_b = 65
border_c = 50
border_d = 30
border_retest = 50

# 特定の入力値(-1, -1, -1)以外の間は繰り返す
while True:
    m,f,r = map(int, input().split())
    mf = m + f

    if (m==-1)and(f==-1)and(r==-1):
        break
    elif (m==-1)or(f==-1):
        print("F")
    elif mf >= border_a:
        print("A")
    elif mf >= border_b:
        print("B")
    elif mf >= border_c:
        print("C")
    elif mf >= border_d:
        if r >= border_retest:
            print("C")
        else:
            print("D")
    else:
        print("F")





Measured memory_bytes: 5592
n, a, b = map(int, input().split())
ls = [int(input()) for _ in range(n)]


def check(k):
    return sum([(x - k * b + a - b - 1) // (a - b)
                for x in ls if x - k * b > 0]) <= k


m = max(ls)
lo = (m + a - 1) // a
hi = (m + b - 1) // b + 1
mi = (hi + lo) // 2
while hi > lo:
    mi = (hi + lo) // 2
    if check(mi):
        hi = mi
    else:
        lo = mi + 1
print(lo)

Measured memory_bytes: 11020
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;

int main()
{
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        string s;
        s=to_string(i);
        if(s.length()%2==1)ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int64_t n,m,q;
vector<int64_t> a;
vector<int64_t> b;
vector<int64_t> c;
vector<int64_t> d;
int64_t ans=0;
void dfs(vector<int64_t>Q){
  if(Q.size()==n){
    int64_t score=0;
    for(int64_t i=0;i<q;i++){
      if(Q[b[i]-1]-Q[a[i]-1]==c[i])score+=d[i];
    }
    ans=max(ans,score);
    return;
  }
  Q.push_back(Q.back());
  while(Q.back()<=m){
    dfs(Q);
    Q.back()++;
  }
}
int main(){
  cin >> n >> m >> q;
  a=b=c=d=vector<int64_t>(q);
  for(int64_t i=0;i<q;i++)cin >> a[i] >> b[i] >> c[i] >> d[i];
  dfs({1});
  cout << ans << endl;
}

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

int main() {
  int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
  int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
  
  string board[60];
  int X, Y;
  cin >> X >> Y;
  
  for (int i = 0; i < X; i++) cin >> board[i];
  
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
      if (board[i][j] == '.') {
        int cnt = 0;
        for (int k = 0; k < 8; k++) {
          int x = i + dx[k];
          int y = j + dy[k];
          
          if (x >= 0 && x < X && y >= 0 && y < Y && board[x][y] == '#')
            cnt++;
        }
        board[i][j] = '0' + cnt;
      }
    }
  }
  for (int i = 0; i < X; i++) cout << board[i] << endl;
  return 0;
}
      
      

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 310000 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

ll check(ll n){
    ll l=0,r=1e8;
    while(l<r){
        ll mid=(l+r)/2;
        if(mid*mid>n) r=mid;
        else if(mid*mid==n) return mid;
        else l=mid+1;
    }
    return 0;
}
main(){
    ll n,s[N],t[N],u[N];
    fill(u,u+N,1);
    cin>>n;
    rep(i,n){
        cin>>s[i];
        t[i]=s[i];
    }
    int prime[100000]={};
    for(ll i=2;i<=10000;i++){
        if(prime[i]) continue;
        for(ll j=i;j<10000;j+=i){
            prime[j]=1;
        }
        ll a=i*i*i;
        rep(j,n){
            while(s[j]%a==0){
                s[j]/=a;
                t[j]/=a;
            }
            int count=0;
            while(t[j]%i==0){
                t[j]/=i;
                count++;
            }
            int b=(3-count)%3;
            rep(iii,b){
                u[j]*=i;
            }
        }
    }
    int ans=0;
    ll m[N];
    rep(i,n){
        m[i]=s[i];
    }
    sort(m,m+n);
    int flag[N]={};
    rep(i,n){
        if(t[i]>1){
            if(check(t[i])){
                u[i]*=check(t[i]);
                t[i]=1;
            }
            else{
                if(t[i]<100001&&t[i]*u[i]<1e10+1){
                    u[i]=u[i]*t[i]*t[i];
                    t[i]=1;
                }
            }
        }
    }
    rep(i,n){
        if(t[i]>1){
            ans+=1;continue;
        }
        if(u[i]==1) continue;
        int a,b,c,d;
        a=upper_bound(m,m+n,s[i])-lower_bound(m,m+n,s[i]);
        b=upper_bound(m,m+n,u[i])-lower_bound(m,m+n,u[i]);
        if(a>b||(a==b&&s[i]>u[i])){
            int p=lower_bound(m,m+n,s[i])-m;
            if(flag[p]) continue;
            flag[p]=1;
            ans+=a;
        }
        else{
            int p=lower_bound(m,m+n,u[i])-m;
            if(flag[p]) continue;
            flag[p]=1;
            ans+=b;
        }
    }
    if(upper_bound(m,m+n,1)-lower_bound(m,m+n,1)>0)
      ans++;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 11260
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

bool isUSCase(const std::string &s){
    return s.find("_") != std::string::npos;
}

bool isUCCase(const std::string &s){
    return std::isupper(s[0]);
}

bool isLCCase(const std::string &s){
    return !isUSCase(s) && std::islower(s[0]);
}

int main(){
    std::string s;
    char c;

    while(std::cin >> s >> c, c != 'X'){

        if(isUSCase(s)){
            if(c == 'U'){
                s[0] = std::toupper(s[0]);
                int pos = 0;
                while(pos = s.find("_", pos), pos != std::string::npos){
                    s.replace(pos, 2, 1, std::toupper(s[pos+1]));
                    pos++;
                }
            }else if(c == 'L'){
                int pos = 0;
                while(pos = s.find("_", pos), pos != std::string::npos){
                    s.replace(pos, 1, "");
                    s[pos] = std::toupper(s[pos]);
                }
            }else if(c == 'D'){
            
            }
        }else if(isUCCase(s)){
            if(c == 'U'){
            
            }else if(c == 'L'){
                s[0] = std::tolower(s[0]);
            }else if(c == 'D'){
                s[0] = std::tolower(s[0]);
                std::string _s = "";
                REP(i, s.size()){
                    if(std::isupper(s[i]) && i > 0){
                        _s += "_";
                        s[i] = std::tolower(s[i]);
                    }
                    _s += s[i];
                }
                s = _s;
            }
        }else if(isLCCase(s)){
            if(c == 'U'){
                s[0] = std::toupper(s[0]);
            }else if(c == 'L'){
            
            }else if(c == 'D'){
                std::string _s = "";
                REP(i, s.size()){
                    if(std::isupper(s[i])){
                        _s += '_';
                        s[i] = std::tolower(s[i]);
                    }
                    _s += s[i];
                }
                s = _s;
            }        
        }

        std::cout << s << std::endl;
    }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll mod = pow(10, 9) + 7;
  ll N;
  cin >> N;
  ll ans = modpow(10, N, mod) - modpow(9, N, mod);
  if (ans < 0) {
    ans += mod;
  }
  ans -= modpow(9, N, mod);
  if (ans < 0) {
    ans += mod;
  }
  ans += modpow(8, N, mod);
  ans %= mod;
  cout << ans << "\n";
}


Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int main()
{
  ll k, a, b;
  cin >> k >> a >> b;
  ll result = k + 1;

  if (k + 1 >= a) {
    ll cur = 1;
    k -= a - 1;
    cur += a - 1;
    if (k % 2) {
      k--;
      cur++;
    }
    cur += k / 2 * (b - a);
    result = max(result, cur);
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int sum,n,k,a[105]={0},i,maxn,minn;
    cin>>sum>>n;
    i=n;
    while(sum--)
    {
        a[i]++;
        if(i==1)
           i=n;
        else
            i--;
    }
    maxn=a[1];
    minn=a[1];
    for(int i=1;i<=n;i++)
    {
        if(maxn<a[i])
             maxn=a[i];
        if(minn>a[i])
            minn=a[i];
    }
    cout<<maxn-minn<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    llint a,b,x;
    cin>>a>>b>>x;
    if(a<=x&&x<=a+b){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cassert>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<bitset>
using namespace std;
#define pb push_back
#define x0 fuckcjb
#define x1 fuckshb
#define y0 fucksub
#define y1 fuckjtjl
struct edges
{
	int x,y,z;
};
int d[15][15];
bool vis[20][20];
int tot,n,idx[120],idy[120],S,T,A,B;
vector<edges> edge;
void check()
{
	for(int i=1;i<=A;i++)
	{
		for(int j=1;j<=B;j++)
		{
			if(!vis[i][j])
			{
			puts("Impossible");
			exit(0);
		}
		}
	}
}
int get(int p,int q)
{
	int c=-1000000;
	for(int i=1;i<=A;i++)
	{
		for(int j=1;j<=B;j++)
		{
			c=max(c,d[i][j]-i*p-j*q);
		}
	}
	if(c<0)
	{
		return -3;
	}
	for(int i=1;i<=A;i++)
	{
		for(int j=1;j<=B;j++)
		{
			if(d[i][j]-i*p-j*q==c)
			{
				vis[i][j]=1;
			}
		}
	}
	return c;
}
void add(int x,int y,int z)
{
	if(z==-3)
	{
		return;
	}
	edge.push_back({x,y,z});
}
int main()
{
	scanf("%d%d",&A,&B);
	for(int i=1;i<=A;i++)
	{
		for(int j=1;j<=B;j++)
		{
			scanf("%d",&d[i][j]);
		}
	}
	S=1;T=2;tot=2;
	idx[0]=S;idy[0]=T;
	for(int i=1;i<=100;i++)
	{
		idx[i]=++tot;
		idy[i]=++tot;
	}
	for(int i=1;i<=100;i++)
	{
		add(idx[i-1],idx[i],-1);
		add(idy[i],idy[i-1],-2);
	}
	for(int i=0;i<=100;i++)
	{
		for(int j=0;j<=100;j++)
		{
			add(idx[i],idy[j],get(i,j));
		}
	}
	check();
	puts("Possible");
	int cnt=edge.size();
	printf("%d %d\n",tot,cnt);
	for(int i=0;i<cnt;i++)
	{
		printf("%d %d ",edge[i].x,edge[i].y);
		if(edge[i].z>=0)
		{
			printf("%d\n",edge[i].z);
		}
		else if(edge[i].z==-1)
		{
			puts("X");
		}
		else
		{
			puts("Y");
		}
	}
	printf("%d %d\n",S,T);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define mx 1000002
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int a[100005];
int f(int a,int b)
{
	return a>b;
}
	
int32_t main() {
	int n,m,s=0,i;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{cin>>a[i];
	s+=a[i];
	}
	double k=(s)/double(4*m);
	sort(a,a+n,f);
	if(a[m-1]>=k)
		cout<<"Yes\n";
	else cout<<"No\n";
		
}	

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

string S;

int ei(string::iterator &it,int r){
    if(r==0){
        vint lis;
        while(it!=S.end()){
            int x=ei(it,1);
            if(*it!='='||x==INF)return INF;
            lis.pb(x);
            it++;
        }
        if(lis.size()!=2||lis[0]!=lis[1])return INF;
        return 114514;
    }

    if(r==1){
        int ret=ei(it,2);
        if(ret==INF)return INF;
        while(true){
            if(*it=='+'){
                it++;
                int x=ei(it,2);
                if(x==INF)return INF;
                ret+=x;
            }
            else if(*it=='-'){
                it++;
                int x=ei(it,2);
                if(x==INF)return INF;
                ret-=x;
            }
            else break;
        }
        return ret;
    }

    if(r==2){
        int ret=ei(it,3);
        if(ret==INF)return INF;
        while(true){
            if(*it=='*'){
                it++;
                int x=ei(it,3);
                if(x==INF)return INF;
                ret*=x;
            }
            else break;
        }
        return ret;
    }
    if(r==3){
        if(*it=='-'){
            it++;
            int x=ei(it,3);
            if(x==INF)return INF;
            return -x;
        }
        if(*it=='('){
            it++;
            int x=ei(it,1);
            if(*it!=')')return INF;
            it++;
            if(x==INF)return INF;
            return x;
        }
        return ei(it,4);
    }

    if(r==4){
        bool f=*it=='0';
        if(!isdigit(*it))return INF;
        int ret=0;
        int cnt=0;
        while(isdigit(*it)){
            ret=ret*2+*it-'0';
            it++;
            cnt++;
        }
        
        if(f&&cnt!=1)return INF;
        return ret;
    }
}

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

    vector<char>v;
    rep(i,s.size())if(isalpha(s[i]))v.pb(s[i]);
    sort(all(v));v.erase(unique(all(v)),v.end());

    if(v.size()>8){
        cout<<0<<endl;
        return 0;
    }

    string x="+-*()=01";
    sort(all(x));

    int ans=0;


    set<string>st;
    do{
        S=s;
        rep(i,S.size()){
            if(isalpha(S[i])){
                int k=lower_bound(all(v),S[i])-v.begin();
                S[i]=x[k];
            }
        }
        S+="=";
        auto it=S.begin();
        if(ei(it,0)!=INF){
            ans++;
        }
    }while(next_permutation(all(x)));


    rep(i,(int)x.size()-(int)v.size())ans/=i+1;

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

Measured memory_bytes: 3208
#include <cstdio>
#include <algorithm>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to

using namespace std;

const int N = 100010;

struct Edge{ int to, next;} edge[N];
int head[N], num, n, k, ans;
void add_edge(int a, int b) { edge[++ num] = (Edge){b, head[a]}, head[a] = num;}

int dfs(int x, int f)
{
	int tmp = 1;
	RepG(i, x) tmp = max(tmp, dfs(v, x) + 1);
//	printf("%d %d\n", tmp, x);
	if (tmp == k && x != 1 && f != 1) ans ++, tmp = 0;
	return tmp;
}

int main()
{
	scanf("%d%d", &n, &k);
	Rep(i, n) {
		int x;
		scanf("%d", &x);
		if (i != 1) add_edge(x, i);
		else if (x != 1) ans ++;
	}
	
	dfs(1, 0);
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 6016
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60

#ここから書き始める
n = int(input())
if n % 2 == 0:
    print(n // 2)
else:
    print(n // 2 + 1)


Measured memory_bytes: 5568
N = int(input())
S = list(input())

ans = S.count('R')*S.count('G')*S.count('B')

for i in range(N):
  for j in range(i+1, N):
    k = j + j - i
    if k < N :
      if (S[i] != S[j]) and (S[j] != S[k]) and (S[k] != S[i]) :
        ans -= 1

print(ans)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    // input
    ll N, M; cin >> N >> M;
    vector<vector<ll>> coor_switch(M);
    for (int i = 0; i < M; ++i) {
        ll k; cin >> k;
        for (int j = 0; j < k; ++j) {
            ll s; cin >> s; coor_switch[i].push_back(s - 1);
        }
    }
    vector<ll> p(M); for (int i = 0; i < M; ++i) cin >> p[i];
    
    // bit全探索
    ll ans = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        bool ok = true;
        for (int i = 0; i < M; ++i) {
            // 各電球の対応するスイッチのbitがONになってるか確認する
            ll count = 0;
            for (auto j: coor_switch[i]) {
                if (bit & (1 << j)) count++;
            }
            // 電球が光らなかったら終了
            if (count % 2 != p[i]) ok = false;
        }
        // 全て光っていたらカウント
        if (ok) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A,B;
cin>>A>>B;
if(A==B){
	cout<<"Draw"<<endl;
}
if((B>A ||B==1)&&A!=1){
	cout<<"Bob"<<endl;
}
if((A>B ||A==1)&&B!=1){
	cout<<"Alice"<<endl;

}
return 0;
}


Measured memory_bytes: 256
//解けなかった
using System;
using static System.Console;
using System.Linq;

namespace AC
{
    public class shiokara
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            long[] A = ReadLine().Split(' ').Select(long.Parse).ToArray();
            long ans = 1;
            if (Array.IndexOf(A, 0) != -1)
            {
                WriteLine(0);
                return;
            }

            try
            {
                for (int i = 0; i < N; i++)
                {
                    checked
                    {
                        ans *= A[i];
                    }
                }
            }
            catch (OverflowException ex)
            {
                WriteLine(-1);
                return;
            }
            if(ans >= 1000000000000000001) WriteLine(-1);
            else WriteLine(ans);
        }
    }
}

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

int main()
{
        int n,k;
        cin>>n>>k;
        bool null[n];
        for(int i = 0;i< n; i++)
        {
                null[i] = false;
        }
        for(int i = 0; i< k;i++)
        {
                int a;
                cin>> a;
                for(int j =0;j< a;j++)
                {       
                        int z;
                        cin >>z;
                        null[z -1] = true;
                }
        }

        int ans = 0;
        for(int i =0; i< n; i++)
        {
                if(null[i] == false)
                {
                        ans++;
                }
        }
        cout << ans << endl;
}


Measured memory_bytes: 3588
N , K = [int(x) for x in input().split()]
s = set()
for i in range(1, N+1):
    s.add(i)

for i in range(K):
    num = int(input())
    discard_num = [int(y) for y in input().split()]
    for j in range(len(discard_num)):
        s.discard(discard_num[j])

print(len(s))

Measured memory_bytes: 9216
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N, K, Q, A[2020];

int B[2020];

int minA[2020][2020];

int r[2020];

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> K >> Q;
    for (int j = 1; j <= N; ++j) cin >> A[j];

    for (int i = 1; i <= N; ++i) {
        minA[i][i] = A[i];
        for (int j = i+1; j <= N; ++j) {
            minA[i][j] = min(minA[i][j-1], A[j]);
        }
    }

    for (int i = 1; i <= N; ++i) { B[i] = A[i]; }
    sort(B+1, B+N+1); B[0] = 0;

    priority_queue<int, vector<int>, greater<int>> pq1, pq2;

    int ans = 1000000007;

    int idx = 0;
    for (int i = 0; i < N; ++i) {
        int threshold = B[idx++];
        while (idx <= N && threshold >= B[idx]) ++idx;

        while (!pq1.empty()) pq1.pop();
        while (!pq2.empty()) pq2.pop();

        for (int j = 1; j <= N; ++j) {
            if (A[j] <= threshold) {
                while (pq1.size() >= K) {
                    pq2.push(pq1.top()); pq1.pop();
                }
                while (!pq1.empty()) pq1.pop();
            } else {
                pq1.push(A[j]);
            }
        }
        while (pq1.size() >= K) {
            pq2.push(pq1.top()); pq1.pop();
        }

        if (pq2.size() < Q) break;

        int min_v = pq2.top();
        for (int j = 0; j < Q-1; ++j) pq2.pop();
        int max_v = pq2.top();

        ans = min(ans, max_v - min_v);

        if (idx > N) break;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//解説放送みました
//すぬけくんかっこいい、かっこいいよぉ（）

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	int pn = 1;
	if (ci - cn + 16 > cm) {
		if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); }
		A = ct - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
	else {
		if ((ct = *ci++) == '-') { pn = -1; ct = *ci++; }
		A = ct - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
}

void pakuripair_sort(int N, int A[], int B[]) {
	const int b = 8;
	int tmp[200001], tmp2[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			B[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

int BIT[200001];
void add(int A) {
	while (A <= 200000) {
		BIT[A]++;
		A += A & -A;
	}
}

int query(int A) {
	int kotae = 0;
	while (A > 0) {
		kotae += BIT[A];
		A -= A & -A;
	}
	return kotae;
}

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


	int N = getint();
	int X[200000], Y[200000], zaatu[200000], zaatu2[200000];
	rep(i, N) {
		X[i] = getint() + 1e9;
		Y[i] = getint() + 1e9;
		zaatu[i] = Y[i];
		zaatu2[i] = i;
	}

	pakuripair_sort(N, zaatu, zaatu2);
	rep(i, N) Y[zaatu2[i]] = i + 1;
	pakuripair_sort(N, X, Y);

	ll beki[200001];
	ll mod = 998244353;
	ll kotae = 0;
	beki[0] = 1;
	rep1(i, 200000) beki[i] = beki[i - 1] * 2 % mod;

	int LU[200000], LD[200000];
	rep(i, N) {
		int k = query(Y[i]);
		LD[i] = beki[k];
		LU[i] = beki[i - k];
		add(Y[i]);
	}
	rep(i, 200001) BIT[i] = 0;
	for (int i = N - 1; i >= 0; i--) {
		int k = query(Y[i]);
		ll RD = beki[k];
		ll RU = beki[N - 1 - i - k];

		kotae += (RU - 1) * RD % mod * LU[i] % mod * (LD[i] - 1);
		kotae += RU * (RD - 1) % mod * (LU[i] - 1) % mod * LD[i];
		kotae -= (RU - 1) * (RD - 1) % mod * (LU[i] - 1) % mod * (LD[i] - 1);
		kotae %= mod;
		add(Y[i]);
	}

	printf("%d", (kotae + mod + beki[N - 1] * N) % mod);

	Would you please return 0;
}

Measured memory_bytes: 8832
N, K = (int(i) for i in input().split())
W = list()
for index in range(N):
	x, y, c = (s for s in input().split())
	x = int(x)
	y = int(y)
	c = 0 if c == "W" else 1
	if x%(2*K) != x%K:
		c = 1-c
	if y%(2*K) != y%K:
		c = 1-c
	W.append((x%K, y%K, c))

w = [[0 for _ in range(K)] for _ in range(K)]
b = [[0 for _ in range(K)] for _ in range(K)]
wx = [0 for _ in range(K)]
wy = [0 for _ in range(K)]
bx = [0 for _ in range(K)]
by = [0 for _ in range(K)]
for x, y, c in W:
	if c == 0:
		w[x][y] += 1
		wx[x] += 1
		wy[y] += 1
	else:
		b[x][y] += 1
		bx[x] += 1
		by[y] += 1

M = 0
for row in w:
	M += sum(row)

s = M
for x in range(K):
	tmp = s
	for y in range(K):
		s += by[y]
		s -= wy[y]
		M = max(s, N-s, M)
	for y in range(K):
		by[y] += w[x][y]
		by[y] -= b[x][y]
		wy[y] += b[x][y]
		wy[y] -= w[x][y]
	tmp += bx[x]
	tmp -= wx[x]
	s = tmp
	M = max(s, N-s, M)

print(M)

Measured memory_bytes: 35396
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<max(ll(0),c-(a-b))<<endl;
    return 0;
    }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] f = new int[n][10];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 10; j++) {
                f[i][j] = sc.nextInt();
            }
        }
        int[][] p = new int[n][11];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 11; j++) {
                p[i][j] = sc.nextInt();
            }
        }

        long ans = Long.MIN_VALUE;
        for (int bit = 1; bit < (1 << 10); bit++) {
            boolean[] open = new boolean[10];
            for (int i = 0; i < open.length; i++) {
                if ((1 & (bit >> i)) == 1) {
                    open[i] = true;
                }
            }
            long sum = 0;
            for (int i = 0; i < n; i++) {
                int cnt = 0;
                for (int j = 0; j < 10; j++) {
                    if (open[j] && f[i][j] == 1) {
                        cnt++;
                    }
                }
                sum += p[i][cnt];
            }
            ans = Math.max(sum, ans);
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 39472
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m,k1,k2;
  while(cin >> n >> m >> k1 >> k2 && n) {
    int a[n+1],x;
    mem(a);
    rep(i,k1) {
      cin >> x;
      a[x]=1;
    }
    rep(i,k2) {
      cin >> x;
      a[x]=2;
    }
    double dp[2][n+1][2];
    mem(dp);
    dp[0][0][0]=1;
    rep(t,m) {
      rep(i,n+1) {
        if(i==n) {
          dp[1][i][0]+=dp[0][i][0];
          continue;
        }
        dp[1][i][0]+=dp[0][i][1];
        REP(j,1,7) {
          x=i+j;
          int y=0;
          if(x>n) x=n-(x-n);
          if(a[x]==1) y=1;
          if(a[x]==2) x=0;
          dp[1][x][y]+=dp[0][i][0]/6;
        }
      }
      rep(i,n+1) {
        rep(j,2) {
          dp[0][i][j]=dp[1][i][j];
          dp[1][i][j]=0;
        }
      }
    }
    pd(dp[0][n][0]);
  }
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 1244
#include <iostream>
#include <array>
#include <algorithm>

using ll = long long;
using namespace std;

int main() {
  ll N;
  cin >> N;
  ll ret = 0, mx = 0, h;
  for (ll i = 0; i < N; i++) {
    cin >> h;
    if (h >= mx) ret++;
    mx = max(mx, h);
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
H = int(input())
cnt = H
ans = 0
B = [H]

if H == 1:
    ans == 'NA'
else:
    for i in range(100000000000):
        cnt = cnt//2
        B.append(cnt)
        if cnt == 1:
            break

C =[1]
for i in range(1,1001):
    C.append(C[i-1]*2)

if ans == 'NA':
    print('0')
else:
    for i in range(len(B)):
        ans +=C[i]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    ans=LINF;
    rep(i,n)cin>>a[i];
    rrep(i,0,101){
        tmp=0;
        tmpp=0;
        rep(j,n){
            if(j<=i)tmp+=a[j];
            else tmpp+=a[j];
        }
        ans=min(abs(tmp-tmpp),ans);
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long ans = 0;
		if ((B-A)%2 == 0) {
			ans = (B-A)/2;
		} else {
			ans = Math.min(A-1,N-B)+(Math.abs(A-B)+1)/2;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

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

Measured memory_bytes: 3860
#include <stdio.h>

int main(){
  int input,h=0,m=0,s=0;
  scanf("%d",&input);
  h = input / 3600;
  input = input - 3600*h;
  m = input / 60;
  input = input - 60*m;
  s = input;
  
  printf("%d:%d:%d\n",h,m,s);
  return 0;
  
} 


Measured memory_bytes: 2060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

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

double EPS = 1e-9;

int main(){
	int n, k, T, u, v, l;
	cin >> n >> k >> T >> u >> v >> l;
	vector<int> d(n);
	rep(i, n) cin >> d[i];
	d.push_back(l);

	double pos = 0, time = 0, car = 0;
	int cnt = 0;

	auto mov = [](double from, double to, double vel){
		return (to - from) / vel;
	};

	while (pos + EPS < l){
		int nxt = upper_bound(ALL(d), pos) - d.begin();

		if (car > EPS){
			double t = mov(pos, d[nxt], v);
			if (car < t){
				time += car;
				pos += car*v;
				car = 0;
			}
			else{
				time += t;
				pos = d[nxt];
				car -= t;
				++cnt;
				if (cnt > k) car = 0;
			}
		}
		else{
			double t = mov(pos, d[nxt], u);
			if (cnt == 0){
				time += t;
				pos = d[nxt];
				++cnt;
			}
			else{
				cnt--;
				car = T;
			}
		}
	}

	cout.setf(ios::fixed);
	cout.precision(10);
	cout << time << endl;

	return 0;
}

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

int main(){
  int n,sum=0,t=1;
  cin >> n;
  
  vector<int> vec(n);
  for(int i=0;i<n;i++)
    cin >> vec.at(i);
  
  while(t){
  for(int i=0;i<n;i++){
    if(vec.at(i)%2!=0){
      t=0;
      break;
    }
    else
      vec.at(i)=vec.at(i)/2;
    if(i==n-1)
      sum++;
     
  }
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  int N, M;
  cin >> N >> M;
  
  string ans;
  if (N > M) ans = "No";
  else ans = "Yes";
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

int main(){
  ll N;
  vector<ll> A;
  vector<ll> B;
  vector<ll> C;
  
  cin >> N;
  for(int i=0;i<N;++i){
    ll t;
    cin >> t;
    A.push_back(t);
  }
  for(int i=0;i<N;++i){
    ll t;
    cin >> t;
    B.push_back(t);
  }
    
  for(int i=0;i<N;++i){
    ll t;
    cin >> t;
    C.push_back(t);
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  ll ans = 0;
  for(ll i=0;i<N;++i){
    cerr<<(lower_bound(A.begin(),A.end(),B[i])-A.begin())<<","<<(N-(upper_bound(C.begin(),C.end(),B[i])-C.begin()-1))<<endl;
    ans += (lower_bound(A.begin(),A.end(),B[i])-A.begin()) * (N-(upper_bound(C.begin(),C.end(),B[i])-C.begin()));
  }
  cout<<ans<<endl;
}

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

int main()
{
    string s;
    cin >> s;
    
    int top = 0, bot = 0;
    
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == 'A')
        {
            top = i;
            break;
        }
    }
    
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == 'Z')
        {
            bot = i;
        }
    }
    
    cout << bot - top + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
n,a,b,c,d = map(int,input().split())
road = input()
if "##" in road[a-1:c-1] or "##" in road[b-1:d-1]:
  print("No")
else:
  if c < d:
    print("Yes")
  else:
    flag = d == b+1 and road[b-2] == "#" and road[d] == "."
    if "..." in road[b-2:d+1] or flag:
      print("Yes")
    else:print("No")

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


int main(){

    int a,b,c,d;
    cin >> a >> b >> c >> d;
    vector<int> tm(100,0);
   
    for(int i = a;i < b;i++){
        
        tm[i]++;
    }
    for(int i = c;i < d;i++){
    
        tm[i]++;
    }
    int count = 0;
    for(int i = c;i < d;i++){
        
        if(tm[i] == 2){
            count++;
        }
    }
    cout << count << endl;
    
    


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
   int a, b, c;
   scanf("%d %d %d",&a,&b,&c);
   if(a==b &&b==c){
      printf("1\n");
   }else if(a==b||b==c||c==a){
      printf("2\n");
   }else{
      printf("3\n");
   }
   return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

const int mod = 1000000007;
ll R,R2,modash;
int logR;
ll MR(ll x){
    ll ret = (x + ((x*modash)&(R-1ll))*mod)>>(logR);
    return (ret>=mod ? ret-mod : ret);
}
ll get_mod(ll x){return MR(MR(x)*R2);}
void init(){
    R=1ll;logR=0;modash=0;
    while(R<mod){R<<=1;logR++;}
    R2=R*R%mod;
    int t=0,r=R,i=1;
    while(r>1){
        if((t&1)==0){t+=mod;modash+=i;}
        t>>=1;r>>=1;i<<=1;
    }
}

vector<vl> mul(vector<vl> a, vector<vl> b){
  int n = a.size();
  vector<vl> ret(n,vl(n,0));
  REP(k,n)REP(i,n)REP(j,n){
    ret[i][j] += get_mod(a[i][k]*b[k][j]);
    if(ret[i][j]>=mod) ret[i][j] -= mod;
  }
  return ret;
}

int main(){
  int n,k,c,t;
  scanf("%d%d%d%d",&n,&k,&c,&t);
  // ????§???????
  // 0?§???????1?§????...4?§????????£??????§??\?????????????????°t?????§?????¨?????????
  vector<vl> mat(5*n,vl(5*n,0));
  // ??????????§?
  REP(i,4){
    REP(j,n) mat[i*n+j][(i+1)*n+j] += 1;
  }
  // ?????????????§?
  REP(_,k){
    int a,b,tm;
    scanf("%d%d%d",&a,&b,&tm);
    // --a; --b;
    --tm;
    REP(i,n){
      int from;
      if(i<b) from = i+a-1;
      else if(i<b+a-1) from = i-b;
      else from = i;
      int to = i;
      mat[tm*n+to][from] += 1;
    }
  }
  // REP(po,5*n){
  //   DEBUG_VEC(mat[po]);
  // }
  // cout<<endl;
  init();
  // ?´????
  vector<vl> ans(5*n,vl(5*n,0));
  REP(i,5*n) ans[i][i]=1;
  while(t){
    if(t&1) ans = mul(ans,mat);
    mat = mul(mat,mat);
    t>>=1;
  }
  // DEBUG
  // REP(po,5*n){
  //   DEBUG_VEC(ans[po]);
  // }
  cout<<ans[0][c-1]<<endl;
  return 0;
}

Measured memory_bytes: 2712