akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
int a[15];
signed main() {
	int r, d;
	cin >> r >> d >> a[0];
	loop(i, 1, 11) {
		a[i] = a[i - 1] * r - d;
	}
	loop(i, 1, 11) {
		cout << a[i] << endl;
	}
}

Measured memory_bytes: 256
import sys
import copy
sys.setrecursionlimit(10**7)


def dfs(now):
    global ans
    if len(now) == N:
        tmp_ans = 0
        for a, b, c, d in query:
            a -= 1
            b -= 1
            if now[b] - now[a] == c:
                tmp_ans += d
        ans = max(tmp_ans, ans)
    else:
        for i in range(now[-1], M+1):
            tmp = copy.deepcopy(now)
            tmp.append(i)
            dfs(tmp)


N, M, Q = map(int, input().split())  # N個の数列, 上限M, Q個のクエリ
query = [list(map(int, input().split())) for _ in range(Q)]

A = [1]
ans = 0
dfs(A)
print(ans)


Measured memory_bytes: 9348
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int a[100],b[100],c[100],d[100];
int dp[101][901][901];


int main(){

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

	int first_a,first_b;
	scanf("%d %d",&first_a,&first_b);

	for(int i = 0; i < N; i++){
		scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
	}

	for(int i = 0; i <= N; i++){
		for(int k = 0; k <= 900; k++){
			for(int p = 0; p <= 900; p++)dp[i][k][p] = -1;
		}
	}

	int BASE = 300;

	dp[0][BASE+first_a][BASE+first_b] = 0;

	for(int i = 0; i < N; i++){
		for(int k = 0; k <= 900; k++){
			for(int p = 0; p <= 900; p++){
				if(dp[i][k][p] == -1)continue;

				dp[i+1][k][p] = max(dp[i+1][k][p],dp[i][k][p]);

				if(k >= a[i]){
					dp[i+1][k-a[i]][p+b[i]] = max(dp[i+1][k-a[i]][p+b[i]],dp[i][k][p]);
				}

				if(p >= c[i]){
					dp[i+1][k][p-c[i]] = max(dp[i+1][k][p-c[i]],dp[i][k][p]+d[i]);
				}
			}
		}
	}

	int ans = 0;
	for(int k = BASE; k <= 900; k++){
		for(int p = BASE; p <= 900; p++)ans = max(ans,dp[N][k][p]);
	}

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

	return 0;
}



Measured memory_bytes: 323468
#include <iostream>
#define MEN 6
using namespace std;


struct DICE
{
	int num;
};

int main()
{
	DICE A[MEN];
	DICE B1[MEN];
	DICE B2[MEN];
	DICE B3[MEN];
	int flag = 0;
	int x;

	for (int in1 = 0; in1 < MEN; in1++)
	{
		cin >> A[in1].num;
	}
	for (int in2 = 0; in2 < MEN; in2++)
	{
		cin >> B1[in2].num;
	}

	for (int count = 0; count < MEN; count++)
	{
		for (int i = 0; i < MEN; i++)
		{
			B2[i] = B1[i];
		}

		if (1 <= count && count <= 5)
		{
			x = B2[0].num;
			B2[0].num = B2[1].num;
			B2[1].num = B2[5].num;
			B2[5].num = B2[4].num;
			B2[4].num = x;
		}

		if (2 <= count && count <= 4)
		{
			for (int i = 0; i < count - 1; i++)
			{
				x = B2[0].num;
				B2[0].num = B2[2].num;
				B2[2].num = B2[5].num;
				B2[5].num = B2[3].num;
				B2[3].num = x;
			}
		}

		if (count == 5)
		{
			x = B2[0].num;
			B2[0].num = B2[1].num;
			B2[1].num = B2[5].num;
			B2[5].num = B2[4].num;
			B2[4].num = x;
		}

		if (A[0].num != B2[0].num)
		{
			continue;
		}

		for (int i= 0; i < MEN; i++)
		{
			B3[i] = B2[i];
		}

		for (int count2 = 0; count2 < 4; count2++)
		{
			for (int i = 0; i < MEN; i++)
			{
				B2[i] = B3[i];
			}
			for (int i = 0; i < count2; i++)
			{
				x = B2[1].num;
				B2[1].num = B2[2].num;
				B2[2].num = B2[4].num;
				B2[4].num = B2[3].num;
				B2[3].num = x;
			}

			x = B2[0].num;
			B2[0].num = B2[1].num;
			B2[1].num = B2[5].num;
			B2[5].num = B2[4].num;
			B2[4].num = x;

			if (A[1].num != B2[0].num)
			{
				continue;
			}

			x = B2[0].num;
			B2[0].num = B2[2].num;
			B2[2].num = B2[5].num;
			B2[5].num = B2[3].num;
			B2[3].num = x;

			if (A[2].num != B2[0].num)
			{
				continue;
			}

			x = B2[0].num;
			B2[0].num = B2[2].num;
			B2[2].num = B2[5].num;
			B2[5].num = B2[3].num;
			B2[3].num = x;

			if (A[4].num != B2[0].num)
			{
				continue;
			}

			x = B2[0].num;
			B2[0].num = B2[2].num;
			B2[2].num = B2[5].num;
			B2[5].num = B2[3].num;
			B2[3].num = x;

			if (A[3].num != B2[0].num)
			{
				continue;
			}

			x = B2[0].num;
			B2[0].num = B2[1].num;
			B2[1].num = B2[5].num;
			B2[5].num = B2[4].num;
			B2[4].num = x;

			if (A[5].num == B2[0].num)
			{
				flag = 1;
			}
			if (flag == 1)
			{
				break;
			}
		}
		if (flag == 1)
		{
			break;
		}
	}

	if (flag == 1)
	{
		cout << "Yes" << endl;
	}
	else if (flag == 0)
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <cstring>
using namespace std;
int n;
char t[256][256];
int d[4][2] = {
	{-1, 0},
	{-1, -1},
	{0, -1},
	{1, -1},
};
int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> t[i];
		}
		int result = 0;
		for (int i = 0; i < 4; i++) {
			int res[256][256];
			memset(res, 0, sizeof(res));
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					int preX = k + d[i][0];
					int preY = j + d[i][1];
					if ((preX < 0 || preY < 0 || preX >= n) && t[j][k] == '1') {
						res[j][k] = 1;
					}
					else {
						if (t[j][k] == '1') {
							res[j][k] = res[preY][preX] + 1;
						}
					}
					result = max(result, res[j][k]);
					//cout << ' ' << res[j][k];
				}
				//cout << endl;
			}
		}
		cout << result << endl;
	}
}

Measured memory_bytes: 1488
package main

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

func main(){
  defer stdout.Flush()
  
  n := readInt()
  k := readInt()
  a := make([]int, n)
  var gcd int
  for i := range a {
    a[i] = readInt()
    if i == 0 {
      gcd = a[i]
    }
    gcd = gcdInt(gcd, a[i])
  }
  sort.Ints(a)
  if a[n-1] >= k && k%gcd == 0 {
    fmt.Println("POSSIBLE")
  }else{
    fmt.Println("IMPOSSIBLE")
  }
}

//====  ↓↓↓ Scanner ↓↓↓  ====================================

var (
  readString func() string
  stdout     *bufio.Writer
)
 
func init() {
  readString = newReadString(os.Stdin)
  stdout = bufio.NewWriter(os.Stdout)
}
 
func newReadString(ior io.Reader) func() string {
  r := bufio.NewScanner(ior)
  r.Buffer(make([]byte, 1024), int(1e+11))
  r.Split(bufio.ScanWords)
 
  return func() string {
    if !r.Scan() {
      panic("Scan failed")
    }
    return r.Text()
  }
}
 
func readInt() int {
  return int(readInt64())
}
 
func readInt64() int64 {
  i, err := strconv.ParseInt(readString(), 0, 64)
  if err != nil {
    panic(err.Error())
  }
  return i
}
 
func readIntSlice(n int) []int {
  b := make([]int, n)
  for i := 0; i < n; i++ {
    b[i] = readInt()
  }
  return b
}
 
func readLengthAndSlice() []int {
  n := readInt()
  return readIntSlice(n)
}


//====  ↓↓↓ template functions ↓↓↓  ===========================

//min max
func minInt(a, b int) int{
  if a < b {
    return a
  }
  return b
}

func minInt64(a, b int64) int64{
  if a < b {
    return a
  }
  return b
}

func minFloat64(a, b float64) float64{
  if a < b {
    return a
  }
  return b
}

func maxInt(a, b int) int{
  if a > b {
    return a
  }
  return b
}

func maxInt64(a, b int64) int64{
  if a > b {
    return a
  }
  return b
}

func maxFloat64(a, b float64) float64{
  if a > b {
    return a
  }
  return b
}

//abs
func absInt(x int) int{
  if x < 0 {
    return -x
  }
  return x
}

func absInt64(x int64) int64{
  if x < 0 {
    return -x
  }
  return x
}

func absFloat64(x float64) float64{
  if x < 0 {
    return -x
  }
  return x
}

//gcd lcm
func gcdInt(a, b int) int{
  if b == 0 {
    return a
  }else{
    return gcdInt(b, a%b)
  }
}

func gcdInt64(a, b int64) int64{
  if b == 0 {
    return a
  }else{
    return gcdInt64(b, a%b)
  }
}

func lcmInt(a, b int) int{
  return a*b/gcdInt(a, b);
}

func lcmInt64(a, b int64) int64{
  return a*b/gcdInt64(a, b);
}


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

int gcd(int a, int b){
        if(a == 0 ){
            return b;
        } else if ( b == 0)
        {
            return a;
        } else if (a >= b )
        {
            a = a - b * ( a / b ) ;
            return gcd(a,b);
        }
        else if ( b > a)
            {
            b = b - a * ( b / a);
            return gcd(a,b);
        }
}

int main(){
    signed int a, b;
    signed int g , l;
    while(cin >> a >> b)
        {
        g = gcd(a,b);
        l = a / g * b;
        cout << g << " " << l << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import numpy as np
N,M = map(int,input().split())

x = []
y = []
z = []
for k in range(N):
    xx,yy,zz = map(int,input().split())
    x.append(xx)
    y.append(yy)
    z.append(zz)

ite = [-1,1]

s_ori = np.vstack([x,y,z])
cc = []
for i in ite:
    for j in ite:
        for k in ite:
            s = s_ori.copy()
            s[0,:] *= i
            s[1,:] *= j
            s[2,:] *= k
            a = np.sum(s,axis = 0)
            b = np.sort(a)[::-1][:M]
            c = sum(b)
            cc.append(c)
print(np.max(cc))

Measured memory_bytes: 21644
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
int main()
{
	int a,b,h,m;
	double PI=3.14159265358979323846;
	cin>>a>>b>>h>>m;
	m+=h*60;
	double hh=2*PI/720*m;
	double mm=2*PI/60*m;
	while (hh>2*PI) hh-=2*PI;
	while (mm>2*PI) mm-=2*PI;
	double del=hh-mm;
	double ans=sqrt(a*a+b*b-2*a*b*cos(del));
	cout<<setiosflags(ios::fixed)<<setprecision(15)<<ans;
}

Measured memory_bytes: 4132
#include <stdio.h>
int main(void)
{
int H ,W;
int i, j;
while(1){
scanf("%d %d" ,&H ,&W);
if(H == 0 && W == 0) break;
for ( i = 0; i < H; i++ ){
for ( j = 0; j < W; j++ ){
if(j==0||j==W-1||i==0||i==H-1){
printf("#");
}else{
printf(".");
}
}
printf("\n");
}
puts("");
}
return 0;
}


Measured memory_bytes: 2052
import java.util.*;
import java.io.*;
class Main{
    public static void main(String[] args){
	int i,j,n,q;
	Scanner sc = new Scanner(System.in);
	int a[] = new int[20];
	int m[] = new int[200];
	int s[] = new int[2000];
	n = sc.nextInt();
	for(i=0;i<n;i++){
	    a[i] = sc.nextInt();
	}
	q = sc.nextInt();
	for(j=0;j<q;j++){
	    m[j] = sc.nextInt();
	}
	for(j=0;j<q;j++){
	    if(solve(0,m[j],n,a)==true){
		System.out.println("yes");
	    }
	    else{
		System.out.println("no");
	    }
	}
    }
    public static boolean solve(int i,int m,int n,int a[]){
	boolean success;
	if(m==0){
	    return true;
	}
	if(i>=n){
	    return false;
	}
	success = solve(i+1,m,n,a) || solve(i+1,m-a[i],n,a);
	return success;
    }
}



Measured memory_bytes: 26972
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}


Measured memory_bytes: 256
import Data.List
import qualified Data.Vector as V

type Floor = V.Vector Int
type Tower = V.Vector Floor
type Estate = V.Vector Tower

estini :: Estate
estini = V.replicate 4 (V.replicate 3 (V.replicate 10 0))

vunwords :: V.Vector String -> String
vunwords vs = ' ' : (V.foldl1 (\n m -> n ++ " " ++ m) vs)

vunlines :: V.Vector String -> String
vunlines vs = (V.foldl1 (\n m -> n ++ "\n" ++ m) vs) ++ "\n"

vrt :: V.Vector Int -> V.Vector String
vrt = V.map show

strTower :: Tower -> String
strTower tw = vunlines (V.map vunwords (V.map vrt tw))

strEstate :: Estate -> [String]
strEstate est = map (\n -> strTower (est V.! n)) [0..3]

sepa :: String
sepa = replicate 20 '#' ++ "\n"

solve :: [Int] -> Estate -> Estate
solve (tw:fl:rm:new:[]) est =
    let old  = (est V.! (tw - 1) V.! (fl - 1)) V.! (rm - 1)
        nfl  = (est V.! (tw - 1) V.! (fl - 1)) V.// [(rm - 1, new + old)]
        ntw  = est V.! (tw - 1) V.// [(fl - 1, nfl)]
     in est V.// [(tw - 1, ntw)]

main = do
    getLine
    cs <- getContents
    let xs = map ((map read) . words) (lines cs) :: [[Int]]
    mapM_ putStr $ intersperse sepa (strEstate (foldr solve estini xs))


Measured memory_bytes: 5092
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
void solve(long long n, long long m, std::vector<long long> a) {
    ll base_cost = 0;
    vector<ll> saved(2 * m + 3);
    auto update = [&](int L, int R) {
        saved[L + 1] += 1;
        saved[R + 1] -= R - L + 1;
        saved[R + 2] += R - L;
    };
    for(int i = 1; i < n; i++) {
        base_cost += (a[i] - a[i - 1] + m) % m;
        a[i] > a[i - 1] ? update(a[i - 1] + 1, a[i]) : update(a[i - 1] + 1, a[i] + m);
    }
    partial_sum(saved.begin(), saved.end(), saved.begin());
    partial_sum(saved.begin(), saved.end(), saved.begin());
    ll ans = lim<ll>::max();
    for(int x = 1; x <= m; x++) {
        ans = min(ans, base_cost - saved[x] - saved[x + m]);
    }
    cout << ans << endl;
}
int main() {
    long long n;
    scanf("%lld",&n);
    long long m;
    scanf("%lld",&m);
    std::vector<long long> a(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&a[i]);
    }
    solve(n, m, std::move(a));
    return 0;
}


Measured memory_bytes: 2560
package main

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

func main() {
	N := ReadInt()
	fmt.Println(180*N - 360)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1836
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long

int n,S[100001],q,C=0;

int main() {
	cin>>n;
	for(int i=0;i<n;i++)cin>>S[i];
	cin>>q;
	for(int i=0;i<q;i++){
		int T;
		cin>>T;
		auto tag = lower_bound(S,S+n,T);
		if(*tag==T)C++;
	}
	cout<<C<<endl;
	return 0;
}




Measured memory_bytes: 3396
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int h, w; cin >> h >> w;
    map<char, int> cnt;
    rep(i, h){
        string s; cin >> s;
        rep(j, w){
            cnt[s[j]]++;
        }
    }
    int x1 = 0, x2 = 0, x4 = 0;
    
    for(auto [c, v] : cnt) {
        // cout << c << " " << v << endl;
        if(v % 2) {
            x1++;
            v--;
        }
        if(v % 4) {
            x2++;
            v -= 2;
        }
        if(v) x4 += v/4;
    }
    // cout << x1 << " " << x2 << " " << x4 << endl;
    
    bool ok = true;
    if((h % 2) && (w % 2)){
        int pr = (h + w - 2) / 2;
        if(x1 != 1) ok = false;
        if(x2 > pr) ok = false;
        if((pr - x2) % 2 != 0) ok = false;
    }else if(!(h % 2) && !(w % 2)){
        if(x1 > 0) ok = false;
        if(x2 > 0) ok = false;
    }else{
        if(w % 2) swap(h, w);
        if(x1 > 0) ok = false;
        if(x2 > w/2) ok = false;
        if((w/2 - x2) % 2 != 0) ok = false;
    }
    puts(ok ? "Yes" : "No");
    return;
}

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

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mn=1e5+10;
typedef pair<int,int>pii;
int a[mn][2];
int dp[1<<18][18];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i][0]);
    for(int i=0;i<n;i++)scanf("%d",&a[i][1]);
    for(int i=1;i<n;i+=2)swap(a[i][0],a[i][1]);
    memset(dp,0x3f,sizeof(dp));
    for(int i=0;i<n;i++)dp[1<<i][i]=i;
    for(int i=1;i<1<<n;i++){
        if(__builtin_popcount(i)==1)continue;
        for(int j=0;j<n;j++)if((i>>j)&1){
            int mov=j-__builtin_popcount(i%(1<<j));
            int ind=__builtin_popcount(i)&1^1;
            for(int k=0;k<n;k++){
                if(j==k)continue;
                if(a[k][ind^1]<=a[j][ind])dp[i][j]=min(dp[i][j],dp[i-(1<<j)][k]+mov);
            }
        }
    }
    int ans=0x3f3f3f3f;
    for(int i=0;i<n;i++)ans=min(ans,dp[(1<<n)-1][i]);
    if(ans<1000)printf("%d",ans);
    else printf("-1");
}

Measured memory_bytes: 18688
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;




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

	long long k, n, i, j, ans = 0, r;
	cin >> k;
	r = 7; ans = 1;
	vector<bool> used(k + 1, false);
	
	if (k == 1) ans = 1;
	else if (k == 7) ans = 1;
	else {
		while (r != 0) {
			if (used[r]) {
				ans = -1;
				break;
			}
			used[r] = true;
			r = (r * 10 + 7) % k;
			ans++;
		}
	}

	cout << ans << "\n";

	return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;

typedef unsigned long long ll;

const long long MOD = 1000000000 + 7;

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

int main(){
    string c;
    cin >> c;
    if(c ==  "a" || c ==  "i" || c ==  "u" ||c ==  "e" || c ==  "o" ) {
        cout << "vowel" << endl;
        return 0;
    }else{
        cout << "consonant" << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
X,N = map(int,input().split())
p = list(map(int,input().split()))

p.sort()

if p.count(X) == 0:
    print(X)
    exit()

array = [0]*100
for i in range(N):
    array[p[i]-1] = 1

ans_smaller_x = 0
ans_bigger_x = 101

for i in range(X-2,-1,-1):
    if array[i] == 0:
        ans_smaller_x = i+1
        break

for i in range(X,100,1):
    if array[i] == 0:
        ans_bigger_x = i+1
        break

if abs(X - ans_smaller_x) == abs(X - ans_bigger_x):
    print(ans_smaller_x)
else:
    if abs(X - ans_smaller_x) > abs(X - ans_bigger_x):
        print(ans_bigger_x)
    else:
        print(ans_smaller_x)

Measured memory_bytes: 9232
import java.util.*;
public class Main{
  public static long[][] memo;
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int W = sc.nextInt();
    memo = new long[N+1][W+1];
    for(int i = 0; i <= N; i++){
      Arrays.fill(memo[i], -1);
    }
    memo[0][0] = 0;
    int[] w = new int[N];
    long[] v = new long[N];
    for(int i = 0; i < N; i++){
      w[i] = sc.nextInt();
      v[i] = sc.nextLong();
    }
    System.out.println(solve(w, v, W, N));
  }
  
  public static long solve(int[] w, long[] v, int W, int N){
    for(int i = 0; i < N; i++){
      for(int j = 0; j <= W; j++){
        if(memo[i][j] != -1){
          if(w[i] + j <= W){
            long tmp = memo[i][j] + v[i];
            memo[i+1][w[i]+j] = memo[i+1][w[i]+j] > tmp ? memo[i+1][w[i]+j] : tmp;
          }
          memo[i+1][j] = memo[i+1][j] > memo[i][j] ? memo[i+1][j] : memo[i][j];
        }
      }
    }
    Arrays.sort(memo[N]);
    return memo[N][W];
  }
}

Measured memory_bytes: 128596
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

//dfs???????????????3^12?
//int used[13]????????§?????????+1??¨-1??¨??????????????????????????????????????°

int card[15];

int dfs(int l, int r, int a, int b, bool turn) {
	if (a == 0)
		return 1;
	if (b == 0)
		return 0;

	int n = 0, m = 0;
	if (card[l - 1] == turn) {
		m++;
		card[l - 1] = -1;
		if (turn == 0) {
			n += dfs(l - 1, r, a - 1, b, !turn);
		}
		else {
			n += dfs(l - 1, r, a, b - 1, !turn);
		}
		card[l - 1] = turn;
	}
	if (card[r + 1] == turn) {
		m++;
		card[r + 1] = -1;
		if (turn == 0) {
			n += dfs(l, r + 1, a - 1, b, !turn);
		}
		else {
			n += dfs(l, r + 1, a, b - 1, !turn);
		}
		card[r + 1] = turn;
	}

	if (m == 0) {
		m++;
		n += dfs(l, r, a, b, !turn);
	}

	if (turn == 0) {
		if (n > 0)
			return 1;
		return 0;
	}
	else {
		if (n == m)
			return 1;
		return 0;
	}
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		int f;

		fill(card, card + 15, -1);
		for (int i = 0; i < 6; ++i) {
			cin >> f;
			card[f] = 0;
		}
		for (int i = 1; i <= 13; ++i) {
			if (i == 7 || card[i] == 0)
				continue;
			card[i] = 1;
		}

		puts(dfs(7, 7, 6, 6, 0) ? "yes" : "no");
	}

	return 0;
}

Measured memory_bytes: 3028
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

# lから1つおきにみたときの最小値を求める特別製
class SparseTable:
    def __init__(self, aa):
        inf = 10 ** 16
        w = len(aa)
        h = w.bit_length()
        table = [aa] * 2 + [[inf] * w for _ in range(h - 2)]
        tablei1 = table[0]
        for i in range(2, h):
            tablei = table[i]
            shift = 1 << (i - 1)
            for j in range(w):
                rj = j + shift
                if rj >= w: break
                tablei[j] = min(tablei1[j], tablei1[rj])
            tablei1 = tablei
        self.table = table

    # [l,r)の最小値
    def min(self, l, r):
        if (r - l) % 2: r += 1
        i = (r - l).bit_length() - 1
        tablei = self.table[i]
        Lmin = tablei[l]
        Rmin = tablei[r - (1 << i)]
        if Lmin < Rmin: Rmin = Lmin
        return Rmin

def main():
    n = int(input())
    pp = LI()
    st = SparseTable(pp)
    ptoi = [0] + [i for i, p in sorted(enumerate(pp), key=lambda x: x[1])]
    # 区間偶数番目の最小値と[l,r)をヒープに
    hp = []
    heappush(hp, [st.min(0, n), 0, n])
    ans = []
    for _ in range(n // 2):
        x, l, r = heappop(hp)
        if l + 2 == r:
            ans += [pp[l], pp[l + 1]]
            continue
        xi = ptoi[x]
        y = st.min(xi + 1, r)
        yi = ptoi[y]
        if xi > l:
            heappush(hp, [st.min(l, xi), l, xi])
        if xi + 1 < yi:
            heappush(hp, [st.min(xi + 1, yi), xi + 1, yi])
        if yi < r - 1:
            heappush(hp, [st.min(yi + 1, r), yi + 1, r])
        ans += [x, y]
    print(*ans)

main()


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

using namespace std;

string solve(vector<int> a) {
    for(auto& i : a) {
        if(i%2 == 0) {
            if(i%3 != 0 && i%5 != 0)
                return "DENIED";
        }
    }
    return "APPROVED";
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a.at(i);
    cout << solve(a);
}


Measured memory_bytes: 256
package main

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

func main() {
	judge(os.Stdin, os.Stdout)
}

func judge(r io.Reader, w io.Writer) {
	n := scanRowText(r)
	result := 0
	for _, v := range n {
		d, _ := strconv.Atoi(string(v))
		result += d
		result %= 9
	}
	if result == 0 {
		fmt.Fprintln(w, "Yes")
		return
	}
	fmt.Fprintln(w, "No")
}

const maxCapacity = 512 * 1024

func scanRowText(r io.Reader) string {
	scanner := bufio.NewScanner(r)
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	return scanner.Text()
}


Measured memory_bytes: 2188
S = input()
T = input()

n = len(T)
res = n
for i in range(len(S) - n + 1):
    count = 0
    for c1, c2 in zip(S[i: i + n], T):
        if c1 != c2:
            count += 1
    res = min(count, res)
print(res)


Measured memory_bytes: 9036
#include <iostream>
#include <vector>
#include <algorithm>
#define A 0
#define B 1
#define C 2

using namespace std;

int num;

int Search(int p, int day, vector<vector<int>> &h, vector<vector<int>> &s) {
	if (day == num)
		return 0;
	int next1 = (p + 1) % 3, next2 = (p + 2) % 3;
	if (s[p][day] == -1)
		s[p][day] = h[p][day] + max(Search(next1, day+1, h, s), Search(next2, day+1, h, s));
	return s[p][day];
}

int main(void) {
	int i = 0, ans = 0;
	cin >> num;
	vector<vector<int>> h(3, vector<int>(num)), s(3, vector<int>(num, -1));
	for (; i < num; i++)
		scanf("%d%d%d", &h[A][i], &h[B][i], &h[C][i]);
	
	for (i = 0; i < 3; i++) {
		ans = max(ans, Search(i, 0, h, s));
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 12408
# ########## ------ Import ------- ##########

import sys
import math
from collections import Counter
from collections import deque as deq
from functools import lru_cache

# ########## ------ Define -------- #########

INT_MAX = float("inf")
INT_MIN = float("-inf")

# ########## ------ Input Functions ---- #########

input = sys.stdin.readline


def inp():
    return(int(input()))


def inlt():
    return(list(map(int, input().split())))


def insr():
    s = input()
    return(list(s[:len(s) - 1]))


def invr():
    return(map(int, input().split()))


# ########## ------ Code ------- ##########
t = inp()
a = inlt()

if t == 1:
    print(0)
elif t == 2:
    print(abs(a[0] - a[1]))

else:
    dp=[-1]*t
    dp[0] = 0
    dp[1] = abs(a[0] - a[1])
    for i in range(2, t):
        dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1],
                    abs(a[i] - a[i - 2]) + dp[i - 2])


    print(dp[t - 1])


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

int main(){
    int N, P;
    cin >> N >> P;
    vector<int> A(N,0);
    REP(i,N){
        cin >> A[i];}
    int c = 0;
    REP(i,N){
        if(A[i]%2==1){
            c = 1;
            break;}}
    ll ans = 0;
    if(c){
        ans = pow(2,N-1);
    }else{
        if(!P){
            ans = pow(2,N);}}
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
int a,b;
	scanf("%d %d",&a,&b);

	if(a>b){
		printf("a > b\n");
	}else if(a<b){
		printf("a < b\n");
	}else if(a==b){
		printf("a == b\n");
	}


return(0);
}


Measured memory_bytes: 2060
from functools import reduce

n,a,b=map(int,input().split())

mod=10**9+7
def nCk(n,k):
  c=reduce(lambda x,y: x*y%mod, range(n,n-k,-1))
  m=reduce(lambda x,y: x*y%mod, range(1,k+1))
  return c*pow(m,mod-2,mod)%mod

all=pow(2,n,mod)
nCa=nCk(n,a)
nCb=nCk(n,b)

print((all-nCa-nCb-1)%mod)

Measured memory_bytes: 3700
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

N = getN()
query = []
for i in range(N):
    a, b = getNM()
    query.append([a, b, i])

q_a = sorted(query, key = lambda i: i[0])
q_b = sorted(query, key = lambda i: i[1])
edges = []

a1 = q_a[0]
b1 = q_b[0]
for i in range(1, N):
    a2 = q_a[i]
    b2 = q_b[i]
    edges.append([abs(a1[0] - a2[0]), a1[2], a2[2]])
    edges.append([abs(b1[1] - b2[1]), b1[2], b2[2]])
    a1, b1 = a2, b2
edges.sort()

def kruskal(n, edges):
    U = UnionFind(n)
    res = 0
    for e in edges:
        w, s, t = e
        if not U.same(s, t):
            res += w
            U.union(s, t)
        if U.size(0) == N:
            break
    return res
print(kruskal(N, edges))

Measured memory_bytes: 136336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int N;
class BellmanFord
{
    struct edge
    {
        int a, b;
        ll w;
    };
    int n;
    vector<edge> edges;
    vector<vector<int>> rev;
    vector<ll> d;
    vector<bool> reachable;
    void bfs(){
        queue<int> que;
        que.push(N);
        reachable[N] = true;
        while(!que.empty()){
        int a = que.front();
        que.pop();
        for(auto i:rev[a]){
            if(reachable[i]==false)
            {
                reachable[i] = true;
                que.push(i);
            }
            }
        }
    }
public:
    bool is_negative_loop = false;
    BellmanFord(int n) : n(n), edges(n), d(n, 1e18),rev(n),reachable(n) {}
    void add_edge(int a, int b, ll w)
    {
        assert(0 <= a && a < n && 0 <= b && b < n);
        edges.push_back({a, b, w});
        edges.push_back({b, a, w});
    }

    void add_arc(int a, int b, ll w)
    {
        assert(0 <= a && a < n && 0 <= b && b < n);
        edges.push_back({a, b, w});
        rev[b].push_back(a);
    }

    // return true if has negative loop
    void build(int a)
    {
        d[a] = 0;
        bfs();
        for (int i = 0; i < n; i++)
        {
            bool change = false;
            for (edge e : edges)
            {
                if (d[e.a] != 1e18 && reachable[e.a] && reachable[e.b])
                {
                    if (d[e.b] > d[e.a] + e.w)
                    {
                        d[e.b] = d[e.a] + e.w;
                        change = true;
                    }
                }
            }
            if (!change)
            {
                return;
            }
        }
        is_negative_loop = true;
    }

    ll dist(int a)
    {
        return d[a];
    }
};

int main()
{
    int m, p;
    cin >> N >> m >> p;
    BellmanFord bel(N+10);
    rep(i, m)
    {
        int a, b, c;
        cin >> a >> b >> c;
        c-=p;
        bel.add_arc(a,b,-c);
    }
    bel.build(1);
        if (bel.is_negative_loop)
        {
            cout << -1 << endl;
            return 0;
        }
    cout << max(0LL,-bel.dist(N))<<endl;
    return 0;
}

Measured memory_bytes: 640
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    i = 0
    while i < N:
        while i+1 < N and A[i] == A[i+1]:
            i += 1
        pos1, pos2 = i, i
        while pos1+1 < N and A[pos1] <= A[pos1+1]:
            pos1 += 1
        while pos2+1 < N and A[pos2] >= A[pos2+1]:
            pos2 += 1
        ans += 1
        i = max(pos1, pos2) + 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

int main() {
  double r;
  double pi = 3.14159265358979323846264338327950288;
  cin>>r;

  cout<<2*r*pi<<endl;

  return 0;
}

Measured memory_bytes: 3784
/*

*/
#include <bits/stdc++.h>

using namespace std;

#define ll           long long int
#define vi 			 vector<int>
#define pb           push_back
#define fi           first
#define si           second
#define pii 		 pair<int,int>
#define vii 		 vector<pair<int,int>>
#define F(a,n)       for(int i=0;i<n;i++){cin>>a[i];}
#define P(a,n)       for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define fastIO       ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F1(a,n)      for(int i=1;i<=n;i++){cin>>a[i];}
#define P1(a,n)      for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define mem(a,b)     memset(a, b, sizeof a)
#define matrix(x) 	 vector<vector<x>>
#define NF(a,n,m)    for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m)   for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m)   for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m)  for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
const int nax = 1e7;
const int mod = 1e9+7;

void func(){
	int t;
	cin>>t;
	if(t){
		cout<<0;
		return;
	}
	cout<<1;
}

int main(){
	fastIO
	int t=1;//cin>>t;
	while(t--){
		func();
	}
}

Measured memory_bytes: 3608
#include <cstdio>
#include <queue>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;
const int MAXN = 305;
struct Edge {
    int v, w;
};
vector<Edge> adj[MAXN];
int n;
struct Item {
    int val;
    int u, v;
};
bool cmp(const Item &a, const Item &b) {
    return a.val < b.val;
}
long long dis[MAXN][MAXN];
Item item[MAXN * MAXN];
int cnt_item;
int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) {
        if(i == j) dis[i][j] = 0;
        else dis[i][j] = 1e9 + 7;
        int val; scanf("%d", &val);
        if(i < j) {
            item[cnt_item++] = (Item){val, i, j};
        }
    }
    sort(item, item + cnt_item, cmp);
    long long ans = 0;
    for(int i = 0; i < cnt_item; i++) {
        if(dis[item[i].u][item[i].v] < item[i].val) {
            printf("-1\n");
            return 0;
        }
        else if(dis[item[i].u][item[i].v] > item[i].val) {
            int u = item[i].u, v = item[i].v;
            dis[u][v] = dis[v][u] = item[i].val;
            for(int x = 1; x <= n; x++) for(int y = 1; y <= n; y++) {
                dis[x][y] = dis[y][x] = std::min(dis[x][y], dis[x][u] + dis[u][v] + dis[v][y]);
            }
            ans += item[i].val;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1536
import sys
if __name__ == '__main__':

	n = int(input())

	A = [sys.stdin.readline().split() for _ in range(n)]

	B = sorted(A,key=lambda x:(int(x[0]),int(x[1]),x[2],int(x[3]),x[4]))

	for i in range(n):
		print(*B[i])



Measured memory_bytes: 68052
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, 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")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        h: usize, w: usize,
        c: [[i64; 10]; 10],
        a: [[i64; w]; h],
    }
    let mut ans = 0;
    let mut cost = c.clone();

    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    for i in 0..h {
        for j in 0..w {
            if a[i][j] >= 0 {
                ans += cost[a[i][j] as usize][1];
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
main()
{

  int i, j, n, pri[60000] = {0};
 
  for(i = 2; i < 60000; i++){
    if(pri[i] == 0){
      for(j = i+i; j < 60000; j+=i){
	pri[j] = 1;
      }
    }
  }

  while(scanf("%d", &n) != EOF){
    
    for(i = n-1; pri[i] != 0; i--);

    for(j = n+1; pri[j] != 0; j++);

    printf("%d %d\n", i, j);

  }
      

  return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
    int paSize = printArray.size();
    for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
    if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const int INF = 1e8;
int n, m;
int c[22];
int dp[55555];

int main() {
    cin >> n >> m;
    rep (i, m) {
        cin >> c[i];
    }

    fill(dp, dp+n+1, INF);
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        rep (j, m) {
            dp[i] = min(dp[i], dp[i-1]+1);
            if (i - c[j] >= 0) {
                dp[i] = min(dp[i], dp[i-c[j]]+1);
            }
        }
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 3276
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	ll n, ans = 0;
	cin >> n;
	vector<ll>l(2 * n + 1);
	for (ll i = 1;i <= 2 * n;i++)cin >> l[i];
	sort(l.begin(), l.end());
	for (ll i = 1;i <= n;i++)ans += l[2 * i - 1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b,c,sum=0;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=a;i<=b;i++){
		if(c%i==0) sum++;
	}
	printf("%d\n",sum);
	return 0;
}


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

int main(){
    int i,j,a[12][10]={0},k,b,c,d,n,m;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>k>>b>>c>>d;
        m=3*(k-1)+b-1;
        a[m][c-1]+=d;
    }
    for(i=0;i<12;i++){
        for(j=0;j<10;j++){
            cout<<" "<<a[i][j];
        }
        cout<<endl;
        if((i+1)%3==0&&i<11){
            cout<<"####################"<<endl;
        }
    }
    return 0;

}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mod 1000000007
using namespace std;
typedef long long ll;

int main(void)
{
    int n;
    cin >> n;
    vector<int> num(n+1);
    for (int i = 1; i <= n - 1; i++)
    {
        int ai;
        cin >> ai;
        num[ai]++;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << num[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,A,B;
  cin >> K >> A >> B;
  int Ka;
  for(int i=1;;i++){
    Ka=K*i;
    if(A<=Ka && B>=Ka){
      cout << "OK" << endl;
      break;
    }
      if(Ka>B){
        cout << "NG" << endl;
        break;
      }
  }
}
        

Measured memory_bytes: 3632
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <set>
#include <map>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
typedef long long LL;
typedef unsigned long long ULL;

string s;
int main() {
	cin >> s;
	if (s[0] == s[s.size() - 1]) {
		cout << (s.size() % 2 == 0 ? "First" : "Second") << endl;
	} else {
		cout << (s.size() % 2 == 0 ? "Second" : "First") << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

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



int main() {
  int K;
  int a[1000001];
  cin >> K;
  int A;
  A = K;
  a[0] = 7;
  if(K % 2 == 0 || K % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }

  rep(i, K) {
    a[i+1] = a[i] * 10;
    a[i+1] %= K;
  }

  // cout << A << endl;
  int key = 0;
  rep(i, A) {
    key += a[i];
    key %= A;
    // cout << a[i] << endl;
    if(key % A == 0) {
      cout << i+1 << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 7468
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;
int c,n,m,s,d;
vector<P> G[101];
int cost[101][11];
int INF=10000000;

int dijkstra(int s){
	priority_queue<PP, vector<PP>, greater<PP> >que;
	for(int i=0;i<=100;i++){
		for(int j=0;j<=10;j++){
			cost[i][j]=INF;
		}
	}
	cost[s][0]=0;
	que.push(PP(P(s,0),0));
	while(que.size()){
		PP p=que.top();que.pop();
		int v=p.first.first,d=p.first.second,k=p.second;
		if(cost[v][k]<d)continue;
		for(int i=0;i<G[v].size();i++){
			P e=G[v][i];
			if(cost[e.first][k]>cost[v][k]+e.second){
				cost[e.first][k]=cost[v][k]+e.second;
				que.push(PP(P(e.first,cost[e.first][k]),k));
			}
		}
		if(k<c)for(int i=0;i<G[v].size();i++){
			P e=G[v][i];
			if(cost[e.first][k+1]>cost[v][k]+e.second/2){
				cost[e.first][k+1]=cost[v][k]+e.second/2;
				que.push(PP(P(e.first,cost[e.first][k+1]),k+1));
			}
		}
	}

	int ans=INF;
	for(int i=0;i<=10;i++){
		ans=min(ans,cost[d][i]);
	}
	return ans;
}

int main(void){
	while(1){
		scanf("%d%d%d%d%d",&c,&n,&m,&s,&d);
		if(c==0 && n==0 && m==0 && s==0 && d==0)break;
		for(int i=0;i<=100;i++)G[i].clear();
		for(int i=0;i<m;i++){
			int a,b,f;
			scanf("%d%d%d",&a,&b,&f);
			G[a].push_back(P(b,f));
			G[b].push_back(P(a,f));
		}
		cout << dijkstra(s) << endl;
	}
    return 0;
}

Measured memory_bytes: 1040