akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#include <stdio.h>
using namespace std;
int main(){
  /* while(true){
    stack<char> st;
    string str;
    int flag = 0;
    cin >> str;
    if(str == ".")return 0;
    int i = 0;
    while(true){
      if(str[i] == '(' || str[i] == '['){
	st.push();
      }

    }
    
    
  }
  }*/
  
  int flag = 0;
  while(true){
    stack<char> st;
    char tmp;
    scanf("%c",&tmp);
    if(tmp == '.')return 0;
    if(tmp != '\n'){
      while(true){
	if(tmp == '(' || tmp == '['){
	  //cout << "入力" << tmp << endl;
	  st.push(tmp);
	}
	else if(tmp == ')' || tmp == ']'){
	  if(tmp == ')')tmp = '(';
	  if(tmp == ']')tmp = '[';
	  if(st.empty()){
	    flag = 1;
	    //break;
	  }
	  else if(st.top() != tmp){
	   
	    //  cout << tmp << endl;
	    flag = 1;
	  }
	  if(flag != 1)st.pop();
	}else if(tmp == '.'){
	  break;
	}
	scanf("%c",&tmp);
      }
    
      if(flag != 1){
	if(st.empty()){
	cout << "yes" << endl;
	}else cout << "no" << endl;
      }else cout << "no" << endl;
      flag = 0;
    }
  }
}
  

Measured memory_bytes: 1184
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let xs: Vec<usize> = sc.vec(5);
    for i in 0..5 {
        if xs[i] == 0 {
            put!(i + 1)
        }
    }
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;
const int blk = 710;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
            if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}

struct queries
{
    int L;
    int R;
    int ix;
};

int cei(int x,int y)
{
    return ((x / y) + (x % y != 0));
}

bool cmp(queries a,queries b)
{
    int kiri = cei(a.L,blk);
    int kanan = cei(b.L,blk);
    if (kiri == kanan)
        return (a.R < b.R);
    return (kiri < kanan);
}

queries ask[500010];
int cnt[500010];
int tab[500010];
int ans[500010];
int tot = 0;

void add(int ix)
{
    ++cnt[tab[ix]];
    if (cnt[tab[ix]] == 1)
        ++tot;
}

void erase(int ix)
{
    --cnt[tab[ix]];
    if (cnt[tab[ix]] == 0)
        --tot;
}

int main()
{
    int n = readInt(), q = readInt();
    for (int i = 1 ; i <= n ; i++)
    {
        tab[i] = readInt();
    }
    for (int i = 1 ; i <= q ; i++)
    {
        ask[i].L = readInt();
        ask[i].R = readInt();
        ask[i].ix = i;
    }
    sort(ask + 1,ask + q + 1,cmp);
    // for (int i = 1 ; i <= q ; i++)
    //     cout << ask[i].L << " " << ask[i].R << endl;
    int currL = 1;
    int currR = 1;
    for (int i = 1 ; i <= q ; i++)
    {
        int L = ask[i].L;
        int R = ask[i].R;
        while (currL > L)
        {
            add(currL - 1);
            --currL;
        }
        while (currR <= R)
        {
            add(currR);
            ++currR;
        }
        while (currL < L)
        {
            erase(currL);
            ++currL;
        }
        while (currR > R + 1)
        {
            erase(currR - 1);
            --currR;
        }
        // for (int j = 1 ; j <= n ; j++)
        //     cout << cnt[j] << " ";
        // cout << endl;
        ans[ask[i].ix] = tot;
    }
    for (int i = 1 ; i <= q ; i++)
        printf("%d\n",ans[i]);
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

int solve(ll x) {
  set<ll> used;
  ll cur = 7;
  int step = 1;
  while( true ) {
    if( used.count(cur) ) {
      return -1;
    }
    if( cur % x == 0 ) {
      return step;
    }
    used.insert(cur);
    cur = ( cur * 10LL ) % x + 7 % x;
    ++step;

  }
}

int main() {
  ll x;
  cin >> x;
  int ans = solve(x);
  if( ans == -1 ) puts("-1");
  else cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 50464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <utility>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)

int main(){
    char a,b;
    cin >>a>>b;
if (a==b)cout << "H"<<endl;
else cout << "D"<<endl;
}


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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

int main()
{
    string s; in >> s;
    int res = 0;
    REP(i, s.size()-1)
    {
        if(s[i] != s[i+1]) res++;
    } out << res << "\n";

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105;
int main(){
	int n;
	string s;
	cin >> n >> s;
	for(int i=0;i<s.size();i++){
		int t=s[i]-'A';
		t=(t+n)%26;
		char ch=t+'A';
		cout << ch;
	}
	return 0;
}

Measured memory_bytes: 256
#400
N, X, Y = map(int,input().split())
L = [0]*(N)

for i in range(1,N):
    for j in range(i+1,N+1):
        if j <= X:
            L[j-i] += 1
        elif i >= Y:
            L[j-i] += 1
        elif i <= X and j >= Y:
            L[j-i - (Y-X-1)] += 1
        elif X < i < j < Y:
            if j - i <= (i-X) + (Y-j) + 1:
                L[j-i] += 1
            else:
                L[(i-X) + (Y-j) + 1] += 1
        elif i <= X < j < Y:
            if j-i < (X-i)+(Y-j)+1:
                L[j-i] += 1
            else:
                L[(X-i)+(Y-j)+1] += 1
        elif X < i < Y <= j:
            if j-i < (i-X)+(j-Y)+1:
                L[j-i] += 1
            else:
                L[(i-X)+(j-Y)+1] += 1

for i in range(N-1):
    print(L[i+1])

Measured memory_bytes: 3444
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <string>
#include <cmath>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char str[SIZE];

int main()
{
	scanf("%s",&str);
	int n=strlen(str),ret=0;
	for(int i=0;i+1<n;i++)
	{
		if(str[i]!=str[i+1])
		{
			ret++;
		}
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int i,j = 0;
    long x[20000];
    
    for(i=0;i<20000;i++){
        
        scanf("%ld",&x[i]);
        j++;
        
        if(x[i] == 0)
            break;
    }
    
    
    for(i = 0; i < j-1; i++){
        printf("Case %d: %ld\n",i+1,x[i]);
    }
    
    return 0;
    
}

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

const int INF = 1e9 + 5;  

void min_self ( int& a, int b  ) {
	a = min (a, b);
}

void max_self ( int& a, int b  ) {
	a = max (a, b);
}


std::vector< int > AdjList[100001];
int dp[100001];
std::vector<bool> vis;

auto dfs( int current ) -> int {
	
	if( dp[current] != -1 ) return dp[current];
	int ret = 0;
	for ( auto const& to : AdjList[current] ) {
		ret = max( ret, dfs(to) + 1 ); 
	}
	return dp[current] = ret;
}

auto solve ( int N ) -> int {
	
	int answer = -1;
	for ( int i = 1; i <= N; ++i ) {
		dp[i] = -1;
	}
	for ( int i = 1; i <= N; ++i ) {
		answer = max(answer , dfs(i));	
	}
	return answer;
}

signed
main () {

	int N, M;
	std::cin >> N >> M;
	int from, to;
	for ( int i = 0; i < M; ++i ) {
		std::cin >> from  >> to;
		AdjList[from].push_back(to);
	}
	std::cout << solve (N) << '\n';
	return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m)-((m)>(n));i!=(n)-((m)>(n));i+=2*((m)<(n))-1)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
double dp[3000][3000],p[2999];

double find(int n,int k) { // n coins with k heads
	if (n<0) return 1;
	if (k<0 or n<k) return 0;
	if (dp[n][k]!=-1) return dp[n][k];
	dp[n][k]=find(n-1,k-1)*p[n]+find(n-1,k)*(1-p[n]);
	return dp[n][k];
}


int main () {
	int n;
	cin >> n;
	fop (i,1,n+1) cin >> p[i];
	double sum=0;
	fop (i,0,n+1) {
		fop (j,0,n+1) {
			dp[i][j]=-1;
		}
	}
	fop (i,n/2+1,n+1) {
		sum+=find(n,i);
	}
	cout << setprecision(10) << sum << endl;
}

Measured memory_bytes: 70784
N = int(input())
def gcd(a,b):
  while(b>0):
    a,b = b,a%b
  return a

def lcm(a,b):
  G = gcd(a,b)
  L = (a*b)//G #ab = GL
  return L

for i in range(N): 
  t = int(input())
  if(i == 0): ans = t
  else: ans= lcm(ans,t)
print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n,m;
    int field[128000]={0};
    scanf("%d%d",&n,&m);
    rep(i,n-1){
        scanf("%d",&field[i]);
    }
    int mod = 100000;
    int res = 0;
    int now = 0;
    rep(i,m){
        int x;
        scanf("%d",&x);
        if(x > 0){
            reps(j,now,now+x){
                if(res+field[j]>=mod){
                    res = (res+field[j])%mod;
                }else{
                    res = (res+field[j]);
                }
            }
            now += x;
        }else{
            for(int j = now-1;j > now+x-1; j--){
                if(res+field[j]>=mod){
                    res = (res+field[j])%mod;
                }else{
                    res=(res+field[j]);
                }
            }
            now += x;
        }
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 1696
def p(n):
    l = [1]*(n+1)
    l[0] = l[1] = 0
    for i in range(2,int(n ** 0.5) + 1):
        if l[i]:
            for j in range(2*i, n+1, i):
                l[j] = 0
    return l
n = input()
l = []
l += [str(n)+":"]
from itertools import compress, count
P = p(int(n ** 0.5))
for i in compress(count(0), P):
    while n % i == 0:
        n /= i
        l += [i]
if n != 1: l += [n]
print " ".join(map(str,l))

Measured memory_bytes: 7356
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <vector>

#define PI 3.1415927

using namespace std;

int main(){
    string A;
    string B;
    getline(cin,A);
    getline(cin,B);
    int a=A.length();
    int b=B.length();
    int q=0,p=0;
    for (int i=1;i<=a+b;i++){
        if (i%2==1){
            cout<<A[q++];
        }
        else{
            cout<<B[p++];
        }
    }
    cout<<endl;

}


Measured memory_bytes: 256
n, x, y = map(int,input().split())
list_length = [0 for i in range(n)]
length = 0

for i in range(1, n+1):
    for j in range(i+1, n+1):
        length = min(j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j))
        list_length[length] += 1

for i in range(1, len(list_length)):
    print(list_length[i])


Measured memory_bytes: 3444
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

const MOD: usize = 1000000007;
fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (h, w, k): (usize, usize, usize) = parse!(it, 3);
    let mut fns: Vec<Vec<usize>> = vec![];
    'outer: for i in 0..(1 << (w - 1)) {
        let mut prev = false;
        let mut func = (0..w).collect::<Vec<usize>>();
        for j in 0..(w - 1) {
            let flag = i & (1 << j) != 0;
            if prev && flag {
                continue 'outer;
            }
            if flag {
                func.swap(j, j + 1);
            }
            prev = flag
        }
        fns.push(func);
    }
    let mut dp = vec![0; w];
    dp[0] = 1;
    for _ in 0..h {
        let mut new = vec![0; w];
        for func in &fns {
            for i in 0..dp.len() {
                new[func[i]] += dp[i];
                new[func[i]] %= MOD;
            }
        }
        dp = new;
    }
    println!("{}", dp[k - 1]);
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  ll a, b;
  cin >> a >> b;
  if(a + b == 15) cout << "+" << endl;
  else if(a * b == 15) cout << "*" << endl;
  else cout << "x" << endl;
  return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/05/11  Problem: AOJ 1243 / Link: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1243  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	VI a(3);
	FOR(i, 0, 3) {
		cin >> a[i];
	}
	SORT(a);
	if (a[0] + a[1] == a[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

long long GCD(long long x,long long y){
  if(y == 0) return x;
  return GCD(y,x%y);
}

vector<pair<long long,long long>>prime_factorize(long long n) {
  vector<pair<long long, long long> > res;
  for(long long p = 2; p * p <= n; ++p) {
      if (n % p != 0) continue;
      int num = 0;
      while (n % p == 0) { ++num; n /= p; }
      res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  long long a,b,gcd;
  cin >> a >> b;
  gcd = GCD(a,b);
  auto pf = prime_factorize(gcd);
  cout << pf.size()+1 << endl;
}


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

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

    int d[300000];
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    for(int i=0;i<n-1;i++){
        D=max(D,d[i]);

        if(D<10){
            cout<<"no"<<endl;
            return 0;
        }
        D-=10;
    }
    D=0;

    for(int i=n-1;i>0;i--){
        D=max(D,d[i]);

        if(D<10){
            cout<<"no"<<endl;
            return 0;
        }
        D-=10;
    }
    cout<<"yes"<<endl;
    return 0;
}


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

int main()
{
  while(1){
    int w, d;
    cin >> w >> d;
    if(w == 0 && d == 0) break;
    int n = max(w, d);
    int hw[n] = {}, hd[n] = {};
    for(int i = 0; i < w; i++)
      cin >> hw[i];
    for(int i = 0; i < d; i++)
      cin >> hd[i];
    reverse(hd,hd+n);
    int ans = 0;
    bool hw_f[n] = {}, hd_f[n] = {};
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        if(!hd_f[j] && hw[i] == hd[j]){
          ans += hw[i];
          hw_f[i] = true;
          hd_f[j] = true;
          break;
        }
      }
    }
    for(int i = 0; i < n; i++){
      if(!hw_f[i]) ans += hw[i];
      if(!hd_f[i]) ans += hd[i];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int n, p;
const int N = 200;
#define LL long long
LL f[N][2];
int main()
{
    cin >> n >> p;
    f[0][0] = 1;
    for (int i = 1; i <= n; ++ i)
    {
        int a; cin >> a;
        if (a & 1)
        {
            f[i][0] = f[i][1] = f[i - 1][0] + f[i - 1][1];
        }
        else
        {
            f[i][0] = f[i - 1][0] * 2;
            f[i][1] = f[i - 1][1] * 2;
        }
    }
    cout << f[n][p];
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

using namespace std;

void shuffle(string& card,int h)
{
  string head = card.substr(0, h);
  string tail = card.substr(h, card.length()-h);
  card.clear();
  card = tail + head;
}

int main(int argc, char* argv[])
{
  string card;
  int ope,h;
  vector<string> output;
  while(1)
  {
    cin >> card;
    if(card=="-") break;
    cin >> ope;
    for(int i=0;i<ope;i++)
    {
      cin >> h;
      shuffle(card,h);
    }
    output.push_back(card);
  }
  for(string n: output) cout << n << endl;
}

Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

template<typename T>
bool is_prime(T n) {
	
	for(T i = 2; i * i <= n; ++i) {
		if( n % i == 0 ) return false;
	}
	
	return true;
}

int main(void) {
	int n;
	cin >> n;
	
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if( is_prime(a) ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 3088
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

vector<int> len;
vector<map<int, int> > value;

int dfs(string& s, int& k)
{
    if(isdigit(s[k])){
        int ret = 0;
        while(k < s.size() && isdigit(s[k])){
            ret *= 10;
            ret += s[k] - '0';
            ++ k;
        }
        return ret;
    }

    char c = s[k];
    k += 2;
    int a = dfs(s, k);
    ++ k;

    if(k < s.size() && s[k] == '='){
        ++ k;
        if(a == -1 || a >= len[c])
            return -1;
        else
            return value[c][a] = dfs(s, k);
    }else{
        if(a == -1 || value[c].find(a) == value[c].end())
            return -1;
        else
            return value[c][a];
    }
}

bool substitute (string& s)
{
    char a=s[0];
    int eq=s.find('='),idx=2;
    int i=dfs(s,idx);
    if(i==-1 || len[a]<=i) return false;
 
    idx=eq+1;
    int res=dfs(s,idx);
    if(res == -1)
        return false;
    value[a][i]=res;
    return true;
}

int solve(vector<string>& s)
{
    len.assign(128, 0);
    value.assign(128, map<int, int>());

    int n = s.size();
    for(int i=0; i<n; ++i){
        if(s[i].find('=') == string::npos){
            int k = 2;
            len[s[i][0]] = dfs(s[i], k);
        }else{
            int k = 0;
            if(!substitute(s[i]))
                return i + 1;
            dfs(s[i], k);
        }
    }

    return 0;
}

int main()
{
    for(;;){
        vector<string> s;
        for(;;){
            string t;
            cin >> t;
            if(t == ".")
                break;
            s.push_back(t);
        }

        if(s.empty())
            return 0;

        cout << solve(s) << endl;
    }
}

Measured memory_bytes: 1340
#include "bits/stdc++.h"
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
set<int> A;

int main()
{
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i,0,N){
        int a;
        cin >> a;
        A.insert(a);
    }
    if (A.size() == N) CO("YES");
    else CO("NO");
    return 0;
}

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


int main (){
    ll a,b;
    int ans;
    cin >> a >> b;
    if(0<a){
        cout << "Positive" << endl;
    }else if(0<=b)
    {
        cout << "Zero" << endl;
    }
    else if((b-a+1)%2 == 0){
        cout << "Positive" << endl;
    }
    else
    {
        cout << "Negative" << endl;
    }
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair((first), (second)))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int N;
	cin >> N;
	vector<int> V(N);
	int cnt = 0;
	for(int i = 0; i < N; i++){
		cin >> V[i];
		if(V[i] != i + 1)cnt++;
	}
	if(cnt <= 2)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


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

using namespace std;

int h, ans;
int a[10][5];

bool change(void) {
  bool res = true;
  for (int i = 0; i < h; i++) {
    int l = 0, r = 0;
    while (l < 5) {
      while (r + 1 < 5 && a[i][r] > 0 && a[i][r] == a[i][r + 1]) r++;
      if (r - l + 1 >= 3) {
        ans += a[i][l] * (r - l + 1);
        for (int j = l; j <= r; j++) {
          a[i][j] = -1;
        }
        res &= false;
      }
      l = ++r;
    }
  }
  return res;
}

int main(void) {
  while (cin >> h, h) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < 5; j++) {
        cin >> a[i][j];
      }
    }

    ans = 0;
    while (true) {
      if (change()) break;
      for (int i = 0; i < 5; i++) {
        for (int j = h - 1; j >= 0; j--) {
          if (a[j][i] > 0) continue;
          int s = j;
          while (s >= 0 && a[s][i] < 0) s--;
          if (s < 0) break;
          while (++s <= j) swap(a[s - 1][i], a[s][i]);
        }
      }
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2964
#include <bits/stdc++.h>
#define debug(x) cout << #x << " -> " << x << endl
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


void testcase(){
	int n,a[200005];
	cin >> n;
	ll sum = 0;
	for(int i{0};i < n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	int ptr = n - 2;
	bool alt = false;
	sum += a[n-1];n-= 2;
	while(n > 0){
		sum += (ll)(a[ptr]);
		n --;
		if(alt){
			ptr--;
		}
		alt = !alt;
	}
	cout << sum << "\n";
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


Measured memory_bytes: 4396
#include<iostream>
#include<cstdio>
#include<cstring>
#include<climits>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define MAXN 100000
#define MAXM 200000
#define INF INT_MAX
int n,m;
struct node
{
    int next,to,w;
}e[MAXM*2+5];
int b[MAXN+5];
int x,y,z,cnt,s,t,ans;
set<int> Ncolor[MAXN+5];
int dist[MAXN+5];
priority_queue < pair<int,int> > Q;
void fpush(int u,int v,long long w)
{
    e[++cnt].next=b[u];
    e[cnt].w=w;
    e[cnt].to=v;
    b[u]=cnt;
}
void Dijkstra()
{
    Q.push({0,s});
    dist[s]=1;
    while(!Q.empty())
    {
        int now=Q.top().second,xval=-Q.top().first;
        Q.pop();
        for(int i=b[now];i;i=e[i].next)
        {
            int xnext=e[i].to,color=e[i].w;
            int val=xval;
            if(!Ncolor[now].count(color))val++;
            if(dist[xnext]>val)
            {
                Ncolor[xnext].clear();
                Ncolor[xnext].insert(color);
                dist[xnext]=val;
                Q.push({-val,xnext});
            }
            if(dist[xnext]==val)Ncolor[xnext].insert(color);
        }
    }
}
int main()
{
    fill(dist+1,dist+MAXN+1,INF);
    scanf("%d%d",&n,&m);
    s=1,t=n;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        fpush(x,y,z);
        fpush(y,x,z);
    }
    Dijkstra();
    if(dist[n]!=INF)printf("%d",dist[n]);
    else printf("-1");
}


Measured memory_bytes: 20216
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;


const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);
    COMinit();
    int n,p; cin >> n>> p;
    int o=0,e=0;
    rep(i,n){
        int a; cin >> a;
        if(a%2==0)e++;
        else o++;
    }

    if(o==0){
        cout<<(p?0:(1LL<<e))<<endl; return 0;
    }

    int res=(1<<e);
    int t=0;
    if(p==1){    
        for(int i=1; i<=o; i+=2) t+=COM(o,i);
    }else{
        for(int i=0; i<=o; i+=2) t+=COM(o,i);
    }   
    cout<<res*t<<endl;


}

Measured memory_bytes: 15568
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, M, L = map(int, input().split())
        ABC = [tuple(map(int, input().split())) for _ in range(M)]
        Q = int(input())
        st = [tuple(map(int, input().split())) for _ in range(Q)]

        INF = 10 **10
        load = [[INF] * N for _ in range(N)]
        for a, b, c in ABC:
            a -= 1
            b -= 1
            load[a][b] = c
            load[b][a] = c

        for k in range(N):
            for i in range(N):
                for j in range(N):
                    load[i][j] = min(load[i][j], load[i][k] + load[k][j])

        load2 = [[INF] * N for _ in range(N)]
        for i in range(N):
            for j in range(N):
                if load[i][j] <= L:
                    load2[i][j] = 1

        for k in range(N):
            for i in range(N):
                for j in range(N):
                    load2[i][j] = min(load2[i][j], load2[i][k] + load2[k][j])

        for s, t in st:
            s -=1
            t-=1
            if load2[s][t] == INF:
                print(-1)
            else:
                print(load2[s][t] - 1)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 70492
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
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;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll n;
    cin>>n;
    vpii  ba,ab;
    rep(i,0,n){
        int a,b;
        cin>>a>>b;
        pii e=make_pair(b,a);
        ba.push_back(e);
        swap(e.first,e.second);
        ab.push_back(e);
    }
    sort(ba.begin(),ba.end());
    sort(ab.begin(),ab.end());
    if(n%2){
        int idx=(n+1)/2-1;
        cout<<ba[idx].first-ab[idx].first+1<<endl;
    }
    else{
        int idxf=(n)/2-1,idxs=n/2;
        int b=(ba[idxs].first+ba[idxf].first),a=ab[idxs].first+ab[idxf].first;
        cout<<b-a+1<<endl;
    }
    return 0;
}




Measured memory_bytes: 6600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
ll gcd(ll a,ll b){if(b==0)return llabs(a); return gcd(b,a%b);}

int a[1010101];
int main() {
    int n;
    scanf("%d", &n);
    rep(i,n) scanf("%d", &a[i]);

    int ggg = a[0];
    rep(i,n-1) ggg = gcd(ggg, a[i+1]);
    if(ggg != 1){
        puts("not coprime");
        return 0;
    }

    //エラトステネスの篩
    #define P_MAX 1000005
    int pmn[P_MAX];     //smallest prime number that can divide i(pmn[i] == i -> i is prime number)
    for(int i = 1; i < P_MAX; i++)
        if(i%2 == 0) pmn[i] = 2;
        else pmn[i] = i;
    for(int i = 3; i*i < P_MAX; i += 2){
        if(pmn[i] == i){
            for(int j = i*i; j < P_MAX; j += 2*i)
                if(pmn[j] == j) pmn[j] = i; 
        }
    }

    int cnt[P_MAX]={0};
    rep(i,n){
        while(a[i] != 1){
            int apmn = pmn[a[i]];
            if(cnt[apmn]){
                puts("setwise coprime");
                return 0;
            }
            cnt[apmn]++;
            while(a[i]%apmn == 0) a[i] /= apmn;
        }
    }
    puts("pairwise coprime");
}


Measured memory_bytes: 13336
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[10010],b[10010];
long long suma,sumb,needa,needb;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		suma+=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		sumb+=b[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]>b[i])
		{
			needb+=a[i]-b[i];
		}
		else if(a[i]<b[i])
		{
			needa+=(b[i]-a[i]+1)/2;
			needb+=(b[i]-a[i])%2;
		}
	}
	if(max(needa,needb)>sumb-suma)
	{
		puts("No");
	}
	else
	{
		puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000003;
vel kai(1000007, 1);
vel ink(1000007, 1);
template<typename T>
V<T> uni(V<T> &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	V<T> ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	return ql;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 1000006) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 1000007) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p;
	return ans;
}
signed main() {
	int n; cin >> n;
	vvel way(n);
	vel c(n);
	rep(i, n - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		way[a].push_back(b);
		way[b].push_back(a);
	}
	int ans = 0; int mx = 0;
	rep(i, n) { cin >> c[i]; ans += c[i]; mmax(mx, c[i]); }
	sor(c);
	vel ind(n);
	int num = 0;
	queue<int> q;
	q.push(0);
	V<bool> seen(n, false); seen[0] = true;
	while (!q.empty()) {
		int st = q.front(); q.pop();
		ind[st] = num; num++;
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (!seen[to]) {
				seen[to] = true;
				q.push(to);
			}
		}
	}
	cout << ans - mx << endl;
	rep(i, n-1) {
		cout << c[n - 1 - ind[i]] << " ";
	}
	cout << c[n - 1 - ind[n - 1]] << endl;
	return 0;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) ans += i;
	}
	dunk(ans);
	return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n;cin>>n;
    int *arr=new int[n];
    int *brr=new int[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    brr[n-1]=1;
    for(int i=n-2;i>=0;i--)
    {
        if(arr[i]>=arr[i+1])
            brr[i]=brr[i+1]+1;
        else
            brr[i]=1;
    }
    cout<<*max_element(brr,brr+n)-1;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, flag = 0;
  cin >> N;
  while (N >= 0) {
    if (N % 7 == 0) flag = 1;
    N -= 4;
  }
  if (flag == 1)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int a;
	for (int i = 0; i < 5; i++) {
		cin >> a;
		if (a == 0) {
			cout << i + 1 << endl;
		}
	}
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,m,o,x;
    cin>>n>>m>>o>>x;
   if(((abs(n-m)<=x)&&(abs(m-o)<=x))||(abs(n-o)<=x))
   {
       cout<<"Yes"<<NL;
   }
   else
   {
       cout<<"No"<<NL;
   }
    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {

    	Scanner sc=new Scanner(System.in);

    	int N=sc.nextInt();
    	int Q=sc.nextInt();

    	int[] val=new int[N];

    	Arrays.fill(val, Integer.MAX_VALUE);

    	RMQ segtree=new RMQ(val);

    	for(int i=0;i<Q;i++) {

    		int c=sc.nextInt();
    		int x=sc.nextInt();
    		int y=sc.nextInt();

    		if(c==0) {
    			segtree.update(x, y);
    		}else {
    			System.out.println(segtree.query(x, y+1, 0, 0, -1));
    		}
    	}
    }




}

class RMQ{

	int n;

	int[] dat;


	RMQ(int[] val){

		int size=val.length;
		n=1;

		//元の配列のサイズ以上になる最小の2のべき乗をnとすると
		//セグメント木の大きさは2n-1である。
		while(n<size) {
			n *=2;
		}

		init();

		//セグメント木の最下段に元の配列の値を入れておく。
		for(int i=0;i<size;i++) {
			dat[i+n-1]=val[i];
		}

		//最下段から子を比べて親を格納していく。

		for(int i=n-2;i>=0;i--) {
			dat[i]=Math.min(dat[2*i+1],dat[2*i+2]);
		}

	}






	void init() {

		dat=new int[2*n-1];

		for(int i=0;i<2*n-1;i++) {
			dat[i]=Integer.MAX_VALUE;
		}

	}

	void update(int i,int val) {

		//葉のノード番号
		i+=n-1;
		dat[i]=val;

		//登りながら更新
		while(i>0) {

			//子から親を求めるには-1して/2
			//切り捨てられて、左からでも右からでも同じ値になる。
			i=(i-1)/2;

			//親は左右の子のうち、小さい値を持っている。
			dat[i]=Math.min(dat[i*2+1],dat[i*2+2]);
		}

	}

	//[a,b)クエリで求められる区間の端。
	//k自分が今いるノードのインデックス
	//今みてる区間[l,r)

	//呼び出す時はquery(a,b,0,0,n)とする。

	int query(int a,int b,int k,int l,int r) {

		if(r<0) {
			r=n;
		}

		if(r<=a||b<=l)return Integer.MAX_VALUE;//交差しない?
		if(a<=l && r<=b) return dat[k];		  //完全に含む?

			int vl=query(a,b,k*2+1,l,(l+r)/2);
			int vr=query(a,b,k*2+2,(l+r)/2,r);

			return Math.min(vl,vr);

	}



}




Measured memory_bytes: 105348
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int k = 0; k < W; k++) {
					if ((i + k) % 2 == 0) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 33448
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) 
	{
	    Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
	    int k=s.nextInt();
	    int[]arr=new int[n];
	   //int[]arr=s.nextIntArray();
	    for(int i=0;i<n;i++){
	        arr[i]=s.nextInt();
	    }
	    int dp[]=new int[n];
	    Arrays.fill(dp,Integer.MAX_VALUE);
	    dp[0]=0;
	    dp[1]=Math.abs(arr[1]-arr[0]);
	    for(int i=2;i<n;i++){
	        for(int j=i-1;j>=i-k&&j>=0;j--){
	            dp[i]=Math.min(dp[i],Math.abs(arr[i]-arr[j])+dp[j]);
	        }
	    }
	    System.out.println(dp[n-1]);
	    
	}
}

Measured memory_bytes: 59556
n=int(input())
mat=[]
for i in range(n):
	a,b=map(int,input().split())
	mat.append([b,a])
mat.sort()
t=0
f=1
for i in range(n):
	if(t+mat[i][1]<=mat[i][0]):
		t+=mat[i][1]
	else:
		f=0
		break
if(f):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 35608
#include<iostream>
#include<algorithm>
#include<math.h>
#include<iomanip>

using namespace std;

int main(){
    int  n,k;
    double sum=0.0,now,tmp;
    cin>>n>>k;

    for(int i=1; i<=n; i++){
        now=i;
        tmp=1.0/n;
        while(k>now){
            tmp/=2;
            now*=2;
        }
        sum+=tmp;
    }
    cout<<fixed<<setprecision(9)<<sum<<endl;

    return 0;
}


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

string st(char c) {
  if(c=='A') return "00000";
  if(c=='B') return "00001";
  if(c=='C') return "00010";
  if(c=='D') return "00011";
  if(c=='E') return "00100";
  if(c=='F') return "00101";
  if(c=='G') return "00110";
  if(c=='H') return "00111";
  if(c=='I') return "01000";
  if(c=='J') return "01001";
  if(c=='K') return "01010";
  if(c=='L') return "01011";
  if(c=='M') return "01100";
  if(c=='N') return "01101";
  if(c=='O') return "01110";
  if(c=='P') return "01111";
  if(c=='Q') return "10000";
  if(c=='R') return "10001";
  if(c=='S') return "10010";
  if(c=='T') return "10011";
  if(c=='U') return "10100";
  if(c=='V') return "10101";
  if(c=='W') return "10110";
  if(c=='X') return "10111";
  if(c=='Y') return "11000";
  if(c=='Z') return "11001";
  if(c==' ') return "11010";
  if(c=='.') return "11011";
  if(c==',') return "11100";
  if(c=='-') return "11101";
  if(c=='\'') return "11110";
  if(c=='?') return "11111";
}

int main() {
  map<string,char> m;
  m["101"]=' ';
  m["000000"]='\'';
  m["000011"]=',';
  m["10010001"]='-';
  m["010001"]='.';
  m["000001"]='?';
  m["100101"]='A';
  m["10011010"]='B';
  m["0101"]='C';
  m["0001"]='D';
  m["110"]='E';
  m["01001"]='F';
  m["10011011"]='G';
  m["010000"]='H';
  m["0111"]='I';
  m["10011000"]='J';
  m["0110"]='K';
  m["00100"]='L';
  m["10011001"]='M';
  m["10011110"]='N';
  m["00101"]='O';
  m["111"]='P';
  m["10011111"]='Q';
  m["1000"]='R';
  m["00110"]='S';
  m["00111"]='T';
  m["10011100"]='U';
  m["10011101"]='V';
  m["000010"]='W';
  m["10010010"]='X';
  m["10010011"]='Y';
  m["10010000"]='Z';
  string s;
  while(getline(cin,s)) {
    string t="";
    for(int i=0; i<s.size(); i++) t+=st(s[i]);
    string ans="";
    for(int i=0; i<t.size(); i++) {
      for(int j=1; j<9; j++) {
	string r=t.substr(i,j);
	if((m[r]>='A' && m[r]<='Z') || m[r]==' ' || m[r]=='.' || m[r]==',' || m[r]=='-' || m[r]=='\'' || m[r]=='?') {
	  ans+=m[r];
	  i+=j-1;
	  break;
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1204