akhauriyash/Code-Regression huggingface dataset:
from collections import deque
h,w,k = map(int,input().split())
a,b,c,d = map(int,input().split())
a -= 1
b -= 1
c -= 1
d -= 1
maze = [input() for _ in range(h)]
dx = [1,-1,0,0]
dy = [0,0,1,-1]
depth = [[float("inf") for _ in range(w)] for _ in range(h)]
dq = deque([(b,a)])
depth[a][b] = 0
while dq:
    x,y = dq.popleft()
    if x == d and y == c:
        break
    for i in range(4):
        nx,ny,K = x,y,k
        while K:
            K -= 1
            nx += dx[i]
            ny += dy[i]
            if 0<=nx<=w-1 and 0<=ny<=h-1 and maze[ny][nx] != "@" and depth[ny][nx] > depth[y][x]:
                if depth[ny][nx] == depth[y][x]+1:
                    continue
                depth[ny][nx] = depth[y][x] +1
                dq.append((nx,ny))
            else:
                break
print(depth[c][d] if depth[c][d] != float("inf") else -1)

Measured memory_bytes: 119480
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const int MAX_N = 100000;
int N;
int h[MAX_N];
int dp[MAX_N];

int solve() {
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    REP(i,2,N) {
        dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]));
    }
    return dp[N-1];
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    REP(i,0,N) cin >> h[i];
    cout << solve() << "\n";
    return 0;
}



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

int main(void) {
    int n;
    int h,w;

    scanf("%d", &n);
    scanf("%d", &h);
    scanf("%d", &w);

    printf("%d\n", (n-h+1) * (n-w+1));
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
vector<pair<int,int> > adj[N];
int in[N], dis[N];
int main(){
	int n, m;
	cin >> n >> m;
	queue<int> store;
	for(int i = 0; i < m; i++){
		int a, b, d;
		cin >> a >> b >> d;
		adj[a].push_back({b, d});
		++in[b];
	}
	memset(dis, -1, sizeof(dis));
	for(int i = 1; i <= n; i++){
		if(in[i] == 0){
			dis[i] = 0;
			store.push(i);
		}
	}
	bool valid = true;
	while(valid && !store.empty()){
		int u = store.front();
		store.pop();
		for(const pair<int,int> &p : adj[u]){
			int v = p.first;
			int w = p.second;
			if(dis[v] == -1){
				dis[v] = dis[u] + w;
				store.push(v);
			}else{
				valid &= (dis[v] == dis[u] + w);
			}
		}
	}
	for (int i = 1; i <= n; ++i) {
    valid &= dis[i] != -1;
  }
	printf("%s\n", valid ? "Yes" : "No");
}

Measured memory_bytes: 6784
import sys
import math
from functools import reduce
N = str(input())
A = list(map(int, input().split()))

M = 10 ** 6
sieve = [0] * (M+1)
for a in  A:
    sieve[a] += 1

def gcd(*numbers):
    return reduce(math.gcd, numbers)

d = 0
for i in range(2, M+1):
    tmp = 0
    for j in range(i,M+1,i):
        tmp += sieve[j]
    if tmp > 1:
        d = 1
        break

            
if d == 0:
    print('pairwise coprime')
    exit()

if gcd(*A) == 1:
    print('setwise coprime')
    exit()

print('not coprime')


Measured memory_bytes: 207024
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N = II()

    ans = ''
    while N > 0:
        N -= 1
        ans += chr(ord('a') + N % 26)
        N //= 26

    print(ans[::-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 9128
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    for(int i=1;;i++)
    {
        if(i%2)
        {
            c-=b;
            if(c<=0)
            {
                cout<<"Yes\n";
                return 0;
            }
        }
        else
        {
            a-=d;
            if(a<=0)
            {
                cout<<"No\n";
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include<string>
using namespace std;
int main(){

    string str;
    int n;
    cin>>str;
    cin>>n;
    int flag=0;
    int soe;
    for(int i=0;i<n;i++){
        if(str[i]!='1'){
            soe=i;
            flag=1;
            break;
        }
        
    }
    if(flag==0){
        cout<<1<<endl;
        return 0;
    }
    if(flag==1){
        cout<<str[soe]<<endl;
        return 0;
    }





return 0;
}


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

int main() {
  long long n,a,b;
  cin>>n>>a>>b;
  if(n%(a+b)<=a) cout<<n/(a+b)*a+n%(a+b)<<endl;
     else  cout<<n/(a+b)*a+a<<endl;//aと余りの関係
}



Measured memory_bytes: 256
def main():
    N, M = list(map(int, input().split(' ')))
    X = list(map(int, input().split(' ')))
    X.sort()
    if N >= M:
        print(0)
        return
    d = [X[i + 1] - X[i] for i in range(M - 1)]
    d.sort()
    print(sum(d[:(M-N)]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 13960
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define ll long long
#define endl '\n'
#define vi vector<int>
#define rep(i, n) for (i = 0; i < n; i++)
#define rep1(i, n) for (i = 1; i <=n; i++)
#define rep2(i, n) for (i = 0; i < n-1; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend() //Sort in reverse,Vector.
#define present(v,x) (v.find(x)!=v.end()) //set/map etc.

int main()
{  ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif

   int i,n,d;

   cin>>n>>d;

   int a[n],count=0,x,y;

  rep(i,n)
 { 
   cin>>x>>y;

   if(hypot(x,y)<=d)
      count++;

  }
  
  cout<<count; 



}  
   




Measured memory_bytes: 3660
PROGRAM ATCODER

implicit none
integer :: n,i,s
character(len=100) :: a,b,c

read(*,*) n,a,b,c    !ここが入力欄

s = 0
do i = 1,n
if (a(i:i) /= b(i:i) .or. a(i:i) /= c(i:i))then
    s = s + 2
    if (a(i:i) == b(i:i) .or. b(i:i) == c(i:i) .or. c(i:i) == a(i:i))then
        s = s - 1
    end if
end if
end do

write(*,'(i0)') s

END PROGRAM ATCODER

Measured memory_bytes: 640
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
	ll k,a,b;
	cin>>k>>a>>b;
	k++;
	ll a1 = a+2;
	if(a1<b){
		if(k<a1){
			cout << k << endl;
		}
		else{
			k-=a1;
			ll n = b;
			n += (k/2)*(b-a);
			n += (k%2);
			cout << n << endl;
		}
	}
	else{
		cout << k << endl;
	}
 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, x;
    cin >> a >> b >> x;
    cout << (a <= x and x - a <= b ? "YES" : "NO") << endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_126
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            string s = Read();
            int front = int.Parse(s.Substring(0, 2));
            int back = int.Parse(s.Substring(2, 2));

            if (1<=front&&front <= 12
                &&1<=back&& back <= 12)
            {
                WriteLine("AMBIGUOUS");
            }
            else if (1<=front&&front <= 12)
            {
                WriteLine("MMYY");
            }
            else if (1<=back&&back <= 12)
            {
                WriteLine("YYMM");
            }
            else
            {
                WriteLine("NA");
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include<cstdio>

const int P=1000000007;
int n,d[305],fac[305],inv[305],f[305][305][2],ans;

int power(int a,int x){
	int ans=1;
	for(;x;x>>=1,a=1ll*a*a%P)if(x&1)ans=1ll*ans*a%P;
	return ans;
}
void upd(int &x,int y){x=x+y>=P?x+y-P:x+y;}

int main(){
	scanf("%d",&n);
	bool cir=true;
	for(int i=1;i<=n;i++)scanf("%d",d+i),cir&=d[i]==2;
	for(int i=fac[0]=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%P;
	inv[n]=power(fac[n],P-2);
	for(int i=n;i;i--)inv[i-1]=1ll*inv[i]*i%P;
	if(cir&&n>=3)ans=1ll*fac[n-1]*inv[2]%P;
	f[0][0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<2;k++){
				if(!f[i][j][k])continue;
				upd(f[i+1][j][k],f[i][j][k]);
				if(d[i+1]>=2)
					upd(f[i+1][j+1][k],1ll*f[i][j][k]*(d[i+1]-1)%P);
				if(!k&&d[i+1]>=3)
					upd(f[i+1][j+1][1],1ll*f[i][j][k]*(d[i+1]-1)%P*(d[i+1]-2)%P);
			}
	for(int i=3;i<n;i++)
		upd(ans,1ll*fac[i-1]*inv[2]%P*f[n][i][1]%P*fac[n-i-1]%P);
	for(int i=1;i<=n;i++)ans=1ll*ans*inv[d[i]-1]%P;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 896
// Problem : B - Minor Change
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		string s,t;
		cin>>s>>t;
		int n = s.size();
		int ct = 0;
		for(int i=0;i<n;++i)
		{
			if(s[i]!=t[i])
			++ct;
		}
		cout<<ct;		
    }
    return 0;
}


Measured memory_bytes: 3884
#include<iostream>
#include<string>
#include<set>
#include<cmath>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b;
  if(b<10)
    c=10*a+b;
  else if(b<100)
    c=100*a+b;
  else
    c=1000*a+b;
  if(double(sqrt(c))==int(sqrt(c)))
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 256
N=int(input())
T,A=map(int,input().split())
H=list(map(int, input().split()))

B=999999999999999
X=0
for i in range(N):
  if B>abs((T-H[i]*0.006)-A):
    X=i+1
    B=min(abs((T-H[i]*0.006)-A),B)

print(X)

Measured memory_bytes: 3060
#include <stdio.h>
int main(){
	int n,s,sum,i,max,min,ave;
	
	while(1){
		sum=0;
		max=0;
		min=1000;
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d",&s);
			sum+=s;
			if(s>max)max=s;
			if(s<min)min=s;
		}
		ave=(sum-(max+min))/(n-2);
		printf("%d\n",ave);
	}
	return 0;
}

Measured memory_bytes: 1028
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

fn main() {
    input!{
        a: usize,
        b: usize,
        t: usize,
    }
    println!("{}", t / a * b);
}


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

const int N = 1e5 + 10;

int n, k = -1;
vector<int> g[N];
int degree[N], ans[N];
map<pair<int, int>, int> ma;
set<int> color[N];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    if (u > v)
      swap(u, v);
    --u, --v;
    ++degree[u], ++degree[v];
    k = max(k, max(degree[u], degree[v]));
    g[u].push_back(v);
    ma[{u, v}] = i;
  }

  for (int i = 0; i < n; ++i)
    for (int j = 0; j < degree[i]; ++j)
      color[i].insert(j);
  
  for (int u = 0; u < n; ++u) {
    for (int v : g[u]) {
      int use = *color[u].begin();
      ans[ma[{u, v}]] = use;
      color[u].erase(use);
      color[v].erase(use);
    }
  }
  
  printf("%d\n", k);
  for (int i = 0; i < n - 1; ++i)
    printf("%d\n", ans[i] + 1);

  return 0;
}

Measured memory_bytes: 25472
#include<bits/stdc++.h>
using namespace std;
int n;
unsigned long long MOD;
vector<int> nei[100005];
unsigned long long dp[100005],res[100005];
unsigned long long ins[100005],pre[100005],suf[100005];
void dfs1(int v,int pa){
	dp[v]=1;
	for(int i=0;i<nei[v].size();i++){
		int u=nei[v][i];
		if(u==pa) continue;
		dfs1(u,v);
		dp[v]=dp[v]*(dp[u]+1)%MOD;
	}
}
void dfs2(int v,int pa){
	res[v]=dp[v]*(ins[v]+1)%MOD;
	vector<pair<int,int> > tmp;
	tmp.push_back(make_pair(1,3002));
	for(int i=0;i<nei[v].size();i++){
		int u=nei[v][i];
		if(u==pa) continue;
		tmp.push_back(make_pair(dp[u]+1,u));
	}
	tmp.push_back(make_pair(ins[v]+1,3002));
	pre[0]=tmp[0].first;
	for(int i=1;i<tmp.size();i++){
		pre[i]=pre[i-1]*tmp[i].first%MOD;
	}
	suf[tmp.size()-1]=tmp.back().first;
	for(int i=tmp.size()-2;i>=0;i--){
		suf[i]=suf[i+1]*tmp[i].first%MOD;
	}
	for(int i=1;i<tmp.size()-1;i++){
		ins[tmp[i].second]=pre[i-1]*suf[i+1]%MOD;
	}
	for(int i=0;i<nei[v].size();i++){
		int u=nei[v][i];
		if(u==pa) continue;
		dfs2(u,v);
	}
	return;
}
int main(){
	cin>>n>>MOD;
	for(int i=0;i<n-1;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		x--,y--;
		nei[x].push_back(y);
		nei[y].push_back(x);
	}
	dfs1(0,-1);
	dfs2(0,-1);
	for(int i=0;i<n;i++){
		cout<<res[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 20352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll W, H, N; cin >> W >> H >> N;
	vector<ll> X(N), Y(N), A(N);
	for (ll i = 0; i < N; ++i) cin >> X[i] >> Y[i] >> A[i];

	ll xl{0}, xr{W}, yb{0}, yt{H};

	for (ll i = 0; i < N; ++i)
	{
		if (A[i] == 1) xl = max(xl, X[i]);
		if (A[i] == 2) xr = min(xr, X[i]);
		if (A[i] == 3) yb = max(yb, Y[i]);
		if (A[i] == 4) yt = min(yt, Y[i]);
	}

	std::cout << max(0ll, yt - yb) * max(0ll, xr - xl) << std::endl;
}


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

int main() {
    int N,M;
    cin >> N >> M;

    int a[60], b[60];

    for(int i = 0; i < M; i++) cin >> a[i] >> b[i];

    int num[60] = {0};

    for(int i = 0; i <M; i++) {
        num[a[i]]++;
        num[b[i]]++;
    }
    for(int i = 1; i < N + 1; i++){
        cout << num[i] << endl; 
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
bool flag = false;
void check(int table[8][8],int y,int x){
	int dx[]={0,0,1,1,1,-1,-1,-1};
	int dy[]={1,-1,0,1,-1,0,1,-1};
	for(int i=0;i<8;i++){
		int tmpx=x,tmpy=y;
		while(tmpx+dx[i]<8 && tmpx+dx[i]>=0 && tmpy+dy[i]<8 && tmpy+dy[i]>=0){
			table[tmpy+dy[i]][tmpx+dx[i]]=2;
			tmpy+=dy[i];
			tmpx+=dx[i];		
		}
	}
}
void dfs(int now,int table[8][8]){
	if(flag==true){
		return ;
	}else if(now==8){
		for(int i=0;i<8;i++){
			for(int k=0;k<8;k++){
				if(table[i][k]==1){
					printf("Q");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		flag=true;
	}else{
		
		for(int i=0;i<8;i++){
			for(int k=0;k<8;k++){
				int tmptable[8][8]={0};
				for(int z=0;z<8;z++){
					for(int j=0;j<8;j++){
						tmptable[z][j]=table[z][j];
					}
				}
				if(tmptable[i][k]==0){
					tmptable[i][k]=1;
					check(tmptable,i,k);
					dfs(now+1,tmptable);
				}
			}
		}		
	}
}


int main(){
	int cases;
	int table[8][8]={0};
	// 0=can 1=queen 2=can't
	scanf("%d",&cases);
	int x,y;
	for(int i=0;i<cases;i++){
		scanf("%d%d",&y,&x);
		table[y][x]=1;
		check(table,y,x);
	}
	dfs(cases,table);
}


Measured memory_bytes: 2692
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
struct pro{
    int time;
    char name[10];
};
void output(pro* process){
    printf("%s %d\n",process->name,process->time);
}
pro ans[100000];
queue<pro> que;
int n,q,c=0,now=0;
int main(){
    scanf("%d %d",&n,&q);
    for(int i=0;i<n;i++){
        pro process;
        scanf("%s %d",process.name,&process.time);
        que.push(process);
    }
    while(!que.empty()){
        pro process=que.front();
        que.pop();
        if(process.time<=q){
            now+=process.time;
            pro a;
            a.time=now;
            strcpy(a.name,process.name);
            ans[c]=a;
            c++;
        }else{
            process.time-=q;
            now+=q;
            que.push(process);
        } 
    }
    for(int i=0;i<n;i++){
        output(&ans[i]);
    }
    return 0;
}

Measured memory_bytes: 2404
// Author by Md. Jashim Uddin_RMSTU

#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     ll              long  long int
#define     fast            ios_base :: sync_with_stdio(false);cin.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)

#define     forn(i,n)       for(int i=1;i<=n;i++)
#define     min3(a,b,c)     min(a,min(b,c)
#define     M             32000

int main()
{

    ll a,sum=0,s=0;
    cin>>a;
    while(a>=5)
    {
       if(a>=500)
       {
           sum+=1000;
           a-=500;
       }
       else
       {
           s+=5;
           a-=5;
       }
    }
    cout<<(sum+s)<<endl;




return 0;

}


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

for i in range(N):
    for j in range(N-1,0,-1):
        if xlist[j-1]>xlist[j]:
            xlist[j-1],xlist[j] = xlist[j],xlist[j-1]

if (xlist[N-1]-xlist[0])%2 == 0:
    T = (xlist[N-1]-xlist[0])//2

if (xlist[N-1]-xlist[0])%2 > 0 : 
    T = (xlist[N-1]-xlist[0])/2+0.5

print(int(T))


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

void ok(int N)
{
    bool ok = false;
    while (N)
    {
        if (N % 10 == 7)
        {
            cout << "Yes" << endl;
            return;
        }
        N /= 10;
    }
    cout << "No" << endl;
    return;
}

int main()
{
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i < N + 1; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            ans += i;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    A = list(map(int, args[1].split()))

    if 0 < A[0]:
        return '1' if n == 0 and A[0] == 1 else '-1'

    R = [0]*(n+1)
    R[0] = 1
    for i in range(1, n+1):
        R[i] = 2*(R[i-1]-A[i-1])

    prev = 0
    ret = 0
    for i in range(n, -1, -1):
        if R[i] < A[i]:
            ret = -1
            break

        prev = min(R[i], A[i]+prev)
        ret += prev

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

int main() {
  int a,b;
  cin >> a >> b;
  cout << max(a-2*b, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#python3

INF = int(1e9)

def main():

    n, k = map(int, input().split()) 
    h = [int(i) for i in input().split()] + [0]* 110


    dp = [INF] * 110000
    dp[0] = 0
    for i in range(n):
        for j in range(1, k+1):
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))

    print(dp[n-1])

main() 


Measured memory_bytes: 53368
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=2e6+9;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int s=a+b+c;
	if(s>=22) cout<<"bust";
	else cout<<"win";    
    return 0;
}


Measured memory_bytes: 256
import itertools
import numpy as np

def calc(aaa, M, X, pattern):
    tmp_price = 0
    for t in pattern:
        price = 0
        sum = np.zeros(M)
        for i in t:
            price += aaa[i][0]
            current = np.array(aaa[i][1:M+1])
            sum = sum + current

        if np.count_nonzero(sum >= X) >= M:
            if tmp_price == 0:
                tmp_price = price
            else:
                tmp_price = min(tmp_price, price)
    
    return tmp_price


def solve(N, M, X, aaa):
    tmp_result = 0
    for i in range(N):
        pattern = list(itertools.combinations(range(N), i + 1))
        result = calc(aaa, M, X, pattern)
        if result > 0:
            if tmp_result == 0:
                tmp_result = result
            else:
                tmp_result = min(tmp_result, result)

    if tmp_result != 0:
        return tmp_result
    else:
        return -1

N, M, X, *A = map(int, open(0).read().split())

aaa = []
aa = []
for index, x in enumerate(A):
    aa.append(x)
    if (index+1) % (M+1) == 0:
        aaa.append(aa)
        aa = []

print(solve(N, M, X, aaa))

Measured memory_bytes: 27572
(defn coins [a b c x]
  (count
    (for [i (range 0 (inc a)) j (range 0 (inc b)) k (range 0 (inc c))
          :let [res (+ (* 500 i) (* 100 j) (* 50 k))]
          :when (= res x)]
     res)))

(println (coins (read) (read) (read) (read)))

Measured memory_bytes: 72468
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

class Node {
public:
    int location;
    int p, l, r;

    Node() {};
};

class Point {
public:
    int id, x, y;

    Point() {};

    Point(int _id, int _x, int _y) {
        id = _id;
        x = _x;
        y = _y;
    }

    bool operator < (const Point &p) const {
        return id < p.id;
    }

    void print() {
        printf("%d\n", id);
    }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;

Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) {
    return p1.x < p2.x;
}

bool lessY(const Point &p1, const Point &p2) {
    return p1.y < p2.y;
}

int makeKDTree(int l, int r, int depth) {
    if (l >= r) {
        return NIL;
    }

    int mid = (l + r) / 2;
    int t = np++;
    if (depth % 2 == 0) {
        sort(P + l, P + r, lessX);
    } else {
        sort(P + l, P + r, lessY);
    }

    T[t].location = mid;
    T[t].l = makeKDTree(l, mid, depth + 1);
    T[t].r = makeKDTree(mid + 1, r, depth + 1);

    return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
    int x = P[T[v].location].x;
    int y = P[T[v].location].y;

    if (sx <= x && x <= tx && sy <= y && y <= ty) {
        ans.push_back(P[T[v].location]);
    }

    if (depth % 2 == 0) {
        if (T[v].l != NIL) {
            if (sx <= x) {
                find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
            }
        }
        if (T[v].r != NIL) {
            if (x <= tx) {
                find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
            }
        }
    } else {
        if (T[v].l != NIL) {
            if (sy <= y) {
                find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
            }
        }
        if (T[v].r != NIL) {
            if (y <= ty) {
                find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
            }
        }
    }
}

int main() {
    int x, y;
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {
        scanf("%d %d", &x, &y);
        P[i] = Point(i, x, y);
        T[i].l = T[i].r = T[i].p = NIL;
    }

    np = 0;
    int root = makeKDTree(0, N, 0);
    int q;
    scanf("%d", &q);
    vector<Point> ans;
    int sx, tx, sy, ty;
    for (int i = 0; i < q; ++i) {
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        ans.clear();
        find(root, sx, tx, sy, ty, 0, ans);
        sort(ans.begin(), ans.end());
        for (int j = 0; j < ans.size(); ++j) {
            ans[j].print();
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 15932
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;
using P = pair<int, int>;
void execute()
{
	int H, W;
	int current_distance;
	int current_point;
	int ans = 0;
	cin >> H >> W;

	vector<vector<int>> a(10, vector<int>(10, 0));
	vector<int> distance(10, INF32);
	priority_queue<pair<int, int>> next;
	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			cin >> a[i][j];
		}
	}

	distance[1] = 0;
	next.push(P(0, 1));

	for (; !next.empty();)
	{
		current_distance = next.top().first;
		current_point = next.top().second;
		next.pop();

		for (int i = 0; i < 10; i++)
		{
			if (i == current_point)
				continue;
			if (distance[i] <= current_distance + a[i][current_point])
				continue;

			next.push(P(current_distance + a[i][current_point], i));
			distance[i] = current_distance + a[i][current_point];
		}
	}
	int tmp;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> tmp;
			if (tmp == -1)
				continue;
			ans += distance[tmp];
		}
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

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

int pow0[] = {1, 10, 100, 1000, 10000, 100000, 1000000};

int newNum(int a, int l) {
    string s;
    for (int i = 0; i < l; i++) s += '0';
    s += to_string(a);
    s = s.substr(s.size()-l, l);
    sort(s.begin(), s.end());
    int minNum = 0, maxNum = 0;
    for (int i = 0; i < s.size(); i++) {
        maxNum += (s[i]-'0') * pow0[i];
        minNum += (s[l-i-1]-'0') * pow0[i];
    }
    return maxNum - minNum;
}

int main(void) {
    int a, L;
    while (cin >> a >> L) {
        if (a == 0 && L == 0) break;
        map<int, int> m;
        m.insert(make_pair(a, 0));
        int cur = 1;
        while (1) {
            int tmp = newNum(a, L);
            if (m.count(tmp) > 0) {
                cout << m[tmp] << " " << tmp << " " << m.size()-m[tmp] << endl;
                break;
            }
            m.insert(make_pair(tmp, cur++));
            a = tmp;
        }
    }
    return 0;
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(c <= a+b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

#define LIM_A 100001

char str[10001];
int N, A, B, C;
int l[LIM_A];

int flag[8];
int min_flag[8];

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d %d %d", &N, &A, &B, &C);

	for (size_t i = 0; i < N; i++) {
		scanf("%d", &l[i]);
	}
}

void initialize() {
	// nop
}

int increment_flag(int digit) {
	if (flag[digit] == 4) {
		if (digit == 0) {
			return 0;
		} else {
			flag[digit] = 0;
			return increment_flag(digit-1);
		}
	} else {
		flag[digit] += 1;
	}
	return 1;
}

int calc_mp(int flag_) {
	int mp = 0;
	int take = 0;
	int num = 0;
	if (flag_ == 0) return -1;

	for (size_t i = 0; i < N; i++) {
		if (flag[i] == flag_) {
			take += l[i];
			num++;
			if (num > 1) {
				mp += 10;
			}
		}
	}

	if (num == 0) {
		return -1;
	}

	int target_length;
	switch (flag_) {
		case 1: target_length = A; break;
		case 2: target_length = B; break;
		case 3: target_length = C; break;
	}

	int abs = take - target_length;
	abs = abs < 0 ? -abs : abs;
	mp += abs;

	return mp;
}

int main(void) {
	receive_input();
	initialize();

	int min = -1;
	do {
		int flag_continue = 0;
		int sum = 0;
		for (size_t i = 1; i < 4; i++) {
			int temp = calc_mp(i);
			if (temp == -1) {
				flag_continue = 1;
				break;
			}
			sum += temp;
		}

		if (flag_continue) {
			continue;
		}

		if (min == -1) {
			min = sum;
		} else {
			min = min < sum ? min : sum;
		}
	} while(increment_flag(N-1));

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

	return 0;
}


Measured memory_bytes: 128
//by xxj
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define fi first
#define se second
#define ll long long
#define mpa make_pair
#define pb push_back
#define pii pair<int,int>
using namespace std;
const int inf=1e9+7;
const ll linf=1e18+7;
const ll hh=523;
const int mod=1073741824;
int a[200007];
int b[200007];
int n;
bool check(int k){
	for (int i=1;i<=2*n-1;i++){
		if (a[i]<k){
			b[i]=0;
		}
		else{
			b[i]=1;
		}
	}
	//int j=n;
	for (int i=n-1;i>=1;i--){
		if (b[i]==b[i+1]){
			return b[i];
		}
		if (b[2*n-i]==b[2*n-i-1]){
			return b[2*n-i];
		}
	}
	return b[1];
}
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	scanf("%d",&n);
	for (int i=1;i<=2*n-1;i++){
		scanf("%d",a+i);
	}
	int l=1,r=2*n-1,mid;
	while (l<=r){
		mid=(l+r)/2;
		if (check(mid)){
			l=mid+1;
		}
		else{
			r=mid-1;
		}
	}
	printf("%d\n",r);
	return 0;
}
/*
input:
*/


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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


int main() {
    
    int n;
    cin >> n;
    vector<int> a(n), b(n - 1);
    rep(i, n - 1) cin >> b[i];
    
    a[0] = b[0];
    rep3(i, 1, n - 1) {
        a[i] = min(b[i - 1], b[i]);
    }
    a[n - 1] = b[n - 2];
    
    int ans = 0;
    rep(i, n) ans += a[i];
    cout << ans << '\n';
}


Measured memory_bytes: 384
import itertools
n = int(input())
l = [i + 1 for i in range(n)]
p = list(map(int, input().split()))
q = list(map(int, input().split()))
a = 0
b = 0
cnt = 1
for v in itertools.permutations(l, n):
    for i in range(n):
        if v[i] != p[i]:
            break
        if i == n - 1:
            a = cnt
    for i in range(n):
        if v[i] != q[i]:
            break
        if i == n - 1:
            b = cnt
    cnt += 1
print(abs(a - b))


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

int main() {
  int N,M;
  cin >> N >> M;
  int a[N],sum=0,count=0;
  for(int i=0; i<N; i++){
	cin >> a[i];
    sum += a[i];
  }

  for(int i=0;i<N; i++){
  	if(a[i]*4*M >= sum){
		 count ++;
    }
  }

  if(count >= M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
n = int(input())
table = [0] * (n + 1)
ans = 0
for i in range(1, n + 1):
    # こいつが地獄のように遅い
    # for v in tes.values():
    #     tmp *= (v + 1)
    # print(i, tmp)
    # 1からnまでの約数の個数を数えるズバリのやつがあるらしい エラトステネスを使ってるらしい
    # http://sucrose.hatenablog.com/entry/2016/11/06/234635
    for j in range(i, n + 1, i):
        table[j] += 1
for i in range(1, n + 1):
    ans += i * table[i]
print(ans)


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

namespace my {
template <typename T>
void input_vec(vector<T> &a, ll n) {
  if (!a.empty()) {
    cout << "wrong argument in input_vec" << endl;
    exit(1);
  }
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
}
template <typename T>
void input_set(set<T> &a, ll n) {
  if (!a.empty()) {
    cout << "wrong argument in input_set" << endl;
    exit(1);
  }
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.insert(tmp);
  }
}

char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }

ll gcd(ll a, ll b) {  // O( log(a) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * (b / my::gcd(a, b)); }  // O( log(a) )

bool isPrime(ll n) {  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}

vector<pair<ll, ll>> primeFac(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////////////////////////////

int main() {
  int n;
  cin >> n;
  vector<int> a;
  my::input_vec(a, n);

  sort(a.begin(), a.end());
  vector<bool> flags(a.back() + 1, true);
  for (int i = 0; i < n - 1; i++) {
    if (a.at(i) == a.at(i + 1)) {
      flags.at(a.at(i)) = false;
      ll tmp = a.at(i);
      while (tmp <= a.back()) {
        flags.at(tmp) = false;
        tmp += a.at(i);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (flags.at(a.at(i))) {
      ans++;
      flags.at(a.at(i)) = false;
      ll tmp = a.at(i);
      while (tmp <= a.back()) {
        flags.at(tmp) = false;
        tmp += a.at(i);
      }
    }
  }

  cout << ans << endl;
}

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

using namespace std;

int main()
{
        int n,a[10000],i,s=0;
        cin>>n;
        for(i=0;i<n;i++)
        {
                cin>>a[i];
        }
        sort(a,a+n);
        for(i=0;i<n-1;i++)
        {
               s=s+a[i];
        }
        s=s+(a[n-1]/2);
        cout<<s<<endl;
        return 0;
}



Measured memory_bytes: 256
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}



void solve(){
  double n,k;
  cin >> n >> k;

  double ans = 0.0;

  for(int i = 1; i<=n;i++){
    //ans = 1/n;
    double tmp = i;
    double cur = 1/n;

    while(tmp<k){
        tmp*=2;
        cur/=2;
    }
    //if(cur==1.0)break;
    ans+=cur;
  }

  cout << setprecision(14) << ans << endl;

} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#define INF 2100000000
using namespace std;
int absint(int a)
{
	return max(a , - a);
}
int main()
{
	int n, h[100010], i, j,k;
	int ans=INF;
	int cost[100010];
	cin >> n;
	cin >> k;
	k = min(k, n - 1);
	for (i = 1; i <= n; i++)
	{
		cin >> h[i];
		cost[i]= INF;
	}
	cost[1]= 0;
	for (i = 1; i <= n - k; i++)
	{
		for (j = 1; j <= k; j++)
		{
			cost[i + j] = min(cost[i + j], cost[i] + absint(h[i + j] - h[i]));
		}
	}
	for (j = 1; j <= k - 1; j++)
	{
		ans = min(ans, cost[n - j] + absint(h[n] - h[n - j]));
	}
	cout << min(cost[n], ans) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << a * b /2 << endl;
    return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << a[k-1] << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 12:06:59 2020

@author: liang
"""


key = 10**9 + 7
N, M = map(int, input().split())

A = [int(input()) for _ in range(M)]
A.sort()
A += [-1]

def solve():
    steps = list()
    count = 0
    index = 0
    #段差数え
    for i in range(N+1):
        if i == A[index]:
            if count == 0:
                return 0
            else:
                steps.append(count)
                count = 0
                if index < M:
                    index += 1
        else:
            count += 1
    else:
         steps.append(count)
         count = 0
        
    smax = max(steps)
    fibs = [0] * smax
    #fibテーブル生成 O(n)
    for i in range(smax):
        if i == 0 or i == 1:
            fibs[i] = 1
        else:
            fibs[i] = fibs[i-1] + fibs[i-2]  
    else:
        ans = 1
        for s in steps:
            #print(s)
            ans *= fibs[s-1]
            #print(ans)
            ans %= key
    #print(A)
    #print(steps)
    #print(fibs)
    return ans

ans = solve()        
print(ans)

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 <= i; i--)
#define FOR(i, from, to)                                                       \
  for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to)                                               \
  for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

#define MOD (ll)1000000007

int main() {
  ll h, w;
  cin >> h >> w;
  if(h == 1 || w == 1)
  {
    cout << 1 << endl;
    return 0;
  }
  
  cout << (h * w + 1) / 2 << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;


int main() {
    ll N,M,X;cin>>N>>M>>X;
    vel C(N); vel2d A(N,vel(M));
    rep0(i,N){
        cin>>C[i];
        rep0(j,M){
            cin>>A[i][j];
        }
    }
    const ll INF=100000000;
    ll ans=INF;
    rep0(tmp,1<<N){
        bitset<12> s(tmp);
        ll sum=0;
        vel d(M,0);
        rep0(i,12){
            if(s.test(i)){
                sum+=C[i];
                rep0(j,M){d[j]+=A[i][j];}
            }
        }
        //cout<<sum<<endl;
        bool flag=true;
        rep0(i,M){if(d[i]<X){flag=false; break;}}
        if(flag){ans=min(ans,sum);}
    }
    if(ans==INF){cout<<-1<<endl;}
    else{cout<<ans<<endl;}
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()	
{
	int a[5][5];
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<=100;i++)
	{
		for(int j=0;j<=100;j++)
		{
			for(int k=0;k<=100;k++)
			{
				bool flag=true;
				for(int l=1;l<=3;l++)
				{
					if(a[l][1]-i!=a[l][2]-j||a[l][2]-j!=a[l][3]-k||a[l][3]-k!=a[l][1]-i)flag=false;
				}
				if(flag)
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;

	vector< vector<int> > b(4, vector<int>(30, 0));

	for (int i = 0; i < n; ++i)
	{
		vector<int> t(4, 0);

		for (int j = 0; j < 4; ++j)
			cin >> skipws >> t[j];

		b[t[0]-1][(10 * (t[1]-1)) + t[2]-1] += t[3];
	}

	for (int i = 0; i < 4; ++i)
	{
		for (int j = 0; j < 30; ++j)
		{
			cout << " " << b[i][j];
			if (j % 10 == 9)
				cout << endl;
		}

		if (i < 3)
			cout << "####################" << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

struct X {
    long long x;
    long long y;
    long long h;
};

int main() {
    
    int N;
    cin >> N;
    vector< X > V(N);
    for ( int i = 0; i < N; i++ ) {
        long long x,y;
        long long h;
        cin >> x >> y >> h;
        V[i].x = x;
        V[i].y = y;
        V[i].h = h;
    }

    for ( long long i = 0; i <= 100; i++ ) {
    for ( long long j = 0; j <= 100; j++ ) {

        long long H = LLONG_MAX;
        long long H_l = LLONG_MAX;
        bool ok = true;
        for ( int k = 0; k < N; k++ ) {
            
            long long c = abs(i-V[k].x)+abs(j-V[k].y);

            if ( V[k].h > 0 ) {
                if ( H_l < V[k].h+c ) { ok = false; break; }

                if ( H == LLONG_MAX ) {                    
                    H = V[k].h+c;
                }
                else {
                    if ( H != V[k].h+c ) { ok = false; break; }
                }
            }

            else if ( V[k].h == 0 ) {
                H_l = min( H_l, c );
                if ( H != LLONG_MAX && H_l != LLONG_MAX && H_l < H ) { ok = false; break; }
            }
            
        }
        if ( H <= 0 ) { continue; }
        if ( ok ) { cout << i << " " << j << " " << H << endl; return 0; }
        
    }
    }

    return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int h,w; cin >> h >> w;
    vector<vector<char>> s(h+2,vector<char>(w+2));
    rep(i,h) rep(j,w) cin >> s[i+1][j+1];
    rep1(i,h+1){
        rep1(j,w+1){
            if(s[i][j] != '#')continue;
            bool is_res = false;
            for(int k=0;k<8;k+=2){
                int ex = i + dx[k];
                int ey = j + dy[k];
                if(s[ex][ey] == '#')is_res = true;
            }
            if(is_res == false){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256