akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int main(){ _
	int n;
	cin >> n;
	vector<int> t(n, 0), m(n, 0);
	vector<int> pos, neg;
	for (int i = 0; i < n; i++){
		string s;
		cin >> s;
		for (char c : s){
			if (c == '(') t[i]++;
			else t[i]--;
			m[i] = min(m[i], t[i]);
		}
		m[i] = -m[i];
		if (t[i] >= 0) pos.push_back(i);
		else neg.push_back(i);
	}
	sort(pos.begin(), pos.end(), [&](int l, int r){
		return m[l] < m[r];
	});
	sort(neg.begin(), neg.end(), [&](int l, int r){
		int sum_l = t[l] + m[l];
		int sum_r = t[r] + m[r];
		return sum_l > sum_r;
	});
	vector<int> ord = pos;
	for (int j : neg) ord.push_back(j);
	int sum = 0;
	bool ok = true;
	for (int i : ord){
		if (sum < m[i]) ok = false;
		sum += t[i];
	}
	ok &= (sum == 0);
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;

	
	exit(0);
}


Measured memory_bytes: 22852
import java.io.*;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();

        int N = nextInt(), M = nextInt();
        Set<Integer> vals = new HashSet<>();
        for (int i = 0; i < M; i++) vals.add(nextInt());

        long mod = 1000000007;
        long[] ways = new long[N + 1];

        ways[0] = 1;

        for (int i = 1; i < ways.length; i++) {
            if (vals.contains(i)) ways[i] = 0;
            else ways[i] = (ways[i - 1] + (i - 2 >= 0 ? ways[i - 2] : 0)) % mod;
        }

        System.out.println(ways[N]);
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}

Measured memory_bytes: 45056
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

fn main() {
    input! {
        n: usize, k: usize,
        mut a: [f64; n],
    }

    a.sort_by_key(|&v| Reverse(OrderedFloat(v)));

    if k == 0 {
        println!("{}", a[0].ceil());
        return;
    }

    let mut ng = 0.0f64;
    let mut ok = a[0];
    'out: while ok - ng > 0.000001f64 {
        let mid = (ok + ng) / 2.;
        let mut count = 0;
        for &v in &a {
            count += (v / mid).ceil() as usize - 1;
            if count > k {
                ng = mid;
                continue 'out;
            }
        }
        ok = mid;
    }
    let ans = if (ok - ok.round()).abs() < 0.000001f64 {
        ok.round() as usize
    } else {
        ok.ceil() as usize
    };
    println!("{}", ans);
}


Measured memory_bytes: 6548
import itertools

n, m = map(int, input().split())

edges = []
for i in range(m):
    edges.append(tuple(map(int, input().split())))

reverse_edges = [e[::-1] for e in edges]
# print(edges)
# print(reverse_edges)
# print(edges + reverse_edges)
edges += reverse_edges

count = 0
start = 1
end = 1
for series in itertools.permutations(range(2, n + 1)):
    # print('candidate', series)
    start, end = 1, 1
    conflict = False
    for i in series:
        edge = (start, i)
        # print(edge)
        if edge not in edges:
            conflict = True
            # print('conflict', edge)
            break
        start = i
    if not conflict:
        count +=1

print(count)



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

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

    int32_t gochi = a[n - 1];

    int32_t usa;
    int32_t m = 2147483647;
    for (int32_t i = 0; i < n; i++) {
        if (abs(a[i] * 2 - gochi) < m) {
            usa = a[i];
            m = abs(a[i] * 2 - gochi);
        }
    }
    cout << gochi << " " << usa << endl;

    return 0;
}


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

int main() {
    int a, b, i, j;
    cin >> a >> b;
    while (a != 0 && b != 0) {
        for (j = 0; j < b; j++)
            cout << "#";
        cout << endl;
        
        for (i = 3; i <= a; i++){
            cout << "#";
            for (j = 3;  j <= b; j++)
            	cout << ".";
        	cout << "#" << endl;
   		}
        for (j = 0; j < b; j++)
            cout << "#";
        cout << endl << endl;;
        cin >> a >> b;
    }
    return 0;
}


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

// 根付き木なので高さ, 深さ, 親が一意に定まる
int root;
#define MAX_N 200001
vector<vector<int>>graph(MAX_N, vector<int>());
int par[MAX_N], depth[MAX_N], height[MAX_N]; // 0で初期化
void tree_init(int r){
    root = r;
    par[root] = -1;
    stack<int> st_op, st_cl;
    st_op.push(root);
    while (! st_op.empty()) {
        int t = st_op.top(); st_op.pop();
        st_cl.push(t);
        for (int x: graph[t]) {
            if (x == par[t]) continue;
            depth[x] = depth[t] + 1;
            par[x] = t;
            st_op.push(x);
        }
    }
    while (! st_cl.empty()) {
        int t = st_cl.top(); st_cl.pop();
        for (int x: graph[t]) {
            height[t] = max(height[t], height[x] + 1);
        }
    }
}

int main() {
    int N, u, v;
    cin >> N >> u >> v;
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    tree_init(v);
    int cnt = (depth[u] - 1) / 2;
    for (int i = 0; i < cnt; ++i) {
        u = par[u];
    }
    int ans = depth[u] + height[u] - 2;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n;
	cin>>n;
	string s="";
	while(n){
		n--;
		s+='a'+(n%26);
		n/=26;
	}
	reverse(s.begin(),s.end());
	cout<<s<<"\n";
}

Measured memory_bytes: 3628
# coding: utf-8
N=int(input())
S=list(input())
RGB=[[0,0,0] for i in range(N)]

ans=0

for i in range(1,N):
    k=-i
    if S[k]=="R":
        RGB[k-1][0]=RGB[k][0]+1
        RGB[k-1][1]=RGB[k][1]
        RGB[k-1][2]=RGB[k][2]
    elif S[k]=="G":
        RGB[k-1][0]=RGB[k][0]
        RGB[k-1][1]=RGB[k][1]+1
        RGB[k-1][2]=RGB[k][2]
    elif S[k]=="B":
        RGB[k-1][0]=RGB[k][0]
        RGB[k-1][1]=RGB[k][1]
        RGB[k-1][2]=RGB[k][2]+1

for i in range(N):
    for j in range(i,N):
        if S[i]!=S[j]:
            if S[i]=="R" and S[j]=="G" or S[i]=="G" and S[j]=="R":
                ans+=RGB[j][2]
                if 2*j-i<N:
                    if RGB[j][2]>0 and S[2*j-i]=="B":
                        ans-=1
            elif S[i]=="R" and S[j]=="B" or S[i]=="B" and S[j]=="R":
                ans+=RGB[j][1]
                if 2*j-i<N:
                    if RGB[j][1]>0 and S[2*j-i]=="G":
                        ans-=1
            elif S[i]=="B" and S[j]=="G" or S[i]=="G" and S[j]=="B":
                ans+=RGB[j][0]
                if 2*j-i<N:
                    if RGB[j][0]>0 and S[2*j-i]=="R":
                        ans-=1

print(ans)

Measured memory_bytes: 69420
# DDCC A
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(str, input().split()))
n=ni()
ST=[]
for i in range(n):
    st=nl()
    ST.append(st)
x=si()

idx=0
for i,sstt in enumerate(ST):
    if sstt[0]==x:
        idx=i
    ST[i][1]=int(ST[i][1])

idx+=1
ans=0
for i in range(idx,n):
    ans+=ST[i][1]
print(ans)





Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x);
P dequeue(void);
int isEmpty(void);
int isFull(void);
int min(int,int);

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  int time=0;
  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
 
  head = 1;
  tail = n+1;
  
  while(head!=tail){
    u=dequeue();
    c=min(q, u.t);
    u.t=u.t-c;
    elaps=elaps+c;
    if (u.t>0){
      enqueue(u);
    }
    else if(u.t<=0){
      printf("%s %d\n",u.name, elaps);
    }
  }
  
  return 0;
}
int isEmpty(){
  if(head == tail) return 1;
  else return 2;
}

int isFull(){
  if(head == ((tail+1)%LEN)) return 1;
  else return 2;
}

void enqueue(P x){
  if(isFull()==1){
    exit(1);
  }
  Q[tail] = x;
  if(tail+1==LEN){
    tail=0;
  }else{
    tail++;
  }
}    

P dequeue(){
  if(isEmpty()==1){
    exit(1);
  }
  P x=Q[head];
  if(head+1==LEN){
    head=0;
  }
  else{
    head++;
    return x;
  }
}
int min(int a, int b) {
  return a < b ? a : b;
}

Measured memory_bytes: 10756
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
#define IO ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL), cerr.tie(NULL);
typedef long long ll;
typedef long double ld;
 

 
ll MOD=1e9 + 7;
ll OO=1e15;
const int N=4e2 + 5,M=1e5 + 5;
ll arr[N];
ll dp[N][N];


ll n,m,k,cnt,SU,idx,len,MN,MX,T;
int l,r,mid;
int a,b,c;
string ans;

ll Solve(int l,int r){
	
	if(l == r)
		return arr[l]-arr[l-1];
	
	ll &ret = dp[l][r];
	if(~ret)
		return ret;
		
	ret = OO;
	for(int i=l;i<r;++i)
		ret = min(ret,arr[r]-arr[l-1] + Solve(l,i) + Solve(i+1,r));
		
	return ret;
	
}



int main(){
	IO
	memset(dp,-1,sizeof dp);
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>arr[i];
		arr[i]+=arr[i-1];
	}
		
	
	cout<<Solve(1,n) - arr[n]<<endl;
	

}





Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>

int N, M;
int num_cases = 0;
int adjacency_matrix[8][8] = {0};
int order_of_passage[8];

int main() {
  std::cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    order_of_passage[i] = i;
  }
  for (int i = 0; i < M; ++i) {
    int a, b;
    std::cin >> a >> b;
    --a;
    --b;
    adjacency_matrix[a][b] = 1;
    adjacency_matrix[b][a] = 1;
  }
  
  do { // Is the case possible?
    bool can_pass = true; 
    for (int i = 0; i < N - 1; ++i) { // Does the cooresponding edge exist?
      if (adjacency_matrix[order_of_passage[i]][order_of_passage[i+1]] == 0) {
        can_pass = false;
        break;
      }
    }
    if (can_pass) ++num_cases;
  } while (std::next_permutation(order_of_passage + 1, order_of_passage + N));
  std::cout << num_cases << std::endl;
}

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

int main() {
	int n;
	long long int a,b,c;
	cin>>n;
	long long int ar[n];
	for(int i=0;i<n;i++){
	    cin>>ar[i];
	}
	int s=sizeof(ar)/sizeof(ar[0]);
	sort(ar,ar+s);
    a=ar[n-1];
    b=ar[0];
	c=a-b;
	cout<<c;
}

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

int main()
{
    int height, width, now_value;

    while(cin >> height >> width)
    {
        if(width == 0 or height == 0) break;
        
        bool map[height][width];

        for(int i = 0; i < height; i++)
        {
            for(int j = 0; j < width; j++)
            {
                cin >> now_value;
                if(now_value == 0) map[i][j] = false;
                else map[i][j] = true;
            }
        }

        //先?行??，因?行比?少，最多有1024?
        //然后去?列?行分析，得到最多可能的正面数
        int total = 1 << height;
        int real_max = 0;
        for(int i = 0; i < total; i++)
        {
            //翻?
            for(int j = 0; j < height; j++)
            {
                //位与?定是否需要翻?
                if(i & (1 << j))
                {
                    for(int col = 0; col < width; col++) map[j][col] = not map[j][col];
                }
            }

            //??最大?
            int max = 0;
            for(int col = 0; col < width; col++)
            {
                int total_one = 0;
                for(int row = 0; row < height; row++)
                {
                    if(map[row][col]) total_one++;
                }
                max += (total_one > height - total_one) ? total_one : height - total_one;  //位1的或者可以翻成1的?入
            }

            if(max > real_max) real_max = max;

            //?原
            for(int j = 0; j < height; j++)
            {
                //位与?定是否需要翻?
                if(i & (1 << j))
                {
                    for(int col = 0; col < width; col++) map[j][col] = not map[j][col];
                }
            }
        }

        cout << real_max << endl;
    }

return 0;
}

/*
?目附?
翻?子，??一些?子数量是W*H，?次可以反一行或一列。
?能同?最多使多少个?子正面朝上，０表示背面，１表示正面。
其中1 ? R ? 10, 1 ? C ? 10000，行少列多。
*/

Measured memory_bytes: 1256
<?php
list($k, $x) = ints();
for($i = $x-$k+1; $i <= $x+$k-1; $i++){
  $list[] = $i;
}
echo implode(" ", $list);

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

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



int main(){
     int n,l;
     cin>>n>>l;
     vector<string> s(n);
     for(int i=0;i<n;++i){
          cin>>s[i];
     }
     sort(s.begin(),s.end());

     for(int i=0;i<n;++i){
          cout<<s[i];
     }
cout<<endl;
}


Measured memory_bytes: 256
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(input())
a = list(range(1,K+1))
b = list(range(1,K+1))
c = list(range(1,K+1))
Sum = 0
for i in a :
    for j in b:
        for k in c:
            S = gcd(i,j,k)
            Sum = Sum + S
print(Sum)

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N, K, X, Y;
    cin >> N >> K >> X >> Y;
    cout << N * X - std::max((ll)0, N - K) * (X - Y) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 2000
int i, n,q,A[N],mi[N];
int solve(int i, int m){
  if(m == 0) return 1;
  if(i >= n) return 0;
  int res=solve(i+1,m)||solve(i+1,m-A[i]);
   return res;
}

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

  for(i=0;i<q;i++){
  
    if(solve(0,mi[i]) == 1)printf("yes\n");
    if(solve(0,mi[i]) == 0)printf("no\n");
  }
  return 0;
}

Measured memory_bytes: 584
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

int n, m;
vector<pair<int, int>> ab;
bool seen[50];
vector<int> G[50];
pair<int, int> rempair;

void dfs(int now) {
    seen[now] = true;
    rep(i, G[now].size()) {
        int nex = G[now][i];
        if ((nex == rempair.first && now == rempair.second) ||
            (now == rempair.first && nex == rempair.second)) {

        } else if (!seen[nex]) {
            dfs(nex);
        }
    }
}

void solve() {
    int ans = 0;
    rep(i, m) {
        rempair = ab[i];
        fill(seen, seen + n, false);
        dfs(0);
        rep(j, n) {
            if (!seen[j]) {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> n >> m;
    ab.resize(m);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        ab[i] = (make_pair(a, b));
    }
    solve();
    return 0;
}

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

int main() {
  int d,n;
  cin >> d >> n;
  int ans = 1;
  int i = d;
  while(i--) ans *= 100;
  if(d == 0 && n == 100) cout << "101" << endl;
  else if(d == 1 && n == 100) cout << 101 * 100 << endl;
  else if(d == 2 && n == 100) cout << 101 * 10000 << endl;
  else cout << ans * n << endl;
}


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

map<long long, long long> mp;

void print(){
    map<long long, long long>::iterator it;
    long long sum=0;
    for(it=mp.begin();it!=mp.end();it++){
        pair<long long, long long> item = *it;
        sum+=item.second*(item.second-1)/2;
    }
    cout << sum << endl;
}

int main(){
    long long n, a, sum=0;
    cin >> n;
    mp[sum]++;
    for(int i=1;i<=n;i++){
        cin >> a;
        sum+=a;
        mp[sum]++;
    }
    print();
    return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
int MAX = 100000+10;
long long fac[100010], finv[100010], inv[100010];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 100010; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	init();
	ll A,B;cin>>A>>B;
	if(A%3==0 || B%3==0 || (A+B)%3==0){
		cout<<"Possible"<<endl;
	}else cout<<"Impossible"<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	int N;cin>>N;
	vector<int>v(N);
	for(int i=0;i<N;i++)cin>>v[i];
	sort(v.begin(), v.end());

	double ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans += 1. * v[i] / pow(2, N-max(i,1));
	}
	
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define le 3003
using namespace std;
int dp[le][le];
string fnc(string s, string t, int i, int j){
    if(i == 0 || j == 0) return "";
    if(s[i - 1] == t[j - 1]) return fnc(s, t, i - 1, j - 1) + s[i - 1];
    else if(dp[i - 1][j] > dp[i][j - 1]) return fnc(s, t, i - 1, j);
    return fnc(s, t, i, j - 1);
}
int main(){
    //freopen("input.txt", "r", stdin);
    string s, t;
    cin >> s >> t;
    for(int i = 1; i < s.size() + 1; i++){
        for(int j = 1; j < t.size() + 1; j++){
            if(s[i - 1] == t[j - 1]) dp[i][j] = 1 + dp[i - 1][j - 1];
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    if(dp[s.size()][t.size()] == 0) cout << "" << endl;
    else cout << fnc(s, t, s.size(), t.size()) << endl;
    return 0;
}


Measured memory_bytes: 68668
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	if (n % 2 == 0)
		printf("0.50000000000000\n");
	else
		printf("%.20lf", (double)(n / 2 + 1.0) / (double)n);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    long int a;
    cin >> a;

    long int list[a];

    for (long int i = 0; i < a; i++)
    {
        cin >> list[i];
    }

    long int counter = 0;
    long int b = 200000;
    for (long int i = 0; i < a; i++)
    {
        if (list[i] <= b)
        {
            b = list[i];
            counter = counter + 1;
        }
    }

    cout << counter << endl;
    return 0;
}

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

int _abc101_a(string& s) {
	int result = 0;
	const char* c = s.c_str();
	while (*c != 0) {
		if (*c == '+') {
			result++;
		}
		else if (*c == '-') {
			result--;
		}
		c++;
	}

	return result;
}

int main()
{
	string s;
	cin >> s;
	cout << _abc101_a(s) << endl;
	
	return 0;
}



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

using namespace std;

#define int long long
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define N 10005
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
int mod=1e9+7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x;}
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int h,w;
char a[N][N];
int cache[N][N];

int dp(int i,int j){
    if(i>=h) return 0;
    if(j>=w) return 0;
    if(i==h-1&&j==w-1) return 1;
    if(a[i][j]=='#') return 0;

    int &ans=cache[i][j];

    if(ans!=-1) return ans;
    else ans=dp(i+1,j)+dp(i,j+1);

    ans%=mod;
    return ans;
}

int32_t main() {
    faster;

    cin>>h>>w;
    mm1(cache);

//    a.assign(h,vint(w,'0'));
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>a[i][j];

    int ans=dp(0,0);
    cout<<ans<<endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	vector<queue<char>>s(3);
	for(int i=0;i<3;++i){
		string a;
		cin>>a;
		for(auto&j:a)s.at(i).push(j);
	}
	for(int i=0,tmp;;){
		if(s.at(i).size()==0){
			cout<<static_cast<char>('A'+i)<<"\n"s;
			break;
		}
		tmp=s.at(i).front()-'a';
		s.at(i).pop();
		i=tmp;
	}
}

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

int main() {
  int a, N, A;
  cin >> N >> A;
  
  if (N >= 500){
   a = (N % 500);
    if (A >= a){
      cout << "Yes" << endl;
    }
    else {
     cout << "No" << endl;
    }
  }
  else if (N < 500){
    if (A >= 500){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 256
class BIT():
    def __init__(self,n):
        self.dat = [0]*(n+1)

    def add(self,a,x):
        i = a
        while i < len(self.dat):
            self.dat[i] = self.dat[i] + x
            i += i & -i

    def sum(self,a):
        res = 0
        i = a
        while i > 0:
            res += self.dat[i]
            i -= i & -i
        return res

n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
tmp = BIT(n)
dic = {}
for i in range(len(b)):
    dic[b[i]] = i+1

ans = 0
for j in range(n):
    ans += j - tmp.sum(dic[a[j]])
    tmp.add(dic[a[j]],1)
print(ans)


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

from math import factorial
from itertools import combinations
from collections import Counter
from copy import deepcopy
from operator import mul
from functools import reduce

def main():
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())
    r = 0
    for ia in range(a + 1):
        for ib in range(min(b + 1, (x - ia * 500)//100 + 1)):
            r +=  (x - ia * 500 - ib * 100) // 50 <= c

    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
def resolve():
    s = int(input())
    print(str.lower(num2alpha(s)))
resolve()

Measured memory_bytes: 9168
#define _USE_MATH_DEFINES 1
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007ll
#define INF 1000000000000000000ll
#define EPS 1e-9
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock

typedef long long         ll;
typedef long double       ld;
typedef pair <ll,ll>      pl;
typedef tuple <ll,ll,ll>  tl;

ll TC, X, N, R;
bool A[105];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	TC = 1;
	
	for (ll q = 1; q <= TC; q++) {
		
		cin >> X >> N;
		memset(A, 1, sizeof A);
		for (ll i = 1; i <= N; i++) {
			ll e;
			cin >> e;
			A[e] = 0;
		}
		
		for (ll d = 0; d <= 200; d++) {
			if (X-d < 1 || A[X-d] == 1) {
				R = X-d;
				break;
			}
			if (X+d > 100 || A[X+d] == 1) {
				R = X+d;
				break;
			}
		}
		
		cout << R << "\n";
	
	}
	
    return 0;
}















Measured memory_bytes: 3652
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath> 
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second
const lint MOD = (lint)1e9 + 7;

signed main(){
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<lint> > dp(H+10, vector<lint>(W+10, 0));
    dp[0][0] = 1;
    FOR(i, 1, W+1) dp[0][i] = 0;
    REP(i, H){
        REP(j, W){
            lint x, y, z;
            x = y = z = 0;
            for(int b=0; b<(1<<(W-1)); ++b){
                bool adjacentEdges = false;
                // adjacent edges should not exist
                for(int k=1; k<W-1; ++k){
                    if(b&(1<<k) and (b&(1<<(k-1)) or b&(1<<(k+1)))){
                        adjacentEdges = true;
                        break;
                    } 
                }
                if(adjacentEdges) continue;

                if(b&(1<<(j-1))) x++;
                else if(b&(1<<j)) y++; 
                else z++;
                x %= MOD;
                y %= MOD;
                z %= MOD;
            }
            dp[i][j] %= MOD;
            if(j>0) dp[i+1][j-1] += (x * dp[i][j])%MOD;
            if(j<W-1) dp[i+1][j+1] += (y * dp[i][j])%MOD;
            dp[i+1][j] += (z * dp[i][j])%MOD;
        }
    }
    cout << dp[H][K-1]%MOD << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct
{
    int S[1000];
    int top;
    void inti()
    {
        memset(S,0,sizeof(S));
    }
    void push(int x)
{
    S[++top]=x;
}
int pop()
{
    top--;
    return S[top+1];
}
}mystack;
int main()
{
    mystack.inti();
    int a,b;
    char s[100];
    while(scanf("%s",s)!=EOF)
    {
        if(s[0]=='+')
        {
            a=mystack.pop();
            b=mystack.pop();
            mystack.push(a+b);
        }
        else if(s[0]=='-')
        {
            b=mystack.pop();
            a=mystack.pop();
            mystack.push(a-b);
        }
        else if(s[0]=='*')
        {
            a=mystack.pop();
            b=mystack.pop();
            mystack.push(a*b);
        }
        else mystack.push(atoi(s));
    }
    printf("%d\n",mystack.pop());
    return 0;
}

Measured memory_bytes: 2712
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    cin>>s;
    int dp[s.length()+1][13]={};
    dp[0][0]=1;
    rep(i,s.length()){
        rep(j,10){
            if(s[i]!='?'&&s[i]-'0'!=j)continue;
            rep(k,13){
                dp[i+1][(k*10+j)%13]=(dp[i+1][(k*10+j)%13]+dp[i][k])%mod;
            }
        }
    }
    cout<<dp[s.length()][5]<<endl;
}

Measured memory_bytes: 10704
#include <iostream>
#include <stdio.h>
#include <vector>
#include <functional>
#include <unordered_set>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

const int N = 1e4;
const int MOD = 1e9 + 7;

template <class T>
void add(T &a, const T b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

long double DP[N];
long double DP2[N];

long double Sum(long double* begin, long double* end) {
	long double ans = *begin++;
	long double c = 0;
	while (begin != end) {
		long double t = ans + *begin;
		if (abs(ans) >= abs(*begin)) {
			c += (ans - t) + *begin;
		} else {
			c += (*begin - t) + ans;
		}
		ans = t;
		begin++;
	}
	return ans + c;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	long double* dp = DP + N / 2;
	long double* dp2 = DP2 + N / 2;
	dp[0] = 1;
	for (int iter = 0; iter < n; ++iter) {
		long double p;
		cin >> p;
		memset(DP2, 0, sizeof(DP2));
		for (int i = -iter; i <= iter; ++i) {
			add(dp2[i + 1], dp[i] * p);
			add(dp2[i - 1], dp[i] * (1 - p));
		}
		swap(DP, DP2);
	}
	cout.precision(20);
	long double ans = 1 - Sum(dp - n, dp);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

const int MAX_INT = 2147483647;

using namespace std;
int main(){
    int x,e,m,ypi,zpi;
    while(true){
        cin >> e;
        if(e==0) break;
        int minM=MAX_INT;
        for(int zi=0;zi<=100;zi++){
            zpi=zi*zi*zi;
            if (e-zpi<0) break;
            for(int yi=0;yi<=1000;yi++){
                ypi=yi*yi;
                if(e-ypi-zpi<0) break;
                x=e-ypi-zpi;
                m=x+yi+zi;
                minM=min(minM,m);
            }
        }
        cout << minM << endl;
    }
    return 0;
}

Measured memory_bytes: 3052
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);
    
    //変数a, b, cを宣言と入力
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int divisorCount = 0;
    
    //約数の個数を探す（割り切れる＝約数が）ある
    for(int i = a; i <= b; i++){
        if(c % i == 0) divisorCount++;
    }

    //約数の個数を表示
    System.out.println(divisorCount);
        
    }
}


/*覚えよう！！
  
 今回は無し
　　
*/
   
   
/*前回の内容！！
 
〇import java.util.Arrays;は重要↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
 
・Arrays：ソート（並べ変え）や検索など、配列を操作するための機能
 
・並べ変えするとき
　import java.util.Arrays;を上に書く
　class Main内に Arrays.sort(a); と書く　←　このとき()内は配列の変数名
　
〇配列とは、同じ変数名に複数の値を入力できる箱
 
　※イメージ
    前回まで、a = 1, b = 2, c = 3など各変数名は1箱に値を代入できない
    今回の配列はa[0] = 1, a[1] = 2, a[2] = 3 のように変数名aは3つの箱に値を代入できる。
    注意：配列の箱は｢ 0 ｣から開始する
 
 
・複数のif(条件)：かつ｢ && ｣とまたは｢ || ｣の２つを使用する
　※かつ｢ && ｣：「真 && 真 = 真」, 「真 && 偽 = 偽」, 「偽 && 真 = 偽」 ,「偽 && 偽 = 偽」の4つの条件
　　または｢ || ｣：「真 && 真 = 真」, 「真 && 偽 = 真」, 「偽 && 真 = 真」 ,「偽 && 偽 = 偽」の4つの条件
 
 
・関係を比較する：if(条件式)
　例：if(2 < 3) この条件は｢真（成立）｣　→　何か命令があれば実行する
　　　if(5 < 3) この条件は｢偽（不成立）｣　→　何か命令があれば実行しない
　　　
・比較の条件式：等しいか比較｢==｣、等しくないか比較｢!=｣ 
　　　　　　　　大きいか比較｢<｣、小さいか比較｢>｣
　　　　　　　　以上の比較｢<=｣、以下の比較｢>=｣
  
  
・else；ifの条件以外の場合に使用する。
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else System.out.println("傘を持って行かない");
　
  
・else if：詳細な場合分けしたいときに使用
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else if(雨 == 午後から降るかも) System.out.println("念のため傘を持って行く");
　　　else System.out.println("傘を持って行かない");
  
 
  
・変数に計算結果を代入する：面積　＝　縦　×　横
　※計算は変数名でも数値でもいける
   
・四則演算：足し算｢＋｣、引き算｢－｣、掛け算｢＊｣、割り算｢／｣
　1 + 2 = 3;
　4 - 3 = 1;
　2 * 5 = 10;
　8 / 2 = 4;
   
・余りの計算：割り算の余り｢％｣
  5 % 3 = 2;
     
     
・printlnの複数表示：｢＋｣を使用
　例：println("Kobe" + "Kagikou"); = KobeKajikou
　　　println("明治 + 20 + "年"); = 明治20年　数値が入ってもOK！
   
   
   
・変数の宣言は｢型｣と｢変数名｣の２つ必要
　例：型＿変数名　→　int x;
　
・キーボードから入力するときは・・・｢ import java.util.Scanner; ｣ と ｢  Scanner sc = new Scanner(System.in) ; ｣が必要
   
・入力するとき・・・変数名 = sc.nextInt(); nextの後は型を書く、頭文字は大文字　
　※  scは変更しても大丈夫しかし全て変更後の文字に統一　例：nyuryoku
   
・println・・・画面に出力するときに使用
   
・文字列の表示・・・"〇〇〇の間に入力"ことが約束
   
*/


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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

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

int main() {
	int r; scanf("%d", &r);
	printf("%d\n", r*r);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<bitset>
#include<functional>
#include<iterator>
#include<complex>
#include<fstream>
#include<random>
#include<ctype.h>
#include<stdio.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using PII = pair<ll, ll>;
using piii = pair<pii, pii>;
using Pi = pair<int, pii>;
using Graph = vector<vector<int>>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
bool check(int x, int y) {
	if (0 <= x && x<55 && 0 <= y && y<55)return true;
	else return false;
}
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;

//iの逆元mod inf
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const double PI = 3.14159265358979323846;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
double Euclidean_distance(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

//素因数分解
map<int, int>prime_factor(int n) {
	map<int, 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;
}


ll powmod(ll a, ll k, ll mod) {
	ll ap = a, ans = 1;
	while (k) {
		if (k & 1) {
			ans *= ap;
			ans %= mod;
		}
		ap = ap * ap;
		ap %= mod;
		k >>= 1;
	}
	return ans;
}
ll invi(ll a, ll mod) {
	return powmod(a, mod - 2, mod);
}
#define PI 3.14159265358979323846  // 円周率
//逆元Aを足したときのmodで割った余りは
//+=invi(A)
//Yで割ることはY^(10^9+7)-2を掛けることは同値
///////////////////////////////////////
bool is_prime(int n) {
	for (int i = 2; i*i <= n; ++i) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


int main() {
	int a; cin >> a;
	cout << a + a * a + a * a*a << endl;
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int a, b, c ;
    cin >> a >> b >> c;
    if(a+b+c>=22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    int caseNum = 1;
    while(true) {
      int data = Integer.parseInt(br.readLine());
      if(data == 0) {
        break;
      }
      sb.append("Case ").append(Integer.toString(caseNum++)).append(": ").append(Integer.toString(data)).append("\n");
    }
    System.out.print(sb);
  }
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  int count = 0;
  bool flag = true;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++) {
      char a;
      cin >> a;
      if (a == '#'){
        if (count == j) count++;
        else flag = false;
      }
    }
    count--;
  }
  
  if (flag == true) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

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

static const int MAX_N = 100000;

int N;
int t[MAX_N], x[MAX_N], y[MAX_N];

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> t[i];
    cin >> x[i];
    cin >> y[i];
  }

  int px=0, py=0, nx=0, ny=0, pt=0, nt=0;

  for(int i = 0; i < N; i++){
    pt=nt;
    px=nx;
    py=ny;
    nt=t[i];
    nx=x[i];
    ny=y[i];
    int value = nx-px+ny-py-(nt-pt);
    if(value>0 || value%2!=0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
  int K=0,A=0,B=0,a=0,b=0,c=0,d=0;
  
  scanf("%d %d %d",&K,&A,&B);
  
  a=A/K;
  b=B/K;
  c=A%K;
  d=B%K;
  
  if(c==0) 
  {
    printf("OK");
  }
  
  else
  {
    if(d==0)
    {
      printf("OK");
    }
    else
    {
      if((b-a)>0)
      {
        printf("OK");
      }
      else
      {
        printf("NG");
      }
   }
    return 0;
  }
}

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

	int r, d, prev;
	cin >> r >> d >> prev;
	for (int i = 1; i <= 10; i++) {
		int curr = prev * r - d;
		cout << curr << "\n";
		prev = curr; 
	}

    return 0;
}


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

int main(){
  string s;
  cin>>s;
  bool ans=false;
  for(int i=0;i+1<s.size();i++){
    if(s[i]=='A'&&s[i+1]=='C'){
      ans=true;
    }
  }
  cout<<( ans ?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
long long para[1200][4];
long long f[1200];
long long res,cand;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>para[i][1]>>para[i][2]>>para[i][3];
	for(int i=0;i<8;i++){
		for(int k=1;k<=n;k++){
			f[k]=0;
		}
		int t=i;
		for(int j=1;j<=3;j++){
			for(int k=1;k<=n;k++){
				f[k]+=para[k][j]*(t%2==0?1:-1);
			}
			t/=2;
		}
		sort(f+1,f+n+1);
		reverse(f+1,f+n+1);
		cand=0;
		for(int j=1;j<=m;j++)
			cand+=f[j];
		res=max(res,cand);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 62) - 1;

int main(void)
{
    int n, k, h;
    int i;
    int ans = 0;

    cin >> n >> k;

    rep(i, 0, n)
    {
        cin >> h;

        if (h >= k)
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n;
    cin >> n;
    ll counts[n];
    memset(counts,0,n*sizeof(ll));
    for(ll i = 1;i < n;i++){
        ll x;
        cin >> x;
        x--;
        counts[x]++;
    }
    for(ll i = 0;i < n;i++){
        cout << counts[i] << endl;
    }
}

Measured memory_bytes: 5148
import os
import sys

import numpy as np

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

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))

A = np.array(A)
B = np.array(B)

diffs = A - B

count = (diffs < 0).sum()
insufficient = -diffs[diffs < 0].sum()

diffs.sort()
redundant = diffs[diffs > 0][::-1]

sub = np.searchsorted(redundant.cumsum(), insufficient) + 1

if insufficient == 0:
    print(0)
elif sub > len(redundant):
    print(-1)
else:
    print(count + sub)


Measured memory_bytes: 27304
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

#define pt(s)      cerr << s << endl
#define pt(a, b)      cerr << a << " "  << b << endl
#define MEM(a,b)    memset(a, b, sizeof(a))
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define MP(a, b)    make_pair(a, b)
#define PAIR(a, b)  pair<int, int>(a, b)

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

const int MOD = 1e9 + 7;
const int maxn = 1;
const double EPS = 1e-8;


class BAtCoderBeginnerContest111 {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n;
		in >> n;
		int t = 111, i;
		for (i = 1; i <= 9 ; ++i) {
			if(t * i >= n)break;
		}
		out << t * i;
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	BAtCoderBeginnerContest111 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

numbers = []
sumN = []
while True:
    number = input()
    if number == '0':
        break
    numbers.append(number)
    
for x in numbers:
    value = 0
    for y in x:
        value += int(y)
    sumN.append(value)

for x in sumN:
    print(x)

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

int sumDigit(int a, int b){
    int sd=0;
    while (a > 0) {
        sd += a % 10;
        a /= 10;
    }
    while (b > 0) {
        sd += b % 10;
        b /= 10;
    }

    return sd;
}

int main(){
    int N, min=INT_MAX;

    cin >> N;
    for(int i=1; i<N; i++){
        int j = N - i;
        int sd;

        sd = sumDigit(i, j);
        if(sd < min) min = sd;
    }

    cout << min << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    sort(a.begin(), a.end());
    printf("%d ", a[n-1]);

    int t = 0;
    int diff = abs(a[n-1] - a[0] * 2);
    for (int i = 1; i < n; i++) {
        int diff2 = abs(a[n-1] - a[i] * 2);
        if (diff > diff2) {
            diff = diff2;
            t = i;
        }
    }
    printf("%d", a[t]);

    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    class P
    {
        public int index;
        public List<int> ads;

        public P(int index)
        {
            this.index = index;
            ads = new List<int>();
        }
    }
    static void Main(string[] args)
    {
        var nm = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ab = new int[nm[1]][];
        for (var i = 0; i < nm[1]; i++)
        {
            var s = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            ab[i] = new int[2];
            ab[i][0] = s[0];
            ab[i][1] = s[1];
        }
        var result = 0;
        for (var i = 0; i < nm[1]; i++)
        {
            var ps = new P[nm[0]];
            for (var j = 0; j < nm[0]; j++) ps[j] = new P(j);
            for (var j = 0; j < nm[1]; j++)
            {
                if (i == j) continue;
                ps[ab[j][0]-1].ads.Add(ab[j][1]-1);
                ps[ab[j][1]-1].ads.Add(ab[j][0]-1);
            }
            var s = new HashSet<int>();
            iscorr(ps, s, 0);
            if (s.Count != nm[0]) result++;
        }
        WriteLine(result);
    }

    private static void iscorr(P[] ps, HashSet<int> set,int index)
    {
        set.Add(index);
        foreach (var p in ps[index].ads)
        {
            if (!set.Contains(p)) iscorr(ps, set,p); 
        }
    }
}


Measured memory_bytes: 11476
N = int(input())
 
lis = [0]*60
 
for a in input().split():
    a = int(a)
    for i in range(60):
        lis[i] += a % 2
        a = a//2
ans = 0
for i, j in enumerate(lis):
    ans += j * (N-j) *(2**i)
    ans = ans % (10**9 + 7)
 
print(ans)

Measured memory_bytes: 122936
N = int(input())
A = [int(a) for a in input().split()]

mod = 10**9+7
A.sort(reverse=True)
i = 0
ans = 1
while i < N-1:
    if A[i] == A[i+1] and A[i] == N-i-1:
        ans *= 2
        ans %= mod
        i += 2
    else:
        ans = 0
        break

if N%2 == 1 and A[-1] != 0:
    ans = 0

print(ans)

Measured memory_bytes: 13880