akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int INF=INT_MAX;
const ld PI=3.1415926535838797323;
const ld E=2.71828183;
const int MOD=1e9+7;

vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src-1]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c-1]){
            if(dst[nbr-1]==INF){
                q.push(nbr);
                dst[nbr-1]=dst[c-1]+1;
            }
        }
    }
    return dst;
}
int powMod(int base,int exp,int mod){
    //base^exp %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}

int binSearch(vi x,int g);
void solve();

int main() {
    //  int t;
      //cin >> t;
      //while(t--)
          solve();
}
void solve(){
    int k;
    string s;
    cin >> k;
    cin >> s;

    if(s.size()<=k)
        cout << s << "\n";
    else{
        for(int i=0; i<k; i++)
            cout << s[i];
        cout << "...\n";
    }

}

Measured memory_bytes: 3584
// @samaranand
//
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define int64 long long
#define VI vector < int >
#define VII vector < vector < int > >
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define pii pair < int , int >
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define sz(v) v.size()
//const string yo = "YES", no = "NO";
const int inf = 2e9 + 7;
//const long long biGinf = 9e+18;
const char nwl = '\n';

int main() {

	//ur code
	int n;
	// VI a(n), b(n), c(n);
	// for0(i, n) { cin >> a[i] >> b[i] >> c[i]; }
	// int s = 0;
	// int x = 0, y = 0, z = 0;
	// for0(i, n) {
	// 	if (a[i] > b[i] && a[i] > c[i] and x < 2) {
	// 		x++;
	// 		y = 0, z = 0;
	// 		s += a[i];
	// 	}

	// }
	cin >> n;
	VI v(n);
	inpv(v);
	v.pb(inf);
	v.pb(inf);
	v.pb(inf);
	//otpv2(v); cout << nwl;
	int t1 = inf, t2 = inf, t = 0;
	for (int i = 0; i < n; i++) {
		t1 = min(t1, t + abs(v[i] - v[i + 1]));
		t2 = min(t2, t + abs(v[i] - v[i + 2]));
		if (i == n - 1)
			break;
		t = t1;
		t1 = t2;
		t2 = inf;
	}
	
	cout << t;

	return 0;
}

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

int main() {
    int n, m;
    int x;
    int ret = -1;

    cin >> n >> m;
    vector<P> p(m);

    for(int i = 0; i < m; i++) {
        cin >> p[i].first >> p[i].second;
    }

    for(x = 0; x < 1000; x++) {
        string number = to_string(x);
        int n_keta = number.length();
        if(x / 100 == 0) number = " " + number;
        if(x / 10 == 0) number = " " + number;

        if(m == 0) {
            if(n_keta == n) {
                ret = x;
                break;
            }
        }
        for(int i = 0; i < m; i++) {
            int keta = p[i].first - 1;
            int kazu = p[i].second;
            keta = keta + 3 - n;
            //cout << n[0] << n[1] << n[2] << endl;
            if(number[keta] -48 != kazu) break;
            if(n_keta != n) break;
            if(i == (m - 1)) ret = x;
        }
        if(ret != -1) break;
    }

    cout << ret << endl;
}

Measured memory_bytes: 764
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.Diagnostics;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    private long NextLong()
    {
        return long.Parse(Next());
    }
}

class Deque<T>
{
    class DequeNode<T>
    {
        public T Item;
        public DequeNode<T> Parent;
        public DequeNode<T> Child;
        public DequeNode(T i, DequeNode<T> p, DequeNode<T> c)
        {
            Item = i;
            Parent = p;
            Child = c;
        }
    }
    private DequeNode<T> First;
    private DequeNode<T> Last;
    public int Count { get; private set; }
    public Deque()
    {
        Count = 0;
        First = null;
        Last = null;
    }
    private void ZeroPush(T item)
    {
        First = new DequeNode<T>(item, null, null);
        Last = First;
    }
    public void PushFront(T item)
    {
        if (Count == 0)
        {
            ZeroPush(item);
        }
        else
        {
            First.Parent = new DequeNode<T>(item, null, First); ;
            First = First.Parent;
        }
        Count++;
    }
    public void PushBack(T item)
    {
        if (Count == 0)
        {
            ZeroPush(item);
        }
        else
        {
            Last.Child = new DequeNode<T>(item, Last, null);
            Last = Last.Child;
        }
        Count++;
    }
    public T PopFront()
    {
        var result = First;
        First = First.Child;
        Count--;
        return result.Item;
    }
    public T PopBack()
    {
        var result = Last;
        Last = Last.Parent;
        Count--;
        return result.Item;
    }
}

struct S
{
    public int Num, Sum;

    public S(int num, int sum)
    {
        this.Num = num;
        this.Sum = sum;
    }
}

class Program
{
    private int K;

    private void Scan()
    {
        var sc = new Scanner();
        K = sc.NextInt();
    }

    public void Solve()
    {
        Scan();
        var ans = new int[K];
        var q = new Deque<S>();
        q.PushBack(new S(1, 1));
        while (q.Count > 0)
        {
            var t = q.PopBack();
            if (ans[t.Num] != 0)
            {
                continue;
            }
            ans[t.Num] = t.Sum;
            q.PushBack(new S((t.Num * 10) % K, t.Sum));
            q.PushFront(new S((t.Num + 1) % K, t.Sum + 1));
        }
        Console.WriteLine(ans[0]);
    }

    static public void Main()
    {
        new Program().Solve();
    }
}

Measured memory_bytes: 19548
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

int main(){
 ll x,y; cin>>x>>y;
  cout<<x+y/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define MAXN 1000002
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod=1e9+7;

void solve()
{
  double pi=3.14159;
  double n;
  cin>>n;
  double a=2;
  double ans=a*pi*n;
  cout<<setprecision(6)<<fixed<<ans;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3812
#pragma optimize("O3")
#pragma GCC target ("sse4")

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

typedef long long int ll;
typedef pair<ll, ll> pii;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define sz(a) ll(a.size())
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front 
#define MAXN 100010
#define N 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define nl '\n'
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll modpower(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
ll power(ll x, ll y)
{
    ll res = 1;     // Initialize result
    x = x ;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);
        y = y>>1; // y = y/2
        x = (x*x);  // Change x to x^2
    }
    return res;
}
// int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return modpower(a,p-2,p);}

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

long long safe_sqrt(long long n) {
    long long res = sqrt((long double) n);
    if (res*res == n) return res;
    const long double eps = 1e-8;
    if ((long double)(res+1)*(res+1) < n + eps) return res+1;
    if ((long double)res*res + eps > n) return res-1;
    return res;
}   
// (a+b-1)/b for ceil
void solve(){
    ll n;
    cin>>n;
    vll a(n);
    ll sum = 0;
    f(i,0,n){
        cin>>a[i];
    }
    sort(all(a));
    sum+=a[n-1];
    ll x = n-2;
    rf(i,n-2,0){
        if (x>0)
        {
            sum+=a[i];
            x--;
        }
        if (x>0)
        {
            sum+=a[i];
            x--;
        }
    }
    cout<<sum<<nl;
    return ;
}
int main()
{
    IO;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int T = 1;
    // cin >> T;
    f(c, 0, T){
        solve();
    }
    return 0;
}//multiset m make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase double priority_queue 
//cout<<setprecision(12); push_back pop_back pop_front push_front  lower_bound upper_bound  reverse

Measured memory_bytes: 4780
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

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

  int ans = -1;

  int l=0, r=N-1;

  while(l < r){
    while(S[l]=='R' && l<N)
      l++;
    while(S[r]=='W' && 0<=r)
      r--;
    ans++;
    S[l] = 'R';
    S[r] = 'W';

  }

  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3888
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int x,a,b;
	cin>>x>>a>>b;
	if((10*a+b)%4)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char to_char(int n) {
    return n + 48;
}
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> board(h);
    for (int i = 0; i < h; ++i) {
        cin >> board.at(i);
    }
    vector<int> dx = {1, 0, -1, 0, 1, -1, -1, 1};
    vector<int> dy = {0, 1, 0, -1, 1, 1, -1, -1};
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (board.at(i).at(j) == '#') {
                continue;
            }
            int num = 0;
            for (int d = 0; d < 8; ++ d) {
                int ni = i + dy.at(d);
                int nj = j + dx.at(d);
                if (ni < 0 || h <= ni) {
                    continue;
                }
                if (nj < 0 || w <= nj) {
                    continue;
                }
                if (board.at(ni).at(nj) == '#') {
                    num++;
                }
            }
            board.at(i).at(j) = to_char(num);
        }
    }
    for (int i = 0; i < h; ++i) {
        cout << board.at(i) << endl;
    }
}


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

using namespace std;

typedef long long LL;

const int N = 100003;

int n, m, a[N];
char s[N];

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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int solve(int n) {
  int ret = 0;
  for (; n; n /= 10) {
    ret += n % 10;
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  int ret = INF;
  for (int i = 1; i < n; ++i) {
    ret = min(ret, solve(i) + solve(n - i));
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define int long long
#define inf 2e15
const int minnodes=1005;
#define ll long long

#define EPS 0.000000001
#define N 2000000 

string s;

 
int32_t main()
{
    IOS;

    cin >> s;
    int n = s.length();

    int prev = 0;
    vector<int> ans(n,0);
    vector<int> got(n);
    for(int i = 1;i < n;i++)
    {
        if(s[i] == 'L')
            got[i] = prev;
        else
            prev = i;
    }
    prev = n - 1;
    for(int i = n - 2;i >= 0;i--)
    {
        if(s[i] == 'R')
            got[i] = prev;
        else
            prev = i;
    }
    for(int i = 0; i < n;i++)
    {
        
        if(s[i] == 'R')
        {
            int mv = ((got[i] - i) & 1);
            if(mv)
                ans[got[i] - 1]++;
            else
                ans[got[i]]++;
        }
        else
        {
            int mv = ((i - got[i]) & 1);

            if(mv)
                ans[got[i] + 1]++;
            else
                ans[got[i]]++;
        }
    }
    for(int i = 0;i < n;i++)
        cout << ans[i] << " ";
}
 

Measured memory_bytes: 2256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  SORT(s);
  rep(i, n) cout << s[i];
  cout << endl;
}


Measured memory_bytes: 256
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    double r;
    cin >> r;
    cout << 2.0 * PI * r ;
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    string ans = "yes";
    map<char, int> mp;
    for (char c: s) {
        mp[c]++;
        if (mp[c]!=1) ans = "no";
    } 
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main () {
 int n, m;
 cin>>n>>m;
 for (int i=m/n;i>=1;i--){
     if (m%i==0){
         if (m/i>=n){
             cout<<i<<endl;
             break;
         }
     }
 }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int N, Z, W;
int a[10004];
int ans;

signed main() {
	cin >> N >> Z >> W;
	a[0] = W;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	
	ans = max(abs(a[N] - W), abs(a[N] - a[N - 1]));

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

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,sum=0;
	scanf("%d %d %d",&a,&b,&c);
	for(;a<=b;a++){
		if(0==c%a){
			sum++;
		}
	}
	printf("%d\n",sum);
	return 0 ;
}

Measured memory_bytes: 596
#include<iostream>
using namespace std;
long n;
main()
{
	while(cin>>n,n)
	{
		for(long w=1e5;--w;)
		{
			if(n>w*(w-1)/2&&(n-w*(w-1)/2)%w<1)
			{
				cout<<(n-w*(w-1)/2)/w<<" "<<w<<endl;
				break;
			}
		}
	}
}



Measured memory_bytes: 2984
from collections import Counter
n = int(input())
a_ls = list(map(int, input().split()))

c = Counter(a_ls)
edges_ls = [0] * 2
for value, count in c.items():
    if count >= 2:
        edges_ls.append(value)
    if count >= 4:
        edges_ls.append(value)
edges_ls.sort()
ans = edges_ls[-1] * edges_ls[-2]
print(ans)

Measured memory_bytes: 18600
#include<stdio.h>
int main(void){
	int N,i,j,k,v;
	scanf("%d",&N);
	int A[N];
	for(i=0;i<N;i++){
		scanf("%d",A+i);
	}
	for(k=0;k<N-1;k++){
			printf("%d ",A[k]);
		}
	printf("%d",A[N-1]);
	printf("\n");
	for(i=1;i<N;i++){
		v = A[i];
		j = i-1;
		while(j>=0 && A[j]>v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		for(k=0;k<N-1;k++){
			printf("%d ",A[k]);
		}
		printf("%d",A[N-1]);
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 1992
infinity=10**30
N,K = map(int,input().split())
h = list(map(int,input().split()))

dp=[infinity]*N
dp[0]=0

for i in range(1,N):
    step=min(K,i)
    for k in range(1,step+1):
        #if dp[i]>dp[i-k]+abs(h[i]-h[i-k]):
        #    dp[i] = dp[i-k]+abs(h[i]-h[i-k])
        dp[i] = min(dp[i],dp[i-k]+abs(h[i]-h[i-k]))

print(dp[-1])
#print(dp)

Measured memory_bytes: 53600
x = int(input())
def make_divisors(n):
    divisors = [0]
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
    return divisors

flag = 0
a_s = 0
if x == 1:
  print(1, 0)
else:
  l = make_divisors(x)
  for a in range(a_s, x+1):
    if flag == 1:
      break
    for b_a in l:
      if b_a <= a:
        b = a - b_a
        if a**5 - b**5 == x or a**5 + b**5 == x:
          flag += 1
          print(a, b)
          break
      if b_a > a:
        b = b_a - a
        if a**5 + b**5 == x:
          flag += 1
          print(a, -b)
          break

Measured memory_bytes: 9268
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class C
{
	public static void Main()
	{
		int N = Int32.Parse(Console.ReadLine());
		string[] args = Console.ReadLine().Split(' ');
		int[] a = new int[N];
		for(int i = 0; i < N; i++)
			a[i] = Int32.Parse(args[i]);

		int[] numFactor2 = new int[N];
		for(int i = 0; i < N; i++)
		{
			int tmp = a[i];
			numFactor2[i] = 0;
			while((tmp % 2) == 0)
			{
				numFactor2[i]++;
				tmp /= 2;
			}
		}

		int ans = 0;
		for(int i = 0; i < N; i++)
			ans += numFactor2[i];

		Console.WriteLine(ans);
	}	
}





Measured memory_bytes: 11872
n = gets.chomp.to_i
array = gets.chomp.split(' ').map(&:to_i)
isApproved = true

for i in 0..(n - 1)
  if (array[i] % 2 == 0) && (array[i] % 3 != 0 && array[i] % 5 != 0)
    isApproved = false
    break
  end
end

if isApproved
  puts 'APPROVED'
else
  puts 'DENIED'
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int h = input.nextInt();
    int n = input.nextInt();
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int temp = input.nextInt();
      sum += temp;
    }
    if (sum >= h) {
      System.out.print("Yes");
    } else {
      System.out.println("No");
    }
  }

}


Measured memory_bytes: 47252
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
typedef long long int ll;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define MOD 1000000007
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
//*s.find_by_order(p)   returns the value of pth largest starting from 0 
//s.order_of_key(p)   returns no. of items that are strictly < p 
//string bin = bitset<64>(m).to_string();     convert decimal m to binary   
int main()
{
      fast;ll t;t=1;
      while(t--)
      {
            ll n,i;
            string s;
            cin>>n;
            while(n!=0){
                  n--;
                  s.pb('a'+n%26);
                  n=n/26;
            }
           // cout<<s<<"\n";
            for(i=s.length()-1;i>=0;i--){cout<<s[i];}
      }     
}


Measured memory_bytes: 3632
import sys
x = input().split()
y = input().split()

if len(y) == 0:
    print(x[0])
    sys.exit()
a=[]
b=[]
for n in range(-1,102):
    b.append(n)
   
for nn in range(len(y)):
    
    b.remove(int(y[nn]))
for m in range(len(b)):  
    d = b[m] - int(x[0])
    if d < 0:
        c = d*(-1)
    if d >= 0:
        c = d
    a.append(c)
mm = min(a)
if str((int(x[0]) - mm)) in y:
    print(int(x[0]) + mm)
else:
    print(int(x[0]) - mm)

Measured memory_bytes: 9236
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>

using namespace std;

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

  vector<pair<int, int>> vp(n);
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    vp[i-1] = make_pair(i, a);
  }

  sort(vp.begin(), vp.end(), [](pair<int, int> a, pair<int, int> b){return a.second < b.second;});

  string delim = "";
  for (int i = 0; i < n; ++i) {
    cout << delim << vp[i].first;
    delim = " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1664
n = int(input())
if n == 2:
  print(1)
  quit()
elif n == 3:
  print(2)
  quit()
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr
ans = 1
for l in factorization(n-1):
  ans *= (l[1]+1)
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  return divisors
lst = make_divisors(n)

for i in lst:
  if i == 1 or i == n:
    continue
  m = n
  while m % i == 0:
    m = m // i
  if m % i == 1:
    ans += 1
  
print(ans)

Measured memory_bytes: 39280
# coding: utf-8
import sys
sysread = sys.stdin.readline
def run():
    N = int(input())
    S = []
    for _ in range(N):
        S.append(input())
    ret = set()
    for s in S:
        ret.add(s)
    print(len(ret))

if __name__ == "__main__":
    run()

Measured memory_bytes: 35716
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define endl "\n"
#define all(c) (c).begin(),(c).end()

// target 4096

constexpr ll mod = 998244353;
signed main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);

	int n, k;
	cin >> n >> k;
	vector<pair<int, int>> seg(k);
	for (int i = 0; i < k; i++) {
		int l, r;
		cin >> l >> r;
		l--;
		seg[i] = {l, r};
	}
	vector<ll> pref(n+1);
	vector<ll> pos(n);
	pos[0] = pref[1] = 1;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < k; j++) {
			auto [l, r] = seg[j];
			pos[i] += pref[max(0, i-l)] - pref[max(0, i-r)] + mod;
			pos[i] %= mod;
		}
		pref[i+1] = pref[i] + pos[i];
		pref[i+1] %= mod;
	}
	cout << pos[n-1] << endl;
}
/* --- PSolving ---
 * Simplifying (getting rid of variables, conditions, code logic, etc.)
 * Reframing
 * Solving a subtask (subgoal, aux. problem, removing a condition or fixing a parameter, etc.)
 * Inducing
 * Divide and conquer
 * Working backwards
 * Visual intuition
 */


Measured memory_bytes: 6344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Atcoder
{
    class aaaa
    {
        static void Main(string[] args)
        {
            char[] inputs = Console.ReadLine().ToCharArray();;
            char X = inputs[0]; char Y = inputs[2];
            int Xint = (int)X; int Yint = (int)Y;
            if(X ==Y){
                Console.WriteLine("=");
            }else{
                Console.WriteLine(Xint>Yint ? ">":"<");
            }
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    ll N;
    cin >> N;
    ll minCount = 1e+13;
    for (ll i = 1000001; i >= 1; --i) {
        if (N % i == 0) {
            ll j = N / i;
            ll d = (i - 1) + (j - 1);
            if (d < minCount) minCount = d;
        }
    }

    cout << minCount << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[][] dp;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println(Math.max(A+B,Math.max(A-B,A*B)));
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

class UnionFind {
public:
    explicit UnionFind(int N) : V_NUM(N) {
        par.resize(N);
        iota(par.begin(), par.end(), 0);
        num.assign(N, 1);
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if (x == y) return;

        if (num[x] < num[y]) swap(x, y);

        num[x] += num[y];
        par[y] = x;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    bool ispar(int x) {
        return x == find(x);
    }

    int size(int x) {
        return num[find(x)];
    }

    int V_NUM;
    vector<int> par, num;
};


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

    string S[H];
    for (int i = 0; i < H; ++i) {
        cin >> S[i];
        for (int j = 0; j < W; ++j) {
            if ((i + j) % 2 == 0) {
                S[i][j] = (S[i][j] == '#' ? '.' : '#');
            }
        }
    }

    UnionFind uf(H * W);
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (i < H - 1 && S[i][j] == S[i + 1][j]) {
                uf.unite(i * W + j, (i + 1) * W + j);
            }
            if (j < W - 1 && S[i][j] == S[i][j + 1]) {
                uf.unite(i * W + j, i * W + (j + 1));
            }
        }
    }

    ll cnt[H * W][2];
    fill(cnt[0], cnt[H * W], 0);
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            ++cnt[uf.find(i * W + j)][(i + j) % 2];
        }
    }

    ll ans = 0;
    for (int i = 0; i < H * W; ++i) {
        ans += cnt[i][0] * cnt[i][1];
    }

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


Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		for(int i = a; i <= b;i++) {
			if(i % k == 0) {
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");
	}
}

Measured memory_bytes: 26976
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int x;
    cin >> x;
    if (x >= 30)
    {
        cout << "Yes" << endl;
    }
    else
    {
        /* code */
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define ll long long
#define mod 1000000007
using namespace std;

    int main() {
        ll n, m;
        cin >> n >> m;
        vector<bool> a(n + 1);
        for (ll i = 0; i < m; i++) {
            ll u;
            cin >> u;
            a[u] = true;
        }
        if (n == 1)
        {

            cout<<1<<endl; return 0;
        }
     vector<ll> st(n+1);
     st[0]=1;st[1]=1;
     for(ll i=2;i<=n;i++){
        st[i]=(a[i-1]?0:st[i-1])+(a[i-2]?0:st[i-2]);
        st[i]%=mod;
     }
     cout<<st[n]<<endl;
        return 0;
}



Measured memory_bytes: 1024
<?php



function checkMonth($n){
    $n = (int)$n;
    if($n > 0 && $n < 13){
        return(true);
    }   else{
        return(false);
    }
}
$n = 0;
# 整数の入力
fscanf(STDIN, "%s", $n);

$array = str_split($n,2);

if(checkMonth($array[0]) && checkMonth($array[1])){
    echo "AMBIGUOUS";
}elseif(checkMonth($array[0])){
    echo "MMYY";
}elseif(checkMonth($array[1])){
    echo "YYMM";
}else{
    echo "NA";
}


Measured memory_bytes: 4604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int n; cin >> n;
    VI a(n);
    int maxa = 0;
    int maxindex = 0;
    REP(i,n)
    {
        int tmp;
        cin >> tmp;
        if(maxa < tmp) 
        {
            maxa = tmp;
            maxindex = i;
        }
        a[i] = tmp;
    }
    int second = -1;
    double diff = INF;

    REP(i,n)
    {
        if(i == maxindex) continue;

        if(abs(a[i] - maxa / 2.0) < diff)
        {
            second = a[i];
            diff = abs(a[i] - maxa / 2.0);
        }

    }
    cout << maxa << " " << second << endl;



}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static boolean isPrime(int n) {
		boolean out = true;
		int last = (int) (Math.floor(Math.sqrt(n)));
		for (int j = 3; j <= last; j += 2) {
			if (n % j == 0) {
				return false;
			}
		}
		return out;
	}

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

		int aCount = in.nextInt();
		int count = 0;
		int next;

		for (int i = 0; i < aCount; i++) {
			next = in.nextInt();
			if (next == 2) {
				count++;
			} else if (next % 2 != 0) {
				if (isPrime(next)) {
					count++;
				}
			}
		}
		System.out.println(count);
		in.close();
	}
}



Measured memory_bytes: 40964
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=998244353;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2LL*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll a, b, x;

ll gv(ll u, ll v)
{
	if(u<0) return 0;
	return u/v+1;
}

int main(void)
{
	cin>>a>>b>>x;
	cout<<gv(b,x)-gv(a-1,x);
}

// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    for (int i = 0; i < n; i++) {
      arr[i] = sc.nextInt();
    }

    trace(arr);
    insertionSort(arr);
  }

  static void insertionSort(int[] arr) {
		// 最初の要素はソート済みとする。ここを基準にしてそれ以降の要素を入れ替える
		for (int i = 1; i < arr.length; i++) {
			int tmp = arr[i];// 入れ替える要素を避けておいて
			int k = i;

			// 挿入する場所を探しつつ
			while (k > 0 && arr[k - 1] > tmp) {
				arr[k] = arr[k - 1];// 要素を大きいほうに詰める
				k--;
			}
      arr[k] = tmp;
      trace(arr);
    }
  }

  static void trace(int[] arr) {
    StringBuilder sb = new StringBuilder();
    for (int num : arr) {
      sb.append(num).append(' ');
    }
    System.out.println(sb.toString().trim());
  }
}


Measured memory_bytes: 29136
#include<iostream>
#include<string>
#include<vector>
#include<queue>
using namespace std;

vector<pair<long long, long long> > G[1000][1000];
bool val[1000][1000];

long long dep_max=0;

int main(){
    //input
    long long H,W;
    cin >> H >> W;
    string S;
    vector<string> A;
    long long i,j;
    for(i=0; i<H; i++){
        cin >> S;
        A.push_back(S);
    }

    //calc
    pair<pair<long long, long long>, long long> p;
    queue<pair<pair<long long, long long>, long long> > que;
    long long x,y,z,s,t;
    for(i=0; i<H; i++){
        for(j=0; j<W-1; j++){
            G[i][j].push_back(make_pair(i,j+1));
            G[i][j+1].push_back(make_pair(i,j));
        }
    }
    for(j=0; j<W; j++){
        for(i=0; i<H-1; i++){
            G[i][j].push_back(make_pair(i+1,j));
            G[i+1][j].push_back(make_pair(i,j));
        }
    }
    for(i=0; i<H; i++){
        for(j=0; j<W; j++){
            val[i][j]=0;
        }
    }
    for(i=0; i<H; i++){
        for(j=0; j<W; j++){
            if(A[i][j]=='#'){
                val[i][j]=1;
                que.push(make_pair(make_pair(i,j),0));
            }
        }
    }
    while(!que.empty()){
        p=que.front();
        que.pop();
        dep_max=max(p.second,dep_max);
        x=p.first.first;
        y=p.first.second;
        z=p.second;
        for(i=0; i<G[x][y].size(); i++){
            s=G[x][y][i].first;
            t=G[x][y][i].second;
            if(val[s][t]==0){
                val[s][t]=1;
                que.push(make_pair(make_pair(s,t),z+1));
            }
        }
    }


    //answer
    cout << dep_max << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 133428
/*
    WRITER:kakitamasziru
*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;
bool E[2005][2005];
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

int main() {
    int N,M;cin >> N >> M;
    vector<int> ans(N);
    for(int i = 0;i<M;i++){
        int A,B;cin >> A >> B;
        ans.at(A-1)++;
        ans.at(B-1)++;
    }
    for(int i = 0;i<N;i++) cout << ans.at(i) << endl;
    /*
    g++ abc.cpp
    ./a.out
    */
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<cstdlib>
    #include<cctype>
    #include<iostream>
    #include<string>
    #include<algorithm>
    #include<vector>
    #include<map>
    #include<stack>
    #include<queue>
    #include<set>
    using namespace std;
    typedef pair<int, int> pii;
    typedef double lf;
    typedef long long ll;
    const int inf=0x3f3f3f3f, mod=1000000007;
    struct node{int to, nxt;}edge[200200];
    int head[100100], cnt=0;
    
    inline int read()
    {
        int x=0,f=1; char ch=getchar();
        for (; ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') f=-1;
        for (; ch>='0' && ch<='9'; ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
        return x*f;
    }
    
    void add(int u, int v)
    {
        edge[++cnt]=(node){v, head[u]};
        head[u]=cnt;
    }
    
    int dfs(int u, int fa)
    {
        int res=0;
        for (int i=head[u]; i; i=edge[i].nxt)
        {
            int v=edge[i].to;
            if (v!=fa) res+=dfs(v, u);
        }
        if (res>=2) return res; else return res^1;
    } 
    
    int main()
    {
        int n=read();
        for (int i=1; i<n; i++)
        {
            int u=read(), v=read();
            add(u, v); add(v, u);
        }
        if (dfs(1, 0)) printf("First\n");
            else printf("Second\n");
        return 0;
    }


Measured memory_bytes: 2176
import static java.lang.System.*;

import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public void solve() {

		int N = nextInt();
		int M = nextInt();
		int[] A = new int[N];
		int total = 0;
		for(int i=0;i<N;i++) {
			A[i] = nextInt();
			total += A[i];
		}
		int count = 0;
		for(int i=0;i<N;i++) {
			if(A[i]*4*M>=total) {
				count++;
			}
		}
		String result = count >= M ? "Yes":"No";
		out.println(result);
	}

	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}

	double sqrt(double x) {
		return Math.sqrt(x);
	}

	double pow(double x, double y) {
		return Math.pow(x, y);
	}
	int max(int a,int b) {
		return Math.max(a, b);
	}

	public static void main(String[] args) {
		Main m = new Main();

		m.solve();
	}

	public void println(Object o) {
		out.println(o);
	}

}


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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k=in.nextInt();
		int [] a=new int [n];
		boolean [] ans = new boolean [k+1];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextInt();
		}
		ans[0]=false;
		for(int i=1;i<=k;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(i>=a[j])
				{
					if(ans[i-a[j]]==false)
					{
						ans[i]=true;
					}
				}
			}
		}
		if(ans[k]==true)
			System.out.println("First");
		else
			System.out.println("Second");
	}
}
	

Measured memory_bytes: 23252
ans = [[0]*10 for i in range(12)]
n = int(input())
for i in range(n):
    b,f,r,v = map(int,input().split())
    ans[(b-1)*3+f-1][r-1] += v
for i in range(0,12):
    if i%3 == 0 and i > 0:
        print('#'*20)
    print('',' '.join(map(str,ans[i][:])))


Measured memory_bytes: 5604
//In the Name of ̲A̲l̲l̲a̲h̲

#define pb push_back
#define F first
#define S second
#define sz size()
#define ll long long

#include <bits/stdc++.h>

using namespace std;

ll n, k, h[100001], dp[100001];

int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    dp[1] = abs(h[1]-h[0]);
    for (int i = 2; i < n; i++)
    {
        dp[i] = 1e9;
        for (int j = 1; j <= k && (i-j) >= 0; j++)
        {
            dp[i] = min((dp[i-j] + abs(h[i-j]-h[i])) , dp[i]);
        }
    }
    cout << dp[n-1];
}

/*𝐻𝒶𝒹𝒾*/


Measured memory_bytes: 1792
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
q = 2
cnt = [0] * 30
a.each do |i|
  q = i.lcm(q)
  c = 0
  until i % 2 != 0
    i /= 2
    c += 1
  end
  cnt[c] += 1
end
puts cnt.uniq.size == 2 ? (m + q/2) / q : 0



Measured memory_bytes: 23384
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    int N, M;
    std::string temp;
    std::vector<std::string> s, t, words;
    
    std::cin >> N;
    for (int i=0; i<N; ++i) {
        std::cin >> temp;
        s.push_back(temp);
        words.push_back(temp);
    }
    std::cin >> M;
    for (int i=0; i<M; ++i) {
        std::cin >> temp;
        t.push_back(temp);
        words.push_back(temp);
    }
    
    int score = -101;
    
    std::sort(words.begin(), words.end());
    words.erase(std::unique(words.begin(), words.end()), words.end());
    
    for (auto itr=words.begin(); itr!=words.end(); itr++) {
        int temp_score = 0;
        for (auto i=s.begin(); i!=s.end(); i++) {
            if (*itr == *i)
                temp_score++;
        }
        for (auto i=t.begin(); i!=t.end(); i++) {
            if (*itr == *i)
                temp_score--;
        }
        if (temp_score > score)
            score = temp_score;
    }
    
    std::cout << (score >= 0 ? score : 0) << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

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

  vector<double> v(n);
  rep(i,n) cin >> v.at(i);
  sort(v.rbegin(), v.rend());
  stack<double> s;
  rep(i,n){
    s.push(v.at(i));
  }

  while (s.size() != 1){
    double a, b, c;
    a = s.top(); s.pop();
    b = s.top(); s.pop();
    c = (a + b) / 2;
    s.push(c);
  }

  double ans = s.top();
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 3760