akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-13

#define INF 1e16
const int MaxSize = 1e4 + 10;
const LL MOD = 1e9 + 7;

int N, A[MaxSize], cnt[1000000];
LL lcm;

LL p(LL b, LL po) {
	if (po == 0)
		return (LL)1;
	LL half = p(b, po / (LL)2);

	LL ans = half * half;
	ans %= MOD;

	if (po % 2) {
		ans *= b;
		ans %= MOD;
	}

	return ans;
}

void precalc() {
	LP(i, 0, N)
	{
		int a = A[i];
		LPE(d, 2, floor(sqrt(a)))//note i didn't use A[i]
		{

			int curC = 0;
			while(a % d  == 0){ //better order of actions
				curC++;
				a /= d;
			}
			cnt[d] = max(cnt[d], curC);
		}
		if (a > 1) {
			cnt[a] = max(cnt[a], 1);
		}
	}

	lcm = 1;

	LP(i, 2, 1000000)
	{
		lcm = lcm * p(i, cnt[i]);
		lcm %= MOD;
	}
}

int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/georgeli/pycp/A_1.in", "r", stdin);
	cin >> N;
	LP(i, 0, N)
	{
		cin >> A[i];
	}

	precalc();

	LL ans = 0;
	LP(i, 0, N)
	{
		ans += (lcm * p(A[i], MOD - 2)) % MOD;
		ans %= MOD;
	}

	cout << ans;

	return 0;
}



Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int H, W;
vector<vector<int> > field;
vector<pair<pair<int, int>, pair<int, int> > > ans;

int main() {
    cin >> H >> W;
    field.assign(H, vector<int>(W));
    for(int h=0; h<H; h++) {
        for(int w=0; w<W; w++) {
            cin >> field[h][w];
        }
    }
    long long int cnt=1;
    
    for(int h=0; h<H; h++) {
        if(h%2==0) {
            for(int w=0; w<W; w++) {
                if(cnt==(long long int)H*(long long int)W) break;
                if(field[h][w]%2!=0) {
                    if(w!=W-1) {
                        ans.push_back(make_pair(make_pair(h+1, w+1), make_pair(h+1, w+2)));
                        field[h][w]--;
                        field[h][w+1]++;
                    } else {
                        ans.push_back(make_pair(make_pair(h+1, w+1), make_pair(h+2, w+1)));
                        field[h][w]--;
                        field[h+1][w]++;
                    }
                }
                cnt++;
            }
        } else {
            for(int w=W-1; w>=0; w--) {
                if(cnt==(long long int)H*(long long int)W) break;
                if(field[h][w]%2!=0) {
                    if(w!=0) {
                        ans.push_back(make_pair(make_pair(h+1, w+1), make_pair(h+1, w)));
                        field[h][w]--;
                        field[h][w-1]++;
                    } else {
                        ans.push_back(make_pair(make_pair(h+1, w+1), make_pair(h+2, w+1)));
                        field[h][w]--;
                        field[h+1][w]++;
                    }
                }
                cnt++;
            }
        }
    }

    cout << ans.size() << endl;
    for(int i=0; i<ans.size(); i++) {
        cout << ans[i].first.first << " " << ans[i].first.second << " " << ans[i].second.first << " " << ans[i].second.second << endl;
    }

    return 0;
    
}

Measured memory_bytes: 5232
/*
2020-05-02
atcoder ABC
A - We Love Golf
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    for(int i = A; i < B + 1; i++){
        if(i % K == 0){
            cout << "OK" << endl; 
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3600
import itertools
N ,M = map(int, input().split())
L = []
cou = 0
ans = 0
for i in range(M):
    L.append(list(map(int, input().split())))
p = list(map(int,input().split()))
l = list(itertools.product(range(2),repeat=N))

for li in l:
    li = list(li)
    for i in range(M):
        for j in range(L[i][0]):
            ans += li[L[i][j+1]-1]
    
        if ans % 2 == p[i]:
            ans = 0
        else:
            ans = 0
            break
        if i == M-1:
            cou += 1
            ans = 0
print(cou)


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

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

struct edge {
    int from, to;
    ll weight;
};

using edges = vector<edge>;
using graph = vector<edges>;

constexpr ll INF = 1e18;

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

    graph g(N);
    ll sum_cost = 0;
    for(int i=0; i<M; ++i) {
        int a, b;
        ll d;
        cin >> a >> b >> d;
        a--; b--;
        g[a].push_back((edge){a, b, d});
        g[b].push_back((edge){b, a, d});
        sum_cost += d;
    }

    vector<P> d(N);
    for(int i=1; i<N; ++i) {
        d[i] = make_pair(INF, i);
    }
    d[0] = make_pair(0, 0);
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(make_pair(0, 0));
    while(!que.empty()) {
        P p = que.top();
        int v = p.second;
        que.pop();
        if(d[v].first > p.first) {
            continue;
        }
        for(auto& e : g[v]) {
            if(d[e.to].first > d[v].first + e.weight) {
                d[e.to].first = d[v].first + e.weight;
                que.push(make_pair(d[e.to].first, e.to));
            }
        }
    }
    sort(d.begin(), d.end());
    ll res = 1e18;
    set<int> S;
    for(int i=0; i<N; ++i) {
        for(auto& e : g[d[i].second]) {
            if(S.count(e.to) == 1) {
                sum_cost -= e.weight;
            }
        }
        res = min(res, sum_cost + C * d[i].first);
        S.insert(d[i].second);
    }
    cout << res << endl;
}

Measured memory_bytes: 22108
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;


int main() {
	int i = 0;
	string S;
	cin >> S;

	if (S[0] != S[1]) {
		i = 1;
	}
	if (S[1] != S[2]) {
		i = 1;
	}

	if (i == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int n,a,b,c;
vector<int> G[MAX];
int size[MAX];
int par[MAX];
int dep[MAX];
int depth[MAX];
int parent[MAX];

void idfs(int pos,int prev){
  int m=-1;
  parent[pos]=prev;
  if(G[pos].size()==1&&prev!=-1)return;  
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    depth[to]=depth[pos]+1;
    idfs(to,pos);
    size[pos]+=size[to];
    if(m==-1||size[m]<size[to]){
      m=to;
    }
  }
  par[m]=pos;
}

int calc(int x){
  if(par[x]==x)return x;
  return par[x]=calc(par[x]);
}

void init(){
  for(int i=0;i<MAX;i++){
    size[i]=1;
    par[i]=i;
  }
  for(int i=0;i<n;i++){    
    scanf("%d",&a);
    while(a--){
      scanf("%d",&b);
      G[i].push_back(b);
      G[b].push_back(i);
    }
  }
  for(int i=0;i<n;i++)sort(G[i].begin(),G[i].end());
  depth[0]=0;
  idfs(0,-1);
  for(int i=0;i<n;i++){
    calc(i);
    int p=par[i];
    while(p>0){
      p= par[ parent[p] ];      
      dep[i]++;
    }
  }  
}

int main(){
  while( scanf("%d",&n)!=EOF){
    init();
    int q;
    scanf("%d",&q);
    while(q--){
      scanf("%d %d",&a,&b);

      while(par[a]!=par[b]){
        if(dep[a]<dep[b])swap(a,b);
        a=parent[par[a]];
      }
      printf("%d\n",(depth[a]<depth[b]?a:b));      

    }
    break;
  }

  
  return 0;
}

Measured memory_bytes: 16048
// AOJ Vol-0 0090: Overlaps of Seals
// 2017.10.1 bal4u@uu

#include <stdio.h>
#include <math.h>

#define EPS 1.0e-8

typedef struct { double x, y; } PP;
PP circle[102];

PP cross[10000]; int sz;

void crossPoint(double x1, double y1, double x2, double y2)
{
	double A, B, d, d2, h, k, X, Y;
	A = (x1 - x2)/2, B = (y1 - y2)/2;
	d = sqrt(A*A + B*B), d2 = d*d;
	if (d2 > 1.0 + EPS) return;
	h = sqrt(1 - d2);
	k = h / d;
	X = (x1 + x2)/2, Y = (y1+y2)/2;
	cross[sz].x = X + k*B, cross[sz++].y = Y - k*A;
	cross[sz].x = X - k*B, cross[sz++].y = Y + k*A;
}

int main()
{
	int i, j, n, f, ans;
	double dx, dy, d;

	while (scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++)
			scanf("%lf,%lf", &circle[i].x, &circle[i].y);
		sz = 0;
		for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
			crossPoint(circle[i].x, circle[i].y, circle[j].x, circle[j].y);
		}
		for (ans = 0, i = 0; i < sz; i++) {
			for (f = 0, j = 0; j < n; j++) {
				dx = circle[j].x - cross[i].x;
				dy = circle[j].y - cross[i].y;
				d = dx*dx + dy*dy;
				if (fabs(d - 1.0) <= EPS || d <= 1.0) f++;
			}
			if (f > ans) ans = f;
		}
		if (ans == 0) ans = 1;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1772
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define MOD 1e9 + 7
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define all(x) (x).begin(), (x).end()

void Main()
{
    int k;
    string s;
    cin >> k >> s;

    string s2 = s.substr(0, k);

    if (s.size() > k)
    {
        cout << s2 << "..." << endl;
    }
    else
    {
        cout << s2 << endl;
    }

    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  string S, T; cin >> S >> T;
  rep(i, S.length()) {
    char first = S[0];
    S[0] = S[S.length() - 1];
    char prev = first, tmp;
    for (int j = 1; j <= S.length() - 1; j++) {
      tmp = S[j];
      S[j] = prev;
      prev = tmp;
    }
    if (S == T) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n,m = i2()
l = []
r = []
for i in range(m):
	L,R = i2()
	l.append(L)
	r.append(R)
print( max(min(r) - max(l) + 1, 0) )

Measured memory_bytes: 16716
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll n, k;
combination comb( 2000000 );

int main() {
  std::cin >> n >> k;

  mint ans = 0;

  rep( K, k+1 ) {
    ans += comb( n-1, n-K-1 )*comb( n, K );
  }

  std::cout << ans.x << endl;

  return 0;
}

Measured memory_bytes: 34184
import collections
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for i in range(Q)]
 
ans = sum(A)
cnt = collections.Counter(A)
 
dp = [0]*(10**5+1)
 
for i in cnt.items():
    dp[i[0]] = i[1]
 
for i in range(Q):
    ans += (BC[i][1] - BC[i][0]) * dp[BC[i][0]]
    dp[BC[i][1]] += dp[BC[i][0]]
    dp[BC[i][0]] = 0
    print(ans)

Measured memory_bytes: 36208
a, b, h, m = gets.split.map(&:to_i)

time = h * 60 + m
short = time * 0.5
long = m * 6

angle = (long - short).abs
angle = (angle < 360 - angle) ? angle : 360 - angle

answer = (a ** 2) + (b ** 2) - (2 * a * b * Math.cos(angle / 180.0 * Math::PI))

puts Math.sqrt(answer)


Measured memory_bytes: 14660
use std::io::{stdin, stdout, BufReader, BufRead, StdinLock, Write, BufWriter};

fn main() {
    let (std_in, std_out) = (stdin(), stdout());
    let mut br = BufReader::new(std_in.lock());
    let mut bw = BufWriter::new(std_out.lock());

    let n = rn::<usize>(&mut br);
    let mut s = Vec::<String>::new();
    for i in 0..n {
        let mut x = rs(&mut br);
        x.sort();
        s.push(x.into_iter().collect());
    }

    s.sort();
    let mut res = 0;
    let mut le = 0;
    for i in 1..n {
        if s[i] == s[i-1] {
            continue;
        }
        let x = i - le;
        res += (x-1) * x / 2;
        le = i;
    }
    let x = n - le;
    res += (x-1) * x / 2;
    writeln!(&mut bw, "{}", res);
}


//////////////////////////////////////////////////////////////////////////////////
#[allow(dead_code)]
fn rs(br: &mut BufReader<StdinLock>) -> Vec<char> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().chars().collect()
}

#[allow(dead_code)]
fn rn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> T {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn rvs(br: &mut BufReader<StdinLock>) -> Vec<Vec<char>> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.chars().collect()).collect()
}

#[allow(dead_code)]
fn rvn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> Vec<T> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 9720
n,k=map(int,input().split())
p=list(map(int,input().split()))
q=[0]
for i in range(0,n-k):
  q.append(q[-1]+p[i+k]-p[i])
b=q.index(max(q))
s=0
for i in range(b,b+k):
  s+=p[i]
print((s+k)/2)

Measured memory_bytes: 24804
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int s,w;
  cin>>s>>w;
  if(w>=s){
    cout<<"unsafe"<<endl;
  }
  else{
    cout<<"safe"<<endl;
  }
  return(0);
}


Measured memory_bytes: 3636
import sys
input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    MOD = 10**9+7
    
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])

        if temp!=1:
            arr.append([temp, 1])

        return arr
        
    cl = factorization(M)
    
    def combinations(x,y,N):
        fac = [0]*(N+1)
        fac[0],fac[1] = 1,1
        
        for i in range(2,N+1):
            fac[i] = (fac[i-1]*i)%MOD
            
        return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD
        
    ans = 1
    for pr,num in cl:
        ans *= combinations(N-1,num,N+num)
        ans %= MOD
    
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 45680
import java.util.*;

class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		for(int i=0; i<n; i++){
			int base=0;
			int cnt = 0, out=0;
			while(out<3){
				String res = in.next();
				if(res.equals("HIT")){
					if((base & (1<<2)) > 0){
						cnt++;
						base &= ~(1<<2);
					}
					base <<= 1;
					base |= 1;
				}
				else if(res.equals("HOMERUN")){
					cnt += 1 + Integer.bitCount(base);
					base = 0;
				}
				else{
					out++;
				}
			}
			System.out.println(cnt);
		}
	}
}

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

int main(){
  long long N;
  cin >> N;
  string res="";
  while(N){
    N--;
    int A=N%26;
    char C='a'+A;
    res+=C;
    N/=26;
  }
  reverse(res.begin(),res.end());
  cout << res << endl;
}
  
  

Measured memory_bytes: 3628
#include<queue>
#include<string>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
int read()
{
	int s=0;int c=getchar(),f=1;
	while(c<48||c>57)
	{
		if(c==45) f=-1;
		c=getchar();
	}
	while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return s*f;
}
void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
void W(int x)
{
	if(x<0) x=-x,putchar(45);
	write(x);
}
int main()
{
	int a=read(),b=read(),c=read();
	if(a==b&&b==c) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#include "bits/stdc++.h"
using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> a(H, vector<char>(W));

	REP(h, H) {
		string S;
		cin >> S;
		REP(w, W) {
			a[h][w] = S[w];
		}
	}

	REP(h, H) {
		bool flag_del = true;
		REP(w, W) {
			if (a[h][w] == '#') {
				flag_del = false;
			}
		}
		if (flag_del) {
			REP(w, W) {
				a[h][w] = 'd';
			}
		}
	}

	REP(w, W) {
		bool flag_del = true;
		REP(h, H) {
			if (a[h][w] == '#') {
				flag_del = false;
			}
		}
		if (flag_del) {
			REP(h, H) {
				a[h][w] = 'd';
			}
		}
	}

	REP(h, H) {
		bool flag_disp = false;
		REP(w, W) {
			if (a[h][w] != 'd') {
				cout << a[h][w];
				flag_disp = true;
			}
		}
		if (flag_disp) {
			cout << endl;
		}		
	}

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

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

const int mod = 1e9 + 7;
const char nl = '\n';

void solve() {
    ll a, b, x, cnt(0);
    cin >> a >> b >> x;
    ll ans = b / x - a / x;
    if((a % x == 0)) ans++;
    cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
string S;

//解法
void solve() {

	int ans = 0;

	rep(i, 4) {
		if (S[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}

	cout << ans;

	return;
}

int main() {
	//入力
	cin >> S;
	solve();
	cout << endl;
	return 0;
}


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


using namespace std;
vector<int>v;
int main(){
	int Q;
	scanf("%d",&Q);
	while(Q--){
		int q,x;
		scanf("%d",&q);
		if(q==0){
			scanf("%d",&x);
			v.push_back(x);
		}
		else if(q==1){
			scanf("%d",&x);
			printf("%d\n",v[x]);
		}
		else v.pop_back();
	}
	return 0;
}


Measured memory_bytes: 3936
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
int main()
{
	IOS;
	ll a,b,n;
	cin>>a>>b>>n;
	ll q=min(b-1,n);
	if(q!=0)
	{
		cout<<(a*q)/b;
	}
	else
	cout<<0;
}



Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int s[100005];
vector<P> path[100005];

void check(int t,int a){
	if(s[t]!=-1)return;
	int b,c,d;
	s[t]=a;
	for(int i=0;i<path[t].size();i++){
		b=path[t][i].first,c=path[t][i].second;
		if(c%2==1)d=1-a;
		else d=a;
		check(b,d);
	}
}

int main(){
	int n;
	int i,j,k;
	int a,b,c;
	cin>>n;
	for(i=0;i<n-1;i++){
		cin>>a>>b>>c;
		a--,b--;
		path[a].push_back(make_pair(b,c));
		path[b].push_back(make_pair(a,c));
	}
	memset(s,-1,sizeof(s));
	check(0,0);
	array_show(s,n);
}


Measured memory_bytes: 8448
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int answer = 0;
        for(int i = 1; i <= 5; i++){
            answer++;
            int n = sc.nextInt();
            if(n == 0){
                break;
            }
        }
        System.out.println(answer);
    }

}


Measured memory_bytes: 35636
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
   while(cin>>a>>b>>c)
    {
        int i,z=0,sum=0;
        for(i=1;i<=a;i++)
        {
            int count=i,d=1;
            z=0;
            while(count)
            {
                d=count%10;
                z=z+d;
                count=count/10;
            }
            if(z>=b&&z<=c)
                sum+=i;
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	char buf[10];
	int sei,bunbo,zyun,i,j,flg,len,x,y,yaku,ama,zbo;
	scanf("%s",buf);
	len=strlen(buf);
	flg=0;
	sei=0;
	bunbo=1;
	zyun=0;
	zbo=0;
	for(i=0;i<len;i++)	{
		if(flg==0)	{
			if(buf[i]!='.')	{
				sei=sei*10;
				sei+=buf[i]-'0';
			}
			else {
				flg=1;
			}
		}
		else if(flg==1)	{
			if(buf[i]!='(')	{
				sei=sei*10;
				sei+=buf[i]-'0';
				bunbo=bunbo*10;
			}
			else {
				flg=2;
				zyun=sei;
			}
		}
		else {
			if(buf[i]!=')')	{
				sei=sei*10;
				sei+=buf[i]-'0';
				zbo=zbo*10;
				zbo+=9;
			}
			else {
				sei=sei-zyun;
				bunbo=bunbo*zbo;
			}
		}
	}
	x=sei;	y=bunbo;
	if(x<y)	swap(x,y);
	while(1)	{
		ama=x%y;
		if(ama==0)	{
			yaku=y;
			break;
		}
		else {
			x=y;
			y=ama;
		}
	}
	sei=sei/yaku;	bunbo=bunbo/yaku;
	printf("%d/%d\n",sei,bunbo);
	return 0;
}


Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
using str = string;
using vi = vector<int>;

int d[2019];
int d2[2019];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);

  vi a(200010);
  str s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  rep(i, n) a[i] = s[i] - '0';
  d2[a[0]]++;
  REP(i, 1, n) {
    d[a[i]]++;
    rep(j, 2019) { d[(10 * j + a[i]) % 2019] += d2[j]; }
    ans += d[0];
    rep(j, 2019) {
      d2[j] = d[j];
      d[j] = 0;
    }
  }
  cout << ans << endl;
}

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

int main(){
  ll x;
  cin>>x;
  ll ans=0;
  for(ll i=1;i<=x;i++){
    ll n=x/i;
    ans+=((n+1)*n*i)/2;
  }
  cout<<ans<<endl;
}

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

using namespace std;

int d_i[4] = {1, 0, -1, 0};
int d_j[4] = {0, 1, 0, -1};

const int N = 55;

char a[N][N];

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		string str;
		cin >> str;
		for (int j = 0; j < m; j++) {
			a[i][j] = str[j];
		}
	}
	bool found = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i][j] == '.') continue;
			bool ok = 0;
			for (int k = 0; k < 4; k++) {
				int x = i + d_i[k];
				int y = j + d_j[k];
				if (x < 0 || x > n || y < 0 || y > m) continue;
				if (a[x][y] == '#') {
					ok = 1;
				}
			}
			found &= ok;
		}
	}
	if (found) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 300010;
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	string a;
	cin >> a;
	if (a.back() == 's')
		a += 'e';
	a += 's';
	cout << a << '\n';
}



Measured memory_bytes: 3636
import java.util.Scanner;
import java.util.Stack;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        sc.useDelimiter("[\\s]+");
        while (sc.hasNext()) {
            int a[] = new int[4];
            for (int i = 0; i < 4; i++) {
                a[i] = sc.nextInt();
            }
            int hit = 0, blow = 0;
            for (int i = 0; i < 4; i++) {
                int b = sc.nextInt();
                for (int j = 0; j < 4; j++) {
                    if (a[j] == b) {
                        if (i == j) {
                            hit++;
                        } else {
                            blow++;
                        }
                        continue;
                    }
                }
            }
            System.out.println(hit + " " + blow);
        }
    }
}


Measured memory_bytes: 26528
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)

typedef long long ll;

using namespace std;

int main()
{
    int N; cin >> N;
    string S; cin >> S;
    int count = 0;
    rep(i, N-1)
    {
        if(S[i] != S[i+1]) count++;
    }
    count++;

    cout << count << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> P(N);
  vector<int> sP(N);
  
  rep(i,N){
    cin >> P.at(i);
    sP.at(i) = P.at(i);
  }
  
  sort(sP.begin(),sP.end());
  
  int cnt = 0;
  rep(i,N){
    if(P.at(i) != sP.at(i)) cnt++;
  }
  
  if(cnt<3) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using pii = pair<int,int>;
using ll = long long;

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

   int a, b, c, d;
   cin >> a >> b >> c >> d;
   int p = abs(a-b);
   int q = abs(b-c);

   outl((p <= d && q <= d) || (abs(a-c) <= d) ? "Yes" : "No");
}



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

int main()
{
    int A, B, K, counts = 0;
    cin >> A >> B >> K;

    for (int i = min(A, B); i > 0; i--)
    {
        if (((A % i) == 0) && ((B % i) == 0))
        {
            counts++;
            if (counts == K)
            {
                cout << i << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}

ll extgcd(ll a,ll b,ll &x,ll &y){
    if(!b){
        x=1;y=0;
        return a;
    }
    ll d=extgcd(b,a%b,y,x);
    y-=a/b*x;
    return d;
}
int main(){
    int n,m;
    cin>>n>>m;
    string s,t;
    cin>>s>>t;
    ll l=lcm(n,m);
    map<ll,char> a;
    REP(i,n){
        a[l/n*i]=s[i];
    }
    REP(i,m){
        if(a.find(l/m*i)!=a.end()&&a[l/m*i]!=t[i]){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 6144
N=int(input())
S=input()
count=0
I=[]
for i in range(N-2):
    if S[i] not in I:
        I.append(S[i])
    else:
        continue
    J=[]
    for j in range(i+1,N-1):
        if S[j] not in J:
            J.append(S[j])
        else:
            continue
        K=[]
        for k in range(j+1,N):
            if S[k] not in K:
                K.append(S[k])
                count+=1
print(count)

Measured memory_bytes: 9280
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int max_index = 0, max_val = min(v.back() - v[0], v[0]);
    for (int i = 1; i < n; i++ ){
        int val = min(v.back() - v[i], v[i]);
        if (val > max_val) {
            max_index = i;
            max_val = val;
        }
    }
    cout << v.back() << " " << v[max_index] << endl;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N;
  cin >> N;

  vector<int> p(N+1);
  for(int i = 1;i <= N;i++) {
    cin >> p.at(i);
  }

  int ans = 0;
  for(int i = 1;i < N;i++) {
    if(p.at(i) == i) {
      swap(p.at(i),p.at(i+1)); 
      ans++;
    }
  }

  if(p.at(N) == N) ans++;

  cout << ans << endl;

}

Measured memory_bytes: 640
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
ctr = 0

ar = (0..a).to_a
br = (0..b).to_a
cr = (0..c).to_a

ar.each do |i1|
  br.each do |i2|
    cr.each do |i3|
      if i1*500+i2*100+i3*50 == x
      ctr += 1
      end
    end
  end
end

puts ctr


Measured memory_bytes: 3836
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;
constexpr ll MAX_N = 100;
ll dp[MAX_N + 1][MAX_N + 1][MAX_N + 1][MAX_N + 1];

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

    ll N, W;
    cin >> N >> W;

    vector<p> inputs(N);
    vector<ll> V[4];
    ll min_weight = INF;
    for (ll i = 0; i < N; i++) {
        ll w, v;
        cin >> w >> v;
        inputs[i] = p(w, v);
        min_weight = min(min_weight, w);
    }

    for (auto in : inputs) {
        V[in.first - min_weight].push_back(in.second);
    }

    for (ll i = 0; i < 4; i++) {
        sort(V[i].begin(), V[i].end());
        V[i].push_back(0);
        reverse(V[i].begin(), V[i].end());
    }

    for (ll i = 0; i < 4; i++) {
        for (ll j = 1; j < V[i].size(); j++) {
            V[i][j] += V[i][j - 1];
        }
    }

    ll ans = 0;

    for (ll a = 0; a < V[0].size(); a++) {
        for (ll b = 0; b < V[1].size(); b++) {
            for (ll c = 0; c < V[2].size(); c++) {
                for (ll d = 0; d < V[3].size(); d++) {
                    ll weight = a * min_weight + b * (min_weight + 1) + c * (min_weight + 2) + d * (min_weight + 3);
                    if (weight <= W) {
                        ans = max(ans, V[0][a] + V[1][b] + V[2][c] + V[3][d]);
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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];
        for(int i=0;i<n;i++)a[i] = Integer.parseInt(sc.next());

        long gcd = 0;
        for(int i=0;i<n;i++){
            gcd = getGCD(a[i], gcd);
        }
        System.out.println(gcd);
        sc.close();

    }

    public static long getGCD(long a,long b){
        if(b==0){
            return a;
        }else{
            return getGCD(b,a%b);
        }
    }
    
}

Measured memory_bytes: 48908
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
 
typedef __int128 LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_backpostdoctoral
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;
 
template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
 
const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;

void solve(LL x){
	cout << (long long)x << endl;
	exit(0);
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  	
  	int n;
  	cin >> n;
  	vector<int> a(n + 1);
  	FOR(i, 0, n + 1) cin >> a[i];
	vector<LL> s(n + 1);
	s[n] = a[n];
	RFOR(i, n, 0) s[i] = s[i + 1] + a[i];
	
	if (n == 0){
		if (a[0] == 1) solve(1);
		else solve(-1);
	}
	
	if (a[0] != 0) solve(-1);
	
	LL ans = 1;	
	LL cnt = 1;
	FOR(i, 1, n + 1){
		cnt = min(s[i], 2 * (cnt - a[i - 1]));
		if (cnt < a[i]) solve(-1);
		ans += cnt;
	}
	
	solve(ans);
	
    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}


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

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<bool> isHave(n);
	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int t;
			cin >> t;
			isHave[t-1] = true;
		}
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (isHave[i] == false) cnt++;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 3620
using System;

namespace AOJ0058
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;

                string[] num = input.Split(' ');
                Point a = new Point(num[0], num[1]);
                Point b = new Point(num[2], num[3]);
                Point c = new Point(num[4], num[5]);
                Point d = new Point(num[6], num[7]);
                Line p = new Line(a, b);
                Line q = new Line(c, d);
                
                if (check_ortho(p, q))
                {
                    Console.WriteLine("YES");
                } else
                {
                    Console.WriteLine("NO");
                }
            }
        }

        static bool check_ortho (Line p, Line q)
        {
            if (p.axis ^ q.axis)
            {
                if (p.slope == 0 && q.slope == 0)
                {
                    return true;
                } else
                {
                    return false;
                }
            } else
            {
                if (p.slope == 0 || q.slope == 0)
                {
                    return false;
                }
                else
                {
                    if (Math.Abs(p.slope + (1 / q.slope)) < 0.0000000001M)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
        }
    }

    public struct Point
    {
        public decimal X, Y;

        public Point(string a, string b)
        {
            this.X = decimal.Parse(a);
            this.Y = decimal.Parse(b);
        }
    }

    public struct Line
    {
        public decimal slope;
        public bool axis;

        public Line(Point a, Point b)
        {
            if (b.X.Equals(a.X))
            {
                this.slope = 0;
                axis = true;
            } else
            {
                this.slope = (b.Y - a.Y) / (b.X - a.X);
                axis = false;
            }   
        }
    }
}

Measured memory_bytes: 9452
#include <iostream>
#include <vector>
using namespace std;
//---------------------------------------
int SelectionSort(vector<int>& a);
void Show(const vector<int> a, const int ss_count);
//---------------------------------------

int main(void)
{
	int n;
	vector<int> a;
	
	cin >> n;
	
	for(int i = 0; i < n; i++){
		int num;
		cin >> num;
		a.push_back(num);
	}
	
	int ss_count = SelectionSort(a); //????????????(???????????????)
	Show(a, ss_count);
	
	return 0;
}

//------------------------------------------
int SelectionSort(vector<int>& a){
	
	int ss_count = 0;
	
	for(int i = 0; i < a.size(); i++){
		int minj = i;
		for(int j = i; j < a.size(); j++){
			if(a[j] < a[minj]){
				minj = j;
			}
		}
		if(i == minj){
			continue; //??\???????????????for????????????
		}
		int temp = a[i];
		a[i] = a[minj];
		a[minj] = temp;
		ss_count++;
	}
	return ss_count;
}
//--------------------------------------------
void Show(const vector<int> a, const int ss_count){
	for(int i = 0; i < a.size() - 1; i++){
		cout << a[i] << ' ';
	}
	cout << a[a.size() - 1] << endl;
	
	cout << ss_count << endl;
	
}

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

int main() {
  string N,M;
  cin>>N>>M;
  N=N+M;
  int n=stoi(N);
  for(int i=0;i<n;i++){
    if(i*i==n){
      cout<<"Yes";
      break;
      
    }
    else if(i==n-1){
      cout<<"No";
    }
  }
  
    
}

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

using namespace std;

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)

int main(int argc, char const *argv[]){

	map<int, int> m;
	int input, ans, sta;
	while(cin >> input){
		sta = 0;
		ans = 1;
		m[input] = 1;
		while(1){
			if (input % 2 == 0){
				ans++;
				input /= 2;
				m[input] += 1;
			}
			else{
				ans++;
				input = (3*input + 1);
				m[input] +=1;
			}
			for (map<int,int>::iterator it=m.begin(); it != m.end(); ++it){
				if (it->second == 2){
					cout << ans << endl;
					sta = 1;
					break;
				}
			}
			if(sta == 1)	break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
from itertools import *
n,k,*p=map(int,open(0).read().split())
a=[(1+i)/2 for i in p]
b=list(accumulate(a))
ans=0
if k==1:
    ans=max(a)
elif k==n:
    ans=b[-1]
else:
    for i in range(n-k):
        ans=max(ans,b[i+k]-b[i])
print(ans)

Measured memory_bytes: 25420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String str = br.readLine();
			String[] strArr = str.split(" ");
			int m = Integer.parseInt(strArr[0]);
			int f = Integer.parseInt(strArr[1]);
			int r = Integer.parseInt(strArr[2]);

			List<String> scores = new ArrayList<String>();
			int sum = 0;
			boolean yasumi=false;
			while (!( m==-1 && f==-1 && r==-1)) {

				sum = m+f;
				yasumi = m==-1 || f==-1;

				if(!yasumi && 80<=sum){
					scores.add("A");
				}else if(!yasumi && 65<=sum){
					scores.add("B");
				}else if(!yasumi && (50<=sum || (sum<50 && 50<=r))){
					scores.add("C");
				}else if(!yasumi && 30<=sum){
					scores.add("D");
				}else{
					scores.add("F");
				}

				str = br.readLine();
				strArr = str.split(" ");
				m = Integer.parseInt(strArr[0]);
				f = Integer.parseInt(strArr[1]);
				r = Integer.parseInt(strArr[2]);

				;
			}

			for(String s : scores){
				System.out.println(s);
			}

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {
					br.close();
				}
			} catch (IOException ioe) {
			}

		}
	}
}

Measured memory_bytes: 17100
#include <iostream>
#include <algorithm>
#include <map>
#include <chrono>

int main() {
    std :: map < int, int > hash;

    int n;
    uint64_t prefix = 0;

    std :: cin >> n;

    int arr[n];
    for(auto& i : arr) {
        std :: cin >> i;
        hash[i]++;
        prefix += i;
    }

    int q;
    std :: cin >> q;

    for(int i = 0 ; i < q ; i++) {
        int b, c;
        std :: cin >> b >> c;

        prefix = prefix - (hash[b] * b) + (hash[b] * c);

        std :: cout << prefix << '\n';
        hash[c] += hash[b];
        hash[b] = 0;
        //for(auto& i : hash) std :: cerr << i.first << " = " << i.second << '\n';
    }
}

Measured memory_bytes: 7968
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long maxHeight;
    cin >> maxHeight;
    long long sumSpringboard = 0;
    rep(i,n-1){
        long long currentHeight;
        cin >> currentHeight;
        if(maxHeight < currentHeight) maxHeight = currentHeight;
        else sumSpringboard += maxHeight - currentHeight;
    }
    cout << sumSpringboard << endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}

	ll money = 1000;
	ll t = 0;

	for (int j = 0; j < n-1; j++) {
		if (a[j] < a[j + 1]) {
			t = money / a[j];
			money += (a[j + 1] - a[j]) * t;
			t = 0;
		}
	}
	cout << money << endl;
}



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

const int N = 200003;
int fa[N], cnt[N];

int ff(int x)
{
	return fa[x] == x ? x : fa[x] = ff(fa[x]);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		fa[i] = i, cnt[i] = 1;
	for (int i = 1; i <= m; ++i)
	{
		int a, b;
		cin >> a >> b;
		int u = ff(a), v = ff(b);
		if (u != v)
		{
			fa[u] = v;
			cnt[v] += cnt[u];
		}
	}
	int sum = 0;
	for (int i = 1; i <= n; ++i)
		if (cnt[i] > sum)
			sum = cnt[i];
	cout << sum;
	return 0;
}

Measured memory_bytes: 5176
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>

using namespace std;


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

  for(int i = 0; i < n; ++i){
    while(a[i] % 2 == 0){
      a[i] /= 2;
      ans++;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))

for i in range(n):
    if 1 <= li[i] <=399:
        li[i] = 1
    elif 400<= li[i] <=799: 
        li[i] = 2
    elif 800<= li[i] <=1199:
        li[i] = 3
    elif 1200<= li[i] <=1599:
        li[i] = 4
    elif 1600<= li[i] <=1999:
        li[i] = 5
    elif 2000<= li[i] <=2399:
        li[i] = 6
    elif 2400<= li[i] <=2799:
        li[i] = 7
    elif 2800<= li[i] <=3199:
        li[i] = 8
    elif 3200<= li[i] <=4800:
        li[i] = 10+i
max1 = len(set(li))
li = [x for x in li if x < 9]
if len(li) == 0:
    min1 = 1
else:
    min1 = len(set(li))
print(min1,max1)

Measured memory_bytes: 3064