akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N-1);
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    REP(i,N-1) cin >> C[i];

    ll ans = 0;
    REP(i,N) {
        if(i != 0) {
            if (A[i] - A[i-1] == 1) ans += C[A[i-1]-1];
        }
        ans += B[A[i]-1];
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3600
#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);
  string s,t;
  cin >> s >> t;
  int ans=0;
  rep(i,3){
    if(s[i]==t[i])ans++;
  }
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ld a,b; cin>>a>>b;
    rep(i,10000){
        if((int)(i*0.08)==a && (int)(i*0.1)==b){
            cout<<i<<endl;
            break;
        }
        if(i==9999) cout<<-1<<endl;
    }
}

Measured memory_bytes: 384
import java.util.Scanner;


public class Main {

	static void init_array ( int[][] array ) {

		for ( int i = 0 ; i < array.length ; i++ ) {
			for( int j = 0 ; j < array[i].length ; j++ ) {
				array[i][j] = 0;
			}
		}
	}

	static void check_island ( int[][] map, int[][] serch_map, int serch_x, int serch_y ) {

		// その島の土地と面する海をサーチ済みにする

		int serch_cnt = 1;
		int[] serch_point_x= new int[70];
		int[] serch_point_y= new int[70];
		int[][] serch_stack_on = new int[14][14];
		int x,y;

		init_array ( serch_stack_on );

		serch_stack_on[serch_x][serch_y] = 1;

		while ( true ) {

			serch_cnt--;

			//右下左上（0123）の連続した土地をサーチ
			//未サーチの連続した土地をサーチポイントとしてスタックし
			//その土地がなくなるまで繰り返す
			//サーチポイントが重複しないようserch_stack_onで管理

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

				x = serch_x;
				y = serch_y;

				switch(i){
				case 0:
					x++;
					break;
				case 1:
					y++;
					break;
				case 2:
					x--;
					break;
				case 3:
					y--;
					break;
				}

				if ( serch_map[x][y] == 0 ) {
					if ( map[x][y] == 1 ) {
						if ( serch_stack_on[x][y] == 0 ) {
							serch_cnt++;
							serch_point_x[serch_cnt] = x;
							serch_point_y[serch_cnt] = y;
							serch_stack_on[x][y] = 1;
						}
					} else {
						serch_map[x][y] = 1;
					}
				}
			}

			//サーチ完了
			serch_stack_on[serch_x][serch_y]=0;
			serch_map[serch_x][serch_y] = 1;

			if ( serch_cnt == 0 ) {
				break;
			}

			serch_x = serch_point_x[serch_cnt];
			serch_y = serch_point_y[serch_cnt];

		}
	}

	public static void main(String[] args) {

		//島の数
		int island_num;
		String[] str_buf = new String[12];

		Scanner sc= new Scanner( System.in );

		int[][] map = new int[14][14];
		//サーチ状態　未:0　済:1
		int[][] serch_map = new int[14][14];

		while( sc.hasNext() ) {

			//データセット（数字）読み込み
			for ( int i = 0 ; i < 12 ; i++ ) {
				str_buf[i] =sc.next();
			}

			//初期化
			island_num = 0;
			init_array( serch_map );

			//mapセット mapを0で囲む serch_mapを1で囲む
			for ( int i = 0 ; i < map.length ; i++ ) {
				for ( int j = 0 ; j < map[i].length ; j++ ) {
					if( ( (i+1) % (map.length-1) ) == 1 || ( (j+1) % (map[i].length-1) ) == 1 ) {
						map[i][j]=0;
						serch_map[i][j]=1;
					}else {
						map[i][j]=Integer.parseInt( "" + str_buf[i-1].charAt( j-1 ) );
					}
				}
			}

			//サーチ処理
			for ( int i = 1 ; i < serch_map.length-1 ; i++ ) {
				for ( int j = 1 ; j < serch_map.length-1 ; j ++) {
					//未サーチの土地を発見時、島の数+1
					if( serch_map[i][j] == 0) {
						if( map[i][j] == 1 ) {
							island_num++;
							check_island( map, serch_map , i, j );
						} else {
							serch_map[i][j] = 1;
						}
					}
				}
			}

			System.out.println( island_num );

		}
		sc.close();
	}
}


Measured memory_bytes: 26456
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int x, a, b;
	cin >> x >> a >> b;
	int dist_a = abs(x-a);
	int dist_b = abs(x-b);

	if(dist_a < dist_b) cout << "A" << endl;
	else cout << "B" << endl;

	return 0;
}

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

typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl; 
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    //OJ;
    FIO;
    int x;
    cin>>x;
    if(x<30){
        cout<<"No\n";
    }
    else{
        cout<<"Yes\n";
    }
}

Measured memory_bytes: 3132
#include <stdio.h>
int main() {
	long long int w,h,x,y;
	scanf("%lld", &w);
	scanf("%lld", &h);
	scanf("%lld", &x);
	scanf("%lld", &y);
	printf("%lf ", (double)w*h/2.0);
	if (x*2==w && y*2==h) printf("1");
	else printf("0");
}

Measured memory_bytes: 128
input()
*a, = map(int, input().split())
input()
*b, = map(int, input().split())
c = {}
d = {}
for i in a:
    c[i] = c.get(i, 0)+1
for i in b:
    d[i] = d.get(i, 0)+1
if all(c.get(i, 0) >= d[i] for i in d.keys()):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 56788
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <cmath>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
    int K;
    cin >> K;
    int a[] = {
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    };
    cout << a[K-1] << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;

int main(){
    int n;  cin >> n;
    map<pair<string, int>, int> v; 
    for(int i=0; i<n; i++){
        string s;   cin >> s;
        int score;  cin >> score;
        v[{s, -score}] = i+1;
    }
    
    for(auto x: v){
        cout << x.second << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for( int i = 0; i < n; i++)
using namespace std;
using ll = unsigned long long;
int main()
{
    
    double n, k;
    cin >> n >> k ;
   
    double ans = 0.0L;
    rep(i,int(n)){
      int tmp   = int(i+1);
      double count = 1.0L;
      while( tmp < k ){
          tmp *= 2;
          count/=2.0L;
      }
      ans += 1.0L / n * count;
    }
    
    //printf("%16.11Le",ans);
    printf("%.12f\n",ans);

    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    char X, Y;
    cin >> X >> Y;

    if (X < Y) {
        cout << "<";
    } else if (X > Y) {
        cout << ">";
    } else {
        cout << "=";
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,n;
  cin>>n;
  a=n%60;
  b=n/60%60;
  c=n/60/60%60;
  cout<<c<<":"<<b<<":"<<a<<'\n';
  return(0);
}



Measured memory_bytes: 3112
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

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

		a[i]--;
	}

	int ret = 0;
	vector<bool> table(N, false);
	for(int index=0; index!=1; index=a[index], ret++)
	{
		if(table[index] == true)
		{
			ret = -1;
			break;
		}

		table[index] = true;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 640
#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>
//#include <bits/stdc++.h>

#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=998244353;
const int MAXN=200055;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
struct enode{ int u,v,c; } e[100];
int main()
{
	int n=read(),num=0,mx=1,p=n;
	while (n>1)
	{
		e[++num]=(enode){mx,mx+1,n/2};
		e[++num]=(enode){mx,mx+1,0};
		if ((n/2)%2==1&&n/2-1>0) e[++num]=(enode){mx+1,0,n/2-1};
		n/=2,mx++;
	}
	if (p&1) e[++num]=(enode){1,mx,p-1};
	int t=num;
	for (int i=1;i<=t;i++) if (e[i].v==0) e[i].v=mx;
	printf("%d %d\n",mx,num);
	for (int i=1;i<=t;i++) printf("%d %d %d\n",e[i].u,e[i].v,e[i].c);
	return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include <cmath>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	int x[101];
	for (int i(0); i < n; i++) {
		cin >> x[i];
	}
	//最小の座標と最大の座標を求める
	int min(x[0]);
	int max(x[0]);
	for (int i(1); i < n; i++) {
		if (min > x[i])min = x[i];
		if (max < x[i])max = x[i];
	}
	//重心の位置から中間の座標までの体力の総和を求める
	int power_total(10000000);
	int tmp_num;
	for (int i(min); i <= max; i++) {
		int tmp_power_total(0);
		for (int j(0); j < n; j++) {
			tmp_power_total += pow(x[j] - i, 2);
		}
		if (power_total > tmp_power_total)power_total = tmp_power_total;
	}
	cout << power_total << endl;
	return 0;
}

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

int main(){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;

  if ( abs(a-b) <= k & abs(a-c) <= k & abs(a-d) <= k & abs(a-e) <= k & abs(b-c) <= k & abs(b-d) <= k & abs(b-e) <= k & abs(c-d) <= k & abs(c-e) <= k & abs(d-e) <= k ){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

signed main(void){
    int N;
    string S[214514];
    cin >> N;
    REP(i,N){
        cin >> S[i];
    }
    sort(S,S+N);
    
    int Ans=0;
    REP(i,N){
        if(i==N-1 || S[i]!=S[i+1]){
            Ans++;
        }
    }
    cout << Ans << endl;
    
    return 0;
}



Measured memory_bytes: 10340
import math
while True:
    l = 0; r = []
    try:
        inp = map(int, raw_input().split())
        l = inp[0]
        r = inp[1:]
    except EOFError:
        break
    n = len(r)
    if 2*sum(r) <= l:
        print "OK"
    else:
        s = []
        if n>1:
            r.sort()
            for i in xrange(n/2):
                s = [r[i]] + s[::-1] + [r[-i-1]]
            if n&1:
                if abs(s[0]-r[n/2]) < abs(s[-1]-r[n/2]):
                    s.append(r[n/2])
                else:
                    s = [r[n/2]] + s
        else:
            s = r
        ans = s[0] + s[-1]
        for i in xrange(n-1):
            ans += 2*math.sqrt(s[i]*s[i+1])
        print "OK" if ans < 0.000000001+l else "NA"

Measured memory_bytes: 4432
from collections import deque
''' 
INF = float('inf')
MOD = 10 ** 9 + 7
'''
## ここは１つにまとめれる
# dy = (0, -1, 0, 1)
# dx = (1, 0, -1, 0)
d=[(1,0),(0,1),(-1,0),(0,-1)]

    
H,W=map(int,input().split())
M = []
Max_list = []
for i  in range(H):
    t = input()
    M.append(t)
dist = [[-1]*W for _ in range(H)]
q = deque()
for i in range(H):
    for j in range(W):
        dist = [[-1]*W for _ in range(H)]
        if M[i][j] == '.':
            Ma = 0
            q.append((i, j))
            dist[i][j] = 0
            while q:
                cx,cy = q.popleft()
                for nx,ny in d:
                    x ,y= cx+nx,cy+ny
                    ''' ここの処理がをnotにしてわかりやすく
                    if x<0 or y<0 or x>=H or y>=W or dist[x][y]>0:
                        continue
                    '''
                    '''
                    if 0<= x < H and 0<= y < W and dist[x][y]<=0:
                    '''
                    if 0<= x < H and 0<= y < W and M[x][y] == "." and dist[x][y]==-1:
                        dist[x][y]=dist[cx][cy]+1
                        Ma = max(Ma,dist[x][y])
                        q.append((x,y))
            Max_list.append(Ma)

print(max(Max_list))

Measured memory_bytes: 3316
#if 0
????????£????????????15m
size_t????????£?????°?¢??????????????????£?????´??°N????????????????????????
#endif

#include <iostream>
#include <string>
#include <map>
using namespace std;

map<string,int> table;
int main(){
	string word, M_frequent, longest;
	size_t N=0; //?????§???????????????????????????????????°
	while(cin>>word){
		table[word]++;
		if(table[word]>N){
			N=table[word];
			M_frequent=word;
		}
		if(word.size()>longest.size())
			longest=word;
	}
	cout<<M_frequent<<" "<<longest<<endl;
}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define INF 1e16
#define mod 1e9+7


int main() {
  str s;
  cin>>s;
  vll count(3,0);
  ll ans=0;
  FOR(i,0,s.sz){
    if(s[i]=='A'){
      if(count[1]==0){
        count[0]++;
      }
      else{
        count[0]=0;
        count[1]=0;
        count[0]++;
      }
    }
    if(s[i]=='B'){
      if(count[0]>0){
        if(count[1]<1){
          count[1]++;
        }
        else{
          count[0]=0;
          count[1]=0;
        }
      }
    }
    if(s[i]=='C'){
      if(count[0]>0){
        if(count[1]==1){
          ans+=count[0];
          count[1]=0;
        }
        else{
          count[0]=0;
          count[1]=0;
        }
      }
    }
 //co(count[0]<<' '<<count[1]<<' '<<ans);
  }
  co(ans);
}
          

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll K;
    cin >> K;

    REP(i, K){
        cout << "ACL";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int n,m,fcount=0;
int fans[1005][1005];
char a[1005][1005];
int visited[1005][1005];
queue<pair<int,int>>q;
void dfs(int i,int j)
{
    if(i>=0 && i<n && j>=0 && j<m && a[i][j]=='.' && visited[i][j]==0)
    {
    fans[i][j]=fcount;
    visited[i][j]=1;
    pair<int,int>p;
    p.first=i;
    p.second=j;
    q.push(p);
    dfs(i,j+1);
    dfs(i,j-1);
    dfs(i-1,j);
    dfs(i+1,j);
    }
    else
    return;
}
int main() {
    int i,j,k;
  cin>>n>>m;
  int x1,x2,y1,y2;
  cin>>x1>>y1>>x2>>y2;
  for(i=0;i<n;i++)
  for(j=0;j<m;j++)
  cin>>a[i][j],fans[i][j]=-1;
  dfs(x2-1,y2-1);
  while(!q.empty()){
      fcount++;
      int sz=q.size();
      for(i=0;i<sz;i++)
      {
         pair<int,int>p;
         p=q.front();
         q.pop();
         int xc=p.first;
         int yc=p.second;
         for(j=xc-2;j<=xc+2;j++)
         for(k=yc-2;k<=yc+2;k++)
         {
             dfs(j,k);
         }
      }
  }
  cout<<fans[x1-1][y1-1];
  
    
}

Measured memory_bytes: 12444
#include<iostream>
using namespace std;
int main(){
  long long N,M,a,b,count=0;
  cin>>N>>M;
  long long H[N],t[N]={};
  for(int k=0;k<N;k++){
    cin>>H[k];
  }
  for(int k=0;k<M;k++){
    cin>>a>>b;
    if(H[a-1]==H[b-1]) t[a-1]=1,t[b-1]=1;
    else if(H[a-1]>H[b-1]) t[b-1]=1;
    else t[a-1]=1;
  }
  for(int k=0;k<N;k++){
    if(t[k]==0) count+=1;
  }
  cout<<count;
}

Measured memory_bytes: 5192
import math
from functools import lru_cache

X = int(input())

@lru_cache(maxsize=None)
def rfn(n):
    if n == 1:
        return 101
    else:
        return math.floor(rfn(n-1)*1.01)

for i in range(1, 10000):
    if rfn(i) >= X:
        print(i)
        break

Measured memory_bytes: 9924
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d=0;
	scanf("%d""/""%d""/""%d",&a,&b,&c);
	d=a*10000+b*100+c;
	if(d<=20190430) cout<<"Heisei";
	else
	cout<<"TBD";
	return 0; 
}


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

int main()
{
	int n,KO,ACE=0;
	cin>>n>>KO;
	int a[KO+1];
	
	for(int i=1; i<=KO; i++)
	{
		cin>>a[i];
		ACE+=a[i];
	}
	
	if(ACE>=n)
		cout<<"Yes"<< endl;
	else
		cout<<"No"<< endl;

	return 0;
}

Measured memory_bytes: 640
function main (input) {
  const a = parseInt(input.split(' ')[0],10);
  const b = parseInt(input.split(' ')[1],10);
  const c = parseInt(input.split(' ')[2],10);
  const d = parseInt(input.split(' ')[3],10);

  if (d >= Math.abs(a-c)) {
    console.log('Yes');
  } else {
    if (d >= Math.abs(b-c)) {
      if (d >= Math.abs(a-b)) {
        console.log('Yes');
      } else {
        console.log('No');
      }
    } else {
      console.log('No');
    }
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>
#include <list>
#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(ll i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(ll i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(ll i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(ll i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

ll fact(ll n){
  ll res=1;
  while(n>=0){
    res*=n;
    n--;
  }
  return res;
}
    
ll pow(ll i, ll n){
  ll res=1;
  while(n>=0){
    res*=i;
    n--;
  }
  return res;
}

ll gcd(ll l, ll r){
  if(l<r){
    return gcd(r, l);
  }
  if(r == 0){
    return l;
  }
  return gcd(r, l % r);
}

template<class T>
vector<T> accum_sum(vector<T> a){
  vector<T> b(a.size() + 1);
  b[0] = a[0];
  rep(i, a.size()){
    b[i + 1] = b[i] + a[i];
  }
  return b;
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(n);
  list<ll> a;
  
  bool before;
  if(n % 2){
    before = true;
  }else{
    before = false;
  }
  
  rep(i, n){
    ll x;
    cin >> x;
    if(before){
      a.push_front(x);
    }else{
      a.push_back(x);
    }
    before = !before;
  }
  rep(i, n){
    cout << a.front() << " ";
    a.pop_front();
  }
  cout << endl;
}
#endif


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

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

	long long ll = 0;

	while(n != 0) {
		if(n % 3 == 0 || n % 5 == 0) {
		} else {
			ll += n;
		}
		n--;
	}

	cout << ll << endl;

    return 0;
}


Measured memory_bytes: 3624
N=2*10**5+7
n,k=map(int,input().split())
List=list(map(float,input().split()))
for i in range(n):
    List[i]=(1+List[i])/2
for i in range(1,n):
    List[i]+=List[i-1]
ans=0.0
for i in range(0,n-k+1):
    #ans=max(ans,List[i+k-1]-List[max(0,i-1)])
    if i==0 :
        ans=max(ans,List[i+k-1])
    else :
        ans=max(ans,List[i+k-1]-List[i-1])
print("{:.12f}".format(ans))


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

using namespace std;

int main(){
    int X;
    while(cin >> X){
        vector<int> valid(X+1, 0);
        valid[0] = 1;
        for(int i=100;i<=105;i++){
            for(int j=0;j+i<=X;j++){
                if(valid[j]) valid[j+i] = 1;
            }
        }
        cout << valid[X] << endl;
    }
}

Measured memory_bytes: 640
import math
while True:
    n=int(input())
    if n==0:
        break
    else:
        a=list(map(int,input().split()))
        m=sum(a)/n
        l=0
        for i in range(n):
            l+=(a[i]-m)**2
        b=math.sqrt(l/n)
        print("{:.8f}".format(b))


Measured memory_bytes: 5700
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int K, S, count=0;

  cin >> K >> S;

  for(int x = 0; x <= K; x++){
    for(int y = 0; y <= K; y++){
      int z = S - x - y;
      if(0 <= z && z <= K) count++;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int n,k,i,j,max,a,b,cnt;
  int x[]={0,1,1,1};
  int y[]={1,1,0,-1};
  char str[256][256];
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    max=0;
    for(i=0;i<n;i++){
      scanf("%s",str[i]);
    }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(str[i][j]=='1'){
	  for(k=0;k<4;k++){
	    for(cnt=1,a=i+x[k],b=j+y[k];a>=0&&b>=0&&a<n&&b<n;a+=x[k],b+=y[k],cnt++){
	      if(str[a][b]=='0')break;
	    }
	    if(cnt>max){
	      max=cnt;
	    }
	  }
	}
      }
    }
    printf("%d\n",max);
  }
  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<pair<double, double> > p(n);
    rep (i, n) cin >> p[i].first;
    rep (i, n) cin >> p[i].second;
    double d1 = 0, d2 = 0, d3 = 0;
    double maxi = -Inf;
    rep (i, n) {
        double tmp = abs(p[i].first - p[i].second);
        d1 += tmp;
        d2 += tmp * tmp;
        d3 += tmp * tmp * tmp;
        maxi = max(maxi, tmp);
    }
    cout << fixed << setprecision(9);
    cout << d1 << endl << sqrt(d2) << endl << pow(d3, (double)1 / 3) << endl << maxi << endl;    
    return 0;
}




Measured memory_bytes: 3508
#include<complex>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cassert>
#include<set>
using namespace std;
#define REP(i,b,n ) for(int i=b;i<n;i++)
#define rep(i,n)    REP(i,0,n)

const int N = 300001;

bool isok(int a,vector<int> &all){
  rep(i,all.size()){
    if (a%all[i] == 0)return false;
    if ((long long)(all[i])*all[i] > a)break;
  }
  return true;
}

void make(vector<int> &all){
  for(int i=2;i<N;i++){
    if (i%7 == 1 || i%7 == 6){
      if (isok(i,all))all.push_back(i);
    }
  }
}

main(){
  vector<int> all;
  make(all);
  int n;
  while(cin>>n && n != 1){
    cout << n <<":";
    rep(i,all.size()){
      if (n%all[i] == 0)cout <<" " << all[i];
      if (n < all[i])break;
    }
    cout << endl;
  }
  return false;
}

Measured memory_bytes: 1176
#include<stdio.h>
int int_comp(const void *_a, const void *_b){
  int a = *(int *)_a;
  int b = *(int *)_b;
  if (a < b) {
    return -1;
  } else if (a > b) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  int V,d,count=0;
  while(scanf("%d%d",&V,&d) != EOF) {
    int i,fib[V],j;
    fib[0]=2,fib[1]=3;
    for(i=2; i<V; i++) fib[i] = ((j = fib[i-1]+fib[i-2])>1001)? (j-1001):j;
    qsort(fib,V,sizeof(int), int_comp);
    for(i=1; i<V; i++)
      if((fib[i] - fib[i-1]) >= d) count++;
    printf("%d\n",++count);
    count=0;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void) {

	int N;
	int A[100];
	double sum = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	for (int i = 0; i < N; i++) {
		sum += (double)1 / A[i];
	}
	printf("%lf", (double)1/sum);
	
	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<"\n";
int n,k;
vector<int>v;
vector<int>dp(1e5+1,-1);

int cal(int idx){
    //debug(idx);
    if(idx+1==n)
        return 0;
    if(idx>=n)
    return 1e9;
    if(dp[idx]+1)
        return dp[idx];
    int mn=1e9;
    for(int x=1;x<= k;x++){
        if(idx+x>=n)break;
        mn=min(mn,abs(v[idx]-v[idx+x])+cal(idx+x));

    }
    return dp[idx]=mn;


}
int main()
{
   cin>>n>>k;
   v.resize(n);
   for(auto &f:v)
        cin>>f;
    cout<<cal(0);


    return 0;
}


Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int i = sc.nextInt();
    int j = sc.nextInt();

    int c = 0;
    if ((j - 1) % (i - 1) == 0) {
      c = (j - 1) / (i - 1);
    } else {
      c = (j - 1) / (i - 1) + 1;
    }

    System.out.println(c);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll N, M, K;
vi A, B;
vi C, D;

struct UnionFind
{
    vector<int> data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k)
    {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k)
    {
        return (-data[find(k)]);
    }
};

int main()
{
    cin >> N >> M >> K;
    A = vi(M);
    B = vi(M);
    REP(i, M)
    {
        cin >> A[i] >> B[i];
    }
    C = vi(K);
    D = vi(K);
    REP(i, K)
    {
        cin >> C[i] >> D[i];
    }

    UnionFind u(N + 1);
    vi cnt = vi(N + 1);
    REP(i, M)
    {
        u.unite(A[i], B[i]);
        ++cnt[A[i]];
        ++cnt[B[i]];
    }
    REP(i, K)
    {
        if (u.find(C[i]) == u.find(D[i]))
        {
            ++cnt[C[i]];
            ++cnt[D[i]];
        }
    }
    for (ll i = 1; i < N; ++i)
    {
        ll ans = u.size(i) - 1 - cnt[i];
        cout << ans << " ";
    }
    ll ans = u.size(N) - 1 - cnt[N];
    cout << ans << endl;
}


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

int main(){
	int L,A,B,C,D,max,l,i,a=0,b=0;
	scanf("%d %d %d %d %d",&L,&A,&B,&C,&D);
	for(i = 0;i<L;i++){
		if(A>0){
			A = A-C;
			a = a+1;
		}
		if(B>0){
			B = B-D;
			b = b+1;	
		}
	}
	max = fmax(a,b);
	l = L-max;
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> sum(n, 0);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll cnt = 1;
  for (ll i = 0; i < a.size(); i++) {
    if (i != 0) {
      sum[i] += sum[i - 1] + a[i];
    } else {
      sum[i] = a[i];
    }
  }
  for (ll i = n - 2; i >= 0; i--) {
    if (a[i] * 2 >= a[n - 1]) {
      cnt++;
    } else {
      if (sum[i] * 2 >= a[i + 1]) {
        cnt++;
      } else {
        break;
      }
    }
  }
  cout << cnt << endl;
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


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

  map<lint,lint> odd,evn;
  for(lint i=0;2*i<n;i++) { odd[v[2*i]]++; evn[v[2*i+1]]++; }

  lint ans=0;
  pair<lint,lint> oddpair_max0,oddpair_max1, evnpair_max0,evnpair_max1;
  for(map<lint,lint>::iterator itr=odd.begin();itr!=odd.end();itr++) {
    if(itr->second > oddpair_max1.second) {
      oddpair_max1 = *itr;
      if(oddpair_max1.second > oddpair_max0.second) { swap(oddpair_max0, oddpair_max1); }
    }
  }

  for(map<lint,lint>::iterator itr=evn.begin();itr!=evn.end();itr++) {
    if(itr->second > evnpair_max1.second) {
      evnpair_max1 = *itr;
      if(evnpair_max1.second > evnpair_max0.second) { swap(evnpair_max0, evnpair_max1); }
    }
  }

  if(oddpair_max0.first != evnpair_max0.first) { ans = n-oddpair_max0.second-evnpair_max0.second; }
  else { ans = n-max(oddpair_max0.second+evnpair_max1.second, oddpair_max1.second+evnpair_max0.second); }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
using namespace std;
int gcd(int a,int b){
    if(a < b) swap(a,b);
    if(b == 0) return a;
    else return gcd(b, a%b);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,x;
    cin >> n >> x;
    vector<int> y(n); for(int i = 0; i < n; ++i) cin >> y[i];
    int gcdx = abs(x-y[0]),gcdy = (n >= 2)?abs(y[0]-y[1]):0;
    for(int i = 0; i < n-1; ++i){
        gcdy = gcd(gcdy, abs(y[i]-y[i+1]));
    }
    for(int i = 0; i < n; ++i){
        gcdx = gcd(gcdx, abs(x - y[i]));
    }
    cout << gcd(gcdx,gcdy) << endl;
    return 0;
}

Measured memory_bytes: 3664
n = int(input())
a = list(map(int, input().split()))

multiple4 = 0
multiple2 = 0
odds = 0

for ai in a:
    if ai % 4 == 0:
        multiple4 += 1
    elif ai % 2 == 0:
        multiple2 += 1
    else:
        odds += 1

if multiple4 == 0:
    if odds == 0:
        print('Yes')
    else:
        print('No')
elif multiple4 >= odds or multiple4 + 1 == odds and multiple2 == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int N = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N+1];
		int sum = 0;
		int ans = 0, pre = 0;

		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		b[0] = 0;
		for (int i = 1; i <= N; i++) {
			b[i] = sc.nextInt();
			sum += b[i];
		}
		
		ans = sum;
		
		for (int i = 0; i < N; i++) {
			ans = ans + a[i] - b[i];
			if (ans > pre) {
				pre = ans;
			}
		}

		System.out.println(pre);

		sc.close();
	}
}


Measured memory_bytes: 23124
package main

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

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	A := make([][]int, 3)
	for i := range A {
		a1, a2, a3 := readInt3()
		A[i] = []int{a1, a2, a3}
	}
	success := [][]int{
		A[0], A[1], A[2],
		[]int{A[0][0], A[1][0], A[2][0]},
		[]int{A[0][1], A[1][1], A[2][1]},
		[]int{A[0][2], A[1][2], A[2][2]},
		[]int{A[0][0], A[1][1], A[2][2]},
		[]int{A[0][2], A[1][1], A[2][0]},
	}

	N := readInt()
	b := make([]int, N)
	for i := 0; i < N; i++ {
		b[i] = readInt()
	}

	for i := range success {
		if check(success[i], b) {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")

}

func check(l []int, b []int) bool {
	m := make(map[int]struct{})
	for i := range b {
		m[b[i]] = struct{}{}
	}

	for i := range l {
		if _, ok := m[l[i]]; !ok {
			return false
		}
	}

	return true
}


Measured memory_bytes: 640
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int n;

void upd(vector<int> &num){
	num[n-1]++;
	int ptr = n-1;
	while(num[ptr] == 10){
		num[ptr] = 0;
		num[ptr-1]++;
		ptr--;
	}
	ptr = 0;
	while(num[ptr] == 0) ptr++;
	for(int i = n-1; i > ptr; --i){
		if(num[i-1] < num[i]-1){
			num[i-1]++;
			num[i] = num[i-1]-1;
			REP(j,i+1,n) num[j] = max(num[j-1]-1,0);
		}else if(num[i-1] > num[i]+1){
			REP(j,i,n) num[j] = max(num[j-1]-1,0);
		}
	}
}

int main(){

	fastio;
	int k;
	cin >> k;
	n = 15;
	vector<int> num(n,0);
	num[n-1] = 0;
	while(k--){ 
		upd(num);
	}

	int ptr = 0;
	while(num[ptr] == 0) ptr++;
	REP(i,ptr,n) cout << num[i]; cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<bitset>
using namespace std;
vector<int>G[501000], P[510], E[501000], F[501000];
int Q[510000], Deg[510000];
bitset<500>D[510000];
int n, cnt, cur, m;
int v[510000], Last[510];
void Make(int a, int t){
    P[a].push_back(cnt);
    cnt++;
}
void Put(int a, int b){
    E[a].push_back(b);
    F[b].push_back(a);
}
void Make_Edge(int a, int ca, int b, int cb){
    Put(a*2+ca, b*2+cb);
    Put((b*2+cb)^1, (a*2+ca)^1);
}
int SCC[501000], ord[501000], cc;
void DFS(int a){
    int i;
    v[a]=1;
    for(i=0;i<E[a].size();i++)if(!v[E[a][i]])DFS(E[a][i]);
    ord[++cc] = a;
}
void DFS2(int a){
    int i;
    SCC[a] = cc;
    for(i=0;i<F[a].size();i++)if(!SCC[F[a][i]])DFS2(F[a][i]);
}
void Make_SCC(){
    int i, j;
    for(i=0;i<m;i++){
        if(!v[i]){
            DFS(i);
        }
    }
    cc = 0;
    for(i=m;i>=1;i--){
        if(!SCC[ord[i]]){
            cc++;
            DFS2(ord[i]);
        }
    }
    for(i=1;i<=n;i++){
        D[SCC[Last[i]*2+1]][i] = 1;
    }
    for(i=0;i<m;i++){
        for(j=0;j<E[i].size();j++){
            if(SCC[i]!=SCC[E[i][j]])G[SCC[i]].push_back(SCC[E[i][j]]), Deg[SCC[E[i][j]]]++;
        }
    }
    int head = 0, tail = 0;
    for(i=1;i<=cc;i++){
        if(!Deg[i])Q[++tail] = i;
    }
    while(head < tail){
        int x = Q[++head];
        for(i=0;i<G[x].size();i++){
            int y = G[x][i];
            D[y] |= D[x];
            Deg[y]--;
            if(!Deg[y])Q[++tail] = y;
        }
    }
}
int main(){
    int i, a, b, j, mm;
    scanf("%d%d",&n,&mm);
    for(i=1;i<=n;i++){
        Make(i, 0);
    }
    for(i=1;i<=mm;i++){
        scanf("%d%d",&a,&b);
        Make(a, i);
        Make(b, i);
        int pa = P[a][P[a].size()-2], pb = P[b][P[b].size()-2];
        int cura = P[a][P[a].size()-1], curb = P[b][P[b].size()-1];
        Make_Edge(pa, 0, curb, 0);
        Make_Edge(pb, 0, cura, 0);
        Make_Edge(cura, 1, curb, 0);
    }
    for(i=1;i<=n;i++)Make(i, mm+1);
    for(i=1;i<=n;i++){
        for(j=0;j<P[i].size()-1;j++){
            Make_Edge(P[i][j], 0, P[i][j+1], 0);
        }
        Last[i] = P[i][P[i].size()-1];
    }
    m = cnt*2;
    Make_SCC();
    int res = 0;
    for(i=1;i<=n;i++){
        for(j=i+1;j<=n;j++){
            if(!D[SCC[Last[i]*2]][j]&&!D[SCC[Last[j]*2]][i]&&!D[SCC[Last[i]*2]][i]&&!D[SCC[Last[j]*2]][j]){
                res++;
            }
        }
    }
    printf("%d\n",res);
}

Measured memory_bytes: 111488
N, K = map(int, input().split())
if N < K:
    prob = 0
    # サイコロの得点がKより小さい場合
    S = min(N+1, K)
    for i in range(1, S):
        counter = 0
        while True:
            counter += 1
            i *= 2
            if i >= K:
                break
        prob += 0.5 ** counter * (1/N)
    print(prob)
else:
    prob = (N-K+1)/N
    S = min(N+1, K)
    for i in range(1, S):
        counter = 0
        while True:
            counter += 1
            i *= 2
            if i >= K:
                break
        prob += 0.5 ** counter * (1/N)
    print(prob)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair<int, int> P;

struct edge {
	int to, cap, cost, rev;
};

int V;
vector<edge> G[50200];
int h[50200], dist[50200];
int prevv[50200], preve[50200];

void addEdge(int from, int to, int cap, int cost)
{
	G[from].push_back((edge){to, cap, cost, G[to].size()});
	G[to].push_back((edge){from, 0, -cost, G[from].size() - 1});
}

int minCostFlow(int s, int t, int f)
{
	int res = 0;
	fill(h, h + V, 0);
	while (f > 0){
		priority_queue<P, vector<P>, greater<P> > pq;
		fill(dist, dist + V, 1000000000);
		dist[s] = 0; pq.push(P(0, s));
		while (!pq.empty()){
			P p = pq.top(); pq.pop();
			int v = p.second;
			if (dist[v] < p.first) continue;
			for (int i = 0; i < G[v].size(); i++){
				edge &e = G[v][i];
				if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
					dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
					prevv[e.to] = v;
					preve[e.to] = i;
					pq.push(P(dist[e.to], e.to));
				}
			}
		}
		
		if (dist[t] == 1000000000) return (-1);
		for (int v = 0; v < V; v++) h[v] += dist[v];
		
		int d = f;
		for (int v = t; v != s; v = prevv[v]){
			d = min(d, G[prevv[v]][preve[v]].cap);
		}
		f -= d;
		res += d * h[t];
		for (int v = t; v != s; v = prevv[v]){
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}
	}
	return (res);
}

int getDist(string s, string t)
{
	int dp[32][32];
	for (int i = 0; i <= s.size(); i++) dp[i][0] = i;
	for (int i = 0; i <= t.size(); i++) dp[0][i] = i;
	
	for (int i = 1; i <= s.size(); i++)
		for (int j = 1; j <= t.size(); j++)
			dp[i][j] = min(min(dp[i - 1][j] + 1, dp[i][j - 1] + 1),
							dp[i - 1][j - 1] + (s[i - 1] != t[j - 1]));
	return (dp[s.size()][t.size()]);					
}

int main()
{
	int N, M;
	vector<string> S, T;
	map<string, int> c;
	scanf("%d %d", &N, &M);
	getchar();
	
	for (int i = 0; i < N; i++){
		char st[1024], *p;
		fgets(st, sizeof(st), stdin);
		p = strtok(st, " \n");
		while (p != NULL){
			S.push_back((string)p);
			if (c.count((string)p) == 0) c[(string)p] = 0;
			c[(string)p]++;
			p = strtok(NULL, " \n");
		}
	}
	
	sort(S.begin(), S.end());
	S.erase(unique(S.begin(), S.end()), S.end());
	
	for (int i = 0; i < M; i++){
		char st[1024];
		scanf("%s", st);
		T.push_back((string)st);
	}
	
	sort(T.begin(), T.end());
	T.erase(unique(T.begin(), T.end()), T.end());
	
	V = S.size() + T.size() + 2;
	
	for (int i = 0; i < S.size(); i++){
		addEdge(0, i + 1, 1, 0);
		for (int j = 0; j < T.size(); j++){
			addEdge(i + 1 , S.size() + j + 1, 1, c[S[i]] * getDist(S[i], T[j]));
			if (!i) addEdge(S.size() + j + 1, S.size() + T.size() + 1, 1, 0);
		}
	}
	
	printf("%d\n", minCostFlow(0, S.size() + T.size() + 1, S.size()));
	
	return (0);
}

Measured memory_bytes: 10140
#include<bits/stdc++.h>
#define INF 1e18
#define int long long
using namespace std;
typedef pair<int,int> P;

struct Graph{
  Graph(int n):E(n),d(n){};
  vector<vector<P>>E;
  vector<int>d;
  void add_edge(int a,int b,int c){
    E[a].push_back({b,c});
  }
  bool bellmanFord(int s,int t){
    int N=d.size();
    fill(d.begin(),d.end(),INF);
    d[s]=0;
    for(int i=0;i<N;++i)
      for(int j=0;j<N;++j)
        for(P& p:E[j])
          if(d[j]!=INF&&d[j]+p.second<d[p.first]){
            d[p.first]=d[j]+p.second;
            if(i==N-1&&p.first==t)return false;
            //if check after destination route
            // if(i==N-1)return false;
          }
    return true;
  }
  int get_cost(int n){
    return d[n];
  }
};

main(){
  int n,m,a,b,c;
  cin>>n>>m;
  Graph G(n);
  for(int i=0;i<m;++i){
    cin>>a>>b>>c;
    G.add_edge(a-1,b-1,-c);
  }
  if(G.bellmanFord(0,n-1))cout<<-G.get_cost(n-1)<<endl;
  else cout<<"inf"<<endl;
}


/***************************

ABC061_D
http://abc061.contest.atcoder.jp/tasks/abc061_d

****************************/


Measured memory_bytes: 384
from collections import defaultdict
import sys
sys.setrecursionlimit(100000)

def seq():
    a = 1
    while True:
        yield a
        a += 1

def dfs(here, went, connect, discovery, low, answer, seq):
    went |= {here}
    discovery[here] = low[here] = next(seq)
    child = 0
    for con in connect[here]:
        if con not in went:
            parent[con] = here
            child += 1
            dfs(con, went, connect, discovery, low, answer, seq)
            low[here] = min(low[here], low[con])
            if discovery[here] < low[con]:
                answer[min(here,con)].append(max(here,con))
        elif parent[here] != con:
            low[here] = min(low[here], discovery[con])

vertices, edges = (int(n) for n in input().split(" "))
connect = defaultdict(list)
for _ in range(edges):
    v1, v2 = (int(n) for n in input().split(" "))
    connect[v1].append(v2)
    connect[v2].append(v1)
answer = defaultdict(list)
new_seq = seq()
went = set()
discovery = [0 for n in range(vertices)]
low = [float("inf") for n in range(vertices)]
parent = [None for n in range(vertices)]
dfs(0, went, connect, discovery, low, answer, new_seq)

for k in sorted(answer.keys()):
    for n in sorted(answer[k]):
        print(k,n)

Measured memory_bytes: 21592
#include <iostream>
using namespace std;
int main(){
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        int j=i,num=0;
        while(j){
            j/=10;
            num++;
        }
        if(num%2==1)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int N;

int check(int a, int b, int c){
    if (c < a + b){
        return 1;
    }else{
        return 0;
    }
}
int main(){
    cin >> N;
    vector<int> L = vector<int>(N);
    for(int i = 0; i< N; i++){
        cin >> L.at(i);
    }
    sort(L.begin(), L.end());
    int ans = 0;
    for(int i=0;i < N-2;i++){
        int a = L.at(i);
        for(int j = i+1;j < N-1; j++){
            int b = L.at(j);
            for(int k = j+1; k < N; k++){
                int c = L.at(k);
                if(c >= a + b){
                    break;
                }
                if(check(a, b, c) == 1){
                    ans++;
                }


            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256