akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

static const int MAX = 100;
int a[MAX];

int main() {
	
	int n;
	cin >> n;
	for ( int i = 0; i < n; i++ ) cin >> a[i];
	
	int swapNum = 0;
	for ( int i = 0; i < n-1; i++ ) {
		int min = i; //??°???????°?????????? 
		for ( int j = i; j < n; j++ ) {
			if ( a[min] > a[j] ) {
				min = j;
			} 
		}
		swap( a[min], a[i] );
		if ( i != min ) swapNum++;
	}
	
	for ( int i = 0; i < n; i++ ) {
		if ( i ) cout << " ";
		cout << a[i];
	}
	cout << endl;
	cout << swapNum << endl;
	
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int N,A,B;

	cin >> N >> A >> B;	

	int ans = min (N*A, B);


	printf("%d",ans);



	return 0;
}



Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int main(){
  int a, b;
  cin >> a >> b;
  int ans = a+ b;
  ans = max(ans, a - b);
  ans = max(ans, a * b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main()
{
	int a,b;
	double C,S=0,L=0,h=0;
	
	scanf("%d %d %lf",&a,&b,&C);
	C=C*M_PI/180;
	S = (a*b*sin(C))/2;
	
	h = b*sin(C);
	
	L = a + b + sqrt((a*a)+(b*b)-(2*a*b*cos(C)));
	
	printf("%.8f\n",S);
	printf("%.8f\n",L);
	printf("%.8f\n",h);
	
	return 0;
}


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

int main() {
  unsigned long long int N,A,B;
  cin >> N >> A >> B;
  if(N == 1 && A != B) {
    cout << 0 << endl;
  }
  else if(A > B) {
    cout << 0 << endl;
  }
  else {
    cout << B * ( N - 1 ) + A - A * ( N - 1 ) - B + 1<< endl;
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, Y = map(int, input().split())

for i in range(N+1):
    for j in range(N-i+1):
        k = N-i-j
        
        if 10000*i+5000*j+1000*k==Y:
            print(i, j, k)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 41324
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    int a, b, c; cin >> a >> b >> c;
    int ans = a + b + c;
    if(ans >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  for (int i =0; i < N ; i++){
    cin >> m.at(i);
    X -= m.at(i);
  }
  
  sort(m.begin(),m.end());
  int ans = m.size() + X/m.at(0);
  
  cout << ans << endl;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n,c;
mat d;
mat l;
lli ans = LONG_MAX;

int main(){
  cin >> n >> c;
  d = mat(c,vll(c));
  for(lli i = 0;i < c;i++){
    for(lli j = 0;j < c;j++){
      cin >> d[i][j];
    }
  }
  l = mat(3,vll(c));
  for(lli i = 0;i < n;i++){
    for(lli j = 0;j < n;j++){
      lli c;
      cin >> c;
      l[(i+j)%3][c-1]++;
    }
  }
  for(lli i = 0;i < c;i++){
    for(lli j = 0;j < c;j++){
      for(lli k = 0;k < c;k++){
        if(i == j || j == k || k == i) continue;
        lli mem = 0;
        for(lli s = 0;s < c;s++){
          mem += d[s][i]*l[0][s];
          mem += d[s][j]*l[1][s];
          mem += d[s][k]*l[2][s];
        }
        ans = min(ans,mem);
      }
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

vi G[MAX_N];
int h[MAX_N];
int n,K;
int ans;

void dfs(int u,int p){
    if(len(G[u]) == 0){
        if(K == 1 && p > 0){
            h[u] = -1;
            ans++;
        }else{
            h[u] = 0;
        }
        return;
    }
    rep(i,len(G[u])){
        if(G[u][i] != p){
            dfs(G[u][i],u);
            h[u] = max(h[u],h[G[u][i]]+1);
        }
    }
    if(h[u] == K-1 && p > 0){
        h[u] = -1;
        ans++;
        return;
    }
}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> K;
    ans = 0;
    rep(i,n){
        int a;
        cin >> a;
        if(i == 0){
            if(a != 1){
                ans++;
            }
        }else{
            G[a-1].pb(i);
        }
    }
    dfs(0,-1);
    // rep(i,n){
    //     svec(G[i]);
    // }
    // rep(i,n){
    //     cout << i << " " << h[i] << endl;
    // }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13952
///  author:Kissheart  ///
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
#define gcd(a,b) __gcd(a,b)
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll qpow(ll a,ll b){ll r=1,t=a; while(b){if(b&1)r=(r*t)%mod;b>>=1;t=(t*t)%mod;}return r;}
inline ll inv1(ll b){return qpow(b,mod-2);}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll r=exgcd(b,a%b,y,x);y-=(a/b)*x;return r;}
inline ll read(){ll x=0,f=1;char c=getchar();for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;for(;isdigit(c);c=getchar()) x=x*10+c-'0';return x*f;}
//freopen( "in.txt" , "r" , stdin );
//freopen( "data.txt" , "w" , stdout );
ll n,m,l;
ll flag=0;
char temp[MAX];
ll s[MAX],t[MAX];
map<ll,ll>a;
int main()
{
    a.clear();
    scanf("%d%d",&n,&m);

    scanf("%s",temp);
    for(int i=0;i<n;i++) s[i]=temp[i]-'a'+1;

    scanf("%s",temp);
    for(int i=0;i<m;i++) t[i]=temp[i]-'a'+1;

    l=lcm(n,m);


    for(int i=1;i<n;i++)
        a[l/n*i+1]=s[i];

    for(int i=1;i<m;i++)
    {
        if(a[l/m*i+1]==0) continue;

        if(a[l/m*i+1]!=t[i])
        {
            flag=1;
            break;
        }
    }
    if(s[0]!=t[0]) flag=1;

    if(flag) printf("-1\n");
    else printf("%lld\n",l);
    return 0;
}


Measured memory_bytes: 12032
#include <set>
#include <cstdio>
int i,n,v[9999];main(){for(;scanf("%d",&n),n;){std::set<int>t;for(i=0;i<n-1;)v[++i]=0,t.insert(i*i%n);for(auto s=t.begin(),S=s,T=t.end();s!=T;S=++s)for(;++S!=T;v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=0;i<n/2;)printf("%d\n",v[++i]);}}

Measured memory_bytes: 1300
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()

ave=sum(a)/n
min_v=10**9
for i in range(n-1,-1,-1):
  if abs(a[i]-ave)<=min_v:
    min_v=abs(a[i]-ave)
    ans=i

print(ans)

Measured memory_bytes: 9180
#include <iostream>
#include <complex>
#include <cmath>
#include <vector>
using namespace std;
typedef complex<double> C;
int n;
C s[100], e[100];

#define EPS (1e-10)
#define EQ(a,b) (abs(a-b) < EPS)
#define EQV(a,b) (EQ(a.real(), b.real()) && EQ(a.imag(), b.imag()))

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

C intersection(C a1, C a2, C b1, C b2) {
  C b = b2 - b1;
  
  double d1 = abs(cross(b, a1 - b1));
  double d2 = abs(cross(b, a2 - b1));
  double t = d1 / (d1 + d2);
  return a1 + (a2 - a1) * t;
}

void solve() {
  for(int i=0;i<n;i++)
    cin>>s[i].real()>>s[i].imag()>>e[i].real()>>e[i].imag();
  
  int res = 1;
  for (int i = 0; i < n; i += 1) {
    int count = 0;
    vector<C> iss;
    for (int j = 0; j < i; j += 1) {
      C iv = e[i] - s[i], jv = e[j] - s[j];
      // ツ陳シツ静シツつェツ古ーツ債キツつオツづつ「ツづゥツつゥ
      if (abs(cross(iv, jv)) < EPS) continue;
      // ツ陳シツ静シツづ個古ーツ点
      //C is = intersection(s[i], e[i], s[j], e[j]);
      C is = s[i] + iv * cross(jv, s[j]-s[i]) / cross(jv, iv);
      // ツ古ーツ点ツつェツ氾債暗債外
      if (abs(is.real()) > 100.0 - EPS) continue;
      if (abs(is.imag()) > 100.0 - EPS) continue;
      // ツ古ーツ点ツつェツ堕カツ催敖つキツづゥツつゥ
      bool flag = false;
      for (int z = 0; z < iss.size(); z += 1) {
        if (EQV(iss[z], is)) {
          flag = true; break;
        }
      }
      if (flag) continue;
      
      iss.push_back(is);
      count++;
    }
    res += count + 1;
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  int M=0, m=0;
  for (int i=0; i<(int)S.size(); i++) {
    m=0;
    for (int j=0; j<(int)S.size()-i; j++) {
      if (S[i+j]=='A' || S[i+j]=='T' || S[i+j]=='G' || S[i+j]=='C') {
        m++;
      }
      else {
        break;
      }
    }
    M=max(M, m);
  }
  cout << M << endl;
}



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

long long pow_mod(long long base,long long exp,long long mod){
    long long res = 1;
    while(exp>0){
        if(exp & 1)res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

const int64_t mood = 1000000007;     
int main()
{
    int64_t n;
    std::cin>>n;
    std::vector<long long> a(n);
    std::vector<std::pair<int64_t,int64_t>> eo(61); //first 1 second 0
    for(int64_t i=0;i<61;i++)eo[i] = {0,0};
    for(int64_t i=0;i<n;i++){
        std::cin>>a[i];
        for(long long j=0;j<60;j++){
            if(a[i] & ((long long)1<<j))eo[j].first++;
            else eo[j].second++;
        }
    }
    long long ans = 0;
    for(int64_t i=0;i<61;i++){
        //std::cout<<eo[i].first<<" : "<<eo[i].second<<std::endl;;
        int64_t tmp = (eo[i].first * eo[i].second) % mood;
        long long kake = pow_mod(2,i,mood);
        ans += tmp*kake;
        ans %= mood;
    }
    std::cout<<ans<<std::endl;
}


Measured memory_bytes: 2560
import java.util.Scanner

fun main(args: Array<String>) {
    val (a, b) = Scanner(System.`in`).use<Scanner, Pair<Int, Int>> {
        val a0 = it.nextInt()
        val b0 = it.nextInt()
        // 1≦A≦13
        // 1≦B≦13
        val a = if (a0 != 1) a0 else a0 + 13
        val b = if (b0 != 1) b0 else b0 + 13
        a to b
    }
    val result = when {
        a > b -> "Alice"
        a < b -> "Bob"
        else -> "Draw"
    }
    print(result)
}

Measured memory_bytes: 17080
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................


   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  //aint n=int_v(read());
	        		  int[] hm=int_arr();
	        		  int[] hi=int_arr();
	        		  Set<Integer>[] l=new HashSet[hm[0]+1];
	        		  for(int i=0;i<=hm[0];i++){l[i]=new HashSet<>();}
	        		  for(int i=1;i<=hm[1];i++){
	        		  	int[] x=int_arr();
	        		  	l[x[0]].add(x[1]);
	        		  	l[x[1]].add(x[0]);
	        		  }
	        		  int res=0;
	        		  for(int i=1;i<=hm[0];i++){
	        		  	int tmp=0;
	        		  	 for(int j:l[i]){
	        		  	 	tmp=Math.max(tmp,hi[j-1]);
	        		  	 }
	        		  	 if(hi[i-1]>tmp){res++;}
	        		  }
	        		  out.write(res+"");
	        	
	        		// if(n[0]>0){out.write("Yes");}
	        		 //else{out.write("No");}
                      out.flush();
	        		 
	}
}
	       
	          



	
  





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

using namespace std;

int main() {
    int n;
    cin >> n;
    string s = to_string(n);
    int sum = 0;
    for (char i : s) {
        sum += (int) (i - '0');
    }
    auto ans = "No";
    if (n % sum == 0) ans = "Yes";
    cout << ans << endl;
    return 0;
}


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

int main() {

	int N, K;
	cin >> N >> K;
	vector<int> P(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}

	sort(P.begin(), P.end());

	int ans = 0;
	for (int i = 0; i < K; i++) {
		ans += P[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<algorithm>
#include<cstdlib>

using namespace std;

const int N_MAX = 50001, INF = 100000;

int dp[N_MAX], n, m, i, j, d[20];

int main(){

  scanf("%d%d", &n, &m);
  for(i=0;i<m;i++){
    scanf("%d", &d[i]);
  }
  
  fill(dp, dp+n+1, INF);
  dp[0] = 0;
  for(i=0;i<=n;i++){
    for(j=0;j<m;j++){
      if(d[j] <= i){
	dp[i] = min(dp[i-d[j]] + 1, dp[i]);
      }
    }
  }
  
  printf("%d\n", dp[n]);
  
  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  ll x;
  cin >> x;
  vector<Pl> v;
  set<ll> st;
  rep(i,2010){
    ll l = i;
    rep(j,4)l *= i;
    st.insert(l);
    st.insert(-l);
    v.push_back(make_pair(l,i));
    v.push_back(make_pair(-l,-i));
  }
  for(auto au : v){
    if(st.find(x+au.first) != st.end()){
      ll k = 0;
      rep(i,2010)if(i*i*i*i*i == x+au.first){
        k = i;
        break;
      }
      cout << k << " " << au.second << endl;
      return 0;
    }
  }
  
  


  

  return 0;
}

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

int main() {
  int64_t n, a, b;
  cin >> n >> a >> b;
  if (n % (a + b) > a) cout << (n / (a + b)) * a + a << endl;
  else cout << (n / (a + b)) * a + n % (a + b) << endl;
}

Measured memory_bytes: 3584
#[macro_use]
mod reader {
    use std;
    macro_rules! read_line((  ) => {
                           {
                           let mut input = String :: new (  ) ; std :: io ::
                           stdin (  ) . read_line ( & mut input ) . unwrap (
                           ) ; input } } ;);
    pub fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
        read_line!().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
    }
}
#[macro_use]
mod misc {
    use std;
    #[macro_export]
    macro_rules! bind_from_vec((
                               $ ( $ variable : ident ) , + = $ vector : expr
                               ) => {
                               let mut v = $ vector . clone (  ) . into_iter (
                                ) ; $ (
                               let $ variable = v . next (  ) . unwrap (  ) ;
                               ) + } ;);
    pub trait ExVec<T> {
        fn sort_rev(&mut self);
    }
    impl <T: Ord> ExVec<T> for Vec<T> {
        fn sort_rev(&mut self) { self.sort_by(|x, y| y.cmp(x)); }
    }
}
use reader::*;
use misc::*;
use std::collections::HashSet;
use std::collections::BinaryHeap;
#[derive(PartialEq, PartialOrd, Eq, Ord, Debug)]
struct Tuple {
    priority: u64,
    index: (usize, usize, usize),
}
fn gen_tuple(ref_vecs: (&Vec<u64>, &Vec<u64>, &Vec<u64>),
             index: (usize, usize, usize)) -> Tuple {
    Tuple{priority:
              ref_vecs.0[index.0] + ref_vecs.1[index.1] + ref_vecs.2[index.2],
          index: index,}
}
fn main() {
    bind_from_vec!(alen , blen , clen , k = read_to_vec :: < usize > (  ));
    let mut a: Vec<u64> = read_to_vec();
    let mut b: Vec<u64> = read_to_vec();
    let mut c: Vec<u64> = read_to_vec();
    a.sort_rev();
    b.sort_rev();
    c.sort_rev();
    let mut appended = HashSet::new();
    let mut q = BinaryHeap::new();
    let ref_vecs = (&a, &b, &c);
    q.push(gen_tuple(ref_vecs, (0, 0, 0)));
    appended.insert((0, 0, 0));
    for _ in 0..k {
        if let Some(top) = q.pop() {
            println!("{}" , top . priority);
            let a_next =
                (std::cmp::min(top.index.0 + 1, alen - 1), top.index.1,
                 top.index.2);
            let b_next =
                (top.index.0, std::cmp::min(top.index.1 + 1, blen - 1),
                 top.index.2);
            let c_next =
                (top.index.0, top.index.1,
                 std::cmp::min(top.index.2 + 1, clen - 1));
            if appended.insert(a_next) {
                q.push(gen_tuple(ref_vecs, a_next));
            }
            if appended.insert(b_next) {
                q.push(gen_tuple(ref_vecs, b_next));
            }
            if appended.insert(c_next) {
                q.push(gen_tuple(ref_vecs, c_next));
            }
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <cstdio>
#include <iomanip>

using namespace std;

int main(){
	
	while(1){
		int n;
		cin >> n;
		
		if(n == 0) break;
		
		int score[n];
		double s_total = 0;
		
		for(int i = 0;i < n; i++){
			cin >> score[i];
			s_total += score[i]; 
		}
		double s_ave = s_total / n; 
		
		double sum = 0;
		for(int i = 0;i < n; i++){
			sum += (score[i] - s_ave) * (score[i] - s_ave);
		}
		double ans = sqrt(sum / n);
		
		cout << fixed << setprecision(5) << ans << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
using namespace std;
typedef long long ll;
ll n, s, b[15]={1,1};
string a;
int main() {
	ll i, j, k;
	cin>>a;
	n = a.size();
	for(i=2; i<n; i++) b[i] = b[i-1] * 2;
	for(i=0; i<n; i++) {
		for(j=i, k=0; j<n; j++) k = k*10 + b[j];
		s += k * (a[i]-'0');
		b[i+1] += b[i];
	}
	cout<<s;
	return 0;
}

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

int main()
{
    int N;
    scanf("%d", &N);
    int p[N+1];
    for(int i = 1; i <= N; ++i) scanf("%d", &p[i]);

    bool flg[N+1];
    fill(flg, flg + N + 1, false);
    for(int i = 1; i <= N; ++i) if(p[i] == i) flg[i] = true;
    int cnt = 0;
    for(int i = 1; i <= N; ++i) {
        if(flg[i]) {
            int j = i-1, k = i+1;
            if(0 < j && flg[j]) { flg[j] = flg[i] = false; ++cnt; }
            else if(k <= N && flg[k]) { flg[i] = flg[k] = false; ++cnt; }
            else { flg[i] = false; ++cnt; }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}

int main(){
	int k,sum=0;
	cin>>k;
	for(int a=1;a<=k;++a){
		for(int b=1;b<=k;++b){
			for(int c=1;c<=k;++c){
				sum+=__gcd(__gcd(a,b),c);
			}
		}
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
long long Q,H,S,D,N,Ans;
int main(){
	scanf("%lld%lld%lld%lld",&Q,&H,&S,&D);
	if (2*Q<H) H = 2*Q;
	if (2*H<S) S = 2*H;
	if (2*S<D) D = 2*S;
	scanf("%lld",&N);
	N = N * 4; 
	Ans = 0;
	Ans = Ans + N / 8 * D;
	N = N % 8;
	Ans = Ans + N / 4 * S;
	N = N % 4;
	Ans = Ans + N / 2 * H;
	N = N % 2;
	Ans = Ans + N / 1 * Q;
	printf("%lld\n",Ans);
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long K, std::vector<long long> A) {
    for (ll i = K; i < N; i++) {
        if (A[i - K] < A[i]) {
            cout << YES << endl;
        } else {
            cout << NO << endl;
        }
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 4844
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int a;
  cin >> a;
  int ans = a + a*a + a*a*a;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3616
#include <iostream> 
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <fstream>
using namespace std;
#define ll long long int


int main( ) {
  int a,b;
  cin >> a >>b;
  int M = max(a,b);
  if( a == b ) {
    cout << 2 * M << endl;  
  }
  else {
    cout << 2 * M - 1 << endl;  
  }
  return 0;
}


Measured memory_bytes: 888
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

ll n;
ll a[100010];

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

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

	ll ans = a[0];
	for (int i = 1; i < n; i++) {
		ans = min(ans, gcd(ans, a[i]));
	}

	printf("%lld\n", ans);
	
	return 0;
}

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

int n,m,sum,r;
int P[110],a[10010],b[10010],cost[10010];
pair<int,int> bridge[10010];
void init(int N) {
	for(int i=0; i<N; ++i) P[i] = i;
}
int root(int a) {
	if(P[a] == a) return a;
	return (P[a] = root(P[a]));
}
void unite(int a,int b) {
	P[root(a)] = root(b);
}

int main() {
	cin >> n >> m;
	while(n!=0 && m!=0) {
		for(int i=0; i<m; ++i) {
			cin >> a[i] >> b[i] >> cost[i];
			bridge[i].first = cost[i];
			bridge[i].second = i;
		}
		sort(bridge,bridge+m);
		init(n);
		for(int i=0; i<m; ++i) {
			int br2 = bridge[i].second;
			if(P[root(b[br2])] != P[root(a[br2])]) {
				unite(a[br2],b[br2]);
				sum += bridge[i].first;
			}
		}
		cout << sum << endl;
		cin >> n >> m;
		sum =0;
	}
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int t[110], v[110], acc[110];
int b[50000];

int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> t[i], t[i] *= 2;
    rep(i, n) cin >> v[i], v[i] *= 2;
    rep(i, n) acc[i+1] = acc[i] + t[i];

    int m = acc[n] + 1;

    rep(i, m) b[i] = min(i, acc[n] - i);

    rep(i, n){
        for(int j = 0; j < acc[i]; j++) b[j] = min(b[j], v[i] + acc[i] - j);
        for(int j = acc[i]; j < acc[i+1]; j++) b[j] = min(b[j], v[i]);
        for(int j = acc[i+1]; j < m; j++) b[j] = min(b[j], v[i] - acc[i+1] + j);
    }
    double ans = 0;
    rep(i, m) ans += b[i] + b[i+1];
    cout << fixed << setprecision(10) << ans/8.0 << endl;

    return 0;
}


Measured memory_bytes: 3836
#include<stdio.h>
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{int a[1000]={0},sum=0,m;
	for(int i=0;i<n;i++)
	{   scanf("%d",&m);
	sum+=m;
	}
	printf("%d\n",sum-n);
	}
	
}

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

int main() {
  int k;
  string s;
  cin >>k >>s;
  if (s.size() > k) {
    cout << s.substr(0, k) << "..." << endl;
  }
  else {
    cout << s << endl;
  }
  return 0;
}


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

int main() {
  string S; cin>>S;
  int res=0, tmp=0;
  int n=S.size();
  char X[4]={'A','C','G','T'};
  rep(i, n) {
    bool frag=false;
    rep(j, 4) {
      if (S[i]==X[j]) frag=true;
    }
    if (frag) {
      tmp++;
      res=max(res, tmp);
    }
    else {
      res=max(res, tmp);
      tmp=0;
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
#if 0
2019.08.08

先枚举位数，考虑每一位的贡献，不难发现每一位与对称位的差值对 D 有 9..90..0 的贡献。
而这个值大到比它更低的所有对称位的最大贡献的和要高。
那么这个差值只可能是两个值，乘上贡献分别小于/大于当前的 D 。
枚举这两种值即可，总复杂度 O(2L * 2^L) 。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long lolong;
inline int input() { int x; scanf("%d", &x); return x; }

lolong dfs(lolong a, lolong b, lolong d) {
	if(not a) return d == 0 ? 10 : 0;
	if(d < 0) d = - d;
	lolong c = a * b;
	int x = d / c;
	int max = b == 1 ? 9 : 10;
	if(a == 9)
		return x * c == d ? std::max(max - x, 0) : 0;
	lolong res = std::max(max - x, 0) * dfs(a / 100, b * 10, d - x * c);
	x ++;
	res += std::max(max - x, 0) * dfs(a / 100, b * 10, d - x * c);
	debug("%lld, %lld, %lld: %lld\n", a, b, d, res);
	return res;
}

int main() {
	lolong ans = 0, d = input();
	for(lolong a = 999999999999999999; a; a /= 10)
		ans += dfs(a, 1, d);
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define var auto
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {

  int n;
  cin >> n;
  int x[n];
  rep(i,0,n) cin >> x[i];

  // 100通り試せばOK

  ll res = INF;
  rep(i,1,100) {
    // (Z - x[i])^2 の総和
    ll sum = 0;
    rep(j,0,n) {
      sum += pow(i - x[j], 2.0);
    }
    chmin(res, sum);
  }

  cout << res << endl;

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<char> s(n);
    for(int i = 0; i < n; i++) cin >> s[i];

    vector<bool> isexist(4, false);
    for(int i = 0; i < n; i++){
        if(s[i] == 'P') isexist[0] = true;
        else if(s[i] == 'W') isexist[1] = true;
        else if(s[i] == 'G') isexist[2] = true;
        else isexist[3] = true;
    }
    int ans = 0;
    for(int i = 0; i < 4; i++){
        if(isexist[i]) ans++;
    }
    if(ans == 3) cout << "Three" << endl;
    else cout << "Four" << endl;
    return 0;
}

Measured memory_bytes: 3528
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val a_n = readLine()!!.split(" ").map(String::toInt)
    val total = a_n.fold(0) {i, e -> i + e}

    if(a_n.filter {if(total % (4 * M) == 0) {it < total / (4 * M)} else {it <= total / (4 * M)} }.size > (N-M)) {"No"} else {"Yes"}.run(::println)
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define INF 2147483647/2

int main()
{
    while(1)
    {
	int n,m,a,b,cost,time;
	int table[2][100][100];
	rep(i,2)rep(j,100)rep(k,100){
	    if (j==k)
		table[i][j][k]=0;
	    else
		table[i][j][k]=INF;
	}
	cin >> n >> m;
	if (n==0)break;
	rep(i,n)
	{
	    cin >> a >> b >> cost >> time;
	    a--;b--;
	    table[0][a][b]=cost;
	    table[0][b][a]=cost;
	    table[1][a][b]=time;
	    table[1][b][a]=time;
	}
	rep(i,2)rep(j,m)rep(k,m)rep(l,m)table[i][k][l] = min(table[i][k][l],table[i][k][j]+table[i][j][l]);
	cin >> n;
	int p,q,r;
	rep(i,n)
	{
	    cin >> p >> q >> r;
	    cout << table[r][p-1][q-1] << endl;
	}
    }
    return 0;
}

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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
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(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};

typedef vector<vector<Edge>> AdjList;
AdjList graph;
int a[200010], b[200010];

int bits[29];
int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    int N; cin >> N;

    int res = 0;
    REP(i, N) cin >> a[i];
    REP(i, N) cin >> b[i];
    
    for(int k = 29; k>=0; --k){
        int ub = 1<<(k+1), lb = 1<<k;
        
        for(int i=0; i<N; ++i) a[i]%=ub, b[i] %=ub;
        sort(b, b+N);
        
        ll num = 0;
        REP(i, N){
            int add = 0;
            if(lb-a[i]>=0){
                add += lower_bound(b, b+N, ub-a[i]) - lower_bound(b, b+N, lb-a[i]);
            }else{
                add += lower_bound(b, b+N, ub-a[i]) - b;
                add += lower_bound(b, b+N, ub) - lower_bound(b, b+N, ub+lb-a[i]);
            }
            num += add;
        }

        if(num & 1) res += lb;
    }
    cout << res << endl;
    
    return 0;

}

Measured memory_bytes: 1792
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


int main() {
	long long n;
	cin >> n;
	for (long long i = 1; i <= 3500; i++) {
		for (long long j = 1; j <= 3500; j++) {
			long long k = 4 * i * j - n * j - n * i;
			long long l = i * j * n;
			if (k > 0 && l % k == 0) {
				cout << i << " " << j << " " << l / k << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;


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

	PQ Q;
	REP(i, 3) {
		int a; cin >> a;
		Q.push(a);

	}
	int K; cin >> K;
	REP(i, K) {
		int a = Q.top();
		a*= 2;
		Q.pop();
		Q.push(a);
	}
	int sum = 0;
	REP(i, 3) {
		sum += Q.top();
		Q.pop();
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
//Author:buckwheat

//time:2019/4/2
//source： https://onlinejudge.u-aizu.ac.jp/problems/DPL_3_A


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
//getline
//sstream
//stringstream     istringstream
//next_permutation


const int maxn=1410;
int c[maxn][maxn],a[maxn][maxn];


int main() {
    int H,W;
    int ans=0;
    scanf("%d%d",&H,&W);
    for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++){
            scanf("%d",&c[i][j]);
            if(c[i][j])  a[i][j]=0;
            else a[i][j]=1;

        }
    for(int i=0;i<=H;i++)
        a[i][0]=0;
    for(int i=0;i<=W;i++)
        a[0][i]=0;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(c[i][j]==0)
                a[i][j]=min(min(a[i][j-1],a[i-1][j]),a[i-1][j-1])+1;
            ans=max(ans,a[i][j]);
        }
    }
    cout<<ans*ans<<endl;
    return 0;
}




Measured memory_bytes: 18600
#include <iostream>
#include <vector>
#include <algorithm>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::vector<long> vec;
	int n, q, b, e, k;
	long result;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif
	vec.resize(n, 0);

	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> vec[i];
#else
		std::cin >> vec[i];
#endif
	}

#if INPUT_FROM_FILE
	ifs >> q;
#else
	std::cin >> q;
#endif

	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		ifs >> b >> e >> k;
#else
		std::cin >>  b >> e >> k;
#endif
		result = std::count(vec.begin() + b, vec.begin() + e, k);
		std::cout << result << std::endl;
	}

	return 0;
}



Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<set>
#define P pair<int, int>
#define MAX_N 100050

using namespace std;

class Unionfind{
    private:
    int par[MAX_N];
    int rank[MAX_N];
    set<int> size;
    public:
    Unionfind() {
        for(int i=0;i < MAX_N;i++){
            par[i] = i;
            rank[i] = 0;
        }
    };

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

    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    };

    bool same(int x,int y){
        return find(x) == find(y);
    };

    int group(int n){
        for(int i=1;i <= n;i++){
            size.insert(find(i));
        }
        return size.size();
    }

    int Size(int x){
        return rank[find(x)];
    }
};

int main(){
    int n,m,ans=0;
    cin >> n >> m;
    vector<P> edge(m);
    for(int i=0;i < m;i++){
        cin >> edge[i].first >> edge[i].second;
    }

    for(int i=0;i < m;i++){
        Unionfind u;

        for(int j=0;j < m;j++){
            if(i == j) continue;
            if(edge[j].first != edge[j].second){
                u.unite(edge[j].first,edge[j].second);
            }
        }
        if(u.group(n) > 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4388
#include<stdio.h>
int main()
{
    int n,k,x,y,tot;
    scanf("%d %d %d %d", &n, &k, &x, &y);
    if(n>k)
    {
        tot = ((k*x) + (n-k)*y);
        printf("%d\n", tot);
    }
    else
    {
        tot = n * x;
        printf("%d\n", tot);
    }
    return 0;
}

Measured memory_bytes: 128
// LNU_Algotesters
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <fstream>
#include <complex>

using namespace std;

#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 ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MAX = 200 * 1000 + 47;

int A[MAX];
int U[MAX];
int cur;
void sett(int idx, int val)
{
    if (U[val])throw 1;
    A[idx] = val;
    U[val] = 1;
}

int get()
{
    while(U[cur])cur++;
    return cur;
}

int main()
{
    cur = 1;
    int n, x;
    cin >> n >> x;
    if (x == 1 || x == n + n - 1)
    {
        cout << "No" <<  endl;
        return 0;
    }
    if (n == 2)
    {
        cout << "Yes\n1\n2\n3\n" << endl;
        return 0;
    }
    int s = (x == n + n - 2) ? -1 : 1;
    sett(n-3, x + 2 * s);
    sett(n-2, x - s);
    sett(n-1, x);
    sett(n, x + s);
    FOR(i, 0, n + n - 1)
        if (A[i] == 0)
            sett(i, get());
    cout << "Yes" << endl;
    FOR(i, 0, n + n - 1)
        cout << A[i] << endl;
}



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



int main(){
	int a;
	vector<int> v;
	for(int i=0;i<3;i++){
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	cout << v[2]*10+v[1]+v[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
    
int main(){
    u_int n;    // the number of vegetable
    u_int m;    // capacity
       
    while(std::cin >> n >> m){
        if(n == 0 && m == 0){
            break;
        }
            
        std::vector<u_int> p(n);  // price
        for(int i = 0; i < n; ++i){
            std::cin >> p[i];
        }
           
        //m, 2*m, 3*m, ... = free(sort by descending)
        std::sort(p.begin(), p.end(), std::greater<u_int>());
        for(int i = m; i <= n; i += m){
            p[i-1] = 0;
        }
           
        std::cout << std::accumulate(p.begin(), p.end(), 0) << std::endl;
    }
        
    return 0;
}


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

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> p(n);
	for(auto &i:p)cin >> i;
	for(auto &i:p)i--;
	vector<ll> c(n);
	for(auto &i:c)cin >> i;

	vector<vector<int>> st(n);//iから始めた時の順列
	for(int i = 0;i<n;i++)
	{
		int now = i;
		for(int j = 0;j<n;j++)
		{
			now = p[now];
			st[i].push_back(c[now]);
			if(now==i)break;
		}
	}
	ll ans = INT_MIN;

	for(int i = 0;i<n;i++)
	{
		ll nowsum = 0;
		ll turnsum = 0;
		for(int j=0;j<st[i].size();j++)turnsum+=st[i][j];

		for(int j = 0;j<st[i].size();j++)
		{
			nowsum+=st[i][j];
			ll nowk = k-j-1;
			ll nowt = nowk/(ll)st[i].size();
			ll nowans = 0;
			if(turnsum>0)nowans += nowt*turnsum;
			if(nowk<0)continue;
			//cout<<i<<' ' <<j<<';'<<nowsum+nowans<<endl;
			ans = max(ans,nowsum+nowans);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 120972
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
using namespace std;
int main(){
    long long n, x = 0, y = 0, m = 0;
    cin >> n;
    REP (i, n) {
        long long t, a;
        cin >> t >> a;
        if (t >= x && a >= y) {
            x = t; y = a;
        } else {
            m = max(x / t, y / a);
            while (!(x <= m * t && y <= m * a)) m++;
            x = m * t; y = m * a;
        }
    }
    cout << x + y << endl;
    return 0;
}

Measured memory_bytes: 256
X = int(input())
if X >=400 and X <= 599:
  print("8")
elif X >=600 and X <= 799:
  print("7")
elif X >=800 and X <= 999:
  print("6")
elif X >=1000 and X <= 1199:
  print("5")
elif X >=1200 and X <= 1399:
  print("4")
elif X >=1400 and X <= 1599:
  print("3")
elif X >=1600 and X <= 1799:
  print("2")
else:
  print("1")

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
const int INF = 100;

template< typename flow_t, typename cost_t >
struct PrimalDual {
  const cost_t INF;

  struct edge {
    int to;
    flow_t cap;
    cost_t cost;
    int rev;
    bool isrev;
  };
  vector< vector< edge > > graph;
  vector< cost_t > potential, min_cost;
  vector< int > prevv, preve;

  PrimalDual(int V) : graph(V), INF(numeric_limits< cost_t >::max()) {}

  void add_edge(int from, int to, flow_t cap, cost_t cost) {
    graph[from].emplace_back((edge) {to, cap, cost, (int) graph[to].size(), false});
    graph[to].emplace_back((edge) {from, 0, -cost, (int) graph[from].size() - 1, true});
  }

  cost_t min_cost_flow(int s, int t, flow_t f) {
    int V = (int) graph.size();
    cost_t ret = 0;
    using Pi = pair< cost_t, int >;
    priority_queue< Pi, vector< Pi >, greater< Pi > > que;
    potential.assign(V, 0);
    preve.assign(V, -1);
    prevv.assign(V, -1);

    while(f > 0) {
      min_cost.assign(V, INF);
      que.emplace(0, s);
      min_cost[s] = 0;
      while(!que.empty()) {
        Pi p = que.top();
        que.pop();
        if(min_cost[p.second] < p.first) continue;
        for(int i = 0; i < graph[p.second].size(); i++) {
          edge &e = graph[p.second][i];
          cost_t nextCost = min_cost[p.second] + e.cost + potential[p.second] - potential[e.to];
          if(e.cap > 0 && min_cost[e.to] > nextCost) {
            min_cost[e.to] = nextCost;
            prevv[e.to] = p.second, preve[e.to] = i;
            que.emplace(min_cost[e.to], e.to);
          }
        }
      }
      if(min_cost[t] == INF) return -1;
      for(int v = 0; v < V; v++) potential[v] += min_cost[v];
      flow_t addflow = f;
      for(int v = t; v != s; v = prevv[v]) {
        addflow = min(addflow, graph[prevv[v]][preve[v]].cap);
      }
      f -= addflow;
      ret += addflow * potential[t];
      for(int v = t; v != s; v = prevv[v]) {
        edge &e = graph[prevv[v]][preve[v]];
        e.cap -= addflow;
        graph[v][e.rev].cap += addflow;
      }
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      for(auto &e : graph[i]) {
        if(e.isrev) continue;
        auto &rev_e = graph[e.to][e.rev];
        cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << rev_e.cap + e.cap << ")" << endl;
      }
    }
  }
};


int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(auto& i : s) cin >> i;
    PrimalDual<int, int> g(h * w + 2);
    const int S = h * w, T = S + 1;
    int cnt = 0;
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++){
        const int at = i * w + j;
        if(s[i][j] == 'o'){
            g.add_edge(S, at, 1, 0);
            cnt++;
        }
        if(s[i][j] != '#'){
            g.add_edge(at, T, 1, 0);
            if(i + 1 < h && s[i + 1][j] != '#') g.add_edge(at, at + w, INF, -1);
            if(j + 1 < w && s[i][j + 1] != '#') g.add_edge(at, at + 1, INF, -1);
        }
    }
    cout << -g.min_cost_flow(S, T, cnt) << endl;
}


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

int main(){
    int N,K,height[100000],min;
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> height[i];
    }
    sort(height,height+N);
    min = height[K-1] - height[0];
    for(int i=1;i<N-K+1;i++){
        if(min > height[K+i-1] - height[i]) min = height[K+i-1] - height[i];
    }
    cout << min;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
p = list(map(int, input().split()))

MAX = 0
# dp[i] i 番目から i + K - 1 番目までのサイコロの期待値の和
dp = [0] * N
for i in range(N - K + 1):
    if i < 1:
        dp[i] = 0.5 * (sum(p[:K]) + K)
    else:
        dp[i] = dp[i - 1] - 0.5 * p[i - 1] + 0.5 * p[i + K - 1]

    MAX = max(MAX, dp[i])
print(MAX)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k, s;
  cin >> n >> k >> s;
  int i;
  if(s != pow(10, 9)){
      for(i = 0; i < k; i++){
        cout << s << " ";
      }
      for(i = k; i < n; i++){
          cout << 1000000000 << " ";
      }
  }else{
      for(i = 0; i < k; i++){
        cout << 1000000000 << " ";
      }
      for(i = k; i < n; i++){
        cout << 1 << " ";
      }   
  }
  cout << endl;
}

Measured memory_bytes: 1280