akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e6 + 10;
char s[N];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  int ret = INF;
  for (int k = 0; k < 2; ++k) {
    int cur = 0;
    for (int i = 0; i < n; ++i) {
      cur += (s[i] - '0' != (i + k) % 2);
    }
    ret = min(ret, cur);
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 384
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word
// also tink all answers possible for a question
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define sz 100005
ll inf = 1e9;
ll power(ll x, ll n, ll mod)
{
  ll res = 1;
  x %= mod;
  while (n)
  {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res%mod;
}
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  string str;
  cin>>str;
  ll n=str.length();
  ll s=0;
  for(ll i=0;i<n;i++)
  {
    s=s+(str[i]-'0');
  }
  if(s%9==0)
  {
    cout<<"Yes\n";
  }
  else
  {
    cout<<"No\n";
  }
  return 0;
}

Measured memory_bytes: 3780
x = input()

sum = 0

for i in range(len(x)):
  #print(x[i])
  #自分より上
  sum += 2**i * int(x[i])*(10**(len(x) - i - 1))
  #print(sum)
  #自分より下
  #print("u")
  d = len(x) - i - 1#自分より下にある数字の数
  for j in range(1,d+1):
    sum += 2**i * 2**(j-1) * int(x[i]) * 10 ** (d-j)
    #print(sum)
print(sum)

Measured memory_bytes: 3060
import java.util.*;

/**
 * @author masayamatu
 * 
 */
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double[] A= new double[n];
    for(int i = 0; i < n; i++) {
     A[i] = sc.nextDouble();
    }
    Arrays.sort(A);
    for(int i = 0 ; i < n-1; i++ ) {
      A[i+1] = (double)(A[i+1]+A[i])/2;
    }
    System.out.println(A[n-1]);
  }  
}

Measured memory_bytes: 23252
import java.util.Scanner;

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

		for(int i = 1; i <= B; i++) {
			if(A * i % B == C) {
				flag = 1;
				break;
			}
		}

		if(flag == 1) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 25044
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
int main()
{
	ios;
	int n,m;
	cin>>n>>m;
	n*=500;
	if(n>=m)cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 3616
# -*- coding: utf-8 -*-

tmp = input()
a = int(tmp.split(" ")[0])
b = int(tmp.split(" ")[1])
k = int(tmp.split(" ")[2])

x = int(min(a,b))
i= int(0)

while i < k:
    if a%x ==0:
        if b%x==0:
            i = i+1
            x = x-1
        else:
            x = x-1
    else:
        x = x-1
x=x+1
print(x)

Measured memory_bytes: 3064
X = int(input())

x = X % 100
n = X // 100

if n > 0:
    while x >= 5 and n != 0:
        x = x - 5
        n = n - 1

    while x >= 4 and n != 0:
        x = x - 4
        n = n - 1

    while x >= 3 and n != 0:
        x = x - 3
        n = n - 1

    while x >= 2 and n != 0:
        x = x - 2
        n = n - 1

    while x >= 1 and n != 0:
        x = x - 1
        n = n - 1

    while x == 0 and n != 0:
        n = n - 1
    
    if n == 0 and x == 0:
        print("1")
    else:
        print("0")


else:
    print("0")

Measured memory_bytes: 3064
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn main() {
    let in_vec: Vec<usize> = read_line();
    let n = in_vec[0];
    let k = in_vec[1];

    let mut res_vec: Vec<usize> = vec![0; n];

    for _i in 0..k {
        let _d: usize = read_line()[0];
        let a: Vec<usize> = read_line();
        for a_i in a {
            res_vec[a_i - 1] += 1;
        }
    }

    let mut res = 0;
    for res_i in res_vec {
        if res_i == 0 {
            res += 1;
        }
    }

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


Measured memory_bytes: 2140
from collections import defaultdict

N = int(input())
dic = defaultdict(int)

for i in range(N):
    dic[input()] += 1


dic = sorted(dic.items(), key=lambda x:x[1], reverse=True)

ans = [dic[0][0]]

for i in range(1,len(dic)):
    if dic[i][1] == dic[0][1]:
        ans.append(dic[i][0])
    else:
        break

for i in sorted(ans):
    print(i)

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

int n, mx;
string s;
map<string, int> mp;
int main() {
	cin >> n;
	while(n--) {
		cin >> s;
		mp[s]++;
		mx = max(mx, mp[s]);
	}
	for(auto x:mp) {
		if(x.second==mx) cout << x.first << '\n';
	}
	return 0;

}


Measured memory_bytes: 25216
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        for (int i = 0 ; i < s.length() ; i++) {
            String a = s.substring(0, 1);
            String b = s.substring(1, s.length());
            s = b + a;
            if (s.equals(t)) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }

}

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

ll solve() {
    ll N, amax = 0;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        amax = max(amax, A[i]);
    }
    sort(A.begin(), A.end());
    vector<bool> num(amax+1, false);
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( num[A[i]] == false ) {
            if ( i == N-1 || A[i] != A[i+1] ) ans++;
            for ( int k = 1; k*A[i] <= amax; k++ ) {
                num[k*A[i]] = true;
            }
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5008
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    ret = 0
    for n in range(1, N+1):
        t = 1
        while n * t < K:
            t *= 2
        ret += 1 / t

    print(ret / N)


if __name__ == '__main__':
    main()


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

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

int main(void) {
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a < b || d < b || a%b>c){
      cout << "No" << endl;
      continue;
    }

    if (d%b == 0) {
      cout << "Yes" << endl;
      continue;
    }

    ll mx = b-(b-a%b)%gcd(b, d%b);
    if (mx == b) mx-=gcd(b, d%b);
    if(mx<=c) {
      cout << "Yes" << endl;
    } else{
      cout << "No" << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
def get(i):
    mx = 0
    while i > 0:
        if bit[i] > mx:
            mx = bit[i]
        i -= i & -i
    return mx


def update(i, x):
    while i < n + 1:
        if x > bit[i]:
            bit[i] = x
        i += i & -i


def f(hs, a_s):
    for h, a in zip(hs, a_s):
        update(h, get(h - 1) + a)
    print(max(bit))


n = int(input())
hs = list(map(int, input().split()))
a_s = list(map(int, input().split()))
bit = [0] * (n + 1)
f(hs, a_s)


Measured memory_bytes: 121168
#include<algorithm>
#include<iostream>
#include<vector>
#include<numeric>
#include<string>
#include<stdio.h>
#include<string.h>
#include<ctype.h>

std::vector<int> v;
std::string s;
std::string::iterator it;
char ope[4] = { '+', '-', '*' };

int term();
int num();

int Expr()
{	
	int p = term();
	
	while( *it == '+' || *it == '-' ){
		if( *it == '+' ){
		 	it++;
			int q = term();
			p += q;
		}
		else{
			it++;
			int q = term();
			p -= q;
		}
	}
	
	return p;
}

int term()
{
	int p = num();
	
	while( *it == '*' || *it == '/' ){
	 	if( *it == '*' ){
		 	it++;
			int q = num();
			p *= q;
		}
		else{
			it++;
			int q = num();
			p /= q;
			if( p % q ) p++;
		}
	}
	
	return p;
}

int num()
{
 	if( *it == '(' ){
		it++;
		int p = Expr();
		it++;
		return p;
	}
	else{
		int p = 0;
	 	while( isdigit( *it ) ){
			p *= 10;
			p += *it - '0';
			it++;
		}
		
		return p;
	}
}

bool f()
{
	s.clear();
	
	char expr[256];
	
	for( int i = 0; i < 3; i++ ){
		for( int j = 0; j < 3; j++ ){
			for( int k = 0; k < 3; k++ ){
				// type 1
				sprintf( expr, "((%d%c%d)%c%d)%c%d", v[0], ope[i], v[1], ope[j], v[2], ope[k], v[3] );
				s = expr;
				it = s.begin();
				if( Expr() == 10 ) return true;
				// type 2
				sprintf( expr, "(%d%c(%d%c%d))%c%d", v[0], ope[i], v[1], ope[j], v[2], ope[k], v[3] );
				s = expr;
				it = s.begin();
				if( Expr() == 10 ) return true;
				// type 3
				sprintf( expr, "%d%c((%d%c%d)%c%d)", v[0], ope[i], v[1], ope[j], v[2], ope[k], v[3] );
				s = expr;
				it = s.begin();
				if( Expr() == 10 ) return true;
				// type 4
				sprintf( expr, "%d%c(%d%c(%d%c%d))", v[0], ope[i], v[1], ope[j], v[2], ope[k], v[3] );
				s = expr;
				it = s.begin();
				if( Expr() == 10 ) return true;
				// type 5
				sprintf( expr, "((%d%c%d)%c(%d%c%d))", v[0], ope[i], v[1], ope[j], v[2], ope[k], v[3] );
				s = expr;
				it = s.begin();
				if( Expr() == 10 ) return true;
			}
		}
	}
	
	return false;
}

int main()
{
	while( 1 ){
		v.clear();
		int a, b, c, d;
	 	std::cin >> a >> b >> c >> d;
		if( !a && !b && !c && !d ) break;
		
		v.push_back( a );
		v.push_back( b );
		v.push_back( c );
		v.push_back( d );
		
		std::sort( v.begin(), v.end(), std::greater<int>() );
		
		bool suc = false;
		do{
			if( f() ){
				std::cout << s << std::endl;
				suc = true;
				break;
			}
		}while( std::prev_permutation( v.begin(), v.end() ) );
		
		if( !suc ){
			std::cout << 0 << std::endl;
		}
	}
	std::cout << Expr();

 	return 0;
}

Measured memory_bytes: 1252
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()
    a,b,n=parseMap(split(readline()))
    tmp=fld(n,b)*b-1
    println(max(big(a*tmp÷b)-big(a*(tmp÷b)),big(a*n÷b)-big(a*(n÷b))))
end
main()

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

int main()
{
	int r, c;
	cin >> r >> c;

	int table[r+1][c+1];
	int i, j;
	for (i = 0; i < r; i++)
		for (j = 0; j < c; j++)
			cin >> table[i][j];


	int sum;
	int all_sum = 0;
	for (i = 0; i < r; i++) {
		sum = 0;
		for (j = 0; j < c; j++) {
			sum += table[i][j];
		}
		table[i][c] = sum;
	}

	for (j = 0; j < c; j++) {
		sum = 0;
		for (i = 0; i < r; i++) {
			sum += table[i][j];
		}
		table[r][j] = sum;
		all_sum += sum;
	}

	table[r][c] = all_sum;

	for (i = 0; i < r+1; i++) {
		for (j = 0; j < c+1; j++) {
			cout << table[i][j];
			if (j != c) cout << " ";
		}
		cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 1196
A = int(input())
B = int(input())
C = int(input())
X = int(input())
res = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            total = 500*a + 100*b + 50*c
            if total == X:
                res += 1
print(res)

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			var n = 0;
			while((n = int.Parse(Console.ReadLine())) != 0)
			{
				var dic = new Dictionary<char, char>();
				foreach(var i in Enumerable.Range(1, n))
				{
					var a = Console.ReadLine().Split(' ').Select(char.Parse).ToArray();
					dic.Add(a[0], a[1]);
				}
				n = int.Parse(Console.ReadLine());
				var arr = new char[n];
				foreach(var i in Enumerable.Range(0, n))
				{
					var c = char.Parse(Console.ReadLine());
					if(dic.ContainsKey(c))
					{
						arr[i] = dic[c];
					}
					else
					{
						arr[i] = c;
					}
				}
				Console.WriteLine(new string(arr));
			}
		}
	}
}

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

#define debug(x) cout << #x << ": " << (x) << endl

typedef vector<pair<int, vector<int> > > Graph;

const int INF = INT_MAX;

bool dfs(Graph &G, int par, int v, int upper, int lower,
         pair<int, int> range[]) {
  int P = G[v].first;

  if (P != INF) {
    if (((upper & 1) == (P & 1)) and lower <= P and P <= upper)
      upper = lower = P;
    else
      return false;
  }

  for (auto u: G[v].second) {
    if (u == par) continue;
    if (not dfs(G, v, u, upper + 1, lower - 1, range))
      return false;
    upper = min(upper, range[u].first + 1);
    lower = max(lower, range[u].second - 1);
  }

  range[v] = make_pair(upper, lower);
  return true;
}

void mark(Graph *G, int root, pair<int, int> range[]) {
  stack<pair<int, int> > s;
  s.push(make_pair(root, root));

  while (not s.empty()) {
    auto pv = s.top(); s.pop();

    int par = pv.first;
    int v = pv.second;
    int P = G->at(par).first;
    if (G->at(v).first == INF)
      G->at(v).first = P + 1 <= range[v].first ? P + 1 : P - 1;

    for (auto u: G->at(v).second) {
      if (u == par) continue;
      s.push(make_pair(v, u));
    }
  }
}

int main(int argc, char *argv[]) {
  int N, K;
  cin >> N;

  int A[N], B[N];
  for (int i = 0; i < N - 1; ++i) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }

  cin >> K;
  int V[K], P[K];
  for (int i = 0; i < K; ++i) {
    cin >> V[i] >> P[i];
    V[i]--;
  }

  Graph G(N);
  for (int i = 0; i < N - 1; ++i) {
    G[A[i]].second.push_back(B[i]);
    G[B[i]].second.push_back(A[i]);
    G[A[i]].first = INF;
    G[B[i]].first = INF;
  }

  for (int i = 0; i < K; ++i) {
    G[V[i]].first = P[i];
  }

  pair<int, int> range[N];
  bool is_possible = dfs(G, -1, V[0], P[0], P[0], range);

  if (is_possible) {
    mark(&G, V[0], range);
    cout << "Yes" << endl;
    for (int i = 0; i < N; ++i) {
      cout << G[i].first << endl;
    }
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 18304
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

class Pascal {
  public:
    vv(ll) t;
    Pascal(int N) {
      t = vv(ll)(N+1,vl(N+1,0));
      rep(i,N+1) {
        rep(j,i+1) {
          if(j==0 || j==i) {
            t[i][j] = 1ll;
          } else {
            t[i][j] = t[i-1][j-1]+t[i-1][j];
          }
        }
      }
    }
    ll getCombi(int n,int k) {
      return t[n][k];
    }
};
  
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  vl va(N);
  rep(i,N) {
    cin >> va[i];
  }
  sort(rng(va));
  reverse(rng(va));
  Pascal C(N);
  ll tar = va[A-1];
  int c1=0;
  rep(i,A) {
    if(va[i] == tar) c1++;
  }
  int c2 = 0;
  rep(i,N) {
    if(va[i] == tar) c2++;
  }
  if(c1==A) {
    ll ans = 0;
    srep(k,A,min(B,c2)+1) {
      ans += C.getCombi(c2,k);
    }
    double ave = va[A-1];
    cout << setprecision(16) << ave << endl;
    cout << ans << endl;
  } else {
    ll  ans = C.getCombi(c2,c1);
    double ave = 0;
    rep(i,A) {
      ave += 1.0 * va[i] / A;
    }
    cout << setprecision(16) << ave << endl;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <bitset>
#include <cmath>
#include <tuple>
#pragma endregion
using namespace std;

#pragma region 定数
#define INF_VAL (2147483647 - 1)
#define INF_VAL_MINUS -INFVAL
#pragma endregion

#pragma region マクロ
// 型
#define ll long long

// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// for文
#define forn(i, size) for (long long(i) = 0; (i) < (size); (i)++)
#define for0(size) for (long(i) = 0; (i) < (size); (i)++)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length, type_name) sort(array, array + length, std::greater<type_name>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)

// 結果出力系
#define YES                    \
    {                          \
        cout << "YES" << endl; \
        return 0;              \
    }
#define NO                    \
    {                         \
        cout << "NO" << endl; \
        return 0;             \
    }
#define Yes                    \
    {                          \
        cout << "Yes" << endl; \
        return 0;              \
    }
#define No                    \
    {                         \
        cout << "No" << endl; \
        return 0;             \
    }
#define println(str) cout << str << endl;

#pragma endregion

#pragma region Utility
#pragma region 最大公約数
ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}
#pragma endregion

#pragma region 最小公倍数
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
#pragma endregion

#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion

#pragma region 連想配列のkeyが存在するか
template <typename T>
bool containsKey(map<string, T> map, string key)
{
    if (map.count(key) == 0)
    {
        return false;
    }
    return true;
}
#pragma endregion
#pragma endregion

int main()
{
    // 標準入力から値を取得
    int N, M;
    cin >> N >> M;

    if (N == M)
    {
        Yes
    }
    No
}


Measured memory_bytes: 256
i;float x,z[];float o(float*a,float*b,float*c){return a[1]*(*c-*b)+c[1]*(*b-*a)+b[1]*(*a-*c);}main(){for(;~scanf("%f,",z+i++%8);)i%8||puts(x*o(z+2,z+4,z+6)>0&x*o(z+4,z+6,z)>0&x*o(z+6,z,z+2)>0?"YES":"NO",x=o(z,z+2,z+4));}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  vector<int> price(5);
  for(int i = 0; i < 5; i++){
    cin >> price.at(i);
  }
  vector<int> muda(5);
  for(int i = 0; i < 5; i++){
    if(price.at(i) % 10 == 0) muda.at(i) = 0;
    else muda.at(i) = 10 - price.at(i) % 10;
  }
  sort(ALL(muda));
  int result = 0;
  for(int i = 0; i < 5; i++){
    result += price.at(i) + muda.at(i);
  }
  result -= muda.at(4);
  cout << result << endl;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬╬╬██╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓▓█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#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(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) (a)<=(i) && (i)<(b)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef pair<int,int> P;
typedef vector<vector<P>> Graph;

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

  string s;
  cin >> s;

  int n = s.size();
  int ans1 = 0;
  int cnt = 0;
  REP(i,n){
    if(s[i] == 'B') cnt++;
    else ans1 += cnt;
  }


  cout << ans1 << endl;
  return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int cnt = 0, ans = 0;
    for(int i = 1; i <=  N; i++){
        if(i % 2 == 0) continue;
        else{
            for(int j = 1; j <= N; j++){
                if(i % j == 0){
                    cnt++;
                }
            }
            if(cnt == 8){
                ans++;
            }
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int w,h;
int c[55][55];

void dfs(int x,int y) {
    for(int dx = -1;dx<=1;dx++) {
        for(int dy = -1;dy<=1;dy++) {
            int nx = x + dx;
            int ny = y + dy;
            if(nx<0 || nx>=h || ny<0 || ny>=w) continue;
            if(c[nx][ny] == 0) continue;
            if(c[nx][ny] == 1) c[nx][ny] = 0;
            dfs(nx,ny);
        }
    }
}

int main() {
    while(true) {
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        rep(i,h) rep(j,w) {
            cin >> c[i][j];
        }
        int ans = 0;
        rep(i,h) rep(j,w) {
            if(c[i][j] == 1) {
                ans++;
                dfs(i,j);
            }
        }
        cout << ans << endl;
    }    
}


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

int main() {
    int n,k;cin>>n>>k;
    int a[n];rep(i,n)cin>>a[i];
    sort(a,a+n);
    int ans = 0;
    rep(i,k)ans+=a[i];
    cout<<ans<<endl;
	return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int64_t> vec(N);
    for (int i = 0; i < N; i++) cin >> vec.at(i);
    int count = 0, ans = 0;
    for(int i = 0; i < N-1; i++){
        if(vec.at(i+1) <= vec.at(i)){
            count++;
            if(i == N-2){
                ans = max(ans,count);
            }
        }else{
            ans = max(ans,count);
            count = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
function main () { 
  var x = input[0];
  console.log(x * x * x);
}


var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 7648
#include <iostream>

using namespace std;

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; i++)
    {
        int e;
        scanf("%d", &e);
        n -= e;
    }
    printf("%d", max(-1, n));
    return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

void print(vector<int> &v, int N) {
	cout << N << endl;
	for(int i = 0; i < N; ++i) {
		cout << v[i] << (i == N - 1 ? "\n": " ");
	}
}
void func(vector<int> &v) {
	int N = v.size();
	int idx = 0;
	for(int i = 1; i < N; ++i) {
		if(v[idx] < v[i]) {
			idx = i;
		}
	}
	for(int i = 0; i < N; ++i) {
		if(i == idx) {
			v[i] -= N;
		} else {
			v[i]++;
		}
	}
}

bool finished(const vector<int> &v) {
	int N = v.size();
	for(int i = 0; i < N; ++i) {
		if(v[i] >= N) {
			return false;
		}
	}
	return true;
}

bool check(vector<int> v, int m) {
	int N = v.size();
	for(int i = 0; i < m; ++i) {
		if(finished(v)) return false;
		func(v);
	}
	return finished(v);
}

signed main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	int K = 0;
	while(true) {
		priority_queue<int> Q;
		vector<int> v;
		for(int i = 0; i < N; ++i) {
			Q.push(a[i]);
		}
		int L = Q.top(); Q.pop();
		if (L < 150) {
			while(!finished(a)) {
				func(a);
				++K;
			}
			cout << K << endl;
			return 0;
		}
		v.push_back(L);
		while(!Q.empty() && Q.top() >= L - N) {
			v.push_back(Q.top()); Q.pop();
		}
		int t;
		if(Q.empty()) {
			t = 50;
		} else {
			t = Q.top();
		}
		int m = v.size(), s = N - m + 1, k = (L - t - N + N) / (N + 1);
		K += m * k;
		for(int i = 0; i < m; ++i) {
			v[i] -= s * k;
		}
		while(!Q.empty()) {
			v.push_back(Q.top() + m * k);
			Q.pop();
		}
		a = v;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int T,N;
long A[202];
main()
{
	cin>>T;
	for(;T--;)
	{
		cin>>N;
		for(int i=0;i<N;i++)cin>>A[i];
		string s;cin>>s;
		bool ok=true;
		vector<long>base;
		for(int i=N;i--;)
		{
			if(s[i]=='0')
			{
				long t=A[i];
				for(long x:base)t=min(t,t^x);
				if(t!=0)base.push_back(t);
			}
			else
			{
				long t=A[i];
				for(long x:base)t=min(t,t^x);
				if(t!=0)
				{
					ok=false;
					break;
				}
			}
		}
		cout<<(ok?0:1)<<endl;
	}
}


Measured memory_bytes: 3556
from collections import defaultdict
n, m = map(int, input().split())
P = list(map(lambda x:int(x)-1,input().split()))

class UnionFind( ):
    def __init__(self, N):
        self.rank = [0] * N
        self.par = [i for i in range(N)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        else:
            self.par[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

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


uf = UnionFind(n)

for i in range(m):
    x,y = map(lambda x:int(x) - 1,input().split())
    uf.unite(x,y)
    
ans = 0 
for i in range(n):
    if uf.find(i)==uf.find(P[i]):
        ans+=1
        
print(ans)

Measured memory_bytes: 95084
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    int n;
    std::deque<string> words;
    std::multimap<string, int> map;
    std::map<string, int> seen;
    while (cin>>s) {
        if (cin.fail()) {
            break;
        } else {
            cin>>n;
        }
        if (seen[s]==0) {
            words.emplace_back(s);
            seen[s]++;
        }
        map.insert(make_pair(s,n));
    }
    sort(words.begin(),words.end());
    for (int i=0;i<words.size();i++) {
        cout<<words[i]<<endl;
        std::deque<int> tmp;
        auto p=map.equal_range(words[i]);
        for (auto itr=p.first;itr!=p.second;itr++) {
            tmp.emplace_back(itr->second);
        }
        sort(tmp.begin(),tmp.end());
        for (int i=0;i<tmp.size();i++) {
            cout<<tmp[i];
            if (i!=tmp.size()-1) {
                cout<<" ";
            } else {
                cout<<endl;
            }
        }
    }
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define inf (long long)(1e16)
using namespace std;

long long n, m, l, q;
long long dist[500][500] = {0};
vector<vector<long long>> memo;

void solve();

int main() {
  cin >> n >> m >> l;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      if(i != j) dist[i][j] = inf;
  for(int i = 0; i < m; ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    if(c > l) continue;
    dist[a][b] = dist[b][a] = min(c, dist[a][b]);
  }
  solve();
  cin >> q;
  for(int i = 0; i < q; ++i) {
    long long s, t;
    cin >> s >> t;
    cout << memo[--s][--t] << endl;
  }
  return 0;
}

void solve() {
  for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j)
        dist[i][j] =
            min(dist[i][j], dist[i][k] + dist[k][j]);

  memo.assign(n, vector<long long>(n, inf));
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) {
      if(i == j)
        memo[i][j] = 0;
      else if(dist[i][j] <= l)
        memo[i][j] = 1;
    }
  for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j)
        memo[i][j] =
            min(memo[i][j], memo[i][k] + memo[k][j]);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) {
      if(memo[i][j] == inf)
        memo[i][j] = -1;
      else
        --memo[i][j];
      if(dist[i][j] <= l) memo[i][j] = 0;
    }
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int r, c;
   cin >> r >> c;
   vector<vector<int>> tab(r + 1, vector<int>(c + 1));
   rep(i, r) rep(j, c) cin >> tab[i][j];
   rep(i, r) rep(j, c) tab[i][c] += tab[i][j];
   rep(j, r) rep(i, c) tab[r][i] += tab[j][i];
   rep(i, r) tab[r][c] += tab[i][c];
   rep(i, r + 1) rep(j, c + 1) {
      printf("%d%c", tab[i][j], j == c ? '\n' : ' ');
   }
   return 0;
}


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

int main(){
  ll n, d;
  cin >> n >> d;

  int ans = 0;
  rep(i,n) {
    ll x, y;
    cin >> x >> y;
    if(x*x+y*y<=d*d) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
N,M = list(map(int,input().split()))
H = list(map(int,input().split()))
R = [[] for i in range(N)]
ans = 0
for i in range(M):
    A,B = list(map(int,input().split()))
    R[A-1].append(B)
    R[B-1].append(A)
for i in range(len(R)):
    if len(R[i]) == 0:
      ans += 1
    for j in range(len(R[i])):
        if H[i] <= H[R[i][j]-1]:
            ans = ans-j
            break
        else:
            ans += 1
        if j == len(R[i])-1:
            ans = ans-j
print(ans)

Measured memory_bytes: 92836
#include <iostream>
using namespace std;
int main(void){
    int A,B;
    int ans=0;
    cin>>A>>B;
    for(int i=A; i<=B; i++){
        bool b =true;
        string str_A=to_string(i);
        for(int j=0; j<str_A.size()/2; j++){
            if(str_A[j] != str_A[str_A.size()-(1+j)]){
                b=false;
                break;
            }
        }
    if(b) ans++;
    
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	aa := make([]int, n+1)
	ai := make([]int, n)
	dup := 0

	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner) - 1
		if ai[aa[i]] > 0 {
			dup += ai[aa[i]] - 1
			dup += n - i
		}
		ai[aa[i]] = i + 1
	}

	var cm CombinationMod

	cm.init(n + 1)

	for i := 0; i < n+1; i++ {
		ans := cm.calc(n+1, i+1)
		if dup >= i {
			ans -= cm.calc(dup, i)
			ans = (ans + cm.mod) % cm.mod
		}
		fmt.Fprintln(writer, ans)
	}

	writer.Flush()
}

// CombinationMod ...
type CombinationMod struct {
	n, mod   int64
	fac, inv []int64
}

func (cm *CombinationMod) init(n int) {
	cm.n = int64(n)
	cm.fac = make([]int64, n+1)
	cm.inv = make([]int64, n+1)
	cm.fac[0] = 1
	cm.inv[0] = 1
	cm.mod = int64(1e9 + 7)
	var i int64
	for i = 1; i < cm.n+1; i++ {
		cm.fac[i] = (cm.fac[i-1] * i) % cm.mod
		cm.inv[i] = cm.calcInv(cm.fac[i])
	}
}

func (cm *CombinationMod) calcInv(n int64) int64 {
	if n == 1 {
		return 1
	}
	var a, b, x, y int64
	a = cm.mod
	b = n
	x = 1
	y = -a / b

	stack := [][]int64{
		[]int64{
			x, y,
		},
	}
	for a%b > 0 {
		a, b = b, a%b
		x = 1
		y = -a / b
		stack = append(stack, []int64{
			x, y,
		})
	}

	for i := len(stack) - 2; i > 0; i-- {
		stack[i-1][0] *= stack[i][1]
		stack[i-1][1] *= stack[i][1]
		stack[i-1][1] += stack[i][0]
	}

	ans := stack[0][1] % cm.mod
	if ans < 0 {
		ans += cm.mod
	}

	return ans
}

func (cm *CombinationMod) calc(n, m int) int64 {
	ans := (cm.fac[n] * ((cm.inv[m] * cm.inv[n-m]) % cm.mod)) % cm.mod
	return ans
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;

#define fi first
#define se second
#define pb push_back
#define sz(x) (int) ((x).size())
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define testcase int _; cin >> _; while (_--)
#define all(x) ((x).begin(), (x).end())


/*C - Ubiquity*/
void Solve() {
	const int mod = 1e9 + 7;
	int n;	cin >> n;
	ll a = 10, b = 9, c = 8;
	ll ten = 1, nine = 1, eight = 1;
	while (n) {
		if (n & 1) {
			ten = (ten * a) % mod;
			nine = (nine * b) % mod;
			eight = (eight * c) % mod;
		}
			
		a = (a * a) % mod;
		b = (b * b) % mod;
		c = (c * c) % mod;
		n >>= 1;
	}

	cout << (ten - nine - nine + eight + mod + mod) % mod;
}

int main() {
	fast
	//testcase
		Solve();
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(n), c(m), d(m);
	rep(i, n) cin >> a[i] >> b[i];
	rep(i, m) cin >> c[i] >> d[i];

	vector<int> ans(n);

	rep(i, n) {
		int e = 1000000000;
		int f;
		rep(j, m) {
			if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < e) {
				e = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				f = j + 1;
			}
		}
		ans[i] = f;
	}

	rep(i, n) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
while True:
  n = int(input())
  k = int(input())
  if not n:
    break
  lst = [input() for i in range(n)]
  dic = dict()
  def func(num,selected):
    if num == 0:
      dic["".join([lst[i] for i in selected])] = 1
      return
    for i in range(n):
      if not i in selected:
        selected.append(i)
        func(num - 1, selected)
        selected.pop()
  func(k,[])

  print(len(dic))
    
   


Measured memory_bytes: 5856
cards = Array.new(3){gets.chomp.scan(/./)}
player = 0
until cards[player].empty?
    card = cards[player].shift
    case card
    when "a"
        player = 0
    when "b"
        player = 1
    when "c"
        player = 2
    end
end
puts ["A", "B", "C"][player]


Measured memory_bytes: 1788
#include<stdio.h>

#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dijkstra(void);

int n,M[MAX][MAX];

int main(){
  int i,j;
  int k,c,u,v;
  
  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      M[i][j] = INFTY;
    }
  }
  
  for( i = 0 ; i < n ; i++ ){
    scanf("%d %d",&u,&k);
    
    for( j = 0 ; j < k ; j++ ){
      scanf("%d %d",&v,&c);
      M[u][v] = c;
  }
  }

  dijkstra();

  return 0;
}

void dijkstra(void){
  int i,minv;
  int d[MAX],color[MAX];

  for( i = 0 ; i < n ; i++ ){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;

  while(1){
    minv = INFTY;
    int u = -1;

    for( i = 0 ; i < n ; i++ ){
      if( minv > d[i] && color[i] != BLACK ){
	u = i;
	minv = d[i];
      }
    }

    if( u == -1 ) break;

    color[u] = BLACK;

    int v;
    
    for( v = 0 ; v < n ; v++ ){
      if( color[v] != BLACK && M[u][v] != INFTY ){
	if( d[v] > d[u] + M[u][v] ) {
	  d[v]  = d[u] + M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }

  for( i = 0 ; i < n ; i++ ){
    printf("%d",i);
    printf(" ");
   d[i] = (d[i] == INFTY) ? -1 : d[i];
      printf("%d\n",d[i]);
  }
}
  

Measured memory_bytes: 640
//Two Switches
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int lower = max(a,c);
    int upper = min(b,d);
    
    cout<< max(0,upper - lower) <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, k;
    cin >> n >> k;
    int ans = 0;
    rep(i, n) {
        int x;
        cin >> x;
        ans += 2 * min(x, k-x);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3540
S = input()
N = len(S)
S2 = S[:(N-1)//2]
S3 = S[((N+3)//2)-1:]
if (S == S[::-1]) and (S2 == S2[::-1]) and (S3 == S3[::-1]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;

signed main(){
    int H, W;
    cin >> H >> W;

    vector<string> c(H);
    rep(H) cin >> c[i];
    
    int ans = 0;
    
    repp(k, W-1){
        vector< vector<int> > dp(H+1, vector<int>(H+1, INF));
        vector< vector<int> > costs(H+1, vector<int>(H+1, 0));
        dp[0][0] = 0;

        repp(i, H+1){
            repp(j, H+1){
                if(i == H && j == H) break;
                if(i == 0 || j == 0){
                    int ii = i, jj = j;
                    int base = min(i, j);
                    while(ii < H && jj < H){
                        if(c[jj-base][k] == c[ii-base][k+1]){
                            costs[i][j]++;
                        }
                        ii++;
                        jj++;
                    }
                }else{
                    costs[i][j] = costs[i-1][j-1];
                    if(c[H-i][k] == c[H-j][k+1]) costs[i][j]--;
                }
                // cout << i << " " << j << " " << costs[i][j] << endl;
                if(i < H) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + costs[i][j]);
                if(j < H) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + costs[i][j]);
            }
        }
        // cout << dp[H][H] << endl;
        ans += dp[H][H];
    }
    cout << ans;
}


Measured memory_bytes: 1200
#coding:UTF-8

while True:
    try:
        n = int(raw_input())

        count=0

        for a in range(10):
            for b in range(10):
                for c in range(10):
                    for d in range(10):
                        if a+b+c+d==n:
                            count+=1

        print count

    except Exception:
        break

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  vector<int> ans(n);
  rep(start, 0, n) {
    vector<int> dist(n, INF);
    queue<int> q;
    auto push = [&](int v, int d) {
      if (dist[v] != INF) return;
      dist[v] = d;
      q.push(v);
    };
    push(start, 0);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      int d = dist[v];
      if (v - 1 >= 0) push(v - 1, d + 1);
      if (v + 1 < n) push(v + 1, d + 1);
      if (v == x) push(y, d + 1);
      if (v == y) push(x, d + 1);
    }
    rep(i, 0, n) ans[dist[i]]++;
  }
  rep(i, 0, n) ans[i] /= 2;
  rep(i, 1, n) cout << ans[i] << endl;
}


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


using namespace std;


using ll = long long;


int main(void) {
    ll K;
    cin >> K;

    if (K < 10) {
        cout << K << endl;
        return 0;
    }

    vector<vector<string>> lunluns(12);
    for (ll i = 1; i < 10; i++) {
        lunluns[1].push_back(to_string(i));
    }
    ll cnt = 9;
    ll order = 1;
    while (cnt < K) {
        for (auto l : lunluns[order]) {
            if (*l.rbegin() == '0') {
                lunluns[order + 1].push_back(l + "0");
                lunluns[order + 1].push_back(l + "1");
                cnt += 2;
            } else if (*l.rbegin() == '9') {
                lunluns[order + 1].push_back(l + "8");
                lunluns[order + 1].push_back(l + "9");
                cnt += 2;
            } else {
                ll last_digit = *l.rbegin() - '0';
                lunluns[order + 1].push_back(l + to_string(last_digit - 1));
                lunluns[order + 1].push_back(l + to_string(last_digit));
                lunluns[order + 1].push_back(l + to_string(last_digit + 1));
                cnt += 3;
            }
        }
        order++;
    }

    vector<string> flat;
    for (auto lo : lunluns) {
        for (auto s : lo) {
            flat.push_back(s);
        }
    }
    cout << flat[K - 1] << endl;
}


Measured memory_bytes: 21972
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.algorithm;
 
void main() {
  auto a = readln.chomp.split(" ").map!(to!int).array;
  
  foreach (size_t i, e;a) {
    if (e == 0) {
      writeln(i + 1);
      break;
    }
  }
}


Measured memory_bytes: 2668
N = int(input())
T = list(map(int, input().split()))
M = int(input())
l = [list(map(int, input().split())) for i in range(M)]

wa = sum(T)
for i in range(M):
    ans = wa -T[l[i][0] - 1] + l[i][1]
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
const int N = 5e5 + 7;
char s[N];
int a[N];
int main()
{
    scanf("%s",s + 1);
    int len = strlen(s + 1);
    int lastlen = 0,curlen = 0;
    for(int i = 1;i <= len;)
    {
        int cur = 0,j = i;
        if(s[i] == '<')
        {
            while(j <= len && s[j] == '<')
            {
                a[j++] = cur++;
                ++curlen;
            }
        }
        else
        {
            while(j <= len && s[j] == '>')
                ++curlen,++j;
            a[i] = max(curlen,lastlen);
            for(int k = j - 1;k > i;--k)
                a[k] = a[k + 1] + 1;
        }
        if(s[i] == '<')
            lastlen = curlen;
        curlen = 0;
        if(i == j)  ++i;
        else i = j;
    }
    if(s[len] == '<')   a[len + 1] = a[len] + 1;
    long long res = 0;
    for(int i = 1;i <= len + 1;++i) res += a[i];
    printf("%lld",res);
    return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <cmath>
#include <iomanip>
#define PI 3.141592653589
using namespace std;

int main() {
  double a, b, C, S, L, h;
  cin >> a >> b >> C;
  S = 0.5 * a * b * sin(C * PI / 180);
  L = a + b + pow(a * a + b * b - 2 * a * b * cos(C * PI / 180), 0.5);
  h = 2 * S / a;
  cout << fixed << setprecision(10) << S << endl << L << endl << h << endl;
}



Measured memory_bytes: 3616