akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        d: usize,
        x: usize,
        a: [usize; n],
    }
    let mut time  = 0;
    for i in 0..n {
        for j in 0..120 {
            if a[i] * j + 1 > d {
                break;
            } else {
                time+=1;
            }
        }
    }
    println!("{}", time + x);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    std::map<int, long long int> map;
    std::deque<int> ans;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            int e;
            long long int p,q;
            map.clear();
            ans.clear();
            for (int i=0;i<n;i++) {
                cin>>e>>p>>q;
                if (map[e]==0) {
                    ans.emplace_back(e);
                }
                map[e]+=p*q;
            }
            int flag=0;
            for (int i=0;i<n;i++) {
                if (map[ans[i]]>=1000000) {
                    cout<<ans[i]<<endl;
                    flag=1;
                }
            }
            if (flag==0) {
                cout<<"NA"<<endl;
            }
        }
    }
}


Measured memory_bytes: 3080
#include <iostream>
using namespace std;
 
int main()
{
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      double x1, y1, x2, y2, x3, y3, x4, y4, g1, g2;
      cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
 
      if ((x1-x2)*(y3-y4) == (x3-x4)*(y1-y2))
    cout << "YES" << endl;
      else
    cout << "NO" << endl;
    }
  }
  return 0;
}

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

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

  for (int i = 0; i < 5; i++)
  {
    int n;
    cin >> n;
    if(n == 0) cout << i+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();



        for (int i = 0; i<=x; i++ ) {
            int j = x - i;
            int n = i * 2 + j * 4;
            if (n == y) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }


}

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

using ll = long long;
int main(){
    ll p,q;
    while(cin >> p >> q){
        ll ans = 1;
        int g = __gcd(p,q);
        p/=g;
        q/=g;
        for(int i = 2; i <= 1e5; ++i){
            int c = 0;
            while(p%i == 0) p/=i, ++c;
            while(q%i == 0) q/=i, --c;
            if(c < 0) ans *= i;
        }
        if(q != 1) ans *= q;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 500001;

int two[10],dp[MAX_N];

int solve(const vi& b)
{
    int n = len(b);
    int sm = accumulate(all(b),0);
    rep(i,sm+1){
        dp[i] = -1;
    }
    dp[0] = 0;
    rep(i,n){
        for(int j = sm/b[i]*b[i]; j >= b[i]; j -= b[i]){
            if(dp[j-b[i]] >= 0){
                cmx(dp[j],dp[j-b[i]]+1);
            }
        }
    }
    int res = 0, nw = 1;
    while(nw <= sm){
        cmx(res,dp[nw]);
        nw *= 2;
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    two[0] = 1;
    rep(i,9){
        two[i+1] = two[i] * 2;
    }
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        vi a(n);
        rep(i,n){
            cin >> a[i];
        }
        int ans = 1;
        srep(i,1,501){
            vi b;
            bool ok = false;
            rep(j,n){
                if(a[j] % i == 0){
                    rep(k,9){
                        if(i*two[k] == a[j]){
                            b.pb(two[k]);
                            if(!k) ok = true;
                        }
                    }
                }
            }
            if(ok) cmx(ans,solve(b));
        }
        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
        sc.Scan()
        i, e := strconv.Atoi(sc.Text())
        if e != nil {
                panic(e)
        }
        return i
}

func main() {
        sc.Split(bufio.ScanWords)
        a := nextInt()
        b := nextInt()

        switch {
        case a > b:
                fmt.Println("a > b")
        case a < b:
                fmt.Println("a < b")
        case a == b:
                fmt.Println("a == b")
        }
}


Measured memory_bytes: 1088
fn calc(n: i64, x: i64) -> i64 {
    if n < 0 {
        return 0;
    }

    n / x + 1
}

fn main() {
    let (a, b, x) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        let abx: Vec<i64> = buf
            .trim()
            .split_whitespace()
            .map(|e| e.trim().parse().ok().unwrap())
            .collect();
        (abx[0], abx[1], abx[2])
    };

    let ans = calc(b, x) - calc(a - 1, x);
    println!("{}", ans);
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
using lint = long long int;

int main() {
    string S;
    cin >> S;
    puts(S[2] == S[3] and S[4] == S[5] ? "Yes" : "No");    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define endl "\n"
typedef long long ll;

const int BIG_NUM = 1e9;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int p, q, r, result;
    cin >> p >> q >> r;
    int a = p + q;
    int b = p + r;
    int c = q + r;
    cout << min(a, min(b, c));
    return 0;
}


Measured memory_bytes: 3644
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        X: i64,
    }
    let ans;
    match X{
        3|5|7 =>{
            ans = "YES";
        }
        _ =>{
            ans = "NO";
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a, int b) {
    int c;
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int lcm(int a, int b) {
    int c = gcd(a, b);
    a /= c;
    return a * b;
}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI = acos(-1.0);

using namespace std;

// #define int long long

signed main() {


    ios::sync_with_stdio(false);
    cin.tie(0);
    //cin高速化

    string s;
    cin >> s;

    string tmp_1 = "";
    string tmp_2 = "";


    for (int i = 0;i< 100000;i++) {
        if (i % 2 == 0) {
            tmp_1 += "1";
            tmp_2 += "0";
        }else {
            tmp_1 += "0";
            tmp_2 += "1";
        }
    }
//    cout << tmp_1 << endl;
//    cout << tmp_2 << endl;

    int a =0;
    int b = 0;

    for( int i = 0;i < s.size();i++){
//        cout << s[i] << " " << tmp_1[i] << " " << tmp_2[i] << endl;
        if (s[i] != tmp_1[i])a++;
        if (s[i] != tmp_2[i])b++;

    }

    cout << min(a, b) << endl;

    return 0;

}

Measured memory_bytes: 768
from heapq import heappush, heappop
N, K = map(int, input().split())
TD = [list(map(int, input().split())) for _ in range(N)]
TD.sort(key=lambda x:x[1], reverse=True)
muptiple = set()
hp = []
for t, d in TD:
    flg = 0
    if t not in muptiple:
        muptiple.add(t)
        flg = 1
    heappush(hp, (d*-1, flg))

ret = []
point = 0
vari = 0
total = 0
for i in range(K):
    v = heappop(hp)
    t = v[0]*-1
    vari += v[1]
    point += t
    if not v[1]:
        heappush(ret, t)

total = vari ** 2 + point

while len(hp) > 0 and len(ret) > 0:
    v = heappop(hp)
    if v[1] == 0:
        continue
    pre_t = heappop(ret)
    t = v[0]*-1
    point -= pre_t - t
    vari += 1
    tmp = vari ** 2 + point
    total = max(total, tmp)

print(total)

Measured memory_bytes: 42836
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    var c = Number(inputs[2]);
    if (a < b && b < c) {
        console.log('Yes');
    } else {
        console.log('No');
    }

});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15532
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

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

		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
		}
		sc.close();
		Arrays.sort(A);
		long k = A[0];
		Deque<Long> que = new ArrayDeque<Long>();
		que.add(A[0]);
		long m = k;
		for(int i = 1; i < N; i++) {
			if(A[i] % k != 0) {
				que.add(A[i]);
				m = Math.min(m, A[i] % k);
			}
		}
		k = m;
		while(!que.isEmpty()) {
			long t = que.pop();
			if(t % k != 0) {
				k = t % k;
				que.add(t);
			}
		}
		System.out.println(k);
	}
}

Measured memory_bytes: 57520
object Main {
  def main(args: Array[String]): Unit = {
    val n = scala.io.StdIn.readInt
    val a = scala.io.StdIn.readLine.split(" ").map(_.toLong)

    var ans = 0

    for (x <- a) {
      var tp = x

      while (tp % 2 == 0) {
        ans += 1
        tp = tp / 2
      }
    }
    println(ans)
  }
}


Measured memory_bytes: 29464
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

struct Info{
	Info(int arg_size,int arg_value){
		size = arg_size;
		value = arg_value;
	}
	bool operator<(const struct Info &arg) const{

		if(value != arg.value){
			return value < arg.value; //価値の降順(PQ)
		}else{
			return size < arg.size; //大きさの降順
		}
	}
	int size,value;
};

int N,M;
vector<int> V;


int main(){

	scanf("%d %d",&N,&M);

	priority_queue<Info> Q;
	int size,value;

	for(int loop = 0; loop < N; loop++){

		scanf("%d %d",&size,&value);
		Q.push(Info(size,value));
	}

	int tmp;

	for(int loop = 0; loop < M; loop++){

		scanf("%d",&tmp);
		V.push_back(tmp);
	}

	sort(V.rbegin(),V.rend());

	int ans = 0;

	for(int i = 0; Q.empty() == false && i < V.size(); ){

		if(Q.top().size <= V[i]){
			ans++;
			i++;
		}
		Q.pop();
	}

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

	return 0;
}



Measured memory_bytes: 4696
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )
#

import math
MOD = 998244353
N,M,K = [int(hoge) for hoge in input().split()]
NcK = []#N-1Ck
temp = ModInt(1)
for k in range(K+1):
    NcK.append(temp)
    temp *= N-1-k
    temp /= k+1

if M==1:
    if N==1 or K==N-1:print(1);exit()
    else:print(0);exit()

ans = ModInt(0)
notNcK = ModInt(M*(M-1)**(N-1))
ans += notNcK*NcK[0]
for k in range(K):#M*(M-1)**(N-1-k)*N-1c
    notNcK /= (M-1)
    ans += notNcK*NcK[k+1]
print(ans)



Measured memory_bytes: 95020
#include<iostream>
#include <iomanip>
#include<string.h>
#include<cmath>

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	
	double l[21],a[21],b[21];
	for(int i = 0;i < n;i++){
		cin >> l[i] >> a[i] >> b[i];
	}
	
	double dis[21][21];
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			double dl,da,db;
			dl = abs(l[i] - l[j]);
			da = abs(a[i] - a[j]);
			db = abs(b[i] - b[j]);
			dis[i][j] = dl*dl + da*da + db*db;
		}
	}
	
	double ans = 0;
	for(int i = 0;i < 1<<n;i++){
		int num = 0;
		int use[21];
		for(int j = 0;j < n;j++){
			if((i >> j) % 2) use[num] = j;
			num += ((i >> j) % 2);
		}
		if(num == m){
			double dsum = 0;
			for(int j = 0;j < num;j++){
				for(int k = j;k < num;k++){
					dsum += dis[use[j]][use[k]];
				}
			}
			if(dsum > ans) ans = dsum;
		}
	}
	
	cout << fixed << setprecision(6) << ans << endl;
	return 0;
}


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

int main() {
	int H, W;
	cin >> H >> W;
	string a;
	for (int i = 0;i < W + 2;i ++) cout << '#'; // 上部分
	cout << endl; // 改行を忘れずに
	for (int i = 0;i < H;i ++) {
		cin >> a;
		cout << '#' << a << '#' << endl; // 左右を追加して出力
	}
	for (int i = 0;i < W + 2;i ++) cout << '#'; // 下部分
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

解説不要よね？書いてる順に出力すればいいだけです
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(20)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	char a;
	cin >> a;
	if ((int)a >= 97 && (int)a <= 122) {
		cout << 'a';
	} else {
		cout << 'A';
	}
}

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


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, k;
	cin >> n >> k;

	cout << (n % k == 0 ? 0 : 1) << endl;
	return 0;
}


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

int main() {
	int p;
	int max = 0;
	int total = 0;

	for (int i = 0; i < 3; i++) {
		cin >> p;
		max = (p > max) ? p : max;
		total += p;
	}

	cout << total - max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,a[SZ],c[4],p[SZ];
bool ok1()
{
	c[0]=c[1]=c[2]=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i]%2) ++c[0];
		else if(a[i]%4) ++c[1];
		else ++c[2];
	}
	int g=0;
	while(c[1]--) p[++g]=2;
	while(c[0]&&c[2]) --c[0],--c[2],p[++g]=4,p[++g]=1;
	while(c[0]--) p[++g]=1;
	while(c[2]--) p[++g]=4;
	for(int i=2;i<=g;++i)
	{
		if(p[i]*p[i-1]%4) return 0;
	}
	return 1;
}
bool ok2()
{
	c[0]=c[1]=c[2]=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i]%2) ++c[0];
		else if(a[i]%4) ++c[1];
		else ++c[2];
	}
	int g=0;
	while(c[0]&&c[2]) --c[0],--c[2],p[++g]=1,p[++g]=4;
	while(c[1]--) p[++g]=2;
	while(c[0]--) p[++g]=1;
	while(c[2]--) p[++g]=4;
	for(int i=2;i<=g;++i)
	{
		if(p[i]*p[i-1]%4) return 0;
	}
	return 1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i);
	if(ok1()||ok2()) puts("Yes");
	else puts("No");
}
//2222222224141414141444444


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin>>n;
	for(int i=6;i>=0;i--)
	{
		int ans=pow(2,i);
		if (ans<=n)
		{
			cout<<ans<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
void printArray(int a[],int length)
{
	for (int i = 0; i < length - 1; ++i)
		cout << a[i] << " ";
	cout << a[length-1];
	cout << endl;

}
void insertionSort(int a[], int length)
{
	printArray(a, length);
	for (int i = 1; i <= length - 1; ++i)
	{
		int num = a[i];
		int j;
		for (j = i-1; j >=0&& num < a[j]; --j)
		{
			a[j + 1] = a[j];
		}
		a[j + 1] = num;
		printArray(a, length);
	}
}
int main()
{
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	insertionSort(a, n);
	delete[]a;
	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		if(n%1000==0) {
			System.out.println("0");
		}
		else {
			int y = n%1000;
			System.out.println(1000-y);
		}
       
       
       
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
//using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

#define MAX_V 10

struct edge {
	int to;
	int cost;
};

int d[MAX_V];
vector<edge> G[MAX_V]; // 隣接リスト表現

void dijkstra(int s) {
	fill(d, d + MAX_V, INF);
	d[s] = 0;  // 始点sへの最短距離は0

	priority_queue<P, vector<P>, greater<P>> que;  // 距離が小さい順に取り出せるようgreater<P>を指定
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;  // 更新した頂点の中で距離が最小の頂点v
		if (d[v] < p.first) {
			continue;
		}
		for (auto e : G[v]) {  // 頂点vから出る辺eを走査
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

void solve_abc_d() {
    ll h, w;
	ll ans = 0;

	cin >> h >> w;

	ll c[10][10];
	edge e;
	rep(i, 10) rep(j, 10) {
		cin >> c[i][j];
		if (i != j) {
			e.to = j;
			e.cost = c[i][j];
			G[i].push_back(e);
		}
	}

	ll a[201][201];
	rep(i, h) rep(j, w) {
		cin >> a[i][j];
	}

	ll minv[10];
	rep(i, 10) {
		dijkstra(i);
		minv[i] = d[1];
	}

	rep(i, h) rep(j, w) {
		if (a[i][j] != -1) {
			ans += minv[a[i][j]];
		}
	}

	cout << ans << "\n";
}

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

	solve_abc_d();

	return 0;
}


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


int main()
{
 int a,b,f=0;
 cin>>a>>b;
for(int i=1;i<=10000;i++)
{
    int ta=(8*i)/100;
    int tb=(10*i)/100;
    if(ta==a && tb==b)
    {
        f=i;
        break;
    }
}
if(f) cout<<f;
else cout<<-1;
}


Measured memory_bytes: 256
using System;

namespace AGC026B
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            Solver solver = new Solver();

            int t = int.Parse(Console.ReadLine());

            for (int i = 0; i < t; i++)
            {
                long[] q = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
                Console.WriteLine(solver.Solve(q[0], q[1], q[2], q[3]) ? "Yes" : "No");
            }
        }
    }

    class Solver
    {
        public bool Solve(long a, long b, long c, long d)
        {
            if (b > d | a < b)
            {
                return false;
            }

            long gcd = Gcd(d % b, b);
           // Console.Write(gcd + " ");
           // Console.WriteLine(b - gcd + a % gcd );
            return b - gcd + a % gcd <= c; 
        }

        public long Gcd(long a, long b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
    int N; cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) cin >> L[i];

    sort(L.begin(), L.end());
    long long ans = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            ans += lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin() - (j + 1);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
//AYUSH GUPTA
//IIITDMJ
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define for0(i, n) for (ll i = 0; i < n; i++)
#define for1(i, n) for (ll i = 1; i <= n; i++)
#define loop(i, a, b) for (ll i = a; i <= b; i++)
#define bloop(i, a, b) for (ll i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define fastio               \
	ios::sync_with_stdio(0); \
	std::cin.tie(0);         \
	std::cout.tie(0)
#define go_t   \
	int tt;    \
	cin >> tt; \
	for (int ttt = 1; ttt <= tt; ttt++)
#define set_ar(arr, v) memset(arr, v, sizeof(arr))
#define mod 1000000007
#define trace2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cout << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;


int main(){
 ll n;
 cin>>n;
 string s[n];
 string s1,s2,s3,s4;
 s1="AC";
 s2="WA";
 s3="TLE";
 s4="RE";

 for0(i,n)
  cin>>s[i];
  ll cnt1=0,cnt2=0,cnt3=0,cnt4=0;
  for0(i,n){

    if(s[i]==s1)
      cnt1++;

    else if(s[i]==s2)
      cnt2++;

    else if(s[i]==s3)
      cnt3++;
    
    else cnt4++;
    }

    cout<<s1<<" x "<<cnt1<<endl;
    cout<<s2<<" x "<<cnt2<<endl;
    cout<<s3<<" x "<<cnt3<<endl;
    cout<<s4<<" x "<<cnt4<<endl;

  return 0;
}

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

using namespace std;
const int maxn=3e5+111;
vector<int> tg[maxn], tg1[maxn], r, c;
int H, W, M, col[maxn], row[maxn];

bool cmp1(int i, int j){
    return row[i]>row[j];
}

bool cmp2(int i, int j){
    return col[i]>col[j];
}

int main(){
    memset(col, 0, sizeof(col));
    memset(row, 0, sizeof(row));
    scanf("%d%d%d", &H, &W, &M);
    for (int i=1; i<=H; i++) r.push_back(i);
    for (int j=1; j<=W; j++) c.push_back(j);
    int hi, wi;
    for (int i=0; i<M; i++){
        scanf("%d%d", &hi, &wi);
        tg[hi].push_back(wi);
        tg1[wi].push_back(hi);
        col[wi]++; row[hi]++;
    }
    sort(r.begin(), r.end(), cmp1);
    sort(c.begin(), c.end(), cmp2);
    int ans=0;
    int cnt=r[0];
    for (int j=0; j<tg[cnt].size(); j++) col[tg[cnt][j]]--;
    int tmp=0;
    for (int j=1; j<=W; j++) tmp=max(tmp, col[j]);
    for (int j=0; j<tg[cnt].size(); j++) col[tg[cnt][j]]++;
    ans=row[cnt]+tmp;

    cnt=c[0]; tmp=0;
    for (int j=0; j<tg1[cnt].size(); j++) row[tg1[cnt][j]]--;
    for (int j=1; j<=H; j++) tmp=max(tmp, row[j]);
    for (int j=0; j<tg1[cnt].size(); j++) row[tg1[cnt][j]]++;
    ans=max(ans, col[cnt]+tmp);

    printf("%d", ans);
}



Measured memory_bytes: 40820
import math
import collections


def kumiawase(n):
    if n == 0 or n == 1:
        return 0
    return (n**2 - n) // 2


n = int(input())
aL = list(map(int, input().split(" ")))

d = collections.Counter(aL)

s = 0
for i in d.values():
    s += kumiawase(i)

for a in aL:
    print(s - d[a] + 1)


Measured memory_bytes: 25892
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

const char col[4] = {'R', 'Y', 'G', 'B'};
int n, m, d, a[555][555];

int main() {
	
	scanf("%d%d%d", &n, &m, &d);
	
	FOR(i, 0, n) FOE(j, 0, m) {
		if ((i + j) % (d + d) >= d) a[i][j] += 1;
		if ((i - j + d * 4000) % (d + d) >= d) a[i][j] += 2;
	}
	
	FOR(i, 0, n) {
		FOR(j, 0, m) printf("%c", col[a[i][j]]);
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;


int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	cout << a[0] + a[1] + 10 * a[2];
}

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

int main()
{
	int n;
	scanf("%d",&n);
	if(n==1 || n==2){
		printf("0");
	}
	else{
		if(n%2==0){
		printf("%d\n",n/2-1);
	}
	else printf("%d\n",n/2);
	}
	
	return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    int i,j,k;
    int a,b;
    int ans=0;
    pair<int,int> p[N];
    priority_queue<int> q;
    for(i=0;i<N;i++){
        cin >> a >> b;
        p[i]=make_pair(a,b);
    }
    sort(p,p+N);
    j=0;
    for(i=1;i<=M;i++){
        if(j<N){
            while(i>=p[j].first){
                q.push(p[j].second);
                j++;
                if(j>=N)break;
                }
            }
        if(!q.empty()){
        ans+=q.top();
        q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
//#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
#define N  1000000007
#define MAXN 15000001
 //priority_queue<int, vector<int>, greater<int> > Q; 
//ll int a[1001][1001];
int main()
{//memset(,0,sizeof(m));
ios_base::sync_with_stdio(false);
 cin.tie(0);
 cout.tie(0);
 
    ll int n,k;
    cin>>n>>k;
    vector<ll int > h(n);
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
     
    //cout<<endl;
    vector<ll int> v(n,0);
     
     v[0]=0;
     v[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
       v[i]=INT_MAX;
       for(int j=1;j<=k&&(i-j>=0);j++)
       {
           v[i]=min(v[i],v[i-j]+abs(h[i]-h[i-j]));
       }
       
    }
    
   cout<<v[n-1];
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
int main(){
    string n;
    int c,nc,l,x;
    do{
        cin >> n;
        if (n=="-")
            break;
        l=n.size();
        cin >> nc;
        c=0;
        for (int i=0;i<nc;i++){
            cin >> x;
            c+=x;
        }
        c%=l;
        string s2=n;
        if (c!=0){
            s2.assign(n,c,l-c);
            s2.append(n,0,c);
        }
        cout << s2 << endl;
    }while (1==1);
    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const int N = 2e5+23;

vector<int> g[N];
int n, m; 

bool bio[N];
bool dfs(int u, int d) {
	bio[u] = true;
	bool ret = u == n-1;
	if (d-1 < 0) return ret;
	for (int v: g[u]) {
		if (bio[v]) continue;
		ret |= dfs(v, d-1);
	}
	return ret;
}

void solve() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int a, b; scanf("%d%d", &a, &b);
		g[--a].push_back(--b);
		g[b].push_back(a);
	}
	if (!dfs(0, 2)) printf("IM");
	puts("POSSIBLE");
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 12144
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  int i=0;
  for(i=0;i<str.size();i++){
    if(str[i]>='a'&&str[i]<='z') str[i]+='A'-'a';
  }
  cout << str << endl;
}



Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <algorithm>
using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)n;(i)++)
#define foreach(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)

int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}

const int SIZE = 1002;
int V;
vector<int> G[1002];
int match[1002];
bool used[1002];

void init(int v) {
  int i;
  fill(used, used + SIZE, false);
  fill(match, match + SIZE, 0);
  rep (i, SIZE) G[i].clear();
  V = v;
}

void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v) {
  int i;
  used[v] = true;
  rep(i,G[v].size()) {
    int u = G[v][i], w = match[u];
    if (w < 0 || !used[w] && dfs(w)) {
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching() {
  int v, res = 0;
  memset(match, -1, sizeof match);
  rep(v,V) {
    if (match[v] < 0) {
      memset(used, 0, sizeof used);
      if (dfs(v)) {
        res++;
      }
    }
  }
  return res;
}

int m, n;
int b[502], r[502];
const int MAX_N = 10000000;

int main() {
  int i, j, k;
    
  while (scanf("%d%d", &m, &n), m|n) {
    rep (i, m) scanf("%d", &b[i]);
    rep (i, n) scanf("%d", &r[i]);

    init(m+n);    
    rep (i, m) {
      rep (j, n) {
        if (gcd(b[i], r[j]) != 1) add_edge(i, m+j);
      }
    }
    
    printf("%d\n", bipartite_matching());
  }
  return 0;
}

Measured memory_bytes: 3072
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        int Y = sc.nextInt();
        int a = -1;
        int b = -1;
        int c = -1;
        int flag = 0;
      
	    for(int i=0; i<=N; i++){
          for(int j=0; i+j<=N; j++){
            int k = N-i-j;
            int M = 10000*i + 5000*j + 1000*k;
            if(M == Y){
              a = i;
              b = j;
              c = k;
              flag = 1;
              break;
            }
            if(flag == 1){
              break;
            }
          }
        }
		System.out.println(a+" "+b+" "+c);
    }
}


Measured memory_bytes: 23124
#include <stdio.h>

int main (void)
{
  int i,n;
  for(i=0;i<10000;i++){
    scanf("%d",&n);
 
    if(n==0)
      break;
    
    printf("Case %d: %d\n",i+1,n);

  }   
  
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main() {
	string w;
	cin >> w;
	
	int f[26] ={0}; //残りの要素はすべて0になる
	for(int i=0; i<w.size(); i++) {
		f[ w[i] - 'a']++;
	}
	
	string ans = "Yes";
	for(int i=0; i<26; i++) {
		if ((f[i] % 2) == 1) {
			ans = "No";
			break;
		}
	}
	cout << ans << endl;
	
	return 0;
	
}

Measured memory_bytes: 256
import math
import numpy as np

N = int(input())
ans = 0
num_mat = np.zeros((9, 9))
for i in range(N+1):
  head = int(list(str(i))[0])
  tail = int(list(str(i))[-1])
  rev = ''.join(list(str(i))[::-1])
  if tail==0:
    continue
  num_mat[head-1, tail-1] += 1

for i in range(9):
  for j in range(i+1):
    if i==j:
      num = num_mat[i,j]
      ans += num + num * (num-1)
    else:
      ans += num_mat[i,j] * num_mat[j,i] * 2

print(int(ans))

  



Measured memory_bytes: 12500
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int arr[6] = {100, 101, 102, 103, 104, 105};
	int a; cin >> a;
	int dp[a + 50] = {0};
	dp[0] = true;
	for(int i=0; i<6; i++)
	{
		for(int j=arr[i]; j<=a; j++)
			dp[j] = dp[j - arr[i]] | dp[j];
	}
	cout << dp[a] << '\n';
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(int, n, k, x, y);
	out(min(n, k)*x + max(n - k, 0)*y);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

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

	string s;
	cin >> s;

	if (s.size() % 2 == 1)
	{
		cout << "No" << endl;
		ret;
	}
	for (int i = 0; i < s.size(); i+=2)
	{
		if (s[i] == 'h' && s[i + 1] == 'i')
			continue;
		else
		{
			cout << "No" << endl;
			ret;
		}
	}
	cout << "Yes" << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

lli ans = 0;
lli n;
void dfs(lli cur, int use){
	if(cur>n) return;
	if(use == 0b111) ans++;
	dfs(cur*10+7, use | 0b001);
	dfs(cur*10+5, use | 0b010);
	dfs(cur*10+3, use | 0b100);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cin >> n;
	dfs(0, 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <array>
#include <numeric>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<vector<ll>> v(N+1,vector<ll>(N+1,0));
    for(int i = 0;i <v.size(); i++){
        v[i][0]=1;
        v[i][i]=1;
    }
    for(int k = 1;k <v.size();k++){
        for(int j = 1;j<k;j++){
            v[k][j]=(v[k-1][j-1]+v[k-1][j]) % MOD;
        }
    }
    rep(i, K) {
        print(v[K-1][i] * v[N-K+1][i+1] % MOD);
        //print(nCrModp(K-1, i, MOD) * nCrModp(N-K+1, i+1, MOD) % MOD);
    }

    return 0;
}

Measured memory_bytes: 31616
n = gets.to_i
stack = []
answer = nil
gets.split.map(&:to_i).each_with_index do |x, i|
  if x > 0
    if stack.include?(x)
      answer = i + 1
      break
    else
      stack << x
    end
  else
    if stack[-1] != -x
      answer = i + 1
      break
    else
      stack.pop
    end
  end
end
puts answer || 'OK'


Measured memory_bytes: 8868
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
//用于表示边的结构体（终点/容量/反向边）
struct edge {
    int to, cap, rev;
};
const int MAX_V = 500;
const int INF = 0x3f3f3f3f;
vector<edge> G[MAX_V];  //图的邻接表表示
int level[MAX_V];  //顶点到源点的距离标号
int iter[MAX_V];  //当前弧，在其之前的边已经没有用了
struct Node {
    int x, y;
}node[MAX_V];
//向图中增加一条从from到to的容量为cap的边
void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size() - 1});
}

//通过BFS计算从源点出发的距离标号
void bfs(int s) {
    memset(level, -1, sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int i = 0; i < G[v].size(); i++) {
            edge &e = G[v][i];
            if (e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

//通过DFS寻找增广路
int dfs(int v, int t, int f) {
    if (v == t)
        return f;
    for (int &i = iter[v]; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (e.cap > 0 && level[v] < level[e.to]) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

//求解从s到t的最大流
int max_flow(int s, int t) {
    int flow = 0;
    for (;;) {
        bfs(s);
        if (level[t] < 0)
            return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while ((f = dfs(s, t, INF)) > 0) {
            flow += f;
        }
    }
}
int main() {
    int N, M;
    while (~scanf("%d",&N)) {
        for (int i = 1; i <= N; i++) {
            scanf("%d%d",&node[i].x,&node[i].y);
        }
        for (int i = N+1; i <= N*2; i++) {
            scanf("%d%d",&node[i].x,&node[i].y);
        }
        int s, t;
        s = 0;
        t = N*2+1;
        for (int i = 1; i <= N; i++) {
            add_edge(s, i, 1);
            for (int j = N+1; j <= N*2; j++) {
                if (node[i].x < node[j].x && node[i].y < node[j].y)
                    add_edge(i, j, 1);
            }
        }
        for (int i = N+1; i <= N*2; i++) {
            add_edge(i, t, 1);
        }
        printf("%d\n",max_flow(s, t));
    }
    return 0;
}


Measured memory_bytes: 384