akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace _0239
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                int[,] x = new int[n, 4];
                for (int i = 0; i < n; i++)
                {
                    int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    x[i, 0] = a[0]; x[i, 1] = a[1]; x[i, 2] = a[2]; x[i, 3] = a[3];
                }
                int[] hikaku = Console.ReadLine().Split().Select(int.Parse).ToArray();
                bool found = false;
                for (int i = 0; i < n; i++)
                {
                    if (hikaku[0] >= x[i, 1] && hikaku[1] >= x[i, 2] && hikaku[2] >= x[i, 3] && hikaku[3] >= x[i, 1] * 4 + x[i, 2] * 9 + x[i, 3] * 4)
                    {
                        found = true;
                        Console.WriteLine(x[i, 0]);
                    }
                }
                if (!found) Console.WriteLine("NA");
            }
        }
    }
}

Measured memory_bytes: 9736
#include<bits/stdc++.h>
using namespace std;
//define
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define elif else if
//vectordefine
#define vint vector<int>
#define vc vector<char>
#define vtr vector<string>
#define pb(n) push_back(n)
//queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
//mapdefine
#define mint map<int>
#define mc map<char>
//pairdefine
#define pint pair<int,int>
#define pis pair<int,str>
#define pic pair<int,char>
#define pci pair<char,int>
#define mod 100000007

string syugei(int N){
  string ST="b";
  for(int i=0;i<N;i++){
    if(i%3==0||i==0)ST="a"+ST+"c";
    else if(i%3==1||i==1)ST="c"+ST+"a";
    else if(i%3==2||i==2)ST="b"+ST+"b";
  }
  return ST;
}
//main
signed main(){
  int N,M,O,P,X,count=0,count2=0;
  double D;
  int c='A'-'a';
  char C;
  str S,T;
  cin>>N>>M;
  cout<<max(N+M,max(N-M,M*N))<<endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll ans=0;
    string s;
    cin>>s;
    for(char x:s){
        if(x=='+')ans++;
        else ans--;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int ans =  0;
		for(int i = 1;i <= n/2;i++){
			if(i != n-i){
				ans++;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 20308
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }

int main() {
	
	long N; cin >> N;
	long res = 0;

	long A[200009]; for (int i = 1; i <= N; i++) cin >> A[i];

	long cumulp[200009] = {}, cumulx[200009] = {};  for (int i = 1; i <= N; i++) { cumulp[i] = cumulp[i - 1] + A[i]; cumulx[i] = cumulx[i - 1] ^ A[i]; }

    long r = 1;
	for (int l = 1; l <= N ; l++) {
			while (cumulp[r] - cumulp[l - 1] == (cumulx[r] ^ cumulx[l - 1]) && r < N + 1) r++;
            r--;
  			res += r - l + 1;
	}

	cout << res << endl;
}

Measured memory_bytes: 4992
# coding: utf-8

# 入力１行目：4桁の整数(１文字列)
n = gets.to_i
p_list = gets.split.map(&:to_i)

counter = 0
p_list.each_cons(3) do |a,b,c|
    counter += 1 if a < b and b < c
    counter += 1 if c < b and b < a
end

puts counter

Measured memory_bytes: 1788
import copy
n = int(input())
s =[int(input()) for _ in range(n)]
ans = 0
s_c = copy.copy(s)
s_c.sort()

if sum(s) % 10 == 0:
    for i in range(n):
        if (sum(s)- s_c[i]) % 10 != 0:
            ans = sum(s) - s_c[i]
            break
else:
    ans = sum(s)
    
print(ans)

Measured memory_bytes: 3444
K,A,B=map(int,input().split())
#X:ビスケットの個数
X=1
#Y:現時点での操作回数
Y=0
if A-1>K:
    print(K+1)
    exit()
X=A
Y=A-1
if B-A<=1:
    print(K+1)
    exit()
X+=(B-A)*((K-Y)//2)
Y+=2*((K-Y)//2)
X+=(K-Y)
print(X)


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k,d,a,cnt=0;
	cin>>n>>k;
	vector<bool>f(n);
	for(int i=0;i<k*2;i++){
		if(i%2==0){
			cin>>d;
		}else{
			for(int j=0;j<d;j++){
				cin>>a;
				f.at(a-1)=true;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(f.at(i)==true)cnt++;
	}
	cout<<n-cnt<<endl;
	return 0;
}


Measured memory_bytes: 3652
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();
    let S = buf_it.next().unwrap();
    let w = buf_it.next().unwrap().parse::<usize>().unwrap();

    let n = S.len();
    println!("{}",(0..n).filter(|&i| i%w==0).fold(String::new(),|x,y| x + &S[y..y+1]));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


class UnionFind{
public:
    UnionFind(int n){
        size = n;
        parent = vector<int>(size,-1);
    }
    int getSize(){return size;}
    int getParentElement(int index){return parent[index];}
    void printParent(){
        for(auto v: parent) {cout << v << " ";}
        cout << endl;
    }
    int find(int x){
        int a = x;
        vector<int> children;
        while(parent[a]>=0){
            children.push_back(a);
            a = parent[a];
        }
        for(auto child: children){parent[child] = a;}
        return a;
    }
    int Union(int x,int y){
        int root_x = find(x);
        int root_y = find(y);
        if(root_x != root_y){
            if(parent[root_x]>=parent[root_y]){
                parent[root_x] += parent[root_y];
                parent[root_y] = root_x;
            }else{
                parent[root_y] += parent[root_x];
                parent[root_x] = root_y;
            }
        }
        return parent[root_x];
    }
private:
    int size;
    vector<int> parent;
};

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

    vector<int> a(m), b(m);
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    reverse(all(a));
    reverse(all(b));
    vector<ll> inconvenient(m+1,(ll)n*(n-1)/2);
    for(int i = 0; i < m; i++){
        if(uf.find(a[i]) == uf.find(b[i])){
            inconvenient[i+1] = inconvenient[i];
        }else{
            int old_size_a = -1*uf.getParentElement(uf.find(a[i]));
            int old_size_b = -1*uf.getParentElement(uf.find(b[i]));
            int newparent = uf.Union(a[i],b[i]);
            int new_size = old_size_a + old_size_b;
            inconvenient[i+1] = inconvenient[i] + (ll)old_size_a*((ll)old_size_a-1)/2 + (ll)old_size_b*((ll)old_size_b-1)/2;
            inconvenient[i+1] -= (ll)new_size*(new_size-1)/2;
        }
    }

    for(int i = m-1; i >= 0; i--){
        cout << inconvenient[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3328
K = int(input())

N = 50
a = [0] * N

m = K // N
mod = K % N

for i in range(0, mod):
    a[i] = N * (m + 2) - K + m

for i in range(mod, N):
    if m != 0:
        a[i] = N * (m + 1) - K + m - 1

print(N)
print(' '.join([str(x) for x in a]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
int N,M,A[100000+10]={};
pair<int,int> Q[100000+10];

signed main(){
  cin >> N >> M;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=0;i<M;i++){
    cin >> Q[i].second >> Q[i].first;
  }
  sort(Q,Q+M);
  reverse(Q,Q+M);
  sort(A,A+N);

  int k=0,i;
  for(int j=0;j<M;j++){
    if(k>=N) break;
    for(i=k;i<k+Q[j].second;i++){
      if(A[i]>Q[j].first) break;
      if(i>=N) break;
      A[i]=Q[j].first;
    }
    k=i;
  }
  int ans=0;
  for(int i=0;i<N;i++){
    ans+=A[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
n = input()

INFTY = 1000000
color = [0 for i in xrange(n)]
d = [INFTY for i in xrange(n)]
M = [[INFTY for i in xrange(n)] for i in xrange(n)]
p = [-1 for i in xrange(n)]

def SSSP1():
    d[0] = 0

    while True:
        cost = INFTY
        for i in xrange(n):
            if color[i] != 2 and d[i] < cost:
                cost = d[i]
                u = i
            
        if cost == INFTY:
            break
        color[u] = 2
    
        for v in xrange(n):
            if color[v] != 2 and M[u][v] != INFTY and d[u] + M[u][v] < d[v]:
                d[v] = d[u] + M[u][v]
                p[v] = u
                color[v] = 1
    
    for i in range(n):
        if d[i] != INFTY:
            print i, d[i]

for i in xrange(n):
    G = map(int, raw_input().split())
    for j in xrange(G[1]):
        M[G[0]][G[(j+1)*2]] = G[j*2+3]
SSSP1()

Measured memory_bytes: 6468
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll min(ll x, ll y){
    if(x<y)return x;
    return y;
}
int a[50];
int b[50];
int p[50][50];

int par[50], rk[50];
void init(int n){
    for(int i = 0;i < n;i++){
        par[i] = i;
        rk[i] = 0;
    }
}
int find(int x){
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
}
void unite(int x, int y){
    int rx = find(x);
    int ry = find(y);
    if(rx == ry)return;
    if(rk[x] < rk[y]){
        par[rx] = ry;
    }else{
        par[ry] = rx;
        if(rk[x] == rk[y])rk[x]++;
    }
}

int main(void){
    int n, m;
    scanf("%d %d", &n, &m);
    int count = 0;
    for(int i = 0;i < m;i++){
        int c, d;
        scanf("%d %d", &c, &d);
        c--;
        d--;
        a[i] = c;
        b[i] = d;
    }
    for(int i = 0;i < m;i++){
        init(n);
        for(int j = 0;j < m;j++){
            if(i!=j){
                unite(a[j], b[j]);
            }
        }
        /*for(int j = 0;j < n;j++){
            printf("%d ", par[j]);
        }*/
        printf("\n");
        int mem;
        for(int j = 0;j < n;j++){
            if(j == 0)mem = find(j);
            if(mem != find(j)){
                mem = -1;
                break;
            }
        }
        if(mem == -1)count++;
    }
    printf("%d\n", count);
    return 0;
}

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

import sys
import math
from decimal import Decimal, ROUND_DOWN
from collections import deque
from itertools import combinations
import copy

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]


    return (n, )


def solve(n):


    # x <= y <= z
    # と仮定して3倍する

    result = []
    for m in range(1, n+1):
        cnt = 0
        for i in range(1, 101):
            for j in range(i, 101):
                t = i*i + j*j + i*j
                for k in range(j, 101):
                    tmp =  t + k*k + j*k + k*i
                    if tmp == m:
                        if i < j and j < k:
                            cnt = cnt + 6
                        elif i == j and j == k:
                            cnt = cnt + 1
                        else:
                            cnt = cnt + 3
                    elif tmp > m:
                        break
                        
        result.append(cnt)

    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

ll D[32][32];
ll c[502][502];

int main() {
    ll N, C; cin >> N >> C;
    REP(i, C) REP(j, C) cin >> D[i+1][j+1];
    REP(i, N) REP(j, N) cin >> c[i+1][j+1];
    
    ll x[3][32];
    memset(x, 0, sizeof(x));
    REP(i, N) REP(j, N) x[((i+1)+(j+1))%3][c[i+1][j+1]]++;
    
    ll ans = INF;
    FOR(i, 1, C+1) FOR(j, 1, C+1) FOR(k, 1, C+1) {
        if (i == j or j == k or k == i) continue;
        
        ll sum_x = 0, sum_y = 0, sum_z = 0;
        FOR(l, 1, C+1) sum_x += D[l][i] * x[0][l];
        FOR(l, 1, C+1) sum_y += D[l][j] * x[1][l];
        FOR(l, 1, C+1) sum_z += D[l][k] * x[2][l];
        ans = min(ans, sum_x + sum_y + sum_z);
    }
    cout << ans << endl;
    
    return 0;
}

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

def main():
    n = int(input())
    x_li = list(map(int, input().split()))

    ans = 0

    for i in range(min(x_li), max(x_li)+1):
        sum_p = sum(list(map(lambda x: (x - i)**2, x_li)))
        if ans == 0:
            ans = sum_p
        elif sum_p < ans:
            ans = sum_p

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
import itertools


def solve(N: int, A: "List[List[int]]"):

    T = list(itertools.accumulate(A[0]))
    B = list(itertools.accumulate(A[1]))

    res = 0

    for i in range(len(T)):
        b = B[-1] if i == 0 else B[-1] - B[i-1]
        res = max(res, T[i] + b)

    print(res)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ [ int(next(tokens)) for _ in range(N) ] for _ in range(2) ]  # type: "List[List[int]]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define loop for(;;)
typedef std::vector<long> LI;
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   std::vector<long> nexts[2123];
   std::vector<long> overlap[2123];
   long n, len, s;
   LI xs, ys, zs;
   long f(long i, long k) {
      long dx = std::max((long)0, s - std::abs(xs[k] - xs[i]));
      long dy = std::max((long)0, s - std::abs(ys[k] - ys[i]));
      long dz = std::max((long)0, s - std::abs(zs[k] - zs[i]));
      if( dx == 0 or dy == 0 or dz == 0 ) return 0;
      return 2 * (dx * dy + dy * dz + dz * dx);
   }
   void solve() {
      scan(n, len, s);
      if( n == 0 and len == 0 and s == 0 ) exit(0);
      xs.resize(n), ys.resize(n), zs.resize(n);
      for(long i = 0; i < n; ++i) scan(xs[i], ys[i], zs[i]);
      for(long i = 0; i < n; ++i) {
         for(long k = 0; k < n; ++k) {
            if( i == k ) continue;
            long over = f(i, k);
            if( over == 0 ) continue;
            nexts[i].push_back(k);
            overlap[i].push_back(over);
         }
      }
      long res = -(1LL << 53);
      for(long i = 0; i < n; ++i) {
         visited.resize(n, false);
         res = std::max(res, dfs(i, len-1, i));
      }
      visited.resize(n);
      printf("%ld\n", res >= 0 ? 6 * s * s * len - res : -1);
   }
   std::vector<bool> visited;
   long dfs(long v, long d, long begin) {
      if( d == 0 ) {
         if( len >= 3 ) {
            for(long i = 0; i < (long)nexts[v].size(); ++i) {
               long next = nexts[v][i];
               long over = overlap[v][i];
               if( next == begin ) {
                  return over;
               }
            }
         }
         return 0;
      }
      long res = -(1LL << 53);
      visited[v] = true;
      for(long i = 0; i < (long)nexts[v].size(); ++i) {
         long next = nexts[v][i];
         long over = overlap[v][i];
         if( visited[next] ) continue;
         res = std::max(res, dfs(next, d-1, begin) + over);
      }
      visited[v] = false;
      return res;
   }
};

int main() {
   loop std::shared_ptr<Solver>(new Solver())->solve();
}

Measured memory_bytes: 3372
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string S;
  cin >> S;

  if (
      S == "abc" or
      S == "acb" or
      S == "bac" or
      S == "bca" or
      S == "cab" or
      S == "cba"
  ) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
string s;
vector< pair<char,char> > query;
int n,q;

bool checkRight(int x){
  int current = x;

  rep(i,q){
    if(s[current] == query[i].first){
      if(query[i].second == 'L'){
        current--;
        if(current < 0) return false;
      }else{
        current++;
        if(current == n) return true;
      }
    }
  }
  return false;
}

bool checkLeft(int x){
  int current = x;

  rep(i,q){
    if(s[current] == query[i].first){
      if(query[i].second == 'L'){
        current--;
        if(current < 0) return true;
      }else{
        current++;
        if(current == n) return false;
      }
    }
  }

  return false;
}

int main(){
  cin >> n >> q;
  cin >> s;
  rep(i,q){
    char x,y;
    cin >> x >> y;
    query.push_back(make_pair(x,y));
  }

  //binary serch
  //right edge
  int right = n - 1,left = 0;
  int rightEdge = 0, leftEdge = 0;
  if( checkRight(right) == false){
    rightEdge = n-1;
  }else{
    while(right - left > 1){
      int mid = (right + left)/2;
      bool flag = checkRight(mid);

      if(flag == true){right = mid;}
      if(flag == false){left = mid;}
      if(left == right){
        break;
      }
    }
    rightEdge = right-1;
  }
  //cout << "rightEdge " <<  rightEdge << endl;

  //left edge
  right = n-1,left = 0;
  if( checkLeft(left) == false){
    leftEdge = 0;
  }else{
    while(right - left > 1){
      int mid = (right + left)/2;
      bool flag = checkLeft(mid);
      if(flag == true){left = mid;}
      if(flag == false){right = mid;}
      if(left == right){
        break;
      }
    }
    leftEdge = left+1;
  }
  //cout << "leftEdge " <<  leftEdge << endl;
  if(rightEdge <= 0){
    cout << 0 << endl;
    return 0;
  }
  if(leftEdge >= n-1){
    cout << 0 << endl;
    return 0;
  }
  cout << max(0,rightEdge - leftEdge + 1) << endl;

  return 0;
}


Measured memory_bytes: 1148
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    n %= 10;

    if (n == 3) {
        cout << "bon" << endl;
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.next());
      int d = Integer.parseInt(sc.next());
      int ans = 0;
      int sum = 0;
      for (int i =0; sum < n; i++) {
        sum += d * 2 + 1;
        ans += 1;
      }
      System.out.println(ans);
    }
}

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

int main(){
    int N;
    cin >> N;
    int res1=0;
    int res2=0;
    bool ok=false;
        for(int i=1;i<10;++i){
            if(N%i==0){
                res1=N/i;
                if(res1<=9){
                  ok=true;
                  break;  
                }
            }
        }
    if(ok==true){
        cout << "Yes";
    }
    else{
        cout << "No";
    }    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int[] a = new int[N];
		int ans = 0;
		int[] M = new int[N];

		for (int i = 0; i < N; i++) {
			ans += reader.nextInt() -1;
		}

		reader.close();
		System.out.print(ans);
	}
}



Measured memory_bytes: 27624
//In The Name of Allah
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template < class T > using Tree = tree < T , null_type , greater < T > , rb_tree_tag , tree_order_statistics_node_update >;
template < class T > using Tree2 = tree < T , null_type , less < T > , rb_tree_tag , tree_order_statistics_node_update >;


typedef long long            ll;
typedef long double          ld;
typedef string               str;
typedef pair < ll , ll >     pll;

#define X               first
#define Y               second
#define pb              push_back
#define all(x)			(x).begin(), (x).end()
#define SZ(x) 			(ll)(x.size())
#define sep             ' '
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define dbl_io(x)       cout << fixed << setprecision(x);

const int N = 3e5 + 10;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 10;

ll a[N];
map < ll , ll > mp1, mp2;
Tree < pll > T1;
Tree2 < pll > T2;

int main(){
    fast_io
    //dbl_io(10);
    ll n;
    cin >> n;
    for (ll i = 0; i < 3 * n; i ++)
    	cin >> a[i];
    ll ans = 0;
    for (ll i = 0; i < n; i ++){
    	ans += a[i];
    	mp1[a[i]] ++;
    	T1.insert(make_pair(a[i], mp1[a[i]]));
    }
    for (ll i = n; i < 3 * n; i ++){
    	mp2[a[i]] ++;
    	T2.insert(make_pair(a[i], mp2[a[i]]));
    }
    for (ll i = 0; i < n; i ++)
    	ans -= T2.find_by_order(i) -> first;
    ll res = ans;
    for (ll i = n; i < 2 * n; i ++){
    	ll x = T1.find_by_order(n - 1) -> first;
    	if (x < a[i]){
    		res -= x;
    		res += a[i];
    	}
    	ll ind = T2.order_of_key(make_pair(a[i], mp2[a[i]]));
    	if (ind < n){
    		res += a[i];
    		res -= T2.find_by_order(n) -> first;
    	}
    	mp1[a[i]] ++;
    	T1.insert(make_pair(a[i], mp1[a[i]]));
    	T2.erase(make_pair(a[i], mp2[a[i]]));
    	mp2[a[i]] --;
    	ans = max(ans, res);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 46336
use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let q: usize = iterator.next().unwrap().parse().unwrap();
    let mut tree: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..(n - 1) {
        let ai: usize = iterator.next().unwrap().parse().unwrap();
        let bi: usize = iterator.next().unwrap().parse().unwrap();
        tree[ai - 1].push(bi - 1);
        tree[bi - 1].push(ai - 1);
    }
    let mut p: Vec<usize> = vec![0; n];
    for _ in 0..q {
        let pi: usize = iterator.next().unwrap().parse().unwrap();
        let xi: usize = iterator.next().unwrap().parse().unwrap();
        p[pi - 1] += xi;
    }

    let mut result: Vec<usize> = vec![0; n];
    let mut visited: Vec<bool> = vec![false; n];
    let mut queue: VecDeque<usize> = VecDeque::new();
    visited[0] = true;
    queue.push_back(0);
    while !queue.is_empty() {
        let u: usize = queue.pop_front().unwrap();
        result[u] += p[u];
        for &v in &tree[u] {
            if visited[v] {
                continue;
            }
            visited[v] = true;
            result[v] += result[u];
            queue.push_back(v);
        }
    }
    return result.iter().map(|it| it.to_string()).collect::<Vec<String>>().join(" ");
}


Measured memory_bytes: 39160
n = int(input())
s = input()
count = 0
for i in s:
    if i == ".":
        count += 1
ans = count
for i in s:
    if i == "#":
        count += 1
        ans = min(ans,count)
    else:
        count -= 1
        ans = min(ans,count)
print(ans)

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

const int N=1e3+20;

int n,a[N];
long long dp[N][N];
bool found[N][N];

void setval(int i,int j,long long val)
{
	found[i][j]=true;
	dp[i][j]=val;
}

long long f(int i,int j)
{
	if(found[i][j]) return dp[i][j];

	found[i][j]=true;
	dp[i][j]=LLONG_MIN;
	for(int pv=0;pv<N;pv++)
	{
		long long money=f(i-1,pv);
		if(pv<j)
		{
			if(money>=(j-pv)*a[i])
				dp[i][j]=max(dp[i][j],money-(j-pv)*a[i]);
		}
		else
		{
			dp[i][j]=max(dp[i][j],money+(pv-j)*a[i]);
		}
	}
	return dp[i][j];
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	a[n+1]=INT_MIN;

	long long money=1000;
	int i=1;
	while(i<=n and a[i]>=a[i+1]) i++;

	if(i==n) return 0 * printf("%lld",money);

	while(i<=n)
	{
		int j=i;
		while(j<=n and a[j]<=a[j+1]) j++;//cout<<i<<" "<<j<<" "<<a[i]<<" "<<a[j]<<"    "<<money<<" "<<stocks<<endl;
		long long stocks=money/a[i];
		money%=a[i];
		money+=stocks*a[j];
		stocks=0;

		i=j;
		while(i<=n and a[i]>=a[i+1]) i++;
	}
	cout<<money<<endl;
}

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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define endl "\n"

int main()
{
	faster;
	
	ll n;
	cin >> n;
	string s;
	while(n > 0){
		n--;
		char c;
		c = ((n % 26) + 'a');
		s = c + s;
		n /= 26;
	}


	cout << s << endl;

	return 0;
}

Measured memory_bytes: 3536
#include<iostream>
#include<vector>

using namespace std;

int jikan(vector<int> num) {
	int result = 0;
	if(num[0] < 0 && num[num.size()-1] > 0) {
		int fu = abs(num[0]), sei = num[num.size()-1];
		if(sei > fu)
			result = fu * 2 + sei;
		else
			result = sei * 2 + fu;
	}
	else if(num[num.size()-1] <= 0)
		result = abs(num[0]);
	else if(num[0] >= 0)
		result = num[num.size()-1];

	return(result);
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> x(N, 0);
	vector<int> num(K, 0);
	for(int i = 0; i < N; i++) {
		cin >> x[i];
		if(i < K)
			num[i] = x[i];
	}

	int min = jikan(num);
	for(int i = K; i < N; i++) {
		num.erase(num.begin());
		num.push_back(x[i]);
		int t = jikan(num);
		if(t < min)
			min = t;
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;

#define INF (i64)(1e18)
#define MOD (i64)(1e9+7)
#define REP(i, n) for(i64 i = 0; i < (n); i++)
#define RREP(i, n) for(i64 i = (n)-1; i >= 0; i--)
#define REPF(i, a, n) for(i64 i = a; i < (a)+(n); i++)
#define RREPF(i, a, n) for(i64 i = (a)+(n)-1; i >= (a); i--)
#define RANGE(i, a, b) for(i64 i = (a); i < (b); i++)
#define RRANGE(i, a, b) for(i64 i = (b)-1; i >= (a); i--)
#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) ((i64)(v).size())
template<class T> inline void chmax(T &a, const T &b) { if (a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if (a > b) a = b; }

i64 binary_search(vector<i64> v, i64 value) {
  i64 ok = -1, ng = SIZE(v);
  while (abs(ok-ng) > 1) {
    i64 mid = (ok+ng)/2;
    if (v[mid] < value) ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  i64 a, b, q;
  cin >> a >> b >> q;
  vector<i64> s(a+2), t(b+2), x(q);
  s[0] = -INF; s[a+1] = INF;
  t[0] = -INF; t[b+1] = INF;
  REP(i, a) cin >> s.at(i+1);
  sort(ALL(s));
  REP(i, b) cin >> t.at(i+1);
  sort(ALL(t));
  REP(i, q) cin >> x.at(i);

  REP(i, q) {
    i64 ans = INF;
    REPF(si, upper_bound(ALL(s), x[i])-s.begin()-1, 2) {
      REPF(ti, upper_bound(ALL(t), s[si])-t.begin()-1, 2) {
        chmin(ans, abs(x[i]-s[si])+abs(s[si]-t[ti]));
        chmin(ans, abs(x[i]-t[ti])+abs(t[ti]-s[si]));
      }
    }
    REPF(ti, upper_bound(ALL(t), x[i])-t.begin()-1, 2) {
      REPF(si, upper_bound(ALL(s), t[ti])-s.begin()-1, 2) {
        chmin(ans, abs(x[i]-s[si])+abs(s[si]-t[ti]));
        chmin(ans, abs(x[i]-t[ti])+abs(t[ti]-s[si]));
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 5640
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}


int main(void) {

	int n, a, b;
	cin >> n >> a >> b;

	cout << min(a, b) << " " << max(a + b - n, 0) << endl;



	return 0;
}


Measured memory_bytes: 256
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
B = [0] * N
max_a = 0
for i in range(N):
    if A[i] > 0:
        B[i] = A[i]
    if i > 0:
        B[i] += B[i - 1]

for i in range(1, N):
    A[i] += A[i - 1]

ans = -1e12
for i in range(N - K+1):
    x = A[i + K - 1] - (A[i - 1] if i > 0 else 0)
    y = B[-1] - (B[i + K - 1] - (B[i - 1] if i > 0 else 0))
    ans = max(y,y+x,ans)
print(ans)

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

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

int f[100];

int main() {
	int a = read(), b = read();
	int c = read(), d = read();
	int n = read();
	memset(f, 60, sizeof(f));
	f[1] = a; f[2] = b;
	f[4] = c; f[8] = d;
	for (int i = 1; i <= 8; i++) f[i + 1] = min(f[i + 1], f[i] + a);
	for (int i = 1; i <= 8; i++) f[i + 2] = min(f[i + 2], f[i] + b);
	for (int i = 1; i <= 8; i++) f[i + 4] = min(f[i + 4], f[i] + c);
	LL ret = (LL)(n >> 1) * f[8];
	if (n % 2) ret += f[4];
	cout<<ret;
	return 0;
}

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

int main(){
    int w,h,x,y,r;    
    cin>>w>>h>>x>>y>>r;
    if(x+r<=w&&x-r>=0&&y+r<=h&&y-r>=0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


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

int main()
{
    int n,l,i;
    cin>>n>>l;
    string s[n];
    string str;
    for(i=0;i<n;i++)
    {
        cin>>s[i];
    }
    sort(s,s+n);
    for(i=0;i<n;i++)
    {
        str=str+s[i];
    }
    cout<<str;

    return 0;
}


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

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> s(100010,0);
  for(ll i=0; i<n; i++){
    ll a, b;
    cin >> a >> b;
    s[a] += b;
  }
  ll sum=0;
  ll i=1;
  while(sum < k){
    sum += s[i];
    i++;
  }
  cout << i-1 << endl;
  return 0;
}


Measured memory_bytes: 1024
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pb push_back
using namespace std;
void solve(){
    ll k,x;
    cin>>k>>x;
    if(k*500>=x)
    cout<<"Yes";
    else
    cout<<"No";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


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

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int A, B, K;
    vector<int> nums;
    cin >> A >> B >> K;
    int bigger = max(A, B);
    for (int i = 1; i <= bigger; i++) {
        if (A % i == 0 && B % i == 0) {
            nums.push_back(i);
        }
    }
    sort(nums.begin(), nums.end(), greater<int>());
    cout << nums.at(K - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int floor(int m,int n){
     if (m%n!=0){
          return m/n+1;
     }else{
          return m/n;
     }
}
int main(){
     int N,X,T;
     cin >> N >> X >> T;
     cout << floor(N,X)*T <<endl;
}


Measured memory_bytes: 3568
n,m=map(int,input().split())
data=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    data[b-1]+=1
    if data[b-1]==2:
      print('POSSIBLE')
      exit()
  if b==n:
    data[a-1]+=1
    if data[a-1]==2:
      print('POSSIBLE')
      exit()
print('IMPOSSIBLE')

Measured memory_bytes: 10348
import std.stdio;
import std.conv;
import std.complex;
import std.algorithm;
import std.range;
import std.math;
import std.string;


void main()
{
    while(1){
        immutable int N = readln().chomp.to!uint;
        if(N == 0)
            break;

        Complex!real[] map2D = new Complex!real[N];
        map2D[0] = complex(0, 0);

        {
            immutable cpxDir = [complex(-1, 0), complex(0, -1), complex(1, 0), complex(0, 1)];
            size_t i = 1;
            foreach(e; iota(N-1).map!(a => readln.split[0..2].map!(to!uint)))
                map2D[i++] = map2D[e[0]] + cpxDir[e[1]];
        }


        real[2] iM = [0, 0], im = [0, 0];
        foreach(i, e; map2D){
            iM[0] = max(e.re, iM[0]);
            iM[1] = max(e.im, iM[1]);
            im[0] = min(e.re, im[0]);
            im[1] = min(e.im, im[1]);
        }

        writefln("%s %s", abs(iM[0] - im[0]).round.to!int + 1, abs(iM[1] - im[1]).round.to!int + 1);
    }
}

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

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int h,m;
		char _;
		cin>>h>>_>>m;
		int d=min(abs(h*60+m-12*m) , 720-max(h*60+m,12*m)+min(h*60+m,12*m));
		if(d<30*2){
			cout<<"alert\n";
		}else if(d<90*2){
			cout<<"warning\n";
		}else{
			cout<<"safe\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1120
import sys
from itertools import permutations


def input():
    return sys.stdin.readline().strip()


def main():
    N, M, R = map(int, input().split())

    def warshall_floyd(d):
        # d[i][j]: iからjへの最短距離
        for k in range(N):
            for i in range(N):
                for j in range(N):
                    tmp = d[i][k] + d[k][j]
                    if d[i][j] > tmp:
                        d[i][j] = tmp
        return d

    r = list(map(int, input().split()))
    d = [[float("inf")] * N for i in range(N)]
    for i in range(M):
        x, y, z = map(int, input().split())
        d[x - 1][y - 1] = z
        d[y - 1][x - 1] = z
    for i in range(N):
        d[i][i] = 0  # 自身のところに行くコストは０
    D = warshall_floyd(d)
    P = list(permutations(r))
    cost = float("inf")
    for p in P:
        c = 0
        for i in range(R - 1):
            c += D[p[i] - 1][p[i + 1] - 1]
        if c < cost:
            cost = c
    print(cost)


if __name__ == "__main__":
    main()


Measured memory_bytes: 54236
#include "bits/stdc++.h"
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll > pll;

bool comp(const pll &a, const pll &b) {
	return a.first < b.first;
}
std::vector<int> enum_div(int n)//nの約数を列挙
{
	std::vector<int> ret;
	for (int i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			ret.push_back(i);
			if (i != 1 && i*i != n)
			{
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}


template<int N>
int factorial() {
	return factorial<N - 1>() * N;
}

template<>  /// 特殊化：factorial<N=”1”>だったら，値を返す
int factorial<1>() {
	return 1;
}
int main()
{
	priority_queue<int> q;
	string s = {};
	string s1 = {};
	ll h = 0, w = 0, k = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, ans = 0;
	//ll x[300005] = {};
	ll y[300005] = {};
	ll z[302][302] = {};
	cin >> a;
	cin >> b;
	while (true)
	{
		a -= b;
		ans++;
		if (a<=0)
		{
			cout << ans << endl;
			return 0;
		}
	}


	cout << ans << endl;



	//return 0;

	/*cout << c << endl;
	cout << b << endl;*/
	//cout << fixed << setprecision(10) <<tmp << endl;
	//cout<<factorial<10><<endl;
	return 0;
}
//2つの組の数をソートしたりするやつ
//vector<pair<ll, ll> > hoges(a);
//for (int i = 1; i <= a; i++)
//{
//	cin >> h;
//	hoges[i - 1] = make_pair(h, i);
//}
//sort(hoges.begin(), hoges.end(), comp);
//for (int i = 0; i < a; i++)
//{
//	cout << hoges[i].second << endl;
//}


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

int main() {
  int a;
  cin >> a;
  if (a%2==0) {
    cout << 0.50000000000000000 << endl;
  }
  else {
    cout << double((double(a)+1)/(2*double(a))) << endl;
  }
}


Measured memory_bytes: 3736
def is_palindrome(s):
    # print(s)
    for i in range(len(s) // 2 + 1):
        if s[i] != s[-(i+1)] and '.' not in [s[i], s[-(i+1)]]:
            return False
    return True

s = input()

a = is_palindrome(s)
b = is_palindrome( s[:(len(s)-1)//2])
c = is_palindrome(s[(len(s)+3)//2-1:])

if a and b and c:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#pragma gcc optimize("Ofast")

#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
    _x = 0;
    int _tmp = 1; char _tc = getchar();
    while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
    if(_tc == '-') _tc = getchar(), _tmp = -1;
    while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
    _x *= _tmp;
}
inline void output(int _x) {
    char _buff[20]; int _f = 0;
    if(_x == 0)putchar('0');
    while(_x > 0)
    {
        _buff[_f++] = _x%10+'0';
        _x /= 10;
    }
    for(_f-=1; _f >= 0; _f--)
        putchar(_buff[_f]);
    putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
     return _out(s,c.begin(),c.end());
 }
#ifdef erd1
    #define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
    #define pprint(x)
#endif

// code starts here
vector<vector<int>> G;
pii dfs(int i, int p){
    int zcnt = 0, ans = 0, nu = false, cnt = 0, nn;
    for(auto x: G[i])
        if(x != p){
            cnt++;
            pii d = dfs(x, i);
            if(!d.ff)zcnt++;
            ans+=d.ff;
            if(d.ss)nu = true, nn = d.ff;
        }
    ans += max(0, zcnt-1);
    if(nu)nu = ans==nn;
    if(!cnt)nu = true;
    if(i==p && nu)ans++;
    //cout << i << " " << ans << endl;
    return {ans, nu || zcnt!=0};
}
int S(pii p){ return p.ff + p.ss; }
signed main(){
    int n;
    cin >> n;
    G.resize(n);
    for(int i = 1; i < n; i++){
        int a, b;
        cin >> a >> b;
        G[a].pb(b);
        G[b].pb(a);
    }
    int ans = dfs(0, 0).ff;
    for(int i = n/10; i < n;i+=max(n/10, 1))
        ans = max(dfs(i, i).ff, ans);
    cout << ans << endl;
}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
    }
};
int main(){
    int n,m,ans=0;
    cin >> n >> m;
    vector<int> p(n);
    for(int i = 0;i < n;i ++){
        cin >> p[i];
    }

    UnionFind tree(n);

    for(int i = 0;i < m;i ++){
        int x,y;
        cin >> x >> y;
        tree.unite(x-1,y-1);
    }
    for(int i = 0;i < n;i ++){
        if(tree.same(i,p[i]-1)) ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
k = int(input())
from fractions import gcd
from functools import reduce

x = 3*k*k - 3*k +1
for a in range(2, k+1):
  for b in range(a, k+1):
    if gcd(a,b)==1:
      x += 6*(k-b)+3
    else:
      for c in range(b, k+1):
        if len({a, b, c})==1:
          x += reduce(gcd, [a,b,c])
        elif len({a, b, c})==2:
          x += 3*reduce(gcd, [a,b,c])
        else:
          x += 6*reduce(gcd, [a,b,c])
      
print(x)

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

int main(void) {
    int N;
    cin >> N;
    
    vector<int> a(N, 0);
    int alice_point = 0, bob_point = 0;
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    
    for (int i = 0; i < N; i ++) {
        if (i % 2 == 0) {
            alice_point += a.at(i);
        } else {
            bob_point += a.at(i);
        }
    }
    cout << alice_point - bob_point << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;


void  solve(){
    int n,k,cnt=0,x;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x;
        if(k<=x) cnt++;
    }
    cout<<cnt;
}
        
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //int n; cin>>n; for(int i=0;i<n;i++)
        solve();
    return 0;
}

Measured memory_bytes: 256
import fractions
A,B,C,D = map(int,input().split())
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
syou = (A-1) - (A-1)//C - (A-1)//D + (A-1)//lcm(C,D)
dai = B - B//C - B//D + B//lcm(C,D)
ans = dai - syou
print(ans)

Measured memory_bytes: 5048