akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: usize = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let M: usize = sc.get();
    let K: usize = sc.get();
    let A: Vec<usize> = sc.vec(N);
    let B: Vec<usize> = sc.vec(M);
    let mut now = 0;
    let mut alla = 0;
    let mut idxa = 0;
    for i in 0..N {
        if now + A[i] <= K {
            now += A[i];
            alla += 1;
            idxa += 1;
        } else {
            break;
        }
    }
    let mut ans = 0;
    ans = max(ans, alla);
    let mut idxb = 0;
    let mut num = alla;
    while idxb < M {
        while idxb < M && now + B[idxb] <= K {
            now += B[idxb];
            num += 1;
            idxb += 1;
        }
        ans = max(ans, num);
        if idxa == 0 {
            break;
        }
        now -= A[idxa-1];
        num -= 1;
        idxa -= 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 5180
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
#define IINF (1<<21)
typedef long long ll;

ll dp[100100];
int N;

int main() {
  cin >> N;
  REP(i, N + 100) {
    dp[i] = INF;
  }

  REP(_, N) {
    ll in;
    cin >> in;

    *lower_bound(dp, dp + N, in) = in;
  }

  int cnt = 0;
  REP(i, N) {
    // if (i) cout << " ";
    // cout << dp[i];

    if (dp[i] < INF) cnt++;
  }
  // cout << endl;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3860
s = input()

if s == "S" :
    print('天気が雨である日が連続していた最大の日数を入力せよ')
elif s == "RRR" :
    print(3)
elif s == "RRS" or s =="SRR" :
    print(2)
elif s == "SSS" :
    print(0)
else :
    print(1)

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, M, ans=0, tmp=0;
vector<ll> color;
vector<vector<ll>> G;

bool bfs(ll id, ll state) {
    queue<ll> Q;
    color[id] = state;
    Q.push(id);
    while(!Q.empty()) {
        ll u = Q.front();
        Q.pop();
        for(int i=0;i<G[u].size();i++) {
            if(color[G[u][i]]==-1) {
                color[G[u][i]] = 1-color[u];
                Q.push(G[u][i]);
            }
            else {
                if(color[G[u][i]]==color[u]) {
                    return false;
                }
            }
        }
    }
    return true;
}

signed main(){
    cin >> N >> M;
    G.resize(N);
    color.resize(N, -1);
    for(int i=0;i<M;i++) {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    if(bfs(0, 0)) {
        for(int i=0;i<N;i++) {
            if(color[i]==1) tmp++;
        }
        ans = tmp*(N-tmp);
    }
    else ans = N*(N-1)/2;
    cout << ans-M << endl;
    return 0;
}

Measured memory_bytes: 10032
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
i64 A[202020];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%lld", A + i);

	i64 sum = 0;
	for (int i = 0; i < N; ++i) sum += A[i];

	i64 ret = 1LL << 62LL;
	i64 t = 0;
	for (int i = 0; i < N; ++i) {
		i64 l = t, r = sum - t;
		ret = min(ret, max(l, r) - min(l, r));
		t += A[i];
	}
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
using ll = long long;

int main(){
    int N;
    cin >> N;
    int A[99];
    int x[99][16], y[99][16];
    for(int i = 1;i <= N;i++){
        cin >> A[i];
        for(int j = 1;j <= A[i];j++){
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << N); bits++) {
        bool a = true;
        for(int i = 1; i <= N; i++) {
            if(bits & (1 << i-1))for(int j = 1; j <= A[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) a = false;
            }
        }
        if(a){
            int count = 0;
            for(int i = 1;i <= N;i++){
                if(bits & (1 << i-1))count++;
            }
            ans = max(ans, count);
        } 
    }
    cout << ans;
}

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

#define pii pair<int,int>
#define F first
#define S second

using namespace std;

const int N = 1e4 + 123, MAXN = 1e6, inf = 1e9 + 7;

int h, n;
int dp[MAXN], can[MAXN], ans, a[N], b[N];

int main () {
    scanf ("%d%d", &h, &n);
    for (int i = 1;i <= n;i ++) {
        scanf ("%d%d", &a[i], &b[i]);
    }can[0] = 1;
    for (int i = 1;i <= MAXN;i ++) {
        dp[i] = inf;
    }ans = inf;
    for (int i = 1;i <= n;i ++) {
        for (int j = 0;j <= h;j ++) {
            if (can[j]) {
                can[j + a[i]] = 1;
                dp[j + a[i]] = min (dp[j + a[i]], dp[j] + b[i]);
                if (j + a[i] >= h) {
                    ans = min (ans, dp[j + a[i]]);
                }
            }
        }
    }
    printf("%d", ans);
}


Measured memory_bytes: 6144
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
long long cnt;
int N;
int A[1000000], G[100];

void insertionSort(int A[], int N, int g)
{
	for (int i = g; i < N; i++)
	{
		int tmp1 = i;
		int tmp2 = i - g;
		while (tmp2 >= 0 && A[tmp2] > A[tmp1])
		{
			swap(A[tmp2], A[tmp1]);
			tmp1 = tmp2;
			tmp2 = tmp2 - g;
			cnt++;
		}
	}

}

void shellSort(int A[], int N, int G[])
{
	int i = 0;
	for (int h = 1; h <= N; i++)
	{
		G[i] = h;
		h = 3 * h + 1;
	}
	cout << i << endl;
	if (i != 1)
	{
		for (int j = i - 1; j > 0; j--)
		{
			cout << G[j] << " ";
		}
	}

	cout << G[0] << endl;
	for (int j = i - 1; j >= 0; j--)
	{
		insertionSort(A, N, G[j]);
	}
	cout << cnt << endl;
	for (int j = 0; j < N; j++)
	{
		cout << A[j] << endl;
	}
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	shellSort(A, N, G);
	return 0;
}


Measured memory_bytes: 6984
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX+1];

void maxHeapfy(int i) {
	int l, r, largest;
	l = i * 2;
	r = i * 2 + 1;
	if (l <= H && A[i] < A[l]) {
		largest = l;
	}
	else {
		largest = i;
	}
	if (r<=H && A[r]>A[largest]) {
		largest = r;
	}
	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapfy(largest);
	}

}

int main() {
	int i;
	cin >> H;
	for (i = 1;i <= H;i++) {
		cin >> A[i];
	}
	for (i = H / 2;i >= 1;i--) {
		maxHeapfy(i);
	}
	for (i = 1;i <= H;i++) {
		cout << " " << A[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 5008
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, k, d, a;
    cin >> n >> k;
    vector<bool> b(n);
    for (int i = 0; i < k; ++i) {
        cin >> d;
        for (int i = 0; i < d; ++i) cin >> a, b.at(--a) = 1;
    }
    cout << count(b.begin(), b.end(), 0) << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <string.h>


#define MOD (1000000007)


using namespace std;
typedef long long ll;
ll memo[220001];

void initTable(ll n)
{
    ll i;
    memo[1] = 1;
    for (i = 2; i <= n; i++){
        memo[(int)i] = (i * memo[(int)(i - 1)]) % MOD;
    }
}

ll extgcd(ll a, ll b, ll *x, ll *y)
{
    ll d = a;
    if (b != 0){
        d = extgcd(b, a % b, y, x);
        *y -= (a / b) * *x;
    }
    else {
        *x = 1;
        *y = 0;
    }
    return (d);
}

ll mod_inverse(ll a, ll m){
    ll x, y;
    extgcd(a, m, &x, &y);
    return ((m + x % m) % m);
}

ll mod_fact(ll n, ll p, ll *e)
{
    ll res;
    int look;
    *e = 0;
    if (n == 0){
        return (1);
    }
    
    res = mod_fact(n / p, p, e);
    *e += n / p;
    
    if (n / p % 2 != 0){
        return (res * (p - memo[(int)(n % p)]) % p);
    }
    look = n % p;
    return (res * memo[(int)(n % p)] % p);
}

ll mod_comb(ll n, ll k, ll p) {
    ll e1, e2, e3;
    ll a1, a2, a3;
    
    if (n < 0 || k < 0 || n < k){
        return (0);
    }
    
    a1 = mod_fact(n, p, &e1);
    a2 = mod_fact(k, p, &e2);
    a3 = mod_fact(n - k, p, &e3);
    
    if (e1 > e2 + e3){ //divisible
        return (0);
    }
    return (a1 * mod_inverse(a2 * a3 % p, p) % p);
}

int main(void)
{
    initTable(200000);
    ll h,w,a,b;
    cin >> h >> w >> a >> b;
    ll ans=0;
    for(ll i=1;i<=h-a;i++){
        ans += (mod_comb(b+i-2,i-1,MOD)*mod_comb(w-b+h-i-1,h-i,MOD))%MOD;
        ans = ans % MOD;
    }
    cout << ans << endl;
    return (0);
}


Measured memory_bytes: 1792
import sys
from random import randint
input = sys.stdin.readline
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [randint(0, 25) for i in range(D)]
last = [0] * 26
def score(day, score):
  for i in range(26): score -= (day - last[i]) * c[i]
  return score
def run(day):
  global last
  last = [0] * 26
  res = 0
  for d in range(day):
    contest = t[d]
    last[contest] = d + 1
    res = score(d + 1, res) + s[d][contest]
  return res


for d in range(1, D + 1):
  mx = -float("inf")
  mxx = randint(0, 25)
  for x in range(26):
    t[d - 1] = x
    res = run(d)
    if mx < res:
      mx = res
      mxx = x
  t[d - 1] = mxx

for l in range(365, 300, -1):
  last = [0] * 26
  run(l)
  #print(last)
  zmx = -float("inf")
  zmxz = 0
  for z in range(26):
    t[l - 1] = z

    for d in range(l + 1, D + 1):
      mx = -float("inf")
      mxx = t[d - 1]
      for x in range(26):
        t[d - 1] = x
        res = score(d, 0) + s[d - 1][x]
        if mx < res:
          mx = res
          mxx = x
      t[d - 1] = mxx
      last[mxx] = d
    zres = run(D)
    if zres > zmx:
      zmx = zres
      zmxz = z
  t[l - 1] = zmxz

for x in t: print(x + 1)

Measured memory_bytes: 80836
using System;
using System.Linq;
    class Program
    {
        static void Main(string[] args)
        {
            var inputsHW = Console.ReadLine().Split(' ').Select(c=>int.Parse(c)).ToArray();
            var inputshw = Console.ReadLine().Split(' ').Select(c=>int.Parse(c)).ToArray();
            Console.WriteLine((inputsHW[0] - inputshw[0]) * (inputsHW[1] - inputshw[1]));
        }
    }

Measured memory_bytes: 13268
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t map[13] = {
	0,
	1,
	3,
	1,
	2,
	1,
	2,
	1,
	1,
	2,
	1,
	2,
	1
};

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	int x, y;
	in >> x>>y;
	std::cout << ((map[x]==map[y]) ? "Yes" : "No") << std::endl;

	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int32_t ARR[300000];
int64_t MAX[112345];//[N-1,2N][0,N+1]
int64_t MIN[112345];//[N-1,2N]
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N;
	for (size_t i = 0; i < 3*N; i++)
	{
		in >> ARR[i];
	}
	//std::sort(ARR, ARR + N);
	//std::sort(ARR+2*N-1, ARR + 3*N);

	//前を最大化
	{
		int64_t sum = 0;
		std::priority_queue<int32_t> que;
		for (int32_t i = 0; i < N; i++)
		{
			que.push(-ARR[i]);
			sum += ARR[i];
		}
		MAX[0] = sum;
		//[N,2N]を処理
		for (int32_t i = 0; i <= N; i++)
		{
			que.push(-ARR[N+i]);
			sum += ARR[N+i];
			sum += que.top(); que.pop();
			MAX[i+1] = sum;
		}
	}
	//後ろを最小化
	{
		int64_t sum = 0;
		std::priority_queue<int32_t> que;
		for (int32_t i = 0; i < N; i++)
		{
			que.push(ARR[3*N-1-i]);
			sum += ARR[3*N-1-i];
		}
		MIN[N+1] = sum;
		//[N,2N]を処理
		for (int32_t i = 0; i <= N; i++)
		{
			que.push(ARR[2*N-1 - i]);
			sum += ARR[2*N-1 - i];
			sum -= que.top(); que.pop();
			MIN[N-i] = sum;
		}
	}
	//[N-1,2N]を処理
	int64_t max_value = (-9223372036854775807i64 - 1);
	for (int32_t i = 0; i <= N; i++)
	{
		max_value = std::max(max_value, MAX[i] - MIN[i+1]);
	}
	std::cout << max_value << std::endl;
	return 0;
}
#endif


Measured memory_bytes: 256
(function () {
  var input = '',
      cnt = 0;

  function main () {
    var inputLen, nums, x, y, temp, ans;

    inputLen = input.length;
    
    for (i = 0; i < inputLen; i += 1) {
      nums = input[i].split(' ');
      x = parseInt(nums[0], 10);
      y = parseInt(nums[1], 10);

      if (x === 0 && y === 0) {
        break;
      } else if (x < y) {
        temp = x;
        x = y;
        y = temp;
      }

      ans = gcd(x, y);

      showResult(ans, cnt);
      cnt = 0;
    }
  }

  function gcd (x, y) {
    cnt += 1;
    return x % y === 0 ? y : gcd(y, x % y);
  }

  function showResult(result, cnt) {
    console.log(result + ' ' + cnt);
  }

  process.stdin.resume();
  process.stdin.setEncoding('utf8');
  process.stdin.on('data', function (chunk) {
    input += chunk;
  });

  process.stdin.on('end', function () {
    input = input.split('\n');
    main();
  });
}());

Measured memory_bytes: 10208
#include <cstdio>
#include <iostream>
#include <cstring>
#define Int register int
using namespace std;

static inline char Get_Char() {
	static char buffer[100000], *S = buffer, *T = buffer;
	if (S == T) {
		T = (S = buffer) + fread(buffer, 1, 100000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}

#define Get_Char() getchar()

static inline int Read() {
	int f = 1, x = 0;
	register char sign = Get_Char();
	for (; sign > '9' || sign < '0'; sign = Get_Char())
		if (sign == '-') f = -1;
	for (; sign >= '0' && sign <= '9'; sign = Get_Char())
		x = (x << 3) + (x << 1) + (sign ^ 48);
	return x * f;
}


string s;
int main() {
	cin >> s;
	Int len = s.length();
	Int i = 0;
	for (; i < len; ++ i) {
		if (s[i] == 'C')
			break;
	} 
	
	for (; i < len; ++ i) {
		if (s[i] == 'F')
			return !printf("Yes\n");
	}
	printf("No\n");
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

#define NIL -1
#define N 25

typedef struct node {
    int p,l,r;
} Node;

Node T[N];

int getDegree(int id) {
    if (T[id].l != NIL && T[id].r != NIL) return 2;
    if (T[id].r != NIL) return 1;
	if (T[id].l != NIL) return 1;

    return 0;
}

int getSib(int id) {
    if (T[id].p == NIL) return NIL;

    if (T[T[id].p].l != id) return T[T[id].p].l;
    return T[T[id].p].r;
}

int getDepth(int id) {
    int depth = 1;

    if (T[id].p == NIL) return 0;
    depth += getDepth(T[id].p);
    return depth;
}

int getHeight(int id) {
    int height = 1;
    int r,l;

    if (T[id].l == -1 && T[id].r == -1)
        return 0;

    if (T[id].l == -1)
        height += getHeight(T[id].r);
    else if (T[id].r == -1)
        height += getHeight(T[id].l);
    else {
        r = getHeight(T[id].r);
        l = getHeight(T[id].l);
        if (r >= l) height += r;
        else height += l;
    }

    return height;
}

int main() {
    int i,j,n;
    int id,l,r;

    scanf("%d",&n);

    for (i = 0; i < n; i++)
        T[i].p = NIL;
    for (i = 0; i < n; i++) {
        scanf("%d %d %d",&id,&l,&r);
        T[id].l = l;
        T[id].r = r;
        if (l != NIL) T[l].p = id;
        if (r != NIL) T[r].p = id;
    }

    for (i = 0; i < n; i++) {
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,",i,T[i].p, getSib(i), getDegree(i), getDepth(i), getHeight(i));
        if (T[i].p == NIL) printf(" root\n");
        else if (T[i].l != NIL) printf(" internal node\n");
		else if (T[i].r != NIL) printf(" internal node\n");
        else printf(" leaf\n");
    }
    return 0;
}

Measured memory_bytes: 612
use std::io::{BufRead, stdin};

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    loop {
        let mut buf = String::new();
        stdin.read_line(&mut buf).unwrap();
        let mut buf = buf.split_whitespace();

        let m: i8 = buf.next().unwrap().parse().unwrap();
        let f: i8 = buf.next().unwrap().parse().unwrap();
        let r: i8 = buf.next().unwrap().parse().unwrap();

        if m == -1 && f == -1 && r == -1 {
            break;
        }

        println!("{}",
            if m == -1 || f == -1 { "F" }
            else if m + f >= 80 { "A" }
            else if m + f >= 65 { "B" }
            else if m + f >= 50 || r >= 50 { "C" }
            else if m + f >= 30 { "D" }
            else { "F" }
        );
    }
}


Measured memory_bytes: 5016
open Array;;let a=make 100 0;;let($)x y=if x>=0&&x<=9&&y>=0&&y<=9then a.(10*y+x)<-a.(10*y+x)+1;;let rec g x y=function|1->(x$y;x$(y-1);(x-1)$y;(x+1)$y;x$(y+1))|2->(g x y 1;(x-1)$(y-1);(x+1)$(y-1);(x-1)$(y+1);(x+1)$(y+1))|3->(g x y 2;x$(y-2);(x-2)$y;(x+2)$y;x$(y+2))|_->();;let rec f()=f(Scanf.scanf"%d,%d,%d
"(fun x y s->g x y s));;try f()with _->(Printf.printf"%d
%d
"(fold_left(fun z e->if e=0then z+1else z)0a)(fold_left(fun z e->max z e)0a))

Measured memory_bytes: 2392
from math import ceil
n,h=map(int,input().split())
g=[list(map(int,input().split())) for i in range(n)]
l=[]
ans=0
dm=0
for i in range(n):
  l.append([g[i][0],2])
  l.append([g[i][1],1])
l.sort(reverse=True)
for i in range(2*n):
  if l[i][1]==1:
    dm+=l[i][0]
    ans+=1
    if dm>=h:
      print(ans)
      exit()
  else:
    h-=dm
    ans+=ceil(h/l[i][0])
    print(ans)
    exit()
    

Measured memory_bytes: 42404
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

#define MAX_N 120
#define MAX_M 120
#define MAX_P 120
#define C 0.621446216671352

double dp[MAX_N][MAX_M][MAX_P];
double ventoh[120000];

int n;

int main() {
	for (int i = 0; i < MAX_N; i++) {
		for (int j = 0; j < MAX_M; j++) {
			for (int k = 0; k < MAX_P; k++) {
				dp[i][j][k] = 0.0;
			}
		}
	}
	dp[0][0][0] = 1;
	for (int i = 1; i < MAX_N; i++) {
		for (int j = 0; j < MAX_M; j++) {
			for (int k = 0; k < MAX_P - 1; k++) {
				if (dp[i - 1][j][k] >= 0) {
					dp[i][j + 1][k + 1] += dp[i - 1][j][k] * 1.0 / pow(2.0, k);
					dp[i][j][0] += dp[i - 1][j][k] * (1.0 - 1.0 / pow(2.0, k));
				}
			}
		}
	}

	for (int i = 0; i < MAX_N; i++) {
		for (int j = 0; j < MAX_M; j++) {
			for (int k = 0; k < MAX_P; k++) {
				if (dp[i][j][k] >= 0) {
					ventoh[i] += dp[i][j][k] * j;
				}
			}
		}
	}

	for (int i = 110; i < 120000; i++) {
		ventoh[i] = ventoh[i - 1] + C;
	}

	while (true) {
		cin >> n;
		if (n == 0) {
			break;
		}
		cout << fixed << setprecision(15) << ventoh[n] << endl;
	}
	return 0;
}

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

long long I, O, T, J, L, S, Z;
int main() {
  cin >> I >> O >> T >> J >> L >> S >> Z;
  long long s = 2*(I/2) + 2*(J/2) + 2*(L/2) + (I % 2 == 1 && J % 2 == 1 && L % 2 == 1 ? 3 : 0);
  if (I > 0 && J > 0 && L > 0) {
    I--, J--, L--;
    s = max(s, 2*(I/2) + 2*(J/2) + 2*(L/2) + 3);
  }
  cout << O + s << "\n";
  return 0;
}


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

int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x ;
    int count=0;

    for(int i=0;i<a+1;i++){

        for(int j=0;j<b+1;j++){

            for(int k=0;k<c+1;k++){

                if(x == 500*i + 100*j + 50*k ){
                    count++;
                }

            }

        }

    }

    cout << count << endl;

    return 0;

}

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

int read()
{
  int x=0,f=1;
  char ch=getchar();
  while((ch<'0')||(ch>'9'))
    {
      if(ch=='-')
        {
          f=-f;
        }
      ch=getchar();
    }
  while((ch>='0')&&(ch<='9'))
    {
      x=x*10+ch-'0';
      ch=getchar();
    }
  return x*f;
}

const int maxn=200000;
const long long inf=0x3f3f3f3f3f3f3f3fll;

int n,q,sta,stb,a[maxn+10];

namespace sgt
{
  long long mn[3][maxn<<2],adt[maxn<<2];

  int puttag(int x,long long v)
  {
    mn[0][x]+=v;
    mn[1][x]+=v;
    mn[2][x]+=v;
    adt[x]+=v;
    return 0;
  }

  int pushdown(int x)
  {
    puttag(x<<1,adt[x]);
    puttag(x<<1|1,adt[x]);
    adt[x]=0;
    return 0;
  }

  int updata(int x)
  {
    mn[0][x]=std::min(mn[0][x<<1],mn[0][x<<1|1]);
    mn[1][x]=std::min(mn[1][x<<1],mn[1][x<<1|1]);
    mn[2][x]=std::min(mn[2][x<<1],mn[2][x<<1|1]);
    return 0;
  }

  int build(int x,int l,int r)
  {
    if(l==r)
      {
        mn[0][x]=inf+l;
        mn[1][x]=inf+n-l+1;
        mn[2][x]=inf;
        return 0;
      }
    int mid=(l+r)>>1;
    build(x<<1,l,mid);
    build(x<<1|1,mid+1,r);
    updata(x);
    return 0;
  }

  int add(int x,int l,int r,int askl,int askr,long long adv)
  {
    if((askl<=l)&&(r<=askr))
      {
        puttag(x,adv);
        return 0;
      }
    int mid=(l+r)>>1;
    pushdown(x);
    if(askl<=mid)
      {
        add(x<<1,l,mid,askl,askr,adv);
      }
    if(mid<askr)
      {
        add(x<<1|1,mid+1,r,askl,askr,adv);
      }
    updata(x);
    return 0;
  }

  long long getmn(int x,int l,int r,int askl,int askr,int id)
  {
    if((askl<=l)&&(r<=askr))
      {
        return mn[id][x];
      }
    int mid=(l+r)>>1;
    long long res=inf<<1;
    pushdown(x);
    if(askl<=mid)
      {
        res=std::min(res,getmn(x<<1,l,mid,askl,askr,id));
      }
    if(mid<askr)
      {
        res=std::min(res,getmn(x<<1|1,mid+1,r,askl,askr,id));
      }
    return res;
  }
}

int abs(int x)
{
  return (x<0)?(-x):x;
}

int main()
{
  n=read();
  q=read();
  sta=read();
  stb=read();
  for(int i=1; i<=q; ++i)
    {
      a[i]=read();
    }
  a[0]=sta;
  sgt::build(1,1,n);
  sgt::add(1,1,n,stb,stb,-inf);
  for(int i=1; i<=q; ++i)
    {
      long long oth=std::min(sgt::getmn(1,1,n,1,a[i],1)-(n-a[i]+1),sgt::getmn(1,1,n,a[i],n,0)-a[i]);
      sgt::add(1,1,n,1,n,abs(a[i]-a[i-1]));
      long long nth=sgt::getmn(1,1,n,a[i-1],a[i-1],2);
      if(nth>oth)
        {
          sgt::add(1,1,n,a[i-1],a[i-1],oth-nth);
        }
    }
  printf("%lld\n",sgt::getmn(1,1,n,1,n,2));
  return 0;
}


Measured memory_bytes: 25472
a,b,c=(int(x) for x in input().split())

if a<b:
    if a<c:
        if c<b:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
if a>b:
    if a>c:
        if c>b:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
if a==b:
    if a==c:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
n = int(input())
a = list(map(int,input().split()))

b=[]
if n % 2 == 0:
    for i in range(n-1, 0, -2):
        b.append(a[i])

    for ii in range(0, n, 2):
        b.append(a[ii])

else:
    for j in range(n-1, -1, -2):
        b.append(a[j])

    for jj in range(1, n, 2):
        b.append(a[jj])

print(*b)

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    int maxK = (N-1)*(N-2)/2;
    if (K > maxK) {
        cout << -1 << endl;
        return 0;
    }

    cout << N - 1 + maxK - K << endl;
    for (int i = 2; i <= N; ++i) {
        cout << "1 " << i << endl;
    }
    
    int k = 0;
    for (int i = 2; i < N; ++i) {
        for (int j = i + 1; j <= N; ++j) {
            if (k++ >= maxK - K) return 0;
            cout << i << " " << j << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
x, k, d = map(int, input().split())

if abs(x) >= k * d:
    print(abs(x) - k * d)
else:
    a = abs(abs(x) - (abs(x) // d) * d)
    k -= (abs(x) // d)
    if k % 2 == 0:
        print(a)
    else:
        print(abs(a - d))



Measured memory_bytes: 61816
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    ll K;
    cin >> K;
    int cnt = 1;
    int now = 7;
    unordered_set<int> nums;
    while (now != 0) 
    {
        while (now<K)
        {
            ++cnt;
            now = now*10 + 7;
        }
        //printf("tgt: %d\n", now);
        now = now % K;
        //printf("now: %d\n", now);

        if (nums.count(now)>0)
        {
            cout << -1 << endl;
            return 0;
        }

        nums.insert(now);
    }
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 39468
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e6+5;
struct node{
	int x,y;
}p[maxn];
int main() {
	int n,m,k;
	map<pair<int,int>,int>mp;
	vector<int> a(maxn),b(maxn);
	cin>>n>>m>>k;
	for(int i=1;i<=k;i++){
		cin>>p[i].x>>p[i].y;
		a[p[i].x]++;
		b[p[i].y]++;
	}  
	int max1=0,max2= 0;
	for(int i=1;i<=n;i++){
		max1 = max(max1,a[i]);
	}
	for(int i=1;i<=m;i++){
		max2 = max(max2,b[i]);
	}
	map<int,int> m1;
	map<int,int> m2;
	ll ct1 = 0,ct2 = 0;
	for(int i=1;i<=n;i++){
		if(a[i]==max1){
			m1[i] = 1;
			ct1++;
		}
	}
	for(int i=1;i<=m;i++){
		if(b[i]==max2){
			m2[i] = 1;
			ct2++;
		}
	}
	//cout<<ct1<<" "<<ct2<<endl;
	ll flag = ct1*ct2;
	for(int i=1;i<=k;i++){
		if(m1[p[i].x]&&m2[p[i].y]) flag--;
	}
	if(flag<=0){
		cout<<max1+max2-1<<endl;
	} else {
		cout<<max1+max2<<endl;
	}
    return 0;
}



Measured memory_bytes: 49436
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

const int MOD = 1e9+7;

int dp[1100][1100] = {0};

void add(int &a, int b) {
    a += b;
    if (a >= MOD) a-= MOD;
}

int main()
{
    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    rep(i, 0, H) cin >> S[i];

    dp[0][0] = 1;

    rep(i, 0, H) {
        rep(j, 0, W) {
            if (i + 1 < H && S[i+1][j] == '.') add(dp[i+1][j], dp[i][j]);
            if (j + 1 < W && S[i][j+1] == '.') add(dp[i][j+1], dp[i][j]);
        }
    }

    cout << dp[H-1][W-1] << endl;

    return 0;
}

Measured memory_bytes: 5632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			if((n|m)==0){
				return;
			}
			int[] invite = new int[n+1];
			int[][] friend = new int[m][2];
			for(int i=0;i<m;i++){
				friend[i][0] = stdIn.nextInt();
				friend[i][1] = stdIn.nextInt();
			}
			invite[0] = 1;
			for(int i=0;i<m;i++){
				if(friend[i][0]==1){
					invite[friend[i][1]] = 2;
				}
				else if(friend[i][1]==1){
					invite[friend[i][0]] = 2;
				}
			}
			for(int i=0;i<m;i++){
				if(invite[friend[i][0]]==2&&invite[friend[i][1]]==0){
					invite[friend[i][1]] = 3;
				}
				if(invite[friend[i][1]]==2&&invite[friend[i][0]]==0){
					invite[friend[i][0]] = 3;
				}
			}
			int cnt = 0;
			for(int i=2;i<=n;i++){
				if(invite[i]>1){
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}

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

//関数
long path(long start,long goal,long N){
    if(goal>=start){
        return goal-start;
    }else{
        return N-(start-goal);
    }
}

long syc(long i,long N){
    while(i<0){
        i+=N;
    }
    return i%N;
}
    
    
//main関数
int main() {
    
    
    //入力
    long N;
    long x;
    cin>>N>>x;
    vector<long> a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    
    
    //計算
    vector<long> b(N);//範囲kの最小
    long ans=0;
    for(int i=0;i<N;i++){
        b.at(i)=a.at(i);
        ans+=b.at(i);
    }
    
    for(int k=0;k<N;k++){
        long tempans=x*k;
        for(int i=0;i<N;i++){
            b.at(i)=min(b.at(i),a.at(syc(i-k,N)));
            tempans+=b.at(i);
        }
        ans=min(ans,tempans);
    }
    
    
    
    //出力
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,K;
  cin>>A>>B>>K;
  vector<int> P(max(A,B));
  int l = 0;
  for(int i=1; i<=min(A,B);i++){
    if(A%i ==0 && B%i==0){
      P.at(l) = i;
      l++;
      }
    }
  sort(P.begin(),P.end());
  reverse(P.begin(),P.end());
  cout<<P.at(K-1)<<endl;
}



Measured memory_bytes: 256
#!/usr/bin/ruby
N=gets.to_i
X=N.times.map{gets.chomp}
Y=N.times.map{gets.chomp}
attackX=attackY=0
N.times{|i|
	foulX=foulY=false
	if X[i]=='kougekida'
		foulX=true if attackX==0
		if Y[i]=='kougekida'
			foulY=true if attackY==0
			next if foulX&&foulY
			if foulX
				puts 'Nakajima-kun'
				exit
			elsif foulY
				puts 'Isono-kun'
				exit
			elsif attackX>attackY
				puts 'Isono-kun'
				exit
			elsif attackY<attackX
				puts 'Nakajima-kun'
				exit
			end
			attackY=0
		elsif foulX
			puts 'Nakajima-kun'
			exit
		elsif Y[i]=='tameru'
			puts 'Isono-kun'
			exit
		elsif Y[i]=='mamoru' && attackX>=5
			puts 'Isono-kun'
			exit
		end
		attackX=0
	elsif X[i]=='tameru'
		if Y[i]=='kougekida'
			if attackY==0
				puts 'Isono-kun'
				exit
			else
				puts 'Nakajima-kun'
				exit
			end
			attackY=0
		elsif Y[i]=='tameru'
			attackY+=1
		elsif Y[i]=='mamoru'
		end
		attackX+=1
	elsif X[i]=='mamoru'
		if Y[i]=='kougekida'
			if attackY==0
				puts 'Isono-kun'
				exit
			elsif attackY>=5
				puts 'Nakajima-kun'
				exit
			end
			attackY=0
		elsif Y[i]=='tameru'
			attackY+=1
		elsif Y[i]=='mamoru'
		end
	end
}
puts 'Hikiwake-kun'

Measured memory_bytes: 8740
#include<iostream>
using namespace std;
int main()
{
  string s;
  int count;
  cin>>s;
  string str[3]={"Sunny","Cloudy","Rainy"};
  for(int i=0;i<3;i++)
  {
    if(str[i]==s)
    {
      count=i;
      break;
    }
  }
  if(count==0||count==1)
  {
    cout<<str[count+1];
  }
  if(count==2)
  {
    cout<<str[0];
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>  
int main()
{      
     int m=0, f=0, r=0, i;  
      for(i=0; ; i++){      
      scanf("%d %d %d", &m, &f, &r);    
      if(m==-1 && f==-1 && r==-1){break;         }
      else if(m==-1 || f==-1){printf("F\n");    
      }else if(m+f>=80){printf("A\n");   
      }else if(m+f>=65){printf("B\n");   
      }else if(m+f>=50){printf("C\n");   
      }else if(m+f>=30 && r>=50){printf("C\n");   
      }else if(m+f>=30){printf("D\n");    
      }else{printf("F\n");     
      }   
  }     
  return 0;
}

Measured memory_bytes: 584
//#include<bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <list>
#include <climits>
#include <bitset>

/*
Not easy to be successful,Dont give up
*/

using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define pb push_back
#define Compiler_Beso ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)        memset(v, d, sizeof(v))
#define endl '\n'
const double EPS = 1e-12;
typedef long long ll;
const double PI = 3.14159265359;
enum dir       { DOWN = 0, UP, RIGHT, LEFT, DOWN_RIGHT, DOWN_LEFT, UP_RIGHT, UP_LEFT };
int  dir_r[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int  dir_c[] = { 0, 0, 1, -1, 1, -1, 1, -1 };

int main()
{
	Compiler_Beso

		int n;
	cin >> n;
	vector<int>x(n+1), y(n+1);
	for (int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
	}
	sort(all(y));
	sort(x.rbegin(), x.rend());
	ll ans = 0;
	for (int i = 0; i < n+1; i++)
	if (x[i]>y[i])
		ans += 2 * (x[i] - y[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
    for j in range (B+1):
        for k in range (C+1):
            if X == i*500 + j*100 + k*50:
                count += 1

print(count)



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

int M[31];
int main()
{
	int N, K, H;
  	cin >> N >> H;
  	for ( int i = 0; i < N; i++ )
    {
      cin >> K;
      for ( int j = 0; j < K; j++ )
      {
        int A;
        cin >> A;
        M[A]++;
      }
    }
  	int ans = 0;
  	for ( int i = 1; i <= H; i++ )
    {
      if ( M[i] == N ) ans++;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int a, i;

    for(i = 1; i <= 10000; i++)
    {
        scanf("%d", &a);

        if(a == 0)
        {
            break;
        }

        printf("%s %d: %d\n", "Case", i, a);
    }

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  bool flag = true;

  for (int i = 0; i < s.size(); i++){
    if ((i + 1) % 2 == 1 && s[i] == 'L'){
      flag = false;
      break;
    }
    else if ((i + 1) % 2 == 0 && s[i] == 'R'){
      flag = false;
      break;
    }
  }

  if(flag) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

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

	for (int i = 0; i < S.size(); i++) {
		string U = S;
		for (int j = 1; j < S.size(); j++) {
			S[j] = U[j - 1];
		}
		S[0] = U[U.size()-1];
		if (S == T) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
}

Measured memory_bytes: 256
import sys

n = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().strip().split()))

S = [0 for _ in range(n)]
acum = 0
for i in range(n):
    acum += A[i]
    S[i] = acum
# print(S)

costs = [0, 0]
for p in (0, 1):
    S_tmp = S[:]
    cost = 0 # BA`:n2s?t
    diff = 0 # +-B$NA`:n$G$NJQF0
    for i in range(n):
        # nB$H0lCW$9$kJ}$rIi$K$9$k
        # print(p, diff + S_tmp[i])
        if i % 2 == p:
            if diff + S_tmp[i] >= 0:
                tmp_cost = diff + S_tmp[i] + 1
                diff -= tmp_cost
                cost += tmp_cost
                # print("cost", cost)
        else:
            # B@5$KJQ49$9$k%3%9%H
            if diff + S_tmp[i] <= 0:
                tmp_cost = 1 - diff - S_tmp[i]
                diff += tmp_cost # +1B$KJQ49$9$k
                cost += tmp_cost
                # print("cost", cost)
    costs[p] = cost

# print(costs)
print(min(costs))

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

int main(){
  int N,D;
  cin >> N >> D;
  int X[10][10];
  for(int i = 0;i < N;i++){
    for(int j = 0;j < D;j++){
      cin >> X[i][j];
    }
  }


  vector<int> dist;

  for(int i = 0;i < N - 1;i++){
    for(int j = i + 1;j < N;j++){
      int now_dist = 0;
      for(int k = 0;k < D;k++){
        now_dist += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
      }

      dist.push_back(now_dist);
    }
  }
  

  int ans = 0;

  for(int i = 0;i < dist.size();i++){
    int distance = dist[i];
    for(int j = 1;j * j <= distance;j++){
      if(j * j == distance){
        ans++;
        break;
      }
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
n = int(input())
a_list = [int(x) for x in input().split()]

count = 0
for i in range(n):
    if a_list[i] < 0:
        a_list[i] *= -1
        count += 1

ans = sum(a_list)
if count % 2 == 1:
    a_list.sort()
    ans -= a_list[0] * 2
print(ans)

Measured memory_bytes: 14260
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto& i:k)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

signed main(){
    int n;
    cin >> n;
    REP(i,9){
      int a=i+1;
      if(n%a==0&&n/a<=9&&n/a>=1){
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
from itertools import permutations

N = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
A = [i for i in range(1, N+1)]
cnt = 0
op = -1
oq = -1
for j in permutations(A):
  cnt += 1
  if(j == p):
    op = cnt
  if(j == q):
    oq = cnt
    
print(abs(op-oq))

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, t;
	ll ans =0, lt=0;
	cin >>n >>t;
	
	rep(i,n){
		ll v;
		cin >>v;
		if(lt <= v){
			ans += t;
		}else{
			ans += v +t -lt;
		}
		lt = v+t;
	}
	cout << ans << endl;
	return 0;
}

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

#define josh 0
#define ll long long
#define llu long long unsigned
#define ii pair<int ,int>
#define iii pair<int, ii>
#define all(v) (v).begin(), (v).end()
#define vout(v) for(auto i:v)cout<<i<<" "; cout<<endl;
#define loop(x, n, p) for(int i=x; p>0 ? i<n : i>=n; i+=p)
#define deb(x) cout<<#x<<" "<<x<<endl;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define file(x) if(x=="in")freopen("input.txt", "r", stdin); \
                else{freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}


/*

template <typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template <typename T>
T get(T& a){
    read(a);
    return a;
}

*/

struct Converter{
template<typename T>
    T toNum(string s, T& n){
        stringstream ss; ss<<s;
        ss>>n;
        return n;
    }
template <typename T>
    string toString(T& n){
        stringstream ss; ss<<n;
        string s; ss>>s;
        return s;
    }

}convert;

struct Prime{

    bool isPrime[10000007]={0};
    std::vector<int> primeContain;

    void sieve(int n){

        memset(isPrime, true, sizeof(isPrime));

        for (int p=2; p*p<=n; p++){
            if (isPrime[p] == true){
                for (int i=p*p; i<=n; i += p)
                    isPrime[i] = false;
            }
        }
        isPrime[0]=0, isPrime[1]=0;
        loop(2, n+7, 1)
            if(isPrime[i])
                primeContain.push_back(i);

    }




}prime;




/*................................let's do it bitch............................................*/




int main(){

    int w, h, x, y, r; cin>>w>>h>>x>>y>>r;
    printf(((x-r)<0 || (x+r)>w || (y-r)<0 || (y+r)>h) ? "No\n" : "Yes\n");

return josh;
}















Measured memory_bytes: 12976
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
typedef long long ll;
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5]){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>S>>K;
    N = S.size();
    set<string> dic;
    reps(i,1,K+1){
        rep(j,N+1-i){
            string p = "";
            rep(k,i) p.push_back(S[j+k]);
            dic.insert(p);
        }
    }
    auto ite = dic.begin();
    rep(i,K-1) ++ite;
    cout<<*ite<<endl;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    double A,B,c;
    A=(double)a;
    B=(double)1/b;
    cout << a/b << " " << a%b << " ";
    cout << fixed << setprecision(12) << A*B << endl;
    return 0;
}


Measured memory_bytes: 3260
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n, X, Y;
    cin >> n >> X >> Y;
    vi x(n, 0);
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int t = min(abs(j - i) , min(abs(i - X) + abs(j - Y) + 1 , abs(i - Y) + abs(j - X)  + 1 ));
            x[t]++;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << x[i] << endl;
    }

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------
/*
const int MAXN = 1e3+5;
vector<int> p;

void sieve()
{
    vector<bool> a(MAXN,false);
    for(int i=2; i<=MAXN; ++i)
    if (!a[i])
    {
        p.pb(i);
        for(int j=i; j<=MAXN/i; ++j)
            a[j*i]=true;
    }
    for(int x:p) cout << x << '\n';
}
*/
int main()
{
    Phuong_;
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int sum=0;
    for(int i=0; i<n; ++i)
    {
        cin >> a[i];
        sum+=a[i];
    }
    sum += (4*m-1);
    sum/=(4*m);
    bool can=false;
    for(int i=0; i<n; ++i)
    {
        if (a[i]>=sum)  m--;
        if (m==0)
        {
            can=true;
        }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

signed main(){
    int A=1e16,a[5],n;
    cin>>n;
    r(i,5)cin>>a[i],A=min(A,a[i]);
    cout<<5+(n/A)+(n%A?0:-1)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int N, M;
int MOD;
int Fact[6005], Inv[6005], Pw2[6005], Pw3[6005], IPw2[6005], IPw3[6005];
int power(int n, int p){
    int sol = 1;
    while(p){
        if(p & 1)
            sol = (1LL * sol * n) % MOD;
        p /= 2;
        n = (1LL * n * n) % MOD;
    }
    return sol;
}
void precalcFact(){
    Fact[0] = 1;
    for(int i = 1; i <= N * 3; i++){
        Fact[i] = (1LL * Fact[i - 1] * i) % MOD;
    }
    Inv[N * 3] = power(Fact[N * 3], M - 2);
    for(int i = N * 3 - 1; i >= 0; i--)
        Inv[i] = (1LL * Inv[i + 1] * (i + 1)) % MOD;
}

void precalcPower(){
    Pw2[0] = 1;
    Pw3[0] = 1;
    IPw2[0] = 1;
    IPw3[0] = 1;
    for(int i = 1; i <= N * 3; i++){
        Pw2[i] = (1LL * Pw2[i - 1] * 2) % MOD;
        Pw3[i] = (1LL * Pw3[i - 1] * 3) % MOD;
        IPw2[i] = power(Pw2[i], M - 2);
        IPw3[i] = power(Pw3[i], M - 2);
    }
}
int compute(int p1, int p2, int p3){
    int ans = Fact[3 * N];
    ans = (1LL * ans * Inv[p1]) % MOD;
    ans = (1LL * ans * Inv[p2]) % MOD;
    ans = (1LL * ans * Inv[p3]) % MOD;
    ans = (1LL * ans * IPw2[p2]) % MOD;
    ans = (1LL * ans * IPw3[p3]) % MOD;
    return ans;
}
void Solve(){
    int ans = 0;
    for(int i = 0; i <= N * 3; i++){
        for(int j = 0; j <= N * 3; j++){
            int g1 = 3 * N - 2 * i - 3 * j;
            if(g1 < i)
                break;
            ans += compute(g1, i, j);
            if(ans >= MOD)
                ans -= MOD;
        }
    }
    cout << ans << '\n';
}
int main()
{
    cin >> N >> M;
    MOD = M;
    precalcFact();
    precalcPower();
    Solve();
    return 0;
}


Measured memory_bytes: 384
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    H,W=map(int,readline().split())

    if H==1:
        print(1)
    elif W==1:
        print(1)
    elif H%2==0:
        print(H*W//2)
    elif H%2==1:
        if W%2==0:
            print(H*W//2)
        elif W%2==1:
            print((H//2)*(W//2)+(H//2+1)*(W//2+1))
if __name__=="__main__":
    main()

Measured memory_bytes: 3060
using System;
class A_Transfer{
	static void Main(string[] args){
		string[] ABC = Console.ReadLine().Split(' ');
		int A = int.Parse(ABC[0]);
		int B = int.Parse(ABC[1]);
		int C = int.Parse(ABC[2]);
		Console.WriteLine(A - B < C ? C - (A - B) : 0);
	}
}

Measured memory_bytes: 13140