akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int N;

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    cin >> N;
    for(int i = 1; i <= N; i++){
        int cnt = 0;
        for(int a = 1; a*a <= i; a++)
            for(int b = a; a*a+b*b+a*b <= i; b++){
                int e = a+b;
                int f = (a*a+b*b+a*b)-i;
                if(e*e < 4*f) continue;
                int c = round((-e+sqrt(e*e-4*f))/2.0);
                if(c > 0 && a*a+b*b+c*c+a*b+c*(a+b) == i){
                    //cout << a << ' ' << b << ' ' << c << endl;
                    if(c < b) break;
                    if(a == b && b == c) cnt++;
                    else if(a == b || b == c) cnt += 3;
                    else cnt += 6;
                }
            }
        cout << cnt << '\n';
    }
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/

Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char s[] = scanner.nextLine().toCharArray();

        List<String> ans = new ArrayList<String>();
        for (char a:s) {
            if (a == '0') {
                ans.add("0");
            }else if (a == '1') {
                ans.add("1");
            }else if(a == 'B' && ans.size() != 0) {
                ans.remove(ans.size() - 1);
            }
        }
        for (String str:ans) {
            System.out.print(str);
        }
    }
}


Measured memory_bytes: 21588
d, n = map(int, input().split())
if (d==0)&(n!=100):
    print(n)
elif (d==0)&(n==100):
    print(101)
else:
    if (n!=100):
        if(d==1):
            print(100*n)
        else:
            print(10000*n)
    else:
        if(d==1):
            print(10100)
        else:
            print(1010000)


Measured memory_bytes: 3060
def is_prime(n):
    for k in range(2, int(n**0.5) + 1):
        if n % k == 0:
            return False
    return True

x=int(input())
if x==2:
  print(x)
else:
  x=x//2*2+1
  while True:
    if is_prime(x)==True:
      print(x)
      exit()
    x+=2

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

#define vvi             vector<vector<int>>
#define ld              long double
#define mod             1000000007
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vpii            vector<pair<int,int>>
#define fr(i,a,b)       for(int i = a; i < b; i += 1)
#define all(x)          x.begin(),x.end()
#define sz(a)           (int)(a.size())
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define input(a)        for(auto it = a.begin(); it != a.end(); it++) { int value; cin >> value; *it = value;}
//#define print(a)        for(auto it = a.begin() ; it != a.end() ; it++){ cout << *it << " " ;}cout << '\n';
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
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...);
}

const int dirx[4] = {0, 0, -1, 1};
const int diry[4] = {-1, 1, 0, 0};

// 0 -> l, 1 - > r, 2 -> u , 3 -> down
void FASTIO()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int mxN = 1e6 + 10;
int n;
int dp[mxN][4];
// 0 -> none, 1-> 0 only, 2-> 9only, 3->0,9 only

void test_case()
{
	cin >> n;
	for(int i = 0; i <= n; i++)
		for(int j = 0; j < 4; j++)
			dp[i][j] = 0;

	dp[1][0] = 8;
	dp[1][1] = 1;
	dp[1][2] = 1;
	dp[1][3] = 0;


	for(int i = 2; i <= n; i++)
	{
		dp[i][0] = dp[i-1][0] * 8;
		dp[i][1] = dp[i-1][0] + dp[i-1][1] * 9;
		dp[i][2] = dp[i-1][0] + dp[i-1][2] * 9;
		dp[i][3] = dp[i-1][1] + dp[i-1][2] + 10 * dp[i-1][3];

		for(int j = 0; j < 4; j++)
			dp[i][j] %= mod;
	}

	cout << dp[n][3];

}   


int32_t main()
{
    FASTIO();

    int t;
    t = 1;
    //cin >> t;

    for(int i = 1; i <= t; i++)
    {
        //cout << "Case #" << i << ": ";
        test_case();
    }
    return 0;
} 


Measured memory_bytes: 34764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)


int main(){
   int n;
  cin >>n;
   vector<ll> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  map<ll ,int> check;
  for(ll x:a){
    if(check.count(x)){
      check.erase(x);
    }
    else{
      check[x]=1;
    }
  }
  cout << check.size() << endl;
}
  

Measured memory_bytes: 7296
from itertools import islice

def nth(iterable, n, default=None):
        "Returns the nth item or a default value"
        return next(islice(iterable, n, None), default)

def gen_numbers(D):
        n = 100**D
        while True:
                yield n
                n += 100**D 
        

D, N = [int(i) for i in input().split()]
if N == 100:
        if D == 0:
                print(101)
        elif D == 1:
                print(10100)
        elif D == 2:
                print(1010000)
else:
        print(nth(gen_numbers(D), N-1))
        
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int T[101];
int main(){
    int n,m,x,p;
    long long sum = 0;
    cin>>n;
    for(int i = 0;i < n;i++){
        cin>>T[i];
        sum += T[i];
    }
    cin>>m;
    for(int i = 0;i < m;i++){
        cin>>p>>x;
        cout<<sum-T[p-1]+x<<endl;
    }
    return 0;
}

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

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;++i) cin >> A[i];
    if (N==1){cout << "Second" << '\n'; return 0;}
    for (int first=1;;first^=1){
        long long sum=0; int even=0,one=0,g=0,nxt;
        for (int i=0;i<N;++i){
            sum+=A[i]-1;
            if (A[i]==1) one=1;
            if (A[i]&1) nxt=i;
            else ++even;
        }
        if (one){cout << ((sum&1LL)^first?"Second":"First") << '\n'; return 0;};
        if (even&1){cout << (first?"First":"Second") << '\n'; return 0;}
        if (N-even>1){cout << (first?"Second":"First") << '\n'; return 0;}
        --A[nxt];
        for (int i=0;i<N;++i) g=gcd(g,A[i]);
        for (int i=0;i<N;++i) A[i]/=g;
    }
}

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

int main() {
    string s;
    while (getline(cin, s) && s != "END OF INPUT") {
        int count = 0;
        s += ' ';
        for (int i = 0; i < s.length(); i++) {
            if (s.at(i) != ' ') {
                count++;
            } else {
                cout << count;
                count = 0;
            }
            
            if (i == s.length()-1) {
                cout << endl;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;
const int mod = 1000000007;

int main()
{
  int n;
  cin>>n;
  vector<int>a(n+1);
  rep(i,n)cin>>a[i+1];
  vector<int>b(n+1);
  for(int i=n;i>=1;i--){
    int sum=0;
    for(int j=i+i;j<=n;j+=i){
      sum^=b[j];
    }
    b[i]=sum^a[i];
  }

  vector<int> ans;
  for (int i=1;i<=n;i++){
    if (b[i])ans.push_back(i);
  }
  cout<<ans.size()<<endl;
  rep(i,ans.size())cout<<ans[i]<<' ';

}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
const int N=5e5+9;
using namespace std;
char s[N];
int a[N],n,f[N],pre[N];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;++i) a[i]=s[i]-'0';
	
	int last=0;
	for(int i=1;i<=n;++i) 
	{
	   pre[i]=last;
	   if(a[i]==0) last=i;
	}
	for(int i=1;i<=n;++i)
	{
	  f[i]=0;
	  if(a[i]==0)     f[i]=f[i-1];
	  else
	   {
	     last=pre[i];
		 if(last==0) f[i]=0;
		 else 
		 {
		 	if(a[last-1]==1)
		 	{
		 	 f[i]=f[last-2]+i-last;
		 	 f[i]=max(f[i],f[pre[last]]+last-pre[last]-1);
		     f[i]=max(f[i],f[pre[last]+1]+last-pre[last]-2);
		    }
		    f[i]=max(f[i],f[i-1]);
		 }	
	   } 
	}
	int ans=f[n];
	
	int flag=0;
	for(int i=1;i<=n;++i)
	 {
	  if(a[i]==1) flag=i;
	  else break; 
	 } 
	int hh=1;
	for(int j=flag+1;j<=n;++j) if(a[j]) hh=0;
	if(hh) ans=0; 
	
	cout<<ans<<endl;
	return 0;
}
/*
10
0011011101
*/ 

Measured memory_bytes: 6656
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()

int main() {
	ll k, n;
	cin >> k >> n;
	int a[n];
	int max = 0;
	rep(i, n) {
		cin >> a[i];
		if (i != 0) {
			if (abs(a[i] - a[i - 1]) > max) {
				max = abs(a[i] - a[i - 1]);
			}
		}
	}
	ll dis = k - max;
	if (a[n - 1] - a[0] < dis) {
		dis = a[n - 1] - a[0];
	}
	cout << dis << endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
using namespace std;

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

	int x,n;
	cin >> x >> n;
	vector<int> p(n);
	if (n == 0) {
		cout << x << endl;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	stable_sort(p.begin(), p.end());

	int min = 500;
	int ans = 0;
	for (int i = p[0] - 2; i <= p[n - 1] + 2; i++) {
		auto c = std::find(p.begin(), p.end(), i);
		if (c == p.end()) {
			int a = abs(x - i);
			if (min > a) {
				min = a;
				ans = i;
			}
		}
		else {
			continue;
		}
	}

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


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    ll n;
    string s;
    ll a,b;
    char c;

    cin>>c;
    cout<<(char)(c+1)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>

using namespace std;

int main(){
	
	int n,a,b,c,x,i,fm;
	int ril[100];
	
	
	while(1){
		
		for(i=0;i<100;i++)ril[i]=0;
		fm=0;
		
		
		cin >> n >> a >> b >> c >> x;
		
		if(n==0)break;
		
		for(i=0;i<n;i++)cin >> ril[i];
		
		for(i=0;i<n;i++){
			
			if(i==0 && ril[i]==x) continue;
			
			while(fm>-1){
				
				x=(a*x+b)%c;
				fm++;
				if(fm==10001)fm=-1;
								
				if(ril[i]==x){
					break;
				}
				
			}
			
		}
		
		cout << fm << endl;
		
	
	}
	
	return 0;
}

Measured memory_bytes: 1160
eval"H,W,*A="+`dd`.split*?,
(H*=W).times{|i|i%W<1&&N=0
N|=$*[-W]||0**i<<1e4
a=A[i]-A[H+i]
$*<<N=N<<a|N>>a}
N>>=1e4
p"%b"%(N&-N)=~/.$/

Measured memory_bytes: 36868
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S, T;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != 'x') T.push_back(S[i]);
	}
	string R = T;
	reverse(R.begin(), R.end());
	int ans = 0;
	if (R != T) {
		cout << -1 << endl;
		return 0;
	}
	int N = S.size();
	int l = 0, r = N - 1;
	while (l < r) {
		//cout << l << " " << r << endl;
		if (S[l] != S[r]) {
			ans++;
			if (S[l] == 'x') l++;
			else r--;
		}
		else {
			l++; r--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3796
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;









int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,r;
    string s;
    cin >> k;
    cin >> s;
    if(s.length()<=k){
        cout << s << el;
    }
    else{
        cout << s.substr(0,k)+"..." << el;
    }
    return 0;
}





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

long long gcd(long long a,long long b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
    int N;
    cin>>N;
    vector<long long>A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    vector<long long>L(N);
    L.at(0)=A.at(0);
    for(int i=1;i<N;i++){
        L.at(i)=gcd(L.at(i-1),A.at(i));
    }
    vector<long long>R(N);
    R.at(N-1)=A.at(N-1);
    for(int i=2;i<N;i++){
        R.at(N-i)=gcd(R.at(N-i+1),A.at(N-i));
    }
    vector<long long>B(N);
    B.at(0)=R.at(1);
    B.at(N-1)=L.at(N-2);
    for(int i=1;i<N-1;i++){
        B.at(i)=gcd(R.at(i+1),L.at(i-1));
    }
    sort(B.begin(),B.end());
    cout<<B.at(N-1)<<endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k) {
        cout << s << endl;
        return 0;
    }
    cout << s.substr(0,k) << "..." << endl;
    return 0;
}

Measured memory_bytes: 3652
A,B,C,D = list(map(int,input().split()))
mod = 998244353

DP = [[0]*(D+1) for i in range(C+1)]
DP[A][B] = 1
for i in range(A+1,C+1):
    DP[i][B] = (DP[i-1][B]*B)%mod
for j in range(B+1,D+1):
    DP[A][j] = (DP[A][j-1]*A)%mod
for i in range(A+1,C+1):
    for j in range(B+1,D+1):
        DP[i][j] = (DP[i-1][j]*j + DP[i][j-1]*i - DP[i-1][j-1]*(i-1)*(j-1))%mod
print(DP[C][D]%mod)


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

int main() {
	int x, y; cin >> x >> y;

	int ans = 0;

	if (x == 1) ans += 300000;
	else if (x == 2) ans += 200000;
	else if (x == 3) ans += 100000;

	if (y == 1) ans += 300000;
	else if (y == 2) ans += 200000;
	else if (y == 3) ans += 100000;

	if ((x == 1) && (y == 1)) ans += 400000;

	cout << ans << endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &e : a) {
		cin >> e;
	}
	vector<int> d(n - 1);
	for (int i = 0; i < n - 1; i++) {
		d[i] = a[i + 1] - a[i];
	}
	int m = 1;
	for (int i = 0; i < n - 2; i++) {
		if (d[i + 1] == 0) {
			d[i + 1] = d[i];
		} else if (d[i] < 0 && 0 < d[i + 1] || d[i + 1] < 0 && 0 < d[i]) {
			m++;
			i++;
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

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

      int s=sc.nextInt();
      int x,y,z,w;

        z=s%10;

        y=(s-z)%100/10;

        x=(s-10*y-z)%1000/100;

        w=(s-100*x-10*y-z)%10000/1000;

///////////////////////////////////////////////////////////
        if(w==x || x==y || y==z || (w==x&&x==y) || (x==y&&y==z) || (w==x&&x==y&&y==z)){
          System.out.println("Bad");
        }
        else{
          System.out.println("Good");
        }
///////////////////////////////////////////////////////////



    }
}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
 
int main() {
    int S,h,m,s;
    cin>>S;
    h=S/3600;
    int a=S%3600;
    m=a/60;
    s=a%60;
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}

Measured memory_bytes: 3092
using System;

namespace ABC144
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] token;
            token =  Console.ReadLine().Split();

            a = Convert.ToInt32(token[0]);
            b = Convert.ToInt32(token[1]);

            if (a<10 && b<10)
            {
                Console.WriteLine(""+a*b);
            }
            else
            {
                Console.WriteLine(-1);
            }
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll h,w;
int table[51][51];

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

void solve(int y,int x){
    table[y][x] = 0;
    rep(i,8){
        int ny = y + dy[i];
        int nx = x + dx[i];
        if(ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
        if(table[ny][nx] == 1)solve(ny,nx);
    }
}

int main(){
    while(cin >> w >> h && w){
        rep(i,h){
            rep(j,w){
                cin >> table[i][j];
            }
        }
        ll ans = 0;
        rep(i,h){
            rep(j,w){
                if(table[i][j]){
                    ans++;
                    solve(i,j);
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
/*while(l<=r)
{
    ll mid=(l+r)/2;
    if(check(mid)) r=mid-1;
    else l=mid+1;
}*/
ll n,m;

int main()
{
  IOS;
    while(cin>>n>>m)
    {
        priority_queue<ll> pq;
        rep(i,n)
        {
            ll tmp;
            cin>>tmp;
            pq.push(tmp);

        }
        rep(i,m)
        {
            ll tmp=pq.top();
            pq.pop();
            tmp/=2;
            pq.push(tmp);
        }
        ll sum=0;
        while(!pq.empty())
        {
            ll tmp=pq.top();
            pq.pop();
            sum+=tmp;
        }
        cout<<sum<<"\n";
    }

    return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);

		char[] c = sc.next().toCharArray();
		int n = c.length;
		int j = 0;
		char[] ans = new char[10];

		for (int i = 0; i < n; i++) {
			if (c[i] == '0') {
				ans[j++] = c[i];
			} else if (c[i] == '1') {
				ans[j++] = c[i];
			} else {
				if (j == 0) {
					continue;
				} else {
					j--;
				}
			}
		}

		for (int i = 0; i < j; i++) {
			System.out.print(ans[i]);
		}
		System.out.println();
	}

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

}


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

// Bの方をX冊:YY分というように足したものを計算しておく 
// Aの方を1冊づつ見ていき、残り時間で⇑がどこまで出来るか二分探索とかで探す
//
// 別海
// Aが0:BがWのときよりBが増えることはないので、
// Bをそこを基準に減らしていく
// 減るならAの計算量も底が見えるし、減らないならO(N+M)で済む

int main()
{
	int N, M, K;
	std::cin >> N >> M >> K;
	std::vector<int> A(N);
	std::vector<int> B(M);

	for ( int i=0; i<N; i++ )	std::cin >> A[i];
	for ( int i=0; i<M; i++ )	std::cin >> B[i];
	
	// Bの足した時間を出す
	std::vector<long long> sigmaB( M+1 );
	sigmaB[0] = 0;
//	printf( "%lld|", sigmaB[0]);
	for( int i=1; i<=M; i++)
	{
		sigmaB[i] = sigmaB[i-1] + B[i-1];
//		printf("%lld|", sigmaB[i]);
	}
//	printf("\n");
//	// Aを1冊づつ見ていく
	long long sigmaA = 0;
	int ans = 0;
	for( int i=0; i<N+1; i++)
	{
		if( i!=0 )
		{
			sigmaA += A[i-1];
//			printf("%lld\n", sigmaA);
			if ( sigmaA > K )
			{
				break;
			}
		}

		// sigmaBから2分探索でいい感じのを探す 
		int nokori_time = K - sigmaA;
		int min = -1;
		int max = M+1;
		while( max - min > 1 )	// maxとminが隣あっていない間
		{
//			printf("max=%d|min=%d", max, min);
		    int j = ( max + min ) / 2;
			if( sigmaB[j] <= nokori_time )	// ⇑で端数は切り捨てられるから 
			{								// ピッタリのときは低い方に落ち着く 
				min = j;
//				printf("|j=%d\n", j);
			}
			else if( sigmaB[j] > nokori_time )
			{
				max = j;
//				printf("|j=%d\n", j);
			}
		}

//		printf( "%d:%d[%lld]\n", i, min, sigmaA + sigmaB[min] );
		ans = std::max( ans, i+min );
	}

	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 5984
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	ans1, ans2 := 0, 0
	total := 0
	for i, a := range A {
		total += a
		if i%2 == 0 {
			if total <= 0 {
				ans1 += abs(1 - total)
				total = 1
			}
		} else {
			if total >= 0 {
				ans1 += abs(-1 - total)
				total = -1
			}
		}
	}
	total = 0
	for i, a := range A {
		total += a
		if i%2 == 0 {
			if total >= 0 {
				ans2 += abs(-1 - total)
				total = -1
			}
		} else {
			if total <= 0 {
				ans2 += abs(1 - total)
				total = 1
			}
		}
	}

	fmt.Fprintln(wtr, min(ans1, ans2))
	wtr.Flush()
}


Measured memory_bytes: 3072
S = input()
n = len(S)

def SplitSum(i, t):
    if i == n-1:
        return sum(list(map(int, t.split('+'))))
    
    return SplitSum(i+1, t+S[i+1]) + SplitSum(i+1, t+'+'+S[i+1])

print(SplitSum(0, S[0]))

Measured memory_bytes: 3060
using System;

class IDONTKNOWCSHARP
{
    public static void Main()
    {
        int[] temp = Convert(GetLines());

        int num = temp[0];
        int K = temp[1];
        int[] people = new int[num];
        for (int i = 0; i < people.Length; i++)
        {
            people[i] = 0;
        }

        for (int i = 0; i < K; i++)
        {
            Console.ReadLine();
            temp = Convert(GetLines());

            foreach (int tem in temp)
            {
                people[tem - 1]++;

            }
        }
        int count = 0;

        foreach (int person in people)
        {
            if (person == 0)
                count++;
        }
        Console.WriteLine(count);

    }


    static int[] Convert(string[] v)
    {
        var temp = new int[v.Length];

        for (int i = 0; i < temp.Length; i++)
        {
            temp[i] = int.Parse(v[i]);
        }

        return temp;
    }




    static string[] GetLines()
    {
        return Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
    }


}

Measured memory_bytes: 28048
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class AAtCoderContest {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            in.string();
            out.println("A" + in.string().charAt(0) + "C");
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; cin>>n;
    for(int i = 0; i<= 100; i++){
        for(int j = 0; j <= 100; j++){
            if(i*4+j*7 == n){
                cout << "Yes" << endl; return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3612
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 20;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n;
vector<II> b[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) {
        int x;
        cin >> x;
        FOR(j,1,x) {
            II p;
            cin >> p.FI >> p.SE;
            b[i].emplace_back(p);
        }
    }
    int res = 0;
    FOR(mask,0,(1<<n)-1) {
        int cnt = __builtin_popcount(mask);
        bool co = true;
        FOR(i,1,n)
            if (mask & (1<<(i-1))) {
                FOR(j,0,SZ(b[i])-1) {
                    int person = b[i][j].FI;
                    bool k = b[i][j].SE;
                    bool w = (mask & (1<<(person-1)));
                    if (k ^ w) co = false;
                }
            }
        if (co) res = max(res, cnt);
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100009
#define MAXM 320
#define EPS 1e-9
#define MOD 1000000007
#define INF 1000000009
#define FOR(x,n) for(int x=0; x<n; x++)
#define FOR1e(x,n) for(int x=1; x<=n; x++)
#define pb push_back
#define all(x) x.begin(), x.end()

int arr[MAXN];

int main() {
	int n; scanf("%d", &n);
	FOR1e(i, n) scanf("%d", &arr[i]);
	arr[n+1] = 0;

	int total = 0;
	FOR1e(i, n+1) {
		total += abs(arr[i] - arr[i-1]);
	}
	FOR1e(i, n) {
		printf("%d\n", total - abs(arr[i] - arr[i-1]) - abs(arr[i] - arr[i+1]) + abs(arr[i-1] - arr[i+1]));
	}
}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

char S[10];

int main(){
  int a, b;
  cin >> a >> b;
  int c = min(a, b) + '0';
  int d = max(a, b);
  rep(i, d) S[i] = c;
  cout << S << endl;
}


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

int main() {
	string s; cin >> s;
	if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi") cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mod 100000
typedef pair<int, int> P;
int n, m, ans;
string s, t;
int dp[2][2010][2010];
int main()
{
	cin >> n >> m >> s >> t;
	memset(dp[1], -1, sizeof(dp[1]));
	for(int i = 0; i <= n; ++i)
	{
		for(int j = 0; j <= m; ++j)
		{
			bool get;
			if(i != n)
			{
				get = (s[i] == 'I');
				dp[get][i + 1][j] = max(dp[get][i + 1][j], dp[get ^ 1][i][j] + 1);
			}
			if(j != m)
			{
				get = (t[j] == 'I');
				dp[get][i][j + 1] = max(dp[get][i][j + 1], dp[get ^ 1][i][j] + 1);
			}	
			ans = max(ans, dp[1][i][j]);
		}
	}
		cout << ans << endl;
}

Measured memory_bytes: 34728
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#define esp 1e-8
using namespace std;
typedef long long ll;
int n,k;
double a[10005];
bool F(double mid)
{
    int ans=0;
    for(int i=0;i<n;i++)
    {
        ans+=a[i]/mid;
    }
    return ans>=k;
}
int main()
{
    ll a,b;while(cin>>a>>b)
    {
        ll gcd=__gcd(a,b);
        ll lcm=a*b/gcd;
        cout<<gcd<<" "<<lcm<<endl;
    }
}



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

int main(){
  int p, q, r;
  cin >> p >> q >> r;
  
  vector<int> ans(3);
  ans.at(0) = p;
  ans.at(1) = q;
  ans.at(2) = r;
  sort(ans.begin(), ans.end());
  
  cout << ans.at(0) + ans.at(1) << endl;
}

Measured memory_bytes: 3592
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;

std::vector<int> graph[100000];
std::vector<int> path;
bool used[100000];

void find_1(int i)
{
	
	used[i] = true;
	for (auto& n : graph[i]) {
		if (used[n] == false) {
			find_1(n);
			break;
		}
	}
	if (i != 0)path.push_back(i);
}
void find_2(int i)
{
	if (i != 0)path.push_back(i);
	used[i] = true;
	for (auto& n : graph[i]) {
		if (used[n] == false) {
			find_2(n);
			break;
		}
	}
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	int32_t M;
	in >> N >> M;
	for (int32_t i = 0; i < M; ++i)
	{
		int a, b;
		in >> a >> b; --a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	find_1(0); path.push_back(0); find_2(0);

	out << path.size() << std::endl;
	auto b = path.back(); path.pop_back();
	for (auto& v : path) {
		out << v + 1 << ' ';
	}
	out << b + 1 << std::endl;

	return 0;
}
#endif


Measured memory_bytes: 9720
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
import math
from math import gcd


N = int(input())
ans = 0
for i in range(1, N+1):
    for j in range(1, N+1):
        b = gcd(i, j)
        for k in range(1, N+1):
            ans += gcd(b, k)

print(ans)

Measured memory_bytes: 9924
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		System.out.print(s.charAt(0));
		s = sc.next();
		
		System.out.print(s.charAt(1));
		
		s = sc.next();
		System.out.print(s.charAt(2));
		sc.close();
	}
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);

    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;

    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))

using namespace std;

#define PB push_back
#define MP make_pair

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long ll;
typedef long double LD;
typedef unsigned long long ULL;

double high,low,p,e,t,Left,Right;
int k;

const double eps = 1e-12;

bool in(double x)
{
    return x-Left>-eps && x-Right<eps;
}

double gao(double L,double R,int depth)
{
  //  cout << L << " " << R << endl;
    if (depth>=k)
        return in((L+R)/2.0) ? 1 : 0;
    if (L-Left>-eps && R-Right < eps) return 1.00;
    if (R-Left<-eps || L-Right > eps) return 0.00;
    double mid = (L+R)/2.0;
    double pLeft,pRight;
    if (t<mid) pLeft = 1-p,pRight = p;
    else pLeft = p,pRight =1-p;
    return gao(L,mid,depth+1)*pLeft+gao(mid,R,depth+1)*pRight;
}

int main()
{
    while (scanf("%d%lf%lf%lf%lf%lf",&k,&low,&high,&p,&e,&t)!=EOF)
    {
        Left = t-e;
        Right = t+e;
        printf("%.6f\n",gao(low,high,0));
    }
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int main()
{
	int res = 0;

	int N, K;
	string S;
	cin >> N >> K;
	cin >> S;

	S[K-1] += 0x20;

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
import collections

N, K, Q = list(map(int, input().split()))

A_list = []

for _ in range(Q):
    A_list.append(int(input()))

A_list_collections = collections.Counter(A_list)
    
for n in range(1, N + 1):
    n_lost_point = Q - A_list_collections[n]
    if n_lost_point < K:
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> A, B;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    A.push_back(x + y);
    B.push_back(x - y);
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  int ans = max(A.at(N - 1) - A.at(0), B.at(N - 1) - B.at(0));
  cout << ans << endl;
}

Measured memory_bytes: 5084
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (l) < (x) && (x) < (r)

int main() {
    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;
    ll dist = abs(A-B);
    if ((V-W)*T >= dist) cout << "YES";
    else cout << "NO";
    cout << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>b) swap(a,b);
	for(int i=1;i<=1000;i++){
		if(floor(i*0.08)==a&&floor(i*0.1)==b){
			cout<<i; return 0;
		}
	}
	cout<<"-1";
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin>>h[i];
    vector<int> dp(n);
    dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        if(1<i) dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


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

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer root;

NodePointer malloc_node (void )
{
	NodePointer ptr = (NodePointer) malloc (sizeof(int) );
	
	return ptr;
}

void free_node (NodePointer ptr )
{
	free (ptr );
	return;
}

NodePointer make_node (int key )
{
	NodePointer curr = malloc_node (); 
	curr->key = key;
	curr->next = NULL;
	curr->prev = NULL;

	return curr;
}

void init (void )
{
	root = make_node (-1 );
	nil = root;
}

void insert (int key )
{
	NodePointer next_node = malloc_node();
	next_node->key = key;
	next_node->next = NULL;
	next_node->prev = nil;
	nil->next = next_node;
	nil = next_node;
}

void delete (int key )
{
	NodePointer search = nil;

	while (search != NULL ){
		if (search->key == key ){
			if (search == nil ){	// ???????????卒???
				nil = search->prev;
				free_node (search );
				break;
			}else{
				NodePointer p = search->prev;
				NodePointer n = search->next;
				p->next = n;
				n->prev = p;
				free_node (search );
				break;
			} // end if
		} // end if
		search = search->prev;
	} // end while								
}

void deleteFirst (void )
{
	if (nil == root ) return;
//	nil->next = NULL;
	NodePointer t = nil;
	t->prev->next = NULL;
	nil = nil->prev;
	free_node (t );
}

void deleteLast (void )
{
	if (nil == root ) return;

	if (root->next != nil ){
		NodePointer n = root->next;
		root->next = root->next->next;
		root->next->prev = root;
		free_node (n );
	}else{
		free_node (nil );
		nil = root;
		root->next = NULL;
	} // end if		
}

void disp_node (void )
{
	if (nil == root ) {
		printf ("\n" );
		return;
	} // end if

	while (1 ){
		printf ("%d", nil->key );
		if (nil->prev != root ){
			printf (" " );
			nil = nil->prev;
		}else{
			printf ("\n" );
			break;
		} // end if
	} // end while
}

int main(){

	char com[12];
	int i, n, key;
	scanf("%d", &n);
	init();

	for ( i = 0; i < n; i++ ){
		scanf("%s %d", com, &key);
	    if ( com[0] == 'i' ) {
			insert(key);
		}else
		if ( com[0] == 'd' ) {
      		if (strlen(com) > 6 ){
				if (com[6] == 'F' ) {
					deleteFirst();
				}else
				if( com[6] == 'L' ) {
	  				deleteLast();
				} // end if
      		}else{
				delete(key);
			} // end if
		} // end if
	} // end for

	disp_node ();

	return 0;
}

Measured memory_bytes: 14000
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 数列数・選択数 - 取得
	int liACnt, liSCnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &liACnt, &liSCnt);

	// 操作回数 - 取得
	int liOCnt = (liACnt - 1 + liSCnt - 2) / (liSCnt - 1);

	// 結果 - セット
	sprintf(lc1Out, "%d\n", liOCnt);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



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

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

    vector<vector<ll>> cnt(11, vector<ll>(11, 0));
    int order = 1;
    for (int i = 1; i <= N; ++i) {
        if (i / order >= 10) order *= 10;
        ++cnt[i / order][i % 10];
    }

    ll ans = 0;
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 100050;

std::string S;
int N;
int tmp[MAX_N];

void proc() {
    for (int i = 2; i < S.size(); i++) {
        if (tmp[i-1] == 0) {
            if (S[i-1] == 'o') {
                tmp[i] = tmp[i-2];
            } else {
                tmp[i] = 1 - tmp[i-2];
            }
        } else {
            if (S[i-1] == 'o') {
                tmp[i] = 1 - tmp[i-2];
            } else {
                tmp[i] = tmp[i-2];
            }
        }
    }
}

void out() {
    std::string ret;
    for (int i = 0; i < S.size(); i++) {
        if (tmp[i] == 0) {
            ret.push_back('S');
        } else {
            ret.push_back('W');
        }
    }
    std::cout << ret << std::endl;
}

bool check(const int i) {
    int l = (i == 0) ? N - 1 : i - 1;
    int r = (i == N - 1) ? 0 : i + 1;

    if (tmp[i] == 0) {
        if (S[i] == 'o') {
            return tmp[l] == tmp[r];
        } else {
            return tmp[l] != tmp[r];
        }
    } else {
        if (S[i] == 'o') {
            return tmp[l] != tmp[r];
        } else {
            return tmp[l] == tmp[r];
        }
    }
}

int main(int argc, char **argv) {
    std::cin >> N;
    std::cin >> S;

    /*
    tmp[0] = 0;
    tmp[1] = 0;
    proc();
    out();
    */
    
    //std::cout << (int)check(0) << " " << (int)check(N-1) << std::endl;

    for (int i0 = 0; i0 <= 1; i0++) {
        for (int i1 = 0; i1 <= 1; i1++) {
            tmp[0] = i0;
            tmp[1] = i1;
            proc();

            if (check(0) && check(N-1)) {
                out();
                return 0;
            }
        }
    }

    std::cout << "-1" << std::endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
       int[] a = new int[5];
       

        for(int i=0; i<5; i++) {
            a[i] = Integer.parseInt(sc.next());
            if(a[i] == 0) {
                System.out.println(i+1);
                break;
            }
        }
     }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> A(n+1);
  for(int i = 2; i < n+1; i++) cin >> A.at(i);
  
  vector<int> sub(n+1,0);
  for(int i = 2; i < n+1; i++) sub.at(A[i])++;
  
  for(int i = 1; i < n+1; i++) cout << sub.at(i) << endl;
  
  return 0;
}

Measured memory_bytes: 4772