akhauriyash/Code-Regression huggingface dataset:
#define LOCAL
#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 rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll a, b, c, n; cin >> a >> b >> c >> n;

	int cnt = 0;
	rep(i, 3001){
		rep(j, 3001){
			ll res = a * i + b * j;
			if(n - res >= 0){
				if((n - res) % c == 0) cnt++;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3608
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

use std::collections::HashMap;
fn combi(n: u64, k: u64) -> u64 {
    //println!("== {} {}", n, k);
    match k {
        0 => 1,
        1 => n,
        _ => combi(n, k - 1) * (n - k + 1) / k,
    }
}
fn main() {
    let n = read::<usize>();
    let mut v = HashMap::new();
    let mut count : u64 = 0;
    for _ in 0..n {
        let mut s = read::<String>().chars().collect::<Vec<char>>();
        s.sort();
        let s2 = s.into_iter().collect::<String>();

        let count = v.entry(s2).or_insert(0);
        *count += 1;
    }

    let mut ans = 0;
    for &val in v.values() {
        if val >= 2 {
            ans += combi(val, 2);
        }
    }
    println!("{}", ans);
/*
    let mut count: u64 = 0;
    for i in 0..n-1 {
        for j in i+1..n {
            if v[i] == v[j] {
                count += 1;
            }
        }
    }
    println!("{}", count);
    */
}


Measured memory_bytes: 15420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 1e9+7;
ll qpow(ll a,ll b){ll res=1;for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}

int main()
{

    ll x,a,b;
    cin>>x;
    for(ll i = 0;i <= 200;++i){
        a= qpow(i,5);
        for(ll j = -200; j<= i;++j){
            b=qpow(j,5);
            if(a-b==x){
                cout<<i<<' '<<j<<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

struct mint {
	ll x;
	mint(ll x = 0) :x(x% mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	map<char, int> mp;
	for (char c : s) mp[c]++;
	mint ans = 1;
	for (auto& p : mp) ans *= (p.second + 1);
	printf("%d\n", ans - 1);
	return 0;
}


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

using namespace std;
using ll = long long;

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

ll pow(ll k, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * k;
    k = k * k;
    n /= 2;
  }
  return res;
}

int main() {
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for (int i = 1; i <= n; ++i) {
    int j = i;
    double now = 1.0 / n;
    int m = 0;
    while (j < k) {
      j *= 2;
      ++m;
    }
    now *= 1.0 / pow(2, m);
    ans += now;
  }
  printf("%.15f\n", ans);
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  string S; cin >> S;
  string ans = "";
  for(int i = 0; i < S.size(); i++){
    ans += "x";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3548
#!/usr/bin/env python3
import math
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, p = MI()
    a = LI()
    num_0 = 0
    num_1 = 0
    for i in range(n):
        if a[i] % 2 == 0:
            num_0 += 1
        else:
            num_1 += 1

    s_1 = 0
    while p <= num_1:
        cmb = math.factorial(num_1) // (
            math.factorial(num_1 - p) * math.factorial(p)
        )
        s_1 += cmb
        p += 2

    print(s_1 * (2 ** num_0))


main()


Measured memory_bytes: 62272
M = input()
n = len(M)
for i in range(0,n//2 +1,1):
    if M[i] != M[n-1-i]:
        print("No")
        exit()
for i in range(0,((n-1)//2 - 1)//2 + 1,1):
    if M[i] != M[(n-1)//2 -1 -i]:
        print("No")
        exit()
for i in range(0,(n-3)//2+1,1):
    if M[(n+3)//2 - 1 +i] != M[n-1-i]:
        print("No")
        exit()
print("Yes")

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

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

	if( H < W ) swap( H, W );
	int ans = 0;
	for( int i = 0; i * H < N; i++ ) {
		ans = i;
	}
	ans++;

	cout << ans << endl;
}


Measured memory_bytes: 256
A,B=map(x->parse(Int,x),split(readline()))
A=gcd(A,B)
ans=1
for i=2:isqrt(A)
	if A%i==0
		ans+=1
		while A%i==0
			A=div(A,i)
		end
	end
end
if A>1
	ans+=1
end
println(ans)


Measured memory_bytes: 153212
#include<iostream>
#include<string>
#include<stdio.h>
#include<cstdio>
#include<math.h>
using namespace std;
int main(){
    double a,b,racount=0,lacount=0,rbcount=0,lbcount=0,rccount=0,lccount=0,rdcount=0,ldcount=0;
    while(cin>>a>>b){
        if(a>=1.1){
            racount++;
        }
        else if(a>=0.6){
            rbcount++;
        }
        else if(a>=0.2){
            rccount++;
        }
        else{
            rdcount++;
        }
        if(b>=1.1){
            lacount++;
        }
        else if(b>=0.6){
            lbcount++;
        }
        else if(b>=0.2){
            lccount++;
        }
        else{
            ldcount++;
        }
    }
    cout<<racount<<" "<<lacount<<endl<<rbcount<<" "<<lbcount<<endl<<rccount<<" "<<lccount<<endl<<rdcount<<" "<<ldcount<<endl;
    return 0;
}

Measured memory_bytes: 3252
void main() {
    int[] tmp = readln.split.to!(int[]);
    int h = tmp[0], w = tmp[1];

    int cnt;
    string[] s = new string[h];
    foreach (i; 0 .. h) {
        s[i] = readln.chomp;
        cnt += s[i].count('.');
    }

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

    int[][] dist = new int[][](h, w);
    foreach (d; dist) {
        d[] = -1;
    }
    dist[0][0] = 0;

    coord[] que;
    que ~= coord(0, 0);

    while (!que.empty) {
        int y1 = que[0].y, x1 = que[0].x;
        que.popFront;
        foreach (dir; 0 .. 4) {
            int y2 = y1 + dy[dir], x2 = x1 + dx[dir];
            if (y2 < 0 || h <= y2 || x2 < 0 || w <= x2) continue;
            if (s[y2][x2] == '#') continue;

            if (dist[y2][x2] == -1) {
                que ~= coord(y2, x2);
                dist[y2][x2] = dist[y1][x1] + 1;
            }
        }
    }

    writeln(dist[h-1][w-1] != -1 ? cnt - dist[h-1][w-1] - 1 : dist[h-1][w-1]);
}

alias Tuple!(int, "y", int, "x") coord;

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define int long long

int32_t main()
{
    int n,sum=0,flag=1e9,fl=0; cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        int temp; cin>>temp;
        a[i]=abs(temp);
        sum+=a[i];
        if(temp<0)
        {
            fl++;
        }
        flag=min(flag,abs(temp));
    }
    if(fl%2==0) cout<<sum;
    else cout<<sum-flag*2;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){

  int i, n, max, min, ans, a;

  scanf("%d %d", &n, &a);
  max = a;
  min = a;

  for(i=1;i<n;i++){
    scanf("%d", &a);
    if(max<a) max=a;
    if(min>a) min=a;
  }

  ans = max-min;

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

//素因数分解, o(sqrt(n))
template<class T>
map<T, int> primeFactor(T n){
	map<T, int> res;
	for(int i = 2; i * i <= n; i++){
		while(n % i == 0){
			res[i]++;
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}


int main(void){
	int N; cin >> N;

	map<int, int> mp;
	for(int i = 1; i <= N; i++){
		map<int, int> m = primeFactor(i);
		for(int i = 1; i <= N; i++){
			mp[i] += m[i];
		}
	}

	ll res = 1;
	for(auto x: mp){
		// printf("mp[%d] = %d\n", x.first, x.second);
		res *= ((x.second + 1) % MOD);
		res %= MOD;
	}

	cout << res << '\n';

	return 0;
}


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

int V, E;
vector<set<int>> redge;

set<int> memo;
void topological_sort(int u) {
  if(memo.count(u)) return;
  memo.insert(u);
  for(int v: redge[u]) topological_sort(v);
  cout << u << endl;
}

int main() {
  cin >> V >> E;
  redge.resize(V);
  for(int i = 0; i < E; ++i) {
    int u, v;
    cin >> u >> v;
    redge[v].insert(u);
  }
  for(int i = 0; i < V; ++i) topological_sort(i);
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
#define Maxn 18
#define modp1 998244353
#define modp2 100000007
using namespace std;
int n,m;
map<pair<int,int>,int> mp;
char s[Maxn][Maxn],s1[Maxn][Maxn];
int ch[Maxn];
bool vis[Maxn];
bool ans=false;
void calc()
{
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			s1[i][j]=s[i][j];
	for (int i=1;i<=(n+1)/2;i++)
		if (ch[i]!=0&&ch[i]<=n)
		{
			for (int j=1;j<=m;j++)
				swap(s1[i][j],s1[ch[i]][j]);
		}
	int cnt=0;
	mp.clear();
	for (int i=1;i<=m;i++)
	{
		int now1=0,now2=0;
		for (int j=1;j<=n;j++)
		{
			now1=(29LL*now1+s1[j][i]-'a'+1)%modp1;
			now2=(29LL*now2+s1[j][i]-'a'+1)%modp2;
		}
		if (mp[make_pair(now1,now2)])
		{
			--cnt;
			--mp[make_pair(now1,now2)];
		} else
		{
			++cnt;
			now1=0,now2=0;
			for (int j=n;j;j--)
			{
				now1=(29LL*now1+s1[j][i]-'a'+1)%modp1;
				now2=(29LL*now2+s1[j][i]-'a'+1)%modp2;
			}
			++mp[make_pair(now1,now2)];
		}
	}
	if (cnt<=1) ans=true;
}
void dfs(int x)
{
	if (ans) return;
	if (x<=(n+1)/2)
	{
		for (int i=x+1;i<=2*((n+1)/2)&&(!ans);i++)
			if (!vis[i])
			{
				ch[x]=i;
				ch[i]=x;
				dfs(x+1);
				ch[i]=0;
			}
	}
	else calc();
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	memset(vis,false,sizeof(vis));
	dfs(1);
	if (ans) printf("YES\n"); else printf("NO\n");
	return 0;
}


Measured memory_bytes: 384
# ABC065
# B
# Trained?

n = int(input())
a_list = [None]*n

for i in range(n):
    a_list[i] = int(input())

ans = 0
done_list = [0]*n
flag = False

now = 1
done_list[0] = 1

while True:
    now = a_list[now-1]
    ans += 1
    if now == 2:
        flag = True
        break
    elif done_list[now-1] == 1:
        break
    done_list[now-1] = 1
    
if flag:
    print(ans)
else:
    print("-1")

Measured memory_bytes: 7796
#include<stdio.h>
int main()
{
	char a,b;
	scanf("%c %c",&a,&b);
	if(a=='H' && b=='H'){
		printf("H\n");
	}
	else if(a=='D' && b=='H'){
		printf("D\n");
	}
	else if(a=='H' && b=='D'){
		printf("D\n");
	}
	else if(a=='D'&&b=='D'){
		printf("H\n");
	}
	return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    // スペース区切りの整数の入力
    BigDecimal R = new BigDecimal(sc.nextInt());
    BigDecimal S = R.multiply(new BigDecimal(2)).setScale(100, RoundingMode.HALF_UP);

    System.out.println(S.multiply(new BigDecimal("3.1415")).setScale(100, RoundingMode.HALF_UP));
  }
}


Measured memory_bytes: 35924
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int ab,bc,ca;
    cin >> ab >> bc >> ca;
    
    int ans = ab * bc;
    cout << ans / 2 << endl;; 

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
int n,d,i,j;
scanf("%d %d",&n,&d);
if (n%((2*d)+1) == 0)
{
printf ("%d",(n/((2*d)+1)));
}
else
{
printf ("%d",(n/((2*d)+1))+1);
}
return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>

int N,rest=20;

int Query(int pos)
{
	char str[20];
	rest--;
	printf("%d\n",pos);
	fflush(stdout);
	scanf("%s",str);
	if(str[0]=='V')
		exit(0);
	if(str[0]=='M')
		return 1;
	if(str[0]=='F')
		return 2;
	return -1;
}

void solve(int L,int R,int st1=-1)
{
	if(R-L+(st1==-1)<=rest)
	{
		for(int i=L+(st1!=-1);i<=R;i++)
			if(Query(i)==0)
				exit(0);
		exit(0);
	}
	if(st1==-1)
		st1=Query(L);
	int mid=(R-L+1)/2;
	if(mid%2==1)
		mid++;
	int st2=Query(L+mid);
	if(st1==st2)
		solve(L+mid,R,st2);
	else
		solve(L,L+mid,st1);
}

int main()
{
	scanf("%d",&N);
	solve(0,N-1);
	
	return 0;
}


Measured memory_bytes: 760
#include <iostream> //cout
#include <cstring> //c
#include <vector> //vector
#include <set> //set
#include <bitset> //bitset
#include <algorithm> //min
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


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

    vector<long> C(N, 0);
    vector<vector<long>> A(N, vector<long>(M,0));

    rep(i, N){
        cin >> C.at(i);
        rep(j, M){
            cin >> A.at(i).at(j);
        }
    }

    long C_min = 1<<30;
    // cout << "min:" << C_min << endl;
    int flag = 0;
    for(int bit = 0; bit < (1<<N); bit++){
        //sum
        vector<long> Atemp(M, 0);
        long C_temp = 0;
        rep(i, N){
            if(bit & (1<<i)){
                rep(j, M){
                    Atemp.at(j) += A.at(i).at(j);
                }
                C_temp += C.at(i);
            }
        }

        //check
        int ngflag = 0;
        // cout << C_temp << "yen, ";
        rep(j, M){
            // cout << j << ":["<< Atemp.at(j) << "],";
            if(X > Atemp.at(j)){
                ngflag = 1;
                break;
            }
        }
        // cout << endl;
        if(ngflag == 0){
            flag = 1;
            C_min =min(C_min, C_temp);
            // cout << "min!:" << C_min << endl;
        }
    }

    if(flag == 0){
        std::cout << "-1" << endl;
    }
    else{
        std::cout << C_min << endl;
    }
}


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

int main(){
    int n,t,a;
    int ans;
    double mi=inf;
    cin >> n >> t >> a;
    rep(i,n){
        int h;
        cin >> h;
        double sub=abs(a-(t-h*0.006));
        if(mi>sub){
            mi=sub;
            ans=i+1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
l_S = [0] * N
memo = []
count = 0

for i, (s_l, s_r) in enumerate(zip(S[:-1], S[1:])):
    if s_l == "R":
        if s_r == "R":
            count += 1
        else:
            count += 1
            l_S[i] = count
            count = 0
            tmp = i + 1
            memo.append(i)
    else:
        if s_r == "R":
            count += 1
            l_S[tmp] = count
            count = 0
        else:
            count += 1

count += 1
l_S[tmp] = count
count = 0

for i in memo:
    tmp = (l_S[i] + l_S[i+1]) // 2
    if (l_S[i] + l_S[i+1]) % 2 == 0:
        l_S[i] = tmp
        l_S[i+1] = tmp
    else:
        if l_S[i] % 2 == 0:
            l_S[i] = tmp
            l_S[i+1] = tmp + 1
        else:
            l_S[i] = tmp + 1
            l_S[i+1] = tmp


print(*l_S)

Measured memory_bytes: 49756
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    int X[2000000];
    int X_in[200000];

    for(int i=0; i < N; i++){
        cin >> X[i];
        X_in[i] = X[i];
      
    }
    sort(X, X+N);
    int med_l = X[N/2 - 1];
    int med_r = X[N/2 ];
    
    if(med_l==med_r){
        for(int i =0; i < N; i++) cout << med_l << endl; 
        return 0;
    }

    for(int i =0; i < N; i++){
        if(X_in[i] <= med_l) cout << med_r << endl;
        else cout << med_l << endl;
    } 
    return 0;

}


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

int main(){
  int n, q;
    cin >> n >> q;
    vector<bool> vchd(n), hchd(n);
    map<int, int> ve, ho;
    ve[n] = ho[n] = n;
    int vl = n, hl = n;
    while (q--) {
      int typ;
      int x;
      cin >> typ >> x;
      if (typ == 1) {
        vchd[x] = 1;
        vl = min(vl, x);
        int y = ve.lower_bound(x)->second;
        if (ho.lower_bound(y)->second > x) {
          while (1) {
            auto p = ho.lower_bound(y);
            if (p == begin(ho)) break;
            if (prev(p)->second < x) break;
            ho.erase(p);
          }
          ho[y] = x;
        }
      } else {
        hchd[x] = 1;
        hl = min(hl, x);
        int y = ho.lower_bound(x)->second;
        if (ve.lower_bound(y)->second > x) {
          while (1) {
            auto p = ve.lower_bound(y);
            if (p == begin(ve)) break;
            if (prev(p)->second < x) break;
            ve.erase(p);
          }
          ve[y] = x;
        }
      }
    }
    long long ans = 0;
    for (auto i = 2; i < n; ++i) {
      if (!vchd[i]) {
        ans += ve.lower_bound(i)->second - 2;
      }
      if (!hchd[i]) {
        ans += ho.lower_bound(i)->second - 2;
      }
    }
    cout << ans - long(vl - 2) * (hl - 2) << endl;
}

Measured memory_bytes: 8132
using System;

public class ITP1_10_B{
    public static void Main(){
        var items = Console.ReadLine().Split(' ');
        
        var a = double.Parse(items[0]);
        var b = double.Parse(items[1]);
        var C = double.Parse(items[2]);
        
        var C_rad = C / 180 * Math.PI;
        
        var S = a * b * Math.Sin(C_rad) / 2;
        
        var c = Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(C_rad));
        var L = a + b + c;
        
        var h = 2 * S / a;
        
        Console.WriteLine(S);
        Console.WriteLine(L);
        Console.WriteLine(h);
    }
}



Measured memory_bytes: 17908
import Data.Char

tab = [ ['.', ',', '!', '?', ' '],
        ['a', 'b', 'c'],
        ['d', 'e', 'f'],
        ['g', 'h', 'i'],
        ['j', 'k', 'l'],
        ['m', 'n', 'o'],
        ['p', 'q', 'r', 's'],
        ['t', 'u', 'v'],
        ['w', 'x', 'y', 'z']
      ]

ans [] = []
ans s =
  let s' = dropWhile (== 0) s
      w  = takeWhile (/= 0) s'
      k  = head w
      l  = (length w) - 1
      t  = tab!!(k-1)
      tl = length t
      c  = t!!(l `mod` tl)
  in
    if w == [] then [] else c:(ans $ dropWhile (/= 0) s')

main = do
  _ <- getLine
  c <- getContents
  let i = map (map digitToInt) $ lines c :: [[Int]]
      o = map ans i
  mapM_ putStrLn o



Measured memory_bytes: 5084
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 100005;

int n, m;
int p[N];
int a[N], b[N];
int sz[N];

int fs(int u) {
  return (p[u] == u ? u : p[u] = fs(p[u]));
}

void join(int x, int y) {
  int aa = fs(x), bb = fs(y);
  if (aa == bb) return;
  p[bb] = aa;
  sz[aa] += sz[bb];
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < N; i++) p[i] = i, sz[i] = 1;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }
  long long ans = 1ll * n * (n - 1) / 2;
  vector <long long> vec;
  for (int i = m - 1; i >= 0; i--) {
    vec.push_back(ans);
    if (fs(a[i]) == fs(b[i])) continue;
    int pr = sz[fs(a[i])];
    ans += 1ll * pr * (pr - 1) / 2;
    pr = sz[fs(b[i])];
    ans += 1ll * pr * (pr - 1) / 2;
    join(a[i], b[i]);
    pr = sz[fs(a[i])];
    ans -= 1ll * pr * (pr - 1) / 2;
  }
  reverse(vec.begin(), vec.end());
  for (long long x : vec) {
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  string S;
  cin>>S;
  ll ans=0;
  for(ll i=0;i<3;i++) {
if(S[i]=='1') {
ans++;
}
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//const ll MOD=(ll)1e9+7;
const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};


void solve(int ca){
    int a,b,c,d,e; string s,t,u;
    char p;
    cin>>p;
    if(p-'a'>=0&&p-'a'<26){
        cout<<'a'<<endl;
    }else cout<<'A'<<endl;

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 3576
times = int(input())
element = []

for i in range(times):
    element.append(int(input()))

maxv = element[1]-element[0]
minv = element[0]
for j in range(1,len(element)):
    maxv = max(element[j]-minv,maxv)
    minv = min(minv,element[j])

print(maxv)

Measured memory_bytes: 15612
#include <iostream>
#include <vector>
#include <algorithm>
#define MAX 1000000
using namespace std;

int main(){
  bool a[MAX];
  vector<int> v;
  for(int i=0;i<MAX;i++) a[i] = true;
  a[0] = a[1] = false;
  for(int i=2;i<MAX;i++){
    if(a[i]){
      v.push_back(i);
      for(int j=i+i;j<MAX;j+=i) a[j] = false;
    }
  }

  int n,p;
  while(cin >> n >> p){
    if(n == -1 && p == -1) break;

    vector<int> s;
    for(int i=0;i<v.size();i++){
      if(v[i] > n){
	for(int j=i;j<i+100;j++){
	  if(j >= v.size()) break;
	  for(int k=j;k<i+100;k++){
	    if(k >= v.size()) break;
	    s.push_back(v[j]+v[k]);
	  }
	}
	break;
      }
    }

    sort(s.begin(),s.end());

    cout << s[p-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe
import Data.Bits
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import Data.Vector.Unboxed ((!))


findMidWithin :: V.Vector Int -> (Int,Int) -> Int
findMidWithin vec (from,to) =
    fromMaybe to $ testIndex
    <$> V.findIndex ((>= lohi) . (`shiftL` 1)) (V.slice from (to-from+1) vec)
    where
      len = V.length vec
      n = len - 1
      lohi = vec!0 + vec!n
      testIndex 0 = from
      testIndex j | lohi <= vec!(from+j-1) + vec!(from+j) = from+j-1
                  | otherwise                             = from+j

findMidIntvWithin :: V.Vector Int -> (Int,Int) -> (Int,Int) -> Int
findMidIntvWithin vec (intvFrom,intvTo) (withinFrom,withinTo)
  = intvFrom
    + findMidWithin (V.slice intvFrom (intvTo-intvFrom+1) vec)
       (withinFrom - intvFrom, withinTo - intvFrom)
                                 
query :: Int -> V.Vector Int -> Int
query n sums =
  V.minimum $ V.imap (curry $ uncurry (-) . maxmin . map diff . poss) inds
  where
    maxmin = foldl' (\(mx,mn) v -> (mx `max` v, mn `min` v))
                    (minBound,maxBound)
    diff (i,j) = sums!j - sums!i
    poss (j',(i,k)) = [(0,i),(i,j),(j,k),(k,n)]
      where j = j' + 2
    inds =
      V.unfoldrN (n-3)
                 (\(!i,!j,!k) ->
                    let j' = findMidIntvWithin sums (0,i) (j,i-1)
                        k' = findMidIntvWithin sums (i,n) (k,n-1)
                    in Just ((j',k'),(i+1,j',k'`max`(i+1))))
                 (2,1,3)
     
main :: IO ()
main = do
  n <- read <$> getLine
  ais <- V.unfoldrN n (B.readInt . B.dropWhile (==' ')) <$> B.getLine
  putStrLn $ show $ query n $ V.scanl (+) 0 ais


Measured memory_bytes: 6908
dict = {
    'A':1,
    'B':2,
    'C':3,
    'D':4,
    'E':5,
    'F':6,
    'G':7,
    'H':8,
    'I':9,
    'J':10,
    'K':11,
    'L':12,
    'M':13,
    'N':14,
    'O':15,
    'P':16,
    'Q':17,
    'R':18,
    'S':19,
    'T':20,
    'U':21,
    'V':22,
    'W':23,
    'X':24,
    'Y':25,
    'Z':26
}
alphlist = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
step = int(input())
a = input()
b = list(a)
d = []
for i in b:
    c = (dict.get(i) + step - 1)%26
    d.append(alphlist[c])
print(''.join(d))

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

string solve() {
    string T;
    cin >> T;
    ll d = 0, pd = 0;
    for ( int i = 0; i < T.size(); i++ ) {
        if ( T[i] == '?' ) T[i] = 'D';
    }
    return T;
}

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

Measured memory_bytes: 3756
import           Data.List
main = do
    n <- readLn :: IO Int
    p <- map read . words <$> getLine :: IO [Int]
    print . length . filter (True==) . foldl' (\a i -> j(f i p):a) [] $ [0..(n-3)]
  where
    f n = take 3 . drop n
    j p = let [_,pi,_] = p in sort p !! 1 == pi


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int a, b;
  cin >> a >> b;

  int h = 0;
  FOR (i, 1, b - a) {
    h += i;
  }

  cout << h - a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100500;
const int D = 12;

int dp[N][D];
int n, m, q;
vector <vector <int> > g;
int v[N], d[N], c[N];

void draw(int v, int d, int c)
{
	if (d == -1 || dp[v][d])
		return;

	dp[v][d] = c;


	for (int to : g[v])
		draw(to, d - 1, c);
}

int main()
{                                                     
	ios_base::sync_with_stdio(0);

	cin >> n >> m;

	g.resize(n);

	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	cin >> q;

	for (int i = q - 1; i >= 0; i--)
	{
		cin >> v[i] >> d[i] >> c[i];
		v[i]--;
	}

	for (int i = 0; i < q; i++)
	{
		for (int x = d[i]; x >= 0; x--)
			draw(v[i], x, c[i]);
	}

	for (int i = 0; i < n; i++)
		cout << dp[i][0] << '\n';

	return 0;
}



Measured memory_bytes: 12408
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
//cout<<setprecision(12)
//fixed
//#include<random>
using namespace std;
typedef long long int llint;
typedef long double lldo;
const int big=1e9+100000;
const int mod=1e9+7;
const lldo eps=1e-9;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
#define dme(in) cout<<in<<endl;return 0
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	int n,q,i,j;cin>>n>>q;
	vector<int>s(n);
	vector<int>mo(n);
	set<pair<int,int>> leader;
	leader.ins(mp(-1,-1));
	for(i=0;i<n;i++){cin>>s[i];mo[i]=s[i];}
	sort(s.begin(),s.end());
	while(q--){
		string st;int x;cin>>st>>x;
		if(st=="ADD"){
			x--;
			leader.ins(mp(mo[x],x));
		}else if(st=="REMOVE"){
			x--;
			leader.era(mp(mo[x],x));
		}else if(st=="CHECK"){
			//?????¶??????
			int bmax=1000000005;int bmin=-1;
			while(bmax-bmin!=1){
				int gen=(bmax+bmin)/2;
				int nin=0;
				for(auto it=next(leader.begin());it!=leader.end();it++){
					int to=max(it->fir-gen,prev(it)->fir+1);
					nin+=upper_bound(s.begin(),s.end(),it->fir)-lower_bound(s.begin(),s.end(),to);
				}
				if(n-nin<=x){bmax=gen;}
				else{bmin=gen;}
			}
			if(bmax<1000000005){cout<<bmax<<endl;}
			else{cout<<"NA"<<endl;}
		}
	}
	return 0;
}

Measured memory_bytes: 10772
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<int, int> P;
vector<int> G[100000];
bool vis[100000];
vector<int> L;
int dp[100000];
void dfs(int v) {
	vis[v] = 1;
	for (int to : G[v]) {
		if (!vis[to]) {
			dfs(to);
		}
	}
	L.push_back(v);
}
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
	}
	for (int i = 0; i < N; i++) {
		if (!vis[i]) {
			dfs(i);
		}
	}
	reverse(L.begin(), L.end());
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int v = L[i];
		for (int to : G[v]) {
			dp[to] = max(dp[to], dp[v] + 1);
			ans = max(ans, dp[to]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 8824
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n[] = sc.next().split("");
		int x = 0;
		int f = 0;
		for (int i = 0; i < n.length; i++) {
			x = x * 10 + Integer.parseInt(n[i]);
			f += Integer.parseInt(n[i]);
		}
		System.out.println((x % f == 0)? "Yes" : "No");
	}
}

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

int main(){
    int N=0,D=0,X=0,result=0,j=0;
    cin >> N >> D >> X;
    for(int i=0;i < N;i++){
        int A[i];
        cin >> A[i];
        for(int j=1;j<=D;j = j + A[i]){
            result++;
        }
    }
    cout << result + X << endl;
}


Measured memory_bytes: 256
import math

def main():
    a, b, x = map(int, input().split())
    if(x <= (a * a * b) / 2): 
        tan_th = (a * b * b) / (2 * x)
    else:
        tan_th = (2 * (a * a * b - x)) / (a * a * a)
    ans = math.degrees(math.atan(tan_th))
    print(ans)
    return 0
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll L;
    cin >> L;

    vector<ll> u, v, w;
    ll r = 0;
    for (int i = 1; i <= L; i*=2) {
        r++;
    }
    r--;

    for (int i = 1; i <= r; i++) {
        u.push_back(i);
        v.push_back(1+i);
        w.push_back(1LL<<(i-1));

        u.push_back(i);
        v.push_back(1+i);
        w.push_back(0);
    }

    for (int i = r; i >= 1; i--) {
        if (L - (1 << (i-1)) >= (1 << r)) {
            L -= 1<<(i-1);
            u.push_back(i);
            v.push_back(r+1);
            w.push_back(L);
        }
    }

    cout << (r+1) << " " << u.size() << endl;
    rep(i, u.size()) {
        cout << u[i] << " " << v[i] << " " << w[i] << endl;
    }
}
signed main(){ Main();return 0;}

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


int main(){
  
  long int a,b,c,tmp=99,d,e;
  cin >> a >> b;
  d = a; e = b;
  
  while(tmp > 0){
    tmp = max(d,e)%min(d,e);
    c = min(d,e);
    d = c; e = tmp;
  }
  
  cout << a*b/c;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<iostream>
#include<set>
#include<string>
#include<math.h>

using namespace std;

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};

int main(){
	int n,k;
	cin>>n>>k;
	long long int a[15];
	long long int ans=16000000000LL;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<(1<<n);i++){
		long long int temp=0LL;
		int i_=i;
		int check=0;
		while(i_){
			check+=i_%2;
			i_=i_>>1;
		}
		if(check<k){continue;}
		long long int highest=0LL;
		for(int j=0;j<n;j++){
			if((i&(1<<j))!=0){
					temp+=max(0LL,highest+1-a[j]);
					highest=max(highest+1,a[j]);
			}
			else{
				highest=max(highest,a[j]);
			}
		}
//		cout<<bitset<5>(i)<<" "<<temp<<endl;
		ans=min(temp,ans);
	}
	cout<<ans<<endl;
}


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

const int maxn = 1010;
const int INF = 1<<30;

char s[maxn], news[maxn], backups[maxn];
int n,len;
char ch;

bool check()
{
	for (int i=1;i<=n;i++)
		if (s[i] != ch) return false;
	return true;
}
		
int main()
{
	//freopen("A.in","r",stdin);
	scanf("%s",s);
	n = strlen(s);
	len = n;
	for (int i=n;i>=1;i--) s[i] = s[i-1], backups[i] = s[i];
	
	int ans = INF;
	for (int i='a'-'a';i<='z' - 'a';i++)
	{
		n = len;
		for (int j=1;j<=n;j++) s[j] = backups[j];
		ch = (char)(i+'a');
		int cnt = 0;
		if (check())
		{
			cout<<0<<endl;
			return 0;
		}
		
		while (n>1)
		{
			cnt++;
			for (int j=1;j<n;j++)
			{
				if (s[j] == ch || s[j+1]==ch) news[j]=ch;
				else news[j] = s[j];
			}
			n--;
			for (int j=1;j<=n;j++) s[j] = news[j];
			if (check()) break;
		}
		ans = min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()



string pre(string s){   // "][" を空白に置き換え
    string b="";
    rep(i,s.sz-1){
        if(s[i]==']' && s[i+1]=='['){
            b+=' ';
            i++;
        }
        else{
            b+=s[i];
        }
    }
    b+=s[s.sz-1];
    return b;
}


string solve(int n,bool check,string s){
    n++;
    string tmp[10000]={};

    int count=0;
    REP(j,n,s.sz){
        if(s[j]!=']'){
            if(s[j]!=' '){
                tmp[count]+=s[j];
            }
            else{
                count++;
            }
        }
        else break;
    }
    vi a;
    rep(i,count+1){
        a.pb(stoi(tmp[i]));
    }
    sort(ALL(a));
    
    int sum=0;
    rep(i,count/2+1){
        if(check==false)
            sum+=a[i]/2+1;
        else
            sum+=a[i];
    }
    return to_string((sum));
}


string delSpace(string s){  // "] [" を "][" に置き換え
    string ret="";
    rep(i,s.sz-2){
        if(s[i]==']' && s[i+1]==' ' && s[i+2]=='['){
            ret+="][";
            i+=2;
        }
        else{
            ret+=s[i];
        }
    }
    ret+=s[s.sz-2];
    ret+=s[s.sz-1];
    return ret;
}


int main(){
    int t;
    cin>>t;
    
    rep(times,t){
        string s;
        cin>>s;
        int check=false;
        s=pre(s);
        while(1){
            if(s.find("[",0)==-1)break;

            string n="";
    
            rep(i,s.sz){
                if(s[i+1]>='0' && s[i+1]<='9'){
                    n+=solve(i,check,s);
                    while(s[i]!=']')i++;
                }
                else{
                    n+=s[i];
                }
            }
            s=n;
            check=true;
        }
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 1524
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
    if(b == 0)
        return a;
    return gcd(b,a%b);
}
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> arr(n);
    for(int i = 0; i < n; ++i)
        scanf("%d",&arr[i]);
    sort(arr.begin(),arr.end());
    int g = 0;
    for(int i = 1; i < n; ++i)
        g = gcd(g,arr[i]-arr[i-1]);
    if(g == 0){
        if(arr[0] == k)
            puts("POSSIBLE");
        else
            puts("IMPOSSIBLE");
        return 0;
    }
    if(abs(k-arr[0]) % g == 0 && arr[n-1] >= k)
        puts("POSSIBLE");
    else
        puts("IMPOSSIBLE");
}


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

ll n, m;

inline ll read(){							//快读 
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read(), m = read();
	if (n == 1 || m == 1) puts("1");		//特判n或m是否为1 
	else printf("%lld\n", (n * m + 1) / 2);	//否则输出答案 
}

int main(){
	work();
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int main(int a, int b, int c) {
return scanf("%d%d%d",&a,&b,&c),puts((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5) ? "YES" : "NO"), 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const int INF=1e7;
const LL LINF=1e18;

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


Measured memory_bytes: 256
n = int(input())
adj = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    l = list(map(int, input().split()))
    if l[1] == 0:
        print(' '.join(list(map(str, adj[i]))))
        # continue
    else:
        for j in range(2,len(l)):
            adj[l[0]-1][l[j]-1] = 1
        print(' '.join(list(map(str, adj[i]))))
# for i in range(n):
    # print(' '.join(list(map(str, adj[i]))))
    


Measured memory_bytes: 5664
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(0)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define _ <<" "<<
const int MOD = 1000 * 1000 * 1000 + 7; // odd modulus
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int main()
{
    Fast_IO();
    int a , b ;
    cin >> a >> b ;
    if ( a == b )
        cout <<  "0" ;
    else if ( (a + b) % 2 == 0 ) cout << (a+ b )/ 2 ;

    else
        cout << "IMPOSSIBLE" ;
    return 0 ;
}
/*
1
5 3
7 18 3 14 1
*/


Measured memory_bytes: 256
def gcd(x,y):
    q = max(x,y)  %  min(x,y)
    if q == 0 :
        return min(x,y)
    return round(gcd(min(x,y),q))

def lcm(a, b):
    return  round(a*b / gcd(a, b))

while True:
    try:
        a, b = map(int,input().split())
        print(gcd(a,b),lcm(a,b))
    except EOFError:
        break



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

#define rep(i, N)   for(int i = 0; i < (int)N; i++)
const long long INF = 1LL<<60;

int main()
{
    string S;
    cin >> S;
    int k = 15;
    int tmp = 0;
    rep(i, S.size())
    {
        if(S.at(i) == 'o')
        {
            tmp++;
            k--;
        }
        else
        {
            k--;
        }
    }

    if(tmp >= 8)
    {
        cout << "YES" << endl;
    }
    else
    {
        if(k > 0)
        {
            if(tmp + k >= 8)
            {
                cout << "YES" << endl;
            }
            else
            {
                cout << "NO" << endl;
            }
        }
        else
        {
            cout << "NO" << endl;
        }
    }
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	string s,t;
	vector <char> str;
	getline(cin,s);
	getline(cin,t);
	int rows = s.length()+1;
	int cols = t.length()+1;
	int D[rows][cols];
	int i,j;
	for(i=0;i<cols;i++) D[0][i] = 0;
	for(i=0;i<rows;i++) D[i][0] = 0;
	for(i=1;i<rows;i++)
	{
		//int a=0;
		for(j=1;j<cols;j++)
		{
		//	cout<<"i = "<<i<<" j = "<<j<<" s["<<i-1<<"] = "<<s[i-1]<<" t["<<j-1<<"] = "<<t[j-1]<<"\n";
			if(s[i-1]==t[j-1]) 
			{ 
			//a++;
			//	if(find(str.begin(),str.end(),s[i])==str.end()) 
			//if(a==1)str.pb(s[i-1]);
			D[i][j] = D[i-1][j-1]+1;
			}
			else 
			{
				D[i][j] = max(D[i-1][j],D[i][j-1]);
			}
		}
	}
	i=rows-1;j=cols-1;
	while(i&&j)
	{
		if(s[i-1]==t[j-1])
		{
			str.pb(s[i-1]);
			i--;
			j--;
		}
		else if(D[i-1][j]>=D[i][j-1]) i--;
		else j--;
	}
//	cout<<s[i-1]<<" chara "<<t[j-1]<<"\n";
//	cout<<"size of lcs = "<<D[rows-1][cols-1]<<"\n";
reverse(str.begin(),str.end());
	for(i=0;i<str.size();i++) cout<<str[i];
	cout<<"\n";
	
}



Measured memory_bytes: 35456
import sys

n, *a = map(int, sys.stdin.read().split())

def main():
    x = 1
    for i in range(n):
        if a[i] == x:
            x += 1
    
    ans = n - (x - 1)
    return -1 if ans == n else ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 25116
#include <bits/stdc++.h>
#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// #define ll long long
// bool isEven(ll n) {return (n%2!=0)?false:true;}

using namespace std;

//atcoder - dp
//f

string s, t;

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

    int sl = s.length();
    int tl = t.length();   

    int a[sl+1][tl+1];

    for (int i = 0; i < tl+1; ++i)
    {
        a[0][i] = 0;
    }

    for (int i = 0; i < sl+1; ++i)
    {
        a[i][0] = 0;
    }


    for (int i = 1; i < sl+1; ++i)
    {
        for (int j = 1; j < tl+1; ++j)
        {
            if(s[i-1]==t[j-1])
                a[i][j] = 1 + a[i-1][j-1];
            else
                a[i][j] = max(a[i-1][j] , a[i][j-1]);
        }
    }

    // for (int i = 0; i < sl+1; ++i)
    // {
    //     for (int j = 0; j < tl+1; ++j)
    //     {
    //         cout<<a[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    stack<char> rev_ans;

    int row = sl, col = tl;

    while(row>0&&col>0)
    {
        if(a[row][col]>max(a[row-1][col], a[row][col-1]))
        {
            rev_ans.push(s[row-1]);
            row--;
            col--;
        }
        else
        {
            if(a[row-1][col]>a[row][col-1])
                row--;
            else
                col--;
        }
    }

    string ans = "";

    while(!rev_ans.empty())
    {
        char temp = rev_ans.top();
        rev_ans.pop();
        ans+=temp;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 35456