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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

constexpr int MOD = 1000000007;

// + - * / ^
int mod(int a)
{
    int res = a % MOD;
    if(res < 0) {
        return res + MOD;
    }
    return res;
}
int mul_mod(int a, int b)
{
    ll res = ((ll)a * (ll)b) % MOD;
    return mod((int)res);
}
int pow_mod(int a, int b)
{
    ll res = 1;
    while (b > 0) {
        if(b & 1) {
            res = res * (ll)a % (ll)MOD;
        }
        a = mul_mod(a, a);
        b >>= 1;
    }
    return (int)res;
}
int inv_mod(int a)
{
    return pow_mod(a, MOD - 2);
}
int div_mod(int a, int b)
{
    return mul_mod(a, inv_mod(b));
}

// ! C
constexpr int FAC_MAX = 3000001;
ll fac[FAC_MAX], finv[FAC_MAX], inv[FAC_MAX];
void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < FAC_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;
    }
}
ll com_mod(int a, int b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;
    return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}


int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<string, int> m;
    int n; cin >> n;
    rep (i, n) {
        string s; cin >> s;
        sort(all(s)); m[s]++;
    }
    ll ans = 0;
    for (auto p : m) ans += (ll)p.second * (p.second - 1) / 2;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>

using namespace std;

typedef long long ll;

const int MAX_N = 1010;
const ll P = 1000000007;

int a[MAX_N];

int main() {
	int N;
	cin >> N;
	for (int i = 2; i <= N; i++) {
		int t = i;
		for (int d = 2; d <= t; d++) {
			while (t % d == 0) {
				a[d] += 1;
				t /= d;
			}
		}
		if (t != 1) a[t] += 1;
	}
	ll ans = 1;
	for (int p = 2; p <= N; p++) {
		if (a[p] != 0) ans = (ans * (a[p] + 1)) % P;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let k: i64 = read();
    let x: i64 = read();

    println!(
        "{}",
        (x - k + 1..x + k)
            .map(|ref x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    )
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = sc.nextInt()
    val x = (1..n).map { sc.nextInt() }
    var ans = t
    for (i in 1 until n) {
        ans += Math.min(t, x[i] - x[i - 1])
    }
    println(ans)
}

Measured memory_bytes: 75304
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[N-1];
		for (int i = 0; i < N; i++)
			a[i] = sc.nextInt()-1;
		for (int i = 0; i < N; i++)
			b[i] = sc.nextInt();
		for (int i = 0; i < N-1; i++)
			c[i] = sc.nextInt();
		int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += b[a[i]];
			if (i < N-1 && a[i] + 1 == a[i + 1])
				sum += c[a[i]];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

int gcd(int a, int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}


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

Measured memory_bytes: 256
import numpy as np
N,K = [int(x) for x in input().split()]
A = np.array([int(x) for x in input().split()])
F = np.array([int(x) for x in input().split()])
A.sort()
Asum=np.sum(A)
F.sort();F=F[::-1]
left=-1 #不可能
right=10**20 #可能
while left+1<right:
  mid =(left+right)//2
  if Asum-np.minimum(A,mid//F).sum()<=K:
    right=mid
  else:
    left=mid
print(right)

Measured memory_bytes: 37232
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int inf = 1<<30;
const int mod = 1e9+7;

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int bra = 0, cket = 0;
  vector<int> d(N, 0);
  int x = 1e9;
  for(int i = 0; i < N; i++) {
    if(S[i] == '(') bra++;
    else cket++;
    d[i] = bra - cket;
    x = min(x, d[i]);
  }
  string ans = "";
  for(int i = 0; i < -x; i++) {
    ans.push_back('(');
  }
  for(int i = 0; i < N; i++) {
    ans.push_back(S[i]);
  }
  for(int i = 0; i < d[N-1] - x; i++) {
    ans.push_back(')');
  }
  if(x==1 && S[0] == S[1] && S[0] == '(') ans.push_back(')');
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

/*
fn bfs(
    pre: usize, now: usize,
    graph: Vec<Vec<usize>>,
    res_array: mut Vec<usize>, used_book: mut HashMap<(usize, usize)>,
    visited: mut Vec<usize>, depth: usize
) {
    res_array[depth] += 1;
    visited[now] = true;

    for &i in graph[now].iter() {
        if not visited[i] {
            bfs(now, i, graph, book, visited, depth+1);
        }
    }
} */

use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    scan!(n, x, y; usize);
    let x = x - 1;
    let y = y - 1;

    // グラフの構築
    let mut g = (0..n)
        .map(|_| Vec::with_capacity(3))
        .collect::<Vec<_>>();

    g[0].push(1);
    for i in 1..n-1 {
        g[i].push(i - 1);
        g[i].push(i + 1);
    }
    g[n-1].push(n - 2);

    g[x].push(y);
    g[y].push(x);

    // println!("{:?}", g);

    let mut res_array = vec![0; n];
    let mut used_book: HashMap<(usize, usize), bool> = HashMap::new();

    for i in 0..n {
        let mut visited = vec![false; n];
        visited[i] = true;

        let mut que: VecDeque<(usize, usize)> = VecDeque::new();

        g[i].iter().map(|&j| {
            que.push_front((j, 1));
        }).collect::<Vec<_>>();

        while let Some(node) = que.pop_back() {
            let (now, depth) = node;
            visited[now] = true;

            if used_book.get(&(i, now)).is_none() {
                res_array[depth] += 1;
                used_book.insert((i, now), true);
                used_book.insert((now, i), true);
            }

            for &j in g[now].iter() {
                if !visited[j] {
                    que.push_front((j, depth+1));
                }
            }
        }
    }

    for i in 1..n {
        println!("{}", res_array[i]);
    }
}


Measured memory_bytes: 397608
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

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

    int N, K;
    cin >> N >> K;
    ll ans = 0;
    while (N > 0) {
        N /= K;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    string s;
    cin >> s;

    int frag = 1;
    for (int i = 0; i < s.size(); i++)
    {
        if (i % 2 == 0)
        {
            if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D')
            {
                frag = 0;
                break;
            }
        }

        if (i % 2 == 1)
        {
            if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D')
            {
                frag = 0;
                break;
            }
        }
    }

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


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

int main(){
  string n;
  cin >> n;
  bool ans = false;
  if(n.at(0) == '7') ans = true;
  if(n.at(1) == '7') ans = true;
  if(n.at(2) == '7') ans = true;
  puts(ans ? "Yes" : "No");
  
}

Measured memory_bytes: 3624
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function lineIn(){
		$buf = fgets(STDIN);
		return $this->killNewLine($buf);
	}
	private function breakIn(){
		$buf = str_split($this->killNewLine(fgets(STDIN)));
		return $buf;
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->breakIn();
		$w = $this->lineIn();

		$ans = "";

		$i = 0;
		while(true){
			if(count($s) <= $i)break;
			$ans .= $s[$i];
			$i = $i + $w;
		}
		echo $ans;
	}
}
?>


Measured memory_bytes: 4856
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define inf 1000000000000000000
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(x) (x).begin(),(x).end()
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; }

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

  ll N; cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  set<ll> Used;
  vector<bool> ans(1000001, true);
  for (auto i : A) {
    if (Used.find(i) != Used.end()) {
      ans[i] = false;
      continue;
    }
    for (ll j = 2 * i; j < 1000001; j += i) {
      ans[j] = false;
    }
    Used.insert(i);
  }

  ll cnt = 0;
  for (auto i : A) {
    if (ans[i]) cnt++;
  }

  cout << cnt << endl;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int h = in(), w = in(), n = in();
    vint a = in(n);
    vvint ans(h, vint(w));
    int y = 0, x = 0;
    rep(i, n)
    {
        while (a[i] > 0)
        {
            ans[y][x] = i + 1;

            if (y % 2 == 0)
            {
                if (x < w - 1)
                    ++x;
                else
                    ++y;
            }
            else
            {
                if (x > 0)
                    --x;
                else
                    ++y;
            }
            --a[i];
        }
    }

    rep(i, h) rep(j, w) cout << ans[i][j] << (j == w - 1 ? "\n" : " ");
}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_


   int a, b, c;
   cin >> a >> b >> c;
   cout<<max(0LL, c-(a-b));
   

   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <string.h>
#include <string>
#include <limits.h>
#include <algorithm>
#include <set>
#include <ctime>
#include <cmath>
#include <assert.h>
#include <stack>
using namespace std;
#define SZ(x) ((int)(x).size())
#define rep(i,a,n) for (int i=a; i<(int)n; i++)
#define per(i,n,a) for (int i=n; i>=a; i--)
#define hk push_back
#define pk pop_back
#define mp make_pair
#define PI 3.141592653589793
#define clr(a) memset(a, 0, sizeof(a))
#define clr1(a) memset(a, -1, sizeof(a))
#define c_false ios_base::sync_with_stdio(false); cin.tie(0)
typedef vector<int> VI;
typedef vector< pair<int, int> > VIP;
typedef vector< pair<int, pair<int, int> > > VIPP;
typedef vector<string> VS;
typedef vector <double> VD;
typedef vector <bool> VB;
typedef long long ll;
#define MAX_V 1000
const ll mod = 1000000007;
ll powmod(ll a, ll b) {
	ll res = 1; a %= mod; for (; b; b >>= 1){ if (b & 1)res = res*a%mod; a = a*a%mod; }return res;
}

string s;
int k;

int main()
{
	c_false;
	cin >> s >> k;

	rep(i, 0, s.length()) {
		int req = (s[i] == 'a') ? 0 : 'z' + 1 - s[i];
		if (i == s.length() - 1) {
			int left = k % 26;
			int tmp = s[i] + left;
			if (tmp > 'z') tmp -= 26;
			s[i] = (char)tmp;
		}
		else if (req > k) continue;
		else {
			k -= req;
			s[i] = 'a';
		}
	}
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 592
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x) {
	while(x->left != NIL) x = x->left;
	return x;
}

Node * find(Node *u, int k) {
	while (u != NIL && k != u->key) {
		if (k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

Node * treeSuccessor(Node *x) {
	if (x->right != NIL) return treeMinimum(x->right);
	Node *y = x->parent;
	while (y != NIL && x == y->right) {
		x = y;
		y = y->parent;
	}
	return y;
}

void treeDelete(Node *z) {
	Node *y;
	Node *x;

	if (z->left == NIL || z->right == NIL) y = z;
	else y = treeSuccessor(z);

	if (y->left != NIL) {
		x = y->left;
	} else {
		x = y->right;
	}

	if (x != NIL) {
		x->parent = y->parent;
	}

	if (y->parent == NIL) {
		root =x;
	} else {
		if (y == y->parent->left) {
			y->parent->left = x;
		} else {
			y->parent->right = x;
		}
	}

	if (y != z) {
		z->key = y->key;
	}

	free(y);
}

void insert(int k) {
	Node *x = root;
	Node *y = NIL;
	while (x != NIL) {
		y = x;
		if (x->key == k) return;
		else if (x->key > k) x = x->left;
		else x = x->right;
	}
	Node* u = (Node*)malloc(sizeof(Node));
	u->key = k;
	u->left = u->right = NIL;
	u->parent = y;
	if (y == NIL) {
		root = u;
		return;
	}
	if (y->key > k) y->left = u;
	else y->right = u;
}

void inorder(Node *u) {
	if (u == NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node *u) {
	if (u == NIL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main() {
	int n, i, x;
	string com;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'f') {
			scanf("%d", &x);
			Node *t = find(root, x);
			if (t != NIL) printf("yes\n");
			else printf("no\n");
		} else if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		} else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		} else if (com == "delete") {
			scanf("%d", &x);
			treeDelete(find(root, x));
		}
	}
}



Measured memory_bytes: 22040
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <set>

using namespace std;

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

	set<int> check;

	for (int i = 1; i < 10; i++)
	{
		for (int j = 1; j < 10; j++)
		{
			check.insert(i * j);
		}
	}

	int N;
	cin >> N;

	if (check.find(N) != check.end())
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>

using namespace std;

int a[59];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
  double ans = a[0];
  for (int i = 1; i < n; ++i) {
    ans += a[i];
    ans /= 2;
  }
  printf("%.15f\n", ans);
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int n, a[1000],i;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);

	for (i = n - 1; i >= 1; i--)
		printf("%d ", a[i]);
	printf("%d\n", a[0]);

	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int prev[200000],next[200000];
int main()
{
	int N,M,Q,a,q,p=0,o;
	scanf("%d %d %d",&N,&M,&Q);
	for(int i=0;i<N;i++){
		prev[i] = (i-1+N)%N;
		next[i] = (i+1)%N;
	}
	for(int i=0;i<M;i++){
		scanf("%d",&a);
		for(int j=0;j<a;j++)
			p=a%2==1?prev[p]:next[p];
		next[prev[p]] = next[p];
		prev[next[p]] = prev[p];
		o = next[p];
		prev[p] = -1;
		next[p] = -1;
		p = o;
	}
	for(int i=0;i<Q;i++){
		scanf("%d",&q);
		if(prev[q] == -1)
			printf("0\n");
		else
			printf("1\n");
	}
	return 0;
}

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

const ll dv = 1000000007;

// n^s mod dv
ll pow2( ll n, ll s ){
  if( s == 0 ) return 1;
  if( s == 1 ) return n;
  ll tmp = pow2(n,s/2);
  if( s%2 == 0 ){
    return tmp%dv*tmp%dv;
  }else{
    return tmp%dv*tmp%dv*n%dv;
  }
}

// sから(s-t+1)までの積
ll fac( ll s, ll t ){
  if( t == 0 ) return 1;
  return (s-t+1)%dv*fac(s,t-1)%dv;
}

// nCr mod dv
ll comb( ll n, ll r ){
  ll num = fac(n,r);
  ll denom = fac(r,r);
  return num*pow2(denom,dv-2)%dv;
}

int main(){
  ll s;cin >> s;
  ll ans = 0;
  for(ll i=1;i<=s;++i){
    ll n = s - 3*i;
    if( n < 0 ) break;
    ans += comb(n+i-1,i-1)%dv;
    ans %= dv;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int N, M;
	ll K;
	ll A[200200];
	ll B[200200];
	cin >> N >> M >> K;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	for(int i = 0; i < M; i++){
		cin >> B[i];
	}
	ll ASum[200200];
	ll BSum[200200];
	ASum[0] = A[0];
	for(int i = 1; i < N; i++){
		ASum[i] = ASum[i-1] + A[i];
	}
	BSum[0] = B[0];
	for(int i = 1; i < M; i++){
		BSum[i] = BSum[i-1] + B[i];
	}
	
	ll ans = 0;
	for(ll i = -1; i < N; i++){
		ll timePassed = 0;
		if(i > -1){
			timePassed = ASum[i];
		}
		if(timePassed <= K){
			if(B[0] > K-timePassed){
				ans = max(ans, i+1);
			}else{
				auto itr = upper_bound(BSum, BSum+M, K-timePassed);
				size_t dist = distance(BSum, itr);
				ans = max(ans, (ll)(i+1+dist));
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 9800
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main()
{
	
  string a,b;
  int ans=0;
  
  cin>>a>>b;
  
  for(int i=0;i<a.size();i++) if(a[i]!=b[i]) ans++;
  cout<<ans<<endl;
}
  


Measured memory_bytes: 3900
/**
 * Depth first search.
 * start from node 1
 * 1) increment time 
 * 2) find non visited adjacent node
 * 3) if found move to that node.  d[v'] = time
 * 4) if not found. f[v] = time
 * 5) else end.
 * 5) go to 2.
 */

#include <iostream>
using namespace std;
const int N = 101;
int adj[N][N] = {0};
int d[N]={0};
int f[N]={0};
int t = 0;

void dfs(int n) {
	if (d[n]) return;
	d[n]=++t;
	int k = adj[n][0];
	for (int j=1;j<=k;j++) {
		dfs(adj[n][j]);
	}
	f[n]=++t;
}

int main()
{
	int n;
	cin >> n;
	for (int i=1;i<=n;i++){
		int j, k;
		cin >> j >> k;
		adj[j][0]=k;
		for (int m=1;m<=k;m++) {
			int a;
			cin >> a;
			adj[j][m]=a;
		}
	}

	for (int i=1;i<=n;i++){
		dfs(i);
	}

	for (int i=1;i<=n;i++){
		cout << i << ' ' << d[i] << ' ' << f[i] << endl;
	}

	return 0;
}

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

const int mod=1e9+7;
const int maxn=1e6+10;

inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

inline bool read(int& a){
    int s=0,w=1;
    char ch=getchar();
    if(ch==EOF){
		return false;
	}
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=s*w;
    return true;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

int res;

int qpow(int a,int b){
	if(b==0&&a!=0)
		return 1;
	if(b<0)
		return 0;
	
	int ans=1%mod;
	for(;b;b>>=1){
		if(b&1)
			ans=(long long)ans*a%mod;
		a=(long long)a*a%mod;
	}
	
	return ans%mod;
}

signed main(){
	int n=read();
	res=1;
	res=((qpow(10,n)+mod+mod+mod-2*qpow(9,n))%mod+qpow(8,n))%mod;
	writeln(res);
	return 0;
}

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

const int mod = 10007;
int dp[1010][8];

map<char,int> id = { {'J',0}, {'O',1}, {'I',2} };

int main(){
  int n;
  string s;

  cin >> n >> s;
  dp[0][1] = 1;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<8;j++){
      for(int k=0;k<8;k++){
	if( (j&k) && ((k>>id[s[i]])&1) ){
	  (dp[i+1][k] += dp[i][j]) %= mod;
	}
      }
    }
  }

  int ans = 0;
  for(int i=0;i<8;i++){
    (ans += dp[n][i]) %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1244
object Main extends App {
  
  val sc = new java.util.Scanner(System.in) 
  val a, b = sc.nextInt()
  val s = sc.next()
  if (!s.contains("-") || s.length != a + b + 1 || s.filter(x => x == '-').length != 1) {
    println("No")
  } else {
    val list = s.split("-")
    if (list(0).length == a && list(1).length == b) {
      println("Yes")
    } else {
      println("No")
    }
  }  
}


Measured memory_bytes: 55340
# created by dipta10

a, b = map(str, input().split(' '))
a = int(a)
x = ""
for i in b:
    if i == '.':
        continue
    x += i
b = int(x)

# print(a, b)
ans = a * b
ans = str(ans)
# print(ans)
if (len(ans) <= 2):
    print ('0')
else:
    print(ans[:-2])



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

int main() {
  int n;
  cin >> n;
  vector<int> sides(n);
  for (int i=0; i<n; i++) {
    cin >> sides.at(i);
  }
  sort(sides.begin(), sides.end());
  int sum=0;

  for (int i=0; i<n-1; i++) {
    sum += sides.at(i);
  }

  if (sides.at(n-1) < sum) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
solve :: Int -> [Int] -> Int
solve x ax = min costLeft costRight
  where costLeft  = length $ filter (< x) ax
        costRight = length $ filter (x <) ax

main :: IO ()
main = do
  [_, _, x] <- map read . words <$> getLine
  ax <- map read . words <$> getLine
  print $ solve x ax

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

int main() {
	int n, m, c, b[21], a[21][21];
	cin >> n >> m >> c;
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			sum += a[i][j] * b[j];
		}
		sum += c;
		if (sum > 0) {
			ans++;
		}
		sum = 0;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

// #define mod 1000000007
// #define mod1 9982
#define int  long long int
#define pii pair<int,int>
#define vpii vector<pii>
#define vi vector<int>
#define fi first
#define se second
#define psb push_back
#define ppb pop_back
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define endl "\n"

const int maxn=2e5+5;
int n,k;
int ar[maxn];

bool ok(int h)
{
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        cnt+=((ar[i]+h-1)/h)-1;
    }
    return cnt <= k;
}

void solve()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>ar[i];
    int l=1,h=(1e9),ans=-1;
    while(l<=h)
    {
        int mid=(l+h)/2;
        if(ok(mid))
        {
            ans=mid;
            h=mid-1;
        }
        else
            l=mid+1;
    }
    cout<<ans<<endl;
}

int32_t main()
{
    fio;
    int t;
    // cin>>t;
    t=1;
    while(t--)
        solve(); 
}

/*
./a.out <input.txt > output.txt
*/


Measured memory_bytes: 5164
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <limits>
#include <tuple>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

float inf = std::numeric_limits<float>::infinity();
ll mod = 1e9+7;

/* 二次元配列の宣言
  vector<vector<int>> tb;
  tb.resize(H);
  for (size_t i = 0; i < H; i++) {
    tb[i].resize(W);
  }
*/
/*
  A.resize(N);
  for (int i = 0; i < N; i++) {scanf("%d",&A[i]);}
*/

int max(int &a,int &b){if(a>b){return a;}else{return b;}}
int min(int &a,int &b){if(a>b){return b;}else{return a;}}

int ar_max(vector<int> &v){
  int max_val = v[0];
  for (size_t i = 1; i < v.size(); i++) {
    if (v[i]>max_val){max_val=v[i];}
  }
  return max_val;
}

int ar_min(vector<int> &v){
  int min_val = v[0];
  for (size_t i = 1; i < v.size(); i++) {
    if (v[i]<min_val){min_val=v[i];}
  }
  return min_val;
}


/* Binary Search(v,N,flag)
  flag = true -> return ind(int) 挿入index
  flag = false -> return in(0or1) 入ってるかどうか*/
int b_search(vector<int> &v, int &N, bool flag=true){
  sort(v.begin(),v.end());
  int left=0,right=v.size()-1,ind;
  if (N < v[left]){return 0;}
  if (N > v[right]){return right+1;}
  while(true){
    ind = (left+right)/2;
    if (v[ind]>N){right = ind;}
    else if(v[ind]<N){left = ind;}
    else if(v[ind]==N){
      if(flag){return ind;}
      else{return 1;}
    }

    /* 終了判定*/
    if (right-left<=1){
      if(flag){
        if(v[left]==N){
          return left;
        }else{
          return right;
        }
      }else{
        if(v[left]==N || v[right]==N){return 1;}
        else{return 0;}
      }
    }
  }
}



/*素因数分解(N) ex:N=90(=2*3^2*5)
prime_tb = [2,3,5]
ans_tb = [[2,1][3,2][5,1]]*/
vector<vector<int>> prime_factor(int &N){
  vector<int> prime_tb;
  vector<vector<int>> ans_tb;
  int max_pr=0,prime=2,ind;
  while (N>=2){
    if (N%prime==0){
      if(max_pr>=prime){/*既に出た素因数*/
        ind = b_search(prime_tb,prime);
        ans_tb[ind][1]++;
      }else if(max_pr<N){/*初めて素因数*/
        ind = prime_tb.size();
        ans_tb.push_back({prime,1});
        prime_tb.push_back(prime);
        max_pr = prime;
      }
      N /= prime;
      prime = 2;
    }else{
      prime ++;
    }
  }
  return ans_tb;
}

/*約数の数*/
int divsor_num(int &N){
  vector<vector<int>> pf_tb;
  int ans=1;
  pf_tb = prime_factor(N);
  for (size_t i = 0; i < pf_tb.size(); i++) {
    ans *= pf_tb[i][1]+1;
  }
  return ans;
}

int main(void) {
  ll N,A,B,dist,ans=0;
  vector<int> xx;
  cin >> N >> A >> B;
  xx.resize(N);
  REP(i,N){cin >> xx[i];}

  FOR(i,1,N){
    dist = xx[i]-xx[i-1];
    ans += min(dist*A,B);
  }
  cout << ans << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll A,B,ans = 0;
  cin >> A >> B;
  for(int n = A; n <= B; n++){
    string S = to_string(n);
    if(S[0] == S[4] && S[1] == S[3]){
      ans++;
    }
  }
  cout << ans;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K;
	ll cur=0;
	for(i=1;i<=10000000;i++) {
		cur=(cur*10+7)%K;
		if(cur==0) {
			cout<<i<<endl;
			return;
		}
	}
	cout<<-1<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
	for( ;; ) {
		string x;
		cin >> x;

		if( x == "0" ) {
			break;
		}

		int result = 0;

		for( int i = 0; i < x.size(); ++i ) {
			result += x.at( i ) - '0';
		}

		cout << result << endl;
	}
}



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


int main(){
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n ; i++) {
        cin >> a[i];
    }

    int flag = 0, l = 0, r = n-1;
    for (int i = n-1; i >= 0; i--) {
        if (flag == 0) {
            b[l] = a[i];
            l++;
            flag = 1;
        }
        else {
            b[r] = a[i];
            r--;
            flag = 0;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << b[i] << " ";
    }
    return 0;
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

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

    cin >> skipws;

    for (;;) {
        int m, nmin, nmax;
        cin >> m >> nmin >> nmax;

        if (!m) break;

        map<int, int> mp;
        rep(i, 0, m) {
            int v; cin >> v;
            mp[v]++;
        }

        int maxgap = 0, passer = 0;
        int cntlo = 0, cnthi = m;

        vector<pair<int, int>> v(mp.begin(), mp.end());
        rep(i, 0, mp.size()) {
            // cout << cntlo << " " << cnthi << " " << endl;
            if (i && nmin <= cnthi && cnthi <= nmax) {
                int gap = v[i].first - v[i - 1].first;
                if (gap > maxgap) {
                    maxgap = gap;
                    passer = cnthi;
                }
            }
            cntlo += v[i].second, cnthi -= v[i].second;
        }

        cout << passer << endl;
    }
}


Measured memory_bytes: 3200
s = input()

check = [0]*4

for i in range(len(s)):
    if s[i] == "N" and check[0] == 0:
        check[0] = 1
    if s[i] == "S" and check[1] == 0:
        check[1] = 1
    if s[i] == "W" and check[2] == 0:
        check[2] = 1
    if s[i] == "E" and check[3] == 0:
        check[3] = 1
if check[0] == check[1] and check[2] == check[3]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9132
import java.util.Scanner;


public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Integer n = Integer.parseInt(sc.next());
        Integer k = Integer.parseInt(sc.next());
        Integer x = Integer.parseInt(sc.next());
        Integer y = Integer.parseInt(sc.next());
        Integer price = 0;

        for (int i = 1; i <= n; i++) {
            if (i <= k) {
                price += x;
            } else {
                price += y;
            }
        }
        
        System.out.println(price);
    }
}


Measured memory_bytes: 9812
#include <bits/stdc++.h>
using namespace std;
int b,ok,d;
string s;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>s;
b=s.size()-1;
d=(b+1)/2;
for(int i=0;i<d;i++){
	 if(s[i]!=s[b]){
	 	 ok++;
	 }
	 b--;
}
cout<<ok;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 200000;

int N;
ll A[MAX_N];

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		A[i] -= (ll)(i + 1);
	}
	sort(A, A + N);
	ll sum = 0;
	for(int i = 0; i < N; i++){
		sum += abs(A[i] - A[N / 2]);
	}
	cout << sum << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
int main(){
  int a=0,i,size;
  int k[50];
  char s[50];
  while(1){
    scanf("%s",s);
    if(s[0]=='#') break;
    size=strlen(s);
    for(i=0;i<size;i++){
      if(s[i]=='y'||s[i]=='u'||s[i]=='i'||s[i]=='o'||s[i]=='p'||s[i]=='h'||s[i]=='j'||s[i]=='k'||s[i]=='l'||s[i]=='n'||s[i]=='m'){
	k[i]=1;
      }
      else {
	k[i]=0;
      }
    }
    for(i=1;i<size;i++){
    if(k[i-1]==k[i]) continue;
    else {
      a++;
	}
    }
    printf("%d\n",a);
    a=0;
  }
  return 0;
}

Measured memory_bytes: 968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

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

    vector<int> ac(n, 0);
    vector<int> wa(n, 0);
    rep(i, m)
    {
        int q;
        string res;
        cin >> q >> res;
        q--;
        if (res == "AC")
        {
            ac[q] = 1;
        }
        else
        {
            wa[q] += ac[q] == 1 ? 0 : 1;
        }
    }

    int acs = 0, was = 0;
    rep(i, n)
    {
        acs += ac[i];
        if (ac[i])
        {
            was += wa[i];
        }
    }

    cout << acs << " " << was << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d;
void solve()
{
    if (a+b==c+d) cout<<"Balanced";
    else if (a+b>c+d) cout<<"Left";
    else cout<<"Right";
    cout<<endl;
}
int main()
{
    while(cin>>a>>b>>c>>d)
        solve();
}

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

int main() {
    int n;
    scanf("%d", &n);
    
    map<string, bool> map;
    while(n--){
        char s[8], d[16];
        scanf("%s %s", s, d);
        string ds(d);
        
        if(s[0] == 'i'){
            map[ds] = true;
        }else if(map[ds]){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 45488
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   int a,b;
   cin>>a>>b;
   if(a+b==15)cout<<"+"<<endl;
   else if(a*b==15)cout<<"*"<<endl;
   else cout<<"x"<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N = 2e5 + 5;
int a[N], b[N];
int n, w;
ll dp[105][N];
ll oo = (ll)0x3f3f3f3f * (ll)0x3f3f3f3f;
int max_value = 1e3 * 101;
ll iterative_dp(){
    for(int j=0; j<=max_value; j++){
        dp[n][j] = oo;
    }
    dp[n][0] = 0;
    for(int i=n-1; i>=0; i--){
        for(int j=1; j<=max_value; j++){
            dp[i][j] = min(dp[i+1][j], (j>=b[i]?dp[i+1][j-b[i]] + a[i]:oo));
        }
    }
    for(int i=max_value; i>0; i--){
        if(dp[0][i] <= w)
            return i;
    }
}

int main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false), cin.tie(0);
#endif
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    cin>>n>>w;
    for(int i=0; i<n; i++)
        cin>>a[i]>>b[i];
    cout<<iterative_dp()<<'\n';
}


Measured memory_bytes: 83748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  cin >> K;

  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  cout << a[K-1] <<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    int N; cin>>N;
    vector<ll>a(N);
    rep(i,N)cin>>a[i];
    bool up=false,dn=false;
    int cnt=1;
    rep(i,N-1){
        if(a[i]<a[i+1]){
            up=true;
            if(dn){
                cnt++;
                up=dn=false;
            }
        }
        else if(a[i]>a[i+1]){
            dn =true;
            if(up){
                cnt++;
                up=dn=false;
            }
        }
}
cout<<cnt<<endl;
}



Measured memory_bytes: 1024
import collections
N = int(input())
A = list(map(int,input().split()))

A_keys = collections.Counter(A)
keys_list= A_keys.keys()

combi_sum = {}
for i in keys_list:
    cnt = A_keys[i]
    combi_sum[i] = cnt * (cnt-1)//2 

v_sum = sum(combi_sum.values())
for k in range(N):
    Ak = A[k]
    k_cnt = A_keys[Ak] - 1
    result = v_sum - combi_sum[Ak] + k_cnt*(k_cnt -1)//2
    print(int(result))

Measured memory_bytes: 32020
import sys
input = sys.stdin.readline

def main():
    H, W = map(int, input().split())
    count = 0
    for _ in range(H):
        for row in list(input().rstrip()):
            count += row.count("#")
    if count == H + W - 1:
        print("Possible")
    else:
        print("Impossible")

if __name__ == '__main__':
    main()

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

int main(){
  int n,d;
  cin >>n >>d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i,n){
    rep(j,d){
      cin >> x[i][j];
    }
  }
  int ans = 0;
  rep(i,n){
    for(int j = i+1; j<n; j++){
      int norm = 0;
      rep(k,d){
        int diff = abs(x[i][k]-x[j][k]);
        norm += diff * diff;
      }
      bool flag = false;
      for (int k = 0; k <= norm; k++){
        if(k*k == norm) { 
          flag = true;
        }
      }
      if (flag) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,j,l;
	int a,b;
	scanf("%d%d",&a,&b);
	int max;
	if(a>b)max=a;
	else max=b;
	bool flag=false;
	for(i=0;i<max;i++){
		int a1,a2;
		a1=abs(a-i);
		a2=abs(b-i);
		if(a1==a2){
			
			flag=true;
			break;
		}
		
	}
	if(flag)printf("%d",i);
	else printf("IMPOSSIBLE");
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define sd second
#define ll long long

using namespace std;

const int maxn = 200200;
const int base = 1e9+7;
const ll inf = 1145141919;

pair<ll, int> p[maxn],q[maxn];
int n,l[maxn],r[maxn],id[maxn],t[maxn],f[maxn];

void update(int i,int k) {
    while (i<=n+1) {
        t[i] = (t[i]+k)%base;
        i+=(i&-i);
    }
}

int get(int i) {
    int res=0;
    while (i>0) {
        res = (res+t[i])%base;
        i-=(i&-i);
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 //   freopen("in.txt","r",stdin);
    cin>>n;
    for (int i=1;i<=n;i++) {
        ll x;
        int v;
        cin>>x>>v;
        p[i] = make_pair(x,v);
    }
    sort(p+1,p+n+1);
    for (int i=1;i<=n;i++) {
        ll s;
        s = p[i].fi + inf*p[i].sd;
        q[i] = make_pair(s,i);
    }
    sort(q+1,q+n+1);
    //cout<<"fuck"<<endl;
    for (int i=1;i<=n;i++) id[q[i].sd] = i;
   // for (int i=1;i<=n;i++) cout<<id[i]<<" ";
    for (int i=1;i<=n;i++) {
        r[i] = id[i];
        if (i>1) r[i] = max(r[i],r[i-1]);
    }
    for (int i=n;i>=1;i--) {
        l[i] = id[i];
        if (i<n) l[i] = min(l[i],l[i+1]);
    }
    //cout<<"fuck"<<endl;
    update(1,1);
    //cout<<get(4)<<"fd"<<endl;
    for (int i=1;i<=n;i++) {
        //cout<<l[i]<<" "<<r[i];
        int sum = (get(r[i]+1) - get(l[i]-1) + base)%base;
        f[r[i]] = (f[r[i]] + sum)%base;
      //  cout<<sum<<endl;
        update(r[i]+1,sum);
    }
    cout<<f[n]<<endl;
}


Measured memory_bytes: 10368
#include <stdio.h>
#include <string.h>

int main(void)
{
  int count=0,max=0,i;
    char buff[11];   
 scanf("%s",buff);
 
for(i=0;i<11;i++){
  
    if( buff[i]=='\0')
   break;
    
  
  if(buff[i]=='A'||buff[i]=='T'||buff[i]=='G'||buff[i]=='C'){
    //printf("B");
    count++;
    if(count>max)
    max=count;
  }else count=0;
  

 
  


}
 printf("%d",max);
 return(0);
    }
   

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
using namespace std;

int main(){
	while(true){
		int n;
		scanf("%d", &n);

		vector<int> a(n + 1);
		for(int i = 1; i <= n; ++i){
			scanf("%d", &a[i]);
		}
		
		int r;
		double b, v, e, f;
		if( scanf("%lf%d%lf%lf%lf", &b, &r, &v, &e, &f) != 5 ){
			break;
		}

		vector<double> t(a[n] + 1);
		for(int x = 0; x < a[n]; ++x){
			if( x >= r ){
				t[x + 1] = t[x] + 1.0 / (v - e * (x - r) );
			}
			else{
				t[x + 1] = t[x] + 1.0 / (v - f * (r - x) );
			}
		}

		vector<double> dp(n + 1, 1e99);
		dp[0] = -b;

		for(int i = 1; i <= n; ++i){
			for(int j = 0; j < i; ++j){
				int x = a[i] - a[j];
				dp[i] = min(dp[i], dp[j] + b + t[x]);
			}
		}

		printf("%f\n", dp[n]);
	}
}

Measured memory_bytes: 1164
n = gets
a = gets.chomp.split("")
b = gets.chomp.split("")
c = gets.chomp.split("")

n = n.to_i * 2

a.each.with_index do |_a, i|
  n = n - 1 if _a == b[i]
  n = n - 1 if _a == c[i]
  n = n - 1 if b[i] == c[i]
  n = n + 1 if _a == b[i] && _a == c[i] && b[i] == c[i]
end

puts n


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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 main(void){
  int n; cin >> n;
  int a;
  set<int> s;
  FOR(i,0,n-1){
    cin >> a;
    if(s.count(a)>0){
      cout << "NO" << endl;
      return 0;
    }
    s.insert(a);
  }

  cout << "YES" << endl;
}

Measured memory_bytes: 9600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            int inputNumber = Integer.parseInt(br.readLine().replaceAll(" ", ""));

            String result = "NO";

            if (inputNumber % 4 == 0) {
                result = "YES";
            }

            System.out.println(result);

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 19924