akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

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

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

class SegmentTree {
    public :
        vecllong __data;
        llong __size;

        SegmentTree (llong size) {
            // 完全二分木にする
            llong binSize = 0;
            while((1 << binSize) < size) {
                binSize++;
            }
            this->__size = (1 << (binSize));

            this->__data = vecllong(this->__size * 2, 0);
        };

        void init (llong size) {
            // 完全二分木にする
            llong binSize = 0;
            while((1 << binSize) < size) {
                binSize++;
            }
            this->__size = (1 << binSize);

            this->__data.resize(this->__size);
            for(llong i = 0; i < this->__size; i++) {
                this->__data[i] = 0;
            }
        };

        /* メソッド */
        void update(llong index, llong value) {
            index += this->__size - 1;
            this->__data[index] = value;
            while(index > 0) {
                index = (index - 1) / 2;
                this->__data[index] = max(this->__data[index * 2 + 1], this->__data[index * 2 + 2]);
            }
        };

        llong __query(llong qLeft, llong qRight, llong node, llong left, llong right) {
            if(right <= qLeft || qRight <= left) return 0;
            if(qLeft <= left && right <= qRight) return this->__data[node];

            llong leftVal = this->__query(qLeft, qRight, node * 2 + 1, left, (left + right) / 2);
            llong rightVal = this->__query(qLeft, qRight, node * 2 + 2, (left + right) / 2, right);
            return max(leftVal, rightVal);
        }

        // return max[left, right)
        llong query(llong left, llong right) {
            return this->__query(left, right, 0, 0, this->__size);
        };
};

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

    llong N;
    cin >> N;

    vecllong height(N);
    FOR(i, N) {
        cin >> height[i];
    }

    vecllong beauty(N);
    FOR(i, N) {
        cin >> beauty[i];
    }

    SegmentTree dp(N + 1);

    FOR(i, N) {
        llong a = beauty[i] + dp.query(0, height[i]);
        dp.update(height[i], a);
    }

    llong ans = dp.query(1, N + 1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7552
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut points: Vec<(isize, isize, isize)> = Vec::new();
    for _ in 0..n {
        let xi: isize = iterator.next().unwrap().parse().unwrap();
        let yi: isize = iterator.next().unwrap().parse().unwrap();
        let hi: isize = iterator.next().unwrap().parse().unwrap();
        points.push((xi, yi, hi));
    }
    points.sort_by_key(|p| -p.2);

    for cx in 0..=100 {
        for cy in 0..=100 {
            let p0 = points[0];
            let h = p0.2 + (cx - p0.0).abs() + (cy - p0.1).abs();
            let mut is_center = true;
            for i in 1..n {
                let p = points[i];
                let h_calc = max(h - (cx - p.0).abs() - (cy - p.1).abs(), 0);
                if h_calc != p.2 {
                    is_center = false;
                    break;
                }
            }
            if is_center {
                return format!("{} {} {}", cx, cy, h);
            }
        }
    }

    String::new()
}


Measured memory_bytes: 2172
loop do
  b,r,g,c,s,t = gets.split.map(&:to_i)
  break if (b|r|g|c|s|t)==0
  puts 100+15*5*b+15*b+15*r+15*3*r+7*g+2*c-3*(t-s)+5*b+3*r
end

Measured memory_bytes: 6080
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		int a,b;
		String op;


		do {
			a=sc.nextInt();
			op=sc.next();
			b=sc.nextInt();

				if(op.equals("+")){System.out.println(a+b);}
				if(op.equals("-")){System.out.println(a-b);}
				if(op.equals("*")){System.out.println(a*b);}
				if(op.equals("/")){System.out.println(a/b);}
		}
		while(!(op.equals("?"))) ;
	}
}



Measured memory_bytes: 26352
sx,sy,tx,ty = gets.split.map &:to_i
y = ty-sy
x = tx-sx
iki = 'U'*y + 'R'*x
kaeri = 'D'*y + 'L'*x
puts iki + kaeri + 'LU' + iki + 'RDRD' + kaeri + 'LU'

Measured memory_bytes: 1916
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
using System.Numerics;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var nk = Reads();
            var n = nk[0];
            var k = nk[1];
            var p = Reads();
            var e = new double[n];
            var sum = new double[n - k + 1];
            for (int i = 0; i < n; i++)
            {
                e[i] = (p[i] + 1) / 2.0;
            }
            for (int i = 0; i < k; i++)
            {
                sum[0] += e[i];
            }
            for (int i = 1; i < n-k+1; i++)
            {
                sum[i] = sum[i - 1] - e[i-1] + e[k+i-1];
            }
            WriteLine(sum.Max());









          
            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 38880
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = S()
    if "7" in n:
        print("Yes")
    else:
        print("No")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 81368
import math
from collections import defaultdict

n = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

divisor_primes = defaultdict(int)

def prime_factrizer(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

for a in A:
    factrized_a = prime_factrizer(a)
    for prime in factrized_a:
        divisor_primes[prime[0]] = max(divisor_primes[prime[0]],prime[1])

invs = [1] * (max(A) + 1)
for i in range(2, max(A) + 1):
    invs[i] = mod - invs[mod % i] * (mod//i) % mod

lcm = 1
for key in divisor_primes.keys():
    power = divisor_primes[key]
    div = 1
    for i in range(power):
        div *= key
        div %= mod
    lcm *= div

ans = 0

for a in A:
    ans += invs[a]
    ans %= mod
ans *= lcm
ans %= mod
print(ans)






Measured memory_bytes: 83972
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  ll n,x,t;
  cin>>n>>x>>t;
  
  cout<<(x+n-1)/x*t<<endl;

  return 0;
}

Measured memory_bytes: 3632
l, r = map(int, input().split())
interval = min(r - (l - 1), 2019)
min_remain = 2018
for i in range(l, l + interval):
    for j in range(i + 1, l + interval):
        if (i * j) % 2019 < min_remain:
            min_remain = (i * j) % 2019
print(min_remain)

Measured memory_bytes: 3060
from collections import Counter
 
N = int(input())
d = Counter(map(int, input().split()))
 
sticks_len = []
for k, v in d.items():
  if v >= 2:
    sticks_len.append(k)
  if v >= 4:
    sticks_len.append(k)
    
sticks_len.sort()
 
if len(sticks_len) >= 2:
  print(sticks_len[-1] * sticks_len[-2])
else:
  print(0)
 

Measured memory_bytes: 24104
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

int A, B, C, D, E, X, Y, Z, N, M;
string S, T;
void solve() {
	cin >> N >> M;
	print(N*(N - 1) / 2 + M * (M - 1)/2);
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



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

int main (){
    int a;
    int ans = 1000;
    char b[11];
    cin >> b;
    int i = 0;
    while (b[i+2] != '\0'){
        int x = b[i] - '0';
        int y = b[i+1] - '0';
        int z = b[i+2] - '0';
        int num = x*100 + y * 10 + z;
        if (num >= 753){
            a = num - 753;
        } else {
            a = 753 - num;
        }
        if (ans > a){
            ans = a;
        }
        i++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int n,a[200];
int solve(int,int);
int main()
{
  int q,m[200],i;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&m[i]);
    }
  
  for(i=0;i<q;i++)
    {
      if(solve(0,m[i])==1)printf("yes\n");
      else if(solve(0,m[i])==0) printf("no\n");
    }
  
  return 0;
}
int solve(int i,int m)
{
  int result;
  if(m==0)return 1;
  if(i>=n)return 0;
  result = solve(i+1,m)||solve(i+1,m-a[i]);
  return result;
}



Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

typedef pair<ll,ll> pl;

int main() {
  ll n,m;
  cin >> n >> m;

  vector<pl> p;

  rep(i,m) {
    ll a,b; cin >> a >> b;
    p.pb(make_pair(a,b));
  }

  sort(p.begin(), p.end(), [](const pl& x, pl& y) {return x.second < y.second;});


  ll tmp = 0, ans = 0;
  rep(i,m) {
    if (p[i].first >= tmp) {
      tmp = p[i].second;
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
#define maxv 100001
#define che 1LL<<32
#define mod 1000000007
ll power(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b=b/2;
    }
    return res%mod;
}
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll i;
    ll z=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(!a[i])
            z++;
    }
    if((n%2!=0&&z>1)||(n%2==0&&z>0))
    {
        cout<<"0";
        return 0;
    }
    ll t[n];
    for(i=0;i<n;i++)
        t[i]=abs(i-n+i+1);
    sort(t,t+n);
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        if(t[i]!=a[i])
            break;
    }
    if(i!=n)
    {
        cout<<"0";
        return 0;
    } 
    cout<<power(2,n/2)%mod;
}

Measured memory_bytes: 1792
W,H,N=map(int,input().split())
rec=[[0,0],[W,H]]

for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        rec[0][0]=max(rec[0][0],x)
    elif a==2:
        rec[1][0]=min(rec[1][0],x)
    elif a==3:
        rec[0][1]=max(rec[0][1],y)
    elif a==4:
        rec[1][1]=min(rec[1][1],y)

if (rec[1][0]-rec[0][0]) >=0 and (rec[1][1]-rec[0][1])>=0:
    ans=(rec[1][0]-rec[0][0])*(rec[1][1]-rec[0][1])
else:
    ans=-1
print(ans if ans>=0 else 0)

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

int main() {
	string s;
	ll cnt=0,n;
	cin>>n>>s;
	char now=s[0];
	for(int i=1;i<s.size();i++){
		if(now!=s[i]){
			cnt++;
			now=s[i];
		}
	}
	cout<<cnt+1;
	return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
inline int mex(unordered_set<int> st)
{
	int m = 0;
	while (st.find(m) != st.end())
	{
		m += 1;
	}
	return m;
}
inline int calculateGrundy(int n)
{
	if (n == 1)
		return 0;
	unordered_set<int> mexi;
	for (int i = 1; i <= sqrt(n); i += 1)
	{
		if (n % i == 0)
		{
			if (n / i != n)
				mexi.insert(calculateGrundy(n / i));
			mexi.insert(calculateGrundy(i));
		}
	}
	return mex(mexi);
}
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0),cin.tie(0);
	ll n, k;
	cin >> n >> k;
	ll count = 1;
	while (n >= k)
	{
		n /= k;
		count += 1;
	}
	cout << count;
	return 0;
}

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

using namespace std;

int main()
{
    string S;
    cin >> S;
    int count = 0;
    for (int i = 0; i < S.length() / 2; i++)
    {
        if (S[i] != S[S.length() - 1 - i])
            count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 1<<18;
int n, a[N][2];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, 1<<n) cin >> a[i][0];
  FOR(j, 0, n)FOR(i, 0, 1<<n)if(i&1<<j){
    int k = i^1<<j;
    maxs(a[i][1], a[i][0] + a[k][0]);
    maxs(a[i][0], a[k][0]);
  }
  int ans = 0;
  FOR(i, 1, 1<<n){
    maxs(ans, a[i][1]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A, B, C;
    cin >> A >> B >> C;
    if (min(A, B) <= C && C <= max(A, B)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

using namespace std;

int n;
vector<int> lis[100100];
int deg[100100];
vector<int> sco;

void dfs(int here, int p) {
    sco.push_back(deg[here]-2);
    for (int &there :lis[here]) {
        if (deg[there]==1||there==p) continue;
        dfs(there,here);
    }
}

int main() {
    int i;

    scanf("%d",&n);
    for (i=0;i<n-1;i++) {
        int a, b;
        scanf("%d%d",&a,&b);--a;--b;
        lis[a].push_back(b);
        lis[b].push_back(a);
        deg[a]++; deg[b]++;
    }
    if (n==2) {
        printf("1 2\n");
        return 0;
    }
    int st = -1;
    for (i=0;i<n;i++) {
        if (deg[i]==1) continue;
        int cnt = 0;
        for (int &v: lis[i]) if (deg[v]!=1) cnt++;
        if (!cnt) {
            printf("1 ");
            for (int j=3;j<n;j++) printf("%d ",j);
            printf("2 %d\n",n);
            return 0;
        }
        if (cnt>=3) {
            printf("-1\n");
            return 0;
        }
        if (cnt==1) st = i;
    }
    dfs(st,-1);
    int t = 0;
    for (i=0;i<sco.size();i++) {
        if (sco[i]!=sco[(int)sco.size()-1-i]) {
            if (sco[i]<sco[(int)sco.size()-1-i]) t = 0;
            else t = 1;
            break;
        }
    }
    if (t) reverse(sco.begin(),sco.end());
    int p = 1;
    printf("%d ",p); p++;
    for (i=0;i<sco.size();i++) {
        for (int j=0;j<sco[i];j++) printf("%d ",p+j+1);
        printf("%d ",p); p += sco[i]+1;
    }
    printf("%d\n",n);

    return 0;
}


Measured memory_bytes: 13432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans;
    
    if (a > b) {
        ans = 0;
    }
    else if (n < 2) {
        if (a == b) {
            ans = 1;
        }
        else {
            ans = 0;
        }
    }
    else if (n == 2) {
        ans = 1;
    }
    else {
        ans = (b * (n - 2)) - (a * (n - 2)) + 1;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 It's better to sleep happy and tired rather than disappointed and frustrated
 There's only 1 thing that's impossible and that is defeating a man who doesn't give up
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

const int inf=0x3f3f3f3f;
int n , ans , sum , a , b ,c ,arr[mx5];
string str;
 
int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{
		cin>>a>>b>>c;
		cout<<c<<" "<<a<<" "<<b;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int w, h, x, y, r;
  scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
  printf("%s\n",((w-r)>=x)&&((x-r)>=0)&&((h-r)>=y)&&((y-r)>=0)?"Yes":"No");
  return 0;
}

Measured memory_bytes: 584
n = input()
dp = [0,1]
ans = 0
for i in range(len(n)):
    cur1 = dp[0]
    cur2 = dp[1]
    if i != len(n)-1:
        dp[0] = min(cur1+int(n[i]), cur2+10-int(n[i]))
        dp[1] = min(cur1+int(n[i])+1, cur2+9-int(n[i]))
    else:
        ans = min(dp[0]+int(n[i]), dp[1]+10-int(n[i]))
print(ans)


Measured memory_bytes: 5492
import sys
fin = sys.stdin.readline
# from functools import lru_cache

N = int(fin())
happinesses = [tuple(int(elem) for elem in fin().split()) for _ in range(N)]

happinesses.sort(key=lambda x: sum(x), reverse=True)
score = sum(A for A, _ in happinesses[::2]) - sum(B for _, B in happinesses[1::2])
print(score)

Measured memory_bytes: 60636
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

const lt = "a < b"
const gt = "a > b"
const eq = "a == b"

func solve(a int64, b int64) string {
	if a < b {
		return lt
	}
	if a > b  {
		return gt
	}
	return eq
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	a := nextInt()
	b := nextInt()
	fmt.Fprintln(out, solve(a, b))
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes(n int64) []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}



Measured memory_bytes: 1108
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int N; cin >> N;
    VI X(N);
    REP(i, N) cin >> X[i];
    int ans = INF;
    FORS(i, 1, 100){
        int cost = 0;
        REP(j, N) cost += (X[j]-i)*(X[j]-i);
        chmin(ans, cost);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    long long d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d) cout<<"Yes\n";
    else cout<<"No\n";
}

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

    int t=1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

ll dp[10010];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll H, N; cin >> H >> N;
    vector<ll> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    Fill(dp, INF);
    dp[0] = 0LL;
    rep(i, N) {
        rep(j, H){
            chmin(dp[min(j+A[i], H)], dp[j] + B[i]);
        }
    }
    cout << dp[H] << endl;
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

struct data {
	int s, t, x;
} a[N];

bool comp(const data& a, const data& b) {
	return a.x < b.x;
}

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

	int n, q;
	cin >> n >> q;

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

	sort(a, a + n, comp);

	vector<int> d(q);
	for (int i = 0; i < q; i++) {
		cin >> d[i];
	}

	set<pii> S;
	for (int i = 0; i < q; i++) {
		S.insert({d[i], i});
	}

	vector<int> res(q, -1);
	for (int i = 0; i < n; i++) {
		auto itl = S.lower_bound({a[i].s - a[i].x, 0});
		auto itr = S.lower_bound({a[i].t - a[i].x, 0});
		for (auto it = itl; it != itr; it++) {
			res[it -> second] = a[i].x;
		}
		S.erase(itl, itr);
	}

	for (int i = 0; i < q; i++) {
		cout << res[i] << "\n";
	}
    return 0;
}

Measured memory_bytes: 22272
n=int(input())
mod=998244353
A=list(map(int,input().split()))
import sys
# mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as frac  #frac(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

C=Counter(A)
if A[0]!=0 or A.count(0)>1:
    print(0);exit()
Q=[C[i] for i in range(max(A)+1)]
#print(Q)
ans=1
for i  in range(len(Q)-1):
    ans*= pow(Q[i],Q[i+1],mod)
    ans%=mod

print(ans)


Measured memory_bytes: 103724
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n; cin >> n;
    vll a(n+1), b(n+1), c(n+1);
    rep(i, n) cin >> a[i+1] >> b[i+1] >> c[i+1];
    vll dpa(n+1, 0), dpb(n+1, 0), dpc(n+1, 0);
    FOR(i, 1, n+1) {
        dpa[i] = max(dpb[i-1], dpc[i-1]) + a[i];
        dpb[i] = max(dpc[i-1], dpa[i-1]) + b[i];
        dpc[i] = max(dpa[i-1], dpb[i-1]) + c[i];
    }
    cout << max({dpa[n], dpb[n], dpc[n]}) << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<cstdio>
#include<map>
#include<set>
using namespace std;
int main()
{
	int m,n,i,x,y,lx,ly;
	typedef pair<int,int>P;
	P a[200];
	while(scanf("%d",&m),m)
	{
		set<P>s;
		for(lx=ly=i=0;i<m;++i)
		{
			scanf("%d%d",&x,&y);
			a[i].first=x-lx,a[i].second=y-ly;
			lx=x,ly=y;
		}
		scanf("%d",&n);
		for(i=0;i<n;++i)
		{
			scanf("%d%d",&x,&y);
			s.insert(P(x,y));
		}
		for(set<P>::iterator z=s.begin();z!=s.end();++z)
		{
			P p(*z);
			for(i=1;i<m;++i)
			{
				p.first+=a[i].first;
				p.second+=a[i].second;
				if(s.find(p)==s.end()) goto NEXT;
			}
			printf("%d %d\n", z->first-a[0].first,z->second-a[0].second);
			break;
		NEXT:
			;
		}
	}
	return 0;
}

Measured memory_bytes: 0
def gcd(a, b):
	while b != 0:
		a, b = b, a%b
	return a

def lcm(a, b):
	return a*b//gcd(a, b)
	
def lcm_n(num):
	value = num[0]
	for item in num[1:]:
		value = lcm(value, item)
	return value

n = int(input())
t_list = [int(input()) for i in range(n)]
t_list = list(set(t_list))
targets = []
for t in t_list:
	flag = True
	for t2 in t_list:
		if t != t2 and t2 % t == 0:
			flag = False
			break
	if flag:
		targets.append(t)
print(lcm_n(targets))


Measured memory_bytes: 38512
import numpy as np
n,w=map(int,input().split())
wv=[]
for _ in range(n):
      wv.append(list(map(int,input().split())))
# dp[i]:価値の総和をちょうどiにできる最小の重さ総和
# dp[i]=w+1となる価値総和iにはできない。
# 求めるのはdp[i]<=wとなる最大のi
dp=np.full(10**5+1,w+1) # ndarray(1000,1000,...,1000])
dp[0]=0
# 10**5:viの総和の最大
for i in range(n):
      w_=wv[i][0]
      v_=wv[i][1]
      # i番目までの商品を取るか取らないかの全ての組み合わせをためすことができる。
      dp[v_:]=np.minimum(dp[v_:], dp[:-v_]+w_)
print(np.where(dp<=w)[0][-1])


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

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<pll> ab(N);
  for (ll i = 0; i < N; ++i) {
    ll a, b;
    cin >> a >> b;
    ab.at(i) = {a, b};
  }
  set<ll> remain;
  for (ll i = 1; i <= M; ++i) {
    remain.insert(i);
  }
  sort(ab.begin(), ab.end(), [] (pll a, pll b) {
    return a.second > b.second;
  });
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    auto index = remain.end();
    index--;
    if (ab.at(i).first > *(index)) {
      continue;
    }
    index = remain.lower_bound(ab.at(i).first);
    ans += ab.at(i).second;
    remain.erase(*index);
    if (remain.empty()) {
      break;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 6528
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

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

    if(s[2] == s[3] && s[4] == s[5]) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }

    return 0;
}





Measured memory_bytes: 888
import java.util.StringTokenizer;
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
/**
 *
 * @author wijebandara
 */
public class Main {
     public static void main(String[] args) {
        java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
        {
            try {
                String s =in.readLine();
                StringTokenizer st;
                while(s!=null)
                {
                    st = new StringTokenizer(s);
                    int p =Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken()) ;
                     
                    System.out.println((int)Math.log10(p)+1);
                    s =in.readLine();
                }
            } catch (Exception ex) {
                System.exit(0);
            }
             
             
        }
     }
}

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

int main() {
  int N;
  cin >> N;
  vector<long long> vec(N + 1);
  vec.at(0) = 2;
  vec.at(1) = 1;
  for(int i = 0; i < N + 1; i++) {
    if(i > 1) {
      vec.at(i) = vec.at(i - 1) + vec.at(i - 2);
    }
  }
  cout << vec.at(N) << endl;
}

Measured memory_bytes: 256
import time
st_time=time.time()

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
ts=time.time()
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
show_flg=True


a,b=MI()

if a<10 and b<10:
    print(a*b)
else:
    print(-1)

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

#define fr first
#define se second

using namespace std;

const long long N = 3e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int a[N];
int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n;
    for(int i = 1; i <= n; i ++){
        int x;
        cin >> x;
        a[x] ++;
    }
    sort(a + 1, a + n + 1);
    vector<int> p(n + 1, 0);
    for(int i = 1; i <= n; i ++){
        p[i] = p[i - 1] + a[i];
    }
    int res = n;
    for(int k = 1; k <= n; k ++){
        while(true){
            int l = 0, r = n;
            while(l < r){
                int m = (l + r) / 2;
                if(a[m + 1] < res){
                    l = m + 1;
                }
                else{
                    r = m;
                }
            }
            int s = p[l] + (n - l) * res;
            if(s >= k * res){
                break;
            }
            res --;
        }
        cout << res << "\n";
    }
}



Measured memory_bytes: 3200
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string ma;
	while (cin >> ma)
	{
		if (ma=="0")break;
		int sum = 0;
		for (int i = 0; i < ma.length(); i++)
			sum += (static_cast<int>(ma[i])-48);
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 1000000007;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  char x;
  cin >> x;
  if (x >= 'A' && x <= 'Z')
    cout << "A" ;
  else
    cout << "a";
}

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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



long long N;
int A[210], K[210];

string sente = "Takahashi";
string gote = "Aoki";

int g[1000];
int rec(int v, int k) {
    if (g[v] != -1) return g[v];
    if (v == 0) return 0;
    set<int> se;
    for (int i = 1; i <= v/k; ++i) {
        int val = rec(v - i, k);
        se.insert(val);
    }
    int res = 0;
    while (se.count(res)) ++res;
    return g[v] = res;
}

void testGrundy(int k) {
    memset(g, -1, sizeof(g));
    g[0] = 0;
    for (int i = 1; i <= 900; ++i) {
        cout << i << ": " << rec(i, k) << endl;
    }
}


int memo[210000];
int subGrundy(int a, int k) {
    if (a < k) return memo[a] = 0;
    if (a < 210000 && memo[a] != -1) return memo[a];
    if (a % k == 0) return a/k;
    
    int p = a/k;
    int res = subGrundy(a - p - 1, k);

    if (a < 210000) return memo[a] = res;
    else return res;
}



int Grundy(int a, int k) {
    if (a < k) return 0;
    if (a % k == 0) return a/k;
    
    memset(memo, -1, sizeof(memo));
    return subGrundy(a, k);
}


string solve() {
    int res = 0;
    for (int i = 0; i < N; ++i) {
        int tmp = Grundy(A[i], K[i]);
        res ^= tmp;
    }
    if (res) return sente;
    else return gote;
}

int main() {
    
    //testGrundy(12);
    
    
    while (cin >> N) {
        for (int i = 0; i < N; ++i) cin >> A[i] >> K[i];
        cout << solve() << endl;
    }
}






Measured memory_bytes: 2048
#include "bits/stdc++.h"

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//

unordered_set<ll> get_p(ll n) {
    ll s = sqrt(n) + 1;
    ll t = n;
    unordered_set<ll> res;
    res.insert(1);
    for (ll i = 2; i <= min(s,n); ++i) {
        while (t % i == 0) {
            res.insert(i);
            t /= i;
        }
    }
    if (t != 1) {
        res.insert(t);
    }
    return res;
}

int main() {
    IOS

    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    cout << get_p(g).size();

    return 0;

}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		
		System.out.println(Math.min(A, B) + Math.min(C, D));
	}
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n, k;
    cin >> n;
    cin >> k;
    priority_queue<int> H;
    for (int i = 0; i < n; i++)
    {
        int h;
        cin >> h;
        H.push(h);
    }
  	long long count = 0;
  	if ( k >= n){
      cout << 0 << endl;
    }
  	else{
      for (int j = 0; j < k; j++)
      {	
          H.pop();
      }
      while(!H.empty()){
          count = count + H.top();
          H.pop();
      }

      cout << count << endl;
    }
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


ll digit(ll num){
	ll ret=0;
	string s=to_string(num);
	return s.length();
}
	
class Edge{
public:
	ll num;
	ll a;
	ll b;
	ll color=0;
	Edge(ll _num,ll _a,ll _b){
		num=_num;
		a=_a;
		b=_b;
	}
};
	
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	ll N,K;
	cin>>N>>K;
	vector<ll>A(N);
	vector<ll>dp(N+1);
	dp[0]=0;
	for(int i=0;i<N;i++){
		cin>>A[i];
		A[i]--;
		A[i]%=K;
		dp[i+1]=(dp[i]+A[i])%K;
	}
	
	map< ll , ll >mp;
	ll ans=0;
	queue<ll>que;
	for(int i=0;i<=N;i++){
		
		ans+=mp[dp[i]];
		mp[dp[i]]++;		
		
		que.push(dp[i]);
		if(que.size()==K){
			mp[que.front()]--;
			que.pop();
		}
	}
	cout<<ans<<endl;
}



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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n,k;
  cin>>n>>k;
  string a[n];
  string b;
  for(int i=0;i<n;i++)
  {
      cin>>b;
      a[i]=b;
  }
  sort(a,a+n);
  for(int i=0;i<n;i++)
  cout<<a[i];
}


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

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int MOD = 1000000007;

ll N;
ll A[100010], B[100010], C[100010];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N;
	rep(i, N)cin >> A[i];
	rep(i, N)cin >> B[i];
	rep(i, N)cin >> C[i];
	sort(A, A + N); sort(B, B + N); sort(C, C + N);
	ll ans = 0;
	rep(i, N) {
		ll a = lower_bound(A, A + N, B[i]) - A;
		ll c = (N - (upper_bound(C, C + N, B[i]) - C));
		ans += max(0LL, a*c);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5964
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	lint N;
	lint H[100010]={};

	cin >> N;
	for(int i=1;i<=N;i++)
		cin >> H[i];
	
	bool ans=true;
	for(int i=1;i<=N;i++)
	{
		if(H[i]>H[i-1])H[i]--;
		if(H[i]<H[i-1])
		{
			ans=false;
			break;
		}
	}

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



Measured memory_bytes: 1024