akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 4010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int h[MAXN];
vector<int> G[MAXN];

void dfs(int node, int par){
	for (int v:G[node]) if (v!=par){
		h[v]=h[node]+1;
		dfs(v, node);
	}
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>k;
	for (int i=1; i<n; i++){
		cin>>u>>v;
		G[u].pb(n+i);
		G[v].pb(n+i);
		G[n+i]={u, v};
	}
	ans=n;
	for (int i=1; i<2*n; i++){
		h[i]=0;
		dfs(i, 0);
		int cnt=0;
		for (int j=1; j<=n; j++) cnt+=(h[j]<=k);
		ans=min(ans, n-cnt);
	}
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;

int main(){

  int n,k,q;
  while(cin >> n >> k >> q){
    vector<int> a(q); cin >> a;

    vector<int> s(n, k-q);

    REP(i,q){
      s[a[i]-1] += 1;
    }

    REP(i,n){
      cout << (s[i] > 0 ? "Yes" : "No") << "\n";
    }
  }


  return 0;
}


Measured memory_bytes: 1408
a,b,x=parse.(split(readline()))

function main(a,b,x)
  menseki=x/a
  takasa=(menseki/b)*2
  if takasa>a
    menseki2=a*b-menseki
    takasa2=(menseki2/a)*2
    c=sqrt(takasa2^2+a^2)
    cosA=(c^2+a^2-takasa2^2)/(2*a*c)
    A=acosd(cosA)
    return 90-(90-A)
  else
    c=sqrt(takasa^2+b^2)
    cosA=(c^2+b^2-takasa^2)/(2*b*c)
    A=acosd(cosA)
    return 90-A
  end
end
  
ans=main(a,b,x)
print(ans)

Measured memory_bytes: 178904
#include<stdio.h>

int main(void)
{
  int a,b,ab,counter=1,temp,i;
  scanf("%d %d",&a,&b);
  temp = b;
  while(temp >= 10)
    {
      temp = temp / 10;
      counter++;
    }
  for(i=0;i<counter;i++)
    {
      a = a * 10;
    }
  ab = a + b;
  for(i=4;i<=316;i++)
    {
      if(ab == i*i)
	{
	  printf("Yes\n");
	  return 0;
	}
    }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    let mut p_cnt = s.iter().filter(|c| *c == &'p').count();

    println!("{}", s.len() / 2 - p_cnt);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define INF (10000000)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int dp[50][500][500];
int a[50], b[50], c[50];

int main(){
	int n, ma, mb; cin >> n >> ma >> mb;
	for( int i = 0; i < n; ++i ){
		cin >> a[i] >> b[i] >> c[i];
	}
	for( int r = 0; r < 50; ++r ){
		for( int p = 0; p < 500; ++p ){
			for( int q = 0; q < 500; ++q ){
				dp[r][p][q] = INF;
			}
		}
	}
	dp[0][0][0] = 0;
	for( int r = 0; r < n; ++r ){
		for( int p = 0; p <= 400; ++p ){
			for( int q = 0; q <= 400; ++q ){
				if( p >= a[r] && q >= b[r] ){
					dp[r+1][p][q] = min( dp[r][p][q], dp[r][p-a[r]][q-b[r]]+c[r] );
				} else {
					dp[r+1][p][q] = dp[r][p][q];
				}
			}
		}
	}
	int ans = INF;
	for( int p = 1; p <= 400; ++p ){
		for( int q = 1; q <= 400; ++q ){
			if( p*mb == q*ma ){
				ans = min(ans, dp[n][p][q]);
			}
		}
	}
	if( ans == INF ) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 49660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, h, m, s;
int a[100000];

int main(){
	while (cin >> n&&n){
		fill(a, a + 100000, 0);
		REP(i, n){
			scanf("%d:%d:%d", &h, &m, &s);
			a[h * 3600 + m * 60 + s]++;
			scanf("%d:%d:%d", &h, &m, &s);
			a[h * 3600 + m * 60 + s]--;
		}
		FOR(i, 1, 100000){
			a[i] += a[i - 1];
		}
		int ans = 1;
		REP(i, 100000){
			ans = max(ans, a[i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1628
# ALDS1_4_C
import sys
M = 1046527


def h1(key):
    return key % M


def h2(key):
    return 1 + (key % (M - 1))


def h(key, i):
    return(h1(key) + i * h2(key)) % M


def getChar(gene):
    if gene == 'A':
        return 1
    elif gene == 'C':
        return 2
    elif gene == 'G':
        return 3
    else:
        return 4


def getkey(gene):
    sum = 0
    p = 1
    for i in gene:
        sum += p * getChar(i)
        p *= 5
    return sum


class HashDict:
    def __init__(self):
        self.key = [None] * (2 * 10 ** 6)

    def insert(self, key):
        i = 0
        while True:
            j = h(key, i)
            if self.key[j] is None:
                self.key[j] = key
                return
            else:
                i += 1

    def find(self, key):
        i = 0
        while True:
            j = h(key, i)
            # print('find j : {}'.format(j))
            if self.key[j] == key:
                return True
            elif self.key[j] is None or i > M:
                return None
            else:
                i += 1


n = int(input())
T = HashDict()

for i in range(n):
    command, key = sys.stdin.readline().strip().split()
    key = getkey(key)
    # print('i : {}  key : {}'.format(i, key))
    if command == 'insert':
        T.insert(key)
    elif command == 'find':
        if T.find(key):
            print('yes')
        else:
            print('no')





Measured memory_bytes: 39640
import java.io.BufferedReader;
import java.io.InputStreamReader;
   
public class Main{
    public static void main(String args[])throws java.lang.Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        //変数に配列を代入
        int s =Integer.parseInt(line);
        int h = s / 3600;
        int m = (s % 3600) / 60;
        s = s % 60;
        System.out.println(h+":"+m+":"+s);
         
    }
}

Measured memory_bytes: 24304
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  st s;
  cin >> s;
  st t="";
  rep(i,s.size()-8){
    t+=s[i];
  }
  cout << t << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll x;
    cin >> x;
    ll p1 = x/500;
    ll q1 = x%500;
    ll p2 = q1/5;
    cout << p1*1000+p2*5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e21 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl


/*--------------------template--------------------*/


int main() {
    vi v(3);
    REP(i, 3) cin >> v[i];
    sort(ALL(v));
    bool f = false;
    REP(i, 3) {
        if (v[i] % 2 == 0) {
            f = true;
        }
    }
    ans = INF;
    if (f) {
        cout << 0 << endl;
    } else {
        REP(i, 3) {
            ll a = v[i % 3] / 2;
            ll b = a + 1;
            ans = min(ans, abs(v[(i + 1) % 3] * v[(i + 2) % 3] * a - v[(i + 1) % 3] * v[(i + 2) % 3] * b));
        }
        cout << ans << endl;
    }

}

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

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

  int table[10][10];

  bool isFound = false;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == N) isFound = true;
    }
  }

  if (isFound) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int n;
string s,t,u="abc";

int main(){
	cin>>n>>s>>t;
	int tmp=-1;
	for(int i=0;i<min(t.size(),s.size());i++){
		if(s.substr(s.size()-i-1,s.size())==t.substr(0,i+1)) tmp=i;
	}
	if(n>=s.size()+t.size()) cout<<n<<endl;
	else{
		int ans=s.size()+t.size()-tmp-1;
		if(ans<n) cout<<n<<endl;
		else cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define fi first 
#define se second
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = 1e9+7 ;
// 998244353;

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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  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];
  }
  mint p(int n,int k){
    return fact[n]*ifact[n-k] ;
  }
}   c(100005);
 
mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

mint komb(ll n,ll m){
  mint x=1 ;mint y=1 ;
  rep(i,m){
    x*= n-i ;
    y*= i+1 ;
  }
  return x/y ;
}

 
 map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;  
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
   if(n!=1) ord[n]++;
   return ord ;
 }

int main(){
  ll n ;cin>>n ;
  string s ; cin>> s ;
  vector<ll> A(26) ;
  rep(i,n){
    int p =  s[i]- 'a' ;
    A[p]++ ;
  }
  mint ans=1 ;
  rep(i,26){
    ans*= (A[i]+1ll) ;
  }
   ans= ans-1ll ;
   cout<<ans<<endl ;
    return 0;
  }
   



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

typedef struct
{
  int x, y;
} Point;

int solve(vector<vector<int> >& board, int idx, const vector<Point>& rp)
{
  if (idx >= 8) {
    bool valid = true;
    for (int i = 0; i < 4 && valid; ++i) {
      for (int j = 0; j < 4 && valid; ++j) {
	if (board[i][j] == -1)
	  valid = false;
      }
    }
    if (valid)
      return 1;
    return 0;
  }

  int res = 0, x = 0, y = 0;
  for (y = 0; y < 4; ++y) {
    bool valid = false;
    for (x = 0; x < 4; ++x) {
      if (board[y][x] == -1) {
	valid = true;
	break;
      }
    }
    if (valid)
      break;
  }

  for (unsigned int i = 0; i < rp.size(); ++i) {
    int xx = x + rp[i].x;
    int yy = y + rp[i].y;
    if (xx < 0 || 4 <= xx || yy < 0 || 4 <= yy || board[yy][xx] != -1)
      continue;
    board[y][x] = board[yy][xx] = idx;
    res += solve(board, idx+1, rp);
    board[y][x] = board[yy][xx] = -1;
  }
  return res;
}

int main()
{
  vector<Point> rp(4);
  while (cin >> rp[0].x >> rp[0].y >> rp[1].x >> rp[1].y
	 >> rp[2].x >> rp[2].y >> rp[3].x >> rp[3].y) {
    if (rp[0].x >= 4)
      break;

    vector<vector<int> > board(4, vector<int>(4, -1));
    cout << solve(board, 0, rp) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test
{
    class ForStudy
    {
        public static void Main(string[] args)
        {
            Console.ReadLine();
            InsertionSort(Console.ReadLine().Split(' ').Select(int.Parse).ToArray());

        }

        public static void InsertionSort(int[] A)
        {
            Console.WriteLine(String.Join(" ", A));
            for (int i = 1; i < A.Length; i++)
            {
                int v = A[i];
                int j = i - 1;
                while (j >= 0 && A[j] > v)
                {
                    A[j + 1] = A[j];
                    j--;
                    A[j + 1] = v;
                    
                }
                Console.WriteLine(String.Join(" ", A));
            }

        }


    }
}


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

using namespace std;

int main() {
#ifdef  DEBUG
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
#endif  // for local.
  int a, b, ans;

  cin >> a >> b;
  ans = a - 2*b;
  if (ans < 0) ans = 0;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int A[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N) cin >> A[i];
    int sum = 0;
    rep(i, N) sum += A[i];
    int loss = N * (N + 1) / 2;
    if (sum % loss != 0) {
        cout << "NO" << endl;
        return 0;
    }
    int cnt = sum / loss;
    int sum2 = 0;
    rep(i, N) {
        int sa = A[(i + 1) % N] - A[i] - cnt;
        //cout << sa << endl;
        if (sa > 0 || -sa % N != 0) {
            cout << "NO" << endl;
            return 0;
        }
        sum2 += -sa / N;
    }
    if (sum2 == cnt) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }




    return 0;
}


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

int isprime(int n){
	int p,i,j=0;
	if(n-1){
		p=sqrt(n);
		for(i=1;i<p+1;i++){
			if(n%i==0){
				j++;
			}
		}
		if(j-1)
			return 0;
		else
			return 1;
	}
	else
		return 0;
}

int main ()
{
	int n,*a,num=0;
	cin>>n;
	a=new int [n];
	for(int i=0;i<n;i++)	cin>>*(a+i);
	for(int i=0;i<n;i++)
	{
		if(isprime(*(a+i)))
			num++;
	}
	cout<<num<<endl;
	delete []a;
//	system("pause");
	return 0;
}



Measured memory_bytes: 3108
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#include <iomanip>

using namespace std;

int main ()
{
    auto PI = 3.141592;
    int R;
    cin >> R;
    cout << setprecision(12) << 2 * R * PI;
}


Measured memory_bytes: 3788
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"


struct aa {
	int now;
	long long int time;
};

class Compare {
public:
	//aa?????????????????¶
	bool operator()(const aa&l, const aa&r) {
		return l.time> r.time;
	}
};
typedef long long int Weight;
struct Edge {
	int id;
	int src, dst;
	Weight weight;
	Edge(int id_,int src_, int dst_, Weight weight_) :
		id(id_),src(src_), dst(dst_), weight(weight_) { }
	Edge(int src_, int dst_) :
		src(src_), dst(dst_) {

	}
};
int main() {
	long long int N, M, C; cin >> N >> M >> C;
	vector<vector<Edge>>edges(N);
	long long int path_len = 0;
	for (int i = 0; i < M; ++i) {
		long long int a, b, d; cin >> a >> b >> d; a--; b--;
		edges[a].emplace_back(i,a,b, d);
		edges[b].emplace_back(i,b,a, d);
		path_len += d;
	}
	vector<long long int>diss(N,1e14);
	diss[0] = 0;
	priority_queue<aa, vector<aa>, Compare>que;
	que.push(aa{ 0,0 });
	while (!que.empty()) {
		aa atop = que.top();
		que.pop();
		const int anow = atop.now;
		const long long  int atime = atop.time;
		for (auto e : edges[anow]) {
			if (diss[e.dst] > atime + e.weight) {
				diss[e.dst] = atime + e.weight;
				que.push(aa{ e.dst,atime + e.weight });
			}
		}
	}
	map<long long int, vector<int>>mp;
	for (int i = 0; i < N; ++i) {
		mp[diss[i]].emplace_back(i);
	}

	long long int ans = 1e18;
	long long int under_num = 0;
	vector<int>path_life(M, 2);
	for (auto m : mp) {
		under_num += m.second.size();
		for (auto n : m.second) {
			for (auto e : edges[n]) {
				path_life[e.id]--;
				if (!path_life[e.id]) {
					path_len -= e.weight;
				}
			}
		}
		ans =min(ans, (C*m.first) + (path_len));
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        string s; cin>>s;
        int n=s.size();
        int ansA=0,ansB=0;
        rep(i,n)
        {
                if(i%2==1)
                {
                        if(s[i]=='1')ansA++;
                        else ansB++;
                }else
                {
                        if(s[i]=='1')ansB++;
                        else ansA++;
                }
        }
        cout<<min(ansA,ansB)<<endl;
}

Measured memory_bytes: 512
dic = {}
def rec(d, pre, acc):
    if d == 1:
        if 1 <= pre <= 8:
            return [acc+c for c in map(str, [pre-1, pre, pre+1])]
        elif pre == 9:
            return [acc+c for c in ["8", "9"]]
        else:
            return [acc+c for c in ["0", "1"]]
    ans = []
    for x in range(max(0,pre-1), min(pre+2, 10)):
        ans += rec(d-1, x, acc+str(x))
    return ans
K = int(input())
ls = [1,2,3,4,5,6,7,8,9]
d = 2
while len(ls) < K:
    for i in range(1,10):
        ls += rec(d-1, i, str(i))
    d+=1
print(ls[K-1])

Measured memory_bytes: 92912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;

ll n, k, a[N];
ll c0, cn, cp;

ll solvene()
{
	vector<ll> x(a, a + cn);
	vector<ll> y(a + n - cp, a + n);
	ll l = x[0] * y.back();
	ll r = x.back() * y[0];
	reverse(x.begin(), x.end());
	reverse(y.begin(), y.end());
	while (l <= r)
	{
		ll mid = l + (r - l) / 2;
		ll cnt = 0;
		for (ll i = 0, j = 0; i < x.size(); i++){
			for ( ; j < y.size() && x[i] * y[j] <= mid; j++);
			cnt += j;
		}
		if (cnt < k) l = mid + 1;
		else	r = mid - 1;
	}
	return l;
}

ll solvenp(ll k)
{
	vector<ll> x(a, a + cn);
	reverse(x.begin(), x.end());
	vector<ll> y(a + n - cp, a + n);
	ll l = LLONG_MAX;
	ll r = LLONG_MIN;
	if (x.size() >= 2)
	{
		l = min(l, x[0] * x[1]);
		r = max(r, x[cn - 1] * x[cn - 2]);
	}
	if (y.size() >= 2)
	{
		l = min(l, y[0] * y[1]);
		r = max(r, y[cp - 1] * y[cp - 2]);
	}
	while (l <= r)
	{
		ll mid = l + (r - l) / 2;
		ll cnt = 0;
		for (ll i = cp - 1, j = 0; i >= 0; i--){
			for (; j < i && y[i] * y[j] <= mid; j++);
			cnt += min(i, j);
		}
		for (ll i = cn - 1, j = 0; i >= 0; i--){
			for (; j < i && x[i] * x[j] <= mid; j++);
			cnt += min(i, j);
		}
		if (cnt < k) l = mid + 1;
		else	r = mid - 1;
	}
	return l;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] == 0)	c0++;
		else if (a[i] > 0)	cp++;
		else	cn++;
	}
	sort(a, a + n);
	ll ne = cn * cp;
	ll n0 = c0 * (c0 - 1) / 2 + c0 * (n - c0);
	ll np = cp * (cp - 1) / 2 + cn * (cn - 1) / 2;
	ll res;
	if (k <= ne) res = solvene();
	else if (k <= ne + n0)	res = 0;
	else	res = solvenp(k - ne - n0);
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 3200
// https://atcoder.jp/contests/abc120/tasks/abc120_c

package main

import "fmt"

func main() {
	var s []byte
	fmt.Scanf("%s", &s)

	count := 0
	for i := 0; i < len(s)-1; i++ {
		// fmt.Println(i, string(s))
		if s[i] != s[i+1] {
			count += 2
			s = append(s[0:i], s[i+2:]...)
			i -= 2
		}
		if i < -1 {
			i = -1
		}
		// fmt.Println(i, string(s))
	}
	fmt.Println(count)
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
#define sz(s) (ll)(s.size())
#define all(x) (x.begin(), x.end())
#define pb push_back
#define pf push_front
#define F first
#define S second
#define nl endl
#define ort1 exit(0);
#define db double
#define TL if(clock() / (double)CLOCKS_PER_SEC > 0.3) cout << "Time Limit exceed", ort1;
#define NFS ios_base :: sync_with_stdio(), cin.tie(), cout.tie();  

using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
 
 
const double pi = acos(-1.0);
const double eps = 1e-9;
const int mod = 1e9 + 7;
const ll INF = 1e12 + 1;
const int N = 1e5 + 9;

int a, b, c, d;

int main(){

	cin >> a >> b >> c >> d;
	if(abs(a - c) <= d) cout << "Yes";
	else if(abs(a - b) <= d && abs(b - c) <= d) cout << "Yes";
	else cout << "No";

	ort1
}

Measured memory_bytes: 256
from sys import stdin

a, b = stdin.readline().rstrip().split()
a, b = int(a), int(b)

for i in range(1, 21):
    if a * i > b:
        print(b - a)
        break

    if b % (a * i) == 0:
        print(a + b)
        break
else:
    print(b - a)

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int monster_h = sc.nextInt();
		int skill_n = sc.nextInt();

		List<Integer> skill_list = new ArrayList<>();

		for (int i = 0; i < skill_n; i++) {
			skill_list.add(sc.nextInt());
		}

		int total_skill = skill_list.stream().mapToInt(Integer::intValue).sum();
		String yesNo = (total_skill >= monster_h) ? "Yes" : "No";

		System.out.println(yesNo);
		sc.close();
	}
}


Measured memory_bytes: 60748
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
   lli A,B,C,L,R,N,M,K,X=0,Y=0,W,H=INF,sum=0,num=0,flag=0;string S,T,O;
   cin >> N;
   Vec(P,string,N,"");
   DV(Q,lli,N,26,0);
   rep(i,0,N)cin >> P[i];
   rep(i,0,N)rep(j,0,50){
      if(j>P[i].size()-1)break;
      Q[i][P[i][j]-97]++;
   }
   T="";
   rep(i,0,26){
      X=INF;
      rep(j,0,N)X=min(X,Q[j][i]);
      while(0<X){
         T+='a'+i;
         X--;
      }
   }
   Out(T);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 0
    return ans


def main():
    N = read_int()
    if N == 1:
        print('Hello World')
    else:
        A = read_int()
        B = read_int()

        print(A + B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7868
#include <bits/stdc++.h>
const long long INF = (1LL<<61);

signed main(void){
    
    long long N;
    std::cin >> N;
    std::vector<long long> A,K(N+1,0ll);
    for(int i=0;i<=N;i++){
        long long a;
        std::cin >> a;
        A.push_back(a);
    }
    
    //N=0の場合だけ分ける
    if(N==0){
        if(A[0]==1){
            std::cout << 1 << std::endl;
        }else{
            std::cout << -1 << std::endl;
        }
        return 0;
    }
    
    //存在しなければtrue
    bool invalid = false;
    
    if(A[0]!=0){
        invalid=true;
    }
    
    K[0]=1;
    for(int i=0;i<N;i++){
        if(K[i]-A[i]<0)invalid=true;
        K[i+1]=std::min(INF,2ll*(K[i]-A[i]));
    }
    if(K[N]-A[N]<0)invalid=true;
    
    K[N]=A[N];
    for(int i=N-1;i>=0;i--){
        K[i]=std::min(K[i],K[i+1]+A[i]);
    }
    
    //for(int i=0;i<=N;i++){std::cout << K[i] << " ";}std::cout << std::endl;
    
    if(invalid){
        std::cout << -1 << std::endl;
        return 0;
    }
    
    
    
    long long Ans=0;
    for(int i=0;i<=N;i++){
        Ans+=K[i];
    }
    std::cout << Ans << std::endl;
    
    return 0;
}


Measured memory_bytes: 5112
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int G[n][n];
    int find[n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>G[i][j];
        }
    }
    for(int i=0;i<n;i++){
        find[i]=-1;
    }
    find[0]=0;
    int end=0;
    int mind;
    int sum=0;
    while(true){
        int min=2001;
        for(int i=0;i<n;i++){
            if (find[i]!=-1){
                for(int j=0;j<n;j++){
                    if (G[i][j]!=-1&&G[i][j]<min){
                        if (find[j]==-1){
                            min=G[i][j];
                            mind=j;
                        }
                    }
                }
            }
        }
        find[mind]=mind;
        sum+=min;
        end+=1;
        if(end==n-1) break;
    }cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
#define all(x) x.begin(), x.end()
#define fi first
#define se second
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    Int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<char> t(q), d(q);
    for (Int i = 0; i < q; i++) {
        cin >> t[i] >> d[i];
    }
    Int ok = -1;
    Int ng = n;
    while (abs(ok - ng) > 1)  {
        Int mid = (ok + ng) / 2;
        bool check = false;
        Int cur = mid;
        for (Int i = 0; i < q; i++) {
            if (t[i] != s[cur]) continue;
            if (d[i] == 'L') {
                cur--;
                if (cur < 0) {
                    check = true;
                    break;
                }
            }
            else {
                cur++;
                if (cur == n) {
                    break;
                }
            }
        }
        if (check) {
            ok = mid;
        }
        else {
            ng = mid;
        }
    }
    Int left = ok + 1;
    ok = n;
    ng = -1;
    while (abs(ok - ng) > 1)  {
        Int mid = (ok + ng) / 2;
        bool check = false;
        Int cur = mid;
        for (Int i = 0; i < q; i++) {
            if (t[i] != s[cur]) continue;
            if (d[i] == 'L') {
                cur--;
                if (cur < 0) {
                    break;
                }
            }
            else {
                cur++;
                if (cur == n) {
                    check = true;
                    break;
                }
            }
        }
        if (check) {
            ok = mid;
        }
        else {
            ng = mid;
        }
    }
    Int right = n - ok;
    dump(n - (left + right));
    return 0;
}

Measured memory_bytes: 1028
from math import sqrt, factorial
from itertools import permutations as pe
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
l = [i for i in range(N)]
d = 0
for i in pe(l):
    flag = False
    dd = 0
    x, y, xx, yy = 0, 0, 0, 0
    
    for ii in i:
        if flag:
            xx, yy = X[ii][0], X[ii][1]
            dd += sqrt((x-xx)**2+(y-yy)**2)
            flag=False
        x, y = X[ii][0], X[ii][1]
        flag=True
    d+=dd
print(d/factorial(N))


Measured memory_bytes: 3188
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:input()

"""========main code==============="""

t=ii()
x=ii()
y=ii()
z=ii()
k=min(t,x)
print(k*y+(t-k)*z)

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

int main()
{
    bool rev = false;
    string s;
    int q;
    cin >> s;
    cin >> q;
    deque<char> deq(s.begin(), s.end());
    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            rev = !rev;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                if (!rev) {
                    deq.push_front(c);
                } else {
                    deq.push_back(c);
                }
            } else {
                if (!rev) {
                    deq.push_back(c);
                } else {
                    deq.push_front(c);
                }
            }
        }
    }
    if (rev) {
        reverse(deq.begin(), deq.end());
    }
    for (auto c : deq) {
        cout << c;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
	#include <cassert>
    #include <iomanip>
    #include <sstream> 
    #include <cstdlib>
using namespace std;
long long N;
int main()
{
	scanf("%lld",&N);
	for(long long  i=1;i<=3500;i++)
	{
		for(long long j=1;j<=3500;j++)
		{
			long long w=N*i*j;
			long long x=4*i*j;
			long long y=i*N;
			long long z=j*N;
			//printf("%d %d %d %d %d %d\n",i,j,w,x,y,z);
			//system("pause");
			if(x-y-z<=0)continue;
			if(w%(x-y-z)==0)
			{
				printf("%lld %lld %lld\n",i,j,w/(x-y-z));
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n,x;
  while(cin >>n,n){
    long long s = 0;
    vector<int> cost;
    for(int i=0; i<n; i++){
      cin >>x;
      cost.push_back(x);
    }
    sort(cost.begin(),cost.end());
    for(int i=0; i<n; i++){
      s+=(n-i-1)*cost[i];
    }
    cout <<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 1324
#include<iostream>
#include<vector>
#include<map>

int main(void){
    int n, q, b, c;
    long long int sum = 0;
    std::cin >> n;
    std::vector<int> A(n);
    std::map<int, int > index_map;

    for(int i = 0; i < n; i++){
	std::cin >> A[i];
	if(index_map.find(A[i]) == index_map.end()) index_map[A[i]] = 1;
	else index_map[A[i]]++;
	sum += A[i];
    }

    std::cin >> q;

    for(int i = 0; i < q; i++){
        std::cin >> b >> c;
        sum = sum + ((-b) + c) * index_map[b];
        index_map[c] += index_map[b];
        index_map[b] = 0;
        std::cout << sum << std::endl;
    }

    return 0;
}


Measured memory_bytes: 8032
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  int alice = 0;
  int bob = 0;
  rep(i,n) {
    if (i%2 == 0) alice += a[i];
    else bob += a[i];
  }
  int ans = alice - bob;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i) = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n;cin>>n;
  ll ans = 0;
  rep(i,n)rep(j,n)rep(k,n){
    ans += gcd(i+1,gcd(j+1,k+1));
  }
  print(ans);
  return 0;
}


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

int n;
long a[100010], b, c, t;

int main(){
	cin >> n;
	for (int i = 0; i < n+1; ++i) cin >> a[i];
	c = 0;
	for (int i = 0; i < n; ++i){
		cin >> b;
		if (a[i] > 0){
			t = min(a[i], b);
			c += t;
			b -= t;
		}
		if (a[i+1] > 0){
			t = min(a[i+1], b);
			c += t;
			a[i+1] -= t;
		}
	}
	cout << c;
}

Measured memory_bytes: 1024
// Problem : A - Nickname
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2020
// URL : https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define int long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define mod 1000000007
#define inf 1e18
#define setbits(x) __builtin_popcount(x)
#define zrbits(x) __builtin_ctzll(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define fi(i,n) for(int i = 0;i < n;i++)
#define fd(i,n) for(int i = n;i >= 0;i--)
int dif(int a,int b){if(a > b)return a - b;else return b - a;}
int gcd(int a, int b){if(b == 0)return a;return gcd(b, a%b);}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];
	return 0;
}


Measured memory_bytes: 3648
//http://arc070.contest.atcoder.jp/tasks/arc070_a

#include <bits/stdc++.h>


using namespace std;

int x,sum=0;

int main() {
    ios_base::sync_with_stdio(0);
    cin>>x;
    int time =0;
    while (sum<x) {
        time++;
        sum+=time;
    }
    cout<<time<<endl;

}



Measured memory_bytes: 256
function keta(num) {
    for(var i=1; i<=6; i++) {
        if(num < Math.pow(10, i)) return i%2;
    }
}

function Main(input) {
    input = parseInt(input);
    var ans = 0;
    var cnt = 1;
    while(cnt <= input) {
        ans += keta(cnt);
        cnt++;
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22964
import sys
import fractions as fl

a, b, c, d = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)

#全体の個数
all = b - a + 1
#cとdの最小公倍数
e = c * d // fl.gcd(c, d)
# a以下でcまたはdで割れる個数
r1 = (a-1) // c + (a-1) // d - (a-1) // e
# b以下でcまたはdで割れる個数
r2 = b // c + b // d - b // e
ans = all - (r2 - r1)
print(ans)

Measured memory_bytes: 5052
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())

a,b = i2()
a1 = ""
b1 = "" 
for i in range(b):
	a1 += str(a)
for i in range(a):
	b1 += str(b)

if a1 < b1:
	print(a1)
else:
	print(b1)

Measured memory_bytes: 9116
#include <iostream>
#include <math.h>
#include <stdio.h>

int main() {
  int a = 0, b = 0;

  scanf(" %d %d", &a, &b);

  if ((float)a / 8 > 1 || (float)b / 8 > 1)
    printf(":(");
  else
    printf("Yay!");

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int max = 0;
		int tmp = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'A' || s.charAt(i) == 'T' || s.charAt(i) == 'C' || s.charAt(i) == 'G') {
				tmp++;
			} else {
				max = Math.max(max, tmp);
				tmp = 0;
			}
		}
		max = Math.max(tmp, max);
		System.out.println(max);
	}
}

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

using namespace std;

int main() {
    int M;
    cin >> M;

    long long d,c;
    long long sum = 0, digit_count = 0, carry_count, answer;

    // 各桁の数の和と桁数を調べる
    for (int i = 0; i < M; i++) {
        cin >> d >> c;
        sum += d*c;
        digit_count += c;
    }

    // 各桁の数の和の繰り上がりの数を調べる
    if (sum % 9 == 0) {
        carry_count = sum / 9 - 1;
    } else {
        carry_count = sum / 9;
    }

    answer = digit_count - 1 + carry_count;

    cout << answer << endl;
	return 0;
}

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

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

	sort(a.begin(), a.end());
	long long int ans = 0;
	for (int i = 0;i < n;) {
		int j = i;
		while (j < n&&a[i] == a[j]) {
			j++;
		}
		int count = j - i;
		if (count < a[i]) {
			ans += count;
		}
		else if (count > a[i]) {
			ans += count - a[i];
		}
		i = j;
	}
	cout << ans << endl;


	return 0;
}

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

typedef pair<int,int> pear;

int main() {
    int n;
    scanf("%*d%d", &n);
    vector<pear> p(n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &p[i].first, &p[i].second);
    }
    sort(p.begin(), p.end(), [](pear a, pear b) {
        return a.second < b.second;
    });
    int ans = 0;
    for (int i = 0; i < p.size(); ans++) {
        int x = p[i].second;
        while (i < p.size() && p[i].first < x) i++;
    }
    printf("%d\n", ans);
}


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

//関数


    
    
    
//main関数
int main() {
    
    
    //入力
    int N;
    cin>>N;
    vector<long> a(3*N);
    for(int i=0;i<3*N;i++){
        cin>>a.at(i);
    }
    
    
    
    //計算
    sort(a.begin(),a.end());
    long ans=0;
    for(int i=0;i<N;i++){
        ans+=a.at(N+2*i);
    }
    
    //出力
    cout<<ans<<endl;
}


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

int main() {
    int s;
    int f,b;
  cin>>s;
    f=s/100;
    b=s-f*100;
    if(f>=1&&f<=12){
        if(b>=1&&b<=12){
            cout<<"AMBIGUOUS"<<endl;
        }else{
            cout<<"MMYY"<<endl;
        }
    }else if(f<1||f>12){
        if(b>=1&&b<=12){
            cout<<"YYMM"<<endl;
        }else{
            cout<<"NA"<<endl;
        }
    }
}

Measured memory_bytes: 256