akhauriyash/Code-Regression huggingface dataset:
import Data.Bits

main = do
    [a, b] <- map read . words <$> getLine
    let ns = map (numBits a (b + 1)) [0..40]
        xs = map (\k -> if numBits a (b + 1) k `mod` 2 == 1 then 1 `shift` k else 0) $ [0..40]
    -- print (ns :: [Int])
    print $ sum (xs :: [Int])

roundDown :: Int -> Int -> Int
roundDown n k = n `div` k * k

roundUp :: Int -> Int -> Int
roundUp n k = (n + k - 1) `div` k * k

nextMultiple :: Int -> Int -> Int
nextMultiple n k = (n + k - 1)

-- numBits :: Int -> Int -> Int -> Int
-- numBits b e k = let twoPowK = 1 `shift` k
--                     twoPowKPlus1 = 1 `shift` (k + 1)
--                     m = b + roundDown (e - b) twoPowKPlus1
--                     m' = roundUp m twoPowK
--                     x = (m - b) `div` 2
--                     y = if m' `mod` twoPowKPlus1 == 0 then min m' e - m else min (m' + twoPowK) e - min m' e
--                     in x + y

numBits :: Int -> Int -> Int -> Int
numBits b e k = let twoPowK = 1 `shift` k
                    twoPowKPlus1 = 1 `shift` (k + 1)
                    b' = roundDown b twoPowKPlus1
                    b'' = b' + twoPowK
                    e' = roundUp e twoPowKPlus1
                    e'' = e' - twoPowK
                    x = (e' - b') `div` 2
                    y = max (e' - max e e'') 0
                    z = max (b - b'') 0
                    in x - y - z

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int main(){
  ll n, m;
  cin >> n;
  vll d(n);
  for (ll i = 0; i < n; i++) cin >> d[i];
  cin >> m;
  vll t(m);
  for (ll i = 0; i < m; i++) cin >> t[i];
  if (n < m) {
    cout << "NO" << endl;
    return 0;
  }
  
  sort(d.begin(), d.end());
  sort(t.begin(), t.end());
  
  ll idx = 0, cnt = 0;
  for (ll i = 0; i < m; i++) {
    for (ll j = idx; j < n; j++) {
      if (t[i] == d[j]) {
        idx = j + 1;
        cnt++;
        break;
      }
    }
  }
  
  if (cnt == m) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3328
H,W = map(int,input().split())
A = [list(input().strip()) for _ in range(H)]

for i in range(H-1,-1,-1):
    ind = 0
    for j in range(W):
        if A[i][j]!=".":
            ind = 1
            break
    if ind==0:
        A.pop(i)
for j in range(len(A[0])-1,-1,-1):
    ind = 0
    for i in range(len(A)):
        if A[i][j]!=".":
            ind = 1
            break
    if ind==0:
        for i in range(len(A)):
            A[i].pop(j)
for i in range(len(A)):
    x = ""
    for j in range(len(A[i])):
        x += str(A[i][j])
    print(x)

Measured memory_bytes: 3188
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line
}

fn compare(a: i32, b: i32) -> bool {
    a > b
}

fn main() {
    let mut nums: Vec<(i32, i32)> = Vec::new();

    loop {
        let entry: Vec<i32> = get_line().trim()
            .split_whitespace()
            .map(|e| e.parse().unwrap()).collect();
        if entry[0] == 0 && entry[1] == 0 {
            break;
        }

        if compare(entry[0], entry[1]) {
            nums.push((entry[1], entry[0]));
        } else {
            nums.push((entry[0], entry[1]));
        }
    }

    for t in &nums {
        println!("{} {}", t.0, t.1);
    }
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int A, B, C;
int l[9];
int main() {
    //cout.precision(10);
    cin >> N >> A >> B >> C;
    for(int i = 0; i < N; i++) {
        cin >> l[i];
    }
    int ans = INF;
    int mask = (1<<N) - 1;
    for(int bit1 = 1; bit1 < (1 << N); bit1++) {
        for(int bit2 = (1<<N) - 1; bit2 > 0; bit2 = (bit2 - 1) & bit1) {
            for(int bit3 = (1<<N) - 1; bit3 > 0; bit3 = (bit3 - 1) & bit2) {
                int bita = bit1 & (mask^bit2);
                int bitb = bit2 & (mask^bit3);
                int bitc = bit3;
                if((bita == 0) || (bitb == 0) || (bitc == 0)) continue;
                int a = 0;
                int b = 0;
                int c = 0;
                int counter = 0;
                for(int j = 0; j < N; j++) {
                    if((bita >> j) & 1) {a += l[j]; counter++;}
                    if((bitb >> j) & 1) {b += l[j]; counter++;}
                    if((bitc >> j) & 1) {c += l[j]; counter++;}
                }
                //cout << counter << " " << bita << " " << a << " " << bitb << " " << b << " " << bitc << " " << c << endl;
                int now = 10 * (counter - 3) + abs(a - A) + abs(b - B) + abs(c - C);
                ans = min(ans, now);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
const int MOD = 1000000007;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)

int main()
{
    int A[3][3];
    rep(i,3){
        rep(j,3){
            cin >> A[i][j];
        }
    }
    int n;
    cin >> n;
    rep(i,n){
        int b;
        cin >> b;
        rep(i,3){
            rep(j,3){
                if(b==A[i][j]){
                    A[i][j] = -1;
                }
            }
        }
    }
    if(A[0][0]==-1&&A[0][1]==-1&&A[0][2]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    if(A[1][0]==-1&&A[1][1]==-1&&A[1][2]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    if(A[2][0]==-1&&A[2][1]==-1&&A[2][2]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    if(A[0][0]==-1&&A[1][0]==-1&&A[2][0]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    if(A[0][1]==-1&&A[1][1]==-1&&A[2][1]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    if(A[0][2]==-1&&A[1][2]==-1&&A[2][2]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    if(A[0][0]==-1&&A[1][1]==-1&&A[2][2]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    if(A[0][2]==-1&&A[1][1]==-1&&A[2][0]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3608
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define MOD 1000000007
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
template<typename T> inline T gcd(T&a,T&b){return b==0?a:gcd(b,a%b);}
template<typename T> inline T lcm(T&a,T&b){return a/gcd(a,b)*b;}
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
int main(){
    int x,a,b;read(x),read(a),read(b);
    int dis1=abs(x-a),dis2=abs(x-b);
    if (dis1<dis2) puts("A");
    else puts("B");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 4e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 200005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
ll sqr(ll x)
{
    return x*x;
}
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;   cin>>n;
    vector<pair<ll,ll> > v;
    f(n){
        ll x,y;   cin>>x>>y;
        v.pb({y,x});
    }
    sort(all(v));
    ll time = 0;
    int f = 0;
    for(int i =0;i<(int)v.size();++i){
        time += v[i].ss;
        if(time > v[i].ff){
            f = 1;
            break;
        }
    }
    if(f){
        cout << "No";
    }
    else{
        cout << "Yes";
    }


    return 0;
}
    


Measured memory_bytes: 6512
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false); cin.tie(0);
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const int nmax = 1000;
int main() {
    IO;
    set <int> a;
    a.insert(1);
    for (int b = 2; b <= nmax; b++) {
        int tmp = b * b;
        while (tmp <= nmax) {
            a.insert(tmp);
            if (tmp * b > nmax) break;
            tmp *= b;
        }
    }
    int x; cin >> x;
    int res = -1;
    set <int> :: iterator it;
    for (it = a.begin(); it != a.end(); it++)
        if (*it <= x) {
            res = *it;
        }
        else break;
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    map<int,int>m;
    lli n;
    cin>>n;
    lli a[n],i,flag=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
        if(m[a[i]]>1)
         flag=1;
    }
    if(flag==1)
     cout<<"NO"<<"\n";
     else
       cout<<"YES"<<"\n";
}

Measured memory_bytes: 14516
#include <bits/stdc++.h>
using namespace std;
typedef long long llong;

llong gcd(llong x, llong y) {
    llong r;

    if (x<y) swap(x, y);
    
    while(y>0) {
        r = x % y;
        x = y;
        y = r;
    }

    return x;
}

bool isPrime(llong x) {
    llong i;
    if (x<2) return false;
    else if (x==2) return true;
    if (x%2==0) return false;
    for(i=3; i*i<=x; i+=2) {
        if(x%i==0) return false;
    }
    return true;
}

llong enumerate(llong N) {
    llong sqrt_N = sqrt(N) + 1; //素因数の個数の最大値sqrt(N)
    llong a = 0; //素因数の個数
    bool flag;
    
    for(llong i=2; i<=sqrt_N; i++) {
        flag = false;
        if(isPrime(i)) {
            while(N%i==0 && N!=1) {
              N /= i;
              flag = true;
            }
        }
        if(flag==true) a++;
        if(N==1) break;
    }

    if(isPrime(N)) a++;
    
    return a;
}

int main(void) {
  llong A, B;

  cin >> A >> B;

  llong G;
  G = gcd(A, B);

  cout << enumerate(G)+1 << endl;

  return (0);
}


Measured memory_bytes: 256
n = int(input())
arm = []
for i in range(n):
    x, l = map(int, input().split())
    arm.append([x-l, x+l])

arm.sort(key = lambda x: x[1])
ans = 0
now = -10**10
for i in range(n):
    if now <= arm[i][0]:
        ans += 1
        now = arm[i][1]

print(ans)


Measured memory_bytes: 21732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
#define pi (acos(-1))
///#define for(i,a,b) for(i=(a);i<(b);++i)
///freopen("input.txt","r",stdin);
///   freopen("output.txt","w",stdout);
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>s;
    reverse(s.begin(),s.end());
    string s1=s;
    reverse(s.begin(),s.end());
    if(s1!=s)
    {
        cout<<"No\n";
        return 0;
    }
    int n=s.length(),i;
    string s2;
    for(i=0; i<(n-1)/2; ++i)
        s2.pb(s[i]);
    reverse(s2.begin(),s2.end());
    string s3=s2;
    reverse(s2.begin(),s2.end());
    if(s3!=s2)
    {
        cout<<"No\n";
        return 0;
    }
    string s4;
    for(i=(n+3)/2-1; i<n; ++i)
        s4.pb(s[i]);
    reverse(s4.begin(),s4.end());
    string s5=s4;
    reverse(s4.begin(),s4.end());
    if(s5!=s4)
    {
        cout<<"No\n";
        return 0;
    }
    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n,m;
  cin>>n;
  map<int,int> memo1,memo2;
  for(int i=0;i<n;i++){
    int d;
    cin>>d;
    memo1[d]++;
  }
  cin>>m;
  for(int i=0;i<m;i++){
    int t;
    cin>>t;
    memo2[t]++;
  }
  bool ans=true;
  for(auto itr=memo2.begin();itr!=memo2.end();itr++){
    if(memo1[itr->first]<itr->second) ans=false;
  }
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


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

using namespace std;

int INF = 1e9 + 5;

int a[100005];

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        if (i-1 >= 0) {
            dp[i] = min(dp[i], dp[i-1] + abs(a[i] - a[i-1]));
        }
        if (i-2 >= 0) {
            dp[i] = min(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;
#define rep(i, n) for(i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x)*(x)
typedef long long ll;

void solve() {
    int n, m;
    cin >> n >> m;
    int count = 0;
    int i;
    rep(i, m) {
        int tmp;
        cin >> tmp;
        count += tmp;
    }

    if(n < count) {
        cout << -1;
    } else {
        cout << n-count;
    }
}

int main() {
    solve();
    return 0;
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    char s[n];
    cin >> s;
    bool ok = true;
    if(n % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    rep(i,0,n/2){
        if(s[i] != s[n/2+i]) ok = false;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N,length,maximum;
bool check[1100];

void func(){

	int read[N],write[N],read_sum = 0,write_sum = 0;

	for(int i = 0; i < N; i++){
		scanf("%d %d",&read[i],&write[i]);
		read_sum += read[i];
		write_sum += write[i];
	}

	sort(read,read+N,greater<int>());
	sort(write,write+N,greater<int>());

	if(N > 1 && read[0] >= read_sum-read[0]){

		length = read[0]-(read_sum-read[0]);

		if(write[N-1] <= length){

			check[0] = true;
			for(int i = 1; i <= length; i++)check[i] = false;
			check[write[N-1]] = true;
			maximum = write[N-1];

			for(int i = N-2; i >= 1; i--){
				if(write[i] > length)break;

				for(int k = length; k-write[i] >= 0; k--){
					if(check[k-write[i]] == true)check[k] = true;
				}
			}

			for(int k = maximum + 1; k <= length; k++){
				if(check[k]){
					maximum = k;
				}
			}

		}else{
			maximum = 0;
		}

		printf("%d\n",max(read_sum+write_sum,2*read[0]+write_sum-maximum));

	}else{
		if(N == 1){
			printf("%d\n",2*read[0]+write[0]);
		}else{
			printf("%d\n",read_sum+write_sum);
		}

	}

}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

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

using namespace std;

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

int main() {
  int H, W; cin >> H >> W;
  vector<string> a(H);
  rep(i, H) cin >> a.at(i);
  rep(i, H) a.at(i) = '#' + a.at(i) + '#';

  string frame;
  rep(i, W+2) frame += '#';

  cout << frame << endl;
  rep(i, H) {
    cout << a.at(i) << endl;
  }
  cout << frame << endl;
  return 0;
}


Measured memory_bytes: 256
import collections

n=int(input())
d=list(map(int, input().split())) 
mod= 998244353
ans=1 
if d[0]!=0:
    print(0)
    exit()
    
d.sort()
e = collections.Counter(d)
e = e.most_common()
e =list(e)
e.sort()

if d.count(0)!=1:
    print(0)
    exit()


for i in range(1,len(e)):
    if e[i][0]-e[i-1][0]!=1:
        print(0)
        exit()
    
    else:
        ans*=(e[i-1][1])**e[i][1]
        ans=ans%mod
print(ans)
        
    
    
    
    
    
        
    

 






        
    
    
    
    
    
        
    

 






        
        


        
    
    
    
    
    
        
    

 






        
    
    
    
    
    
        
    

 






        
        


        
    
    
    
    
    
        
    

 







Measured memory_bytes: 21980
# input
X, N = map(int, input().split())
P = list(map(int, input().split()))

# process
if N == 0:
    print(X)
else:
    P.sort()

    idx = N-1
    num = P[-1]
    for i in range(N):
        if X <= P[i]:
            idx = i
            num = P[idx]
            break

    for i in range(idx, -1, -1):
        if i == 0:
            low = P[i]-1
            break
        
        if P[i]-1 != P[i-1]:
            low = P[i]-1
            break

    for i in range(idx, N):
        if i == N-1:
            high = P[i]+1
            break
        
        if P[i]+1 != P[i+1]:
            high = P[i]+1
            break

    # output
    print(low if X-low <= high-X else high)


Measured memory_bytes: 9236
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N, A, B;
  cin >> N >> A >> B;

  ll train = N * A;
  if (train < B) {
    COUT(train);
  } else {
    COUT(B);
  }
  return 0;
}

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

/*
*/

ll a,b,c;

void init(){
	cin>>a>>b;
}

int main(void){
	init();
	cout<<(b==1?0:a-b)<<endl;
	return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()
a = b = 0
for s in S:
  if s == 'a' and a+b < A+B:
    print('Yes')
    a += 1
  elif s == 'b' and a+b < A+B and b < B:
    print('Yes')
    b += 1
  else:
    print('No')

Measured memory_bytes: 4016
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

struct Req{
  int a, b, c, d;
  Req(int a, int b, int c, int d) : a(a), b(b), c(c), d(d){}
};

vector<Req> query;

int n, m, q;
vector<int> perm;
vector<int> perm2;

ll calc(){
	ll ret = 0;
  	for(int i = 0; i < q; ++i){
  		int a = query[i].a;
  		int b = query[i].b;
  		int c = query[i].c;
  		int d = query[i].d;
  		if(perm2[b] - perm2[a] == c)ret += d;
  	}

    return ret;
}

int main(){
  cin >> n >> m >> q;
  perm.resize(n + m);
  perm2.resize(n);
  for(int i = 0; i < n; ++i)perm[i] = 0;
  for(int i = n; i < n + m; ++i)perm[i] = 1;
  for(int i = 0; i < q; ++i){
  	int a, b, c, d;
  	cin >> a >> b >> c >> d;
  	--a;
  	--b;
    query.push_back(Req(a, b, c, d));
  }

  ll ans = 0;
  do{
    if(perm[0] == 0)continue;

    int zero_cnt = 0;
    int cnt = 0;
    for(int i = 0; i < n + m; ++i){
      if(perm[i])++cnt;
      else{
        perm2[zero_cnt] = cnt;
        ++zero_cnt;
      }
    }

    ans = max(ans, calc());
  }while(next_permutation(perm.begin(), perm.end()));

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


Measured memory_bytes: 3588
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}



const ll N=1e5+5;

ll vis[600][600];

ll n,m,s,cnt,k;

//cnt goes from 1 to s-k.

char ch[600][600];

bool valid(ll x,ll y){
  if(vis[x][y])return false;
  if(ch[x][y]=='#')return false;
  if(x<1||x>n||y<1||y>m)return false;
  return true;
}

ll dx[]={1,-1,0,0};
ll dy[]={0,0,-1,1};

void dfs(ll x,ll y){
  cnt++;
  if(cnt>s-k)return;
  //cnt++;
  vis[x][y]=1;

  FOR(i,4){
    ll nx=x+dx[i],ny=y+dy[i];
    if(valid(nx,ny))dfs(nx,ny);
  }

}


int main()
{ 

IOS;

ll n;cin>>n;

ll c=0;

FOR(i,n){
  ll x;cin>>x;
  if(x&1)c=1;
}

if(c)cout<<"first";
else cout<<"second";


//end_routine();

return 0;
 
 }


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll x;std::cin >> x;
  set<ll> candi;
  candi.insert(1);
  for(int i=2;i<=33;i++){
    ll t = i;
    while(t<=x){
      t*=i;
      if(candi.find(t)==candi.end()&&t<=x) candi.insert(t);
    }
  }
  std::cout << *(--candi.end()) << '\n';
  return 0;
}


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

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> dp(n), cnt(n);
    cnt[0] = 1;
    if(a[0] == 0) dp[0] = 1, cnt[1]++;
    else dp[0] = 0;
    FOR(i, 1, n) {
        // if(cnt[a[i]] < 0) cnt[a[i]] = 0;
        dp[i] = dp[i-1] * cnt[a[i]] % MOD;
        if(a[i]+1 < n) cnt[a[i]+1]++;
        if(a[i]) cnt[a[i]]--;
    }
    dump(dp);

    ll ma = 0;
    cnt.assign(n, 0);
    REP(i, n) cnt[a[i]]++;
    REP(i, n) chmax(ma, cnt[i]);
    ll coff = 3;
    if(ma >= 4) coff = 0;
    else if(ma >= 2) coff = 6;
    else if(ma == 1) coff = 3;
    else coff = 0;
    cout << dp[n-1]*coff % MOD << endl;

    return 0;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =
				new BufferedReader(
						new InputStreamReader(System.in) );

		int n = Integer.parseInt( br.readLine() );
		String[] temp;

		int[] S = new int[n];
		temp = br.readLine().split(" ");
		for (int i=0; i < n; i++) {
			S[i] = Integer.parseInt(temp[i]);
		}

		int q = Integer.parseInt( br.readLine() );

		int[] T = new int[q];
		temp = br.readLine().split(" ");
		for (int i=0; i < q; i++) {
			T[i] = Integer.parseInt(temp[i]);
		}

		int count = 0;
		for (int i=0; i < T.length; i++) {
			for (int j=0; j < S.length; j++) {
				if (T[i] == S[j]) {
					count++;
					break;
				}
			}
		}

		System.out.println(count);
	}

}

Measured memory_bytes: 27444
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  ll n;
  cin>>n;
  vector<ll>march(5);
  for(int i=0;i<n;i++){
  	string s;
  	cin>>s;
  	s[0]=='M'?march[0]++:march[0]=march[0];
  	s[0]=='A'?march[1]++:march[1]=march[1];
  	s[0]=='R'?march[2]++:march[2]=march[2];
  	s[0]=='C'?march[3]++:march[3]=march[3];
  	s[0]=='H'?march[4]++:march[4]=march[4];
  }
  ll tot = 0;
  for(int a=0;a<5;a++){
  	 for(int b=a+1;b<5;b++){
  		for(int c=b+1;c<5;c++){
  			tot+=march[a]*march[b]*march[c];
  		}
  	}
  }
  cout<<tot<<endl;
}  



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

int main(){

    double a,b;
    cin >> a >> b;

    rep(i, 1001) {
        int at = i * 0.08;
        int bt = i * 0.1;
        if (a == at && b == bt) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
} 


Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;

int main(void) {
    string str;
    cin >> str;

    int zero = 0;
    int one = 0;

    for(int i=0; i<str.length(); i++) {
        if (str[i] == '0') {
            ++zero;
        }else {
            ++one;
        }
    }

    cout << (min(zero,one) * 2) << "\n";

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	long long int N,res=0,five;
	cin>>N;
	if(N%2==1)cout<<0;
	else{
		for(int i=1;i<=25;i++){
			five=1;
			for(int j=1;j<=i;j++)five*=5;
			res+=N/2/five;
		}
		cout<<res;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
class Dice {
private:
    void shift(int i, int j, int k, int l) {
        // i<-j<-k<-l<-i
        int t=a[i];a[i]=a[j];a[j]=a[k];a[k]=a[l];a[l]=t;
    }
public:
    int a[7]={0};
    void move(char d) {
        if(d=='N') shift(1,2,6,5);
        else if(d=='E') shift(1,4,6,3);
        else if(d=='W') shift(1,3,6,4);
        else if(d=='S') shift(1,5,6,2);
    }
};
int main() {
    Dice d; int n;
    for(int i = 1; i <= 6; ++i) cin >> d.a[i];
    cin >> n;
    string r[2][7] = {
        // 1<-1,2,3,4,5,6(2fix)
        {"","","","W","E","","WW"},
        // 2<-1,2,3,4,5,6
        {"","S","","WS","ES","SS","N"}
    };
    for(int i = 0, x, y, p, q; i < n; ++i) {
        cin >> x >> y;
        for(int j = 1; j <= 6; ++j) if(d.a[j]==y) {q=j;break;}
        for(int j = 0; j < r[1][q].length(); ++j) d.move(r[1][q][j]);
        for(int j = 1; j <= 6; ++j) if(d.a[j]==x) {p=j;break;}
        for(int j = 0; j < r[0][p].length(); ++j) d.move(r[0][p][j]);
        cout << d.a[3] << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void){
    int q;
    cin >> q;
    
    long long a, b;
    long long root;
    long long ans;
    int i;
    for(i = 1; i <= q; i++){
        cin >> a >> b;
        root = sqrt(a * b);
        if(root * (root + 1) == a * b){
            ans = root * 2 - 2;
        }else if(root * (root + 1) < a * b){
            ans = root * 2 - 1;
        }else if(a != b && root * root == a * b){
            ans = root * 2 - 3;
        }else{
            ans = root * 2 - 2;
        }
        
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}



//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}


int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 4; i++)
	{
		if (s[i] == '2') {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

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

	int ans = 0;

	char prev = 'X';
	int cnt = 0;

	for (auto c : S) {
		if (c == 'R') {
			if (c == prev) {
				++cnt;
			}
			else {
				cnt = 1;
			}
		}
		else {
			cnt = 0;
		}
		ans = max(ans, cnt);
		prev = c;
	}

	cout << ans << endl;
}


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

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

const int INF = 1000000007;

int main(void){
	int n,t,a;
	cin>>n;
	cin>>t>>a;
	int h[1010] = {0};
	for(int i=0;i<n;i++) cin>>h[i];

	double avet = 0.0;
	double ans = INF;
	int pos = 0;
	for(int i=0;i<n;i++){
		avet = t - h[i] * 0.006;
		if(abs(a - avet) < ans){
			ans = abs(a - avet);
			pos = i;
		}
	}

	cout<< pos + 1 <<endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main(){
	string a,b,c;
	char s,d,f;
	cin>>a>>b>>c;
	s=a[0],d=b[0],f=c[0];
	s-='a'-'A',d-='a'-'A',f-='a'-'A';
	cout<<s<<d<<f;
}

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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}
ll calc(ll a, ll b, ll x) { return (a * x) / b - a * (x / b); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = min(n, b - 1);

  cout << calc(a, b, x) << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
double pi=3.14159265;

int main(){
    int n;
    cin >> n;
    pair<char, int> p[n];
    rep(i,n) cin >> p[i].first >> p[i].second;
    rep(i,13){
        bool exist=false;
        rep(j,n){
            if(p[j].first == 'S' && p[j].second == i+1) exist=true;
        }
        if(!exist) cout << "S " << i+1 << endl;
    }
    rep(i,13){
        bool exist=false;
        rep(j,n){
            if(p[j].first == 'H' && p[j].second == i+1) exist=true;
        }
        if(!exist) cout << "H " << i+1 << endl;
    }
    rep(i,13){
        bool exist=false;
        rep(j,n){
            if(p[j].first == 'C' && p[j].second == i+1) exist=true;
        }
        if(!exist) cout << "C " << i+1 << endl;
    }
    rep(i,13){
        bool exist=false;
        rep(j,n){
            if(p[j].first == 'D' && p[j].second == i+1) exist=true;
        }
        if(!exist) cout << "D " << i+1 << endl;
    }
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <map>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <set>
#include <stack>
#include <stack>
#include <list>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>

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

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

int main(){
    
    int m, f, r;
    int n = 50;
    string Grade[50] = {};
    int num;
    
    rep(i, n){
        cin >> m >> f >> r;
        num = i;
        if(m == -1 && f == -1 && r == -1) break;
        else if(m == -1 || f == -1) Grade[i]="F";
        else if((m+f)>=80) Grade[i]="A";
        else if((m+f)>=65) Grade[i]="B";
        else if((m+f)>=50) Grade[i]="C";
        else if((m+f)>=30 && r >= 50) Grade[i]="C";
        else if((m+f)>=30) Grade[i]="D";
        else if((m+f)<30) Grade[i]="F";
    }
    
    rep(j,num){
        cout << Grade[j] << endl;
    }
       
    return 0;
}



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

using namespace std;

#define whole(xs) (xs).begin(), (xs).end()

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    int N;
    vector<int> A;
    void input() {
        cin >> N;
        A.resize(N); cin >> A;
    }

    const int INF = 1<<28;

    int cost(int x, int y) {
        int ret = 0;
        int c = 0;
        for (int i = 0; ; i++) {
            if (x == 0 && y == 0 && c == 0) break;
            int xi = x % 10; x /= 10;
            int yi = y % 10; y /= 10;
            ret += xi * yi + c;
            if (xi + yi + c >= 10) c = 1;
            else c = 0;
        }
        return ret;
    }

    void solve() {

        vector<int> sum(N + 1, 0);
        for (int i = 0; i < N; i++) {
            sum[i + 1] = sum[i] + A[i];
        }

        vector< vector<int> > dp = vector< vector<int> >(N, vector<int>(N + 1, INF));

        for (int i = 0; i + 1 <= N; i++) {
            dp[i][i + 1] = 0;
        }

        for (int k = 2; k <= N; k++) {
            for (int i = 0; i + k <= N; i++) {
                for (int j = 1; j < k; j++) {
                    dp[i][i + k] = 
                        min (
                            dp[i][i + k], 
                            dp[i][i + j] + dp[i + j][i + k] + cost(sum[i + j] - sum[i], sum[i + k] - sum[i + j])
                        );
                }
            }
        }
        cout << dp[0][N] << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}

Measured memory_bytes: 3284
gets
v=gets.split.map &:to_i
o=Hash.new{0}
e=Hash.new{0}
o[0]=e[0]=0
1.step(v.size,2){|i|
  o[v[i]]+=1
  e[v[i-1]]+=1
}
o=o.sort{|(k1,v1),(k2,v2)| v2<=>v1}
e=e.sort{|(k1,v1),(k2,v2)| v2<=>v1}
p v.size - (o[0][0]==e[0][0] ? [o[0][1]+e[1][1],o[1][1]+e[0][1]].max : o[0][1]+e[0][1])


Measured memory_bytes: 20344
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
using namespace std;
using vi = vector<int>;

int abs(int x, int y){
    int r = (x>y) ? x-y : y-x;
    return r;
}

int main(void){
    int n;
    cin >> n;
    int pt = 0, px = 0, py = 0;
    bool suc = true;
    for(int i=1; i<=n; i++){
        int t, x, y;
        cin >> t >> x >> y;
        int dr = abs(x, px) + abs(y, py);
        int dt = t - pt;
        if(dt >= dr && dt%2 == dr%2){
            pt = t;
            px = x;
            py = y;
            continue;
        }
        suc = false;
        break;
    }
    if(suc) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
long i,j,k,p[8],c[8],c0,n,kk;
while(cin>>p[0]){
for(i=1;i<8;i++)cin>>p[i];
c[0]=c[2]=c[4]=c[6]=1;
c[1]=c[3]=2;
c[5]=c[7]=4;
for(k=0;k<8;k++){
for(j=0,i=0;i<8;i++)if(p[i]>c[i])j+=p[i]-c[i];
if(k==0){n=j;kk=k;}
else if(n>j){n=j;kk=k;}
else if(n==j){
if(kk==1&&(k==2||k==4||k==6))kk=k;
else if(kk==3&&(k==4||k==6))kk=k;
else if(kk==4&&k==6)kk=k;
else if(kk==5&&(k==6||k==7))kk=k;
}
c0=c[0];for(i=0;i<7;i++)c[i]=c[i+1];c[7]=c0;
}
for(k=0;k<kk;k++){
c0=c[0];for(i=0;i<7;i++)c[i]=c[i+1];c[7]=c0;
}
cout<<c[0];
for(i=1;i<8;i++)cout<<" "<<c[i];
cout<<endl;
}
return 0;
}

Measured memory_bytes: 1160
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B = IL()

if 6 <= A <= 12:
    B //= 2
if A <= 5:
    B = 0
print(B)

Measured memory_bytes: 21880
def uni(t, l):
    if len(l) < 2:
        return True
    else:
        for i in range(1, len(l)):
            if t[l[0]] != t[l[i]]:
                return False
            else:
                pass
        return True

s = input()
t = input()

l = 'abcdefghijklmnopqrstuvwxyz'

flag = True

for x in l:
    tmp = []
    for i,y in enumerate(t):
        if y == x:
            tmp.append(i)
#    print(x)
#    print(tmp)
    if not uni(s, tmp):
        flag = False

for x in l:
    tmp = []
    for i,y in enumerate(s):
        if y == x:
            tmp.append(i)
    if not uni(t,tmp):
        flag = False

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7588
n=int(input())
l=list(map(int,input().split()))
b=True
ans=[]
for i in range(n):
  index=-1
  for j in range(n-i):
    if l[j]>j+1:
      b=False
      index=-1
      break
    if l[j]==j+1:
      index=j
  if index==-1:
    b=False
    break
  ans.append(l[index])
  del l[index]
if not b:
  print(-1)
else:
  for i in range(1,n+1):
    print(ans[-i])

    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

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

  map<ll, ll> mp;
  ll mi = inf;
  rep(i, n) {
    mi = min(mi, a[i]);
    mp[a[i]-mi]++;
  }

  cout << (*mp.rbegin()).second << endl;

  return 0;
}


Measured memory_bytes: 10352
io = STDIN
SAME={}
def check(s,t)
  hash={}
  s.zip(t) do |i,j|
    if i==j
      SAME[i]=true
      next
    end
    return 'No' if SAME.has_key?(i)
    return 'No' if SAME.has_key?(j)
    if hash.has_key?(i)
      return 'No' if hash[i]!=j
    else
      return 'No' if hash.values.include?(j)
      hash[i]=j
    end
  end
  'Yes'
end
s=io.gets.chomp.chars
t=io.gets.chomp.chars
puts check(s,t)


Measured memory_bytes: 22780
#include <iostream>

using namespace std;
long long int arr[5];
int main()
{
    long long int N;
    cin >> N >> arr[0] >> arr[1]>> arr[2]>> arr[3]>> arr[4];

    int m = 0;
    long long int m_val = arr[0];

    for (int i = 0; i < 5; i++)
    {
        if (arr[i] < m_val)
        {
            m = i;
            m_val = arr[i];
        }
    }

    if (N%arr[m]!=0)
    {
        cout << N/arr[m] +5  <<endl;
    }
    else
    {
        cout << N/arr[m] +4  <<endl;
    }

    return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())

field = [[s for s in input()] for _ in range(h)]

tmp = ["" for _ in range(w)]
for i in range(h):
    for j in range(w):
        tmp[j] += field[i][j]

row = [s.count("#") == 0 for s in field]
col = [s.count("#") == 0 for s in tmp]

for i,r in enumerate(row):
    for j,c in enumerate(col):
       if not (r or c):
           print(field[i][j],end="")

    print()

Measured memory_bytes: 4468
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const ll MOD = 1000000007;

int main() {
	ll H, W, K;
	cin >> H >> W >> K;
	K--;

	if (W==1){
		cout << 1 << "\n";
		return 0;
	}

	//事前計算
	vector <ll> NN(W);
	vector <ll> YN(W);
	vector <ll> NY(W);
	for (int n = 0; n < (1<<(W-1)); ++n){
		bitset< 1<<8 > bs(n);

		bool ok = true;
		for (int ii = 0; ii < W-2; ++ii){
			if (bs[ii] && bs[ii+1]){
				ok = false;
				break;
			}
		}
		if (!ok) continue;

		//x=0のケース
		if (bs[0]){
			NY[0]++;
		} else {
			NN[0]++;
		}

		//x=W-1のケース
		if (bs[W-2]){
			YN[W-1]++;
		} else {
			NN[W-1]++;
		}

		//それ以外のケース
		for (int ii = 1; ii < W-1; ++ii){
			if (!bs[ii-1] && !bs[ii]){
				NN[ii]++;
			} else if (bs[ii-1]) {
				YN[ii]++;
			} else {
				NY[ii]++;
			}
		}
	}

	//計算
	vector<vector<ll>> dp(H+1, vector <ll> (W));
	dp[0][0] = 1;
	for (int y = 0; y < H; ++y){
		for (int x = 0; x < W; ++x){
			dp[y+1][x] = (dp[y+1][x] + dp[y][x] * NN[x]) % MOD;
			if (x-1 >= 0){
				dp[y+1][x] = (dp[y+1][x] + dp[y][x-1] * YN[x]) % MOD;
			}
			if (x+1 < W){
				dp[y+1][x] = (dp[y+1][x] + dp[y][x+1] * NY[x]) % MOD;
			}			
		}
	}

	cout << dp[H][K] << "\n";

	return 0;
}


Measured memory_bytes: 3592
var a,b,c,d,e,i,j,k:longint;
    x:array[0..10000] of longint;
begin
readln(k);
for i:=1 to k do
 read(x[i]);
for i:=1 to k-1 do
 for j:=i+1 to k do
 if x[i]<x[j] then
  begin
   c:=x[i];
   x[i]:=x[j];
   x[j]:=c;
  end;
for i:=1 to k do
 if i mod 2=0 then
    d:=d+x[i]
   else
    b:=b+x[i];
 e:=b-d;
   writeln(e);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;


int main() {
  int h , n ;
  cin >> h >> n ;
  
  int sum=0;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
    sum+=vec.at(i);
  }
  
  if(h<=sum){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	long long n,m,x,y;
	cin>>n>>m;
	long long a[n+1]={0};
	for(long long i=0;i<m;i++)
	{
		cin>>x>>y;
		a[x-1]++;
		a[y]--;
	}
	long long c=0;
	//cout<<a[0]<<" ";
	for(long long i=1;i<n;i++)
	{
		a[i]=a[i]+a[i-1];
		if(a[i]==m)
		{
			c++;
		}
		//cout<<a[i]<<" ";
	}
	if(a[0]==m)
	{
		c++;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<numeric>
#include<functional>
int main(){
    int n,m;
    std::cin >> n >> m;
    std::vector<int>v(n+2,0);
    for(int i = 0; i < m; ++i){
        int l,r;
        std::cin >> l >> r;
        --l;
        v[l]++; v[r]--;
    }
    for(int i = 0; i < n+1; ++i)v[i+1] += v[i];
    auto f = [=](int ans, int e){ return ans += (e == m);};
    std::cout << std::accumulate(v.begin(),v.end(),0LL,f) << std::endl;
}



Measured memory_bytes: 640
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

  for(i=0; i<n; i++) {
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2072
n, k, c = gets.split.map(&:to_i)
s = gets.chomp.split('')

s.length.times do |i|
end

i = 0
kk = k
lefts = []
while(kk>0) do
  if s[i] != 'x'
    kk -= 1
    lefts.push(i)
    i += c
  end
  i+= 1
end
i = n - 1
kk = k
rights = []
while(kk>0) do
  if s[i] != 'x'
    kk -= 1
    rights.unshift(i)
    i -= c
  end
  i -= 1
end
k.times do |i|
  if lefts[i] == rights[i]
    puts lefts[i] + 1
  end
end

Measured memory_bytes: 21756