akhauriyash/Code-Regression huggingface dataset:
def md(a,b,c,d):
    return abs(a-c) + abs(b-d)
n,m = map(int, input().split())
s = []
for i in range(n):
    y,x = map(int, input().split())
    s.append((y,x))
c = []
for i in range(m):
    y,x = map(int, input().split())
    c.append((y,x))
for i in range(n):
    min_j = 0
    min_d = float('inf')
    for j in range(m):
        d = md(s[i][0], s[i][1], c[j][0], c[j][1])
        if min_d > d:
            min_j = j
            min_d = d
    print(min_j+1)




Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
typedef long long ll;
ll a,b,c,d,ans,N,M,tt,A[200007],B[200007],p[200007];
bool cmp(ll x1,ll x2){
	return B[x1]<B[x2];
}
int main(){
	scanf("%lld",&N);
	rep(i,1,N) scanf("%lld%lld",&A[i],&B[i]);
	rep(i,1,N) p[i]=i;
	sort(p+1,p+N+1,cmp);
	ll t=0;
	rep(i,1,N){
		t+=A[p[i]];
		if (t>B[p[i]]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Circle
{
    Circle(double x, double y, double r)
        : x(x), y(y), r(r)
    {
    }
    Circle() {}
    double x, y;
    double r;
};
struct Vertex
{
    int i;
    double cost;
};

Circle C[1005];
//! startから点iまでの最短距離
double L[1005];

double length(Circle c0, Circle c1)
{
    return std::max(sqrt(pow(c0.x - c1.x, 2) + pow(c0.y - c1.y, 2)) - c0.r - c1.r, (double)0);
}

int main()
{
    double x0, y0, x1, y1;
    int N;
    cin >> x0 >> y0 >> x1 >> y1;
    cin >> N;
    REP(i, N)
    {
        double x, y, r;
        cin >> x >> y >> r;
        C[i] = Circle(x, y, r);
        L[i] = INF;
    }
    C[N] = Circle(x1, y1, 0);
    L[N] = INF;

    priority_queue<Vertex, vector<Vertex>, function<bool(Vertex, Vertex)>> q([](Vertex a, Vertex b) { return a.cost > b.cost; });
    Circle c(x0, y0, 0);
    REP(i, N + 1)
    {
        double cost = length(c, C[i]);
        Vertex v;
        v.i = i;
        v.cost = cost;
        q.push(v);
    }

    while (!q.empty())
    {
        Vertex v = q.top();
        q.pop();
        if (L[v.i] <= v.cost)
            continue;
        L[v.i] = v.cost;
        REP(i, N + 1)
        {
            if (i == v.i)
                continue;
            double cost = v.cost + length(C[i], C[v.i]);
            if (cost >= L[i])
                continue;
            Vertex nv;
            nv.i = i;
            nv.cost = cost;
            q.push(nv);
        }
    }
    cout << OF64 << L[N] << endl;
    return 0;
}

Measured memory_bytes: 10476
N, K = map(int, input().split())

if K % 2 == 1:
    num = N // K
    ans = num ** 3
else:
    K_ = K // 2
    num1 = N // K
    num2 = (N + K - K_) // K
    ans = num1 ** 3 + num2 ** 3

print(ans)


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

macro_rules! input {
    ($($name:ident : $t:tt),*,) => {
        input!($($name: $t),*)
    };
    ($($name:ident : $t:tt),*) => {
        let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
        $(
            let $name = unsafe { _read_value!(_scanned, $t) };
        )*
    };
}

macro_rules! _read_value {
    ($scanned:expr, ($($t:tt),*)) => {
        ($(_read_value!($scanned, $t)),*)
    };
    ($scanned:expr, 1based) => {
        _read_value!($scanned, usize) - 1
    };
    ($scanned:expr, [u8]) => {
        _read_value!($scanned, String).into_bytes()
    };
    ($scanned:expr, [$t:tt; $n:expr]) => {
        (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
    };
    ($scanned:expr, $t:ty) => {
        $scanned.next::<$t>()
    };
}

mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::iter::{self, Product, Sum};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Deref,
    DerefMut, Div, DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

fn main() {
    input! {
        w: f64,
        h: f64,
        x: f64,
        y: f64,
    }
    let p1 = w - 2.0 * x == 0.0;
    let p2 = h - 2.0 * y == 0.0;
    if p1 && p2 {
        println!("{} 1", w * h / 2.0);
    } else {
        println!("{} 0", w * h / 2.0);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main() {
  ll n;
  double d;
  cin >> n >> d;
  double sum[1000000];
  for (int i = 0; i < n ; i++){
    double  a, b;
    cin >> a >> b;
    sum[i] = sqrt(a*a + b*b);
  }

  ll ans = 0;
  for (int i = 0; i < n; i++ ){
    if (sum[i] <= d){
      ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


int main(){
  int n;
  cin >> n; // 偶数
  vector<ll> ai(n, 0);
  rep(i,n) {
    cin >> ai[i];
  }

  ll totalxor =ai[0];
  for(int i = 1; i < n; ++i) {
    totalxor = totalxor ^ ai[i];
  }
  rep(i,n) {
    if (i > 0) {
      cout << " ";
    }
    cout << (totalxor ^ ai[i]);
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 4832
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        int w = in.nextInt();

        long[] wa = new long[n];
        int[] va = new int[n];
        int vsum = 0;
        for (int i = 0; i < n; i++) {
            wa[i] = in.nextInt();
            va[i] = in.nextInt();
            vsum += va[i];
        }
        vsum++;
        long[][] dp = new long[n][vsum + 1];
        for (int i = 0; i <= vsum; i++) {
            if (i == va[0]) {
                dp[0][va[0]] = wa[0];
            } else {
                dp[0][i] = Integer.MAX_VALUE;
            }
        }
        dp[0][0] = 0;
        for (int i = 1; i < n; i++) {
            for (int j = 0; j <= vsum; j++) {
                long val = (j - va[i] >= 0) ? wa[i] + dp[i - 1][j - va[i]] : Integer.MAX_VALUE;
                dp[i][j] = Math.min(dp[i - 1][j], val);
            }
        }

        long ans = 0;
        for (int k = 0; k < vsum; k++) {
            if (dp[n - 1][k] <= w) {
                ans = Math.max(ans, k);
            }
        }
        out.println(ans);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


Measured memory_bytes: 125072
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;

const ll mod = 1000000007;
const int N = 2e5+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
char s[N];
int a[N];
ll dp[N][2];
void init(char * s) {
	mt(a, 0); mt(dp, -1);
	int n = strlen(s);
	repd(i, n - 1, 0) a[i] = s[n - i - 1] - '0'; //, dd(i), de(a[i]);
}
ll DP(int pos, int fg) {
	if(pos == -1) return 1ll;
	ll & ret = dp[pos][fg];
	if(ret != -1) return ret;
	ret = 0;
	// a 1 b 0 or a 0 b 1
	if(fg || a[pos] == 1) ret += 2ll * DP(pos - 1, fg);
	// a 0 b 0
	ret += DP(pos - 1, fg || a[pos] == 1);
	ret %= mod;
	return ret;
}
int main() {
	while(~scanf("%s", s)) {
		init(s);
		printf("%lld\n", DP(N - 1, 0));
	}
    return 0;
}


Measured memory_bytes: 13696
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B;
  cin>>A>>B;
  cout<<max({A+B,A-B,A*B})<<endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    min = -1

    for i in a:
        now = i
        count =0
        while now >1:
            if now %2 ==0:
                now=now//2
                count+=1
            else:
                break
        if min == -1 or min > count:
            min=count
    print(min)

Measured memory_bytes: 3060
def fact(n):
	return 1 if n == 0 else n*fact(n-1)

S = raw_input()
l,s = len(S),set(list(S))
lens = len(s)
d = [S.count(i) for i in s]
if l%2 == 0:
	for i in range(lens):
		if d[i]%2 == 1:
			print 0
			break
	else:
		denomi = 1
		for i in range(lens):
			denomi *= fact(d[i]/2)
		print fact(l/2)/denomi
else:
	for i in range(lens):
		if sum([d[i]%2 for i in range(lens)]) != 1:
			print 0
			break
	else:
		denomi = 1
		for i in range(lens):
			denomi *= fact(d[i]/2) if d[i]%2 == 0 else fact((d[i]-1)/2)
		print fact((l-1)/2)/denomi

Measured memory_bytes: 4268
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1000005];
int dp[1000005];
bool visited[1000005];
void visit(int vertex)
{
    visited[vertex]=1;
    dp[vertex]=0;
    for(int child: adj[vertex])
    {
        if(!visited[child])
        visit(child);
        
        dp[vertex]=max(dp[vertex],dp[child]+1);
    }
}

int main()
{
    int x,y,a,b;
    cin>>x>>y;
    for(int i=0;i<y;i++)
    {
        cin>>a>>b;
        adj[a].push_back(b);
    }

for(int i=1;i<=x;i++)
{
    if(!visited[i])
    visit(i);
}
int ans=0;
for(int i=1;i<=x;i++)
ans=max(ans,dp[i]);
cout<<ans;

    return 0;
}


Measured memory_bytes: 33384
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define REP(i,M) for(int i=0;i<M;i++)
 
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;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  ll N = input();
  map<int,int> data;

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

  for(int i=0;i<N-1;i++){
    int index = input()-1;
    data[index]++;
  }
  for(auto iter:data){
    output(iter.second);
  }

  return 0;
}

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

int main(){
    int n ;
    cin >> n ;
    vector<int> v(n) ;
    for(int i=0;i<n;i++){
        cin >> v[i] ;
    }
    int nax = 1e9 ;
    for(int i=-200;i<=200;i++){
        int ans = 0 ;
        for(int j=0;j<n;j++){
            ans += (v[j]-i)*(v[j]-i);
        }
        nax = min(nax,ans);
    }
    cout << nax << endl;
    return 0 ;
}


Measured memory_bytes: 256
import sys
from heapq import *
sys.setrecursionlimit(200000)

def rec(i):
  if dp[i] != 0:
    return dp[i]
  res = 0
  for j in E[i]:
    res = max(rec(j) + 1, res)
  dp[i] = res
  return dp[i]


#入力
N,M = (int(x) for x in input().split())
#エッジ
E = [[] for _ in [0]*N]
dp = [0]*N

for i in range(M):
  a,b = (int(x) for x in input().split())
  E[a-1].append(b-1)

ans = 0
for i in range(N):
  ans = max(ans, rec(i))

#出力
print(ans)


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

const int N = 2e5 + 5;

int n, t = 0, ans = 0, a[N], b[N], dp[N], tree[N];
map <int, int> m;

signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		m[a[i]]++;
	}
	for (auto& x : m) {
		x.second = ++t;
	}
	for (int i = 1; i <= n; i++) {
		a[i] = m[a[i]];
		cin >> b[i];
	}
	function <void(int, int)> update = [&](int k, int x) {
		while (k <= t) {
			tree[k] = max(tree[k], x);
			k += k & -k;
		}
	};
	function <int(int)> get = [&](int k) {
		int mx = 0;
		while (k >= 1) {
			mx = max(mx, tree[k]);
			k -= k & -k;
		}
		return mx;
	};
	for (int i = 1; i <= n; i++) {
		dp[a[i]] = get(a[i]) + b[i];
		update(a[i], dp[a[i]]);
		ans = max(ans, dp[a[i]]);
	}
	cout << ans;
}

Measured memory_bytes: 18944
module Main where

import Data.Functor

main :: IO ()
main = do
  { [a, b] <- getInts
  ; if a < b then putStrLn "a < b"
    else if a > b then putStrLn "a > b"
         else putStrLn "a == b"
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 3620
#include <cstdlib>
#include <iostream>
#include <typeinfo>
//#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

  int ans;
  ans = H * W - h * W - w * H + h * w;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (1000003LL)
typedef long long Int;

int n, mi, memo[60000*4], cs[60000][2];
vector<int> g[60000];
bool has[60000];

void add(int p, int q) {
    if (p > q) swap(p, q);
    g[p].push_back(q);
}

int pre(int p, int q) {
    if (p+1 == q) return -1;
    const int k = mi++;
    has[k] = false;
    if (g[p].back() == q) {
        has[k] = true;
        g[p].pop_back();
    }
    const int r = g[p].back();
    rep (b, 4) memo[k*4|b] = -1;
    cs[k][0] = pre(p, r);
    cs[k][1] = pre(r, q);
    return k;
}

int rec(int k, int x, int y) {
    if (k == -1) return x == y;
    const int sig = k*4|x*2|y;
    if (memo[sig] != -1) return memo[sig];
    const int p = cs[k][0], q = cs[k][1];
    Int ans = 0;
    rep (i, 2) ans = (ans + (Int)rec(p, x, i)*rec(q, 1-i, y)) % MOD;
    if (x && y && has[k]) {
        rep (i, 2) ans = (ans + (Int)rec(p, 0, i)*rec(q, 1-i, 0)) % MOD;
    }
    return memo[sig] = ans;
}

int main() {
    for (;;) {
        int m, a, b;
        scanf("%d%d", &n, &m);
        if (n == 0) return 0;
        rep (i, 60000) g[i].clear();
        rep (_, m) {
            scanf("%d%d", &a, &b);
            add(a-1, b-1);
        }
        rep (i, n) add(i, (i+1)%n);
        rep (i, n) sort(g[i].begin(), g[i].end());
        mi = 0;
        pre(0, n-1);
        printf("%d\n", (int)rec(0, 1, 1));
    }
}

Measured memory_bytes: 10276
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
ll power(ll a,ll b)
{ll result=1;
while(b>0)
{if(b%2==1)
 result*=a;
 a*=a;
 b/=2;
}
return result;
}
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll n,sum=0;
cin>>n;
ll a[n];
for(ll i=0;i<n;i++)
cin>>a[i];
for(ll i=1;i<n;i++)
{if(a[i]<a[i-1])
 {
  sum+=a[i-1]-a[i];
  a[i]=a[i-1];
  //cout<<sum;
}
}
/*for(ll i=0;i<n;i++)
cout<<a[i];*/
cout<<sum;
}


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

int dp[102][2][4];

int main()
{
    string n;
    cin >> n;
    int k;
    cin >> k;
    int l = n.size();
    reverse(n.begin(), n.end());
    dp[0][0][0] = 1;
    for(int i = 1; i <= l; i++){
        for(int j = 0; j <= k; j++){
            if(n[i - 1] == '0'){
                dp[i][0][j] += dp[i - 1][0][j];
                dp[i][1][j] += dp[i - 1][1][j];
            }
            else{
                dp[i][0][j] += dp[i - 1][0][j] + dp[i - 1][1][j];
            }
        }
        for(int j = 1; j <= k; j++){
            if(n[i - 1] == '0') dp[i][1][j] += (dp[i - 1][0][j - 1] + dp[i - 1][1][j - 1]) * 9;
            else{
                dp[i][0][j] += dp[i - 1][0][j - 1] * (n[i - 1] - '0') + dp[i - 1][1][j - 1] * (n[i - 1] - '0' - 1);
                dp[i][1][j] += dp[i - 1][0][j - 1] * (9 - (n[i - 1] - '0')) + dp[i - 1][1][j - 1] * (10 - (n[i - 1] - '0'));
            }
        }
    }
    cout << dp[l][0][k] << endl;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int gcd(int, int);
	cout << gcd(a, b) << endl;
	return 0;
}

int gcd(int m, int n) {
	int r;
	while (n != 0) {
		r = m % n;
		m = n;
		n = r;
	}
	return m;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 50000;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
char text[MAXN];
int arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    int g = 0;
    for (int i = 0; i < n; i++) {
        arr[i] = read<int>();
    }
    for (int i = 1; i < n; i += 2) {
        g ^= arr[i] ^ arr[i - 1];
    }
    for (int i = 0; i < n; i++) {
        printf("%d ", g ^ arr[i]);
    }
    return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define rep(i,f,n) for(int i=(f); (i) < (n); i++)
#define repe(i,f,n) for(int i=(f); (i) <= (n); i++)
#define PI 3.14159265359
#define MOD (ll)1000000007
using namespace std;
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}


typedef long long ll;
ll INF = 1e+18;

int main() {
  int A, B; cin >> A >> B;
  cout << A * B << endl;

}

Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from collections import defaultdict
def resolve():
    n,a,d=map(int,input().split())
    if(d==0):
        if(a==0): print(1)
        else: print(n+1)
        return
    if(d<0): a,d=-a,-d

    D=defaultdict(list)
    for k in range(n+1):
        L=k*a+k*(k-1)*d//2
        R=k*a+k*(2*n-k-1)*d//2
        r=L%d
        D[r].append((L//d,0))
        D[r].append((R//d,1))


    ans=0
    for arr in D.values():
        arr.sort()
        over=0
        now=0
        for v,q in arr:
            if(q==0):
                if(not over): now=v
                over+=1
            else:
                over-=1
                if(not over): ans+=v-now+1

    print(ans)
resolve()

Measured memory_bytes: 88020
#include <cstdio>
#include <cstring>
#include <algorithm>

const int MN = 105, Sig = 26;

int N;
char S[MN];
int lst[Sig], ans[Sig];

int main() {
	scanf("%s", S + 1), N = strlen(S + 1);
	for (int i = 1; i <= N; ++i) {
		int x = S[i] - 'a';
		ans[x] = std::max(ans[x], i - lst[x] - 1);
		lst[x] = i;
	}
	int tans = N;
	for (int x = 0; x < Sig; ++x) tans = std::min(tans, std::max(ans[x], N - lst[x]));
	printf("%d\n", tans);
	return 0;
}

Measured memory_bytes: 1720
L = input()
MOD = 10 ** 9 + 7
N = len(L)

dp = [[0] * 2 for _ in range(N + 1)]
dp[0][0] = 1

for i in range(N) :
    if L[i] == '1' :
        dp[i+1][0] = (dp[i][0] * 2) % MOD
        dp[i+1][1] = (dp[i][0] + dp[i][1] * 3) % MOD
    else :
        dp[i+1][0] = dp[i][0]
        dp[i+1][1] = (dp[i][1] * 3) % MOD

print(sum(dp[N]) % MOD)

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

int main(){
	double tim1[] = {35.5,37.5,40.0,43.0,50.0,55.0,70.0},tim2[] = {71.0,77.0,83.0,89.0,105.0,116.0,148.0};
	string rnk[] = {"AAA","AA","A","B","C","D","E"};
	double t1,t2;
	while(cin >> t1 >> t2){
		int i = 0;
		for(;i < 7;i++){
			if(t1 < tim1[i] && t2 < tim2[i]) break;
		}
		if(i == 7) cout << "NA" << endl;
		else cout << rnk[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n,k;
    cin>>n>>k;
    vector<double> p(n);
    rep(i,n) cin>>p[i];

    rep(i,n){
        p[i]=(p[i]+1)/2;
    }

    vector<double> sum(n+1,0);
    rep(i,n) sum[i+1]=sum[i]+p[i];

    double ans=0;
    rep(i,n){
        ans=max(ans,sum[min(n,i+k)]-sum[i]);
    }

    cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 6512
dan = list(input())
wid = len(dan)
stack_s1 = list()
stack_s2 = list()

for i in range(wid):
    if dan[i] == '\\':
        stack_s1.append(i)
    if len(stack_s1) > 0 and dan[i] == '/':
        j = stack_s1.pop()
        men = i - j
        while len(stack_s2) > 0 and j < stack_s2[-1][0]:
            tmp = stack_s2.pop()
            men += tmp[1]
        stack_s2.append([j, men])

t_men = 0
k = list()
k.append(str(len(stack_s2)))
for i, j in stack_s2:
    t_men += j
    k.append(str(j))
print(t_men)
print(' '.join(k))



Measured memory_bytes: 6360
// LNU_Algotesters
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <fstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MAX = 1000 * 1000 + 47;





int main()
{
    //freopen("input.txt", "r", stdin);
    LL a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
        cout << 0 << endl;
    else cout << min(min(a * b, a * c), b * c) << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};

int n, ans[100][100], dir = 0;
vector<vector<int> > g;
bool used[10000];

int main() {
    cin >> n;
    g.resize(n*n);
    for(int i=0;i<2*(n*n-n);i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    int s = -1;
    for(int i=0;i<n*n;i++){
        if(g[i].size()==2){
            s = i;
            break;
        }
    }
    for(int i=0;i<n;i++){
        ans[0][i] = s;
        used[s] = true;
        for(auto v : g[s]){
            if(used[v]) continue;
            if(g[v].size()<=3){
                s = v;
                break;
            }
        }
    }
    for(int i=1;i<n;i++){
        for(int j=0;j<n;j++){
            for(auto v : g[ans[i-1][j]]){
                if(used[v]) continue;
                ans[i][j] = v;
                used[v] = true;
            }
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout << ans[i][j]+1 << " \n"[j==n-1];
        }
    }
    return 0;
}



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

int main()
{
  const int mod = 1000000007;
  long n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  long s = 0, t = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a.at(i) > a.at(j)) s++;
      if (a.at(i) != a.at(j)) t++;
    }
  }
  long l = (k - 1) % 2 == 0 ? (k - 1) / 2 : (k - 1 + mod) / 2;
  s = k * (s + l * t % mod) % mod;
  cout << s << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000

int main(){
	int x, y, z;
	int s, ans;
	scanf("%d %d %d", &x, &y, &z);
	s = x + y + 1;
	ans = min(s, z);
	ans += y;

	printf("%d\n", ans);


	return 0;
}



Measured memory_bytes: 128
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	while(cin>>n,n){
		vint v(2*n);
		set<int> a;
		set<int> b;
		rep(i,n){
			int t;
			cin>>t;
			a.insert(t);
			v[t-1]=1;
		}
		rep(i,2*n){
			if(v[i]==0) b.insert(i+1);
		}
		pii turn(0,0);
		pii ans(0,0);
		while(1){
			// cout<<a.size()<<" "<<b.size()<<endl;
			if(a.size()==0){
				ans.F=b.size();
				break;
			}
			if(b.size()==0){
				ans.S=a.size();
				break;
			}
			if(turn.S==0){
				auto it=a.upper_bound(turn.F);
				if(it==a.end()){
					turn=pii(0,1);
				}
				else{
					// cout<<"a "<< *it<<endl;
					a.erase(it);
					turn=pii(*it,1);
				}
			}
			else if(turn.S==1){
				auto it=b.upper_bound(turn.F);
				if(it==b.end()){
					turn=pii(0,0);
				}
				else{
					// cout<<"b "<< *it<<endl;
					b.erase(it);
					turn=pii(*it,0);
				}
			}
		}
		cout<<ans.F<<endl<<ans.S<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <cmath>
#include <cctype>

using namespace std;

int main()
{
	char W[10], T[100];
	int count = 0;

	cin >> W;

	while (1) {
		cin >> T;
		if (strcmp("END_OF_TEXT", T) == 0) break;
		int i = 0;
		while (T[i] != '\0') {
			if ('A' <= T[i] && T[i] <= 'Z') T[i] += 'a' - 'A';
			i++;
		} 

		if (strcmp(W, T) == 0) count++;
		
	}
	printf("%d\n", count);

	return (0);
}

Measured memory_bytes: 1124
#include <bits/stdc++.h>
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE1=1e6+1000;
const int SIZE2=2020;
const int SIZE3=410;
const int SIZE=SIZE1;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string S;
ut N,M,K,X,Y;
// ut A,B,C,D,E,F,G,H,I,J,L,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE],nums[SIZE],maps[SIZE2][SIZE2],answer=zero;
 
////////////////////////////////////////////////////////////////////////////////////////////
 
////////////////////////////////////////////////////////////////////////////////////////////
 
LL solve(){
	cin >> X >> Y;
	int ans=0;
	while(X<=Y){
		ans++;
		X*=2;
	}
	return ans;
}
signed main(){
	OUT(solve());
	return 0;
}

Measured memory_bytes: 24192
N, M = map(int, input().split())
aL, aR = 0, 10**6
for _ in range(M):
    L, R = map(int, input().split())
    aL = max(aL, L)
    aR = min(aR, R)
if aR>= aL:
    print(aR-aL+1)
else:
    print(0)

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> v[n];
    string ans[m];
    rep(i, m)
    {
        int p, y;
        cin >> p >> y;
        p--;
        v[p].push_back(pii(y, i));
    }

    rep(i, n) sort(ALL(v[i]));
    rep(i, n)
    {
        rep(j, v[i].size())
        {
            stringstream ss;
            ss << setw(6) << setfill('0') << i + 1;
            stringstream tt;
            tt << setw(6) << setfill('0') << j + 1;
            ans[v[i][j].second] = ss.str() + tt.str();
        }
    }
    rep(i, m) OP(ans[i]);

    return 0;
}

Measured memory_bytes: 12416
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int ma = cin.Int();
			int mb = cin.Int();
			var val = new Tuple<int, int>[n];
			for (int i = 0; i < n; i++) {
				int a = cin.Int();
				int b = cin.Int();
				int c = cin.Int();
				int d = a * mb - b * ma;
				val[i] = new Tuple<int, int>(d, c);
			}

			int offset = 10000;
			int range = offset * 2 + 1;
			int max = 10000000;
			int[,] dp = new int[n + 1, range];
			for (int i = 0; i <= n; i++) {
				for (int j = 0; j < range; j++) {
					dp[i, j] = max;
				}
			}

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < range; j++) {
					if (dp[i, j] != max) {
						dp[i + 1, j + val[i].Item1] = Math.Min(
							dp[i, j + val[i].Item1],
							dp[i, j] + val[i].Item2);

						dp[i + 1, j] = Math.Min(dp[i + 1, j], dp[i, j]);
					}
				}
				
				dp[i + 1, val[i].Item1 + offset] = Math.Min(dp[i, val[i].Item1 + offset], val[i].Item2);
			}

			if (dp[n, offset] == max) {
				Console.WriteLine(-1);
				return;
			}

			Console.WriteLine(dp[n, offset]);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 14176
#include <cstdio>
#include <cassert>
#include <queue>
#include <deque>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <cstdlib>
#include <string>
#include <unordered_map>
#include <sstream>
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef unsigned char byte;
typedef unsigned int uint;
typedef unsigned long long int ulli;

vector<pii> ll[100100];
int checked[100100];
const int IMP = -1e9 - 100;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    int i;
    while (m--) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        ll[a].emplace_back(b, c);
        ll[b].emplace_back(a, -c);
    }
    for (i=1; i<=n; ++i) {
        checked[i] = IMP;
    }
    for (i=1; i<=n; ++i) {
        if (checked[i] == IMP) {
            checked[i] = 0;
            queue<int> q;
            q.push(i);
            while (!q.empty()) {
                int f = q.front();
                q.pop();
                for (auto e : ll[f]) {
                    if (checked[e.first] == IMP) {
                        checked[e.first] = checked[f] + e.second;
                        q.push(e.first);
                    } else if (checked[e.first] != checked[f] + e.second) {
                        return puts("No") & 0;
                    }
                }
            }
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 9344
#include <stdio.h>

int main(){
    int h, w;
    int i, j;
    while(1){
        scanf("%d %d ", &h, &w);
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if((i%2==0&&j%2==0)||(i%2==1&&j%2==1)){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

struct edge{int to,cost;};
vector<int> G[100005];
 
long long int n,m,k,i,j=1;
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1,};
ll a,b,c;

std::vector<P> tree[100010];
long long int d[100005];
bool flag=false;

void bfs(int node,ll x){
	d[node] = x;
	for(int i=0;i<tree[node].size();i++){
		if(d[tree[node][i].first]==INF){
			bfs(tree[node][i].first,x+tree[node][i].second);
		}else{
			if(d[tree[node][i].first]!=x+tree[node][i].second){
				flag=true;
			}
		}
	}
}

int main(){
	cin>>n>>m;
	for(i=1;i<=m;i++){
		cin>>a>>b>>c;
		tree[a].push_back(P(b,c));
		tree[b].push_back(P(a,-c));
	}
	for(i=1;i<=n;i++)d[i]=INF;
	for(i=1;i<=n;i++){
		if(d[i]==INF)bfs(i,0);
	}
	if(flag){
		cout<<"No";
	}else{
		cout<<"Yes";
	}

	cout<<endl;
	return 0;
}

Measured memory_bytes: 18816
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int N, out;
	cin >> N;
	for (int i = 0; i < 7; i++) {
		if (pow(2, i) <= N && N < pow(2, i + 1)) out = pow(2, i);
	}
	cout << out << endl;
}

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

int main(){
  int A,B,pul,min,mul;
  cin >> A >> B;
  pul = A+B;min = A-B;mul = A*B;
  if (pul >= min and pul >= mul){
    cout << pul <<endl;
  }else{
    if (min >= pul and min >= mul){
      cout << min <<endl;
    }else{
      if (mul >= min and mul >= pul){
 	    cout << mul <<endl;
      }
    }
  }
}


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

using namespace std;

typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    int P = 1;
    for (int i = 0; i < n; i++) {
        int tmp = (a[i] - 1) / P;
        ans += tmp;
        a[i] -= tmp * P;
        if (tmp != 0) a[i] = 1;
        if (a[i] == P) P++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <utility>
using namespace std;

using i64 = long long;

#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)

i64 D[13];
i64 E[13];
const i64 M = 1000000007;
signed main() {
	D[0] = 1;
	while(true) {
		char c = getchar();
		if (c == '\n') {
			break;
		} else if (c == '?') {
			REP(r, 13) {
				i64 s = 0;
				REP(j, 10) {
					s += D[(j - r + 13) * 9 % 13];
				}
				E[r] = s % M;
			}
		} else {
			i64 d = c - '0';
			REP(r, 13) {
				i64 s = D[(d - r + 13) * 9 % 13];
				E[r] = s % M;
			}
		}
		swap(D, E);
	}
	printf("%d", D[5]);
}


Measured memory_bytes: 128
from  bisect import bisect

n,d,a=map(int,input().split())
monster=[list(map(int,input().split())) for i in range(n)]
monster.sort(key=lambda i:i[0])
r=[monster[i][0] for i in range(n)]
hp=[monster[i][1] for i  in range(n)]
#print(r,hp)

d=2*d
i,ans,damages=0,0,[0]*n
while i<n:
  if i>0:
    damages[i]+=damages[i-1]
    s=hp[i]+damages[i]
  else:
    s=hp[i]
  if s>0:
    cnt=(s+a-1)//a
    ans+=cnt
    #print(ans)
    damage=cnt*a
    damages[i]-=damage
    zone=bisect(r,r[i]+d)
    if zone<n:
      damages[zone]+=damage 
  i+=1
  #print(damages)
  #print(hp)
print(ans)


Measured memory_bytes: 62888
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  vector<ll> B(N);
  vector<ll> C(N);
  for(ll i=0;i<N;i++)cin>>A[i];
  for(ll i=0;i<N;i++)cin>>B[i];
  for(ll i=0;i<N;i++)cin>>C[i];
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  ll ans=0;
  for(ll i=0;i<N;i++){
    ll low_num=N-(upper_bound(C.begin(),C.end(),B[i])-C.begin());
    ll upp_num=lower_bound(A.begin(),A.end(),B[i])-A.begin();
    ans+=low_num*upp_num;
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 2560
number = int(input())
# values = [i+2 for i in range(2*10**5)]
values = list(map(int, input().split()))

maxV = 10**6+1
dp = [0]*(maxV)

for a in values:
    i = 1
    if dp[a] > 0:
        dp[a] = dp[a] + 1
        continue
    while i * a < maxV:
        i_a = i * a
        dp[i_a] = dp[i_a] + 1
        i += 1

count = 0
for a in values:
    if dp[a] == 1:
        count+=1

print(count)


Measured memory_bytes: 32224
#include <iostream>
#include <deque>
#include <string>
using namespace std;

int main(){
	int n;cin >> n;
	string s;
	while(n--){
		deque<char> d;
		cin >> s;
		int p = 0;
		d.push_back(s[0]);
		for(int i = 1;i < s.size();i += 3){
			if(s[i] == '<'){
				if(!p)d.push_front(s[i+2]);
				else p--;
			}else{
				if(p == d.size()-1)d.push_back(s[i+2]);
				p++;
			}
		}
		for(int i = 0;i < d.size();i++)cout << d[i];
		cout << endl;
	}
	return 0;
}

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

int main() {
 int R;
 cin >> R;
  if(R < 1200) cout << "ABC" << endl;
  if(R >= 1200 && R < 2800) cout << "ARC" << endl;
  if(R >= 2800) cout << "AGC" << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func Find(E *[][]int, src, dst int) []int {
  P := make([]int, len((*E)))
  for i := range P {
    P[i] = -1
  }
  P[src] = src
  Q := make([]int, 0)
  Q = append(Q, src)
  for len(Q) > 0 {
    q := Q[0]
    Q = Q[1:]
    if q == dst { break }
    for _, adj := range (*E)[q] {
      if P[adj] >= 0 { continue }
      P[adj] = q
      Q = append(Q, adj)
    }
  }
  C := make([]int, 0)
  C = append(C, dst + 1)
  p := dst
  for p != src {
    C = append(C[:1], C[0:]...)
    C[0] = P[p] + 1
    p = P[p]
  }
  return C
}

func main() {
  NM := NextIntVec()
  N, M := NM[0], NM[1]
  E := make([][]int, N)
  P := make([][]int, N)
  for i := range E {
    E[i] = make([]int, 0)
    P[i] = make([]int, N)
    P[i][i] = 1
  }
  for i := 0; i < M; i++ {
    AB := NextIntVec()
    A, B := AB[0] - 1, AB[1] - 1
    E[A] = append(E[A], B)
  }
  R := make([]int, N)
  Q := make([]int, 0)
  C := make([]int, 0)
  L := N + 1
  for i := 0; i < N; i++ {
    if L <= N { break }
    if R[i] > 0 { continue }
    Q = append(Q, i)
    for len(Q) > 0 {
      if L <= N { break }
      q := Q[0]
      Q = Q[1:]
      R[q] = i + 1
      for _, adj := range E[q] {
        if R[adj] > 0 && R[adj] != R[q] { continue }
        for j, p := range P[q] {
          if p == 0 { continue }
          P[adj][j] |= p
          if P[j][adj] > 0 {
            _C := Find(&E, adj, q)
            if len(_C) < L {
              C = _C
              L = len(C)
            }
          }
        }
        if R[adj] == 0 {
          Q = append(Q, adj)
        }
      }
    }
  }
  if N < L { L = -1 }
  Write(L)
  if L > 0 {
    for _, c := range C {
      Write(c)
    }
  }
  Output()
}

Measured memory_bytes: 18432
N,Y=map(int,input().split())
for i in range(N+1):
  if 10000*i>Y:
    break
  for j in range(N+1-i):
    k=N-i-j
    S = 10000*i + 5000*j + 1000*k
    if k<0 or S>Y:
      continue
    elif S == Y:
      print(i,j,k)
      exit()
print(-1,-1,-1)


Measured memory_bytes: 9184