akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int ct = 0;
struct Node {
	vector<int>e;
	bool flag;
	Node():flag(0){}
}node[100009];
int N;
int a, b;
int search(int i, int pre) {
	if (node[i].e.size() == 1&&i!=N&&i!=1)return 1;
	int tot = 0;
	for (int j = 0; j < node[i].e.size();j++){
		if (pre != node[i].e[j]) {
			tot += search(node[i].e[j], i);
		}
	}
	return tot + 1;
}
bool dfs(int i,int pre) {
	if (node[i].e.size()==1&&i!=1)return false;
	int t;
	if (find(node[i].e.begin(), node[i].e.end(), N) != node[i].e.end()) {
		node[i].flag = true;
		return true;
	}
	for (int j = 0; j < node[i].e.size(); j++) {
		if (pre!=node[i].e[j]&&dfs(node[i].e[j],i)) {
			node[i].flag = true;
			return true;
		}
	}
	return false;
}
int main()
{
	scanf("%d", &N);
	int way = 0;
	for (int i = 1; i < N; i++) {
		scanf("%d%d", &a, &b);
		node[a].e.push_back(b);
		node[b].e.push_back(a);
	}
	node[N].flag = true;
	dfs(1, 1);
	int white, black;
	int bnow = 1,bpre = 1;
	for (int i = 1; i <= N; i++) {
		if (node[i].flag == true)way++;
	}
	for (int i = 0; i < node[1].e.size(); i++) {
		if (node[node[1].e[i]].flag == true) {
			bnow = node[1].e[i];
			break;
		}
	}
	for (int i = 0; i < (way - 1) / 2; i++) {
		for (int j = 0; j < node[bnow].e.size(); j++) {
			if (node[bnow].e[j] != bpre&&node[node[bnow].e[j]].flag == true) {
				bpre = bnow;
				bnow = node[bnow].e[j];
				break;
			}
		}
	}
	node[bpre].e.erase(find(node[bpre].e.begin(), node[bpre].e.end(), bnow));
	node[bnow].e.erase(find(node[bnow].e.begin(), node[bnow].e.end(), bpre));
	black = search(1, 1);
	white = N - black;
	if (white < black) {
		printf("Fennec\n");
	}
	else printf("Snuke\n");
}

Measured memory_bytes: 12800
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextLong());
        }
        System.out.println(list.stream().sorted(Comparator.reverseOrder()).skip(k).mapToLong(l -> l).sum());
    }
}

Measured memory_bytes: 67068
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> Point;

double cross(Point a,Point b){
  return a.real()*b.imag()-a.imag()*b.real();
}

struct Line{
  Point a,b;
};

const double Size=100;
const double EPS=1e-11;

Point is_ll(Line s,Line t){
  Point sv=s.b-s.a,tv=t.b-t.a;
    if(abs(cross(sv,tv))<EPS){
    return {Size*2,Size*2};
  }
  return s.a+sv*cross(tv,t.a-s.a)/cross(tv,sv);
}

bool isrange(Point p){
  return -Size+EPS<p.real() && p.real()<Size-EPS && -Size+EPS<p.imag() && p.imag()<Size-EPS;
}

int main(){
  int n;
  while(cin>>n,n){
    vector<Line> line(n);
    for(int i=0;i<n;i++){
      double x1,y1,x2,y2;
      cin>>x1>>y1>>x2>>y2;
      line[i]={Point(x1,y1),Point(x2,y2)};
    }
    int cnt=n+1;
    for(int i=0;i<n;i++){
      set<pair<double,double>> s;
      for(int j=0;j<i;j++){
	Point p;
	p=is_ll(line[i],line[j]);

	if(isrange(p)){
	  auto it=s.lower_bound({p.real()-EPS,p.imag()-EPS});
	  if(it!=s.end() && abs((it->first)-p.real())+abs((it->second)-p.imag())<1e-11){

	    continue;
	  }
	  s.insert({p.real(),p.imag()});
	  cnt++;
	}
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 3140
n = int(input())
d = {i+1: v for i, v in enumerate(list(map(int, input().split())))}
m = int(input())
a = list(map(int, input().split()))

for i in a:
    if d[i]+1 not in d.values() and d[i] != 2019:
        d[i] += 1

print(*d.values(), sep="\n")


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

#define pb push_back

using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;


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

    int k, x;
    cin >> k >> x;
    const int xmin = -1e6, xmax = 1e6;
    int xl = max(xmin, x-k+1);
    int xr = min(xmax, x+k-1);
    for (int xi = xl; xi < xr ; ++xi)
        cout << xi << " ";
    cout << xr << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int white = 0, black = 0;
    rep(i, n) {
        if(s[i] == '.') {
            white++;
        }
    }

    int ans = white;
    rep(i, n) {
        if(s[i] == '.'){
            white--;
        }
        else {
            black++;
        }
        int now = white + black;
        ans = min(ans, now);
    }
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

	string s;
	cin >> s;
	map<char, int> mp;
	for (char c : s) {
		mp[c]++;
	}
	int ng = 0;
	int np = 0;
	int res = 0;
	for (int i = 0; i < mp['g']; i++) {
		if (ng == np) {
			ng++;
		} else {
			np++;
			res++;
		}
	}
	for (int i = 0; i < mp['p']; i++) {
		if (ng == np) {
			ng++;
			res--;
		} else {
			np++;
		}
	}
	cout << res << '\n';

	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;



int main() {
	int n,m;

	cin >> n >> m;
	int h[n];
	rep(i, n) {
		cin >> h[i];
	}
	vector< vector<int> > v(n);
	rep(i, m) {
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int total = 0;
	rep(i, n) {
		bool is_ok = true;
		for(int v : v[i]) {
			if (h[i] <= h[v]){
				is_ok = false;
				break;
			}
		}
		if (is_ok) total++;
	}
	cout << total << endl;



	return 0;
}


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

using namespace std;
using ll = long long;

class Osa_k {
private:
	int n;
	vector<int> factor;

	void dfs(int val, int idx ,vector<int>& ans, map<int,int>& mp,const vector<int> &facts) {
		if(idx == (int)facts.size()) {
			ans.push_back(val);
			return;
		}
		int v = facts[idx];
		for(int i = 0; i <= mp[v]; i++) {
			dfs(val, idx+1, ans, mp, facts);
			val *= v;
		}
	}

public:

	//O(NloglogN)
	Osa_k(int _n):n(_n) {
		factor.assign(n, 0);
		iota(factor.begin(), factor.end(), 0);
		for(int i = 2; i*i < n; i++) {
			if(factor[i] < i)continue;
			for(int j = i * i; j < n; j += i) {
				if(factor[j] == j)factor[j] = i;
			}
		}
	}

	//O(logV)
	map<int, int> sieve(int v) {
		map<int, int> ret;
		while(v != factor[v]) {
			ret[factor[v]]++;
			v /= factor[v];
		}
		if(v != 1)ret[v]++;
		return ret;
	}


	vector<int> divisor(int v) {
		map<int,int> mp = sieve(v);
		vector<int> factors;
		for(auto i : mp)factors.emplace_back(i.first);
		vector<int> ans;
		dfs(1, 0, ans, mp, factors);
		sort(ans.begin(), ans.end());
		return ans;
	}


	//O(N)
	vector<int> get_list() {
		vector<int> prime;
		for(int i = 2; i < n; i++)if(factor[i] == i)prime.emplace_back(i);
		return prime;
	}

	//O(1)
	bool is_prime(int v) {
		if(v <= 1)return false;
		return (factor[v] == v);
	}

}fact(1000001);


int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i = 0; i < n; i++) {
        vector<int> s = fact.divisor(a[i]);
        int m = s.size();
        int cnt = 0;
        for(int j = 0; j < m; j++) {
            cnt += upper_bound(a.begin(), a.end(), s[j]) - lower_bound(a.begin(), a.end(), s[j]); 
        }
        if(cnt == 1)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8000
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n;
  ll a[5];
  cin >> n;
  ll min_val=pow(10,15)+1;
  REP(i,5) {
    cin >> a[i];
    min_val = min(min_val,a[i]);
  }
  cout << (n-1)/min_val + 5  << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using namespace std;

int main() {
    string s;
    cin >> s;
    int x , y;
    for (int i = 0; i < s.length(); ++i) {
        if(s[i] == 'A') {
            x = i;
            break;
        }
    }

    for (int i = s.length()-1; i > 0; --i) {
        if(s[i] == 'Z') {
            y = i;
            break;
        }
    }
    cout << y-x+1 << "\n";
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string a;
bool dfs(string s){
  if(s.size()<=3)return s=="ABC";
  string s1,s2,s3;
  int v[3]={};
  r(i,s.size())

    if(i+2<s.size())

      if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        s1+="A",s2+="B",s3+="C",i+=2;

      else s1+=s[i],s2+=s[i],s3+=s[i],v[s[i]-'A']++;

    else s1+=s[i],s2+=s[i],s3+=s[i],v[s[i]-'A']++;

  if(s!=s1){
    if(!v[0])if(dfs(s1))return 1;
    if(!v[1])if(dfs(s2))return 1;
    if(!v[2])if(dfs(s3))return 1;
  }
  return 0;
}
main(){
  cin>>a;
  cout<<(dfs(a)?"Yes":"No")<<endl;
 }

Measured memory_bytes: 46484
while True:
    n = int(input())
    if n == -1:
        break
    if n == 0:
        print(0)
    else:
        ans = []

        while n > 0:
            ans.append(n % 4)
            n = n // 4

        for i in range(len(ans)):
            print(ans[len(ans) - 1 - i], end="")
        print("")


Measured memory_bytes: 5608
#include<stdio.h>
int main(){
int i;
int a,b,c,d;
while(scanf("%d%d%d",&a,&b,&c)!=-1){
d=0;
for(i=1;i<11;i++){
if(i!=a&&i!=b&&i!=c)
if(a+b+i<=20)
d++;
}
if(d>3)
puts("YES");
else
puts("NO");
}
return 0;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  double W,H,x,y; cin >> W >> H >> x >> y;
  printf("%.6f ",W*H/2);
  int cnt = 0;
  if(H/W == y/x) cnt++;
  if(H/2 == y) cnt++;
  if(W/2 == x) cnt++; 
  if(cnt >= 2) cout << 1 << endl;
  else cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())

lm = (M*6)
sh = (H*30)
sm = (M*0.5)
s = sh+sm
r = abs(s-lm)
k = min(r, 360-r)

ans2 = (A*A)+(B*B)-2*A*B*(math.cos(math.radians(k)))
ans = math.sqrt(ans2)

print(ans)

Measured memory_bytes: 9580
n,*z=`dd`.split.map &:to_i
t=(e=[*0...n]).dup
a=z.shift n+1
n.downto(1){|i|a[i]-=a[i-1]}
k,*z=z
z.map{|x|t[x-2,2]=t[x-1],t[x-2]}
60.times{|i|k[i]>0&&e.map!{|q|t[q]};t=t.map{|q|t[q]}}
k,*a=a
n.times{|i|p k;k+=a[e[i]]}

Measured memory_bytes: 57232
import math
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())
n = ii()
a = li()
b = [0]*(n+10)
for i in range(n-1):
    b[a[i]-1]+=1
for i in range(n):
    print(b[i])

Measured memory_bytes: 92272
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n, m, x;
    cin >> n >> m >> x;
    vector<Int> c(n);
    vector<vector<Int>> a(n, vector<Int>(m));
    for (Int i = 0; i < n; i++) {
        cin >> c[i];
        for (Int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    Int ans = 1000000000LL;

    for (Int i = (1LL << n) - 1; i >= 0; i--) {
        vector<Int> rikai(m);
        Int tem = i;
        Int money = 0;

        for (Int j = 0; j < n; j++) {
            if (tem & 1) {
                money += c[j];
                for (Int k = 0; k < m; k++) {
                    rikai[k] += a[j][k];
                }
            }

            tem = tem >> 1;
        }

        bool isar = true;
        for (Int j = 0; j < m; j++) {
            if (rikai[j] < x) {
                isar = false;
                break;
            }
        }

        if (isar) {
            ans = min(ans, money);
        }
    }

    if (ans == 1000000000LL) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3652
#![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"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
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, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

// code...
// #[fastout]
fn main() {
    input! {
        edges: [(Usize1, Usize1); 3]
    }

    let mut c = vec![0; 4];
    for (a, b) in edges {
        c[a] += 1;
        c[b] += 1;
    }

    let c = c.iter().filter(|x| *x % 2 == 1).count();
    if c == 0 || c == 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}



Measured memory_bytes: 2024
// 2011/07/20 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		double n;
		cin >> n;
		if(n<0.0)
			break;

		int n16 = (int)(n*16.0);	// 16{µÄC¬_ÈºØèÌÄ
		if(n*16.0!=(double)n16){	// §ÀÉûÜçÈ¢ê
			cout << "NA" << endl;
			continue;
		}

		int bin[12];
		for(int i=0; i<12; i++){
			bin[i] = n16%2;
			n16 /= 2;
		}

		for(int i=11; i>=4; i--)
			cout << bin[i];
		cout << '.';
		for(int i=3; i>=0; i--)
			cout << bin[i];
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
import copy

def display(masu):
    for m in masu:
        string = ''
        for mm in m:
            string += mm
        print(string)

[H, W] = [int(i) for i in input().split()]

S = []
for h in range(H):
    s = input()
    S.append(list(s))

# スタート地点になり得る地点
start_position = []
for i in range(len(S)):
    for j in range(len(S[i])):
        if S[i][j] == '.':
            start_position.append((i, j))

max_distance = 0
for (i, j) in start_position:
    masu = copy.deepcopy(S)
    #print('{}, {}'.format(i, j))
    masu[i][j] = '*'
    now_position = [(i, j)]
    distance = -1
    while len(now_position) > 0:
        distance += 1
        new_position = []
        for (i, j) in now_position:
            # 上
            if i > 0:
                if masu[i-1][j] == '.':
                    new_position.append((i-1, j))
                    masu[i-1][j] = '*'
            # 下
            if i < H-1:
                if masu[i+1][j] == '.':
                    new_position.append((i+1, j))
                    masu[i+1][j] = '*'
            # 左
            if j > 0:
                if masu[i][j-1] == '.':
                    new_position.append((i, j-1))
                    masu[i][j-1] = '*'
            # 右
            if j < W-1:
                if masu[i][j+1] == '.':
                    new_position.append((i, j+1))
                    masu[i][j+1] = '*'
        now_position = new_position

    #print(distance)
    if distance > max_distance:
        max_distance = distance

print(max_distance)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
 

int main(){
    int n,x,y; cin >> n >> x >> y;
    vector<int> ans(n,0);
    rep(i,n-1){
        for(int j=i+1; j<n; j++){
            //cout << i << j << endl;
            int left=i+1; int right=j+1;
            /*if(x<left && y>right){
                ans[j-i]++;
                continue;
            }*/
                int di=j-i;
                di=min(di,abs(x-left)+abs(right-y)+1);
                ans[di]++;
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

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

int main() {
  string S;
  cin >> S;
  bool G = true;
  REP(i, S.size() - 1) {
    if (S[i] == S[i + 1])
      G = false;
  }
  if (G) {
    std::cout << "Good" << '\n';
  } else {
    std::cout << "Bad" << '\n';
  }
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int max(int a,int b){ return a<b?b:a;}
int n,t,s;
int dp[3005][3005]={},a[3005],b[3005],ret=0;
int main(){
	scanf("%d%d%d",&n,&t,&s);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=t;j++){
			if(b[i]<=j && (j-b[i]>=s || j<=s)){
				dp[i][j]=max(dp[i][j],dp[i-1][j-b[i]]+a[i]);
			}
			dp[i][j]=max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
			ret=max(ret,dp[i][j]);
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 36276
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  map<string, bool> mp;

  ll ans = 0;
  rep(i, n) {
    string s;
    cin >> s;
    if(mp.count(s) == 0){
      ans++;
      mp[s] = true;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 19232
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

a = inp()
b = inp()

ans = 0
if a != 1 and b != 1:
    ans = 1
elif a != 2 and b != 2:
    ans = 2
else:
    ans = 3

print(ans)

Measured memory_bytes: 31208
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n = inp()
    s = input()
    cnt = 0
    for i in range(n-2):
        if s[i:i+3] == 'ABC':
            cnt += 1
    print(cnt)
if __name__ == "__main__":
    main()

Measured memory_bytes: 39148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s.at(i);

    vector<ll> cx = {-1, 0, 1, -1, 1, -1, 0, 1};
    vector<ll> cy = {-1, -1, -1, 0, 0, 1, 1, 1};
    for(size_t i = 0; i < h; i++) {
        for(size_t j = 0; j < w; j++) {
            if(s.at(i).at(j) == '#')
                continue;

            ll cnt = 0;
            rep(k, 8) {
                ll x = j + cx.at(k);
                ll y = i + cy.at(k);
                if(x < 0 || w <= x)
                    continue;
                if(y < 0 || h <= y)
                    continue;
                if(s[y][x] == '#')
                    cnt++;
            }

            s.at(i).at(j) = (char)(cnt + '0');
        }
    }
    rep(i, h) cout << s.at(i) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

inline void work() {
    int N;
    cin >> N;
    int res;
    int mod = 1000;
    if (N % 1000 == 0)  
        res = 0;
    else 
        res = (N / mod + 1) * mod - N;
    cout << res;
}

int main() {
    // freopen(".txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<string>
#include<list>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通

int K;
vector<llong> A;

int main() {
	cin >> K;
	for (int i = 0; i < K; i++) {
		llong a;
		cin >> a;
		A.push_back(a);
	}

	llong NM = 2, Nm = 2; bool f = true;
	for (int i = K - 1; i >= 0; i--) {
		llong tmp1 = (Nm - 1) / A[i] + 1;
		if (Nm <= A[i] * tmp1 && A[i] * tmp1 <= NM) {
			llong tmp2 = NM / A[i] + 1;
			Nm = A[i] * tmp1;
			NM = A[i] * tmp2 - 1;
		}
		else {
			f = false;
			break;
		}
	}

	if (f) cout << Nm << ' ' << NM;
	else cout << -1;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		//Input
		Scanner scanner = new Scanner(System.in);
		int total_element_number = scanner.nextInt();
		int[] data_array = new int[total_element_number];
		for (int i = 0; i < total_element_number; i++) {
			data_array[i] = scanner.nextInt();
		}



		int count = 0;
		//bubbleSort
		int sorted_element_number = -1;
		while(sorted_element_number < (total_element_number - 2)) {
			for (int target = total_element_number - 1; target >= sorted_element_number + 2; target--) {
				//比較して入れ替え
				if(data_array[target - 1] > data_array[target]) {
					int bf = data_array[target - 1];
					data_array[target - 1] = data_array[target];
					data_array[target] = bf;
					count++;
				}
			}
			sorted_element_number++;
		}




		for (int i = 0; i < total_element_number - 1; i++) {
			System.out.print(data_array[i] + " ");
		}
		System.out.println(data_array[total_element_number - 1]);
		System.out.println(count);

	}
}



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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    int Q;
    cin >> Q;
    bool normal = true;
    vector<char> head(Q), tail(Q);
    int h_i = 0;
    int t_i = 0;
    REP(i, Q) {
        int t;
        cin >> t;
        if(t == 1) {
            normal = !normal;
        }else{
            int f;
            char c;
            cin >> f >> c;
            bool p = normal == (f == 2);
            if(p) {
                tail[t_i] = c;
                t_i++;
            }else{
                head[h_i] = c;
                h_i++;
            }
        }
    }
    if(normal) {
        for(int i = h_i - 1;0 <= i;i--) {
            cout << head[i];
        }
        cout << s;
        REP(i, t_i) {
            cout << tail[i];
        }
        cout << endl;
    }else{
        reverse(ALL(s));
        for(int i = t_i - 1;0 <= i;i--) {
            cout << tail[i];
        }
        cout << s;
        REP(i, h_i) {
            cout << head[i];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define N 105
using namespace std;
char s[N][N];
int n,m;
int Ex,Ey,ans;
int cnt[N][N];
void mmax(int &x,int v){
	x=max(x,v);ans=max(ans,v);
}
int get(int x1,int y1,int x2,int y2){
	return cnt[x2][y2]-cnt[x2][y1-1]-cnt[x1-1][y2]+cnt[x1-1][y1-1];
}
int dp[2][N][N][N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			cnt[i][j]=cnt[i-1][j]+cnt[i][j-1]-cnt[i-1][j-1]+(s[i][j]=='o');
			if(s[i][j]=='E') Ex=i,Ey=j;
		}
	int now=0;
	for (int i=0;i<=Ex-1;i++){
		memset(dp[now^1],0,sizeof(dp[0]));
		for (int j=0;j<=n-Ex;j++)
			for (int k=0;k<=Ey-1;k++)
				for (int L=0;L<=m-Ey;L++){
					int v=dp[now][j][k][L];
					int xl=max(Ex-i,j+1),yl=max(Ey-k,L+1),xr=min(Ex+j,n-i),yr=min(Ey+L,m-k);
					if (Ex-i-1>j) mmax(dp[now^1][j][k][L],v+get(Ex-i-1,yl,Ex-i-1,yr));
					if (Ex+j<n-i) mmax(dp[now][j+1][k][L],v+get(Ex+j+1,yl,Ex+j+1,yr));
					if (Ey-k-1>L) mmax(dp[now][j][k+1][L],v+get(xl,Ey-k-1,xr,Ey-k-1));
					if (Ey+L<m-k) mmax(dp[now][j][k][L+1],v+get(xl,Ey+L+1,xr,Ey+L+1));
				}
		now^=1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9472
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n+1];
        
        for(int i=1; i<=n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        ArrayList<Integer> ans = new ArrayList<Integer>();
        int[] b = new int[n+1];
        
        for(int i=n; i>=1; i--){
            int t = 0;
            for(int j=i; j<=n; j+=i){
                t += b[j];
            }
            if(t%2!=a[i]){
                ans.add(i);
                b[i]++;
            }
        }
        
        System.out.println(ans.size());
        for(int i=0; i<ans.size(); i++){
            System.out.println(ans.get(i));
        }
    }
}


Measured memory_bytes: 56032
#include <bits/stdc++.h>
#define N 100005
using namespace std;
int a[N];
int main(){
  int n,count=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  for(int i=1;i<=n;i++){
    if(a[i]==i){
      count++;
      i++;
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

vector<long> dataset(1,0);
long upp = 3234566667;


void dfs(string s){
    if((s.at(0)-'0') <= 3 && s.size() == 10){
        long tmp = 0;
        rep(i,s.size()){
            tmp += pow(10,s.size()-1-i)*(s.at(i)-'0');
        }
        if(tmp <= upp) dataset.push_back(tmp);
        return;
    }
    if((s.at(0)-'0') >= 4 && s.size() == 9){
        long tmp = 0;
        rep(i,s.size()){
            tmp += pow(10,s.size()-1-i)*(s.at(i)-'0');
        }
        if(tmp <= upp) dataset.push_back(tmp);
        return;
    }
    long tmp = 0;
    rep(i,s.size()){
        tmp += pow(10,s.size()-1-i)*(s.at(i)-'0');
    }
    dataset.push_back(tmp);
    int last = s.at(s.size()-1) - '0';
    if(last == 0){
        dfs(s + to_string(last+1));
        dfs(s + to_string(last));
        //dfs(s + to_string(last-1));
    }else if(last == 9){
        //dfs(s + to_string(last+1));
        dfs(s + to_string(last));
        dfs(s + to_string(last-1));
    }else{
        dfs(s + to_string(last+1));
        dfs(s + to_string(last));
        dfs(s + to_string(last-1));
    }
}

int main(){
    long k;
    cin >> k;
    for(int i=1;i<=9;i++){
        dfs(to_string(i));
    }
    sort(all(dataset));
    //rep(i,dataset.size()) cout << dataset.at(i) << endl;
    cout << dataset.at(k) << endl;
}

Measured memory_bytes: 1528
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
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 fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = []
L = []

for i in range(N):
    a = INT()
    A.append(a)
    l = []
    for j in range(a):
        l.append(LIST())
    L.append(l)

from itertools import product
num = N
bits = product([0, 1], repeat=N)

ans = 0

for x in bits:
    flag = 0# honest
    for j in range(N):
        if x[j] == 1:# honest
            for a, b in L[j]:
                if b != x[a-1]:# lie
                    flag = 1
                    break
        if flag == 1:
            break
    else:
        tmp = sum(x)
        if ans <= tmp:
            ans = tmp
print(ans)



exit()

for l in L:
    info = [False] * 2 ** num
    print(info)
    for y in l:
        a, b = y
        print(a, b)
        for x in bits:
            #print(x)
            if x[a-1] == b:
                info[a-1] = True
                print(info)
        
    print(info)
            
            










#for l in L:
#    x_t = [True] * len(list(bits))
#    for info in l:
#        print(info)
#        print(x_t)
#        i = 0
#        for x in bits:
#            print(x)
#            if x[info[0]-1] != info[1]:
#                x_t[i] = False
#            i += 1
#    print(x_t)
#                
#for x in bits:
#     for l in L:
#         for y in l:
#             print(x)
     









Measured memory_bytes: 5384
use std::io::Read;

const MOD: u64 = 1000001137;
const RAD: u64 = 200;

fn mod_pow(r: u64, mut n: u64) -> u64 {
    let mut t = 1;
    let mut s = r;
    while n > 0 {
        if n & 1 == 1 {
            t = t * s % MOD;
        }
        s = s * s % MOD;
        n >>= 1;
    }
    t
}

fn can(a: &Vec<u64>, s: &Vec<char>, len: usize) -> bool {
    let n = a.len() - 1;
    let f = mod_pow(RAD, len as u64);
    let mut i = 0;
    while i + 2 * len <= n {
        let v = (a[i] + MOD * MOD - a[i + len] * f) % MOD;
        let mut j = i + len;
        while j + len <= n {
            let u = (a[j] + MOD * MOD - a[j + len] * f) % MOD;
            if u == v {
                let mut ok = true;
                for k in 0..len {
                    if s[i + k] != s[j + k] {
                        ok = false;
                        break;
                    }
                }
                if ok {
                    return true;
                }
            }
            j += 1;
        }
        i += 1;
    }
    false
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let s: Vec<char> = it.next().unwrap().trim().chars().collect();
    let mut a = vec![0; n + 1];
    for i in (0..n).rev() {
        a[i] = (a[i + 1] * RAD + s[i].to_digit(36).unwrap() as u64) % MOD;
    }
    let mut l = 0;
    let mut r = n / 2 + 1;
    while r - l > 1 {
        let m = (l + r) / 2;
        if can(&a, &s, m) {
            l = m;
        } else {
            r = m;
        }
    }
    println!("{}", l);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

signed main() {
	int n;
	cin >> n;
	cout << (1 + n) * n / 2 << endl;
	return 0;
}

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

int main(){
    int n, r, l;
    cin >> n >> r >> l;

    int D[100001] = {};
    int T[100001] = {};

    int d, t, x;
    priority_queue<pair<int,int>> pq;
    for(int i = 1; i <= n; i++) pq.push({0, -i});
    int now = 0;

    for(int i = 0; i < r; i++){
        cin >> d >> t >> x;
        int diff = t-now;
        now = t;

        while(!pq.empty()){
            pair<int,int> p = pq.top();
            if(D[-p.second] == p.first){
                T[-p.second] += diff;
                break;
            }
            pq.pop();
        }
        D[d] += x;
        pq.push({D[d], -d});
    }

    int ans, _max = INT_MIN;
    for(int i = 1; i <= n; i++){
        if(D[i] > _max){
            _max = D[i];
            ans = i;
        }
    }
    T[ans] += l-now;

    ans = 0, _max = INT_MIN;
    for(int i = 1; i <= n; i++){
        if(T[i] > _max){
            _max = T[i];
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11920
#include <stdio.h>
#include <math.h>
 
#define PI 3.141592653589793
 
int main(void){
    int a,b,c;
    double s,l,h;
     
    scanf("%d%d%d",&a,&b,&c);
     
    s = sin(c * PI / 180.0)*a*b/2;
    l = a + b + sqrt(a*a + b*b - 2*a*b * cos(c * PI / 180.0));
    h = s/a*2;
     
    printf("%lf %lf %lf\n" ,s,l,h);
     
    return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

string angle = "RLUD";
ll vx[4] = {1,-1,0,0};
ll vy[4] = {0,0,1,-1};

void solve(const vector<ll>& w, ll x, ll y){
  ll nx = 0, ny = 0;
  rep(i,w.size()){
    ll len = w[i];
    ll mindist = 1e18;
    int mink = -1;
    rep(k,4){
      ll px = nx + len * vx[k];
      ll py = ny + len * vy[k];
      ll dist = llabs(x - px) + llabs(y - py);
      if(mindist > dist){
        mindist = dist;
        mink = k;
      }
    }

    cout << angle[mink];
    nx += len * vx[mink];
    ny += len * vy[mink];
  }
  cout << endl;
}


int main(){
  int N;
  cin >> N;
  vector<vector<ll>> v;
  bool odd = false;
  bool even = false;
  rep(i,N){
    ll x, y;
    cin >> x >> y;
    v.push_back({x,y});
    if((llabs(x) + llabs(y))%2 == 0) even = true;
    else odd = true;
  }

  if(even && odd){
    cout << -1 << endl;
  }else{
    vector<ll> w;
    if(even) w.push_back(1);
    ll p = 1;
    rep(i,32){
      w.push_back(p);
      p *= 2;
    }
    reverse(ALLOF(w));
    cout << w.size() << endl;
    rep(i,w.size()){
      if(i>0) cout << " ";
      cout << w[i];
    }
    cout << endl;
    
    rep(i,N){
      solve(w, v[i][0], v[i][1]);
    }
  }
  
  return 0;
}


Measured memory_bytes: 384
import heapq

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
sum=0
for i in range(N):
  if A[i]>=B[i]:
#    print("-1:",B[i])
    sum+=B[i]
    A[i]-=B[i]
  else:
#    print("-2:",A[i])
    sum+=A[i]
    tmp=B[i]-A[i]
    A[i]=0
    if A[i+1]>=tmp:
#      print("--1:",tmp)
      sum+=tmp
      A[i+1]-=tmp
    else:
#      print("--2:",A[i+1])
      sum+=A[i+1]
      A[i+1]=0
#  print(A)

#print(A)
print(sum)


Measured memory_bytes: 18752
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ios ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

int main()
{
    ll x;
    cin>>x;
    for(ll i=0;i<=1000;i++)
    {
        for(ll j=0;j<=1000;j++)
        {
            ll p=i-j;
            ll q=(i+j)*(i+j)*(i+j)*(i+j);
            ll r=i*j;
            ll s=(i+j)*(i+j);
            if(p*(q-(3*s*r)+(r*r))==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
            j=-j;
            p=i-j;
            q=(i+j)*(i+j)*(i+j)*(i+j);
            r=i*j;
            s=(i+j)*(i+j);
            if(p*(q-(3*s*r)+(r*r))==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
            i=-i;
            p=i-j;
            q=(i+j)*(i+j)*(i+j)*(i+j);
            r=i*j;
            s=(i+j)*(i+j);
            if(p*(q-(3*s*r)+(r*r))==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
            j=-j;
            p=i-j;
            q=(i+j)*(i+j)*(i+j)*(i+j);
            r=i*j;
            s=(i+j)*(i+j);
            if(p*(q-(3*s*r)+(r*r))==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
            i=-i;
        }
    }
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
typedef long long ll;
ll n, h[101], ans;
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n; i++) cin >> h[i];
    for (ll i = 100; i > 0; i--)
    {
        ll u = 0;
        for (ll j = 0; j < n; j++)
        {
            if (h[j] < i && u == 1)
            {
                u = 0;
            }
            if (u == 0 && h[j] >= i)
            {
                ans++, u = 1;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/******************
*  Writer: Oh no  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;

int n,k;
int a[100005];
int ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	
	ans=1e9;
	for(int i=1;i<=n-k+1;i++){
		if(a[i]>=0){
			ans=min(ans,a[i+k-1]-0);
		}else{
			if(a[i+k-1]<=0){
				ans=min(ans,0-a[i]);
			}else{
				ans=min(ans,min(a[i+k-1]*2+0-a[i],(0-a[i])*2+a[i+k-1]));
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
int main(){
  int n, c,a=0;
  std::cin>>n;
  for(int i=1;i<n+1;++i){if(i%2){c=0;for(int j=1;j<i+1;++j){(i%j?0:++c);}(c==8?++a:0);}}
  std::cout << a;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)

// dir???0:??????1:??? 2:??????3:???
// x:1~W y:1~H
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int W, H; 
	while (cin >> W >> H, W | H) {
		// s := square state
		vector<vector<int>> s(H + 2, vector<int>(W + 2, -1));
		for (int h = 1; h <= H;h++) for (int w = 1; w <= W;w++) cin >> s[h][w];

		// c := command cost
		vector<int> c(5, INF);
		for (int i = 0; i < 4;i++)cin >> c[i];

		//dist[h][w][dir] := stay s[h][w] / direction = dir
		vector<vector<vector<int>>> dist(H + 2, vector<vector<int>>(W + 2, vector<int>(4, INF)));
		dist[1][1][0] = 0;

		// tuple<h,w,dir>
		using key = tuple<int, int, int>;
		queue<key> q;
		q.push(key(1, 1, 0));



		while (!q.empty()) {
			int h, w, dir;
			tie(h, w, dir) = q.front(); q.pop();

			for (int com = 0; com < 4;com++) {
				int next_h = h + dy[(com + dir) % 4];
				int next_w = w + dx[(com + dir) % 4];

				// out square
				if (s[next_h][next_w] == -1) continue;

				int move_cost;
				if (s[h][w] == com) move_cost = 0;
				else move_cost = c[com];

				if (dist[next_h][next_w][(com + dir) % 4] > dist[h][w][dir] + move_cost) {
					dist[next_h][next_w][(com + dir) % 4] = dist[h][w][dir] + move_cost;
					if (next_h == H && next_w == W) continue;

					q.push(key(next_h, next_w, (com + dir) % 4));
				}
			}
		}

		int ans = INF;
		for (int i = 0; i < 4;i++) {
			ans = min(ans, dist[H][W][i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3220
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        int n= Integer.parseInt(br.readLine());
        int fx = 0;
        int tmp = n;
        while(tmp >0){
            fx += tmp%10;
            tmp /= 10;
        }
        if(n%fx == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }

}



Measured memory_bytes: 32768