akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb(x) push_back(x)
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
const int MAXN = 1024;

//OPERATORS


//GLOBALS


//FUNCTIONS


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int q; cin >> q;
	deque<char> u;
	for(int i = 0; i < s.size(); i++){
		u.push_back(s[i]);
	}
	bool estado = 0; // normal , 1 revers
	for(int i = 0; i < q; i++){
		int t; cin >> t;
		if(t == 1){
			estado = !estado;
		}
		else{
			int f;
			char c;
			cin >> f >> c;
			if(f == 1){
				if(estado == 0){
					u.push_front(c);
				}
				else{
					u.pb(c);
				}
			}
			else{
				if(estado == 0){
					u.pb(c);
				}
				else{
					u.push_front(c);
				}
			}
		}
	}
	
	if(estado == 1){
		reverse(u.begin(),u.end());
	}
	
	for(auto z: u){
		cout << z;
	}
	cout << endl;


	return 0;
}


Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  for(int i=1;i<=n;i++){
    string s=to_string(i);
    int x=0;
    for(char c:s) x+=c-'0';
    if(a<=x&&x<=b) ans+=i;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
import bisect
from collections import deque

def main():
    N = int(input())
    INF = 10**10
    col = deque([INF])
    for _ in range(N):
        num = int(input())
        ind = bisect.bisect_left(col,num)
        if ind == 0:
            col.appendleft(num)
        else:
            col[ind-1] = num
    
    print(len(col)-1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 44132
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

import java.util.*;
import java.util.Collections; // sorting use
import java.io.*;
import static java.lang.System.*;

public class Main{
	public static void main(String[] args){
		int n,a;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		a = sc.nextInt();
		if(n % 500 <= a)	out.println("Yes");
		else out.println("No");
	}
}


Measured memory_bytes: 23764
'use strict'
const main = (input: string) => {
    const std: string[] = input.trim().split('\n');
    const n: number = ~~std.shift();
    let h: number[] = std[0].split(' ').map(Number);
    for (let i = 0; i < n-1; i++) {
        if (h[i] > h[i+1]) {
            return console.log("No");
        }
        if (h[i] < h[i+1]) {
            h[i+1]--;
        }
    }
    console.log("Yes");
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  


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

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

using namespace std;

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

    if (H == 1 || W == 1) {
        cout << 1 << endl;
    } else {
        ll total = H * W;
        if ((H * W) % 2 == 1) {
            cout << (ll)total / 2 + 1 << endl;
        } else {
            cout << (ll)total / 2 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
def main():
    MAX = 100010
    n,k = map(int,input().split())
    m = {}
    for x in range(100010):
        m[x] = 0
    for x in range(n):
        a,b = map(int,input().split())
        m[a] += b
    if k == 0:
        print(m.keys()[0])
        return
    for key,value in m.items():
        k-=value
        if k <= 0:
            print(key)
            return

if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}

int rec(vector<int>& a, vector<vector<int> >& dp, int i, int j)
{
	cout<<"i "<<i<<" j "<<j<<endl;

	if(i==a.size())
	{
		// dp[i]=min(abs(ind));
		return 100000000;
	}
	if(i==a.size()-1)
	{
		// dp[i][j]=abs(a[i]-a[i-(j+1)]);
		// dp[i][j]
		return 0;
		// cout<<dp[i][j]<<endl;
		// return dp[i][j];
		// return imx;
	}
	else
	{
		if(dp[i][j]==-1)
		{
			cout<<"inside "<<i<<endl;

			dp[i][j]=min(abs(a[i]-a[i+1])+rec(a, dp, i+1, 0), abs(a[i]-a[i+2])+rec(a, dp, i+2, 1));
			// int t1 = abs(a[i]-rec(a, dp, i+1, 0));
			// cout<<"t1 "<<t1<<endl;
			// int t2 = abs(a[i]-rec(a, dp, i+2, 1));
			// cout<<"t2 "<<t2<<endl;
			// if(t1>t2)
			// {
			// 	dp[i][j]=dp[i+2][1]+t2;
			// }
			// else
			// {
			// 	dp[i][j]=dp[i+1][0]+t1;
			// }
			// dp[i][j] = min(t1, t2);
			 // min(abs(a[i]-rec(a, dp, i+1, 0)), abs(a[i]-rec(a, dp, i+2, 1)));
			// cout<<"dp[i] "<<dp[i]<<endl;
			return dp[i][j];
		}

	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<int> a(n+2, 100000000), dp(n+2);
	// vector<vector<int> > dp(n, vector<int> (2, -1));
	// vector<vector<int> >  dp(n, vector;

	for(int i = 1; i <= n; i++)
	{
		cin>>a[i];
	}
	// for(int )
	for(int i = 2; i <= n; i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]), dp[i-2]+abs(a[i-2]-a[i]));
	}

	// cout<<rec(a, dp, 0, 0)<<endl;
	// for(int i = 0; i < n; i++)
	// {
	// 	cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
	// }
	// // } cout<<dp[i]<<" ";
	// 	cout<<endl;
	// for(int i = 0; i <= n; i++)
	// {
	// 	cout<<dp[i]<<" ";
	// }
	// cout<<endl;

	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#define int long long
template<class T, class Func = function<T(T, T)>>
class segtree {
    vector<T> obj;
    int offset;
    Func updater;
    T e;
    int bufsize(int num) {
        int i = 1;
        for (; num + 1 >i; i <<= 1);
        offset = i - 1;
        return (i << 1) - 1;
    }
    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)return e;
        if (a <= l && r <= b)return obj[k];
        else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
    }
public:
    T query(int a, int b) {//[a,b)
        return query(a, b, 0, 0, offset + 1);
    }
    void updateall(int l = 0, int r = -1) {
        if (r < 0)r = offset + 1;
        l += offset, r += offset;
        do {
            l = (l - 1) >> 1, r = (r - 1) >> 1;
            for (int i = l; i < r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]);
        } while (l);
    }
    void update(int k, T a) {
        k += offset;
        obj[k] = a;
        while (k) {
            k = (k - 1) >> 1;
            obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]);
        }
    }
    segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {}
    segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) {
        copy(vec.begin(), vec.end(), obj.begin() + offset);
        updateall();
    }
    typename vector<T>::reference operator[](int n) {
        return obj[n + offset];
    }
};

signed main(){
    Int N ; cin >> N;
    vector<Int>h(N);
    vector<Int>A(N);
    for(auto& e : h) cin >> e;
    for(auto& e : A) cin >> e;
    map<Int,Int>toIdx;
    auto cv = h;
    sort(cv.begin(), cv.end());
    for(Int i = 0; i < N; ++i)
        toIdx[cv[i]] = i;
    vector<Int>dp1(N),dp2(N);
    constexpr Int inf = (1LL << 60) * -1;
    auto maxf = [](Int a,Int b){
        return max(a,b);
    };
    auto dp =  segtree<Int>(dp1,inf, maxf);
    auto udp = segtree<Int>(dp2,inf, maxf);
    for(int i = 0; i < N; ++i){
        Int idx = toIdx[h[i]];
        Int ls1 = dp.query(0,idx);
        Int ls2 = udp.query(0,idx);
        if(ls1 == inf) ls1 = 0;
        if(ls2 == inf) ls2  = 0;
        dp.update(idx,A[i]+max(ls1,ls2));
        udp.update(idx,max(ls1,ls2));
    }
    
    cout << max(dp.query(0,N), udp.query(0,N))  << endl;
}


Measured memory_bytes: 28800
#include <iostream>
#include <cmath>
using namespace std;
double EPS=1e-10;
double add(double a, double b)
{
	if(abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
	return a+b;
}
int main()
{
	double x[4],y[4];
	while(cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>x[3]>>y[3])
	{
		double vx[2],vy[2];
		for(int i=0;i<2;i++)
		{
			vx[i]=x[2*i+1]-x[2*i];
			vy[i]=y[2*i+1]-y[2*i];
		}
		if(add(vx[0]*vx[1],vy[0]*vy[1])==0) cout << "YES" << '\n' ;
		else cout << "NO" << '\n' ;
	}
}

Measured memory_bytes: 1188
package main

import (
	"fmt"
)

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	Z := "Z"
	ans := make([]string, len(s))
	for i := 0; i < len(s); i++ {
		if s[i]+uint8(n) <= Z[0] {
			ans[i] = string(s[i] + uint8(n))
		} else {
			ans[i] = string(s[i] + uint8(n) - 26)
		}
	}

	for _, v := range ans {
		fmt.Print(v)
	}
}


Measured memory_bytes: 1024
N, K = [int(x) for x in input().split()]
S = input()

L = [0]
R = []
for i in range(0, len(S) - 1):
    if S[i:i + 2] == "01":
        L.append(i + 1)
j = 0
while j < len(S) and S[j] == '1':
    j += 1
for i in range(j, len(S) - 1):
    if S[i:i + 2] == "10":
        R.append(i)
R.append(len(S) - 1)

ans = 0
z = min(len(L) - K, len(R) - K)
if z <= 0:
    ans = len(S)

for i in range(z + 1):
    Ri = max(0, i + K - 1)
    d = R[Ri] - L[i] + 1
    # print("(l,r)=({},{}) : {}".format(L[i], R[Ri], d))
    ans = max(ans, d)

# print(L)
# print(R)

print(ans)

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e18)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll ans = 1;
    bool ng = false;
    rep(i, n) {
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
        if (ng || (ll)(INF)/ans<a[i]) ng = true;
        ans *= a[i];
    }
    if (ng) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4028
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int x,y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x==0&&y==0){
            break;
        }
        if(x<y){
            printf("%d %d\n", x, y);
        }
        else{
            printf("%d %d\n", y, x);
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main()
{
    int A1,A2,A3,x,y,z;
    scanf("%d%d%d",&A1,&A2,&A3);
    if(A1>A2&&A1>A3)
    {
        z=A1;
        if(A2>A3){
            y=A2;
            x=A3;
        }
        else
        {
            y=A3;
            x=A2;
        }
    }
       else if(A2>A1&&A2>A3)
    {
        z=A2;
        if(A1>A3){
            y=A1;
            x=A3;
        }
        else
        {
            y=A3;
            x=A1;
        }
    }
    else
    {
        z=A3;
        if(A1>A2){
            y=A1;
            x=A2;
        }
        else
        {
            y=A2;
            x=A1;
        }
    }

    printf("%d\n",z-x);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){

char ch;

while(1){
	scanf("%c", &ch);
	if ( ch == '\n' ) break;
	char d=toupper(ch);
	cout<<d;
}
	cout<<endl;
}

Measured memory_bytes: 0
inpl = lambda: list(map(int,input().split()))
N = int(input())
S = input()
NE = S.count('E')
ans = cur = NE
prev = S[0]
n = 0
for s in S + 'A':
    if s == prev:
        n += 1
    else:
        if prev == 'E':
            cur -= n
            if cur < ans:
                ans = cur
        else:
            cur += n
        n = 1
        prev = s
print(ans)

Measured memory_bytes: 42992
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [list(map(int,input().split())) for i in range(M)]

minPrice = min(a) + min(b) #割引額を考慮しない最小金額
price = 0

for x in range(len(c)):
    price = a[c[x][0]-1] + b[c[x][1]-1] - c[x][2]
    if minPrice > price:
        minPrice = price
    price = 0

print(minPrice)

Measured memory_bytes: 38564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n;
  cin >> n;
  vector<ll>vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  sort(all(vec),greater<ll>());
  ll ans = 0;
  ll piv = 0;
  t1 = n;
  while(t1 > 0){
    if(t1 == 1){
      ans += vec[piv];
    }else{
      ans += vec[piv] * 2;
    }
    t1 -= 2;
    piv++;
  }
  ans -= vec[0];
  cout << ans << endl;
}


Measured memory_bytes: 4840
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

int dp[4096][4096];
int sum[2010][2010];

void solve(ll N, ll K, vector<ll> x, vector<ll> y, vector<string> c) {
  REP(i,N) {
    if (c[i] == "B") x[i] += K;
    x[i] %= K * 2;
    y[i] %= K * 2;
    dp[x[i]+0][y[i]+0] += 1;
    dp[x[i]+0][y[i]+K] -= 1;
    dp[x[i]+K][y[i]+0] -= 1;
    dp[x[i]+K][y[i]+K] += 1;

    dp[x[i]+K][y[i]+K] += 1;
    dp[x[i]+K][y[i]+K+K] -= 1;
    dp[x[i]+K+K][y[i]+K] -= 1;
    dp[x[i]+K+K][y[i]+K+K] += 1;
  }
  REP(i,4010) REP(j,4010) dp[i][j+1] += dp[i][j];
  REP(i,4010) REP(j,4010) dp[i+1][j] += dp[i][j];
  REP(i,4010) REP(j,4010) sum[i%(2*K)][j%(2*K)] += dp[i][j];
  // REP(i,2*K) { REP(j,2*K) cout << sum[i][j] << " "; cout << endl; }
  int res = 0;
  REP(i,2*K) REP(j,2*K) chmax(res, sum[i][j]);
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	ll K;
	scanf("%lld", &N);
	vector<ll> y(N-1+1);
	vector<string> c(N-1+1);
	vector<ll> x(N-1+1);
	scanf("%lld", &K);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &x[i]);
	  scanf("%lld", &y[i]);
	  cin >> c[i];
	}
	solve(N, K, x, y, c);
	return 0;
}


Measured memory_bytes: 89600
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
      int nam = in.nextInt();
      int sum = in.nextInt();
      int cnt = 0;
      
      if(nam==0){
        if(sum==100){
           System.out.print(sum+1);    
        }else{
          System.out.print(sum);   
        }
      }
      else if(nam==1){
        if(sum==100){
           System.out.print(sum*100+100);    
        }else{
          System.out.print(sum*100);   
        }
      }
      else if(nam==2){
        if(sum==100){
           System.out.print(sum*10000+10000);    
        }else{
          System.out.print(sum*10000);   
        }
      }

	}
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

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

        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int X = x;
        int Y = y;
        while (!(X % Y == 0)) {
            int Z = X;
            X = Y;
            Y = Z % Y;
        }
        int d = x/Y;
        int w = y/Y;
        System.out.println(((w+d)*Y)-(Y-1));
        
    }

}



Measured memory_bytes: 26340
// author : DmitryGrigorev
#include <bits/stdc++.h>
#define int long long

#define TASKNAME ""

using namespace std;
const int K = 300;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector<bitset<K> > v;
    for (int i=0; i < n; i ++){
        string s;
        cin >> s;
        bitset<K> b;
        for (int j=0; j < m; j++){
            if (s[j] == '#') b[j] = 1;
        }
        v.push_back(b);
    }
    int ans = 0;
    bitset<K> a, b, c;
    for (int i=0; i < n; i++){
        for (int j=i; j < n; j++){
            for (int k=j; k < n; k++){
                if (i==k) continue;
                a = v[i], b = v[j], c = v[k];
                int d1 = j-i, d2 = k-j, s1, s2;
                if (d1 >= d2) s1 = d1, s2=2*d1-d2;
                else s1 = d1 + 2*(d2-d1), s2 = d2;
                //cout << i << " " << j << " " << k << " " << s1 << " " << s2 << endl;
                a <<= s1, c <<= s2;
                b &= a;
                b &= c;
                ans += b.count();
                if (d1==0 || d2==0) continue;
                a = v[i], b = v[j], c = v[k];
               // cout << a[1] << " " << s1 << endl;
                a >>= s1, c >>= s2;
                b &= a;
                b &= c;
                ans += b.count();
            }
        }
    }
    cout << ans;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;
/**==Info==
*Program:2
*Problem:Fennce VS Snuke
*Date:2017-8-12
*Algorithm:DFS
*Stats:WA for 7 tests(But faster) :)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))*/
int n;
vector<int> nei[100005];
int d[2][100005];
inline void dfs(int root,int dis,int place){ //root:this point,dis:now distance,place:which place to write in Array
	d[place][root]=dis;
	for(int i=0;i<nei[root].size();i++){
		if(d[place][nei[root][i]]>d[place][root]+1){
			d[place][nei[root][i]]=d[place][root]+1;
			dfs(nei[root][i],dis+1,place);
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;b--;
		nei[a].push_back(b);
		nei[b].push_back(a);
	}
	for(int i=0;i<n;i++) d[0][i]=d[1][i]=1e8;
	dfs(0,0,0);
	dfs(n-1,0,1);
	
	int f=0,s=0;
	for(int i=0;i<n;i++){
		//cout<<d[0][i]<<" "<<d[1][i]<<endl;
		if(d[0][i]<=d[1][i]){
			f++;
		}else{
			s++;
		}
	}
	cout<<(f>s?"Fennec":"Snuke");
	return 0;
}


Measured memory_bytes: 10112
#include <iostream>
#include <unordered_set>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  unordered_set<string> elems;

  for (int i = 0; i < n; ++i) {
    string cmd, elem;
    cin >> cmd >> elem;
    if (cmd == "insert") {
      elems.insert(elem);
    } else if (cmd == "find") {
      if (elems.find(elem) != elems.end()) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    }
  }
}



Measured memory_bytes: 28940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(4*a*b<(c-a-b)*(c-a-b)&&c-a-b>0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;
}


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

int main(){
    string S,T,U;
    int A,B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if(S==U) A--;
    if(T==U) B--;
    cout << A << " " << B <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t


int main(void){
    string s;
    int count = 0;
    string b = "CODEFESTIVAL2016";
    cin >> s;
    for(int  i = 0 ; i < s.size() ; i++ )
        if( b[i] != s[i] )count++;
    
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

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

    int H, W, h, w;
    cin >> H >> W >> h >> w;

    int ans = H * W;
    ans = ans - (h * W);
    ans = ans - (w * (H - h));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int w[105];
int main()
{
    int n,ans=0,k=0,t=1000000,i,num;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&w[i]);
        ans=ans+w[i];
    }
    for(i=1;i<=n;i++)
    {
        k=k+w[i];
        num=ans-2*k;
        if(num<0)
        {
            num=-num;
            if(num<t)t=num;
            break;
        }
        if(num<t)t=num;
    }
    printf("%d\n",t);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,p1[15],p2[15];
string st[15],st2[15];
void dfs1(int x,int y)
{
	if (x==m)
	{
		cout<<"YES";;
		exit(0);
	}
	if (p2[x]!=-1)
	{
		dfs1(x+1,y);
		return;
	}
	int i,j;
	for (i=x+1;i<m;i++)
	{
		if (p2[i]!=-1) continue;
		for (j=0;j<n;j++)
		{
			if (st[j][x]!=st[p1[j]][i]) break;
		}
		if (j>=n)
		{
			p2[x]=i;
			p2[i]=x;
			dfs1(x+1,y);
			p2[x]=-1;
			p2[i]=-1;
		}
	}
	if (!y)
	{
		for (j=0;j<n;j++)
		{
			if (st[j][x]!=st[p1[j]][x]) break;
		}
		if (j>=n)
		{
			p2[x]=x;
			dfs1(x+1,1);
			p2[x]=-1;
		}
	}
}
void dfs2(int x,int y)
{
	if (x==n)
	{
		dfs1(0,m%2==0);
		return;
	}
	if (p1[x]!=-1)
	{
		dfs2(x+1,y);
		return;
	}
	int i;
	for (i=x+1;i<n;i++)
	{
		if (p1[i]!=-1) continue;
		if (st2[x]!=st2[i]) continue;
		p1[x]=i;
		p1[i]=x;
		dfs2(x+1,y);
		p1[x]=-1;
		p1[i]=-1;
	}
	if (!y)
	{
		p1[x]=x;
		dfs2(x+1,1);
		p1[x]=-1;
	}
}
int main()
{
	cin>>n>>m;
	for (i=0;i<n;i++) 
	{
		cin>>st[i];
		st2[i]=st[i];
		sort(st2[i].begin(),st2[i].end());
	}
	memset(p1,-1,sizeof(p1));
	memset(p2,-1,sizeof(p2));
	dfs2(0,n%2==0);
	cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#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 ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    priority_queue<int> q;
    int t;
    REP(i,N) {
        cin >> t;
        q.push(t);
    }

    REP(_,M) {
        t = q.top(); q.pop();
        q.push(t/2);
    }

    ll ans = 0;
    while(!q.empty()){
        ans += q.top(); q.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
#!/usr/bin/env python


class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


n, m = map(int, input().split())
ps = list(map(int, input().split()))
uf = UnionFind(n + 1)
for _ in range(m):
    x, y = map(int, input().split())
    uf.unite(x, y)
print(sum([uf.same(i + 1, p) for i, p in enumerate(ps)]))


Measured memory_bytes: 13812
#include<bits/stdc++.h>
#define FOR(i,a,b) for(register int i=a;i<=b;i++)

using namespace std;

inline int read(){
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

int main(){
	
	int age=read(); int W=read();
	
	if(age>=13)
		cout<<W;
	if(age>=6&&age<=12)
		cout<<W/2;
	if(age<6)
		cout<<0;

	return 0;
}


Measured memory_bytes: 256
from fractions import gcd
#from math import gcd
from functools import reduce

def lcm_base(a, b):
    return (a * b) // gcd(a, b)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
times = [int(input()) for i in range(n)]

print(lcm(times))


Measured memory_bytes: 5460
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>

using namespace std;

int suger[3001],a,b,c,d,e,f;

int main(int argc,char** argv) {
	cin >> a >> b >> c >> d >> e >> f;
	for(int i = 1;i <= f;i++) suger[i] = -100000;
	for(int i = 0;i < f ;i++) {
		if(i + a * 100 <= f) suger[i + a * 100] = max(suger[i + a * 100],suger[i]);
		if(i + b * 100 <= f) suger[i + b * 100] = max(suger[i + b * 100],suger[i]);
		if(i + c <= f && (suger[i] + c) * 100  <= (i - suger[i]) * e) suger[i + c] = max(suger[i + c],suger[i] + c);
		if(i + d <= f && (suger[i] + d) * 100  <= (i - suger[i]) * e) suger[i + d] = max(suger[i + d],suger[i] + d);
	}
	double maxr = -1;
	int ind = -1;
	for(int i = 0;i <= f;i++) {
		double rate = (double)suger[i] / (double)i;
		if(rate >= maxr) {
			maxr = rate;
			ind = i;
		}
	}
	cout << ind << " " << suger[ind] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int A,H;
    cin>>H>>A;
    cout<< (H-1)/A + 1 <<endl;
    return 0;
}

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

int farm[101][101];
int h,w;

void kubun(int k,int a,int b){
	if(a<0 | a>w | b<0 | b>h)return;
	farm[a][b]=0;
	if(k==farm[a-1][b])kubun(farm[a-1][b],a-1,b);
	if(k==farm[a+1][b])kubun(farm[a+1][b],a+1,b);
	if(k==farm[a][b-1])kubun(farm[a][b-1],a,b-1);
	if(k==farm[a][b+1])kubun(farm[a][b+1],a,b+1);
	
}
int main(void){
	char c[101][101];
	int a,b;
	int ans=0;
	while(1){
		ans=0;
		for(b=0;b<101;b++){
			for(a=0;a<101;a++){
				farm[a][b]=0;
			}
		}
		scanf("%d %d",&h,&w);
		if(h==0 && w==0)break;
		for(b=0;b<h;b++){
			scanf("%s",c[b]);   
			for(a=0;a<w;a++){
				if(c[b][a]=='@')farm[a][b]=1;
				if(c[b][a]=='#')farm[a][b]=2;
				if(c[b][a]=='*')farm[a][b]=3;
				
			}
		}
		for(b=0;b<h;b++){
			for(a=0;a<w;a++){
				if(farm[a][b]==0);
				else{
					ans++;
					kubun(farm[a][b],a,b); 
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
static const int MAX=500;
int N;
int F[100][11],P[100][11];

int main(){ 
    cin>>N;
    for(int i=0;i<N;i++){
        for(int j=0;j<10;j++)
            cin>>F[i][j];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<=10;j++)
            cin>>P[i][j];
    }
    int res=-(1<<30);
    for(int b=1;b<(1<<10);b++){
        int cc=0;
        for(int i=0;i<N;i++){
            int c=0;
            for(int j=0;j<10;j++){
                if((b>>j&1)&&F[i][j])c++;
            }
            cc+=P[i][c];
        }
        if(res<cc)res=cc;
    }
    cout<<res<<"\n";
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

S = []
for _ in range(H):
    S.append(list(str(input().replace(".", "0"))))  # .を0に置換しておく。文字列にしか置換できないので注意

def fill_blank_around_mine(i,j): # 地雷の座標(i,j)を与え、その周りのセルの値を+1する
    for y in range(max(0,i-1),min(H,i+2)):
        for x in range(max(0, j-1), min(W,j+2)):
            if S[y][x] != "#":
                S[y][x] = str(int(S[y][x])+1)

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            fill_blank_around_mine(i,j)

for idx in range(len(S)):
    print("".join(S[idx]))

Measured memory_bytes: 3064
#include<stdio.h>
int a[3][8] =	{1,3,5,7,8,10,12,
				4,6,9,11,0,0,0,
				2,0,0,0,0,0,0};
int x, y;
int ansx, ansy;
int main(){
	scanf("%d %d",&x, &y);
	for(int i = 0 ; i <=2 ; i++){
		for(int j = 0 ; j <= 6 ; j++){
			if(a[i][j] == x)ansx = i;
			if(a[i][j] == y)ansy = i;
		}
	}
	if(ansx == ansy)
		printf("Yes");
	else
		printf("No");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll INF = 1LL << 58;

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
def main():
    n = int(input())
    mod = 10 ** 9 + 7
    ans = pow(10, n, mod)
    ans -= 2 * pow(9, n, mod)
    ans += pow(8, n, mod)
    ans %= mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	while(cin>>n,n){
		vi in(n);
		rep(i,n)cin>>in[i];
		int mi=inf;
		rep(i,n)rep(j,n)if(i!=j)mi=min(mi,abs(in[i]-in[j]));
		cout<<mi<<endl;
	}
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
long double const pi = std::acos(-1.0L);

int calc(int x) {
	int ret = 0;
	while(x % 100 == 0) {
		x /= 100;
		++ret;
	}
	return ret;
}

int main() {
  int d, n;
  cin >> d >> n;
  int cnt = 0, val = 0;
  while(cnt < n){
    ++val;
    if(calc(val)==d) ++cnt;
  }
  cout << val << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var H = readInputLine().toLong()
    var ans = 0L
    var monsCnt = 1L

    while (H > 0L) {
        ans += monsCnt
        H /= 2L
        monsCnt *= 2L
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 31796
#include<iostream>

using namespace std;

int main() {
  string S;
  cin >> S;
  if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;  
  }
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
long n,ans,M=1e7,i,j;
int main(){
  cin>>n;
  for(i=2;i<=min(n,M);i++){
    j=i;
    while(!(n%j))ans++,n/=j,j*=i;
    while(!(n%i))n/=i;
  }
  cout<<ans+(n>=M)<<endl;
}


Measured memory_bytes: 3636
alps = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def reverse(data):
    ret = ""
    while(True):
        if data[0] == "[" and (not ("[" in data[1:]) or data.index("[") > data.index("]")):
            tmp = data[1:data.index("]")][::-1]
            ret += tmp
            ret += data[data.index("]")+1:]
            return(ret)
        else:
            ret += data[0]
            data = data[1:]

while(True):
    a = input()
    if a == ".":
        quit()
    ans = ""
    plus = 0
    count = 0
    while(a != ""):
        if a[0] in ["[","]"]:
            ans += a[0]
            plus = 0
            count += 1
        elif a[0] == "?":
            ans += "A"
            plus = 0
        elif a[0] == "+":
            plus += 1
        elif a[0] == "-":
            plus -= 1
        else:
            t = alps.index(a[0])
            ans += alps[(t + plus)%26]
            plus = 0
        a = a[1:]
    count //= 2
    indl = [i for i, x in enumerate(a) if x == "["]
    indr = [i for i, x in enumerate(a) if x == "]"]
    for i in range(count):
        ans = reverse(ans)
    print(ans)



Measured memory_bytes: 5584
N = int(input())
str_dict = dict()
total_comb_num = 0
for _ in range(N):
    tmp_string = input()
    sorted_tmp_string = ''.join(sorted(tmp_string)) 
    if sorted_tmp_string in str_dict:
        total_comb_num += str_dict[sorted_tmp_string]
        str_dict[sorted_tmp_string] += 1
    else:
        str_dict[sorted_tmp_string] = 1
        
print(total_comb_num)

Measured memory_bytes: 17892
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

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

    int h[n+1];
    h[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    int dp[n+5];
    for(int i=0;i<=n+5;i++)
    {
        dp[i]=1e9;
    }
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if((i-j)>0)
                dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
        }
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 5196
#from pprint import pprint
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from copy import deepcopy
#from itertools
#from bisect import bisect_right #二分探索用のモジュール bisect_right(a_list,value)

#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。

# = map(int,input().split())

# = list(map(int,input().split()))

# = [list(map(int,input().split())) for _ in range(XXXX)]



a,b = input().split()

a = int(a)
b = int(b.replace(".",""))

print(int(a*b//100))

Measured memory_bytes: 61848
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CMinimization {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, k;
        in >> n >> k;
        n--, k--;
        vi A(n);
        in >> A;
        int res = (n + k - 1) / k;
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CMinimization solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
ll INF = 10010001010;

ll lcm(ll a,ll b)
{
    return a * b / __gcd(a, b);
}
typedef tuple<string, int, int> mytuple;

bool mycompare(const mytuple &lhs, const mytuple &rhs)
{
    if (get<0>(lhs) != get<0>(rhs))
        return get<0>(lhs) < get<0>(rhs);
    if (get<1>(lhs) != get<1>(rhs))
        return get<1>(lhs) > get<1>(rhs);
    return get<2>(lhs) < get<2>(rhs);
}

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

int main(){
    int N;
    cin >> N;
    vector<mytuple> tup;
    for (int i = 0; i < N; i++)
    {
        string S;
        int P;
        cin >> S >> P;
        tup.emplace_back(S, P, i+1);
    }
    sort(tup.begin(),tup.end(),mycompare);
    for (int i = 0; i < tup.size(); i++)
    {
        cout << get<2>(tup[i]) << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

void solve(int N, vector<int> l) {
  int lsum = 0;
  for (int i = 0; i < N; i++) {
    lsum += l[i];
  }
  int lmax = *max_element(l.begin(), l.end());
  if (lmax < lsum - lmax) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> l(N);
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  solve(N, l);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    int cnt = 0;
    int ans = 1;
    bool flag = true;
    bool horyuu = false;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(i == 1) {
            if(cnt > A[i]) {
                flag = false;
            }
        }
        else if(!horyuu){
            if(flag && cnt > A[i]) {
                ans++;
                horyuu = true;
            }
            else if(!flag && cnt < A[i]) {
                ans++;
                horyuu = true;
            }
        }
        else if(horyuu) {
            if(cnt < A[i]) {
                flag = true;
                horyuu = false;
            }
            if(cnt > A[i]) {
                flag = false;
                horyuu = false;
            }
        }
        cnt = A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
int main(){
  int ans=0;
  string s,t="CODEFESTIVAL2016";
  cin >> s;
  for(int i=0;i<16;i++){
    if(s[i]!=t[i]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 764
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int s_v_;scanf("%d", &(s_v_));vec.PB(s_v_);}while(0)
#define ALL(vec) (vec).begin(), (vec).end()
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF   1000000007
#define INFLL 1000000000000000007LL

int n;
string x;
set<string> s;

int main ()
{
  cin >> n;
  FOR(i, 0, n) 
  {
    cin >> x;
    s.insert(x);
  }
  printf("%d\n", s.size());
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
typedef vector<int> vint;
typedef vector<long long> vlint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<vector<long long>> vlint2;

lint powint(lint x, lint y){
    int ret = 1;
    for (int i=0; i < y; i++) ret *= x;
    return ret;
};

lint mod = 1000000007;
vector<int> dx = {1, 0, 0, -1, 1, 1, -1, -1};
vector<int> dy = {0, -1, 1, 0, 1, -1, 1, -1};

map<char, long long> counter(string s){
    map<char, long long> count;
    rep(i, s.size()){
        count[s[i]] ++;
    }
    return count;
};

int powmod(int x, int y, int m){
    if (y == 0) return 1;
    return ((powint(powmod(x, y>>1, m), 2) % m) * powint(x, (y & 1))) % m;
};

int main() {
    string s; cin >> s;
    lint n = s.size();

    lint ans = 0;
    // aの連続をカウント
    lint a = 0;
    lint i = 0;
    while (i < n-2){
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            ans += a + 1;
            s[i+2] = 'A';
            i++;
        }
        else if (s[i] == 'A'){
            a ++;
        }
        else{
            a = 0;
        }
        i++;
    }
    cout << ans << endl;

}



Measured memory_bytes: 640