akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int
main(void)
{
	int i, x, n;

	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		x = i;

		if (x % 3 == 0) {
			printf(" %d", i);
			continue;
		}

		do {
			if (x % 10 == 3) {
				printf(" %d", i);
				x = 0;
			} else {
				x /= 10;
			}
		} while (x);
	}

	printf("\n");

	return 0;
}



Measured memory_bytes: 2092
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
using ll=long long;
#include <set>
using namespace std;
ll gcd(ll x,ll y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}
int main(){
    int n;
    cin >> n;
    int c=0;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        if(s.size()%2==1){
            c++;
        }
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n,T;
  cin >> n>>T;
  int c,t;
  int ans=INT_MAX;
  rep(i,n){
    cin >> c >> t;
    if(t<=T) ans=min(ans,c);
  }
  if(ans==INT_MAX){
    cout << "TLE" << endl;
  }
    else cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;

void solve(string S){
  int cnt=0;
  rep(i,3) if(!S.compare(i,1, "1")) cnt++;
  cout << cnt << "\n";
}

int main(){
    string S;
    cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
  int l,r;
  int i,tmp,min=20000,j;
  cin>>l>>r;
  
  if(r-l>=2019){
    cout<<0<<endl;
  }
  else{
    for(i=l;i<r;i++){
      for(j=i+1;j<=r;j++){
        tmp=((i%2019)*(j%2019))%2019;
        if(tmp<min)min=tmp;
      }
    }
    cout<<min<<endl;
  }

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		
		int n, v, j;
		
		n = scan.nextInt();
		
		int[] a = new int[n];
		
		for(int i = 0; i < n; i++){
			
			a[i] = scan.nextInt();
			
		}
		
		for(int k = 0; k < n; k++){
			
			if(k == n - 1){
				
				System.out.print(a[k]);
				System.out.println();
				
			}else{
				
				System.out.print(a[k]+" ");
				
			}
		}
		
		
		for(int i = 1; i <= n - 1; i++){
			
			v = a[i];
			j = i - 1;
			
			while(j >= 0 && a[j] > v){
				
				a[j + 1] = a[j];
				j--;
				a[j + 1] = v;
				
			}
			
			for(int k = 0; k < n; k++){
				
				if(k == n - 1){
					
					System.out.print(a[k]);
					System.out.println();
					
				}else{
					
					System.out.print(a[k]+" ");
					
				}
			}
		}
	}
}

Measured memory_bytes: 32216
A, B, C, D = map(int, input().split())
if(C % B == 0):
  Takahashi = C//B
else:
  Takahashi = C//B + 1
if(A % D == 0):
  Aoki = A//D
else:
  Aoki = A//D + 1
if(Takahashi > Aoki):
  print('No')
else:
  print('Yes')

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,m;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll tab[2*m+1]={};
    ll ans=0;
    for(int i=0;i<n-1;i++){
        int prev=a[i]-1;
        int next=a[i+1]-1;
        if(prev>next)next+=m;
        ans+=next-prev;
        tab[prev+2]++;
        tab[next+1]--;
    }
    for(int i=1;i<2*m;i++){
        tab[i]+=tab[i-1];
    }
    for(int i=0;i<n-1;i++){
        int prev=a[i]-1;
        int next=a[i+1]-1;
        if(prev>next)next+=m;
        if(prev+2<=next)tab[next+1]-=next-prev-1;
    }
    for(int i=1;i<2*m;i++){
        tab[i]+=tab[i-1];
    }
    ll mx=-1;
    for(int x=0;x<m;x++){
        mx=max(mx,tab[x]+tab[x+m]);
    }
    ans-=mx;
    cout<<ans<<endl;
}

Measured memory_bytes: 2176
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AtCoder_Beginner_Contest_134
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var col = new List<long>() { -1 };
            for (var i = 0; i < N; ++i)
            {
                var ai = Sarray()[0];
                if (col[col.Count - 1] >= ai)
                { col.Add(ai); }
                else if (ai > col[0])
                {
                    col[0] = ai;
                }
                else
                {
                    var idx = binary_search(col, ai, 1, col.Count - 1);
                    while (col[idx] == ai)
                        ++idx;
                    col[idx] = ai;
                }
            }
            WriteLine(col.Count);
        }
        static int binary_search(List<long> lst, long key, long min, long max)
        {
            if (max < min)
                return (int)min;

            var mid = min + (max - min) / 2;
            if (key > lst[(int)mid])
            {
                return binary_search(lst, key, min, mid - 1);
            }
            if (lst[(int)mid] > key)
            {
                return binary_search(lst, key, mid + 1, max);
            }
            if (mid == lst.Count - 1)
                return (int)mid;
            if (lst[(int)mid] == lst[(int)mid + 1])
                return binary_search(lst, key, mid + 1, max);
            return (int)mid;
        }
    }
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n;
  cin>>n;
  vector<string> s(n);
  cin>>s;

  auto calc = [](string const& s)->pll{
    ll low=0,res=0;
    for(auto& c:s){
      if(c=='(')res++;
      else res--;
      chmin(low,res);
    }
    return {low,res};
  };

  vector<pll> mem(n);
  rep(i,n)mem[i]=calc(s[i]);

  vector<pll> plus,minus;
  rep(i,n){
    if(mem[i].second>0)plus.emplace_back(mem[i]);
    else minus.emplace_back(mem[i]);
  }
  sort(begin(plus),end(plus),greater<>());

  auto trans = [](vector<pll> const& v){
    vector<pll> tmp;
    for(auto [low,res]:v){
      tmp.emplace_back(low-res,-res);
    }
    return tmp;
  };
  minus = trans(minus);
  sort(begin(minus),end(minus),greater<>());

  auto chk = [](vector<pll> const& v){
    ll now = 0;
    for(auto [low,res]:v){
      if(now+low<0)return false;
      now += res;
    }
    return true;
  };
  auto sum = [](vector<pll> const& v){
    ll s = 0;
    for(auto [_,val]:v)s+=val;
    return s;
  };

  bool ok = chk(plus) && chk(minus) && (sum(plus)==sum(minus));
  cout<<(ok?"Yes":"No")<<endl;


}

Measured memory_bytes: 78032
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
print(n**3)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    int a[3][3]={0};
    int b[3][3]={0};
    int i,j;
    for(i=0; i<3; i++) {
        for(j=0; j<3; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    int n;
    scanf("%d", &n);
    int p;
    for(p=0; p<n; p++) {
        int tmp;
        scanf("%d", &tmp);
        for(i=0; i<3; i++) {
            for(j=0; j<3; j++) {
                if(tmp==a[i][j]) b[i][j]=1;
            }
        }        
    }
    for(i=0; i<3; i++) {
        int sum=0;
        for(j=0; j<3; j++) {
            sum+=b[i][j];
        }
        if(sum==3) {
            printf("Yes\n"); return;
        }
    }
    for(i=0; i<3; i++) {
        int sum=0;
        for(j=0; j<3; j++) {
            sum+=b[j][i];
        }
        if(sum==3) {
            printf("Yes\n"); return;
        }
    }
    if(b[0][0]+b[1][1]+b[2][2]==3) {
        printf("Yes\n"); return;
    }
    if(b[0][2]+b[1][1]+b[2][0]==3) {
        printf("Yes\n"); return;
    }
    printf("No\n");

    return;
}


int main(int argc, char* argv[])
{
#if 1
	solve();
#else
	int T; scanf("%d", &T);
	while (T--) {
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int gcd(int a, int b)
{
  int tmp,r;
  if(a<b)
  {
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a%b;
  while(r != 0)
  {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}

int main(void)
{
  int K,sum;
  int i,j,k;
  sum = 0;

  scanf("%d",&K);

  for(i=1;i<=K;i++)
  {
    for(j=1;j<=K;j++)
    {
      for(k=1;k<=K;k++)
      {
        sum += gcd(gcd(i,j),k);
      }
    }
  }

  printf("%d\n",sum);

  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
using namespace std;
int main() {
  int x[3001], y[3001];
  int count = 3001;
  int tmp;
  for (int i=1; i <= 3000; i++) {
    cin >> x[i] >> y[i];
    if (x[i] == 0 && y[i] == 0) {
      count = i;
      break;
    }
    else {
      if (x[i] > y[i]) {
	tmp = x[i];
	x[i] = y[i];
	y[i] = tmp;
      }
    }
  }
  for (int i=1; i < count; i++) 
    cout << x[i] << " " << y[i] << endl;
  return 0;
}



Measured memory_bytes: 3024
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long k = sc.nextLong();

        long sum =0;
        while(a >0 && k>0){
            sum++;
            a--;k--;
        }
        while(b > 0 && k>0){
            b--;
            k--;
        }
        while(c > 0 && k>0){
            sum--;
            c--;k--;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 35508
#include<complex>
#include<cstdio>
using namespace std;
const int mod=1e9+7;
const int N=1e6+7;
int n;
int fac[N],finv[N],f[N];
int qread()
{
	int x=0;
	char ch=getchar();
	while(ch<'0' || ch>'9')ch=getchar();
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
int Fpow(long long b,int p)
{
	long long res=1;
	for(;p;p>>=1,b=b*b%mod)
		if(p&1)res=res*b%mod;
	return res;
}
void Init()
{
	fac[0]=finv[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=1ll*fac[i-1]*i%mod;
	finv[n]=Fpow(fac[n],mod-2);
	for(int i=n-1;i;i--)
		finv[i]=1ll*finv[i+1]*(i+1)%mod;
}
long long C(int n,int m)
{
	return 1ll*fac[n]*finv[m]%mod*finv[n-m]%mod;
}
int main()
{
	scanf("%d",&n);
	Init();
	int l=n+1>>1,ans=0;
	for(int i=l;i<n;i++)
		f[i]=C(i-1,n-i-1)*fac[i]%mod*fac[n-i-1]%mod;
	for(int i=n-1;i>=l;i--)
		f[i]=(f[i]-f[i-1]+mod)%mod;
	for(int i=l;i<n;i++)
		ans=(ans+1ll*f[i]*i%mod)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9984
#include <iostream>

using namespace std;

int main(){
	int a, b, c; cin >> a >> b >> c;
	int k; cin >> k; int n;
	n = max(a, b);
	n = max(n, c);
	int p=n;
	for(int i=0; i<k; i++){
		n=2*n;
	}
	cout << a + b + c + n - p << endl;
}


Measured memory_bytes: 256
import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as BS8
import qualified Data.Vector as Vector
import Data.Vector ((!))

main :: IO ()
main = do
  n <- fst . fromJust . BS8.readInt <$> BS8.getLine
  a <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine

  let
    vb = Vector.fromList $ replicate n 0
    v = Vector.accum (+) vb (zip (map (+(-1)) a) $ repeat 1)

  Vector.mapM_ print v


Measured memory_bytes: 25460
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define WAIT system ("pause")
#define rt0 return 0
using namespace std;
int main()
{
	int N, A[100],B[100],C[100],D[100];
	int big[100],small[100];
	
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i]>>B[i];
		big[i]=0;
	} 
	for(int i=0;i<N;i++){
		cin>>C[i]>>D[i];
		small[i]=0;
		for(int j=0;j<N;j++){
			if(A[j]<C[i] and B[j]<D[i]){
				small[i]++;
				big[j]++;
			}
		}
	} 
	
	int ans=0;
	while(1){
		int k=-1;
		int count=101;
		for(int i=0;i<N;i++){
			if(small[i]<=0) continue;
			if(small[i]<count){
				k=i;
				count=small[i];
			}
		}
		if(count>100) break;
		
		small[k]=0;
		count=0;
		int x=-1;
		int count1=101;
		for(int j=0;j<N;j++){
			if(big[j]<=0) continue;
			if(A[j]<C[k] and B[j]<D[k]){
				big[j]--;
				if(big[j]<count1) {
					count1=big[j];
					x=j;
				}
				count++;
			}
		}
		if(count>0) ans++;
		if(x>=0) {
			big[x]=0;
			for(int i=0;i<N;i++){
				if(A[x]<C[i] and B[x]<D[i]) small[i]--;
			}
		}
	}
	cout<<ans;
	
    rt0;
}


Measured memory_bytes: 256
import re
S = list(input())
S2=''.join(S)
ans=0
cou=2
Ccou=0
A=S.count('A')
C=S.count('C')
jud = len(re.findall('[A-Z]', S2))
rep=len(S)-2
if S[0]=='A':
    ans=+1
rep=len(S)-2
for i in range(1,rep):
    if S[cou]=='C':
        Ccou=Ccou+1
    cou=cou+1
if Ccou == 1:
    ans=ans+1
if ans ==2 and A==1 and C==1 and jud==2:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3188
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    string s; cin >> s;
    print(s.substr(0, 3));

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#define reep(n1,n2,n3) for(int n1=n3;n1<n2;n1++)
#define rep(n1,n2) reep(n1,n2,0)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1e9
using namespace std;
typedef long long int lint;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int,int> > vp;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > pii;
typedef vector<string> vs;
const double PI  = acos(-1.0);
int main(){
    int a,b,c,d,l;
    cin>>l>>a>>b>>c>>d;
    cout<<l-max((a+c-1)/c,(b+d-1)/d)<<endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld\n",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define mod (int)(1e9 + 7) 

using namespace std;
double dp[301][301][301];

double dfs(int a, int b, int c, int N){
	if(a == 0 && b == 0 && c == 0)return 0.0;
	if(dp[a][b][c] > -0.5)return dp[a][b][c];
	double res = 0;
	double ks = (double)N / (a + b + c);
	if(a){
		res += (ks + dfs(a-1,b,c, N)) * (double)(a)/(a + b + c);		
	}
	if(b){
		res += (ks + dfs(a+1,b-1,c, N)) * (double)(b)/(a + b + c);
	}
	if(c){
		res += (ks + dfs(a,b+1,c-1, N)) * (double)(c)/ (a + b + c);
	}
	return dp[a][b][c] = res;
}

int main(){
	memset(dp, -1, sizeof(dp));
	int n;
	cin >> n;
	vector<int> a(n);
	cout << fixed << setprecision(15);
	int one = 0;
	int two = 0;
	int three = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] == 1)one++;
		if(a[i] == 2)two++;
		if(a[i] == 3)three++;
	}
	// dp[i][j][k] = expected no of operations with i 1's , j 2's , k 3's
	double res = dfs(one, two, three, n);
	cout << res << endl; 
	
}

Measured memory_bytes: 216812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

bool ok=true;
ll n,m,a[4];

void init(){
	cin>>n>>m;
	reg(i,1,n)a[i]=-1;
}

int main(void){
	init();
	rep(i,m){
		int s,c;
		cin>>s>>c;
		if(a[s]==-1){
			a[s]=c;
		}else{
			if(a[s]!=c)ok=false;
		}
	}
	if(ok){
		if(n==1){
			if(a[1]==-1){
				cout<<0;
			}else{
				cout<<a[1];
			}
			cout<<endl;
			return 0;
		}else{
			if(a[1]==0){
				cout<<-1<<endl;
				return 0;
			}
			if(a[1]==-1){
				cout<<1;
			}else{
				cout<<a[1];
			}
			reg(i,2,n){
				if(a[i]==-1){
					cout<<0;
				}else{
					cout<<a[i];
				}
			}
			cout<<endl;
			}
	}else{
		cout<<-1<<endl;
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    string s; cin >> s;
    int N = s.size();
    if(s == "keyence") {
        cout << "YES" << '\n';
        return 0;
    }
    rep(i, N) {
        REP(j, i, N) {
            string str = "";
            rep(k, N) {
                if(i <= k && k <= j) continue;
                else str.push_back(s[k]);
            }
            if(str == "keyence") {
                cout << "YES" << '\n';
                return 0;
            }
        }
    }
    cout << "NO" << '\n';
    return 0;
}

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

#define NIL -1
#define MAX 500001

typedef struct{
  int right;
  int left;
  int key;
  int parent;
} Node;

void Insert(Node*,int,int);
void PreOrder(Node*,int);
void InOrder(Node*,int);
void Find(Node*,int, int);
void Delete(Node*,int);
int Successor(Node*, int);

int main(void){
  int i, n, k, f, del, count=0;
  char state[8];
  Node T[MAX];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s", state);

    if(state[0] == 'i'){

      scanf("%d",&k);
      Insert(T, count, k);
      count++;

    } else if(state[0] == 'p'){

      if(count > 0){
        InOrder(T, 0);
        printf("\n");
        PreOrder(T, 0);
        printf("\n");
      }

    } else if(state[0] == 'f'){

      scanf("%d", &f);
      Find(T, f, 0);

    } else if(state[0] == 'd'){

      scanf("%d", &del);
      Delete(T, del);

    }
  }
  return 0;
}

void Insert(Node *T,int count, int k){
  int x, y;

  T[count].key = k;
  T[count].left = NIL;
  T[count].right = NIL;
  //T[count].parent = NIL;

  if(count == 0) return;

  x = 0;
  while(x!=NIL){
    y = x;

    if(k < T[x].key) x = T[x].left;
    else x = T[x].right;

  }

  T[count].parent = y;

  if(k < T[y].key) T[y].left = count;
  else T[y].right = count;

  return;
}

void PreOrder(Node *T, int u){

  if(u == NIL) return;

  printf(" %d", T[u].key);
  PreOrder(T, T[u].left);
  PreOrder(T, T[u].right);

  return;
}

void InOrder(Node *T, int u){

  if(u == NIL) return;

  InOrder(T, T[u].left);
  printf(" %d", T[u].key);
  InOrder(T, T[u].right);

  return;
}

void Find(Node *T, int f, int u){

  if(u == NIL) printf("no\n");
  else if(T[u].key == f) printf("yes\n");
  else if(T[u].key > f && T[u].left != NIL) Find(T, f, T[u].left);
  else Find(T, f, T[u].right);

  return;
}

void Delete(Node *T, int k){
  int x, y, z = 0;

  while(1){
    if(T[z].key == k) break;
    else if(k < T[z].key) z = T[z].left;
    else z = T[z].right;

  }

  if(T[z].left == NIL || T[z].right == NIL) y = z;
  else y = Successor(T, z);

  if(T[y].left != NIL) x = T[y].left;
  else x = T[y].right;

  if(x != -1) T[x].parent = T[y].parent;

  if(T[y].parent != NIL){
    if(y == T[T[y].parent].left) T[T[y].parent].left = x;
    else T[T[y].parent].right = x;
  }

  if(y != z) T[z].key = T[y].key;

  return;

}

int Successor(Node *T,int x){
  int y;

  if(T[x].right != NIL){
    x = T[x].right;
    while(T[x].left != NIL) x = T[x].left;
    return x;
  } else {
    y = T[x].parent;
    while(y != NIL && x == T[y].right){
      x = y;
      y = T[y].parent;
    }
    return y;
  }

}

Measured memory_bytes: 6956
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}


int main() {
    Int A,B,C,D;
    cin >> A >> B >> C >> D;

    Int aminus = A-1;
    Int underB = B-((B/C + B/D) - B/(C*D/GCD(C,D)) );
    Int underA = aminus - ((aminus/C + aminus/D) - aminus/(C*D/GCD(C,D)) );

    cout << underB - underA << endl;

    return 0;
}

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

using namespace std;

const int MX = 100000;

int main() {
	int n;
	ignore = scanf("%d", &n);
	vector<pair<int, int>> byL, byR;
	for (int i = 0, l, r; i < n; i++) {
		ignore = scanf("%d %d", &l, &r);
		byL.emplace_back(l, i);
		byR.emplace_back(r, i);
	}
	
	sort(byL.begin(), byL.end());
	sort(byR.begin(), byR.end());
	reverse(byL.begin(), byL.end());
	
	auto f = [](auto& a, auto& b, int d) -> long long {
		long long res = 0, p = 0;
		set<int> used;
		for (size_t i = 0, j = 0; i < a.size(); ) {
			while (i < a.size() && used.insert(a[i].second).second == false) i++;
			if (i == a.size()) break;
			if ((a[i].first < p) != (d < 0)) break;
			res += abs(a[i].first - p);
			p = a[i].first;
			
			while (j < b.size() && used.insert(b[j].second).second == false) j++;
			if (j == b.size()) break;
			if ((b[j].first < p) == (d < 0)) break;
			res += abs(b[j].first - p);
			p = b[j].first;
		}
		
		return res + abs(p);
	};
	
	long long ans = max(f(byL, byR, 1), f(byR, byL, -1));
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 6508
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n; cin >> n;
    int ans = 0;
    for (int a = 1; a < n; a++) {
        for(int b = 1; a*b <n ; b++) {
            // debug(a,b, a*b);
            if (a*b<n) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
    int i, flag=0;
    char s1[12], s2[12];
    scanf("%s", &s1);
    scanf("%s", &s2);

    for(i=0; s1[i] != NULL; i++){
        if(s1[i] != s2[i]){

            flag++;
        }
    }
    if(flag==0){
        printf("Yes\n");
    }
    else printf("No\n");

    return 0;
}


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

int input, num[11];

int main() {
	for (int i = 0; i < 3; i++) {
		cin >> input;
		num[input]++;
	}

	if (num[5] == 2 && num[7] == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
double x1,Y1,x2,y2,x3,y3;
double px, py,r;
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lf%lf%lf%lf%lf%lf",&x1,&Y1,&x2,&y2,&x3,&y3);
        double A1 =(x2*x2+y2*y2-x1*x1-Y1*Y1)*(y3-Y1);
        double B1 =(x3*x3+y3*y3-x1*x1-Y1*Y1)*(y2-Y1);
        double A2 =(x3*x3+y3*y3-x1*x1-Y1*Y1)*(x2-x1);
        double B2 =(x2*x2+y2*y2-x1*x1-Y1*Y1)*(x3-x1);
        double D = (x2-x1)*(y3-Y1)-(y2-Y1)*(x3-x1);
         px=(A1-B1)/D/2;
         py=(A2-B2)/D/2;
         r = sqrt((px-x1)*(px-x1)+(py-Y1)*(py-Y1));
        printf("%.3f %.3f %.3f\n",px,py,r);
    }
    return 0;
}

Measured memory_bytes: 2704
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll x, a, b;std::cin >> x >> a >> b;
  std::cout << (abs(x-a)<abs(x-b)?"A":"B") << '\n';
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> h(n);
    rep(i,n){
        cin >> h[i];
    }
    int ans=0;
    ans+=h[0];
    for(int i=1;i<n;i++){
        if(h[i]>h[i-1]){
            ans+=h[i]-h[i-1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// https://atcoder.jp/contests/abc167/tasks/abc167_c
func main() {

	var lines [][]string
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan() {
		lines = append(lines, strings.Split(stdin.Text(), " "))
	}

	// line 1 N札 M個 目標値
	// line over 2 値段 アルゴ理解度......
	books, _ := strconv.Atoi(lines[0][0])
	algo, _ := strconv.Atoi(lines[0][1])
	target, _ := strconv.Atoi(lines[0][2])

	var datas [][]int
	for i := 1; i < len(lines); i++ {
		var data []int
		for _, v := range lines[i] {
			num, _ := strconv.Atoi(v)
			data = append(data, num)
		}
		datas = append(datas, data)
	}

	// results[i][0] 金額, results[i][1....] 各アルゴの理解度
	// i は i番目の結果
	var results [][]int

	n := books
	// bitsがn個の要素の各パターンを表す
	for bits := 0; bits < (1 << uint64(n)); bits++ {
		// bitsの各要素についてのループ
		result := make([]int, algo + 1)
		for i := 0; i < n; i++ {
			// bitsのi個目の要素の状態がonかどうかチェック
			if (bits>>uint64(i))&1 == 1 {
				// 何かしらの処理
				for j, v := range datas[i] {
					result[j] += v
				}
			}
		}
		ok := true
		for i, v := range result {
			if i == 0 {
				continue
			}
			if v < target {
				ok = false
				break
			}
		}
		if ok {
			results = append(results, result)
		}
	}

	if len(results) == 0 {
		fmt.Println(-1)
	} else {
		sort.Slice(results, func(i, j int) bool {
			if results[i][0] < results[j][0] {
				return true
			} else {
				return false
			}
		})
		fmt.Println(results[0][0])
	}

}


Measured memory_bytes: 2572
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e4+10;
const ll MOD=1e9+7;

int D;
string K;
int N;
int s[MAX];
int sum[MAX];

ll dp[MAX][100];
ll ans;
void solve(){
    cin>>K;
    cin>>D;
    N=sz(K);
    rep(i,N){
      	s[i]=K[i]-'0';
      	sum[i+1]=(sum[i]+s[i])%D;
    }
  	
    rep(d,s[0]+1)dp[0][d%D]++;
    rep(i,N-1)rep(r,D){
        rep(d,10){
            if(d>s[i+1] && r==sum[i+1]) dp[i+1][(r+d)%D]=(dp[i+1][(r+d)%D]+dp[i][r]-1+MOD)%MOD;
            else dp[i+1][(r+d)%D]=(dp[i+1][(r+d)%D]+dp[i][r])%MOD;
        }
    }
    ans=(dp[N-1][0]-1+MOD)%MOD;
    cout<<ans<<endl;
}

int main(){
    solve();
}

Measured memory_bytes: 8192
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[][][] number = new int[4][3][10];

        for (int b = 0; b < 4; b++) {
            for (int f = 0; f < 3;f++) {
                for(int r = 0; r < 10;r++) {
                    number[b][f][r] = 0;
                }
            }
        }

        while(n != 0){
            String str[] = br.readLine().split(" ");
            int b = Integer.parseInt(str[0]) - 1;
            int f = Integer.parseInt(str[1]) - 1;
            int r = Integer.parseInt(str[2]) - 1;
            int v = Integer.parseInt(str[3]);

            number[b][f][r] += v;
            n--;
        }
        for(int b = 0; b < 4; b++){
            for(int f = 0; f < 3; f++){
                for(int r = 0; r < 10; r++){
                    System.out.print(" "+number[b][f][r]);
                }
                System.out.println("");
            }
            if(b != 3) System.out.println("####################");
        }
    }
}

Measured memory_bytes: 24392
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;

#define ll long long

void solve()
{
    string N;
    cin >> N;
    if (N.at(0) == '7' ||
        N.at(1) == '7' ||
        N.at(2) == '7')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return;
}

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


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};


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

	int n,m;
	cin >> n >> m;
	
	vector<int> es[n];
	int a,b;
	for(int i=0;i<m;i++){
		cin >> a >> b;
		a--;b--;
		es[a].push_back(b);
		es[b].push_back(a);
	}

	int d[n];
	d[0]=0;
	for(int i=1;i<n;i++) d[i] = INF;
	
	priority_queue<P,vector<P>,greater<P>> que;
	que.push(P(0,0));
	while(!que.empty()){
		P tmp = que.top(); que.pop();
		int cost=tmp.first,t=tmp.second;
		if(d[t] < cost) continue;
		for(int i=0;i<es[t].size();i++){
			int e=es[t][i];
			if(d[e] > cost+1){
				d[e] = cost+1;
				que.push(P(d[e],e));
			}
		}
	}
	cout << (d[n-1]<=2?"":"IM") << "POSSIBLE\n";

	return 0;
}

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

// 最大公約数 gcd
long long gcdTest(long long x, long long y) {
  if (y > x) swap(x, y);
  if (y == 0) return x;
  return gcdTest(y, x % y);
}

int main() {
  int K; cin >> K;
  long long ans =0;

  for (int a=1; a<=K; a++) {
    for (int b=1; b<=K; b++) {
      for (int c=1; c<=K; c++) {
        ans += gcdTest(a, gcdTest(b, c));
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
N = int(input())
A = list(map(int, input().split()))
B = [0]
for i in range(N):
    B.append(B[i] + A[i])

from collections import Counter
c = Counter(B)
ans = 0
for _, cnt in c.items():
    if cnt >= 2:
        ans += cnt * (cnt-1) // 2
print(ans)

Measured memory_bytes: 41580
#include<stdio.h>
int main(void){
    char S[3+1];
    scanf("%s",S);
    if((S[0]=='A')&&(S[1]=='A')&&(S[2]=='B')||(S[0]=='A')&&(S[1]=='B')&&(S[2]=='A')||(S[0]=='A')&&(S[1]=='B')&&(S[2]=='B')||(S[0]=='B')&&(S[1]=='A')&&(S[2]=='A')||(S[0]=='B')&&(S[1]=='A')&&(S[2]=='B')||(S[0]=='B')&&(S[1]=='B')&&(S[2]=='A')){
        printf("Yes\n");
    }else if((S[0]=='A')&&(S[1]=='A')&&(S[2]=='A')||(S[0]=='B')&&(S[1]=='B')&&(S[2]=='B')){
        printf("No\n");
    }
}

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

int main()
{
	int n,k,m,node,sum=0;
	cin>>n>>k;
	bool a[n+1]={false};
	
	while(k--)
	{
		cin>>m;
		while(m--)
		{
			cin>>node;
			a[node]=true;
		}
	}
	
	for(int i=1;i<=n;i++)
	 if(!a[i]) 
	  sum++;
	
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll q, h, s, d;
    cin >> q >> h >> s >> d;
    ll n;
    cin >> n;
    h = min(h, q * 2);
    s = min(s, h * 2);
    if(s * 2 <= d){
        cout << n * s << endl;
    }
    else{
        cout << (n / 2) * d + (n % 2) * s << endl;
    }
}

Measured memory_bytes: 256
#include <atcoder/all>
#include <iostream>

using namespace std;
using namespace atcoder;

int main(void) {
    int N, Q;
    cin >> N >> Q;

    dsu uf(N);

    while(Q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0) {
            uf.merge(u, v);
        } else {
            cout << uf.same(u, v) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4060
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T>
inline void chmax(T &a, const T &b) {
    if ((a) < (b)) (a) = (b);
}
template <class T>
inline void chmin(T &a, const T &b) {
    if ((a) > (b)) (a) = (b);
}

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x)    \
    sort(all(x)); \
    x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> iii;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
    }
} fast;
void check_input() {
    assert(cin.eof() == 0);
    int tmp;
    cin >> tmp;
    assert(cin.eof() == 1);
}

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"


int solve() {
    string s,t;cin>>s>>t;
    int n = sz(s);
    if (sz(t)==n+1 && s==t.substr(0, n)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3656
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`
 
 
				`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/
 
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())
	//https://atcoder.jp/contests/abc165/tasks/abc165_f
	//https://www.dropbox.com/sh/nx3tnilzqz7df8a/AAA0887IQFx5BcrZcrpRD7uga/ABC165/F?dl=0&subfolder_nav_tracking=1
 
	n := nextInt()
	a := nextInts(n)
 
	ans := -1
	f := true
	for ; f; ans++ {
		for i := 0; i < n; i++ {
			if a[i]%2 != 0 {
				f = false
				break
			}
			a[i] /= 2
		}
	}
 
	//	fmt.Fprintln(out, "[DEBUG]]", a)
	fmt.Fprintln(out, ans)
}
 
//------------------------------------------------------------------------------
 
// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
 
func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}
 
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}
 
func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

Measured memory_bytes: 640
#include <stdio.h>
 
int main(void){
  int a, b, ret;
  
  ret = scanf("%d %d", &a, &b);
  
  if(a >= 13){
    printf("%d\n", b);
  }else if(a >= 6 && a <= 12){
    printf("%d\n", b/2);
  }else{
    printf("0\n");
  }
  
  return 0;
}

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

int N;
map<int, int> m;

int main() {
    scanf("%d", &N);
    for(int i=0, x; i<N; i++) {
        scanf("%d", &x);
        m[x] = !m[x];
    }
    int ans = 0;
    for(auto it : m) ans += it.second;
    printf("%d\n", ans);
}


Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 配列
        String s = sc.next();
        String t = sc.next();

        int df = s.length() - t.length();
        int ans = 9999999;
        for (int i = 0;i <= df;i++){
            int dd = 0;
            for (int j = 0;j < t.length(); j++) {
                if(s.charAt(i + j) != t.charAt(j)) {
                    dd++;
                }
            }
            if(ans > dd) {
                ans = dd;
            }
        }
            System.out.println(ans);
    }
   
}



Measured memory_bytes: 35544
# C - Tsundoku
from bisect import bisect
from itertools import accumulate


def main():
    N, M, K, *AB = map(int, open(0).read().split())
    cum_A, cum_B = tuple(accumulate([0] + AB[:N])), tuple(accumulate(AB[N:]))
    candidates = [0]
    for i, a_time in enumerate(cum_A):
        if a_time > K:
            break
        b_time = K - a_time
        candidates.append(i + bisect(cum_B, b_time))
    print(max(candidates))


if __name__ == "__main__":
    main()


Measured memory_bytes: 55184
#include <bits/stdc++.h>
using namespace std;
const int N = 110, M = 100010;
int n, k, a[N], f[M] = {-1};
int dfs(int x)
{
    if (f[x])
        return f[x];
    bool flag = false;
    for (int i = 1; i <= n; i++)
        if (a[i] <= x && dfs(x - a[i]) == -1)
            flag = true;
    return f[x] = (flag ? 1 : -1);
}
int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++)
        scanf("%d", a + i);
    if (dfs(k) == 1)
        puts("First");
    else
        puts("Second");
    return 0;
}


Measured memory_bytes: 5376
// RAM RAM
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55
const int MOD=1000000007;
using namespace std;

int fact(int n); 
  
int nCr(int n, int r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
// Returns factorial of n 
int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 

int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);


    string a;cin>>a;

    int idx1=0;
    int idx=a.length()-1;
    for(int i=0;i<a.length();i++){
    	if(a[i]=='A'){
    		idx1=i;
    		break;
    	}
    }

	for(int i=a.length()-1;i>=0;i--){
    	if(a[i]=='Z'){
    		idx=i;
    		break;
    	}
    }    

    cout<<idx-idx1+1<<endl;
	return 0;
}

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

int pow(int n){

        int ans = 1;
        for(int i=0;i<n;i++){
            ans *= 10;
        }
    return ans;

}

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

    int total=0;
    int A;

    rep(i,N){
        cin >> A;
        total +=A;
    }

    if(H>total){
        cout << "No" << endl;
    }else{
        cout << "Yes" <<endl;
    }

    return 0;

}

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

int main(){
	ll n; cin >> n;
	ll a[n], b[n], c[n];
	for(int i = 0; i < n; ++i) cin >> a[i];
	for(int i = 0; i < n; ++i) cin >> b[i];
	for(int i = 0; i < n; ++i) cin >> c[i];
	ll aflag = 0, cflag = 0;
	ll ans = 0;
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	for(int i = 0; i < n; ++i){
		while(aflag < n && a[aflag] < b[i]) ++aflag;
		while(cflag < n && c[cflag] <= b[i]) ++cflag;
		ans += aflag * (n - cflag);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560