akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int numOfDivisor(int n)
{
    int num = 0;
    for (int i = 1; i <= n; i = i + 2) {
        if (n % i == 0) {
            ++num;
        }
    }

    return num;
}

int main()
{
    int N;
    std::cin >> N;

    int cnt = 0;
    for (int i = 1; i <= N; i = i + 2) {
        if (numOfDivisor(i) == 8) {
            ++cnt;
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

ll gcd(ll a,ll b){
  if(a<b) swap(a,b);
  if(a%b==0) return b;
  return gcd(b,a%b);
}

int main(){
  int i,j;
  ll a,b;
  cin>>a>>b;
  ll g=gcd(a,b);
  cout<<a*b/g<<endl;

  return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> num(n);
  int cnt = 0;
  for(int i = 1; i <= n; i++){
    cin >> num.at(i - 1);
    if(i != num.at(i - 1)) cnt++;
  }
  if(cnt <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
from collections import *
H,W,K=map(int,input().split())
A=[list(input()) for i in range(H)]
SX,SY=0,0
for i in range(H):
  for j in range(W):
    if A[i][j]=='S':
      SX,SY=j,i
D=deque()
Z=set()
P=1
def qao(y,x):
  if min(x,y)==0 or x+1==W or y+1==H:
    print(P)
    exit()
  if (y,x) in Z:
    return False
  D.append((y,x))
  Z.add((y,x))
  return True

w4x=(1,0,-1,0)
w4y=(0,1,0,-1)
def bfs(F):
  v=0
  for i in range(len(D)):
    v=D.popleft()
    for j in range(4):
      if A[v[0]+w4y[j]][v[1]+w4x[j]]=='.' or F:
        qao(v[0]+w4y[j],v[1]+w4x[j])

qao(SY,SX)
for i in range(K):
  bfs(0)
D=deque(Z)
while True:
  P+=1
  for i in range(K):
    bfs(1)

Measured memory_bytes: 131356
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll r; cin >> r;
	cout << 3 * r * r;
	return 0;
}
/*

*/

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll all_xor = 0;
  rep(i, n) {
    cin >> a[i];
    all_xor ^= a[i];
  }

  rep(i, n) {
    cout << (all_xor ^ a[i]);
    if (i != n - 1)
      cout << " ";
    else
      cout << endl;
  }
  return 0;
}


Measured memory_bytes: 4772
def score(str)
  sr = str.split("L").reject(&:empty?).map { |x| x.count("R") - 1 }.inject(:+)
  sl = str.split("R").reject(&:empty?).map { |x| x.count("L") - 1 }.inject(:+)
  sr.to_i + sl.to_i
end

n, k = gets.split.map(&:to_i)
s = gets.chomp

if s.count("L") == n || s.count("R") == n
  puts n - 1
  exit
end

sr = s.split("L").reject(&:empty?)
sl = s.split("R").reject(&:empty?)
if sl.size > sr.size
  # L増やす
  cnt = (k > sr.size ? sr.size : k)
  cnt.times do |i|
    break if sr[i].nil?
    sr[i] = sr[i].gsub!("R", "L")
  end
elsif sl.size < sr.size
  # R増やす
  cnt = (k > sr.size ? sr.size : k)
  cnt.times do |i|
    break if sl[i].nil?
    sl[i] = sl[i].gsub!("L", "R")
  end
else
  cnt = (k > sr.size ? sr.size : k)
  if s[0] == "L"
    cnt.times do |i|
      break if sr[i].nil?
      sr[i] = sr[i].gsub!("R", "L")
    end
  else
    cnt.times do |i|
      break if sl[i].nil?
      sl[i] = sl[i].gsub!("L", "R")
    end
  end
end
ans = []
l_first = (sl.size > sr.size)
if sl.size == sr.size
  l_first = (s[0] == "L")
end
until sl.empty? && sr.empty?
  if l_first
    ans << sl.shift
    l_first = false
  else
    ans << sr.shift
    l_first = true
  end
end
p score(ans.join(""))


Measured memory_bytes: 18272
H, W = gets.split.map(&:to_i)
INFINITY = 999999999

dark = []
max_hw = Array.new(H) { Array.new(W, INFINITY) }

H.times do |i|
  gets.chomp.each_char.with_index do |c, idx|
    if c == '#'
      dark.unshift([i, idx, 0])
      max_hw[i][idx] = 0
    end
  end
end

count = 0

while !dark.empty?
  y, x, count = dark.shift
  count += 1

  # up
  if y != 0
    if max_hw[y - 1][x] == INFINITY
      max_hw[y - 1][x] = count
      dark << [y - 1, x, count]
    end
  end

  # bottom
  if y + 1 < H
    if max_hw[y + 1][x] == INFINITY
      max_hw[y + 1][x] = count
      dark << [y + 1, x, count]
    end
  end

  # left
  if x != 0
    if max_hw[y][x - 1] == INFINITY
      max_hw[y][x - 1] = count
      dark << [y, x - 1, count]
    end
  end

  # right
  if x + 1 < W
    if max_hw[y][x + 1] == INFINITY
      max_hw[y][x + 1] = count
      dark << [y, x + 1, count]
    end
  end
end

puts count - 1

Measured memory_bytes: 86140
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[500009],br[500009];
int main()
{
    ll a,b,c,i,j,k;
    string s;
    cin>>a>>s;
    if(a%2==1)
    {
        cout<<"No"<<endl;
    }
    else
    {
        for(i=0;i<(a/2);i++)
        {
            if(s[i]!=s[(a/2)+i])
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

ll n, v[MAX], a[MAX];
long long t, ans;

void solve() {
	memset(v, 0, sizeof v);
	cin >> n;
	for(int i=0; i<n; i++) {
		int x;
		cin >> x;
		v[x]++;
		a[i] = x;
	}
	
	t = 0ll;
       	for(int i=1; i<=n; i++) {
		t += (ll)((v[i] * (v[i]-1)) / 2);
	}
	
	for(int i=0; i<n; i++) {
		ans = (ll)(t) + 1ll - (ll)(v[a[i]]);
		cout << (ll)(ans) << "\n";
	}
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 13000
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{one, zero, One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize, k: usize,
        mut a: [i64; n]
    }

    for _ in 0..k {
        let next = ch(&a);
        if a == next {
            break;
        }
        a = next;
        // println!("{}", a.iter().join(" "));
    }
    println!("{}", a.iter().join(" "));
}

fn ch(a: &Vec<i64>) -> Vec<i64> {
    let mut res = vec![0i64; a.len() + 1];
    for (i, v) in a.iter().enumerate() {
        res[max(i as i64 - *v, 0) as usize] += 1;
        res[min(i as i64 + *v + 1, a.len() as i64) as usize] -= 1;
    }
    // res[a.len()] = -cur;

    let mut ret = Vec::new();
    let mut cur = 0;
    for i in res.iter().take(a.len()) {
        cur += i;
        ret.push(cur);
    }

    ret
}


Measured memory_bytes: 8832
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 11;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int dp[2050][2050];
int mx[2050][2050];
int mn[2050][2050];
int in1[2050];
int in2[2050];
int main() {
	int N, i, j;
	scanf("%d %d %d", &N, &in1[0], &in2[0]);
	for (i = 1; i <= N; i++) {
		scanf("%d", &in1[i]);
		in2[i] = in1[i];
	}

	for (i = 0; i <= N + 1; i++) mn[i][N + 1] = mn[N + 1][i] = INF;
	for (i = N; i >= 0; i--) {
		for (j = N; j >= 0; j--) {
			if (i != N && j != N) continue;
			dp[i][j] = abs(in1[i] - in2[j]);
			mx[i][j] = max(mx[i + 1][j], dp[i][j]);
			mn[i][j] = min(mn[i][j + 1], dp[i][j]);
		}
	}
	for (i = N - 1; i >= 0; i--) {
		for (j = N - 1; j >= 0; j--) {
			if (i > j) dp[i][j] = mn[i][i + 1];
			else dp[i][j] = mx[j + 1][j];
			mx[i][j] = max(mx[i + 1][j], dp[i][j]);
			mn[i][j] = min(mn[i][j + 1], dp[i][j]);
		}
	}
	return !printf("%d\n", dp[0][0]);
}

Measured memory_bytes: 49408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if((b*10+c)%4==0){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Security.Principal;
using System.Text;
class Simple {
    private int N;
    private int[] d;
    void Solve() {
        //input
        N = io.Int;
        d = new int[N];
        for(int i = 0; i < N; ++i) d[i] = io.Int;
        //cal
        var ans = d.Distinct().Count();
        //ret
        Console.WriteLine(ans);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] {' '};
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if(BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while(st == "") st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}

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

// ワ―シャルフロイド法 O(V^3)
int M[10][10];
// main関数からこれらを削除すること

void warshall_floyd() { // 隣接行列Mを書き換える
  for(int i = 0; i < 10; i++) // 経由する頂点
    for(int j = 0; j < 10; j++) // 始点
      for(int k = 0; k < 10; k++) // 終点
        M[j][k] = min(M[j][k], M[j][i] + M[i][k]);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 重み付き無向(有向)グラフの隣接行列
  int h, w;
  cin >> h >> w;
  
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> M[i][j];
    }
  }
  
  warshall_floyd();
  
  int a, ans = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> a;
      if(a != -1) ans += M[a][1];
    }
  }
  
  cout << ans << '\n';
}

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

int main(){
  ll a,b;
  ll n;
  ll ans;
  ll syou;
  ll amari;
  cin >> n >> a >> b;
  syou = n / (a+b);
  amari = n % (a+b);
  if(amari >= a) ans = a*syou + a;
  if(amari < a) ans = a*syou + amari;
  cout << ans << endl;
  return 0;
}

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

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b==0) {
        x=1;
        y=0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1LL;
    if(P%2LL==0){
        ll t = RepeatSquaring(N, P/2LL, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1LL, M);
}
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll k=n;
    ll mod=1e9+7;
    ll ans=RepeatSquaring(2LL,k,mod);
    ll nca_a=1,nca_b=1,ncb_a=1,ncb_b=1;
    for(ll i=0; i<a; i++){
        nca_a*=(n-i);
        nca_b*=(i+1LL);
        nca_a%=mod;
        nca_b%=mod;
    }
    for(ll i=0; i<b; i++){
        ncb_a*=(n-i);
        ncb_b*=(i+1LL);
        ncb_a%=mod;
        ncb_b%=mod;
    }
    ll nca=nca_a*modinv(nca_b,mod)%mod,ncb=ncb_a*modinv(ncb_b,mod)%mod;
    //cout<<nca<<" "<<ncb;
    ans-=nca;
    if(ans<0) ans+=mod;
    ans-=ncb;
    if(ans<0) ans+=mod;
    ans-=1LL;
    if(ans<0) ans+=mod;
    cout<<ans%mod<<endl;
}


Measured memory_bytes: 256
N,K,S=map(int,input().split())
ans=[S]*K
if len(ans)<N:
    nk=N-K
    if S==1000000000:
        aps=S-1
    else:
        aps=S+1
    for i in range(nk):
        ans.append(aps)
print(' '.join(map(str,ans)))

Measured memory_bytes: 12068
N = int(input())
G = {i:[] for i in range(1,N+1)}
A = list(map(int,input().split()))
A.insert(0,0)
A.insert(0,0)
for i in range(2,N+1):
    G[A[i]].append(i)
for i in range(1,N+1):
    print(len(G[i]))

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

int main() {
	int n, q;
	cin >> n >> q;
	vector<priority_queue<int>> Q(n);
	for (int i = 0; i < q; ++i) {
		int query, t;
		cin >> query >> t;
		if (query == 0) {
			int x;
			cin >> x;
			Q[t].push(x);
		}
		else if (query == 1) {
			if (!Q[t].empty()) cout << Q[t].top() << endl;
		}
		else {
			if (!Q[t].empty()) Q[t].pop();
		}
	}
}


Measured memory_bytes: 4120
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
*/
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli n,i,h;
    cin>>n>>h;
    lli a[n],b[n],dp[n];
    vplli v;
    rep(i,0,n)
    {
        dp[i]=0;
        cin>>a[i]>>b[i];
        v.pb(mp(a[i],0));
        v.pb(mp(b[i],1));
    }
    lli ans=0;
    sort(ALL(v));
    reverse(ALL(v));
    rep(i,0,v.sz())
    {
        if(v[i].s)
        {
            h-=v[i].f;
            ans++;
        }
        else
        {
            lli temp=h/v[i].f;
            if(h%v[i].f)
            {
                temp++;
            }
            h-=temp*v[i].f;
            ans+=temp;
        }
        if(h<=0)
        {
            break;
        }
    }
    cout<<ans;
}



Measured memory_bytes: 7792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    ll  n;
    cin >> n;
    vector<ll> p(n);
    ll tmp;
    for(int i = 0; i < n;i++){
        cin >> tmp;
        p[i] = tmp;
    }

    ll min=MOD;
    ll ans = 0;

    for(int i = 0; i < n;i++){
        if(p[i] <= min){
            ans++;
            min = p[i];
        }
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 1792
import sys
from collections import defaultdict
data_list = []

for line in sys.stdin:
    data_list.append(list(map(int, line.split())))

def is_half_euler_graph(node_list):
    for node in node_list:
        isBool = True
        for dic_key, dic_value in node.items():
            if dic_key != 1 and dic_key != 2:
                if dic_value % 2 != 0:
                    isBool = False
                    break
            else :
                if dic_value % 2 == 0:
                    isBool = False
                    break
        if isBool :
            print("OK")
        else :
            print("NG")



if __name__ == '__main__' :
    node_data_lists = []
    tmp_list = []
    count_lists = []
    tmp_dic = {}
    tmp_dic = defaultdict(int)

    for i in range(0, len(data_list)):
        if data_list[i][0] == 0 and data_list[i][1] == 0:
            node_data_lists.append(tmp_list[:])
            tmp_list.clear()
        else :
            tmp_list.append(data_list[i])

    for node_data_list in node_data_lists :
        tmp_dic.clear()
        for i in range(0, len(node_data_list)):
            tmp_dic[node_data_list[i][0]] += 1
            tmp_dic[node_data_list[i][1]] += 1

        count_lists.append(tmp_dic.copy())

    is_half_euler_graph(count_lists)


Measured memory_bytes: 6044
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll n, k;
    cin >> n >> k;
    ll a[n];
    za(n, a);
    rp(i, 0, k)
    {
        ll y;
        cin >> y;
        rp(j, 0, y)
        {
            ll x;
            cin >> x;
            a[x - 1]++;
        }
    }
    ll ans = 0;
    rp(i, 0, n) if (a[i] == 0) ans++;
    ce(ans);
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
vector<lli> factorize(lli n) {
    vector<lli> res;
    for (lli i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}
int main() {
    fast;
    lli a,b;
    cin>>a>>b;
    vector<lli>v=factorize(a),w=factorize(b);
    v.erase(unique(v.begin(),v.end()),v.end());
    w.erase(unique(w.begin(),w.end()),w.end());
    map<lli,lli>m;
    lli ans=0,i;
    fr(i,v.size())
    {
        m[v[i]]=1;
    }
    fr(i,w.size())
    {
        if(m[w[i]]==1)
            ans++;
    }
    cout<<ans+1;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n, m, in;
    cin >> n >> m;
    rep(i, m){
        cin >> in;
        n -= in;
    }
    if(n >= 0){
        cout << n << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

typedef struct aaaa{
	lli a,b,c,d;
};
lli a[600][600];

signed main(){

	lli h,w;
	cin>>h>>w;

	REP(i,1,h+1)REP(j,1,w+1)cin>>a[i][j];

	lli state=0;
	lli oi,oj,ti,tj;
	lli bi=1,bj=1;
	vector<aaaa> ans;
	vector<aaaa> v;
	for(lli i=1;i<=h;i++){
		lli sj,pj;
		if(i%2==1)sj=1,pj=1;
		else sj=w,pj=-1;
		for(lli j=sj;j>=1 && j<=w;j+=pj){
			if(state){
				v.push_back({bi,bj,i,j});
			}
			if(DEBUG)cout<<"i="<<i<<" j="<<j<<endl;
			if(a[i][j]%2==1){
				if(state==0){
					oi=i,oj=j;
					state=1;
					a[i][j]--;
				}
				else{
					ti=i,tj=j;
					state=0;
					a[i][j]++;
					REP(f,0,v.size()){
						ans.push_back(v[f]);
					}
					v.clear();
				}
			}
			bi=i,bj=j;
		}
	}
	cout<<ans.size()<<endl;
	REP(i,0,ans.size())cout<<ans[i].a<<" "<<ans[i].b<<" "<<ans[i].c<<" "<<ans[i].d<<endl;



	return 0;
}

Measured memory_bytes: 8688
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <utility>
#include <string>
#include <cctype>
#include <cstdlib>
#include <algorithm>
using namespace std;

typedef long long LL;

LL gcd(LL a, LL b){
	while(b){
		LL r = a % b;
		a = b;
		b = r;
	}
	return a;
}

struct frac{
	LL num, den;

	frac(LL n, LL d = 1LL) : num(n), den(d){
		LL g = gcd(num, den);
		num /= g;
		den /= g;
	}

	frac operator +(const frac &f) const{
		return frac(f.den * num + f.num * den , den * f.den);
	}

	frac operator -(const frac &f) const{
		return frac(num * f.den - f.num * den, den * f.den);
	}

	frac operator *(const frac &f) const{
		return frac(num * f.num, den * f.den);
	}
	
	frac operator /(const frac &f) const{
		return frac(num * f.den, den * f.num);
	}
};


char name[4];
const char *ptr;
map<string,int> tbl;

vector<int> parse(){
	vector<int> ret(tbl.size());

	while(true){
		if( *ptr == '(' ){
			++ptr;
			vector<int> r = parse();
			++ptr;
			
			int x = 1;
			if( isdigit(*ptr) ){
				char *endp;
				x = strtol(ptr, &endp, 10);
				ptr = endp;
			}
			
			for(int i = 0; i < tbl.size(); ++i){
				ret[i] += r[i] * x;
			}
		}
		else if( isupper(*ptr) ){
			name[0] = *ptr++;
			name[1] = 0;
			
			if( islower(*ptr) ){
				name[1] = *ptr++;
			}

			int y = tbl[name];
			int x = 1;

			if( isdigit(*ptr) ){
				char *endp;
				x = strtol(ptr, &endp, 10);
				ptr = endp;
			}
			
			ret[y] += x;
		}
		else{
			break;
		}
	}
	return ret;
}


int main(){
	string expr;
	while( cin >> expr, expr[0] != '.' ){
		tbl.clear();

		int dim = 1;

		for( ptr = expr.c_str(); *ptr != '.'; ){
			if( *ptr == '+' || *ptr == '-' ){
				++dim;
			}

			if( isupper(*ptr) ){
				name[0] = *ptr++;
				name[1] = 0;
				
				if( islower(*ptr) ){
					name[1] = *ptr++;
				}

				tbl.insert( make_pair(name, tbl.size()) );
			}
			else{
				++ptr;
			}
		}

		int n = tbl.size();
		vector<vector<frac> > a(n + 1, vector<frac>(dim + 1, 0));

		a[n][0] = a[n][dim] = 1;

		bool minus = false;
		ptr = expr.c_str();
		for(int u = 0; u < dim; ++u){
			vector<int> res = parse();
			for(int i = 0; i < n; ++i){
				if( minus ){
					a[i][u] = -res[i];
				}
				else{
					a[i][u] = res[i];
				}
			}

			if( *ptr == '-' ){
				ptr += 2;
				minus = true;
			}
			else{
				++ptr;
			}

		}
		swap(a[0], a[n]);

		for(int i = 0; i < min(dim, n+1); ++i){
			int index;
			for(index = i; index <= n && a[index][i].num == 0; ++index);
			if( index > n ) continue;
			a[i].swap(a[index]);

			frac piv = a[i][i];
			for(int j = i; j <= dim; ++j){
				a[i][j] = a[i][j] / piv;
			}

			for(int j = 0; j <= n; ++j){
				if(i == j){	continue;	}
				frac t = a[j][i];

				for(int k = 0; k <= dim; ++k){
					a[j][k] = a[j][k] - t * a[i][k];
				}
			}
		}

		LL lcm = 1;
		for(int i = 0; i <= n; ++i){
			lcm *= a[i][dim].den / gcd(lcm, a[i][dim].den);
		}

		for(int i = 0; i < dim; ++i){
			LL z = lcm / a[i][dim].den * a[i][dim].num;
			if( i != 0 ){	cout << ' ';	}
			cout << z;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1228
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    A = [INT() for _ in range(N)]

    ctr = Counter(A)
    ans = 0
    for c in ctr.values():
        if c % 2 == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21568
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	int a,b,c;
	cin>>a>>b>>c;
	set<int>s;
	s.clear();
	s.insert(a), s.insert(b), s.insert(c);
	cout<<(int)s.size()<<endl;
	return 0;
}

 

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

using namespace std;

#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 each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a == c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

const int N = 300004;
int cnth[N], cntw[N], x[N], y[N];
map <int, bool> mp[N];

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, w, m;
    cin >> h >> w >> m;
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i];
        mp[x[i]][y[i]] = true;
        cnth[x[i]]++, cntw[y[i]]++;
    }
    int mxh = 0, mxw = 0;
    for (int i = 0; i < N; i++) {
        mxh = max(mxh, cnth[i]);
        mxw = max(mxw, cntw[i]);
    }
    vector <int> hall, wall;
    for (int i = 0; i < N; i++) {
        if (cnth[i] == mxh) {
            hall.push_back(i);
        }
        if (cntw[i] == mxw) {
            wall.push_back(i);
        }
    }
    int cnt = 0, mx = 0;
    for (int i = 0; i < hall.size(); i++) {
        for (int j = 0; j < wall.size(); j++) {
            cnt++;
            if (cnt > N * 2)
                break;
            mx = max(mx, mxh + mxw - mp[hall[i]][wall[j]]);
        }
        if (cnt > N * 2)
            break;
    }
    cout << mx;
}

Measured memory_bytes: 66540
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++) cin >> X[i];

    vector<int> v = X;
    sort(v.begin(), v.end());

    int a = v[N/2-1], b = v[N/2];
    
    int ans;
    for (int i = 0; i < N; i++) {
        if (X[i] >= b) ans = a;
        if (X[i] <= a) ans = b;
        cout << ans << '\n';
    }
}

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

    solve();

    return 0;
}

Measured memory_bytes: 4792
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

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

  vi ans(n,0);
  rep(i,m){
    int a,b;
    cin >> a >> b;

    ans[a-1]++;
    ans[b-1]++;
  }

  rep(i,n) cout << ans[i] << endl;
  return 0;
} 

Measured memory_bytes: 3592
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
  b.append([a[i],i])
b.sort(reverse=True)
now = [0]
for i in range(n):
  aj,j = b[i]
  last = now
  now = []
  for l in range(i+1):
    r = l+n-1-i
    now.append(last[l]+aj*abs(r-j))
    #print(aj,j,l,r,abs(r-j))
  #print(now,'#',aj,j)
  for l in range(i):
    now[l+1] = max(now[l+1],last[l]+aj*abs(l-j))
  now.append(last[-1]+aj*abs(i-j))
  #print(now)
print(max(now))

Measured memory_bytes: 69148
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof (a))
#define gcd(a,b) __gcd(a,b)
#define all(a) a.begin(),a.end()
#define in(a) insert(a)
#define sz() size()
#define endl '\n'
#define pb push_back
typedef unsigned long long ll;
const int maxn=100010;
const int inf=1e9;
const ll mod=998244353;
const double pi=3.14159265358979;
const double ep=0.0;
using namespace std;
int vis[maxn]={0};
int main()
{
    int n,k,r,s,p;
    string ss;
    cin>>n>>k>>r>>s>>p>>ss;
    int ans=0;
    for (int i=0;i<n;i++)
    {
        if (i>=k&&vis[i-k]&&ss[i]==ss[i-k])
            continue;
        if (ss[i]=='r')
            ans+=p;
        if (ss[i]=='s')
            ans+=r;
        if (ss[i]=='p')
            ans+=s;
        vis[i]=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 832
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int check = 0;

		for (int i=0; i<str.length()-1; i++){
			char a = str.charAt(i);
			for (int j=i+1; j<str.length(); j++){
				char b = str.charAt(j);
				if (a == b){
					check++;
				}
			}
		}

		if (check == 0){
			System.out.println("yes");
		}
		else{
			System.out.println("no");
		}
	}
}

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

using namespace std;

typedef long long ll;

const int maxn = 2e5+5;
const ll mod = ll(1e9+7);

char s[maxn];
int s2[maxn];

int main()
{
    int n;
    scanf("%d%s",&n,s);
    s2[0] = 1;
    for(int i=1;i<2*n;i++)
    {
        if(s[i]==s[i-1])
            s2[i] = (s2[i-1]+1)%2;
        else
            s2[i] = s2[i-1];
    }
    ll sum = 1LL;
    for(int i=2;i<=n;i++)
    {
        sum = (sum * (ll)i)%mod;
    }
    //cout << sum << endl;
    int num = 0;
    for(int i=0;i<2*n;i++)
    {
        //out << sum << "*" << num << endl;
        if(s2[i]==1)
            num++;
        else
        {
            sum = (sum * ll(num))%mod;
            //cout << sum << "*" << num << endl;
            num--;
        }
    }
    if(s[0]=='W'||num!=0)
        printf("0\n");
    else
        printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 200005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));

using namespace std;
using P = pair<long long, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];

int H, W;

long long dp[1005][1005];
long long a[1005][1005];

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

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination() {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= MAX; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[MAX] = CalcPow(fact[MAX], MOD - 2);
	for (int i = MAX - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

int dfs(int y, int x) {
	if (dp[y][x] != -1)return dp[y][x];
	ll count = 1;
	for (int i = 0; i < 4;++i) {
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (ny < 0 || H <= ny || nx < 0 || W <= nx)continue;
		if (a[y][x] < a[ny][nx]) {
			count = (count + dfs(ny, nx)) % MOD;
		}
	}
	dp[y][x] = count;
	return count;
}

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;

	string ans = "No";
	if (N % 2 == 0) {
		ans = "Yes";
		int half = N / 2;
		string halfStr = "";
		for (int i = 0; i < N;++i) {	
			if (i < half) {
				halfStr += S[i];
			}
			else {
				if (S[i] != halfStr[i - half])ans = "No";
			}
		}
	}
	cout << ans << endl;
}

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


int main(){
  
  int m, f, r;
  while(cin >> m >> f >> r){
    if(m==-1 && f==-1 && r==-1) break;

    if(m==-1 || f==-1){
      cout << "F" << endl;
    }else if(m+f >= 80){
      cout << "A" << endl;
    }else if(m+f >= 65){
      cout << "B" << endl;
    }else if(m+f >= 50){
      cout << "C" << endl;
    }else if(m+f >= 30){
      if(r >= 50){
        cout << "C" << endl;
      }else{
        cout << "D" << endl;
      }
    }else{
      cout << "F" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3096
// Problem : A - Air Conditioner
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#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;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

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

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int t;
	cin>>t;
	if(t>=30)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()

{

    ll n, ans = 0;
    cin >> n;
    while(n--)
    {

        ll x;
        cin >> x;
        x--;
        ans+=x;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int i, j, k;
	int n, minn = 99999;
	string s;

	cin >> s;

	for (i = 2; i < s.length(); i++) {
		//string ss += s[i] + s[i - 1] + s[i - 2];
		string s1;
		s1 += s[i - 2];
		s1 += s[i - 1];
		s1 += s[i];

		minn = min(abs(stoi(s1) - 753), minn);
	
	}

	cout << minn << endl;









	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a,b,c,g;
    scanf("%d %d %d",&a,&b,&c);
    if (a>b) {
        g=a;
        a=b;
        b=g;
    }
    if(b>c){
        g=b;
        b=c;
        c=g;
    }
    if(a>b){
        g=a;
        a=b;
        b=g;
    }
    
    printf("%d %d %d\n",a,b,c);
    return 0;
}



Measured memory_bytes: 2124
N=int(input())
P=list(map(float,input().split()))
dp=[[0]*(N+1) for i in range(N+1)]
dp[0][0]=1
for i in range(1,N+1):
  for j in range(N+1):
    dp[i][j]=dp[i-1][j-1]*P[i-1]+dp[i-1][j]*(1-P[i-1])
ans=0

for i in range(N//2+1,N+1):
  ans+=dp[-1][i]
print(ans)

Measured memory_bytes: 259720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 0;
    rep(i, n) {
        ll t;
        cin >> t;
        if ((t < a) || (t >= b)) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
string s[302];
int n,ans;
int main()
{
	cin>>n;
	for (int i=0;i<n;++i) cin>>s[i];
	for (int iter=0;iter<n;++iter)
	{
		for (int i=0;i<n;++i) rotate(s[i].begin(),s[i].begin()+1,s[i].end());
		bool flag=true;
		for (int i=0;i<n;++i) for (int j=i+1;j<n;++j) flag&=(s[i][j]==s[j][i]);
		ans+=flag;
	}
	cout<<ans*n<<endl;
	return 0;
}

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

int main() {
    int64_t n, j, ans = 1e12, count;
    cin >> n;

    for(int i=1; i<=sqrt(n); i++){
        if(n%i==0) {
            j = n/i;
        }
        count = 0;
        count += i+j-2;
        ans = min(ans, count);
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <map>
#define ll long long
using namespace std;
const int  N=1e5+9;
int  n,a[N];
int main()
{
    while(~scanf("%d",&n))
    {
        for(int i=1; i<=n; i++)
        {
            scanf("%d",&a[i]);
        }
        a[n+1]=-1;
        int cnt=0;

        int i=1;
        while(i<=n)
        {
            if(a[i]==i&&a[i+1]==i+1)
            {
                cnt++;
                i+=2;

            }
            else if(a[i]==i&&a[i+1]!=i+1)
            {
                cnt++;
                i+=2;

            }
            else
            {
                i++;
            }
        }
 printf("%d\n",cnt);
    }
return 0;
}


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

using namespace std;

#define MOD 2019

int m[2020];

int choose(int n) {
    if (n < 2) return 0;
    return n*(n-1)/2;
}

int main() {
    string s; cin >> s;
    memset(m, 0, sizeof(m));
    int n = s.size();
    vector<int> arr(n + 1);
    vector<int> p(n);
    p[n - 1] = 1;
    for (int i = n - 2; i >= 0; i--) p[i] = p[i+1]*10 % MOD;
    arr[n] = 0;
    int c = 0;
    for (int i = n - 1; i >= 0; i--) {
        arr[i] = ((s[i] - '0')*p[i] + arr[i + 1]) % MOD;
        c = c - choose(m[arr[i]]) + choose(++m[arr[i]]);
    }
    c = c - choose(m[0]) + choose(++m[0]);
    cout << c << endl;

    return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int x, y;
  if (c % b) x = c / b + 1;
  else x = c / b;
  if (a % d) y = a / d + 1;
  else y = a / d;
  if (x <= y) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3576
from collections import Counter
from itertools import combinations

N = int(input())
L = Counter(list(map(int, input().split())))
ans = 0
for sides in combinations(L.keys(), 3):
    a, b, c = sorted(sides)
    if a + b > c:
        ans += L[a]*L[b]*L[c]
print(ans)

Measured memory_bytes: 73956