akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[]={1,2,4,8,16,32,64,128};
    int n;
    cin>>n;

    for(int i=0;i<8;i++)
    {
        if(a[i]>n)
        {
            cout<<a[i-1];
            break;
        }
    }
}


Measured memory_bytes: 256
/*
 Akhil Saini
 DP : Atcoder DP Series Problem 1 : Frog 1
*/
#include<bits/stdc++.h>
using namespace std;
#define f0(i,n)            for(i=0;i<n;i++)
#define flast(i,n)         for(i=n-1;i>=0;i--)
#define f1(i,n)            for(i=1;i<=n;i++)
#define f(i,a,n)           for(i=a;i<=n;i++)
#define fit(v)             for(auto itr=v.begin();itr!=v.end();itr++)
#define ump(a,b)           unordered_map<a,b>
#define ll                 long long int
#define endl               "\n"
#define fir                first
#define sec                second
#define pb                 push_back
#define bp                 __builtin_popcount
#define bit()              bitset<62>(x).to_string()
#define binstr_to_num(x)   stoll(x,nullptr,2)
#define mod                1000000007
#define inf                1e18+1
#define all(v)             v.begin(),v.end()
#define debug              cout<<"Hello"<<endl
typedef                    vector<ll> vll;
const double pi=acos(-1.0);

//You can only take 1 or 2 steps then in
//how many ways you can reach to the nth stairs.

ll dp[1000001];
vector<ll> v;

//Function to store ans of each stairs. 
ll dp_function(ll n)
{
    if(n==0)
    return 0;
    if(n==1)
    return abs(v[0]-v[1]);

    if(dp[n]!=-1) return dp[n];

    dp[n]=min(dp_function(n-1)+abs(v[n-1]-v[n]),dp_function(n-2)+abs(v[n-2]-v[n]));
    return dp[n];
}

void solve()
{
    ll n,x,i;
    cin>>n;
    v.clear();
    f0(i,n) { cin>>x; v.push_back(x); }
    cout<<dp_function(n-1)<<endl;
}

void fast()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

int main()
{
    fast();
    int t=1,i;
    f1(i,1000000) dp[i]=-1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 14132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  vector<ll>h(n);
  rep(i,n)cin >> h[i];
  ll ng = 0,ok = 1e9;
  while(abs(ng - ok) > 1){
    ll mid = (ok + ng) / 2;
    bool can = false;
    ll tmp = 0;
    rep(i,n){
      tmp += (max((ll)0,h[i] - b * mid) + a - b - 1) / (a - b);
    }
    if(tmp <= mid)can = true;
    if(can)ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 4012
A,B = map(int,input().split())
S = str(input())
len_S = len(list(S))
S[A].isdecimal()
if S[A] == "-" and S[0:A] != "-" and S[A+1:] != "-" and S[0:A].isdecimal()== True and S[A+1:].isdecimal() ==  True and len_S == A+B+1:
        print("Yes")
else:
        print("No")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    ll r;
    cin >> r;
    cout << M_PI * r * 2 << endl;
    return 0;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
  
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	ll n,k;
	cin>>n;
	ll a[n+1];
	for(i=0;i<n;i++)
	cin>>a[i];
	ll dp[n+1][n+1];
	for(int l=n-1;l>=0;l--)
	for(int r=l;r<n;r++)
	{
		if(l==r)
		dp[l][r]=a[l];
		else
		{
			dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
		}
	}
	cout<<dp[0][n-1];
	cout<<"\n"; 
 } 
}


Measured memory_bytes: 46464
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<sstream>
using namespace std;
typedef long long ll;
const ll maxn=1e6+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
void io(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int main()
{
	io();
	ll n,k;
	cin>>n>>k;
	if(k==1||n%k==0)
		cout<<"0"<<endl;
	else
	{
		ll ans=n%k;
		cout<<min(abs(ans-k),ans)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a[5];
    for(int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < 5; i++) {
        if(a[i] == 0) {
            cout << (i + 1) << endl;
            break;
        }
    }
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string s;
  cin >> s;
  int N = s.size();
  string ans = "";
  REP(i, N) {
    if (s[i] == '0')
      ans += "0";
    else if (s[i] == '1')
      ans += "1";
    else {
      if (ans.size()) {
        ans = ans.substr(0, ans.size() - 1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin>>a[i];

    sort(ALL(a));
    int minv=INF;
    REP(i,n-1){
        minv=min(minv,gcd(a[0],a[i+1]));
    }

    cout<<minv<<endl;
    
	return 0; 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  if (N < 2) cout << 1 << endl;
  else if (N < 4) cout << 2 << endl;
  else if (N < 8) cout << 4 << endl;
  else if (N < 16) cout << 8 << endl;
  else if (N < 32) cout << 16 << endl;
  else if (N < 64) cout << 32 << endl;
  else cout << 64 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int x,y;
    while(1){
        scanf("%d%d",&x,&y);
        if(x==0 && y==0)break;
        if(x>y){
            printf("%d %d\n",y,x);
        }else if(x<y){
            printf("%d %d\n",x,y);
        }
        if(x==y){
            printf("%d %d\n",x,y);
        }
    }
        return 0;

}

Measured memory_bytes: 600
import std.stdio;

void main(){
	auto cin = new Cin();
	
	auto ab = cin.line!long();
	
	if( ab[0] <= 0 && 0 <= ab[1] ){
		writeln("Zero");
	} else if( ab[1]<0 && (ab[1]-ab[0])%2==0 ){
		writeln("Negative");
	} else {
		writeln("Positive");
	}
	
	//sum.writeln();
}
auto solve(){
}
unittest{
	
}


import std.stdio,std.conv,std.string;
import std.algorithm,std.array;

class Cin
{
	T[] line( T = size_t , string token = " " )( size_t m = 1 ){
		T[] arr = [];
		foreach( i ; 0..m ){
			arr ~= this.read!T();
		}
		return arr;
	}
	T[][] rect( T = size_t , string token = " " )( size_t m = 1 ){
		T[][] arr = new T[][](m);
		foreach( i ; 0..m ){
			arr[i] = this.read!T(token);
		}
		return arr;
	}
	private T[] read( T = size_t )( string token = " " ){
		T[] arr;
		foreach( elm ; readln().chomp().split(token) ){
			arr ~= elm.to!T();
		}
		return arr;
	}
}

Measured memory_bytes: 256
# include <stdio.h>

int main(){
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  if ( a+b-c-d > 0){
    printf("%s\n","Left");
  }
  else if ( a+b-c-d < 0){
    printf("%s\n","Right");
  }else{
    printf("%s\n","Balanced");
  }
  return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int n, s;
    cin >> n >> s;

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int sum = 0;
    int len = INF;
    int j = 0;
    rep(i, n){
        while(sum < s && j < n){
            sum += a[j++];
        }
        if(j - i < len && sum >= s){
            len = j - i;
        }
        sum -= a[i];
    }
    cout << (len == INF ? 0 : len) << endl;

    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
int main()
{
	char c[4];
	for(int i=0;i<4;i++)
		cin>>c[i];
	int cnt=0;
	int yeno=0;
	for(int i=1;i<4;i++)
	{
		cnt++;
		if(c[0]==c[i])
		{
			if(cnt==1)
				if(c[2]==c[3])
					if(c[1]!=c[2])
				yeno=1;		
			if(cnt==2)
				if(c[1]==c[3])
						if(c[1]!=c[2])
				yeno=1;	
			if(cnt==3)
				if(c[1]==c[2])
					if(c[1]!=c[3])
				yeno=1;			
		}
	}
	if(yeno==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    string s;
    cin >> s;

    if (s == "Sunny") {
        cout << "Cloudy" << '\n';
    } else if (s == "Cloudy") {
        cout << "Rainy" << '\n';
    } else {
        cout << "Sunny" << '\n';
    }

    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int N;
int A[100010];
bool F[100010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	int cnt=0;
	int ans=0;
	REP(i,N){
		if(A[i]!=0){
			cnt+=A[i];
		}
		else{
			ans+=cnt/2;
			cnt=0;
		}
	}
	ans+=cnt/2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long a[5],b,ans;
int main(void){
    // Your code here!
    cin>>b;
    for(int i=0;i<5;i++)cin>>a[i];
    sort(a,a+5);
    long long ppap=b/a[0];

    if(b%a[0]!=0&&b>a[0])ppap++;
    
    if(ppap!=0)ppap-=1;
    cout<<5+ppap<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi                    3.14159265359
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

const int N=1e4+10;
const int M=1e3+10;
int dp[M][2*N];

int main()
{
    fastio;
    int h,n;cin>>h>>n;
    int nn=n+1;
    int a[nn],b[nn];
    rep(i,1,nn)cin>>a[i]>>b[i];
    rep(i,0,M)
        rep(j,0,2*N)
            dp[i][j]=INT_MAX-1e6;

    rep(i,0,M)dp[i][0]=0;

    rep(i,1,nn)
        rep(j,1,2*N)
            dp[i][j]=min(dp[i-1][max(0ll,j-a[i])]+b[i],min(dp[i][max(0ll,j-a[i])]+b[i],dp[i-1][j]));

    rep(i,1,nn)
        for(int j=2*N-2;j>=1;j--)
            dp[i][j]=min(dp[i][j],dp[i][j+1]);

    int ans=INT_MAX;
    rep(i,1,nn)
        ans=min(ans,dp[i][h]);

    cout<<ans;
}


Measured memory_bytes: 79232
n, m = map(int, input().split())
c = [0] * m
ans = 0
for i in range(n):
    a = list(map(int, input().split()))
    for i in range(a[0]):
        c[a[i + 1] - 1] += 1
for i in c:
    if i == n:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	
	long long ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(i == 0)
		{
			ans = k;
		}
		else
		{
			ans *= k - 1;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
public class compiler
  Shared Sub Main()
    Dim n As Integer = CType(Console.ReadLine(), Integer)
    Dim input As String = Console.ReadLine()
    Dim d As String()  = input.split(" ")
    Dim dInt(0 To n - 1) As Integer
    For i As Integer = 0 To n - 1
        dInt(i) = CType(d(i), Integer)
    Next
    Array.Sort(dInt)
    Dim output As Integer = dInt(n / 2) - dInt(n / 2 - 1)
    Console.WriteLine(output.ToString())
  End Sub
end class

Measured memory_bytes: 26204
#include"bits/stdc++.h"

using namespace std;

int main() {
	int N;
	cin >> N;
	set <int > num;

	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		num.insert(x);
	}
	
	cout << num.size() << endl;

	return 0;
}

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

const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);

using Point = complex<double>;
using Polygon = vector<Point>;

inline int sgn(const double &a) { return (a < -EPS ? -1 : (a > EPS ? 1 : 0)); }

inline bool eq(const Point &a, const Point &b) { return abs(a - b) < EPS; }

namespace std {
inline bool operator<(const Point &a, const Point &b) {
    if (sgn(a.real() - b.real()))
        return sgn(a.real() - b.real()) < 0;
    return sgn(a.imag() - b.imag()) < 0;
}
} // namespace std

double dot(const Point &a, const Point &b) { return real(conj(a) * b); }

double det(const Point &a, const Point &b) { return imag(conj(a) * b); }

struct Line {
    Point p1, p2;

    Line(Point p1 = Point(), Point p2 = Point()) : p1(p1), p2(p2) {}

    bool operator<(const Line &rhs) const {
        if (eq(p2, rhs.p2))
            return p1 < rhs.p1;
        return p2 < rhs.p2;
    }
    bool operator==(const Line &rhs) const {
        return (eq(p1, rhs.p1) && eq(p2, rhs.p2)) ||
               (eq(p1, rhs.p2) && eq(p2, rhs.p1));
    }
};

inline Point curr(const Polygon &p, const int &i) { return p[i % p.size()]; }

inline Point next(const Polygon &p, const int &i) {
    return p[(i + 1) % p.size()];
}

inline Point prev(const Polygon &p, const int &i) {
    return p[(i + p.size() - 1) % p.size()];
}

double convex_diameter(const Polygon &pg) {
    const int n = pg.size();
    int ps = 0, qs = 0;
    for(int i=1;i<n;i++){
        if(pg[i].imag() > pg[ps].imag())ps = i;
        if(pg[i].imag() < pg[qs].imag())qs = i;
    }
    double diameter = abs(pg[ps] - pg[qs]);

    int p = ps, q = qs, maxp = ps, maxq = qs;
    do {
        if(sgn(det(next(pg, p)-curr(pg, p), next(pg, q)-curr(pg, q))) >= 0)
            q = (q+1) % n;
        else
            p = (p+1) % n;
        double d = abs(pg[p] - pg[q]);
        if(sgn(d - diameter) > 0){
            diameter = d;
            maxp = p;
            maxq = q;
        }
    }while(p != ps || q != qs);
    return diameter;
}

int main(){
    int n;
    cin >> n;
    Polygon pg;
    for(int i=0;i<n;++i){
        double x, y;
        cin >> x >> y;
        pg.push_back(Point(x, y));
    }

    printf("%.10f\n", convex_diameter(pg));

    return 0;
}



Measured memory_bytes: 4864
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text as T
import qualified Data.Text.IO as TIO

main :: IO ()
main = do
  str <- TIO.getLine
  let length = T.length str
      strBef = T.take ((length-1)`div`2) str
      strAft = T.drop ((length+1)`div`2) str
  if all (==True) [isPalindrome str, isPalindrome strBef, isPalindrome strAft]
    then TIO.putStrLn "Yes"
    else TIO.putStrLn "No"
isPalindrome :: T.Text -> Bool
isPalindrome text = text == (T.reverse text)


Measured memory_bytes: 508
import java.util.*;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        String r="";

        while(c>0 && a>0){
            c-= b;
            if(c<=0) {
                r="Yes";
                break;
            }
            a-=d;
            if(a<=0) {
                r="No";
                break;
            }
        }

        System.out.println(r);
    }
}

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

int main(){
    int n;
    cin >> n;
    int s = 2;
    int res = 1;
  	if(n <= 2){
      	cout << 1 << endl;
      return 0;
    }
  	else{
        rep(i,10){
            if(s*2 > n) break;
            else {
                s *= 2;
                res++;
            }
        }
    }
    cout << pow(2,res) << endl;
}

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

int main() {
  int N, M;
  cin >> N;
  vector<string>a(N);
  vector<string>b(M);
  for (int i = 0; i<N;i++)
    cin >> a.at(i) ;
  cin >> M;
  for (int j = 0; j<M;j++)
    cin >> b.at(j);
  vector<int>vec(N);
  for (int i = 0; i<N;i++){
    for (int k = 0 ; k<N;k++){
      if (a.at(k) == a.at(i))
        vec.at(i)++;
    }
    for (int l = 0; l<M; l++){
      if (b.at(l) ==a.at(i))
        vec.at(i)--;
    }
  }
  sort(vec.begin(),vec.end());
  if(vec.at(N-1)>=0)
    cout << vec.at(N-1) <<endl;
  else
    cout << 0 <<endl;
}
    

        
      
  
 

Measured memory_bytes: 512
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
 
int main(){
int ans=0,n=read(),k=read(),now=1;
for (;now<n;++ans) now+=k-1;
write(ans); 
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <vector>
using std::bitset;
using std::cin;
using std::cout;
using std::vector;

int main() {
    int n;
    cin >> n;
    vector<bitset<32>> a;
    for (int i = 0; i < n; ++i) {
        long ai;
        cin >> ai;
        bitset<32> aib(ai);
        a.push_back(aib);
    }
    vector<bool> inv(32);
    std::fill(inv.begin(), inv.end(), false);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 32; ++j) {
            if (a[i][j]) inv[j] = !inv[j];
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 32; ++j) {
            if (inv[j]) a[i].flip(j);
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << a[i].to_ulong() << (i + 1 != n ? ' ' : '\n');
    }
    return 0;
}

Measured memory_bytes: 5236
N = int(input())
x, a, b, c = 0, 0, 0, 0
for i in range(N):
	s = input()
	x += s.count('AB')
	if s[-1] == 'A' and s[0] == 'B':
		c += 1
	elif s[-1] == 'A':
		a += 1
	elif s[0] == 'B':
		b += 1
if a == 0 and b == 0:
	x += max(c - 1, 0)
else:
	x += min(a, b) + c
print(x)

Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.conv, std.range, std.string;
 
void main(){
    string line;
    while(line = readln.chomp, line.length){
        auto d = line.to!int;
        int s;
        for(int x = 0; x < 600; x += d){
            s += x * x * d;
        }
        s.writeln;
        //auto d2 = reduce!((a, b) => a + b * b * d)(0, iota(d, 600, d));
        //if(d != d2) throw new Exception(text(d, " ", d2));
        //s.writeln;
    }
}

Measured memory_bytes: 972
#A
"""
n,k =map(int, input().split())

print(k * (k - 1)**(n - 1)) 
"""

#B
"""
import math
r, n, m = map(int, input().split())
kankaku = 2 * r / n
tyusin = n / 2
sum = 0
for i in range(1, n + m):
    if i - m < 0:
        yoko1 = 2 * math.sqrt(r ** 2 - ((tyusin - i) * kankaku)** 2)
        sum += yoko1
    elif i > n:
        yoko2 = 2*math.sqrt(r ** 2 - ((tyusin - i + m) * kankaku)** 2)
        sum += yoko2
    else:
        yoko1 = 2 * math.sqrt(r ** 2 - ((tyusin - i) * kankaku)** 2)
        yoko2 = 2 * math.sqrt(r ** 2 - ((tyusin - i + m) * kankaku)** 2)
        sum += max(yoko1, yoko2)
print(sum)
"""

#C
"""
n = int(input())
an = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += an[i] - 1
print(ans)
"""
#D

import itertools
s = input()
sum = int(s)
sb = list(s)
for i in range(1, len(s)):
    a = list(itertools.combinations(list(range(1,len(s))), i))
    for k in a:
        sb = list(s)
        f = 0
        for n in k:
            sb.insert(n + f, "+")
            f += 1
        b = ""
        for n in sb:
            if n == "+":
                sum += int(b)
                b = ""
            else:
                b += n
        sum += int(b)

print(sum)
    

Measured memory_bytes: 39664
#include <bits/stdc++.h>
#define REP(i, n, s) for (LL i = (s); i < (n); i++)
#define SIZE 200001
using namespace std;
typedef long long int LL;
typedef long double LD;

struct UF {
	int par[SIZE], ran[SIZE];
	void init(int n) {
		REP(i, n, 0) par[i] = i;
	}
	int getpar(int n) {
		if (par[n] == n) return n;
		par[n] = getpar(par[n]);
		return par[n];
	}
	void mrg(int a, int b) {
		a = getpar(a), b = getpar(b);
		if (a == b) return;
		if (ran[a] > ran[b]) par[a] = b;
		else {
			par[b] = a;
			if (ran[a] == ran[b]) ran[a]++;
		}

	}
} UA, UB;

vector<int> hv[SIZE];
int freq[SIZE];
int ans[SIZE];
int N, K, L, A, B;

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

	cin >> N >> K >> L;
	UA.init(N);
	UB.init(N);
	while (K--) {
		cin >> A >> B;
		UA.mrg(--A, --B);
	}
	while (L--) {
		cin >> A >> B;
		UB.mrg(--A, --B);
	}
	REP(i, N, 0) hv[UA.getpar(i)].push_back(i);
	REP(i, N, 0) if (hv[i].size()) {
		for (int u: hv[i]) freq[UB.getpar(u)]++;
		for (int u: hv[i]) ans[u] = freq[UB.getpar(u)];
		for (int u: hv[i]) freq[UB.getpar(u)]--;
	}
	REP(i, N, 0) cout << ans[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 14208
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;

int main()
{
    string S;
    cin >> S;
    bool ok = true;
    for( int i = 0; i < S.size(); i++ ) {
        if( i % 2 == 0 ) {
            if( !(S[i] == 'R' || S[i] == 'U' || S[i] == 'D') ) {
                ok = false;
            }
        }else{
            if ( !(S[i] == 'L' || S[i] == 'U' || S[i] == 'D' ) ) {
                ok = false;
            }
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

template<Int MOD = 1000000007>
struct Mod{
  Int prev=0;
  vector<Int> fact,inv,finv;
  Mod(){}
  Mod(Int n){init(n);}
  
  Int pow(Int x,Int n){
    Int res=1;
    while(n){
      if(n&1) (res*=x)%=MOD;
      (x*=x)%=MOD;
      n>>=1;
    }
    return res;
  }
  
  Int inverse(Int a){
    return pow(a,MOD-2);
  }
  
  void init(Int n){
    if(prev>=n) return;
    prev=n;
    fact=inv=finv=vector<Int>(n);
    
    fact[0]=1;
    for(Int i=1;i<n;i++)
      fact[i]=(fact[i-1]*i)%MOD;
    
    inv[1]=1;
    for(Int i=2;i<n;i++)
      inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    
    finv[0]=1;
    for(Int i=1;i<n;i++)
      finv[i]=finv[i-1]*inv[i]%MOD;
  }
  
  Int comb(Int n,Int k){
    Int res=1;
    for(Int i=0;i<k;i++){
      res*=(n-i)%MOD;
      res%=MOD;
      res*=inverse(i+1);
      res%=MOD;
    }
    return res;
  }
  
  //only for prime MOD
  Int C(Int n,Int k){
    if(k<0||k>n) return 0;
    return fact[n]*finv[k]%MOD*finv[n-k]%MOD;
  }

  Int H(Int n,Int k){
    return C(n+k-1,n);
  }

  Int S(Int n,Int k){
    Int res=0;
    for(Int i=1;i<=k;i++){
      Int tmp=C(k,i)*pow(i,n)%MOD;
      if((k-i)&1) res+=MOD-tmp;
      else res+=tmp;
      res%=MOD;
    }
    res=res*finv[k]%MOD;
    return res;
  }
  
  Int B(Int n,Int k){
    Int res=0;
    for(Int j=1;j<=k;j++){
      res+=S(n,j);
      res%=MOD;
    }
    return res;
  }

  
  vector<vector<Int> > D(Int n,Int m){
    vector<vector<Int> > dp(n+1,vector<Int>(m+1,0));
    dp[0][0]=1;
    for(Int i=0;i<=n;i++){
      for(Int j=1;j<=m;j++){
	if(i-j>=0) dp[i][j]=(dp[i][j-1]+dp[i-j][j])%MOD;
	else dp[i][j]=dp[i][j-1];
      }
    }
    return dp;
  }
  
  Int montmort(Int n){
    Int res=0,rinv=1;
    for(Int k=2;k<=n;k++){
      rinv=rinv*inverse(k)%MOD;
      if(k%2) res+MOD-rinv;
      else res+=rinv;
      res%=MOD;
    }
    for(Int i=1;i<=n;i++) res=res*i%MOD;
    return res;
  }
  
  // calculate P(t) from given points in [0,N]
  Int LagrangePolynomial(vector<Int> &y,Int t){
    Int n=y.size()-1;
    init(n+1);
    Int num=1;
    for(Int i=0;i<=n;i++)
      num=num*((t-i)%MOD)%MOD;
    Int res=0;
    for(Int i=0;i<=n;i++){
      Int tmp=(y[i]*num%MOD)*inverse((t-i)%MOD)%MOD;
      tmp=tmp*finv[i]%MOD;
      tmp=tmp*finv[n-i]%MOD;
      if((n-i)&1) tmp=MOD-tmp;
      res=(res+tmp)%MOD;
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  const Int MOD = 1e9+7;
  Mod<MOD> mod(2e5);
  Int n,k;
  cin>>n>>k;
  cout<<mod.D(n,k)[n][k]<<endl;
  return 0;
}



Measured memory_bytes: 15472
from collections import deque
Q = deque()
q = int(input())
for i in range(q):
    a = input()
    if   a[0] == '0': Q.append(a[2:])      # pushBack
    elif a[0] == '1': print(Q[int(a[2:])]) # randomAccess
    else:             Q.pop()              # popBack


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main() {
    fast;
    string s,t;
    cin >> s >> t;

    int ans = inf;

    f(i,0,sz(s) - sz(t) + 1){
        int cur = 0;
        f(j,0,sz(t)) cur += s[i+j] != t[j];
        ans = min(ans, cur);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e8;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    LL a[n], sq = 0, sum = 0, mn = INF, mx = -INF;
    loop(i,0,n)
    {
        cin>>a[i];
        sum += a[i];
        sq += (a[i] * a[i]);
        mn = min(mn,a[i]);
        mx = max(mx,a[i]);
    }

    LL ans = INT_MAX, cst;
    loop(i,mn,mx+1)
    {
        cst = sq + (n * i * i) - (2 * i * sum);
        ans = min(ans,cst);
    }

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n) cin>>a[i];
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3648
package main

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

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_D&lang=jp>
 */

var S int

func init() {
	S, _ = IntStdin()
}

func main() {
	fmt.Printf("%d:%d:%d\n",S/3600,(S%3600)/60,S%60)
}

// ????????????1?????????
func StrStdin() (stringReturned string) {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	stringInput := scanner.Text()

	stringReturned = strings.TrimSpace(stringInput)
	return
}

// ??´??°???1?????????
func IntStdin() (int, error) {
	stringInput := StrStdin()
	return strconv.Atoi(strings.TrimSpace(stringInput))
}

// ?????????????????????????????????????????????Split()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}

	return
}

// ??????????????§??????????????????????????????????????????
func SplitStrStdin(delim string) (stringReturned []string) {
	// ???????????§1?????????
	stringInput := StrStdin()

	// ????????§??????
	// stringSplited := strings.Split(stringInput, delim)
	stringReturned = SplitWithoutEmpty(stringInput, delim)

	return
}

// ??????????????§??????????????´??°????????????????????????
func SplitIntStdin(delim string) (intSlices []int, err error) {
	// ??????????????????????????????
	stringSplited := SplitStrStdin(" ")

	// ??´??°?????????????????????
	for i := range stringSplited {
		var iparam int
		iparam, err = strconv.Atoi(stringSplited[i])
		if err != nil {
			return
		}
		intSlices = append(intSlices, iparam)
	}
	return
}

Measured memory_bytes: 1100
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define SETMAX(a, b) a = max(a, (b));

int main(){
    ll r, c, k;
    cin >> r >> c >> k;
    vector<vector<ll>> v(r, vector<ll>(c, 0LL));
    REP(i, k){
        ll ri, ci, vi;
        cin >> ri >> ci >> vi;
        ri--; ci--;
        v.at(ri).at(ci) = vi;
    }

    vector<vector<vector<ll>>> dp(r, vector<vector<ll>>(c, vector<ll>(4, 0)));
    ll ans = 0;
    REP(i, r){
        REP(j, c){
            REP(n, 4){
                if(v.at(i).at(j) > 0){
                    if(n == 0){
                        if(i > 0){
                            REP(m, 4){
                                SETMAX(dp[i][j][n], dp[i - 1][j][m]);
                            }
                        }
                        if(j > 0){
                            SETMAX(dp[i][j][n], dp[i][j - 1][n]);
                        }
                    }else{
                        if(n == 1){
                            SETMAX(dp[i][j][1], dp[i][j][0] + v[i][j]);
                        }
                        if(j > 0){
                            SETMAX(dp[i][j][n], dp[i][j - 1][n]);
                            SETMAX(dp[i][j][n], dp[i][j - 1][n - 1] + v[i][j]);
                        }
                    }
                }else{
                    if(n == 0){
                        if(i > 0){
                            REP(m, 4){
                                SETMAX(dp[i][j][n], dp[i - 1][j][m]);
                            }
                        }
                    }
                    if(j > 0){
                        SETMAX(dp[i][j][n], dp[i][j - 1][n]);
                    }
                }
                // cerr << i << ", " << j << ", " << n << " =" << dp.at(i).at(j).at(n) << endl;
                ans = max(dp.at(i).at(j).at(n), ans);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 706068
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] A = new int[N + 1];
            for (int i = 0; i < N; i++) {
                A[in.nextInt()] = i + 1;
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < N; i++) {
                sb.append(A[i + 1]).append(' ');
            }
            out.println(sb.substring(0, sb.length() - 1));
        }

    }
}



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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;

const string YES = "Yes";
const string NO = "No";

void solve()
{
  ll N;
  scanf("%lld",&N);
  vector<ll> L(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&L[i]);
  }
  sort(L.begin(),L.end());
  ll sum=0;
  for (int i=0; i<N-1; i++) {
    sum+=L[i];
  }
  if (L.back()>=sum) cout << NO << endl;
  else cout << YES << endl;
}

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


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;

  int ans = 0;
  int l = S.length();
  REP(i, l / 2) {
    if (S[i] != S[l - 1 - i]) {
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int x,a,b;
   cin>>x>>a>>b;
   if(a>=b)
   {
       cout<<"delicious";
   }
   else if(a+x<b)
   {
       cout<<"dangerous";
   }
   else
    cout<<"safe";


    return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>

int main(int argc, char** argv)
{
	std::string S;
	std::cin>>S;	
	int N = S.length();
	int start = 0;
	int end = N-1;
	int count = 0;
	while(start<end)
	{
		if(S[start] == S[end])
		{
			start++;
			end--;
		}
		else if(S[start] == 'x')
		{
			count++;
			start++;
		}
		else if(S[end] == 'x')
		{
			count++;
			end--;
		}
		else
		{
			count = -1;
			break;
		}
	}
	printf("%d\n", count);
	
	return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    ll N;
    cin >> N;
    vector<ll> N_S(N+1);
    for (ll i = 1; i <= N; ++i) {
        for (ll j = 1; i*j <= N; ++j) {
            N_S[i*j] += 1;
        }
    }
    ll res = 0;
    for (ll i = 1; i <= N; ++i) {
        res += N_S[i] * i;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 81396
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

struct edge
{
    ll from, to, cost;
};

vector<int> G1[2501], G2[2501];
vector<bool> from1(2501), toN(2501);
vector<vector<edge>> G(2500);

void dfs1(int v) {
    if (from1[v]) return;
    from1[v] = true;
    for (auto to : G1[v]) {
        dfs1(to);
    }
}

void dfsN(int v) {
    if (toN[v]) return;
    toN[v] = true;
    for (auto to : G2[v]) {
        dfsN(to);
    }
}

int main()
{
    int N, M, P;
    cin >> N >> M >> P;

    vector<edge> E;
    rep(i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        A--; B--; C -= P; C = -C;
        G1[A].push_back(B);
        G2[B].push_back(A);
        E.push_back({A, B, C});
    }

    dfs1(0); dfsN(N - 1);

    vector<bool> ok(N);
    rep(i, N) ok[i] = from1[i] & toN[i];

    vector<ll> d(N, INF);
    d[0] = 0;
    bool update = true;
    int cnt = 0;
    while (update) {
        update = false;
        rep(i, M) {
            edge e = E[i];
            if (!ok[e.to] || !ok[e.from]) continue;
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        cnt++;
        // 負閉路判定
        if (cnt > N) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << max(0LL, -d[N - 1]) << endl;
    return 0;
}

Measured memory_bytes: 896
/*
 * main.cpp
 *
 *  Created on: 2011/04/08
 *      Author: satoki
 *      5:01 ~ 5:09
 */
#include <iostream>
#include <string.h>
using namespace std;

int iN;

bool input() {
  if (scanf("%d", &iN) == EOF) return false;
  return true;
}

int manage() {
  int a, b, c, d, cnt = 0;
  for (a = 0; a < 10; a++) {
    for (b = 0; b < 10; b++) {
      for (c = 0; c < 10; c++) {
        for (d = 0; d < 10; d++) {
          if (a + b + c + d == iN) cnt++;
        }
      }
    }
  }
  return cnt;
}

int main() {
  while (1) {
    if (!input()) break;
    printf("%d\n", manage());
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
import static java.lang.Math.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt = 0;
        for(int i=0; i<n; i++){
            int num = sc.nextInt();
            if(num%2==1){
                cnt++;
            }
        }
        if(cnt%2==1){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
}

Measured memory_bytes: 48684
#include "bits/stdc++.h"
using namespace std;
pair<int,int> Array[200005];

int main(){
    int N , i;
    scanf( "%d" , &N );

    for( i = 1 ; i <= N ; ++i )
        scanf( "%d%d" , &Array[i].second , &Array[i].first );

    sort( Array + 1 , Array + N + 1 );
    long long Total = 0;

    for( i = 1 ; i <= N ; ++i ){
        if( Total + Array[i].second <= Array[i].first )
            Total += Array[i].second;
        else{
            puts( "No" );
            return 0;
        }
    }

    puts( "Yes" );
    return 0;
}

Measured memory_bytes: 1792
/*input
eye
eel
*/
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	string a,b;
	cin>>a;
	cin>>b;
	reverse(a.begin(),a.end());
	if(a==b)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<std::pair<int64_t, int64_t>> s(n), c(m);
  std::cin >> s >> c;

  for (const auto i : s) {
    int c_i = 1;
    int64_t l = std::abs(i.first - c[0].first)
      + std::abs(i.second - c[0].second);

    for (int j = 1; j < m; j++) {
      int64_t tt = std::abs(i.first - c[j].first)
        + std::abs(i.second - c[j].second);
      if (tt < l) {
        c_i = j + 1;
        l = tt;
      }
    }
    std::cout << c_i << std::endl;
  }
  return 0;
}

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

int main()
{
  long long int n,m,count=0;
  double tot=0;
  cin>>n>>m;
  
  vector<double>v(n);
  
  for(long long int i=0;i<n;i++)
  {
    cin>>v[i];
    tot = tot + v[i];
  }
  
  tot = tot/(4*m);
  
  for(long long int i=0;i<n;i++)
  {
    if((double)v[i] >= tot)
    {
      count++;
    }
  }
//  cout<<tot<<" "<<count<<" ";
  if(count >= m)
  {
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  return 0;  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
const int N = 1e5+5;
const int INF = (1<<30)-1;
 
int hd[N],iter[N],dis[N];
struct E{int v,w,nxt;}e[N<<2];
queue<int>Q;
bool v[N];
int p[N],q[N],c[N],d[N];
int n,nc,nd,tot=1,S,T;
 
inline void add(int u,int v,int w,int w2){
	e[++tot]={v,w,hd[u]};hd[u]=tot;
	e[++tot]={u,w2,hd[v]};hd[v]=tot;
}
inline bool bfs(){
	rep(i,S,T) iter[i]=hd[i], dis[i]=-1;
	Q.push(S);dis[S]=0;
	while(!Q.empty()){
		int x=Q.front();Q.pop();
		for(int i=hd[x],y;i;i=e[i].nxt)
			if(e[i].w&&dis[y=e[i].v]==-1){
				dis[y]=dis[x]+1, Q.push(y);
			}
	}
	return ~dis[T];
}
int dfs(int x=S,int f=INF){
	if(x==T||!f)return f;
	int sf=0,y;
	for(int &i=iter[x];i;i=e[i].nxt)
		if(e[i].w&&dis[y=e[i].v]==dis[x]+1){
			int w=dfs(y,min(f,e[i].w));
			e[i].w-=w, e[i^1].w+=w;
			f-=w, sf+=w;
			if(!f)break;
		}
	return sf;
}
 
void prep(int p[],int c[],int &m){
	m = 0;
	rep(i,1,n) if(!c[i]){
		++m;
		for(int x=i;!c[x];x=p[x]) c[x] = m;
	}
}
 
int main() {
	scanf("%d",&n);
	rep(i,1,n)scanf("%d",p+i),++p[i];
	rep(i,1,n)scanf("%d",q+i),++q[i];
	prep(p,c,nc);
	prep(q,d,nd);
	S = 0, T = nc+nd+1;
	int ans = n;
	rep(i,1,n){
		bool f1 = (p[i]==i), f2 = (q[i]==i);
		if(f1&&f2) --ans;
		else if(f1) add(nc+d[i],T,1,0);
		else if(f2) add(S,c[i],1,0);
		else add(nc+d[i],c[i],1,p[i]==q[i]);
	}
	int flow = 0;
	while(bfs()) flow += dfs();
	printf("%d\n",ans-flow);
	return 0;
}

Measured memory_bytes: 7168
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for(ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
template<typename T> inline void print(const T &x){ cout << x << endl; }
template<typename T> inline void print(const vector<T> &x){ rep(i, SZ(x)){ cout << x[i] << " \n"[i+1==SZ(x)]; } cout << flush; }
template<typename T> inline void print(const vector<T> &x, ll s, ll n){ repr(i, s, n){ cout << x[i] << " \n"[i+1==n]; } cout << flush; }
template<typename T> inline void printv(const vector<T> &x){ rep(i, SZ(x)){ cout << x[i] << "\n"; } cout << flush; }
template<typename T> inline void printv(const vector<T> &x, ll s, ll n){ repr(i, s, n){ cout << x[i] << "\n"; } cout << flush; }
template<typename T> inline void print(const vector<vector<T>> &x){ rep(i, SZ(x)){ rep(j, SZ(x[i])){ cout << x[i][j] << " \n"[j+1==SZ(x[i])]; } } cout << flush; }
template<typename T> inline void print(const vector<vector<T>> &x, ll s1, ll n1, ll s2, ll n2){ repr(i, s1, n1){ repr(j, s2, n2){ cout << x[i][j] << " \n"[j+1==n2]; } } cout << flush; }
template<typename T, size_t S> inline void print(const T (&x)[S], ll s = 0, ll n = S){ repr(i, s, n){ cout << x[i] << " \n"[i+1==n]; } cout << flush; }
inline void print(const char* x){ cout << x << endl; }
template<typename T, size_t S> inline void printv(const T (&x)[S], ll s = 0, ll n = S){ repr(i, s, n){ cout << x[i] << "\n"; } cout << flush; }
template<typename T, size_t S1, size_t S2> inline void print(const T (&x)[S1][S2], ll s1 = 0, ll n1 = S1, ll s2 = 0, ll n2 = S2){ repr(i, s1, n1){ repr(j, s2, n2){ cout << x[i][j] << " \n"[j+1==n2]; } } cout << flush; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
#pragma endregion

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    print((int)(a!=c));
    return 0;
}


Measured memory_bytes: 256