akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

struct LazySegmentTree {
private:
    int length;
    vector<long long> node, lazy;
public:
    LazySegmentTree(int N) {
        length = 1;
        while (length < N) length *= 2;
        node.resize(2 * length - 1, 0);
        lazy.resize(2 * length - 1, 0);
    }
    void eval(int k, int l, int r) {
        node[k] += lazy[k];
        if (r - l > 1) {
            lazy[2 * k + 1] += lazy[k] / 2;
            lazy[2 * k + 2] += lazy[k] / 2;
        }
        lazy[k] = 0;
    }
    void add(int a, int b, long long x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = length;
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy[k] += x * (r - l);
            eval(k, l, r);
        } else {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = node[2 * k + 1] + node[2 * k + 2];
        }
    }
    long long getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = length;
        if (b <= l || r <= a) return 0;
        eval(k, l, r);
        if (a <= l && r <= b) return node[k];
        long long vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
        long long vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
        return vl + vr;
    }
};

int main() {
    int N;
    long long D, A;
    cin >> N >> D >> A;
    vector<pair<long long, long long>> S(N);
    rep(i, N) cin >> S[i].first >> S[i].second;
    S.push_back(pair<long long, long long>{1E15, 0});
    
    sort(S.begin(), S.end());
    LazySegmentTree LST(N);
    rep(i, N) LST.add(i, i + 1, S[i].second);
    long long ans = 0;
    rep(i, N) {
        long long x = LST.getsum(i, i + 1);
        if (x <= 0) continue;
        auto iter = upper_bound(S.begin(), S.end(), pair<long long, long long>{S[i].first + 2 * D, 1E15});
        ans += (x - 1 + A) / A;
        LST.add(i, (int)(iter - S.begin()), -(x - 1 + A) / A * A);
    }
    cout << ans << endl;
}


Measured memory_bytes: 13640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[200005],vis[200005],n,pos[200005];
long long k;
int main()
{int i;
	scanf("%d%lld",&n,&k);k++;
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int x=1,cnt=1,len;
	for (i=1;i<=n;i++)
	{
		if (vis[x]) {
			cnt=vis[x];
			len=i-vis[x];
			break;
		}
		vis[x]=i;
		pos[i]=x;
		//printf("%d\n",x);
		x=a[x];
		cnt++;
	} 
	//printf("%d %d\n",cnt,len);
	if (k<=cnt) printf("%d",pos[k]);
	else printf("%d",pos[(k-cnt)%len+cnt]);
}

Measured memory_bytes: 6056
import java.io.IOException;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static long lcm(int[] array) {
		int max = Integer.MIN_VALUE;
		
		for(int num : array){
			max = Math.max(max, num);
		}
		
		LOOP:
		for(int div = max; div >= 2; div--){
			
			for(int num : array){
				if(num % div != 0){
					continue LOOP;
				}
			}
			
			for(int i = 0; i < array.length; i++){
				array[i] /= div;
			}
			
			return div * lcm(array);
		}
		
		long pi = 1;
		for(int num : array){
			pi *= num;
		}
		
		return pi;
	}
	
	public static long lcm(long[] array) {
		long max = Long.MIN_VALUE;
		
		for(long num : array){
			max = Math.max(max, num);
		}
		
		//System.out.println("[" + max + "]");
		
		final long ceil = (long) Math.ceil(Math.sqrt(max));
		LOOP:
		for(long div = ceil; div >= 2; div--){
			
			for(long num : array){
				if(num % div != 0){
					continue LOOP;
				}
			}
			
			for(int i = 0; i < array.length; i++){
				array[i] /= div;
			}
			
			return div * lcm(array);
		}
		
		long pi = 1;
		for(long num : array){
			pi *= num;
		}
		
		return pi;
	}
	
	public static int gcd(int x, int y){
		if(x == 0){
			return y;
		}else{
			return gcd(y % x, x);
		}
	}
	
	public static void gcd_a(int[] d, int[] v){
		for(int i = 0; i < d.length; i++){
			int g = gcd(d[i], v[i]);
			d[i] /= g;
			v[i] /= g;
		}
	}
	
	public static boolean all_same_pair(int[] d, int[] v){
		for(int i = 1; i < d.length; i++){
			if(d[0] != d[i] && v[0] != v[i]){
				return false;
			}
		}
		
		return true;
	}
	
	public static boolean all_same(int[] d){
		for(int i = 1; i < d.length; i++){
			if(d[i] != d[0]){
				return false;
			}
		}
		
		return true;
	}
	
	public static BigInteger gcd(BigInteger first, BigInteger second){
		return first.gcd(second);
	}
	
	public static BigInteger lcm(BigInteger first, BigInteger second){
		return first.multiply(second).divide(gcd(first, second));
	}
	
	public static BigInteger lcm(BigInteger[] bigs){
		BigInteger big = bigs[0];
		
		for(int i = 1; i < bigs.length; i++){
			big = lcm(big, bigs[i]);
		}
		
		return big;
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			final int n = sc.nextInt();

			if (n == 0) {
				break;
			}
			
			BigInteger[] dist = new BigInteger[n];
			BigInteger[] velo = new BigInteger[n];
			
			for(int i = 0; i < n; i++){
				dist[i] = new BigInteger(sc.next());
				velo[i] = new BigInteger(sc.next());
			}
			
			BigInteger velo_lcm = lcm(velo);
			
			//System.out.println(velo_lcm);
			
			BigInteger[] dist_norm = new BigInteger[n];
			for(int i = 0; i < n; i++){
				dist_norm[i] = dist[i].multiply(velo_lcm.divide(velo[i]));
			}
			
			//System.out.println("!");
			BigInteger dist_lcm = lcm(dist_norm);
			//System.out.println(dist_lcm);
			//System.out.println("!");
			for(int i = 0; i < n; i++){
				System.out.println(dist_lcm.multiply(velo[i]).divide(velo_lcm).divide(dist[i]));
			}
			
			
		}
	}

}

Measured memory_bytes: 45160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
int main()
{
    int n,ans=1e9;
    cin>>n;
    vector<int> w(n);
    rep(i,n) cin>>w[i];
    rep(i,n){
        int sum1=0,sum2=0;
        rep(j,n){
            if(j<=i) sum1+=w[j];
            else sum2+=w[j];
        }
        ans=min(ans,abs(sum1-sum2));
    }
    cout<<ans;
}

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

using namespace std;
vector<int> digit(int num, int n){
    vector<int> v(n, 0);
    for(int i =0 ; i < n; i++){
        v[i] = num%2;
        num /= 2;
    }
    return v;
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v;
    for(int i = 0; i < m; i++){
        int k;
        cin >> k;
        v.push_back(vector<int>(k));
        for(int j = 0; j < k; j++){
            cin >> v[i][j];
        }
    }
    vector<int> p(m);
    for(int i = 0; i < m; i++) cin >> p[i];


    int ans = 0;
    int po = pow(2, n);
    for(int num = 0; num < po; num++){
        vector<int> d = digit(num, n);

        /*for(int i : d) cout << i;
        cout << endl;*/

        int light_num = 0;
        for(int i = 0; i < m; i++){
            int on_num = 0;
            for(int j = 0; j < v[i].size(); j++){
                on_num += d[v[i][j]-1];
            }
            //cout << on_num << endl;
            if(on_num%2 == p[i]) light_num++;
        }
        if(light_num == m) ans++;
        //cout << endl;
    }

    cout << ans << endl;

}

Measured memory_bytes: 4024
def main():
    # 下、右、上、左
    dy = (1, 0, -1, 0)
    dx = (0, 1, 0, -1)
    H, W = map(int, input().split())
    s = ("." * (W + 2),)
    for i in range(H):
        s += ("." + input() + ".",)
    s += ("." * (W + 2),)
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if s[y][x] == "#" and\
                    "." == s[y + dy[0]][x + dx[0]]\
                    == s[y + dy[1]][x + dx[1]]\
                    == s[y + dy[2]][x + dx[2]]\
                    == s[y + dy[3]][x + dx[3]]:
                print("No")
                return
    print("Yes")
    return


main()


Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
    }
    let mut plug = 1;
    let mut ans = 0;
    loop {
        if plug >= b {
            break;
        }
        ans += 1;
        plug += a - 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
	int array[5][4][11]={};
	int a;
	int b;
	int x,y,z;
	int p;
	scanf("%d",&b);
	for(a=0;a<b;a++){
		scanf("%d %d %d %d",&x,&y,&z,&p);
	array[x][y][z]+=p;
	}
		for(x=1;x<5;x++){
			for(y=1;y<4;y++){
				for(z=1;z<11;z++){
					printf(" %d",array[x][y][z]);
				}
				printf("\n");
				}
			if(x!=4){
				printf("####################\n");
			}
		}
	return 0;
}

Measured memory_bytes: 612
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  ls <- map read . lines <$> getContents
  forM_ ls $ \n -> print $ length $ takeWhile (<=n) primes

primes :: [Int]
primes = 2:sieve [3] [3,5..]
  where
    sieve :: [Int] -> [Int] -> [Int]
    sieve (x:xs) ys = let
        (ps, qs) = span (<x^2) ys
      in ps ++ sieve (xs ++ ps) (filter ((/=0) . (`mod`x)) qs)

Measured memory_bytes: 18020
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    K = int(readline())

    subs = set()

    S_sorted = sorted(set(S))
    for c_min in S_sorted:
        indices = [i for i, c in enumerate(S) if c == c_min]
        for i in indices:
            for j in range(i + 1, min(len(S) + 1, i + K + 1)):
                subs.add(S[i:j])

        if len(subs) >= K:
            break

    subs = sorted(subs)
    print(subs[K - 1])

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 69040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    vector<ll> v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    cout<<*max_element(v.begin(),v.end())-*min_element(v.begin(),v.end());
}

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

typedef long long int64;
typedef int int__;
#define rep(i,j) for(int__ i=0;i<j;i++)

typedef unsigned long long ull;
const ull HashBase = 100000007;

/*
  s := s1 s2 ... sn
  
  hash[1_to_i] := s1*b^(i-1) + s2*b^(i-2) + ... + si*b^0
  
  hash[1_to_j] := s1*b^(j-1) + s2*b^(j-2) + ... + si*b^(j-i) + ... + sj*b^0
  
  
  hash[(i+1)_to_j] = hash[1_to_j] - hash[1_to_i]*b^(j-i)
  
                   = s(i+1)*b^(j-i-1) + ... + sj*b^0
*/


int main()
{
  int n,m;string s;
  cin>>n>>m>>s;
  
  vector<ull> hash(n+1);
  vector<ull> pow_base(n+1);

  hash[0]=0;pow_base[0]=1;
  rep(i,n){
    hash[i+1] = hash[i]*HashBase + s[i];
    pow_base[i+1]=pow_base[i]*HashBase;
  }
  
  int r=1,l=1;
  set<ull> subhash;
  rep(i,m){
    string query;
    cin>>query;

    if(query=="L++")l++;
    else if(query=="L--")l--;
    else if(query=="R++")r++;
    else if(query=="R--")r--;

    subhash.insert(hash[r]-hash[l-1]*pow_base[r-l+1]);
  }

  cout<<subhash.size()<<endl;
  
  return 0;
}

Measured memory_bytes: 20024
Scanf.scanf "%d" (fun d ->
    let c = Array.init 26 (fun _ -> Scanf.scanf " %d" (fun c -> c)) in
    let s = Array.init d (fun _ ->
        Array.init 26 (fun _ ->
            Scanf.scanf " %d" (fun s -> s)))
    in
    let last = Array.make 26 (-1) in
    let t = Array.make d 0 in
    for i = 0 to d - 1 do
        let rec loop j mi mx =
            if j = 26 then (last.(mi) <- i; t.(i) <- mi) else
                if s.(i).(j) + c.(j) * (i - last.(j)) > mx then loop (j + 1) j (s.(i).(j) + c.(j) * (i - last.(j)))
                                                           else loop (j + 1) mi mx
        in
        loop 0 0 0
    done;
    let basicsat =
        let rec loop i acc =
            if i = d then acc else loop (i + 1) (acc + s.(i).(t.(i)))
        in
        loop 0 0
    in
    let module S = Set.Make (struct type t = int let compare = compare end) in
    let last = Array.make 26 (S.add d @@ S.singleton (-1)) in
    Array.iteri (fun i t -> last.(t) <- S.add i last.(t)) t;

    let f a = a * (a - 1) / 2 in

    let reducesat =
        let calc set =
            let rec loop prev acc = function
            | [] -> acc
            | hd :: tl -> loop hd (acc + f (hd - prev)) tl
            in
            match S.elements set with
            | hd :: tl -> loop hd 0 tl
            | [] -> 0
        in
        let rec loop i acc =
            if i = 26 then acc else loop (i + 1) (acc + c.(i) * calc last.(i))
        in
        loop 0 0
    in

    let trycalc a b =
        let pre = t.(a) in
        if pre = b then 0 else
        let p1, _, p2 = S.split a last.(pre) in
        let p1m = S.max_elt p1 in
        let p2m = S.min_elt p2 in
        let delta = c.(pre)* f (a - p1m) + f (p2m - a) - f (p2m - p1m) - s.(a).(pre) in

        let p1, _, p2 = S.split a last.(b) in
        let p1m = S.max_elt p1 in
        let p2m = S.min_elt p2 in
        let delta = c.(b) * (- f (a - p1m) - f (p2m - a) + f (p2m - p1m)) + s.(a).(b) in
        delta
    in
    let apply a b =
        let pre = t.(a) in
        last.(pre) <- S.remove a last.(pre);
        last.(b)   <- S.add    a last.(b);
        t.(a) <- b
    in
    for i = 1 to 10 do
        let rec loop_a a acc =
            let rec loop_b b ((ma, mb, md) as acc) =
                if b = 26 then acc else
                    let d = trycalc a b in
                    if d > md then loop_b (b + 1) (a, b, d)
                              else loop_b (b + 1) acc
            in
            if a = d then acc else loop_a (a + 1) (loop_b 0 acc)
        in
        let a, b, d = loop_a 0 (0, 0, min_int) in

        apply a b;
    done;
    Array.iter (fun c -> Printf.printf "%d\n" (c + 1)) t
)

Measured memory_bytes: 6128
#import heapq
v, e = map(int, input().split( ))

Edg = []

for _ in range(e):
    s,t,w = map(int, input().split( ))
    Edg.append([w,s,t])
    Edg.append([w,t,s])
    
Edg.sort(reverse = True)

UF = [i for i in range(v)]

ans = 0
#cnt = v

for i in range(2*e):#無向辺で2倍
    edg = Edg.pop()
    s, t = edg[1],edg[2]
    Ls = [s]
    Lt = [t]
    root_s = UF[s]
    
    while root_s!=s:
        Ls.append(root_s)
        s = root_s
        root_s = UF[root_s]
        
    root_t = UF[t]
    while root_t!=t:
        Lt.append(root_t)
        t = root_t
        root_t = UF[root_t]
    
    if root_s == root_t:
        continue
    
    else:
        #print(root_t,root_s)
        for j in Lt:
            UF[j] = root_s
        #print(edg)
        ans += edg[0]
        #cnt -= 1
    #print(*UF)


print(ans)




Measured memory_bytes: 34608
loop do
  s = gets.split //
  break if s[0] == '.'
  res = true
  a = []
  s.each do |c|
    case c
    when '[' then
      a.push '['
    when ']' then
      if a.pop != '['
        res = false
        break
      end
    when '(' then
      a.push '('
    when ')' then
      if a.pop != '('
        res = false
        break
      end
    end
  end
  puts res && a.size == 0 ? 'yes' : 'no'
end

Measured memory_bytes: 6108
import sys
import bisect
input = sys.stdin.readline
import numpy as np

class Bisect(object):
    def bisect_max(self, reva, func,M):
        ok = 0 # exist
        ng = 2*(10**5)+1 # not exist
        while abs(ok-ng) > 1:
            cnt = (ok + ng) // 2
            if func(cnt,reva,M):
                ok = cnt
            else:
                ng = cnt
        return ok

def solve1(tgt,reva,M):
    res=0
    n = len(reva)
    if (n - bisect.bisect_left(reva,tgt-reva[n-1]))*n < M:
        return False
    for i in range(n):
        res += n - bisect.bisect_left(reva,tgt-reva[n-i-1])
        if M <= res:
            return True
    return False

N,M = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
reva = a[::-1]
bs = Bisect()
Kmax = (bs.bisect_max(reva,solve1,M))

r=np.zeros((N+1),dtype='int64')
np.cumsum(a,out=r[1:])

res = 0
cnt = 0
t = 0
for i in range(N):
    tmp = bisect.bisect_left(reva,Kmax-reva[N-i-1])
    tmp2 = bisect.bisect_right(reva,Kmax-reva[N-i-1])
    if tmp!=tmp2:
        t = 1
    tmp = N - tmp
    cnt += tmp
    res += tmp*a[i]+r[tmp]
if t==1:
    res -= (cnt-M)*Kmax
print(res)


Measured memory_bytes: 23388
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


const ll INFLL = 1e18;
const int MAXN = 2e5+100;
const ll INF = 1e9;
const ll mod1=998244353;
const ll mod2=2e9+11;
ll fact[MAXN],ifact[MAXN];
ll add(ll a,ll b)
{
    a+=b;
    if (a>=mod1)
        return a-mod1;
    return a;
}

ll mult(ll a,ll b)
{
    return (a*b)%mod1;
}

ll sub(ll a,ll b)
{
    a-=b;
    if (a<0)
        return a+mod1;
    return a;
}

ll bin_pow(ll base,ll deg)
{
    if (deg==0)
        return 1;
    ll t=bin_pow(base,deg/2);
    if (deg&1)
        return (((t*t)%mod1)*base)%mod1;
    else
        return (t*t)%mod1;
}

ll C(ll n,ll k)
{
    if (k>n)
        return 0;
    ll ans=fact[n];
    ans=mult(ans,ifact[k]);
    return mult(ans,ifact[n-k]);
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    ll ff=1;
    for (ll i=0;i<MAXN;i++)
        fact[i]=ff,ifact[i]=bin_pow(ff,mod1-2),ff*=(i+1),ff%=mod1;
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    for (ll f=1;f<=n;f++)
    {
        if (n-f>k)
            continue;
        ll sum=m;
        sum=mult(sum,bin_pow(m-1,f-1));
        sum=mult(sum,C(n-1,f-1));
        ans=add(ans,sum);
    }
    cout<<ans;
}

Measured memory_bytes: 6804
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int a, b, c, d;
    cin >> a>> b>>c>>d;
    cout << a+ b + c+d << endl;
    return 0;}


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

int main() {
    string s;
    cin >> s;
    int A[4];
    for(int i = 0; i < 4; i++) A[i] = s[i] - '0';
    string op[3];
    for (int i = 0; i < (1<<3); i++)
    {
        int ans = A[0];
        for (int j = 0; j < 3; j++)
        {
            if((i >> j) & 1){
                op[j] = '+';
                ans += A[j+1];
            }
            else{
                op[j] = '-';
                ans -= A[j+1];
            }
        }
        if(ans == 7){
            cout << A[0] << op[0] << A[1] << op[1] << A[2] << op[2] << A[3] << "=7" << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;  //これで"std::cout"が"cout"と書ける

//MACRO
typedef long long ll;                  //64bit以上を表現可能な型
#define INF 100000000                  //ほぼ無限
#define itn int                        //タイポ対策
#define all(x) (x).begin(), (x).end()  //sort(all(x))などとする
#define SZ(x) ((int)(x).size())        //size()簡略化
//repetition
#define FOR(i, p, b) for (int i = (p); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define repR(i, n) for (int i = n; i >= 0; i--)
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \<< " " << __FILE__ << endl;
template <class T>
bool chmax(T &a, const T &b) {  //aよりbが大きければaに代入
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //aよりbが小さければaに代入
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

//
//
//

int main() {
    char c;
    cin >> c;

    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }

}

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

const long long MOD = 1000000007;

int main() {
    long long n, result = 1;
    cin >> n;
    vector<long long> prime;
    bool composite[n + 1] = {};
    for (long long i = 2; i <= n; i++) {
        if (!composite[i]) {
            prime.emplace_back(i);
        }
        for (long long j = 0; j < prime.size() && i * prime[j] <= n; j++) {
            composite[i * prime[j]] = true;
            if (i % prime[j] == 0) {
                break;
            }
        }
    }
    for (long long p : prime) {
        long long count = 1, q = p;
        do {
            count += n / p;
            p *= q;
        } while (p <= n);
        result = result * count % MOD;
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

	static MyReader sc = new MyReader();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws IOException {
		int k = sc.nextInt();
		long ans = 0;
		for(int a = 1; a < k + 1; a++) {
			for(int b = 1; b < k + 1; b++) {
				for(int c = 1; c < k + 1; c++) {
					ans += GCD(GCD(a, b), c);
				}
			}
		}
		out.println(ans);
		out.close();

	}

	//GCD
	static int GCD(int n, int m) {
		if(m > n)
			return GCD(m, n);
		if(n % m == 0)
			return m;
		else {
			return GCD(m, n % m);
		}
	}

}

class MyReader {
	private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	private static String[] line = new String[0];
	private static int num = 0;

	protected MyReader() {

	}

	private void nextline() throws IOException {
		String s = in.readLine();
		line = s.split(" ");
	}

	protected String next() throws IOException {
		if(num == line.length) {
			nextline();
			num = 0;
		}
		String ret = line[num];
		num++;
		return ret;
	}

	protected int nextInt() throws IOException {
		if(num == line.length) {
			nextline();
			num = 0;
		}
		int ret = Integer.valueOf(line[num]);
		num++;
		return ret;
	}

	protected long nextLong() throws IOException {
		if(num == line.length) {
			nextline();
			num = 0;
		}
		long ret = Long.valueOf(line[num]);
		num++;
		return ret;
	}

}

// 組み合わせ計算
class Combination {
	public static int MAX = 510000;
	public static int MOD = 1000000007;

	public static long[] f = new long[MAX];
	public static long[] finv = new long[MAX];
	public static long[] inv = new long[MAX];

	protected Combination() {
		f[0] = f[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i = 2; i < MAX; i++) {
			f[i] = f[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

	public static long Com(int n, int k) {
		if(n < k)
			return 0;
		if(n < 0 || k < 0)
			return 0;
		return f[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}

	public static long Inverse(int n) {
		return inv[n];
	}

	public static long Factorial(int n) {
		return f[n];
	}
}

// union-find木
class UnionFind {
	private int[] parent;
	private int[] depth;
	private int[] size;

	protected UnionFind(int n) {
		super();
		parent = new int[n];
		for(int i = 0; i < n; i++) {
			parent[i] = i;
		}
		depth = new int[n];
		size = new int[n];
		for(int i = 0; i < n; i++) {
			depth[i] = 1;
			size[i] = 1;
		}
	}

	public int Parent(int n) {
		if(parent[n] == n) {
			return n;
		} else {
			return Parent(parent[n]);
		}
	}

	public void Union(int a, int b) {
		int pa = Parent(a);
		int pb = Parent(b);
		if(pa != pb) {
			if(depth[pa] > depth[pb]) {
				parent[pb] = pa;
				size[pa] += pb;
			} else if(depth[pa] == depth[pb]) {
				parent[pb] = pa;
				size[pa] += pb;
				depth[pa]++;
			} else {
				parent[pa] = pb;
				size[pb] += pa;
			}
		}
	}

	public int Size(int n) {
		return size[Parent(n)];
	}

}

Measured memory_bytes: 33568
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,m;
    cin >> n >> m;
    UnionFind uni(n+1);
    vector<int> p(n+1);
    rep(i,n)cin >> p[i+1];
    rep(i,m){
        int x,y;
        cin >> x >> y;
        uni.unionSet(x,y);
    }
    ll ans = 0;
    for(int i=1;i<=n;i++){
        if(p[i]==i)ans++;
        else if(uni.findSet(i,p[i]))ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if ((a == b && b == c) || (a != b && a != c && b != c)) cout << "No";
  else cout << "Yes";

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x = scan.nextInt();
		int[] mArray = new int[n];
		for (int i = 0; i < n; i++) {
			mArray[i] = scan.nextInt();
		}
		scan.close();

		int mMin = mArray[0];
		int xRest = x;
		for (int i = 0; i < n; i++) {
			xRest = xRest - mArray[i];
			if (mArray[i] < mMin) {
				mMin = mArray[i];
			}
		}
		System.out.println(mArray.length + xRest / mMin);
	}
}


Measured memory_bytes: 21716
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;

//最大公約数
ll gcd(ll a, ll b){
    if(a % b == 0)return b;
    else return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}

int main(){
    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll len = lcm(n, m);
    
    int nn = n / gcd(n, m), mm = m / gcd(n, m);
    rep(i, gcd(n, m)){
        if(s[i * nn] != t[i * mm]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << len << endl;
}



Measured memory_bytes: 3288
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

unsigned long long bitmask[10];

int main(void) {
    for(long long i = 0;i < 10;i++) {
        bitmask[i] = 1 << i;
    }
    long long d,g,p[10],c[10];
    cin >> d >> g;
    for(long long i = 0;i < d;i++) {
        cin >> p[i] >> c[i];
    }
    long long result = 10000;
    unsigned long long endb = (unsigned long long)pow(2,d);
    for(unsigned long long i = 0;i < endb;i++) {
        long long countN = 0;
        long long countS = 0;
        long long pp[10];
        for(long long k = 0;k < d;k++) {
            pp[k] = p[k];
        }
        for(long long j = 0;j< 10;j++) {
            if((bitmask[j] & i) != 0) {
                countN += p[j];
                countS += c[j];
                countS += (j+1) * 100 * p[j];
                pp[j] = 0;
            }
        }
        long long cur = d-1;
        while(countS < g && cur >= 0) {
            if(pp[cur] == 0) {
                cur--;
            }
            else {
                countS += (cur + 1) * 100;
                countN++;
                pp[cur]--;
            }
        }
        if(countS >= g)
            result = min(result,countN);
    }
    cout << result << endl;
}




Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N,M;
	std::cin >> N>>M;

	vector<pair<ll, ll>> vp(M);
	rep(i, 0, M) {
		std::cin >> vp[i].second >> vp[i].first;
	}
	sort(vp.begin(), vp.end());

	vector<pair<ll, ll>> border;
	border.push_back({ vp[0].first, vp[0].second });
	size_t idx = 0;
	rep(i, 1, M) {
		if (border[idx].first >= vp[i].first) {
			border[idx].first = vp[i].first;
			border[idx].second = max(border[idx].second, vp[i].second);
		}
		else if(border[idx].first <= vp[i].second){
			border.push_back({ vp[i].first,vp[i].second });
			idx++;
		}
	}

	std::cout << border.size() << endl;
	return 0;
}


Measured memory_bytes: 4780
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;

int main(){
   int N,K;
   int l[60];
   cin >> N >> K;
   for(int i = 0;i < N;i++) cin >> l[i];

   sort(l,l + N,greater<int>());
   int sum = 0;
   for(int i = 0; i < K;i++){
       sum += l[i];
   }
   cout << sum << endl;
}

Measured memory_bytes: 256
while True:
  q = int(input())
  score1,score2 = 0,0
  if q == 0:break
  else:
    for p in range(q):
      w = map(int,raw_input().split())
      a,b = w[0],w[1]
      if a > b:
        score1 += a+b
        
      elif a < b:
       score2 += a+b
        
      elif a == b:
        score1+=a
        score2+=a
        
    print score1,score2

Measured memory_bytes: 4468
def judge(S):
    half = int(len(S)/2)
    if S[:half] == S[half:]:
        return True
    else:
        return False

S= input()
l = len(S)
if l%2 == 1:
    S = S[:-1]
else:
    S = S[:-2]
while S != "":
    if judge(S):
        break
    S = S[:-2]

print(len(S))

Measured memory_bytes: 3060
'''
Created on 2020/08/19

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  S=pin()[:-1]
  T=list(set(S))
  if len(T)==4:
    print("Yes")
  elif len(T)==3 or len(T)==1:
    print("No")
  else:
    if (("N" in S )and ("S" in S)) or (("W" in S) and ("E" in S)):
      print("Yes")
    else:
      print("No")
  return 

main()

Measured memory_bytes: 8980
import numpy as np

N, M, X = map(int,input().split())
CA = []
for _ in range(N):
    CA.append(list(map(int,input().split())))

MIN = 10 ** 7
for i in range(2**N):
    cost = 0
    result = np.array([0] * M)
    for j in range(N):
        if ((i>>j)&1):
            cost += CA[j][0]
            result += CA[j][1:]

    if all(result >=X):
        MIN = min(cost,MIN)
if MIN == 10**7:
    print(-1)
else:
    print(MIN)

Measured memory_bytes: 27228
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

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


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


memo = {}

def countbit(x):
    i = 0
    cnt = 0
    while x >= 1<<i:
        if x & (1<<i):
            cnt += 1
        i += 1
    return cnt


def count(x):
    # if c == 0:
    #     return 0
    # s = 1
    # x = x % c
    s = 0
    while x != 0:
        s += 1
        x = x % countbit(x)
    return s

def main():
    n = int(input())
    xs = list(input())
    c = len([i for i in xs if i == '1'])
    dp = {}
    dps = {}
    for i in range(-1, 2):
        cc = c + i
        if cc == 0:
            continue
        dp[cc] = [-1] * n
        base = 1 % cc
        dpstmp = 0
        for i in range(n):
            dp[cc][i] = base
            if xs[-i-1] == '1':
                dpstmp += base
            base = base * 2 % cc
        dps[cc] = dpstmp % cc

    for i in range(n):
        cc = c
        if xs[i] == '1':
            cc -= 1
        else:
            cc += 1
        if cc == 0:
            print(0)
            continue
        res = dps[cc]
        if xs[i] == '1':
            res = (res - dp[cc][-i-1]) % cc
        else:
            res = (res + dp[cc][-i-1]) % cc
        s = count(res) + 1
        print(s)


main()


Measured memory_bytes: 95396
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <stdlib.h>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <float.h>
using namespace std;

#define N 100000

string s[N];

int main()
{
	int n;
	long long ans = 0;
 
	cin >> n;
	for( int i = 0; i < n; i++ ) {
		cin >> s[i];
	}

	long long nm[5] = {0};
	for( int i = 0; i < n; i++ ) {
		if( s[i][0] == 'M' ) {
			nm[0]++;
		}
		else if( s[i][0] == 'A' ) {
			nm[1]++;
		}
		else if( s[i][0] == 'R' ) {
			nm[2]++;
		}
		else if( s[i][0] == 'C' ) {
			nm[3]++;
		}
		else if( s[i][0] == 'H' ) {
			nm[4]++;
		}

	}

	ans += nm[0] * nm[1] * nm[2];
	ans += nm[0] * nm[1] * nm[3];
	ans += nm[0] * nm[1] * nm[4];
	ans += nm[0] * nm[2] * nm[3];
	ans += nm[0] * nm[2] * nm[4];
	ans += nm[0] * nm[3] * nm[4];
	ans += nm[1] * nm[2] * nm[3];
	ans += nm[1] * nm[2] * nm[4];
	ans += nm[1] * nm[3] * nm[4];
	ans += nm[2] * nm[3] * nm[4];

	cout << ans << endl;
 
	return 0;
}


Measured memory_bytes: 6144
n = int(input())
ns = list(map(int, input().split()))
#ns = sorted(list(set(map(int, input().split()))))
n = len(ns)
tri = []
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if j == k or i == j or i == k or i == j == k:
                pass
            else:
                ts = [ns[i], ns[j], ns[k]]
                m = max(ts)
                rest = sum(ts) - m
                if m < rest:
                    tri.append(ts)
r = []
for i in range(len(tri)):
    t = list(set(tri[i]))
    if len(t) == 3:
        r.append(t)
    
print(len(r))

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

int main() {
  int N; cin >> N;
  int P[N]; for (int i = 0; i < N; i++) cin >> P[i];
  int count = 0, min_num = 1000000;
  for (int i = 0; i < N; i++) {
    if (P[i] <= min_num) {
      count++; min_num = P[i];
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 1024
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-01-27 10:30:59
# @Description: You build it. You run it
# @More: Once lots of AC, try Brute-force,dynamic programming
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
typedef long long ll;
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int main()
{
    int a[3];
    for(int i = 0; i < 3; i++){
        cin >> a[i];
    }sort(a, a+3);
    if(a[0] == 5 && a[1] == 5 && a[2] == 7)puts("YES");
    else puts("NO");
    
    //system("pause");
}
/***************************************************************************
*stuff you should look for
*int overflow, array bounds
*special cases (n=1?), set tle
*do smth instead of nothing and stay organized
***************************************************************************/

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  db r;cin>>r;
  cout<<2*acos(-1.0)*r<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
int a[200010];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	if(n%2==0){
		for(int i=n;i>0;i-=2)
		cout<<a[i]<<" ";
		for(int i=1;i<n;i+=2)
		cout<<a[i]<<" ";
	}
	else{
		for(int i=n;i>0;i-=2)
		cout<<a[i]<<" ";
		for(int i=2;i<n;i+=2)
		cout<<a[i]<<" ";
	}
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
int main(){
  int d[]={400,800,1200,1600,2000,2400,2800,3200,5000};
  int i,n,a,b[10]={};
  scanf("%d",&n);
  while(n--){
    scanf("%d",&a);
    for(i=0;d[i]<=a;i++);
    b[i]++;//printf("%d\n",i);
  }
  for(i=a=0;i<8;i++){
    if(b[i])a++;
  }
  printf("%d %d\n",a?a:1,a+b[8]);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
//とりまイントとダブルが入り乱れるときは
//とりまどちらかに統一しよう。

int max(int x,int y){
  if(x>y) return x;
  return y;
}

int min(int x,int y){
  if(x<y) return x;
  return y;
}

int main() {
  int n;
  cin >> n;
  int res = 0;
  bool judge=false;
  for (int a = 0; a <= 26; ++a) {
    for (int b = 0; b <= 14; ++b) {
        int total = 4*a + 7*b; // 合計金額
        if (total == n) {
          judge=true;
          break; // 合計金額が X に一致したらbreak
        }
    }
    if(judge==true)break;
  }
  if(judge==true)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
from sys import stdin
from itertools import combinations_with_replacement

input = stdin.readline
N,M,Q = map(int, input().split())
numlist = [i for i in range(1,M+1)]
A = [0]*(Q+1)
B = [0]*(Q+1)
C = [0]*(Q+1)
D = [0]*(Q+1)
for q in range(1,Q+1):
    A[q],B[q],C[q],D[q] = map(int, input().split())

maxscore = 0
for tpl in combinations_with_replacement(numlist,N):
    score = 0
    for q in range(1,Q+1):
        if tpl[B[q]-1] - tpl[A[q]-1] == C[q]:
            score += D[q]
    maxscore = max(maxscore, score)
print(maxscore)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
using namespace std;
const int N = 1e5+10;
long double cnt[N];
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        string s;cin>>s;
        cnt[s[0]]++;
    }
    int a[]={cnt['M'],cnt['A'],cnt['R'],cnt['C'],cnt['H']};
    int ans=0;
    for(int i=0;i<5;i++)
        for(int j=i+1;j<5;j++)
            for(int k=j+1;k<5;k++)
                ans+=a[i]*a[j]*a[k];
    cout<<ans;
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong(), M = scanner.nextLong();
        Map<Long, Long> drinks = new TreeMap<>();
        for(int i = 0; i < N; i++){
            Long key = scanner.nextLong();
            Long value = scanner.nextLong();
            drinks.computeIfPresent(key,(k, v) -> v + value);
            drinks.computeIfAbsent(key,(k) -> value);
        }
        drinks.entrySet().stream().sorted((m1, m2) -> {
            return m1.getKey().compareTo(m2.getKey());
        });
        long ans = 0;
        for(Long k : drinks.keySet()){
            long buy = Long.min(drinks.get(k), M);
            ans += (buy * k);
            M -= buy;
            if(M == 0)
                break;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 100564
<?php
declare(strict_types=1);

//引数を取得
list($s) = fscanf(STDIN, '%s');

//天気を設定
$weatherArray = ['Sunny', 'Cloudy', 'Rainy']; 

//現在の天気から明日の天気のインデックスを取得
$weatherIndex = array_search($s, $weatherArray) + 1;

//天気のインデックスがなければ0に設定
if (!array_key_exists($weatherIndex, $weatherArray)) {
    $weatherIndex = 0;
}

//明日の天気を出力
echo $weatherArray[$weatherIndex];


Measured memory_bytes: 4728
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
#include<cstdio>
#include <iomanip>
#include <limits>

using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
typedef pair<ll, ll > P;
const int MOD = 1000000007;


int main() {
	ll i, j, k, l, m, n, sum, flag, cc, M, X, H, W, N,Y,Z,K;
	cc = 0;
	flag = 0;
	double x[3];
	double y[3];
	double a[3];
	REP(i, 0, 3) {
		cin >> x[i] >> y[i];

	}
	REP(i, 0, 3) {
		a[i] = sqrt((x[(i + 1) % 3] - x[i])*(x[(i + 1) % 3] - x[i]) + (y[(i + 1) % 3] - y[i])*(y[(i + 1) % 3] - y[i]));
	}
	sort(a, a + 3);
	double maxa;
	maxa = a[2];
	REP(i, 0, 3) {
	//	output(a[i]);
	}
	double r;
	r =abs((x[1] - x[0])*(y[2] - y[0]) - (x[2] - x[0])*(y[1] - y[0])) / (a[0] + a[1] + a[2]);
	double ans;
	ans = r * maxa / (2 * r + maxa);
	//output(r);
	cout << setprecision(11)<<ans << endl;


	return 0;
}





Measured memory_bytes: 256