akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
int isused[1111],n,m,bef[1111],nowx,isused2[1111];
vector<int> e[1111];
bool dfs(int now)
{
    if(isused[now]){nowx=now;return 1;}
    if(isused2[now])return 0;
    isused[now]=isused2[now]=1;
    for(int k:e[now])
    {
        bef[k]=now;
        if(dfs(k))return 1;
    }
    isused[now]=0;
    return 0;
}
vector<int> st;
bool getit(vector<int> &t)
{
    rep(i,1,n+1)isused[i]=0;
    rep(i,0,t.size())isused[t[i]]=i+1;
    st.clear();
    rep(i,0,t.size())
    for(int k:e[t[i]])
    {
        if(k!=t[(i+1)%t.size()]&&isused[k])
        {
            int x=isused[k]-1;
            if(x<i)
            {
                rep(j,x,i+1)st.push_back(t[j]);
            }
            else{
                rep(j,0,i+1)st.push_back(t[j]);
                rep(j,x,t.size())st.push_back(t[j]);
            }
            return 0;
        }
    }
    return 1;
}
int main()
{
    int a,b;scanf("%d%d",&n,&m);
    rep(i,1,m+1)scanf("%d%d",&a,&b),e[a].push_back(b);
    rep(i,1,n+1)
    {
        rep(j,1,n+1)isused2[j]=0;
        if(dfs(i))break;
    }
    if(!nowx){printf("-1\n");return 0;}
    int k=nowx;
    vector<int> tmp;
    do{tmp.push_back(nowx),nowx=bef[nowx];}while(nowx!=k);
    reverse(tmp.begin(),tmp.end());
    while(!getit(tmp))tmp=st;
    printf("%d\n",tmp.size());
    for(int k:tmp)printf("%d\n",k);
}


Measured memory_bytes: 384
n, m = map(int, input().split())
h = list(map(int, input().split()))
cnt = [1] * n
for i in range(m):
    a, b = map(int,input().split())
    if h[a-1] > h[b-1]:
        cnt[b-1] = 0
    elif h[a-1] == h[b-1]:
        cnt[a-1] = 0
        cnt[b-1] = 0
    else:
        cnt[a-1] = 0
print(sum(cnt))


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

int main(){
  int n;
  cin >> n;
  while(n--){
    int l=0, r=0, tmp;
    bool flag=true;
    for(int i=0; i<10; i++){
      cin>>tmp;
      if(l>=r && l<tmp){l=tmp; continue;}
      if(l>=r && r<tmp){r=tmp; continue;}
      if(r>l  && r<tmp){r=tmp; continue;}
      if(r>l  && l<tmp){l=tmp; continue;}
      flag=false;
    }
    if(flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
long long n, k, s, x, z, y, m, b, l;
long long p[5000];
long long c[5000];
int main() {
	scanf("%lld%lld", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%lld", p + i);
		p[i]--;
	}
	for (int i = 0; i < n; i++) {
		scanf("%lld", c + i);
	}
	m = -1000000000;
	for (int i = 0; i < n; i++) {
		s = i;
		x = 0;
		b = 0;
		while (p[s] != i) {
			s = p[s];
			x += c[s];
			b++;
		}
		x += c[i];
		b++;
		if (k > b) {
			l = b + k % b;
			y = 0;
			if (k > l) {
				if (x > 0)y += (k - l) / b * x;
			}
			s = i;
			for (int j = 0; j < l; j++) {
				s = p[s];
				y += c[s];
				if (y > m)m = y;
			}
		}
		else {
			s = i;
			y = 0;
			for (int j = 0; j < k; j++) {
				s = p[s];
				y += c[s];
				if (y > m)m = y;
			}
		}
	}
	printf("%lld\n", m);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, T;
	cin >> n >> T;
	int mx = 0;
	for(register int i = 1; i <= T; ++i)
	{
		int x;
		cin >> x;
		mx = max(mx, x);
	}
	cout << max(mx - 1 - (n - mx), 0) << endl;
} 

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

using namespace std;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	string t, s; cin >> s >> t;
	

	int count_ = 0; int ans = INT_MAX;
	int n = s.length(); int m = t.length();
	for(int i = 0 ; i < n; i++){
		count_ = 0;
		for(int j = 0 ; j < m; j++){
		
			if(i+j < n && t[j] == s[i+j]) count_++;
			if(i+j == n) count_ = 0;
		}

		ans = min(ans, m - count_);
	}

	cout << ans ;
	    

  return 0;
}


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

int main(){
long n;
cin>>n;
long start = sqrt(n)/1;
for(int i=start ;i>0;i--){
  if(n%i==0){

      cout<<(n/i-1)+(i-1)<<endl;
      return 0;
}
}
}


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

using namespace std;

int main(){
	string S; cin >> S;
	string s1, s2;

	s1 = S.substr(0, S.size()/2);
	s2 = S.substr(S.size()-S.size()/2, S.size()/2);
	reverse(s2.begin(), s2.end());

	int cnt = 0;
	for(int i = 0; i < s1.size(); ++i){
		if(s1[i] != s2[i]) cnt++;
	}
	
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  long double a, b, h, m;
  scanf("%Lf %Lf %Lf %Lf", &a, &b, &h, &m);

  long double max = max(h * 30.0 + m / 60.0 * 30.0, m * 6.0);
  long double min = min(h * 30.0 + m / 60.0 * 30.0, m * 6.0);
  long double rad = (max - min) / 180.0 * M_PI;
  long double c = a * a + b * b - 2.0 * a * b * cosl(rad);
  printf("%.10Lf\n", sqrtl(c));
  return 0;
}


Measured memory_bytes: 2576
#include <stdio.h>
#define MAX_N 200000
int max(a, b){
  if (a>b)return a;
  else return b;
}
int i;
int main(){
  int n, k;
  int t;
  int longest=-1;
  scanf("%d %d", &k, &n);
  int a[MAX_N];
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
    if(i>0){
      longest = max(longest, a[i]-a[i-1]);
    }
  }
  t = a[0]-(a[n-1]-k);
  longest = max(longest, t);
  printf("%d", k-longest);
  printf("\n");
}


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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#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 REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


void solve(){
  int N;
  string S;
  cin >> N >> S;

  ll sum = 0;
  int r = 0, g = 0, b = 0;
  rep(i,N){
    if(S[i] == 'R'){
      r++;
      continue;
    }
    if(S[i] == 'G'){
      g++;
      continue;
    }
    if(S[i] == 'B'){
      b++;
      continue;
    }
  }

  rep(i, N){
    if(S[i] == 'R'){
      r--;
    }else if(S[i] == 'G'){
      g--;
    }else if(S[i] == 'B'){
      b--;
    }

    int rr = r;
    int gg = g;
    int bb = b;
    REP(j, i+1, N-1){
      if(S[j] == 'R'){
        rr--;
      }else if(S[j] == 'G'){
        gg--;
      }else if(S[j] == 'B'){
        bb--;
      }
      if(S[i] != S[j]){
        //cout << i << "," << j << endl;
        //cout << rr << ", " << gg << ", " << bb << endl << endl;
        if(S[i] != 'R' && S[j] != 'R')
          sum += rr;
        else if(S[i] != 'G' && S[j] != 'G')
          sum += gg;
        else if(S[i] != 'B' && S[j] != 'B')
          sum += bb;

        if(j - i + j < N && S[j - i + j] != S[i] && S[j - i + j] != S[j]){
          sum--;
        }
      }
    }
  }

  cout << sum << endl;
}

int main(){
  // FastIO
  //ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long A, B, N, X;
            long result, max=0;
            string[] str = Console.ReadLine().Split(' ');
            A = long.Parse(str[0]);
            B = long.Parse(str[1]);
            N = long.Parse(str[2]);
            if (B - 1 < N) X = B - 1;
            else { X = N; }
            max = floor(A, B, X) - A * floor(1, B, X);
            Console.WriteLine(max);
        }
        static long floor(long A,long B,long x)
        {
            long result=0;
            result = (long)(A * x / B);
            return result;
        }
    }
}


Measured memory_bytes: 27492
n=int(input())
a=list(map(int,input().split()))
a_min=min(a)
a_max=max(a)

s=list(range(a_min,a_max+1))
t=[0]*(a_max+1)

for i in range(n):
  t[a[i]]+=1

x=sum(t[:2]) #initialize
for j in range(1,len(t)-1):
  x=max(x,t[j-1]+t[j]+t[j+1])

print(x)
  

Measured memory_bytes: 13964
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
 
using namespace std;
 
 
#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

const int MAXN= 20100;
int a[MAXN];
int up[MAXN];
int down[MAXN];
int b[MAXN];
int s[MAXN];


int c[MAXN],n;
int lowbit(int x)//计算lowbit
{
    return x&(-x);
}

void add(int i,int val)//将第i个元素更改为val
{
    while(i<=n)
    {
        c[i]+=val;
        i+=lowbit(i);
    }
}

int sum(int i)//求前i项和
{
    int s=0;
    while(i>0)
    {
        s+=c[i];
        i-=lowbit(i);
    }
    return s;
}

int main(){
        scanf("%d",&n);
        memset(up,0,sizeof(up));
        memset(down,0,sizeof(down));
        memset(c,0,sizeof(c));
        for(int i=1;i<=n;i++){
                up[i]=i;
                down[i]=n-i+1;
        }
        for(int i=1;i<=n;i++){
                scanf("%d",&a[i]);
                //int small = sum(a[i]);
                //int big = i - small;
                for(int j=a[i]+1;j<=n;j++){
                        up[j]+=n-i+1;
                }
                for(int j=a[i]-1;j>=1;j--){
                        down[j] += n-i+1;
                }
                //up[a[i]] = a[i] + small;
                //down[a[i]] = n+1-a[i] + big;

                //add(a[i],1);
        }
        for(int i=1;i<=n;i++){
                if(i!=n)
                        printf("%d ",up[i]);
                else
                        printf("%d\n",up[i]);
        }     
        for(int i=1;i<=n;i++){
          if(i!=n)
              printf("%d ",down[i]);
          else
              printf("%d\n",down[i]);
   }
  
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		
		int n[] = new int[32];
		 n[0]=1;
		 n[1]=1;
		 n[2]=1;
		 n[3]=2;
		 n[4]=1;
		 n[5]=2;
		 n[6]=1;
		 n[7]=5;
		 n[8]=2;
		 n[9]=2;
		 n[10]=1;
		 n[11]=5;
		 n[12]=1;
		 n[13]=2;
		 n[14]=1;
		 n[15]=14;
		 n[16]=1;
		 n[17]=5;
		 n[18]=1;
		 n[19]=5;
		 n[20]=2;
		 n[21]=2;
		 n[22]=1;
		 n[23]=15;
		 n[24]=2;
		 n[25]=2;
		 n[26]=5;
		 n[27]=4;
		 n[28]=1;
		 n[29]=4;
		 n[30]=1;
		 n[31]=51;

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		System.out.print(n[A-1]);
		
	}
}




Measured memory_bytes: 22868
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll pow(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	if (b == 1) {
		return a;
	}
	ll ans = pow(a, b / 2);
	ans *= ans;
	ans *= b % 2 == 1 ? a : 1;
	return ans;
}

namespace SOLVE {
	void main() {
		int n;
		cin >> n;

		deque<int> dq;
		VI ans(n, pow(2,31) - 1);

		dq.push_front(1);
		ans[1] = 1;

		while (sz(dq)) {
			int at = dq.front();
			dq.pop_front();
			if (ans[at] + 1 < ans[(at + 1) % n]) {
				ans[(at + 1) % n] = ans[at] + 1;
				dq.push_back((at + 1) % n);
			}
			if (ans[at] < ans[at * 10 % n]) {
				ans[at * 10 % n] = ans[at];
				dq.push_front(at * 10 % n);
			}
		}
		cout << ans[0];


	}
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t;
	//    in(t);
	t = 1;
	while (t--) {
		SOLVE::main();

	}

	return 0;
}


Measured memory_bytes: 896
func readInt() -> Int {
    return Int(readLine()!)!
}

func mainA() {
    let X = readInt()

    switch X {
    case 400...599:
        print(8)
    case 600...799:
        print(7)
    case 800...999:
        print(6)
    case 1000...1199:
        print(5)
    case 1200...1399:
        print(4)
    case 1400...1599:
        print(3)
    case 1600...1799:
        print(2)
    case 1800...1999:
        print(1)
    default:
        fatalError()
    }
}

mainA()

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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

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

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

using namespace std;
int N; vector<int> L; int A,B,C;

int ans = 1e9;

void dfs(int depth, int a, int b, int c,int mp){
  if( depth == N){ //ベースケース
    if( a > 0 && b > 0 && c > 0){
       mp += abs(a-A) + abs(b-B) + abs(c-C); ans = min(ans, mp-30); return;}
    else{ return;}
  }
  
   dfs(depth+1, a+L[depth],b,c,mp+10);
   dfs(depth+1, a,b+L[depth],c,mp+10);
   dfs(depth+1, a,b, c+L[depth], mp+10);
   dfs(depth+1, a,b, c, mp);
}
      
    


int main(){

  cin >> N >> A >> B >> C;  L.resize(N);
  for(int i = 0; i < N; i++){
    cin >> L[i];}
  
  dfs(0,0,0,0,0);
  
  cout << ans << endl; return 0;}

  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
// http://www.prefield.com/algorithm/container/union_find.html
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};


int main(){
    int N, M, x, y;
    cin >> N;
    cin >> M;
    UnionFind G = UnionFind(N);
    vector<int> p(N, -1);
    for(int i=0; i<N; ++i){
        cin >> p[i];
    }
    for(int i=0; i<M; ++i){
        cin >> x;
        cin >> y;
        G.unionSet(x-1, y-1);
    }
    int cnt = 0;
    for(int i=0; i<N; ++i)
        cnt += G.findSet(p[i]-1, i);
    cout << cnt;
}

Measured memory_bytes: 1024
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF = (1<<21)+9;
const ll mod = 1e9+7;
ll n;
ll a[29][29];
ll dp[29][INF];
ll bt(ll id,ll mask){
    if(id == n) return 1;
    ll &ret = dp[id][mask];
    if(ret != -1) return ret;
    ret = 0;
    for(int i=0;i<n;i++){
        if(!a[id][i]) continue;
        if(mask&(1<<i)) continue;
        ret = (ret+bt(id+1,mask|(1<<i)))%mod;
    }
    return ret;
}
int main(){
    fast,cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    cout<<bt(0,0)<<endl;
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    rep(i, h)
    {
        rep(j, w)
        {
            if (s[i][j] == '#')
            {
                cout << s[i][j];
            }
            else
            {
                int ans = 0;
                for (int ri = -1; ri <= 1; ++ri)
                    for (int rj = -1; rj <= 1; ++rj)
                    {
                        int rri = i + ri;
                        int rrj = j + rj;
                        if (rri < 0 || rri >= h || rrj < 0 || rrj >= w)
                            continue;
                        if (s[rri][rrj] == '#')
                            ++ans;
                    }
                cout << ans;
            }
        }
        cout << endl;
    }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  ll ret = 0;
  priority_queue<int, vector<int>, greater<int>> que;
  vector<pair<int, int>> BC(M);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    que.push(a);
    ret += a;
  }

  for (int i = 0; i < M; i++) {
    int B, C;
    cin >> B >> C;
    BC[i] = make_pair(C, B);
  }
  sort(BC.begin(), BC.end(), greater<pair<int, int>>());

  vector<int> D;
  int cnt = 0;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < BC[i].second && cnt < N; j++) {
      cnt++;
      D.push_back(BC[i].first);
    }
  }
  reverse(D.begin(), D.end());

  for (int i = 0; i < D.size(); i++) {
    int top = que.top();
    que.pop();
    ret += max(D[i] - top, 0);
    que.push(max(top, D[i]));
  }
  cout << ret << endl;
}


Measured memory_bytes: 2168
def main():
     n=int(input())
     h=list(map(int,input().split()))
     flag=0
     h[0]-=1
     for i in range(n-1):
          if h[i+1]>h[i]:
               h[i+1]-=1
          elif h[i+1]<h[i]:
               flag=1
               break
     if h[n-1]<h[n-2]:
          flag=1
     if flag==1:
          print('No')
     else:
          print('Yes')
     
     
if __name__ == '__main__':
     main()

Measured memory_bytes: 64080
object Main extends App {
  val nk =  scala.io.StdIn.readLine()
  val nkArray = nk.split(" ").map(_.toLong).toSeq
  val n = nkArray(0)
  val k = nkArray(1)

  val amari = n % k
  val amariMinusK = Math.abs(n % k - k)

  println(if(amariMinusK < amari) amariMinusK else amari)
}

Measured memory_bytes: 25416
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, i, ans=0;

    cin >> A >> B;

    for(i=A; i<=B; i++){
        if(i/10000 == i%10 && (i/1000)%10 == (i/10)%10){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void insertionSort(int *,int);
void print(int *,int);

int main(){
  int i,N;
  int A[1000];
  
  scanf("%d",&N);
  if(N <= 0 && N >= 100)return 0;
  
  for( i = 0 ; i < N ; i++ ){
    scanf("%d",&A[i]);
  }

  print(A,N);
  
  insertionSort(A,N);

  return 0;
}

void print(int *A ,int N){
  int i;
  for( i = 0 ; i < N ; i++ ){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
 
  printf("\n");
}

void insertionSort(int *A ,int N){
  int i,x,j;
  for( i = 1 ; i < N ; i++ ){
    x = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > x){
      A[j+1] = A[j];
      j--;
    }
      A[j+1] = x;
      print(A,N);
  }
}
     
      



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

class Main {
    static int searchP(long p,int[] ws){
        int count = 1;
        int sum = 0; 
        for(int i = 0; i < ws.length; i++){
            if(sum + ws[i] <= p) {
            sum += ws[i];
            } else {
                count++;
                if(ws[i] <= p){
                sum = ws[i];
                } else{
                    count += 99999;
                }
            }
        }
        return count;
    }
    static long solve(long p, int[] ws, long k){
        long right = p;
        long left = 0;
        long mid;
        while(right - left > 1) {
            mid = (left + right) / 2;
            int v = searchP(mid,ws);
            if(k >= v) {
                right = mid;
            } else {
               left = mid;
                
            }
        }
    return right;
    }
    public static void main(String...args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] info = br.readLine().split(" ");
        int n = Integer.parseInt(info[0]);
        int k = Integer.parseInt(info[1]);
        int[] ws = new int[n];
        for(int i = 0; i < n; i++) {
            ws[i] = Integer.parseInt(br.readLine());
        }
        long p = 100000 * 10000;
        System.out.println(solve(p,ws,k));
        
    }
}





Measured memory_bytes: 35384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
unordered_map<ll,int> m;
ll N,A,ans;
int main(){
    cin>>N;
    while(N--){
        cin>>A;
        m[A]=1-m[A];
    }
    for(auto& x:m)
        ans+=x.second;
    cout<<ans<<endl;
}


Measured memory_bytes: 4388
# ABC107C - Candles (ARC101C)
def main():
    N, K, *X = map(int, open(0).read().split())
    ans = min(r - l + min(abs(l), abs(r)) for l, r in zip(X, X[K - 1 :]))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14052
h,w,a,b=map(int,input().split())
A=[]
for i in range(b):
    A.append(["1"]*a+["0"]*(w-a))
for i in range(h-b):
    A.append(["0"]*a+["1"]*(w-a))
for l in A:
    print("".join(l))

Measured memory_bytes: 76088
n,x,y=map(int,input().split())
ans=[0 for i in range(n)]
for start in range(n):
  gone=[0 for i in range(n)]
  gone[start]=1
  now ={start}
  for i in range(1,n):
    go=set()
    for s in now:
      if s!=0 and gone[s-1]==0:
        go.add(s-1)
        gone[s-1]=1
        ans[i]+=1
      if s!=n-1 and gone[s+1]==0:
        go.add(s+1)
        gone[s+1]=1
        ans[i]+=1
      if s==x-1 and gone[y-1]==0:
        go.add(y-1)
        gone[y-1]=1
        ans[i]+=1
      if s==y-1 and gone[x-1]==0:
        go.add(x-1)
        gone[x-1]=1
        ans[i]+=1
    now=go
for i in range(1,n):
  print(ans[i]//2)


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

using namespace std;
const int MOD = 1e6 * 2 + 7;


int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.length();
    if (k < n) {
        s = s.substr(0, k);
        s += "...";
    }
    cout << s;

    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
        #include <stdlib.h>
         
        int main(void)
        {
            int a, b, max = 0;
            int n;
            scanf("%d%d%d", &n, &a, &b);
            int h[n];
            for (int i = 0; i < n; ++i){
                 scanf("%lld", &h[i]);
                 if (max < h[i])
                    max = h[i];
            }
         
            int del = a - b, l = 0, r = max/b + 1;
            int t;
            while (r - l > 1){
                t = (l+r)/2;
                long long ch = t;
                for (int i = 0; i < n; ++i){
                    if (t*b < h[i]){
                        ch -= (h[i] - t*b)/del + ((h[i] - t*b)%del? 1:0);
                    }
                }
                if (ch < 0)
                    l = t;
                else
                    r = t;
            }
            printf("%d\n", r);
            return 0;
        }

Measured memory_bytes: 512
import java.math.*

fun main(args: Array<String>) {
    val n = Integer.parseInt(readInputLine())
    val aList = readInputLine().split(" ").map { Integer.parseInt(it) }.toMutableList<Int>()
    aList.add(0, 0)
    aList.add(0)

    var totalCost = 0L
    for (i in 1 until aList.size) {
        totalCost += Math.abs(aList[i - 1] - aList[i])
    }

    for (i in 1..n) {
        println("""${totalCost 
                     - Math.abs(aList[i - 1] - aList[i]) 
                     - Math.abs(aList[i] - aList[i + 1])
                     + Math.abs(aList[i - 1] - aList[i + 1])}""")
    }
    
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 58252
package main

import (
	"fmt"
)

func main() {
	var n, l int
	fmt.Scan(&n, &l)
	mini := 400
	total := 0
	for i := 1; i <= n; i++ {
		azi := l + i - 1
		if abs(mini) > abs(azi) {
			mini = azi
		}
		total += azi
	}
	fmt.Println(total - mini)
}


func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(1000000)
n,q=map(int,input().split())

d=[[0] for _ in range(n+1)]
d1=[0 for _ in range(n+1)]

for i in range(n-1):
  a,b=map(int,input().split())
  d[a].append(b)
  d[b].append(a)

for i in range(q):
  p,x=map(int,input().split())
  d1[p]+=x

#d 関係性 d1価
vi=[-1 for _ in range(n+1)]

def dfs(x,i):
  vi[x]=i+d1[x]
  for m in d[x]:
    if vi[m]==-1 and m!=0:
      dfs(m,vi[x])    

dfs(1,0)


print(*vi[1:])

Measured memory_bytes: 231212
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define MOD 10000007
#define PB push_back

using namespace std;



int main(){
  
  int n;
  cin >> n;
  
  if(n%2 == 0) cout << n / 2 <<endl;
  else cout << n / 2 + 1 <<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int cnt[5]={};
  for(int i=0;i<3;i++){
    int a,b;
    cin>>a>>b;
    cnt[a]++;
    cnt[b]++;
  }
  int ans[3]={};
  for(int i=1;i<=4;i++)ans[cnt[i]]++;
  if(ans[1]==2&&ans[2]==2)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,i,j,x[1000],a,b;
	long long cnt;
	scanf("%d",&n);
	for(i=1;i<1000;i++)	x[i]=0;
	for(i=2;i<=n;i++)	{
		a=2;	b=i;
		while(b>1)	{
			if(b%a==0)	{
				x[a]++;
				b/=a;
			}
			else a++;
		}
	}
	cnt=1;
	for(i=1;i<1000;i++)	{
		if(x[i]!=0)	{
			cnt=cnt*(x[i]+1);
			cnt%=1000000007;
		}
	}
	printf("%lld\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX



 
void solve()
{
    int n;
    cin >> n;
    if(n%1000==0)
        cout << 0 << endl;
    else
        cout << (1000-(n%1000)) << endl; 
}


signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

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

typedef struct node{
	int parent;
	int rank;
	int size;
}node;

int find(vector<node> &nodes, int x){
	if(x == (nodes[x].parent))
		return x; // found the root of this tree
	else {
		nodes[x].parent = find(nodes, nodes[x].parent); // path compression
		return nodes[x].parent;
	}
}

void doUnion(vector<node> &nodes, int x, int y){
	int rootX = find(nodes, x);
	int rootY = find(nodes, y);
	if(rootX == rootY)
		return;
	else if(nodes[rootX].rank > nodes[rootY].rank){
		nodes[rootY].parent = nodes[rootX].parent;
		nodes[rootX].size = nodes[rootX].size + nodes[rootY].size;
	}
	else if(nodes[rootX].rank < nodes[rootY].rank){
		nodes[rootX].parent = nodes[rootY].parent;
		nodes[rootY].size = nodes[rootX].size + nodes[rootY].size;
	}
	else{
		nodes[rootX].parent = nodes[rootY].parent;
		nodes[rootY].rank = nodes[rootY].rank + 1;
		nodes[rootY].size = nodes[rootX].size + nodes[rootY].size;
	}
}

int main(){
	int N, M;
	int x,y;

	cin >> N >> M;
	vector<node> nodes;
	nodes.push_back({-1, -1, 0});

	for (int i=1;i<N+1;i++)
		nodes.push_back({i, 0, 1});

	for(int i=1;i<=M;i++){
		cin >> x >> y;
		doUnion(nodes, x, y);
	}
	int res = 1;
	for(int i=1;i<=N;i++)
		res = max(res, nodes[i].size);

	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 6384
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C (GCC 5.4.1)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n;
	int cnt = 0;
	char s[53];

	scanf("%d", &n);
	scanf("%s", s);

	for(int i = 0; i < n - 2; ++i){
		if(strncmp(&s[i], "ABC", 3) == 0)	++cnt;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100005;
int cnt4, cnt2, cnt0;
int a[Maxn];
int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i] % 4 == 0)
			cnt4++;
		else if(a[i] % 2 == 0)
			cnt2++;
		else
			cnt0++;
	}
	bool ok = true;
	if(cnt4 < cnt0 - 1) ok = false;
	if(cnt4 == cnt0 - 1) {
		if(cnt2 != 0)
			ok = false;
	}
	if(ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll n, t, a, h;
  cin >> n >> t >> a;
  ll min_i = -1;
  double dist=LLONG_MAX;
  forll(i, 0, n){
	cin >> h;
	if (abs(a - ((double)t - (double)h * 0.006)) < dist){
	  min_i = i;
	  dist = abs(a - ((double)t - (double)h * 0.006));
	}
  }
  cout << min_i + 1 << endl;
}

Measured memory_bytes: 256
import bisect


def main():
    n = int(input())
    l_lst = list(map(int, input().split()))
    l_lst.sort()

    count = 0
    for i in range(n - 1):
        for j in range(i + 1, n):

            a = l_lst[i]
            b = l_lst[j]
            tmp = bisect.bisect_left(l_lst, a + b)
            tmp -= j + 1
            tmp = max(0, tmp)
            count += tmp

    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int a, b;
  cin >> a >> b;
  int c = a*b;
  if(c%2 == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
	
}

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

using namespace std;

int main(void) {

    int A, B, K;
    cin >> A >> B >> K;

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

        if ((i % 2) == 0) {
            if ((A % 2) == 1) {
                A -= 1;
            }
            B += A/2;
            A /= 2;
        }
        else {
            if ((B % 2) == 1) {
                B -= 1;
            }
            A += B/2;
            B /= 2;
        }
    }

    cout << A << " " << B << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define PI acos(-1)
#define BMW_GTR ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef long long ll;
using namespace std;

//ll const n = 50005;

int main()
{
    BMW_GTR;

    string s;
    cin >> s;

    if(s[2] == s[3] && s[4] == s[5])cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 3648
def calc(l):
    n = len(l)
    dp = [[0]*3 for _ in range(n+1)]
    
    for i in range(n):
        if l[i]=='r':
            dp[i+1][0] = max(dp[i][1], dp[i][2])
            dp[i+1][1] = max(dp[i][0], dp[i][2])
            dp[i+1][2] = max(dp[i][0], dp[i][1])+P
        elif l[i]=='s':
            dp[i+1][0] = max(dp[i][1], dp[i][2])+R
            dp[i+1][1] = max(dp[i][0], dp[i][2])
            dp[i+1][2] = max(dp[i][0], dp[i][1])
        else:
            dp[i+1][0] = max(dp[i][1], dp[i][2])
            dp[i+1][1] = max(dp[i][0], dp[i][2])+S
            dp[i+1][2] = max(dp[i][0], dp[i][1])
    
    return max(dp[n])

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
ans = 0

for i in range(K):
    l = []
    j = i
    
    for j in range(i, N, K):
        l.append(T[j])
    
    ans += calc(l)

print(ans)

Measured memory_bytes: 68336
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define rrep(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define sort(x) sort(x.begin(),x.end());
#define lli long long int
#define vi vector<int> 

using namespace std;

void p(int x) {
	cout << x << endl;
}

void pp(string s) {
	cout << s << endl;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<char>> v(n+2, vector<char>(m+2));
	
	vector<vector<char>> vv(n , vector<char>(m));

	rep(i, 0, n+2) {
		rep(j, 0, m + 2) {
			if (i == 0 || j == 0 || i == n+1 || j == m+1) v[i][j] += '.';
			else cin >> v[i][j];
		}
	}

	rep(i, 1, n+1) {
		rep(j, 1, m+1) {
			int sum=0;

			if (v[i][j] == '#') {
				vv[i-1][j-1] = '#';
				continue;
			}
			else {
				if (v[i - 1][j - 1] == '#')sum++;
				if (v[i][j - 1] == '#')sum++;
				if (v[i - 1][j] == '#')sum++;
				if (v[i+1][j+1] == '#')sum++;
				if (v[i + 1][j - 1] == '#')sum++;
				if (v[i - 1][j + 1] == '#')sum++;
				if (v[i + 1][j] == '#')sum++;
				if (v[i][j + 1] == '#')sum++;
			}
			vv[i-1][j-1] = '0'+sum;


			
			
		}
	}
	
	rep(i, 0, n) {
		rep(j, 0, m) {
			if (j == 0)cout << vv[i][j];
			else cout << vv[i][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

const long long Mod = 1000000007;

int main()
{
	int i, N, C, A[401], B[401];
	scanf("%d %d", &N, &C);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	for (i = 1; i <= N; i++) scanf("%d", &(B[i]));
	
	int j;
	long long pow[401][401], sum[401][401];
	for (i = 1; i <= 400; i++) {
		for (j = 1, pow[i][0] = 1; j <= C; j++) pow[i][j] = pow[i][j-1] * i % Mod;
	}
	for (i = 0; i <= C; i++) {
		for (j = 1, sum[i][0] = 0; j <= 400; j++) sum[i][j] = sum[i][j-1] + pow[j][i];
	}
	
	int k;
	long long dp[2][401] = {};
	for (j = 0; j <= C; j++) dp[1][j] = (sum[j][B[1]] - sum[j][A[1]-1]) % Mod;
	for (i = 2; i <= N; i++) {
		for (j = 0; j <= C; j++) {
			for (k = 0, dp[i%2][j] = 0; k <= j; k++) dp[i%2][j] = (dp[i%2][j] + dp[1-i%2][j-k] * ((sum[k][B[i]] - sum[k][A[i]-1]) % Mod)) % Mod;
		}
	}
	printf("%lld\n", dp[1-i%2][C]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4228
#include <stdio.h>

int main()
{
	int nn;
	long long int sum = 0;
	scanf("%d", &nn);
	for(int ii = 1;ii <= nn;ii++)
	{
		if(ii % 3 && ii % 5)
		{
			sum += ii;
		}
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

void solve() {
    int n;
    cin >> n;
    REP(i,1,n+1) {
        if (int(i * 1.08) == n) {
            cout << i << endl;
            return;
        }
    }
    cout << ":(" << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A_list = [int(e) for e in input().split()]

#bのうちどれか1つが偶数ならばOK
#bは3通り
#∴3**Nから全部が奇数のパターンを引けばOK

odd_pattern = 1

for i in range(N):
    if A_list[i]%2 == 0:
        odd_pattern *= 2
        
print(3**N - odd_pattern)

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

using namespace std;

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

    int len = 0, max_len = 0;
    for (char c : s) {
        switch (c) {
            case 'A':
            case 'C':
            case 'G':
            case 'T':
                len++;
                break;
            default:
                max_len = max(max_len, len);
                len = 0;
        }
    }

    cout << max(max_len, len) << endl;
}

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

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

    string t0, t1;

    for(long long i = 0; i < s.size(); i++){
        if(i % 2 == 0){
            t0.push_back('0');
            t1.push_back('1');
        }
        else{
            t0.push_back('1');
            t1.push_back('0');
        }
    }
    long long count1 = 0, count0 = 0;
    for(long long i = 0; i < s.size(); i++){
        if(t0[i] != s[i]){
            count0++;
        }

        if(t1[i] != s[i]){
            count1++;
        }
    }

    cout << min(count0, count1) << endl;

    return 0;
}

Measured memory_bytes: 3984
'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  const N = tmp.shift()[0];
  const h = tmp;
  const dp = [[0,0,0]];
  for ( let i = 0; i < N; i++ ) {
    dp.push([0,0,0]);
    for ( let j = 0; j < 3; j++ ) {
      for ( let k = 0; k < 3; k++ ) {
        if ( j === k ) continue;
        const happy = h[i][j] + dp[i][k];
        if ( dp[i+1][j] < happy ) dp[i+1][j] = happy;
      }
    }
  }
  return Math.max(...dp[N]).toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 52144
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
double GetDistance(int,int,int,int);

int main(void){
  int A,B,H,M;
  double result;
  cin>>A>>B>>H>>M;
  result=GetDistance(A,B,H,M);
  cout<<setprecision(20)<<result<<endl;
}

double GetDistance(int aa,int bb,int h,int m){
  double a=(double)aa;
  double b=(double)bb;
  double deg_m=(double)m*6;
  double deg_h=(double)h*30+(deg_m*30.0/360.0);
  double theta=(deg_h-deg_m)*2*M_PI/360.0;
  if(theta<0) theta=-theta;
  if(theta>=180) theta-=180;
  
  return sqrt(a*a+b*b-(2*a*b*cos(theta)));
}

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

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

// O(n * W)

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<ll> dp(W + 1); // 0 ... W
    // dp[i] - the maximum total value of items with total weight exactly i
    for(int item = 0; item < n; ++item) {
        int weight, value;
        scanf("%d%d", &weight, &value);
        // dp[0] -> dp[3] -> dp[6]
        for(int weight_already = W - weight; weight_already >= 0; --weight_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            max_self(dp[weight_already+weight], dp[weight_already] + value);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= W; ++i) {
        max_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}


Measured memory_bytes: 1024
def prime(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

a, b = map(int,input().split())
x = prime(a)
y = prime(b)
print(len(set(x) & set(y)) + 1)

Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/

inline int read() {
	int w=0; bool q=1; char c=getchar();
	while ((c<'0'||c>'9')&&c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c<='9') w=w*10+c-'0',c=getchar();
	return q?w:-w;
}
inline char readc(){
	char c=getchar();
	while (!isalnum(c)) c=getchar();
	return c;
}
inline int quickpow(int x,int y){
	int ans=1;
	while (y)
		ans=(y&1)?1ll*ans*x%mods:ans,
		x=1ll*x*x%mods,y>>=1;
	return ans;
}
int main()
{
    int a=read(),b=read(),c=read();
	if (a<b) swap(a,b);
	if (a<c) swap(a,c);
	if (b<c) swap(b,c);
	cout<<a*10+b+c<<endl; 
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <functional>
using namespace std;
#define int long long
signed main(void)
{
	int x;
	cin >> x;
	int ans = 0; int sum = 0;
	while (sum < x) {
		sum += ans; ans += 1;
	}
	cout << ans-1<<endl;

	return 0;
}

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

int main()
{
    int n,l;
    cin >> n >> l;
    vector<string> s;
    rep(i,n){
        string str;
        cin >> str;
        s.push_back(str);
    }
    sort(s.begin(),s.end());
    string ans="";
    rep(i,n){
        ans+=s[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    int n,k;
    cin >> n >> k;
    vec<long> h(n);
    for (auto &&e : h)
    {
        cin >> e;
    }
    sort(h.rbegin(),h.rend());

    long ans=0ll;
    auto it = h.begin();
    while (it != h.end() and k != 0)
    {
        it++;
        k--;
    }
    while(it != h.end())
    {
        ans += *it;
        it++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#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>;

ll c[200005];
ll sum[200005];
vector<vector<int> > child;
 
void add(int pn, int cn, ll x){
    sum[cn] += (x + c[cn]);
    if(child[cn].size() != 0){
        rep(i, (int)child[cn].size()){
            if(pn != child[cn][i]) add(cn, child[cn][i], x + c[cn]);
        }
    }
}

void show(int num){
    rep(i, (int)child[num].size()){
        cout << child[num][i] << " ";
    }
    cout << endl;
}

int main() {
    int n, q;
    cin >> n >> q;
    child = vector<vector <int>>(n);
    
    int a, b;
    rep(i, n-1){
        cin >> a >> b;
        child[a-1].push_back(b-1);
        child[b-1].push_back(a-1);
    }
    
    int p;
    ll x;
    rep(i, q){
        cin >> p >> x;
        c[p-1] += x;
    }
    
    add(-1, 0, 0);
    
    rep(i, n) cout << sum[i] << " ";
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define maxn 15

int gcd(int x, int y)
{
    if (x < y)
        swap(x, y);
    if (y == 0)
        return x;
    return gcd(x % y, y);
}

signed main()
{
    int N;
    cin >> N;
    double long x[N];
    string u[N];
    double long ans = 0;
    rep(i, N)
    {
        cin >> x[i] >> u[i];
        if (u[i] == "BTC")
        {
            ans += x[i] * 380000;
        }
        else
        {
            ans += x[i];
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256