akhauriyash/Code-Regression huggingface dataset:
#[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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!{
      a: usize,
      s: String
    }
    if a>=3200 {
        puts!("{}\n", s);
    } else {
        puts!("{}\n", "red");
    }
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val INF = 1001001001
    val (N, A, B, C) = listOfInt()
    val L = (0 until N).map { nextInt() }.sortedDescending()
    fun min(vararg v: Int) = v.asList().min()!!
    fun dfs(cur: Int, a: Int, b: Int, c: Int): Int {
        if (cur == N) return if (min(a, b, c) > 0) Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30 else INF
        val r0 = dfs(cur + 1, a, b, c)
        val r1 = dfs(cur + 1, a + L[cur], b, c) + 10
        val r2 = dfs(cur + 1, a, b + L[cur], c) + 10
        val r3 = dfs(cur + 1, a, b, c + L[cur]) + 10
        return min(r0, r1, r2, r3)
    }
    println(dfs(0, 0, 0, 0))
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 42832
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,m=parseMap(split(readline()))
    s=chomp(readline())
    t=chomp(readline())
    l=BigInt(lcm(n,m))
    ans=l
    s_=[i*l÷n+1 for i in 0:n-1]
    t_=[i*l÷m+1 for i in 0:m-1]
    for i in 1:n
        num=searchsortedfirst(t_,s_[i])
        if num<=m && s_[i]==t_[num] && s[i]!=t[num]
            ans=-1
            break
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 174708
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;
struct color
{
    int x,y,no;
}s[100000];
int n,k,ans,sum;
int v[2000];
int main()
{
    char ch;
    scanf("%d%d",&n,&k);
    for(int i = 0;i < n;i ++)
    {
        scanf("%d %d %c",&s[i].x,&s[i].y,&ch);
        s[i].x %= k * 2;
        s[i].y %= k * 2;
        s[i].no = (ch == 'W' ? 1 : 0);
    }
    for(int i = 0;i < k;i ++)
    {
        sum = 0;
        memset(v,0,sizeof(v));
        for(int j = 0;j < n;j ++)
        {
            int p = s[j].x >= i && s[j].x < i + k;
            int q = s[j].y >= 0 && s[j].y < k;
            if(p ^ q ^ s[j].no)sum ++,v[s[j].y] ++;
            else v[s[j].y] --;
        }
        for(int j = 0;j <= k;j ++)
        {
            ans = max(ans,max(sum,n - sum));
            if(j != k)sum -= v[j] + v[j + k];
        }
    }
    printf("%d",ans);
}


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

using namespace std;
 
int main() {
    
    int n,d;
    cin >> n >> d;
    d = 2*d + 1;
    if(n%d == 0) cout << n/d << "\n";
    else cout << (n/d)+1 << "\n";
    
    return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	string s,t;
	std::cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if (s < t) {
		std::cout << "Yes" << '\n';
	}
	else {
		std::cout << "No" << '\n';
	}
	return 0;
}


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

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

    int h, w, K;
    cin >> h >> w >> K;
    vector<string> board(h);
    for (int i = 0; i < h; i++) cin >> board[i];
    int ans = 1e9;
    for (int i = 0; i < 1 << h - 1; i++) {
        int tmp = __builtin_popcount(i);
        vector<int> last;
        for (int j = 0; j < h - 1; j++) {
            if (i >> j & 1) {
                last.push_back(j);
            }
        }
        last.push_back(h - 1);
        vector<int> cur(last.size());
        int last_w = -1;
        bool impossible = false;
        for (int j = 0; j < w; j++) {
            bool ok = true;
            for (int k = 0; k < last.size(); k++) {
                for (int a = (k == 0 ? 0 : last[k - 1] + 1); a <= last[k]; a++) {
                    if (board[a][j] == '1') cur[k]++;
                }
                if (cur[k] > K) {
                    ok = false;
                    break;
                }
            }
            if (!ok) {
                j--;
                tmp++;
                cur.assign(last.size(), 0);
                if (j == last_w) {
                    impossible = true;
                    break;
                }
                last_w = j;
            }
        }
        if (!impossible) {
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def examC():
    N, A = LI()
    x = LI()
    maxNX = max(x)*N
    dp = [[[0]*(maxNX+1) for _ in range(N+1)]for _ in range(N+1)]
    dp[0][0][0] = 1
    for i in range(1,N+1):
        cur = x[i-1]
        for l in range(N+1):
            for j in range(maxNX + 1):
                dp[l][i][j] += dp[l][i - 1][j]
        for l in range(1,N + 1):
            for j in range(cur, maxNX + 1):
                dp[l][i][j] += dp[l-1][i - 1][j - cur]
#    print(dp)
    ans = int(0)
    for i in range(1,min(maxNX//A+1,N+1)):
        ans += dp[i][N][i*A]
    print(ans)


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Measured memory_bytes: 93916
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define inf 2147483647
#define eps 1e-9
#define mod 1000000007
using namespace std;
typedef long long ll;
ll n,pre=1,ans=0,f[1000001];
int main(){
	scanf("%lld",&n);
	f[0]=1;
	for(int i=1;i<=n;i++){
		if(i>=2)f[i]-=f[i-2];
		f[i]=(f[i]+pre+mod)%mod;
		pre=(pre+f[i])%mod;
	}
	for(int i=0;i<=n-2;i++){
		ans=(ans+f[i]*(n-1)%mod*(n-1)%mod+f[i]*(i+1)%mod)%mod;
	}
	ans=(ans+f[n-1]*(n-1)%mod+f[n])%mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 8064
import sys

def main():
    N = int(input())
    d = {}
    for _ in range(N):
        a = int(input())
        if a not in d:
            d[a] = 1
        else:
            if d[a] == 1:
                d[a] = 0
            else:
                d[a] = 1
    
    cnt = 0
    for v in d.values():
        if v == 1:
            cnt += 1
    print(cnt)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 15068
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// 連長圧縮（ランレングス圧縮）：sの連長部分を{文字,個数}の配列で返す。
vector<pair<char, long long>> RunLengthEncoding(string s){
    vector<pair<char, long long>> ret;
    long long i = 0, n = s.size();
    while(i<n){
        char tmp = s[i];
        long long cnt = 1;
        while(i<n){
            i++;
            if(tmp == s[i]) cnt++;
            else break;
        }
        ret.push_back(make_pair(tmp, cnt));
    }
    return ret;
}

int main(){
    Init();
    ll n, a, b, c, d; string s;
    cin >> n >> a >> b >> c >> d >> s;
    a--, b--, c--, d--;
    bool ans = true;

    // ゴールcがdより右にあるなら、すぬけはふぬけを飛び越す必要がある。
    // 飛び越すためには[b-1, d]に何もないマスが3マス以上連続した部分が必要
    if(c > d){
        auto rle = RunLengthEncoding(s.substr(b-1, d-(b-1)+2));
        bool over3 = false;
        for(auto &p: rle){
            if(p.first == '.' && p.second >= 3) over3 = true;
        }
        if(!over3){
            ans = false;
            goto LAST;
        }
        // a -> cに石が2箇所続く部分がなければOK
        auto AtoC = RunLengthEncoding(s.substr(a, c-a+1));
        for(auto &p: AtoC){
            if(p.first == '#' && p.second >= 2){
                ans = false;
                goto LAST;
            }
        }
    }
    // 飛び越す必要が無い場合はb -> dが到達可能か確認し、その後a -> bが到達可能ならOK
    else{
        auto BtoD = RunLengthEncoding(s.substr(b, d-b+1));
        for(auto &p: BtoD){
            if(p.first == '#' && p.second >= 2){
                ans = false;
                goto LAST;
            }
        }
        auto AtoB = RunLengthEncoding(s.substr(a, b-a+1));
        for(auto &p: AtoB){
            if(p.first == '#' && p.second >= 2){
                ans = false;
                goto LAST;
            }
        }
    }
LAST:
    ans ? Yes() : No();
}

Measured memory_bytes: 8568
n,m = map(int,input().split())
a=list(map(int,input().split()))
b=[list(map(int,input().split())) for _ in range(m)]
c=[]
for i in range(m):
  if a[int(b[i][0])-1]>a[int(b[i][1]-1)]:
       c.append(int(b[i][1]))
  if a[int(b[i][0])-1]<a[int(b[i][1]-1)]:
       c.append(int(b[i][0]))
  if a[int(b[i][0])-1]==a[int(b[i][1]-1)]:
       c.append(int(b[i][0]))
       c.append(int(b[i][1]))
d=set(c)
print(n-len(d))

Measured memory_bytes: 34568
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <class T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

bool isPrime(ll num) {
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) { return false; }
    }

    return true;
};

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int X;
    cin >> X;

    while (!isPrime(X)) { X++; }

    cout << X << endl;
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

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

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

bool visited[51][51];
int dis[51][51];
char x[51][51];

void bfs(int h , int w){
    memset(visited, false , sizeof(visited));
    memset(dis , -1 , sizeof(dis));
    if(x[0][0] == '.')
        visited[0][0] = true , dis[0][0] = 0;
    else return;

    queue<pair<int,int>> q;
    q.push({0, 0});
    while(!q.empty()){
        ii from = q.front();
        q.pop();
        int ii = from.first , jj = from.second;
        if(ii - 1 >= 0  && !visited[ii-1][jj] && x[ii-1][jj] == '.'){
            visited[ii-1][jj] = true;
            q.push({ii-1 , jj });
            dis[ii-1][jj] = dis[ii][jj] + 1;
        }
        if(ii + 1 <  h && !visited[ii+1][jj ] && x[ii+1][jj] == '.'){
            visited[ii+1][jj] = true;
            q.push({ii+1 , jj});
            dis[ii+1][jj] = dis[ii][jj] + 1;
        }
        if( jj +1 < w && !visited[ii][jj +1] && x[ii][jj+1] == '.'){
            visited[ii][jj+1] = true;
            q.push({ii , jj +1});
            dis[ii][jj + 1] = dis[ii][jj] + 1;
        }
        if(jj - 1 < w && !visited[ii][jj-1] && x[ii][jj-1] == '.'){
            visited[ii][jj-1] = true;
            q.push({ii , jj -1});
            dis[ii][jj -1] = dis[ii][jj] + 1;
        }
    }
}

void solve() {
    int h , w;
    cin>>h>>w;

    for (int i = 0; i < h; ++i) {
        cin>>x[i];
    }
    bfs(h ,w);
        if(visited[h-1][w-1]){
        int white = 0 , black = 0;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if(x[i][j] == '.') white++;
                else black++;
            }
        }
        cout<<white - (dis[h-1][w-1] + 1)<<endl;
    }else cout<<-1<<endl;

}

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

Measured memory_bytes: 256
/* Filename: ABC076C.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNext()){
			char[] SPrime = input.next().toCharArray();
			char[] T = input.next().toCharArray();
			
			boolean hasSol = false;
			for(int i = SPrime.length - T.length; i >= 0; --i){
				
				boolean isMatch = true;
				for(int j = 0; j < T.length; ++j){
					if(SPrime[i + j] != '?'){
						if(SPrime[i + j] != T[j]){
							isMatch = false;
							break;
						}
					}
				}
				
				if(isMatch){
					hasSol = true;
					
					for(int j = 0; j < T.length; ++j){
						SPrime[i + j] = T[j];
					}
					
					break;
				}
			}
			
			if(hasSol){
				for(int i = 0; i < SPrime.length; ++i){
					if(SPrime[i] == '?'){
						SPrime[i] = 'a';
					}
				}
				
				System.out.println(SPrime);
			} else {
				System.out.println("UNRESTORABLE");
			}
		}
	}

}


Measured memory_bytes: 20948
import math#mathモジュールをインポートする
a,b,c = map(int,input().split())#標準入力
i = (math.gcd(a,b))#最大公約数
a *= b#開拓した面積を求める
i *= i#正方形の面接を求める
print(int(a / i * c))#正方形のに開拓費用をかけた数を出力する


Measured memory_bytes: 5660
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, a, A = 0, B = 0;
  priority_queue<int> que;
  cin >> n;
  for(int i = 0;i < n;i++) {
    cin >> a;
    que.push(a);
  }
  while(que.empty() == false){
    A += que.top();
    que.pop();
    if(que.empty() == true) break;
    B += que.top();
    que.pop();
  }

  cout << A - B << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stdint.h>

std::vector<int64_t> fwd[100000];
std::vector<int64_t> rev[100000];

int64_t vis[100000];

int64_t cnt[4];
bool one;
int64_t edges=0;

void dfs(int64_t node,int64_t color){
  if(vis[node]==color) return;
  if(vis[node]!=0){one=true;return;}
  vis[node]=color;
  cnt[color%3]++;
  for(int64_t nxt:fwd[node]){
    dfs(nxt,color%3+1);
    edges++;
  }
  for(int64_t prv:rev[node]){
    dfs(prv,(color+1)%3+1);
    edges++;
  }
}

int main(){
  int64_t N,M;
  scanf("%ld %ld",&N,&M);
  for(int64_t i=0;i<M;i++){
    int64_t A,B;
    scanf("%ld %ld",&A,&B);
    A--,B--;
    fwd[A].push_back(B);
    rev[B].push_back(A);
  }
  int64_t total=0;
  for(int64_t i=0;i<N;i++){
    if(vis[i]) continue;
    std::fill(cnt,cnt+3,0);
    one=false;
    edges=0;
    dfs(i,1);
    if(one){
      int64_t here=cnt[0]+cnt[1]+cnt[2];
      total+=here*here;
    }else if(cnt[0]&&cnt[1]&&cnt[2]){
      for(int64_t i=0;i<3;i++){
	total+=cnt[i]*cnt[(i+1)%3];
      }
    }else{
      total+=edges/2;
    }
  }
  /*
  for(int64_t i=0;i<N;i++){
    printf("color[%ld]=%ld\n",i,vis[i]);
  }
  */
  printf("%ld\n",total);
  return 0;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);

int main(){
double a,b,c,d;
  cin>>a>>b>>c>>d;
  c=c*30+d/60*30;
  d*=6;
  c=abs(c-d);
  if(2*c>360)c=360-c;
  printf("%.20f\n",sqrt(a*a+b*b-2*a*b*cos(pi*c/180)));
  
  
  return 0;
}

Measured memory_bytes: 4224
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES//(M_PIに使える（π）)

#include<stdio.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
#include<numeric>
#include<random>
#include <functional>
using namespace std;

int main() {
	string S;
	string s2;
	cin >> S;
	//if (S.size()>4) {
		//for (int i = 4; i <S.size(); i++) {
			//cout <<i<< S << endl;
			//S.erase(S.begin() + 4);
//	}
//}
	for (int i = 0;i<4;i++) {
	s2.push_back(S[i]);
}
//	cout << s2 << endl;
	if (s2=="YAKI") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No"<< endl;
	}

	return 0;
}

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

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

Measured memory_bytes: 3604
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new aoj1155().doIt();
    }
    class aoj1155{
    	int d(int n,int m,int s,int g1,int g2){
    		int cost[][] = new int [n][n];
			for(int i = 0;i < n;i++){
				for(int j = 0;j < n;j++){
					if(i == j)continue;
					cost[i][j] = Integer.MAX_VALUE/4;
				}
			}
			for(int i = 0;i < m;i++){
				int st = sc.nextInt()-1;
				int et = sc.nextInt()-1;
				int co = sc.nextInt();
				cost[st][et] = co;
			}
			for(int i=0; i<n;i++){
				for(int j=0; j<n;j++){
					for(int k=0; k<n;k++){
						cost[j][k]=Math.min(cost[j][k], cost[j][i]+cost[i][k]);
					}
				}
			}
            int ans = Integer.MAX_VALUE/4;
//            for(int i = 0;i < n;i++){
//            	for(int j = 0;j < n;j++){
//            		System.out.print(cost[i][j]+" ");
//            	}
//            	System.out.println();
//            }
            for(int i=0; i<n;i++)ans=Math.min(ans,cost[s][i]+cost[i][g1]+cost[i][g2]);
			return ans;
		}
    	void doIt(){
    		while(true){
    			int n = sc.nextInt();
    			int m = sc.nextInt();
    			int s = sc.nextInt();
    			int g1 = sc.nextInt();
    			int g2 = sc.nextInt();
    			if(n+m+s+g1+g2 == 0)break;
    			System.out.println(d(n,m,s-1,g1-1,g2-1));
    		}
    	}
     }
}

Measured memory_bytes: 76316
import itertools


def main():
    count = 0
    MOD = 10**9+7
    n = int(input())
    a = list(map(int, input().split()))
    s = [0]
    for i in range(n-1):
        s.append((s[i]+a[i]) % MOD)
    for ai, si in zip(a, s):
        count += (ai*si) % MOD
    return count % MOD


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 107312
#!/usr/bin/perl
my ($n,$m) = map { $_ - 0 } split(/\s+/,<STDIN>);
my $lmax = -1;
my $rmin = $n+1;
for(my $i=0;$i<$m;$i++){
  my ($l,$r) = map { $_ - 0 } split(/\s+/,<STDIN>);
  $rmin = $r if $r < $rmin;
  $lmax = $l if $l > $lmax;
}
my $res = $rmin - $lmax + 1;
$res = 0 if $res < 0;
print "$res\n";


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

int main() {

	ll n, k; cin >> n >> k;
	vector<ll> num(k, 0);
	for (ll i = 1; i <= n; i++) {
		num[i % k]++;
	}
	ll ans = 0;
	for (ll a = 0; a < k; a++) {
		ll b = (k - a) % k;
		ll c = (k - a) % k;
		if ((b + c) % k != 0) continue;
		ans += num[a] * num[b] * num[c];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4700
line1 = input()
line2 = input()
n, k = line1.split(" ")
h = line2.split(" ")
h = [int(i) for i in h]
h.sort()
if int(k) >= int(n):
    print(0)
else:
    for i in range(int(k)):
        h.pop(-1)
    print(sum(h))

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int a, b; read(a, b); die(a * b);
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int N;cin>>N;
  vi A(N);rep(i,N)cin>>A[i];
  sort(all(A));
  int ans=0;
  for(int i=0;i<N;i++){
    int cnt=1;
    int j=i+1;
    while(A[i]==A[j]&&j<N){
      cnt++;
      j++;
    }
    if(cnt%2==1)ans++;
    i=j-1;
  }
  
  cout<<ans<<endl;

  
}







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

using namespace std;

#define MIN 0
int n;	
vector <long long int> H,A;
vector <long long int> tree;

void update(int node, int start, int end, int left, int right,long long int val)
{
	if(left > end || right < start)
	{
		return;
	}
	if (left <= start && end <= right)
	{
		tree[node] = max(tree[node],val);
		return;
	}	
	int mid = (start + end) / 2;
	update(node * 2, start, mid, left, right, val);
	update(node * 2 + 1, mid + 1, end, left, right, val);
	tree[node] = max(tree[node],max(tree[node * 2],tree[node * 2 + 1]));
}

long long int find(int node, int start, int end, int left, int right)
{
	if (left > end || right < start)
	{
		return MIN;
	}

	if (left <= start && end <= right)
	{
		return tree[node];
	}

	int mid = (start + end) / 2;
	return max(find(node * 2, start, mid, left, right), find(node * 2 + 1, mid + 1, end, left, right));
}


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

	cin >> n;
	int h = (int)ceil(log2(200010));
	int size = (1 << (h + 1)) - 1;
	tree.resize(size);
	
	for(int i=0;i<n;i++)
	{
		int t;
		cin >> t;
		H.push_back(t);
	}

	for(int i=0;i<n;i++)
	{
		int t;
		cin >> t;
		A.push_back(t);
	}

	for (int i = 0; i < n; i++)
	{
		long long int val = find(1,0,n,0,H[i]-1);
		val += A[i];
		update(1,0,n,H[i],H[i],val);
		//cout << minfind(1, 0, n, a, b) << ' ' << maxfind(1, 0, n - 1, a, b) << '\n';
	}

	cout << find(1,0,n,0,n) << '\n';

	return 0;
}

Measured memory_bytes: 12036
#include <stdio.h>
#include <math.h>

int main(void){
	double x1,x2,y1,y2,dist;

	scanf("%lf%lf%lf%lf", &x1,&y1,&x2,&y2);
	dist = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
	printf("%f\n", sqrt(dist));

	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
int n,m,ans=0;
vector <pair<int,int> > v;
int main() {
	cin>>n>>m;
	for (int i=0; i<m; i++) {
		int x,y;
		cin>>x>>y;
		if (x>y) swap (x,y);
		v.push_back(make_pair(x,y));
	}
	sort (v.begin(),v.end());
	int t=v[0].first;
	int p=v[0].second;
	for(int i=1; i<m; i++) {
		if(t!=v[i].first) t=v[i].first;
		if(p>v[i].second) p=v[i].second;
		if(t>=p) {
			ans++;
			t=v[i].first;
			p=v[i].second;
		}
	}
	cout<<ans+1;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int h, w; cin >> h >> w;
    vector<string> field(h);
    for(auto& e : field) cin >> e;

    vector<string> A, B;
    A = B = field;

    rep(x, w){
        A[0][x] = '#';
        B[h-1][x] = '#';

        rep(y, 1, h - 1){
            if(x % 2 == 0) A[y][x] = '#';
            else B[y][x] = '#';
        }
    }

    for(auto& e : A){
        cout << e << endl;
    }
    cout << endl;
    for(auto& e : B){
        cout << e << endl;
    }

    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,l;
    cin >> n >> l;
    vector <string> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    for (int i=0;i<n;i++){
        cout << s[i];
    }

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    while (true)
    {
        int h, w;
        std::cin >> h >> w;
        
        if (h == 0 && w == 0)
            break;
        else
        {
            for (int hh = 0; hh < h; ++hh)
            {
                for (int ww = 0; ww < w; ++ww)
                    std::cout << ((hh == 0 || ww == 0 || hh == h - 1 || ww == w - 1) ? '#' : '.');
            
                std::cout << std::endl;
            }
            
            std::cout << std::endl;
        }
    }
    
    return 0;
}


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

// definitions
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define pb push_back
#define mod1 998244353
#define mod 1000000007
#define MAX_CHAR 256

using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dq;
typedef long long int lli;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;


// standard functions
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 
 


ll modexp(ll x, ll ex, ll modp) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x)%modp;
        ex >>= 1ll;
        x = (x * x)%modp;
    }
    return ans;
} 
 
ll nCrModp(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}
 
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true;  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
vl countFreq(ll arr[], ll n) 
{ 
    unordered_map<ll, ll> mp; 
    vector <ll> v;
    
    for (ll i = 0; i < n; i++) 
        mp[arr[i]]++; 
   
    for (auto x : mp) 
        v.pb(x.second);
    
    return v;
}

ll binarySearch(ll arr[], ll l, ll r, ll x) 
{ 
    while (l <= r) 
    { 
        ll m = l + (r - l) / 2; 
        if (arr[m] == x) 
            return m; 
        if (arr[m] < x) 
            l = m + 1; 
        else
            r = m - 1; 
    }
    return -1; 
}

const ll MAXSIEVE=(1e3);
ll spf[MAXSIEVE];
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXSIEVE; i++) 
        spf[i] = i; 

    for (ll i=4; i<MAXSIEVE; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXSIEVE; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXSIEVE; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

// code beigns in main
int main()
{
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
        ld r;
        cin >> r;

        ld area=M_PI*r*2;
        cout << area << endl;
    }
}



Measured memory_bytes: 3836
A,B = map(int, input().split())

G = [["#" if j <=49 else "." for i in range(100)] for j in range(100)]


x = y = 0
for i in range(A-1):
    G[y][x] = "."
    x += 2
    if x >= 100:
        x -= 100
        y += 2

x = 0
y = 51
for i in range(B-1):
    G[y][x] = "#"
    x += 2
    if x >= 100:
        x -= 100
        y += 2
        
print(100, 100)
for s in G:
    print("".join(s))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

// #define int ll

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

#define fst first
#define snd second
#define pb push_back

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    int H, W, N;

    cin >> H >> W;
    cin >> N;

    vector<int> As(N);
    REP(i, N) {
        cin >> As.at(i);
    }

    // 各indexの色
    vector<int> index_to_color(H*W);
    int i = 0;
    int ind = 0;
    REP(color_name, N) {
        int a = As.at(color_name);
        FORE(k, ind, ind + a - 1) {
            index_to_color.at(k) = color_name;
        }

        ind += a;
    }

    // for(auto c : index_to_color) {
    //     debug(c);
    // }

    // コの字型に書いていけばいけるのでは?
    vector<vector<int>> colors(H, vector<int>(W));
    int index = 0;
    REP(h, H) {
        REP(tmp_w, W) {
            int w;
            if (h % 2 == 0) {
                // 順
                w = tmp_w;
            } else {
                // 逆
                w = (W - 1) - tmp_w;
            }

            // cerr << "(" << h << "," << w <<  ")"  << endl;

            colors.at(h).at(w) = index_to_color.at(index);
            index += 1;
        }
    }

    REP(h, H) {
        REP(w, W) {
            if (w == W - 1) {
                cout << colors.at(h).at(w) + 1 << endl;;
            } else {
                cout << colors.at(h).at(w) + 1 << " ";
            }
        }
    }
}


Measured memory_bytes: 384
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
costRight, costLeft = 0, 0
for i in range(X, N):
    if i in A:
        costRight +=1
for i in range(X, 0, -1):
    if i in A:
        costLeft += 1
print(min(costRight, costLeft))

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<set<int>> st(26);
  int Q;
  cin >> Q;
  for (int i = 0; i < 26; i++) st[i].insert(INF);
  for (int i = 0; i < n; i++) st[s[i] - 'a'].insert(i);

  while (Q--) {
    int d, l, r;
    char c;
    cin >> d;
    if (d == 1) {
      cin >> l >> c;
      l--;
      st[s[l] - 'a'].erase(l);
      st[c - 'a'].insert(l);
      s[l] = c;
    } else {
      cin >> l >> r;
      l--;
      int res = 0;
      for (int i = 0; i < 26; i++) {
        auto itr = st[i].lower_bound(l);
        if (*itr < r) res++;
      }
      cout << res << endl;
    }

  }
  return 0;
} 

Measured memory_bytes: 24324
A,Y,n,t,f,a,s,y;double r;main(M){for(;~scanf("%*d%d%d%d"+!M*3,&A,&Y,&n);M=!printf("%d\n",M))for(;n--;a+s>M?M=a+s:0)for(s=!scanf("%d%lf%d",&t,&r,&f),a=A,y=Y;y--;a-=f)s+=(t?a+s:a)*r;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

const int MAX_S = 1000000;

int main() {
    int D; cin >> D;
    vector<ll> cvec(26, 0);
    for(int i = 0; i < 26; ++i) cin >> cvec.at(i);
    vector< vector<ll> > smap(D, vector<ll>(26, 0));
    for(int i = 0; i < D; ++i) {
        for(int j = 0; j < 26; ++j) {
            cin >> smap.at(i).at(j);
        }
    }

    vector<ll> vvec(D, 0);
    vector<int> lastvec(26, 0);
    ll sum = 0;
    for(int i = 0; i < D; ++i) {
        int t; cin >> t; t--;
        // その日のコンテストの満足度
        sum += smap.at(i).at(t);
        // コンテストが行われた記録
        lastvec.at(t) = (i+1);
        // 行われなかったコンテストの不満
        for(int j = 0; j < 26; ++j) {
            sum -= (cvec.at(j)*((i+1) - lastvec.at(j)));
        }
        vvec.at(i) = sum;
    }

    for(int i = 0; i < D; ++i) {
        cout << vvec.at(i) << endl;
    }
}

Measured memory_bytes: 3692
import math

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

pi = math.pi


c = 2 * x / a **2 - b
if c >= 0:
    th = math.asin(a / (math.sqrt(a**2 +(b - (2 * x / a **2 - b))**2)))


else:

    th = math.acos(b/(math.sqrt((2*x / (b*a))**2+b**2)))

deg = math.degrees(th)
print(90-deg)


Measured memory_bytes: 3060
//https://atcoder.jp/contests/abc119/tasks/abc119_c
//2019-02-24
#include <bits/stdc++.h>
using namespace std;
int N, A, B, C;
vector<int> l(8);
int DFS(int i, int a, int b, int c){
    if(i == N){
        if(a*b*c > 0){
            return abs(a-A) +abs(b-B) + abs(c-C);
        }
        return 10000000;
    }
    int ret = DFS(i + 1 ,a , b, c);
    ret = min(ret, DFS(i + 1, a + l.at(i) , b, c) + 10);
    ret = min(ret, DFS(i + 1, a , b + l.at(i), c) + 10);
    ret = min(ret, DFS(i + 1, a , b, c + l.at(i)) + 10);
    return ret;
}
int main(){
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++) {
        cin >> l.at(i);
    }
    cout << DFS(0, 0, 0, 0) - 30 << endl;
}


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

def checkstr(ss):
  for (s, t) in zip(ss, T):
    check = True
    if s is '?':
      continue
    if s is not t:
      check = False
      break
  return check

tmp=''
ans='z'*50

for i in range(len(S)-len(T)+1):
  str = S[i:len(T)+i] 
  if checkstr(str):
    tmp = S[:i].replace("?","a")+T+S[i+len(T):].replace("?","a")
    ans = min(tmp, ans)
if tmp is '':
  ans = "UNRESTORABLE"
print(ans)

Measured memory_bytes: 3064
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  real xs, ys, xt, yt; readV(xs, ys, xt, yt);
  int n; readV(n);
  real[] x, y, r; readC(n, x, y, r);

  auto g = GraphW!(int, real, 1.0e+18L)(n+2);

  foreach (i; 0..n)
    foreach (j; i+1..n)
      g.addEdgeB(i, j, max(0, sqrt((x[i]-x[j])^^2+(y[i]-y[j])^^2)-(r[i]+r[j])));

  foreach (i; 0..n) {
    g.addEdgeB(n, i, max(0, sqrt((xs-x[i])^^2+(ys-y[i])^^2)-r[i]));
    g.addEdgeB(n+1, i, max(0, sqrt((xt-x[i])^^2+(yt-y[i])^^2)-r[i]));
  }
  g.addEdgeB(n, n+1, sqrt((xs-xt)^^2+(ys-yt)^^2));

  auto d = g.dijkstra(n);
  writefln("%.10f", d[n+1]);
}

struct GraphW(N = int, W = int, W i = 10^^9)
{
  alias Node = N, Wt = W, inf = i;
  struct Edge { Node src, dst; Wt wt; alias cap = wt; }
  Node n;
  Edge[][] g;
  alias g this;
  this(Node n) { this.n = n; g = new Edge[][](n); }
  void addEdge(Node u, Node v, Wt w) { g[u] ~= Edge(u, v, w); }
  void addEdgeB(Node u, Node v, Wt w) { g[u] ~= Edge(u, v, w); g[v] ~= Edge(v, u, w); }
}

template Dijkstra(Graph)
{
  import std.array, std.container, std.traits;
  alias Node = TemplateArgsOf!Graph[0], Wt = TemplateArgsOf!Graph[1];
  alias Edge = Graph.Edge;

  void dijkstra(ref Graph g, Node s, out Wt[] dist, out Node[] prev)
  {
    auto n = g.n, sent = n;

    dist = new Wt[](n);
    dist[] = g.inf;
    dist[s] = 0;

    prev = new Node[](n);
    prev[] = sent;

    auto q = heapify!("a.wt > b.wt")(Array!Edge(Edge(sent, s, 0)));
    while (!q.empty) {
      auto e = q.front; q.removeFront();
      if (prev[e.dst] != sent) continue;
      prev[e.dst] = e.src;
      foreach (f; g[e.dst]) {
        auto w = e.wt + f.wt;
        if (dist[f.dst] > w) {
          dist[f.dst] = w;
          q.insert(Edge(f.src, f.dst, w));
        }
      }
    }
  }

  auto dijkstra(ref Graph g, Node s)
  {
    Wt[] dist;
    Node[] prev;
    dijkstra(g, s, dist, prev);
    return dist;
  }
}
auto dijkstra(G, N)(G g, N s) { return Dijkstra!G.dijkstra(g, s); }


Measured memory_bytes: 81876
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<hash_map>
#include<bitset>

using namespace std;

vector<string>card(3);
vector<int>turn(3);

int main(){	
	cin>>card[0]>>card[1]>>card[2];
	int turns=0;
	turn[0]=turn[1]=turn[2]=0;
	int win;
	while(1){
		if(turn[turns]==card[turns].size()){
			win=turns;
			break;
		}
		else{
			turns=card[turns][turn[turns]++]-'a';
		}
	}
	cout<<(char)('A'+win)<<endl;
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;

int N, M, X, Y;
int x[105] = {};
int y[105] = {};



int main(){
	cin >> N >> M >> X >>Y;
	rep(i, N) cin >> x[i];
	rep(i, M) cin >> y[i];

	sort(x, x+N, greater<int>());
	sort(y, y + M);
	
	bool ok = 0;
	for (int i = X + 1; i < Y + 1; i++) {
		if (x[0]<i && y[0] + 1>i) {
			ok = 1;
			break;
		}
	
	}

	if (ok) cout << "No War\n";
	else	cout << "War" <<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

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

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

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/   

int main()
{
    int M, N, K, L;
    int A[200000];
    lli count = 0;
    lli temp, temp2;
    lli ans = 0;
    lli max = 0;
  
    temp = 0;

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

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

    for (int i = 0; i < N - 1; i++)
    {
        if (A[i + 1] - A[i] >max)
            max = A[i + 1] - A[i];
    }


    if (A[0] + (K - A[N - 1]) > max)
        max = A[0] + (K - A[N - 1]);


    for(int i = 1; i < N; i++)
        ans += A[i] - A[i - 1];

    ans += A[0];
    ans += K - A[N - 1];


  //  printf("%lld %lld", ans, temp);

    printf("%lld", K-max);
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

const int MAX = 10;
bool m[MAX][MAX],tmp[MAX][MAX];
bool ans[MAX][MAX];
int num;
int dx[] = {-1,0,0,0,1};
int dy[] = {0,-1,0,1,0};

void input(){
  num = 0;

  for(int i = 0; i < MAX; i++)
    for(int j = 0; j < MAX; j++){
      cin >> m[i][j];
      if(m[i][j]) num++;
    }
}

bool isInside(int y, int x){
  return 0<=y&&y<MAX&&0<=x&&x<MAX;
}

void rev(int y, int x, int& now){
  for(int i = 0; i < 5; i++){
    int nx = x+dx[i];
    int ny = y+dy[i];

    if(isInside(ny,nx)){
      tmp[ny][nx] = !tmp[ny][nx];
      if(tmp[ny][nx]) now++;
      else now--;
    }
  }
}

void print(){
  for(int i = 0; i < MAX; i++){
    for(int j = 0; j < MAX; j++){
      if(j) cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }
}

void solve(){

  for(int i = 0; i < (1<<MAX); i++){
    memset(ans,false,sizeof(ans));
    memcpy(tmp,m,sizeof(m));

    int now = num;

    for(int j = 0; j < MAX; j++){
      if(i&(1<<j)){
	ans[0][j] = true;
	rev(0,j,now);
      }
    }

    for(int j = 1; j < MAX; j++)
      for(int k = 0; k < MAX; k++){
	if(tmp[j-1][k]){
	  ans[j][k] = true;
	  rev(j,k,now);
	}
      }

    if(now == 0){
      print();
      break;
    }
  }
}

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

  while(n--){
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1160