akhauriyash/Code-Regression huggingface dataset:
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define int ll 
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
long const M=1e9+7;
const long mxN =1e5+2 ;
int n,m,x,a[13][13],c[13];
vi ans ;
void brute(int l,int cost,ar<int,13> curr){ 
  if(l==n){
    return ;
  }
  ar<int,13> new_curr ;
  For(i,13){
    new_curr[i]=curr[i] ;
    
  }
  int new_cost=cost+c[l] ;
  For(i,13){
    new_curr[i]+=a[l][i] ;
  }
  bool ok = 1;
  For(i,m){
    if(new_curr[i]<x)ok=0 ;
  }
  if(ok){
    ans.pb(new_cost) ;
  }
  brute(l+1,new_cost,new_curr) ;
  brute(l+1,cost,curr) ;
}
void solve(){
  cin >>  n >> m >> x ;
  mems(a,0) ;
  For(i,n){
    cin >> c[i] ;
    For(j,m){
      cin >> a[i][j] ;
      
    }
  }
  ar<int,13>curr ={0,0,0,0,0,0,0,0,0,0,0,0,0} ;
  brute(0,0,curr) ;
  if(ans.empty()){
    pf(-1) ;
    return ;
  }
  int val =1e9 ;
  for(int c:ans){
    val=min(val,c) ;
  }
  cout << val ;
  
  
  
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 3720
/// referenced: https://beta.atcoder.jp/contests/abc045/submissions/887597
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
int f(const string&S,int index,int pool,int sum){
  if(index>=S.size()){
    return pool+sum;
  }else{
    const int no_plus=f(S,index+1,10*pool+S[index]-'0',sum);
    const int plus=f(S,index+1,S[index]-'0',pool+sum);
    return no_plus+plus;
  }
}
main(){
  string S;
  cin>>S;
  cout<<f(S,1,S[0]-'0',0)<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    public static boolean checkEven(int[] nArray) {
	boolean flag = true;
	for ( int i=0; i<nArray.length; i++ ) {
	    if ( nArray[i]%2 == 0 ) {
		nArray[i] /= 2;
		continue;
	    }
	    flag = false;
	    break;
	}
	return flag;
    }

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

	n = sc.nextInt();
	for ( int i=0; i<n; i++ ) {
	    nArray[i] = sc.nextInt();
	}

	int cnt = 0;
	while ( true ) {
	    if ( checkEven(nArray) ) {
		cnt++;
		continue;
	    }
	    break;
	}
	System.out.println(cnt);
    }
    
}

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

long long n2(long long a){
    if(a % 2 == 0){
        return 1 +  n2(a/2);
    }
    else{
        return 0;
    }
}

int main(){
    long N;
    long long a;
    long long ans=0;
    cin >> N;
    for(long i=0;i<N;i++){
        cin >> a;
        ans += n2(a);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  int ans=0;
  for(int i=0;i<n-1;i++){
    if(n%(i+1)==0){
      ans=ans+n/(i+1)-1;
    }else{
      ans=ans+n/(i+1);
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define inf 2333333333333333
#define N 3010
#define p(a) putchar(a)
#define For(i,a,b) for(long long i=a;i<=b;++i)
//by war
//2020.7.21
using namespace std;
long long a,b,c,d,mod=998244353;
long long f[N][N];
void in(long long &x){
    long long y=1;char c=getchar();x=0;
    while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
    while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();}
    x*=y;
}
void o(long long x){
    if(x<0){p('-');x=-x;}
    if(x>9)o(x/10);
    p(x%10+'0');
}

long long dfs(long long x,long long y){
	if(x<a || y<b) return 0;
	if(~f[x][y]) return f[x][y];
	long long ans=0;
	if(x==a) ans+=x*dfs(x,y-1),ans%=mod;
	if(y==b) ans+=y*dfs(x-1,y),ans%=mod;
	if(x>a && y>b) ans+=((x*dfs(x,y-1)%mod+y*dfs(x-1,y)%mod)%mod-(x-1)*(y-1)*dfs(x-1,y-1)%mod+mod)%mod,ans%=mod;
	f[x][y]=(ans+mod)%mod;
	return f[x][y];
}

signed main(){
    in(a);in(b);in(c);in(d);
    memset(f,-1,sizeof f);
    f[a][b]=1;
    o(dfs(c,d));
    return 0;
}

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

using namespace std;

int main(){
	int n, ans = 0;
	cin >> n;
	vector<vector<char>> s(n, vector<char>(n));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> s[i][j];
		}
	}
	for(int i = 0; i < n; i++){
		bool f = true;
		for(int j = 0; j < n; j++){
			for(int k = 0; k < n; k++){
				if(s[j][(k + i) % n] != s[k][(j + i) % n]){
					f = false;
					break;
				}
			}
			if(!f) break;
		}
		if(f) ans++;
	}
	ans *= n;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s1,s2;
  cin>>s1;
  cin>>s2;
  int count=0;
  for(int i=0;i<s1.size();i++)
  {
    if(s1[i]==s2[i])
    {
      count++;
    }
  }
  if(count==s1.size())
  {
    cout<<"Yes";
  }
  else
  {
    cout<<"No";
  }
}


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

#define REP(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define el "\n"
#define mnl *min_element
#define mxl *max_element

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;

bool pfctsq(int n)
{
	int m=sqrt(n);

	if((m*m)==n)
		return true;

	return false;
}

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

	int n;
	cin>>n;

	if(n==0)
	{
		cout<<1;
	}
	else
		cout<<0;
}

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

using int64 = long long;

int64 cal(int64 n, int64 m, int k) {
	int64 t = pow(n, 1.0 / k);
	int64 val = 1, ans = (k - 1) * m;
	for (int i = 0; i < k; i++)
		val *= t, ans += t;
	while (val < n) {
		val /= t;
		val *= (t + 1);
		ans++;
	}
	return ans;
}

int main() {
	int64 n, m;
	cin >> n >> m;
	int64 ans = LLONG_MAX;
	for (int i = 1; i < 50; i++) 
		ans = min(ans, cal(n, m, i));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "2 3", "8 20" ].parse.expand.solve == 7 );
	assert( [ "2 10", "3 5" ].parse.expand.solve == 8 );
	assert( [ "4 5", "10 1 2 22" ].parse.expand.solve == 7 );
	assert( [ "8 7", "1 7 5 6 8 2 6 5" ].parse.expand.solve == 5 );
	
	assert( [ "8 0", "1 7 5 6 8 2 6 5" ].parse.expand.solve == 1 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nk[ 1 ], as );
}

auto solve( long k, long[] as )
{
	// 合計の約数を最大公約数の候補として全探索
	foreach( d; as.sum.divisors.sort!( ( x, y ) => y < x ) )
	{
		// asをdで割った余りをマイナスとプラスに振り分けて釣り合うところを探索
		auto rs = new long[ as.length ];
		auto m = 0L;
		auto p = 0L;
		foreach( ref r, a; lockstep( rs, as ) )
		{
			r  = a % d;
			m += r;
		}
		foreach( r; rs.sort!( ( x, y ) => y < x ) )		// 昇順でも降順でも釣り合いはとれるけど、降順のほうが操作回数が少なくなる
		{
			if( m <= p ) break;
			m -= r;
			p += d - r;
		}
		if( m == p && m <= k ) return d;
	}
	assert( false );
}

// 約数列挙
auto divisors( long n )
{
	bool[ long ] ds;
	for( auto i = 1L; i <= n ^^ 0.5; i++ )
	{
		if( n % i != 0 ) continue;
		ds[ i     ] = true;
		ds[ n / i ] = true;
	}
	return ds.keys;
}


Measured memory_bytes: 4348
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

long long cnt = 0;
long long N;

void DFS(long long num , bool x, bool y, bool z) {
    // 終了条件
    if(num > N){
        return;
    }
    if(x==true & y==true & z == true){
        cnt++;
    }
    DFS(num*10 + 3 , true, y, z);
    DFS(num*10 + 5 , x, true, z);
    DFS(num*10 + 7 , x, y, true);
}

int main() {
    cin >> N;   
    DFS(0, false, false, false);
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// Shojin
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			long k = sc.nextLong();
			Long[] A = new Long[n];
			long tmp = 0;
			for (int i = 0; i < n; i++) {
				long next = sc.nextLong();
				A[i] = next;
				tmp += next;
			}
			final long sum = tmp;
			Arrays.sort(A, (x, y) -> x / ((x * k / sum) + 1) > y / ((y * k / sum) + 1) ? 1 : -1);
			if (k == 0) {
				System.out.println(A[n - 1]);
				return;
			}
			int[] cutCnt = new int[n];
			int cutCntSum = 0;
			for (int i = 0; i < n; i++) {
				long cnt = A[i] * k / sum;
				cutCnt[i] = (int) cnt;
				cutCntSum += (int) cnt;
			}
			long ans = 0;
			for (int i = n - 1; i >= 0; i--) {
				if (cutCntSum < k) {
					cutCnt[i]++;
					cutCntSum++;
				}
				if (cutCnt[i] == 0) {
					ans = Math.max(ans, A[i]);
					continue;
				}
				if (A[i] % cutCnt[i] == 0) {
					ans = Math.max(ans, A[i] / (cutCnt[i] + 1));
				} else {
					ans = Math.max(ans, A[i] / (cutCnt[i] + 1) + 1);
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 65700
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define debug(x)  cerr << #x << " = " << x << endl
#define pb push_back
#define F first
#define S second
#define OK order_of_key
#define FO find_by_order
#define PI 3.14159265
#define nmax 100100
const ll inf = std::numeric_limits<ll>::max();
const int infint = std::numeric_limits<int>::max();
const ll mod = 1e9+7;
using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vi g[nmax];
int ted[nmax],par[nmax],timee[nmax],tnow;
bool seen[nmax],out[nmax];
void dfs(int v){
    seen[v] = true;
    timee[v] = tnow++;
    for(auto i : g[v]){
        if(seen[i]){
            if(!out[par[i]]){
                par[i] = v;
            }
            continue;
        }
        par[i] = v;
        dfs(i);
    }
    out[v] = true;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin >> n >> m;
    fo(i,0,n+m-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        g[a].pb(b);
        ted[b]++;
    }
    M_(par);
    int root = 0;
    fo(i,0,n) if(ted[i] == 0) root = i;
    dfs(root);

    fo(i,0,n) cout << par[i]+1 << '\n';
    return 0;
}



Measured memory_bytes: 12416
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, ans, sum, last,a[200001];
struct Edge { LL to, cost; }; 
string str,ss;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	LL x, y, z;
	cin >> x >> y >> z;
	if (z - y <= 0)
		cout << "delicious" << endl;
	else if (z - y <= x)
		cout << "safe" << endl;
	else
		cout << "dangerous" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main()
{
    //　数値の定義
    //　文字列の定義
    long long N; //初期値
    long long K; //対象の値
    cin >> N;
    cin >> K;

    //long long count = 0;

    // 操作
    long long diff = N;
    long long diff_before = 1000000000000000000;

    if(N % K == 0){
        diff = 0;
    }else{
        diff = N % K;
        while(1){
            diff = abs(diff - K);
            if(diff > diff_before){
                diff = diff_before;
                break;
            }else{
                //cout << diff << endl;
                diff_before = diff;
            }
        }
    }
    
    
    //判定
    cout << diff << endl;
    return 0;
}

Measured memory_bytes: 888
// 5/8 過去問ガリガリ
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    string S, T, U;
    int A, B;

    cin >> S >> T >> A >> B >> U;

    // cout << S.size() << endl;
    // cout << T.size() << endl;
    // cout << A << endl;
    // cout << B << endl;
    // cout << U << endl;

    if (S == U) cout << A - 1 << " " << B << endl;
    else cout << A << " " << B - 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#define INF 1<<28
using namespace std;
 
int p[222];
int memo[1111111];
int memo2[1111111];
 
int solve(int n){
   
  if(!n) return 0;
  if(~memo[n]) return memo[n];
 
  int ans = INF;
  for(int i=180;i>0;i--) if(n >= p[i]) ans = min(ans, solve(n-p[i])+1);
   
  return memo[n] = ans;
}
 
int solve2(int n){
   
  if(!n) return 0;
  if(~memo2[n]) return memo2[n];
 
  int ans = INF;
  for(int i=180;i>0;i--) if(p[i]&1 && n >= p[i]) ans = min(ans, solve2(n-p[i])+1);
 
  return memo2[n] = ans;
}
 
int main(){
   
  int n;
   
  memset(memo, -1, sizeof(memo));
  memset(memo2, -1, sizeof(memo2));
 
  for(int i=0;i<181;i++) p[i] = i*(i+1)*(i+2)/6;

  for(int i=0;i<1111111;i++){ solve(i), solve2(i); }
  while(cin >> n, n) cout << solve(n) << " " << solve2(n) << endl;
 
}

Measured memory_bytes: 9848
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main(){
    ll n,m;cin>>n>>m;
    ll aa[n];
    vector<ll> a;
    ll b[m],c[m];
    for(ll i=0;i<n;i++){
        cin>>aa[i];
        a.push_back(aa[i]);
    }
    vector<pair<ll,ll>> p;
    for(ll i=0;i<m;i++){
        cin>>b[i]>>c[i];
        p.push_back(make_pair(c[i],b[i]));
    }
    sort(a.begin(),a.end());
    sort(p.begin(),p.end(),greater<pair<ll,ll>>());
    ll d=0;
    for(ll i=0;i<m;i++){
        for(ll j=d;j<min(d+p[i].second,n);j++){
            if(p[i].first>a[j]){
                a[j]=p[i].first;
            }else{
                j=n+1;
                i=m+1;
            }
        }
        d=d+p[i].second;
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 5492
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>

using namespace std;

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B and B == C) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#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 sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    string s;cin>>s;
    int r=0,b=0;
    rep(i,s.size()){
        if(s[i]=='1')r++;
        else b++;
    }
    int res=min(r,b)*2;
    cout<<res<<endl;
}

Measured memory_bytes: 512
// AOJ ALDS1_3_C Doubly Linked List
// 2018.5.1 bal4u

#include <stdio.h>

// 数値のハッシュ関数
#define HASHSIZ 2000003
typedef struct { int n; short f; } HASH;
HASH hash[HASHSIZ+5], *hashend = hash+HASHSIZ;

void insert(int n)
{
	HASH *p = hash + n % HASHSIZ;
	while (p->n) {
		if (p->n == n) { p->f++; return; }
		if (++p == hashend) p = hash;
	}
	p->n = n, p->f = 1;
}

int lookup(int n)
{
	HASH *p = hash + n % HASHSIZ;
	while (p->n) {
		if (p->n == n) {
			if (p->f > 0) { p->f--; return 1; }
			return 0;
		}
		if (++p == hashend) p = hash;
	}
	return 0;
}

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void skip(int k) { while (k--) gc(); }

void out(int n)
{
	int i;
	char ob[20];

	if (!n) { pc('0'); return; }
	i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
	while (i--) pc(ob[i]); 
}

int que[2000005]; int top, end;

int main()
{
	int n, i, t;
	char op;

	n = in(); top = 0, end = 1;
	while (n--) {
		if (gc() == 'i') {
			skip(6);
			que[end++] = t = in();
			insert(t);
		} else {
			skip(5);
			op = gc();
			if (op == 'F') {
				skip(5);
				lookup(que[--end]);
			} else if (op == 'L') {
				skip(4);
				lookup(que[++top]);
			} else {
				t = in();
				if (lookup(t)) {
					que[top] = t;
					for (i = end-1; que[i] != t; i--);
					if (i > top) {
						if (end - i < i - top) {
							while (++i < end) que[i-1] = que[i];
							end--;
						} else {
							while (--i > top) que[i+1] = que[i];
							top++;
						}
					}
				}
			}
		}
	}
	t = 0;
	for (i = end-1; i > top; i--) {
		if (t) pc(' ');
		else t = 1;
		out(que[i]);
	}
	pc('\n');
	return 0;
}


Measured memory_bytes: 13324
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
#include <iomanip>
#include <limits>

//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

using namespace std;
int main() {
	int N;
	int K;
	cin >> N;
	cin >> K;
	int k;
	int j;
	long double ans = 0;
	int res = 0;

	for (int i = 1; i <= N; i++) {
		k = i;
		while (k < K) {
			k = 2 * k;
			res = res + 1;
		}
		long double b = powl(0.5, res);
		res = 0;
		ans = b / N  + ans;
		  b = 0;
	
	}
	
	
	cout << setprecision(15) << ans  << endl;


}

Measured memory_bytes: 256
def main():
    n, a, b = map(int, input().split())
    res = n
    count = 0
    if a == 0:
        print(0)
        exit(0)
    count = res // (a + b)
    res = n - ( ( a + b ) * count )
    if a < res:
        print(a * (count + 1))
    else:
        print(a * count + res)
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const int N = 333;
vector<pair<long long, long long>> g[N];
pair<long long, long long> dist[N][N];
long long INF = 1LL << 50;
long long L;
void doit (int st) {
  for (int i = 0; i < N; i++) dist[st][i] = make_pair(INF, INF);
  priority_queue<vector<long long>, vector<vector<long long>>, greater<vector<long long>>> que;
  dist[st][st] = {0, -L};
  que.push({0, -L, st});
  while (que.size()) {
    vector<long long> cur = que.top();
    que.pop();
    if (dist[st][cur[2]] < make_pair(cur[0], cur[1])) continue;
    for (const pair<long long, long long>& nxt : g[cur[2]]) {
      long long fuel, rem;
      if (nxt.second > -cur[1]) {
        fuel = cur[0] + 1;
        rem = L - nxt.second;
      } else {
        fuel = cur[0];
        rem = -cur[1] - nxt.second;
      }
      if (rem < 0) continue;
      if (dist[st][nxt.first] > make_pair(fuel, -rem)) {
        dist[st][nxt.first] = make_pair(fuel, -rem);
        que.push({fuel, -rem, nxt.first});
      }
    }
  }
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //e
  int n, m;
  cin >> n >> m >> L;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a].emplace_back(b, c);
    g[b].emplace_back(a, c);
  }
  for (int i = 0; i < n; i++) {
    doit(i);
  }
  int q;
  cin >> q;
  while (q--) {
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    cout << (dist[s][t].first == INF ? -1 : dist[s][t].first) << '\n';
  }
  return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 1145141919
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(bit)

using namespace std;

int main(void){
  int N,M,count=0,check=0,ans=0;
  cin >> N >> M;
  int k[M];
  int s,p[M];
  int bit[M]={};
  rep(i,M){
    cin >> k[i];
    rep(j,k[i]){
      cin >> s;
      bit[i]+=Flag(s-1);
    }
  }
  rep(i,M) cin >> p[i];
  for(int i=0;i<Flag(N);i++){
    count=0,check=0;
    for(int j=0;j<M;j++){
      count=0;
      for(int k=0;k<N;k++){
        if(i&bit[j]&Flag(k)) count++;
      }
      if(count%2!=p[j]){
        check=1;
        break;
      }
    }
    if(check==0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
	char *num;
  num=malloc(sizeof(char)*(a+b+1));
  scanf("%s",num);
  int i,j;
  for(j=0;j<a;j++){
    if(num[j]>'9'||num[j]<'0'){
      printf("No");
      return 0;
    }
  }
  if(num[a]!='-'){
      printf("No");
      return 0;
  }
  for(j=a+1;j<a+b+1;j++){
    if(num[j]>'9'||num[j]<'0'){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n =readInt()
    val s = n.toString()
    var ns = ""
    s.forEach { c ->
        ns += when(c) {
            '1' -> "9" 
            '9' -> "1"
            else -> c
        }
    }
    println(ns)
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
    }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 33744
#include <iostream>
#include <cmath>

using namespace std;

int operate(int value, int count, int k, int n)
{
	if ( count >= n ) return value;
	
	return min(
		operate(value * 2, count + 1, k, n),
		operate(value + k, count + 1, k, n));
	
}

int main()
{
	int n, k;
	
	cin >> n >> k;
	
	cout << operate(1, 0, k, n) << endl;
	
	return 0;
}


Measured memory_bytes: 256
lis=[True for i in range(int(1e6+1))]

lis[0]=lis[1]=False
end=int(1e6**0.5)
for i in range(end+1):
    if lis[i]:
        for j in range(i*2,int(1e6+1),i):
            lis[j]=False

while True:
    try:
        n=int(input())
        cnt=0
        for i in range(n+1):
            if lis[i]:cnt+=1
        print(cnt)
        
        
    except EOFError:
        break

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

int main()
{
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  double half = W * H / 2;
  int c = 0;
  if (W / 2 == x && H / 2 == y)
    c = 1;

  cout << half << " " << c << endl;
  return 0;
}

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

using namespace std;

#define ll long long int

ll arr[(int)1e5 + 1];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	char c; cin >> c;

	if(c == 'a' || c == 'u' || c == 'i' || c == 'e' || c == 'o')
		cout << "vowel\n";
	else cout << "consonant\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 401
using namespace std;
typedef complex <double> P;
P p[N];
int n;
const double EPS = 1e-8; 

double dot(P a,P b){return real(conj(a)*b);}
double cross(P a,P b){return imag(conj(a)*b);}

int ccw(P a,P b,P c){
  b-=a;
  c-=a;
  if(cross(b,c)> EPS) return 1;
  if(cross(b,c)<-EPS) return -1;
  if(dot(b,c) < -EPS) return 2;
  if(norm(b)<norm(c))return -2;
  return 0;
}

bool check(P s, P t){
  if(t==P(-1,-1))return 0;
  for(int i=0;i<n;i++){
    if(p[i]==P(-1,-1)||p[i]==t)continue;
    int r=ccw(s,p[i],t);
    if(!(r==1||r==0)) return 0;
  }
  return 1;
}

double solve(){
  double res=0;
  P pos=P(0,0);
  for(int i=0;i<n;i++)
    if(check(pos,p[i])) {
      res+=abs(pos-p[i]);
      pos=p[i];
      p[i]=P(-1,-1);
      i=-1;
    }
  return res;
}

int main(){
  while(cin>>n,n){
    for(int i=0,x,y;i<n;i++)cin>>x>>y,p[i]=P(x,y);
    printf("%.1f\n",solve());
  }
  return 0;
}

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

// @@ !! LIM()
// --> 
// @@ !! LIM  -- end mark --

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> X(N), Y(N), P(N);
  for (ll i = 0; i < N; i++) {
    ll x, y, p; cin >> x >> y >> p;
    X.at(i) = x;
    Y.at(i) = y;
    P.at(i) = p;
  }

  ll pssize = 1LL << N;
  vector distX(pssize, vector(N, 0LL));
  vector distY(pssize, vector(N, 0LL));
  for (ll t = 0; t < pssize; t++) {
    for (ll i = 0; i < N; i++) {
      ll vminx = abs(X.at(i));
      ll vminy = abs(Y.at(i));
      for (ll j = 0; j < N; j++) {
	if (t & (1LL << j)) {
	  vminx = min(vminx, abs(X.at(i) - X.at(j)));
	  vminy = min(vminy, abs(Y.at(i) - Y.at(j)));
	}
      }
      distX.at(t).at(i) = vminx;
      distY.at(t).at(i) = vminy;
    }
  }

  vector<ll> ans(N+1, LLONG_MAX);
  for (ll tt = 0; tt < pssize; tt++) {
    ll k = __builtin_popcountll(tt);
    for (ll tx = tt; true; tx = (tx - 1) & tt) {
      ll ty = tt ^ tx;
      ll sum = 0;
      for (ll i = 0; i < N; i++) {
	sum += min(distX.at(tx).at(i), distY.at(ty).at(i)) * P.at(i);
      }
      ans.at(k) = min(ans.at(k), sum);
      if (tx == 0) break;
    }
  }

  for (ll i = 0; i <= N; i++) cout << ans.at(i) << endl;

  return 0;
}



Measured memory_bytes: 12908
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String isPalin = sc.next();
        int count = 0;
        for (int i = 0; i < isPalin.length(); i++) {
            if (isPalin.charAt(i) != isPalin.charAt(isPalin.length() - 1 - i)) {
                count++;
            }
        }
        System.out.println(count/2);
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	string S;
	cin >> S;
	bool check=true;
	for (int i = 0; i < 3; i++) {
		if (S[i] == S[i + 1])
			check = false;
	}

	if (check)
		cout << "Good";
	else
		cout << "Bad";
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	map<string, long long> mp;
	for(int i=1; i<=N; i++){
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		if(mp.count(s)==0){
			mp[s] = 1;
		}
		else{
			mp[s]++;
		}
	}

	long long ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		long long v = itr->second;
		v = v * (v - 1);
		v /= 2;
		ans += v;
	}
	cout << ans << endl ;
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define ifl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(int i=0;i<n;i++)
#define bf(i,n)    for(int i=n-1;i>=0;i++)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < int ,int ,int > > ;
// #define vector< int ,int > pv;
// vector< pair <int,int> > vect;


//------------------------------------------------------------------------

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

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

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

//---------------------------------------------------------------------------

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

// ---------------------------------------------------------------------------	

// int n;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];    
// for(int i=0;i<n;i++)cout<<a[i];
// int a,b;cin>>a>>b;   

//---------------------------------------------------------------------------


//----------------------------------------------------------------------------


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int tt=1;
   // cin>>tt;
	while(tt--)
	{
	    ll n;cin>>n;
	    double z=100;
	    for(ll i=1;i<100000000000000;i++)
	    {
	        z=z*(1+.01);
	        z=floor(z);
	        if(z>=n)
	        {cout<<i<<bn;break;}
	    }
	    
	    
	   
	   
	   
	    
	}
	
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#ifdef _WIN32
#include <windows.h>
#define print(x) PRINT(x, #x)
template<typename T> inline const void PRINT(T VARIABLE, string NAME)
{
#ifndef ONLINE_JUDGE /// ONLINE_JUDGE IS DEFINED ON CODEFORCES
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, 10);
    cerr << NAME << " = " << VARIABLE;
    SetConsoleTextAttribute(hConsole, 7);
    cerr << '\n';
#endif
}
#else
#define print(x) 0
#endif
typedef long long ll;
typedef unsigned long long ull;
const ll INFLL = 2 * (ll)1e18 + 100;
const int INFINT = 2 * (int)1e9 + 100;
const double PI = atan(1) * 4;
const double EPS = 1e-12;
const int SEED = 1e3 + 7;

const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const int NMAX = 300 + 5;

string s;
int k;
int dp[NMAX][NMAX][NMAX], trecut[NMAX][NMAX][NMAX];

void solve(int l, int r, int x)
{
    if(trecut[l][r][x]) return;
    if(l == r)
    {
        dp[l][r][x] = 1;
        trecut[l][r][x] = 1;
        return;
    }
    if(l > r)
    {
        dp[l][r][x] = 0;
        trecut[l][r][x] = 1;
        return;
    }

    if(s[l] == s[r])
    {
        if(!trecut[l + 1][r - 1][x]) solve(l + 1, r - 1, x);
        dp[l][r][x] = 2 + dp[l + 1][r - 1][x];
    }
    else
    {
        if(x - 1 >= 0)
        {
            if(!trecut[l + 1][r - 1][x - 1])
                solve(l + 1, r - 1, x - 1);
            dp[l][r][x] = 2 + dp[l + 1][r - 1][x - 1];
        }

        if(!trecut[l + 1][r][x]) solve(l + 1, r, x);
        if(!trecut[l][r - 1][x]) solve(l, r - 1, x);
        dp[l][r][x] = max(dp[l][r][x], max(dp[l + 1][r][x], dp[l][r - 1][x]));

    }
    trecut[l][r][x] = 1;
}

int main()
{
    FASTIO;
    cin >> s >> k;
    int n = s.size();
    solve(0, n - 1, k);
    int sol = 1;
    for0(i, n)
    for0(j, n)
    for0(K, k + 1)
    {
        if(!trecut[i][j][K]) solve(i, j, K);
        sol = max(sol, dp[i][j][K]);
    }

    cout << sol;
    return 0;
}


Measured memory_bytes: 221440
// Author: Jinhai Chen
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long ll;
const int maxn = 100005;
int n,m;
int x[maxn],a[maxn];

int main() {
#ifdef CJHCJH
	freopen("data.in","r",stdin);
#endif
	int n;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++) scanf("%d",&a[i]);
	sort(a,a+m);
	for(int i=0;i<m-1;i++) {
		x[i]=a[i+1]-a[i];
	}
	sort(x,x+m-1);
	ll sum=0;
	for(int i=0;i<m-n;i++) sum+=x[i];
	cout<<sum<<endl;
	return 0;
}














Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var cup = new bool[3] { true, false, false };
			string s = "";
			while ((s = Console.ReadLine()) != null)
			{
				int a = s[0] - 'A';
				int b = s[2] - 'A';
				Swap(ref cup[a], ref cup[b]);
			}
			Console.WriteLine((char)('A' + Array.IndexOf(cup, true)));
		}

		static void Swap<T>(ref T a1, ref T a2)
		{
			T temp;
			temp = a1;
			a1 = a2;
			a2 = temp;
		}
	}
}

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

int main() {
	int n,m,x;
	
	cin >> n;
	cin >> m;
	cin >> x;
	
	int l = 0, r = 0;
	for(int i=0;i<m;i++){
		int a;
		cin >> a;
		if(a<x){
			l++;
		}else{
			r++;
		}
	}
	
	cout << ((l<r)?l:r) << endl;

	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc165/tasks/abc165_b
#include <iostream>
#include <cmath>

unsigned long int X;

//(100 * 1.01).floor*1.01.floor)*1.01.floor... >= X
unsigned int calc(){
  double balance = 100.0;
  const double rate = 1.01;
  unsigned int n = 0;
  while(balance < X){
    balance = floor(balance * rate);
    n++;
  }
  return n;
}

void solve() {
  unsigned int ans = calc();
  std::cout << ans << std::endl;
}

void input() {
  std::cin >> X;
}

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


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int D,N;cin>>D>>N;
  if (N==100) N++;
  string ans = to_string(N);
  REP(i,D) ans += "00";
  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
using namespace std ;

string a , b ;

void input ( ) {
    cin >> a >> b ;
}

void solve ( ) {
    cout << ( a[ 0 ] == b[ 0 ] ) + ( a[ 1 ] == b[ 1 ] ) +( a[ 2 ] == b[ 2 ] ) << "\n" ;
}

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


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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    ll sl[n] = {}, sr[n] = {};
    for (int i = 0; i < n; i++) {
        if (i + a[i] < n) sl[i + a[i]]++;
    }
    for (int i = n - 1; i >= 0; i--) {
        if (i - a[i] >= 0) sr[i - a[i]]++;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += sl[i] * sr[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 7464
#include <bits/stdc++.h>
using namespace std;
int main()
{
cin.tie(0);
cin.sync_with_stdio(0);
int n,m,cont=0,x,d;
cin>>n>>m;
int arr[n+1]={0};
for(int i=1;i<=m;i++){
    cin>>x;
    for(int j=1;j<=x;j++){
        cin>>d;
        arr[d]++;}}

    for(int i=1;i<=n;i++)
            if(arr[i]==0)
            cont++;
    cout<<cont;
}


Measured memory_bytes: 3576
#include <iostream>
using namespace std;
 
int main() 
{
  int h,w;
  int i,j;
  while(true){
    cin >> h >> w;
    if(h == 0 && w == 0){
      return 0;
    }
    for(i = 0;i < h;i++){
      for(j = 0;j < w;j++){
        cout << '#';
      }
      cout << "\n";
    }
    cout << "\n";
  }
  
}


Measured memory_bytes: 3044
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<ctime>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
int read(){
    int f=1,x=0;char c=getchar();
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
    while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	x*=f;
    return x;
}
#define MAXN 100
#define INF 0x3f3f3f3f
int vis[MAXN+5];
int n,a[MAXN+5],ans[MAXN+5];
bool check(int x){
	int cnt=0;
	for(int i=1;i<=n&&cnt<a[x];i++)
		if(vis[i]){
			cnt++;
			if(cnt==a[x]) return 1;
			if(x<i) return 0;
		}
	return 1;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=1;i<=n;i++){
		bool f=0;
		for(int j=n;j>=1;j--)
			if(!vis[j]&&a[j]<=i&&check(j)){
				f=1,vis[j]=1,ans[i]=a[j];
				break;
			}
		if(!f){
			puts("-1");
			return 0;
		}
	}
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
typedef long long ll;
#define PI 3.14159265
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(NULL);
    char ch;
    cin>>ch;
    int x=(int)ch+1;
    cout<<char(x);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main(int argc, char* argv[]){
  int a, b;
  std::cin >> a >> b;
  int axb = a * b;
  int apb = a + b;
  int amb = a - b;
  if (axb < apb){
    if (apb < amb) {
      std::cout << amb;
    } else {
      std::cout << apb;
    }
  } else {
    if (axb < amb) {
      std::cout << amb;
    } else {
      std::cout << axb;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

char rbuf[2800014];
char wbuf[699997];
int rbufl, wbufl;

#define getchar_unlocked() rbuf[rbufl++]
#define putchar_unlocked(c) wbuf[wbufl++]=(c)

uint32_t nextpint(void){ char c=getchar_unlocked(); uint32_t x=0; while('0'<=c){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }
void printpint(int32_t x){ if(x==0){putchar_unlocked('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar_unlocked(s[i]); putchar_unlocked('\n'); }

int edge[200000][2];

int qmem[400000];

int *e[100001];
int el[100001];

int prev[100001];

int s[100000];
int sl, sr;

int main(void){
	read(STDIN_FILENO, rbuf, sizeof(rbuf));
	int n=nextpint();
	int m=nextpint();
	for(int i=0; i<m; i++){
		int A=nextpint();
		int B=nextpint();
		edge[i][0]=A;
		edge[i][1]=B;
		el[A]++;
		el[B]++;
	}
	int ne=0;
	for(int i=1; i<=n; i++){
		e[i]=&qmem[ne];
		ne+=el[i];
		el[i]=0;
	}
	for(int i=0; i<m; i++){
		int A=edge[i][0];
		int B=edge[i][1];
		e[A][el[A]++]=B;
		e[B][el[B]++]=A;
	}
	int k=0;
	prev[1]=1;
	s[sr++]=1;
	while(sl<sr){
		k++;
		int from = s[sl++];
		for(int i=0; i<el[from]; i++){
			int to = e[from][i];
			if(prev[to]==0){
				prev[to]=from;
				s[sr++]=to;
			}
		}
	}
	if(k==n){
		putchar_unlocked('Y');
		putchar_unlocked('e');
		putchar_unlocked('s');
		putchar_unlocked('\n');
		for(int i=2; i<=n; i++){
			printpint(prev[i]);
		}
		write(STDOUT_FILENO, wbuf, wbufl);
	}else{
		puts("No");
	}
}


Measured memory_bytes: 9192
#include <iostream>
#include <numeric>
#include <algorithm>

using namespace std;

long long int n;
int gcd(int a, int b) {
  while (b != 0)  {
    int t = b;
    b = a % b;
    a = t;
  }
  return a;
}

int main(){
	cin >> n;
	long long int a[1000000];
	for(int i = 0; i < n; ++i) cin >> a[i];
	sort(a, a + n);
for(int i =0;i<n-1;i++){
	a[i+1] = gcd(a[i],a[i+1]);
}
cout << a[n-1] << endl;
}


Measured memory_bytes: 2816
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1e9

bool isin(int i, int j, int h, int w){
    return i>=0 && j>=0 && i<h && j<w;
}

int main() {
    int w, h;

    while (cin >> w >> h && w) {
        VVI f(h,VI(w));
        vector<P> p(1);
        REP(i,h) {
            string s;
            cin >> s;
            REP(j,w) {
                if (s[j] == 'o') p[0] = make_pair(i, j);
                if (s[j] == '*') p.push_back(make_pair(i, j));
                if (s[j] == 'x') f[i][j] = 1;
            }
        }
        int n = p.size();
        VVI dist(n, VI(n));
        REP(x,n){
            VVI d(h,VI(w));
            queue<P> que;
            d[p[x].first][p[x].second] = 1;
            que.push(make_pair(p[x].first, p[x].second));
            int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1};
            while (!que.empty()){
                P po = que.front();
                que.pop();
                int i = po.first, j = po.second;
                REP(k,4){
                    int ii = i+dx[k], jj = j+dy[k];
                    if (!isin(ii,jj,h,w) || d[ii][jj] > 0 || f[ii][jj]) continue;
                    d[ii][jj] = d[i][j] + 1;
                    que.push(make_pair(ii, jj));
                }
            }
            REP(y,n){
                dist[x][y] = d[p[y].first][p[y].second] - 1;
            }
        }
        bool flag = 0;
        REP(i,n) REP(j,n) {
            if (dist[i][j] == -1){
                flag = 1;
            }
        }
        if (flag) {
            cout << -1 << endl;
            continue;
        }

        VVI dp(1<<n, VI(n, INF));
        dp[1][0] = 0;
        REP(i,1<<n) REP(j,n) REP(k,n) {
            if ((i>>k) & 1) continue;
            dp[i | (1<<k)][k] = min(dp[i | (1<<k)][k], dp[i][j] + dist[j][k]);
        }

        int ans = 1e9;
        REP(j,n) ans = min(ans, dp[(1<<n)-1][j]);
        cout << ans << endl;

    }

    return 0;
}

Measured memory_bytes: 3200
package main
import(
  "fmt"
)
func main(){
  var n, i, j, temp int
  fmt.Scan(&n)
  a:=make([]int, n)
  ans:=0
  for i=0;i<n;i++{
    fmt.Scan(&a[i])
  }
  temp=n*(n-1)
  temp/=2
  for i=0;i<n;i++{
    if a[i]!=0{
      for j=i+1;j<n;j++{
        if a[j]!=0{
          ans+=a[i]*a[j]
        }
      }
    }
  }
  fmt.Println(ans)
}


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

const int maxn = 105;
int N;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N;
    vector<int> b = {0};
    for (int i = 1; i <= N; i++) {
        int bi; cin >> bi;
        b.push_back(bi);
    }
    vector<int> ans;
    while (ans.size() < N) {
        bool found = false;
        for (int i = b.size() - 1; i >= 1; i--) {
            if (b[i] == i) {
                ans.push_back(i);
                b.erase(b.begin()+i);
                found = true;
                break;
            }
        }
        /*
        for (int i: b) {
            cout << i << ' ';
        }
        cout << '\n';
        */
        if (!found) {
            cout << -1 << '\n';
            return 0;
        }
    }
    reverse(ans.begin(),ans.end());
    for (int i: ans) {
        cout << i << '\n';
    }
}



Measured memory_bytes: 256