akhauriyash/Code-Regression huggingface dataset:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    INF = 10**10
    N = NI()
    a = LI()
    a.sort()
    u = 2 ** 31
    ans = 0
    while u > 2:
        u /= 2
        j = N-1
        for i in range(N):
            if a[i] == INF: continue
            while j > i and a[i] + a[j] > u:
                j -= 1
            if j <= i: break
            if a[i] + a[j] == u:
                ans += 1
                a[i] = a[j] = INF

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 100960
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
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; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){

    ll N,ans=0;
    cin >> N;
    ll mini=INF;
    rep(i,N){
        ll p;
        cin >> p;
        mini=min(mini,p);
        if(mini==p) ans++;
    }
    cout << ans << endl;
}

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

int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	
	sort(a,a+n);
	int sum=0;
	for(int i=0;i<k;i++)
	  sum+=a[i];
	  
	cout<<sum<<endl;  
	
	return 0;   
}

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


void no(){
    cout << "NO" << endl;
}

int main(){
    int a,b,c;
    
    cin >> a >> b >> c;
    
    vector<int> abc = {a,b,c};
    
    sort(abc.begin(), abc.end());
    
    if(abc.at(0) == 5){
        if(abc.at(1) == 5){
            if(abc.at(2) == 7){
                cout << "YES" << endl;
            }
            else no();
        }
        else no();
    }
    else no();
}

Measured memory_bytes: 256
toInt :: String -> Int
toInt = read :: String -> Int

getCharacter :: Int -> Char
getCharacter n = ['a'..'z'] !! n

solve :: Int -> String
solve n
  | n == 0 = ""
  | otherwise = solve (div (n-1) 26) ++ [getCharacter (mod (n-1) 26)]

main = do
  n <- toInt <$> getLine
  putStrLn $ solve n

Measured memory_bytes: 3860
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    if v[0] + v[1] >= v[2] {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
N, K = list(map(int, input().split()))
h = list(map(int, input().split()))

dp = [0 for i in range(N)]
dp[1] = dp[0] + abs(h[1] - h[0])

for i in range(2, N):
    if (i-K < 0) :
        nums = list(range(i))
    else :
        nums = list(range(i-K, i))
    li = [dp[num] + abs(h[i] - h[num]) for num in nums]
    dp[i] = min(li)

print(dp[N-1])

Measured memory_bytes: 56160
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using Graph = vector<VE>;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k; cin >> n >> k;
	string s; cin >> s;
	int ans = 0;
	rep(i, n-1) {
		if (s[i] == s[i + 1])ans++;
	}
	cout << min(ans + 2 * k, n - 1) << endl;
	return 0;
}

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

def main():
    # 入力
    N = int(input())
    nums = list(map(int, input().split()))

    cnt = 0
    while len([x for x in nums if x % 2 == 1]) == 0:
        cnt += 1
        nums = [x/2 for x in nums]

    print(cnt)


main()


Measured memory_bytes: 2940
while(n,p=gets.split.map(&:to_i))!=[0,0]
	a=Array.new(n,0)
	a[0]=1
	i=0
	c=p-1
	while (c!=0 || a.count(0)!=n-1)
		i+=1
		i=0 if i>=n
		c>0 ? (a[i]+=1;c-=1) : (c+=a[i];a[i]=0)
	end
	puts i
end

Measured memory_bytes: 6100
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)

	for i := 1; i*(i+1) <= n*2; i++ {
		if i*(i+1) == n*2 {
			fmt.Fprintln(writer, "Yes")
			fmt.Fprintln(writer, i+1)
			ans := make([][]int, i+1)
			for ii := 0; ii < i+1; ii++ {
				ans[ii] = make([]int, i)
			}

			inc := 0
			for ii := 0; ii < i; ii++ {
				for iii := ii; iii < i; iii++ {
					inc++
					ans[ii][iii] = inc
					ans[iii+1][ii] = inc
				}
			}

			for ii := 0; ii < i+1; ii++ {
				fmt.Fprint(writer, i)
				for iii := 0; iii < i; iii++ {
					fmt.Fprint(writer, " ")
					fmt.Fprint(writer, ans[ii][iii])
				}
				fmt.Fprintln(writer, "")
			}
			writer.Flush()
			return
		}
	}
	fmt.Fprintln(writer, "No")
	writer.Flush()
}


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

using namespace std;

typedef long long ll;

const int N = 2010;
const ll INF = (ll) 1e18;

ll dp[N][N];
ll a[N];
ll b[N];

int main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    ll x;
    cin >> x;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    ll res = INF;
    for (int s = 0; s < n; s++) {
        ll cur = s * x;
        for (int i = 0; i < n; i++)
            cur += a[i];
        res = min(res, cur);
        for (int i = 0; i < n; i++)
            b[i] = min(a[i], a[(i + 1) % n]);
        for (int i = 0; i < n; i++)
            a[i] = b[i];
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    set<int> used;
    rep(i, N) used.insert(A[i]);
    if (used.size() == N) {
        cout << "YES" << '\n';
    }else{
        cout << "NO" << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back
#define PS string qqwwee;cin>>qqwwee;
typedef pair<int,int> pii;

__int128 Abs(__int128 t) {if(t<0) return -t;return t;}
__int128 calc(ll x,ll left,ll right,ll d) {
    return x+(__int128)(right-left)*d;
}
int main() {
    ll x,k,d;
    cin>>x>>k>>d;
    ll lo=0,hi=k;
    __int128 ans=1e18;
    while(hi-lo>3) {
        ll mid1=lo+(hi-lo)/3,mid2=hi-(hi-lo)/3;
        ans = min(Abs(calc(x,mid1,k-mid1,d)), ans);
        ans = min(Abs(calc(x,mid2,k-mid2,d)), ans);
        if(Abs(calc(x,mid1,k-mid1,d)) > Abs(calc(x,mid2,k-mid2,d))) {
            lo = mid1;
        } else {
            hi = mid2;
        }
    }
    for(ll i=lo;i<=hi;++i) ans=min(ans, Abs(calc(x,i,k-i,d)));
    cout << (ll)ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int gcd(int,int);

int main()
{
    int n,k,Max=0,Gcd=0;

    cin>>n>>k;

    while(n--)
    {
        int x;

        cin>>x;

        Max=max(Max,x);

        Gcd=gcd(Gcd,x);
    }

    if(k>Max || k%Gcd)
        cout<<"IMPOSSIBLE"<<endl;

    else
        cout<<"POSSIBLE"<<endl;

    return 0;
}

int gcd(int a,int b)
{
    if(a<b)
        swap(a,b);

    if(b==0)
        return a;

    return gcd(a%b,b);
}

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



int main(){
    int K,S,cn=0;cin>>K>>S;
    rep(i,0,K+1){
        rep(j,0,K+1){
            if(S-i-j>=0&&K>=S-i-j)cn++;
        }
    }
    cout<<cn<<endl;
}






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

int main(){
  string s;
  cin>>s;
  bool ans = true;
  if(s.at(2)!=s.at(3) ||s.at(4)!=s.at(5)){
    ans = false;
    }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc123/tasks/abc123_d

def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

X, Y, Z, K = MAP()
A = LIST()
B = LIST()
C = LIST()

# A.sort(reverse=True); B.sort(reverse=True); C.sort(reverse=True)

E = []
for a in A:
    for b in B:
        E.append(a+b)
E.sort(reverse=True)

ans = []

for c in C[:K]:
    for e in E[:K]:
        ans.append(c+e)
ans.sort(reverse=True)

for i, a in enumerate(ans):
    if i < K:
        print(a)
    else:
        break

Measured memory_bytes: 141896
#include <stdio.h>


int main(void) {
	// a + b = x
	// 2a + 4b = y
	// 2b = y -2x <- must be >= 0
	// b = (y - 2x) / 2 <- must be %2 == 0
	// a = x - b <- must be >= 0

	int x, y, z;
	scanf("%d %d", &x, &y);

	if ((z = y - 2 * x) >= 0 && z % 2 == 0 && x - z / 2 >= 0) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


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

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int a,b,c,k;cin>>a>>b>>c>>k;
  int ans=0;
  if(k<=a){
    ans+=k;
  }else{
    ans+=a;
    if(k>=a+b){
      ans-=(k-a-b);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
public class ABC125B {
    public static void Main() {
        int R, G, B, N, ans = 0;
        int rMax, gMax, bMax;
        string[] str = System.Console.ReadLine().Split(' ');
        R = int.Parse(str[0]);
        G = int.Parse(str[1]);
        B = int.Parse(str[2]);
        N = int.Parse(str[3]);

        rMax = N / R;
        for(int r = 0; r <= rMax; r++) {
            gMax = (N - R * r) / G;
            for(int g = 0; g <= gMax; g++) {
                if ((N - R * r - G * g) % B == 0)  {
                    ans++;
                }
            }
        }
        System.Console.WriteLine(ans);
    }
}

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

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 5999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

int w[310000], e[310000];
int main() {
	int n,ans = INF;
	string s;
	cin >> n >> s;
	REP(i, n) {
		if (s[i] == 'W') {
			w[i + 1] = w[i] + 1;
			e[i + 1] = e[i];
		}
		else {
			e[i + 1] = e[i] + 1;
			w[i + 1] = w[i];
		}
	}
	REPO(i, n) ans = min(ans, w[i - 1] + e[n] - e[i]);
	cout << ans << endl;

}

Measured memory_bytes: 3076
def solve():
    from sys import stdin
    f_i = stdin
    
    buttons = {
            '1': ".,!? ",
            '2': "abc",
            '3': "def",
            '4': "ghi",
            '5': "jkl",
            '6': "mno",
            '7': "pqrs",
            '8': "tuv",
            '9': "wxyz",
            }
    
    n = int(f_i.readline())
    
    ans = ""
    
    for i in range(n):
        code = f_i.readline().rstrip().split('0')
        
        for c in filter(lambda x: x != '', code):
            btn_chars = buttons[c[0]]
            idx = (len(c) - 1) % len(btn_chars)
            ans += btn_chars[idx]
            
        ans += '\n'
        
    print(ans, end='')

solve()


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

int main(){
    ll n, m; cin >> n >> m;
    ll ans =0;
    if(n>=m/2){
        ans = m/2;
    }else{
        ans += n;
        m -= 2*n;
        ans += m/4;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
3 2 0 = 2 //121 212
3 2 1 = 6 // 2*(2+1)
3 2 2 = 8 // 2^3

2通りとれるばしょ
4 2 1だとして
1121
ペアは3か所。そのうち1か所まで
2 * 

DP

DP[K]
DP[0] = M;
1回目のループ
DP[0] = DP[0] * (M-1)
DP[1] = DP[0];
DP(NK)になってまう

3 3 0
3 * 2 * 2
=12
3 3 1 = 3^2 3^(N-K)
3 3 2 = 3^1
330+
112
113
221
223
331
332
122
133
211
233
311
322
=9通り
3*3

3 3 2
=3通り

1=0+1
2=0+1+2

3 3 0 = 12
3 3 1 = 12 + 9同じペアをくっつけてカウント？
3 3 2 = 12 + 9 + 3

4 4 0 = 4*3*3*3
4 4 1 = 4 * 3 * 3 * 3C1 = (N-1)CK
4 4 2 = 4 * 3 * 2C2？
1122 1133
1112 1113とか
3通りある。3C2か
1123
1223
1233
1112
1222
1122
1111

4 4 0 = 4*3*3*3* 3C0//1234
4 4 1 = 4*3*3* 3C1//1123 1223 1233
4 4 2 = 4*3 * 3C2//1122 1112 1222
4 4 3 = 4 * 3C3 //1111
M * (M-1)^(N-1-K)*(N-1)CK

3 2 0 = 2 //121 212
2 * 1 * 1 * 2C0
*/

const int MAX = 210000;
const int MOD = 998244353;

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

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2; i<MAX; i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

ll COM(int n, int k){
  if(n<k)
    return 0;
  if(n<0 || k<0)
    return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  COMinit();
  
  ll N, M, K; cin >> N >> M >> K;
  ll ans = 0;
  vector<ll> Z(N+10, 1);
  rep(i, N){
    Z[i+1] = Z[i] * (M-1);
    Z[i+1] %= MOD;
  }
  for(ll k=K; k>=0; k--){
//cout << "k;"<<k<<" ans:"<<ans<<endl;
//M * (M-1)^(N-1-K)*(N-1)CK
    ll tmp = M * Z[N-1-k];
    tmp %= MOD;
    tmp *= COM(N-1, k);
    tmp %= MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    int a,b;
    cin >> a >> b;

    cout << (a+b) % 24 << endl;
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


// map の key, value を全て抜き出す。
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//     cout << "key" << itr->first << " value" << itr->second << endl;
// }

// 文字列の検索
// string s="abc";
// if (s.find('d') == string::npos){
//     cout << "find" << endl;
// }else{
//     cout << "not find" << endl;
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  string s; cin >> s;
  int digit = s.size();
  ll n = stoll(s);
  int ans = 0;
  rep(i,digit){
    int k = n % 10;
    n /= 10;
    if(i != digit-1){
      if(k != 9) n--;
      ans += 9;
    }else{
      ans += k;
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n;
	string s;
	cin >> n >> s;
	
	vi f(n), g(n);
	f[0] = (s[0] == 'W');
	For(i, 1, n) f[i] = f[i - 1] + (s[i] == 'W');
	g[n - 1] = (s[n - 1] == 'E');
	Doz(i, n - 1) g[i] = g[i + 1] + (s[i] == 'E');

	int ans = min(f[n - 2], g[1]);
	For(i, 1, n - 1) ans = min(ans, f[i - 1] + g[i + 1]);
	cout << ans << '\n';
}



Measured memory_bytes: 2964
n,a,b=map(int,input().split())
s=input()
yosen=0
kaigai=0
for ss in s:
  if ss=="a" and yosen<a+b:
    yosen+=1
    print('Yes')
  elif ss=="b" and yosen<a+b:
    if kaigai<b:
      yosen+=1
      kaigai+=1
      print('Yes')
    else:
      print('No')
  else:
    print('No')

Measured memory_bytes: 4016
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		sc.close();

		int[] cnt = new int[N];
		for ( int i = 1 ; i <= N ; i++ ) {
			LinkedList<Integer> q = new LinkedList<>();
			int[] d = new int[N+2];
			Arrays.fill(d, -1);
			d[0] = 1;
			d[N+1] = 1;
			d[i] = 0;
			q.add(i);
			while (q.size() > 0) {
				int cur = q.poll();
				int dn = d[cur] + 1;
				if ( d[cur-1] < 0 ) {
					d[cur-1] = dn;
					cnt[dn]++;
					q.add(cur-1);
				}
				if ( d[cur+1] < 0 ) {
					d[cur+1] = dn;
					cnt[dn]++;
					q.add(cur+1);
				}
				if ( cur == X && d[Y] < 0 ) {
					d[Y] = dn;
					cnt[dn]++;
					q.add(Y);
				}
				if ( cur == Y && d[X] < 0 ) {
					d[X] = dn;
					cnt[dn]++;
					q.add(X);
				}
			}
		}
		StringBuilder ans = new StringBuilder();
		for ( int i = 1 ; i < N ; i++ ) {
			ans.append(cnt[i] / 2);
			ans.append("\n");
		}
		System.out.println(ans);
	}
}


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

    #define all(v) v.begin(),v.end()
    #define rall(v) v.rbegin(),v.rend()
    #define trav(i,a) for(auto i: a)
    #define ff first
    #define ss second
    #define eb emplace_back
    #define tc(t) ll t; cin>>t; while(t--)
    #define prec(n) fixed<<setprecission(n)
    #define mst(arr,value) memset(arr,value,sizeof(arr))
    #define sz(a) a.size()
    #define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    
    const long long inf = (long long)1e18;
    const long long M = (long long)1e9+7;
    
    #define fab(i,a,b) for(ll i=a; i<b; i++)
    #define fba(i,b,a) for(ll i=b; i>=a; i--)

    ll mpw(ll a, ll b, ll M = inf) {
        if(b == 0) return 1;
        if(b % 2 == 1) 
            return a * mpw((a * a) % M, b / 2, M) % M;
        return mpw((a * a) % M, b / 2, M);        
    } 

    ll knapsack(vector<pair<ll, ll>> items, ll n, ll w) {
        ll ans = 0, sum = 0;

        fab(i, 0, n) {
            sum += items[i].ss;
        }
        vector<ll> dp(sum + 1, inf);
        dp[0] = 0;
        fab(i, 0, n) {
            ll wt = items[i].ff;
            ll vl = items[i].ss;
            fba(j, sum - vl, 0) {
                dp[vl + j] = min(dp[j] + wt, dp[vl + j]);
            }
        }
        fab(i, 0, sum + 1) {
            if(dp[i] <= w)
                ans = max(ans, i);
        }
        return ans;
    }

    int main() {
        fio

        ll n, w;
        cin >> n >> w;

        vector<pair<ll, ll>> items(n);

        fab(i, 0, n) { 
            cin >> items[i].ff >> items[i].ss;
        }

        cout << knapsack(items, n, w);

        
        return 0;
    }

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

string s, t;
vector<char>r;
int dp[3002][3002];

int main()
{
    cin>>s>>t;
    for(int i=1; i<=s.size(); i++)
    {
        for(int j=1; j<=t.size(); j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    int x=s.size();
    int y=t.size();
    while(dp[x][y]!=0)
    {
        if(s[x-1]==t[y-1])
        {
            r.push_back(s[x-1]);
            x--;
            y--;
        }
        else if(dp[x-1][y]>dp[x][y-1])
        {
            x--;
        }
        else
        {
            y--;
        }
    }
    for(int i=r.size()-1; i>=0; i--)
    {
        cout<<r[i];
    }
    return 0;
}


Measured memory_bytes: 35456
N, M = gets.split.map(&:to_i)
ab = []
N.times do
  ab.push gets.split.map(&:to_i)
end
abH = Hash.new(0)
ab.each do |a, b|
  abH[a] += b
end

sum = 0

m = M
abH.keys.sort.each do |a|
  if m > abH[a]
    sum += a * abH[a]
    m -= abH[a]
  else
    sum += a * m
    break
  end
end

ans = sum
print("#{ans}\n")


Measured memory_bytes: 18424
function main(arg) {
	arg = arg.trim().split("\n").map(Number)
	var k = arg.pop()
	var data = arg
	for (var i  = 0; i < data.length; i++) {
		for (var j = i + 1; j < data.length; j++) {
			var ans = Math.abs(data[i] - data[j])
			if (ans > k) {
				console.log(':(')
				return
			}
		}
	}
	console.log('Yay!')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]

D=N()
c=[0]+L()
s=[[0]*27]+[[0]+L() for i in range(D)]

dp=[]
T=[0]
ld=[0]*(27)
for i in range(1,D+1):
    ma=0
    t=0
    for j in range(1,27):
        tmp=s[i][j]+(i-ld[j])*(D-i+1)*c[j]
        if tmp>ma:
            ma=tmp
            t=j
    T.append(t)
    ld[t]=i
        
sc=sum(c)
def point():
    ld=[0]*(27)
    score=-sc*((D+1)*D//2)
    for i in range(1,D+1):
        t=T[i]
        score+=s[i][t]+(i-ld[t])*(D-i+1)*c[t]
        ld[t]=i
    return score

now=point()
import random
for i in range(80000):
    d,q=random.randrange(1,D+1),random.randrange(1,27)
    old=T[d]
    T[d]=q
    new=point()
    if new>now:
        now=new
    else:
        T[d]=old

for i in T[1:]:
    print(i)

Measured memory_bytes: 79696
from sys import stdin

def mpow(n, p, mod):
    if mod == 0:
        return 0
    r = 1
    while p > 0:
        if p & 1 == 1:
            r = r * n % mod
        n = n * n % mod
        p >>= 1
    return r
def popcount(u):
    if u == 0:
        return 0
    a = u % bin(u).count('1')
    return 1 + popcount(a)
def main():
    input = stdin.readline
    n = int(input())
    x = '0b' + input()
    xs = int(x, 0)
    xc = x.count('1')
    xsp = mpow(xs, 1, xc + 1)
    xsm = mpow(xs, 1, xc - 1)
    for i in range(2, n + 2):
        if x[i] == '0':
            y = xsp + mpow(2, n - i + 1, xc + 1)
            y = mpow(y, 1, xc + 1)
        elif xc == 1:
            print(0)
            continue
        else:
            y = xsm - mpow(2, n - i + 1, xc - 1)
            y = mpow(y, 1, xc - 1)
        print(popcount(y) + 1)
main()

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

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


Measured memory_bytes: 2128
// Oh boi here we go again
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

#define all(s) s.begin(), s.end()
#define ok puts("ok")
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >
#define pii pair < int, pi >
#define next next123
#define left left123

const int N = 2e5 + 7;
const ll mod = 1e9 + 7;

int h, w, n;

main(){
    cin >> h >> w >> n;
    if (h > w)
        swap(h, w);
    cout << (n + w - 1) / w;
}


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

using namespace std;

const int N = 2000 + 7;
const int MOD = 1000000000 + 7;

typedef long long ll;

ll f[N], finv[N], inv[N];

ll modinv(ll a) {
  ll b = MOD, x = 1, y = 0;
  //ax + by = 1 (mod MOD)
  //->find x
  while(b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    x -= t * y; swap(x, y);
  }
  x += MOD;
  x %= MOD;
  return x;
}

ll add(ll x, ll y) {
  x %= MOD;
  y %= MOD;
  return (x + y) % MOD;
}

ll sub(ll x, ll y) {
  x %= MOD;
  y %= MOD;
  x += MOD;
  return (x - y) % MOD;
}

ll mul(ll x, ll y) {
  x %= MOD;
  y %= MOD;
  return (x * y) % MOD;
}

ll bigdiv(ll x, ll y) {
  return mul(x, modinv(y));
}

void Cinit() {
  f[0] = 1; f[1] = 1;
  finv[0] = 1; finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < N; ++i) {
    f[i] = mul(f[i - 1], i);
    inv[i] = sub(MOD, mul(inv[MOD % i], MOD / i));
    finv[i] = mul(finv[i - 1], inv[i]);
  }
}

ll C(ll n, ll k) {
  if(n < k || n < 0 || k < 0) return 0;
  return mul(f[n], mul(finv[k], finv[n - k]));
}

int main() {
  Cinit();
  ll n, k;
  scanf("%lld %lld", &n, &k);
  for(int i = 1; i <= k; ++i) {
    if(i > 1) printf(" ");
    printf("%lld", mul(C(n - k + 1, i), C(k - 1, i - 1)));
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 256
import math
N=10000
prime=[1]*(N+1)
prime[0],prime[1]=0,0
for i in range(2,int(math.sqrt(N))):
    if prime[i]==1:
        j=i
        while i*j<=N:
            prime[i*j]=0
            j+=1

while True:
    n=input()
    if n==0:break
    for i in range(n,2,-1):
        if prime[i]==prime[i-2]==1:
            print i-2,i
            break

Measured memory_bytes: 4796
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N{}; cin >> N;
  vector<ull> A(N);
  for(auto& a : A) cin >> a;

  // ull seki = boost::accumulate(A, (ull)1, [](auto r, auto a){ return boost::integer::lcm(r, a); });
  // ull sum = boost::accumulate(A, (ull)0, [&seki](auto r, auto a){ return r + (seki / a); });

  typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;
  cpp_dec_float_1000 res{};
  for(const auto& a : A)
  {
    cpp_dec_float_1000 b(a);
    res += 1 / b;
  }
  res = 1 / res;
  // cpp_dec_float_1000 seki_f(seki);
  // cpp_dec_float_1000 sum_f(sum);
  // cpp_dec_float_1000 res = seki_f / sum_f;
  auto ans = res.str();
  cout << ans << CRLF;

  // long double ans = (long double)seki / (long double)sum;
  // cout << std::fixed << std::setprecision(7) << ans << CRLF;


  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 512
#include <cstdio>

using namespace std;

const int NMAX = 100000;

int f[NMAX+5];

int main()
{
    //freopen("test.in", "r", stdin);
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=0; i<m; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        f[x]++;
        f[y]++;
    }
    for(int i=1; i<=n; i++)
        if(f[i] % 2 == 1)
        {
            printf("NO\n");
            return 0;
        }
    printf("YES\n");
    return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W));
    rep(i, H) {
        rep(j, W) {
            cin >> a.at(i).at(j);
        }
    }

    vector<vector<char>> b(H + 2, vector<char>(W + 2));
    rep(i, H + 2) {
        rep(j, W + 2) {
            b.at(i).at(j) = '#';
        }
    }

    rep(i, H) {
        rep(j, W) {
            b.at(i + 1).at(j + 1) = a.at(i).at(j);
        }
    }

    rep(i, H + 2) {
        rep(j, W + 2) {
            cout << b.at(i).at(j);
        }
        cout << endl;
    }

    return 0;
}

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

#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
	int x;
	cin >> x;

	int xx = 0, i = 0;
	while (xx < x) {
		i += 1;
		xx += i;
	}

	cout << i << endl;

	return 0;
}

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

int main() {
  cout<<setprecision(10)<<fixed;
  long double w,h,x,y;
  cin>>w>>h>>x>>y;
  long double cenx=w,ceny=h;
  cenx/=2;
  ceny/=2;
  int hantei=0;
  if(x==cenx&&y==ceny){
    hantei=1;
  }
  long double ans=w*h;
  ans/=2;
  cout<<ans<<" "<<hantei<<endl;
}

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

using ll = long long;

int A , B , Q;

set < ll > s , t;

ll tmp(ll x){

    auto it = t.upper_bound(x);

    if(it == t.end())it --;

    ll ans = abs(x - *it);


    if(it != t.begin()){
        it --;
        ans = min(ans , x - *it);
    }

    if(it != t.begin()){
        it --;
        ans = min(ans , x - *it);
    }

    return ans;

}

ll sh(ll x){

    auto it = s.upper_bound(x);

    if(it == s.end())it --;

    ll ans = abs(x - *it);


    if(it != s.begin()){
        it --;
        ans = min(ans , x - *it);
    }

    if(it != s.begin()){
        it --;
        ans = min(ans , x - *it);
    }

    return ans;

}

main(){
    scanf("%d %d %d" , &A , &B, &Q);

    ll x;
    for(int i = 1 ; i <= A ; i ++){
        scanf("%lld" , &x);
        s.insert(x);
    }

    for(int i = 1 ; i <= B ; i ++){
        scanf("%lld" , &x);
        t.insert(x);
    }

    while( Q -- ){
        scanf("%lld" , &x);

        auto it  = s.upper_bound(x);
        auto it2 = t.upper_bound(x);

        if(it == s.end()){
            it --;
        }
        ll ans = abs(x - *it) + tmp(*it);
        if(it != s.begin())it --;
        ans = min(ans , abs(x - *it) + tmp(*it));
        if(it != s.begin())it --;
        ans = min(ans , abs(x - *it) + tmp(*it));

        ans = min(ans , abs(x - *it2) + sh(*it2));
        if(it2 != t.begin())it2 --;
        ans = min(ans , abs(x - *it2) + sh(*it2));
        if(it2 != t.begin())it2 --;
        ans = min(ans , abs(x - *it2) + sh(*it2));

        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    int A, B, T;
    cin >> A >> B >> T;
    cout << B * (T / A) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  long int a,b,ans,eve,n=100000000000;
  cin>>a>>b;
  long long int tree[120000];
  for(int i=0;i<a;i++){
    cin>>tree[i];
  }
  sort(tree,tree+a);
  for(int j=0;j<(a-b+1);j++){
    eve=tree[j+b-1]-tree[j];
    ans=min(eve,n);
    if(eve<=n)
      n=eve;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
<?php
$N = (int)fgets(STDIN);
$A = array_map(function ($n) {
    return (int)$n;
}, explode(' ', fgets(STDIN)));

if (array_search(0, $A)) {
    echo 0;
    return;
}

$ans = 1;
foreach ($A as $a) {
    $ans *= $a;
    if ($ans > 1000000000000000000) {
        echo '-1';
        return;
    }
}

echo $ans;

Measured memory_bytes: 28960
#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 <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	//入力
	int A, B;
	string S;
	cin >> A >> B >> S;

	if (S[A] == '-') {
		for (int i = 0; i < A + B + 1; i++) {
			if (i != A) {
				if (S[i] == '-') {
					cout << "No";
					return 0;
				}
			}
		}
	}
	else {
		cout << "No";
		return 0;
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
#define N 8
#define free -1
#define notfree 1
#define FALSE 2
#define TRUE 3
 
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int X[N][N];
 
void initialize(void);
void printboard(void);
void recursive(int);
 
int main(){
  int i,j,k,r,c;
 
  initialize();
 
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      X[i][j] = FALSE;
 
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d %d",&r,&c);
    X[r][c] = TRUE;
  }
 
  recursive(0);
 
  return 0;
}
 
void initialize(){
  int i;
 
  for(i=0;i<N;i++){
    row[i] = free;
    col[i] = free;
  }
 
  for(i=0;i<2*N-1;i++){
    dpos[i] = free;
    dneg[i] = free;
  }
}
 
void printboard(){
  int i,j;
 
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      if(X[i][j] == TRUE){
    if(row[i] != j)return;
      }
 
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
 
void recursive(int i){
  int j;
 
  if(i == N){
    printboard();
    return;
  }
 
  for(j=0;j<N;j++){
    if(notfree == col[j] || notfree == dpos[i+j] || notfree == dneg[i-j+N-1])continue;
    row[i] =j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = notfree;
    recursive(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = free;
  }
}


Measured memory_bytes: 2108
#include <stdio.h>

int main()
{
	int i, H, W, K;
	char c[8][8];
	scanf("%d %d %d", &H, &W, &K);
	for (i = 1; i <= H; i++) scanf("%s", &(c[i][1]));
	
	int j, flag[16] = {}, ans = 0, count;
	while (flag[H+W+1] == 0) {
		count = 0;
		for (i = 1; i <= H; i++) {
			if (flag[i] == 0) continue;
			for (j = 1; j <= W; j++) {
				if (flag[H+j] == 1 && c[i][j] == '#') count++;
			}
		}
		if (count == K) ans++;
		
		for (i = 1; flag[i] == 1; i++);
		for (flag[i--] = 1; i >= 1; flag[i--] = 0);
	}
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1712
n, h = map(int, input().split())
a, b = [0]*n, [0]*n
for i in range(n):
  a[i], b[i] = map(int, input().split())

a_max = max(a)
b = sorted(b, reverse=True)
b_throw = [bi for bi in b if bi > a_max]

ans = 0
for k in b_throw:
  h -= k
  ans += 1
  if h <= 0: break

if h > 0:
  ans += (h + a_max - 1) // a_max

print(ans)

Measured memory_bytes: 12040
#include<bits/stdc++.h>
using namespace std;
int main(){
int64_t x;
  cin>>x;
  x--;
  int64_t ans=(x/11)*2;
  if((x%11)<=5)
    cout<<ans+1<<endl;
  else
    cout<<ans+2<<endl;

    return 0;
}

Measured memory_bytes: 256
// In the name of Allah. Ya ali!
#include<bits/stdc++.h>
#define double long double
typedef long long ll;
const ll MAX_N = 2e5+10;
const ll MOD = 1e9+7;
using namespace std;

ll dp[MAX_N];
ll sum[MAX_N];
int n,m;

ll solve(ll lim)
{
    if (n&1)
        return 0;
    dp[1] = 1;
    dp[3] = 1;
    sum[1] = 1;
    sum[3] = 2;
    for(int i = 5;i<=n+1;i+=2)
    {
        dp[i] = sum[i-2];
        if (i-2>lim)
            dp[i] = (dp[i]-sum[i-lim-3]+MOD)%MOD;
        sum[i] = (sum[i-2]+dp[i])%MOD;
    }
    ll ans = 0;
    ans = dp[n+1];
    for(ll i = 1;i<=lim;i+=2)
    {
        ans += (i*dp[n-i])%MOD;
        ans %= MOD;
    }
    return ans;
}

int main()
{
    cin >> n >> m;
    string s;
    cin >> s;
    if (s[0]=='B')
    {
        for(int i = 0;i<m;++i)
        {
            if (s[i]=='B')
                s[i] = 'R';
            else
                s[i] = 'B';
        }
    }
    bool ok = false;
    for(int i = 0;i<m;++i)
        ok |= (s[i]=='B');
    if (!ok)
    {
        dp[1] = 1;
        dp[3] = 1;
        sum[1] = 1;
        sum[2] = 1;
        sum[3] = 2;
        for(int i = 4;i<=n+1;++i)
        {
            dp[i] = sum[i-2];
            sum[i] = (sum[i-1]+dp[i])%MOD;
        }
        ll ans = dp[n+1]+1;
        for(ll i = 1;i<n;++i)
        {
            ans += (i*dp[n-i])%MOD;
            ans %= MOD;
        }
        cout << ans;
        return 0;
    }
    for(int i = m-1;i>=0;--i)
    {
        if (s[i]=='B')
        {
            m = i+1;
            break;
        }
    }
    vector<int> vc;
    int cnt = 0;
    for(int i = 0;i<m;++i)
    {
        if (s[i]=='B')
        {
            if (cnt)
                vc.push_back(cnt);
            cnt = 0;
        }
        else
            cnt++;
    }
    ok = false;
    for(auto x:vc)
        ok |= (x&1);
    if (!ok)
        return cout << solve(vc[0]+1),0;
    int mn = 1e9;
    if (vc[0]%2==0)
        mn = vc[0]+1;
    for(auto x:vc)
    {
        if (x&1)
            mn = min(mn,x);
    }
    cout << solve(mn);
    return 0;
}


Measured memory_bytes: 3840
n = int(input())
def counter(num1, num2):
	if num2 == "0":
		num21 = "3"
		num22 = "5"
		num23 = "7"
		return counter(num1, num21) + counter(num1, num22) + counter(num1, num23)
	elif int(num2) > num1:
		return 0
	else:
		result = 0
		num21 = "3" + num2
		num22 = "5" + num2
		num23 = "7" + num2
		if "3" in num21 and "5" in num21 and "7" in num21 and int(num21) <= num1:
			result += 1
		if "3" in num22 and "5" in num22 and "7" in num22 and int(num22) <= num1:
			result += 1
		if "3" in num23 and "5" in num23 and "7" in num23 and int(num23) <= num1:
			result += 1
		return counter(num1, num21) + counter(num1, num22) + counter(num1, num23) + result

print(counter(n, "0"))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = min(a,b); i >= 1; i--) {
        if (a%i == 0 && b%i == 0) k--;
        if (k == 0) {
            cout << i << endl; 
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
from collections import Counter

N=int(input())
D=list(map(int, input().split()))
M=int(input())
T=list(map(int, input().split()))

dd=Counter(D)
td=Counter(T)

ddl=list(dd.items())
tdl=list(td.items())

for k, v in tdl:
  if dd[k]<v:
    print("NO")
    exit()

print("YES")

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

int main() {
    int r, D, x;
    cin >> r >> D >> x;
    vector<int> W(10 + 1);
    W[0] = x;
    for (int i = 1; i <= 10; i++) {
        W[i] = r * W[i - 1] - D;
    }

    for (int i = 1; i <= 10; i++) {
        cout << W[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
constexpr ll mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), b(n);
    rep(i, 0, n) cin >> a[i] >> b[i];
    vector<pair<ll,ll>> p(n);
    rep(i, 0, n) p[i] = {a[i], b[i]};
    sort(p.begin(), p.end());
    ll cur = 0;
    rep(i, 0, n) {
        cur += p[i].second;
        if(cur >= k) {
            cout << p[i].first << endl;
            return 0;
        } 
    }
    return 0;
}

Measured memory_bytes: 6360