akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	ld r;
	cin>>r; 
	cout<<2*r*3.14159265358979323;
	re 0;
}

Measured memory_bytes: 3788
using System;
using System.Collections.Generic;

namespace ALDS1_4_A
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var S = new HashSet<int>(Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse));
            Console.ReadLine();
            var T = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int cnt = 0;
            foreach (var a in T)
            {
                if (S.Contains(a)) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 10648
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

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





using namespace std;
int main() {
	
	int  a, b;
	cin >> a >> b;
	if (a < b)a = 0;
	else a = 10;
	cout << a << endl;

	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  vector<string> d(6);
  d[5] = "dream",d[3] = "dreamer",d[4] = "erase",d[2] = "eraser",d[1] = "dreamerase",d[0] = "dreameraser";
  rep(i,d.size()){
    auto pos = S.find(d[i]);
    while(pos != string::npos){
      S.replace(pos,d[i].size(),to_string(i));
      pos = S.find(d[i],pos+1);
    }
  }
  rep(i,S.size()){
    if(!(S[i] >= '0' && S[i] < '6')){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}



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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  cout << min(A*N, B) << endl;

  return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n;
  scanf("%lld", &n);
  double dp[n][n + 1], p[n], ans = 0.0;
  for(i = 0; i < n; ++i) scanf("%lf", &p[i]);
  for(i = 0; i < n; ++i) for(j = 0; j <= n; ++j) dp[i][j] = 0.0;
  for(i = 0; i < n; ++i) for(j = 0; j <= n; ++j) {
    if(i && j) dp[i][j] += dp[i - 1][j - 1] * p[i];
    if(i) dp[i][j] += dp[i - 1][j] * (1 - p[i]);
    else dp[i][0] = 1 - p[i], dp[i][1] = p[i];
  }
  for(i = n / 2 + 1; i <= n; ++i) ans += dp[n - 1][i];
  printf("%.12f", ans);
  return 0;
}

Measured memory_bytes: 70528
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for (int i = 0; i < h; i++) { cin >> s[i]; }
    int ans = INT_MAX;
    for (int div = 0; div < (1 << (h - 1)); div++) {
        int g = 0;
        vector<int> id(h);
        for (int i = 0; i < h; i++) {
            id[i] = g;
            if (div >> i & 1) g++;
        }
        g++;
        vector<vector<int>> c(g, vector<int>(w, 0));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) { c[id[i]][j] += (s[i][j] - '0'); }
        }
        vector<int> now(g);
        auto ok = [&](int j) {
            for (int i = 0; i < g; i++) now[i] += c[i][j];
            for (int i = 0; i < g; i++) {
                if (now[i] > k) return false;
            }
            return true;
        };
        int tmpans = g - 1;
        for (int j = 0; j < w; j++) {
            if (!ok(j)) {
                tmpans++;
                now = vector<int>(g, 0);
                if (!ok(j)) {
                    tmpans = INT_MAX;
                    break;
                }
            }
        }
        ans = min(tmpans, ans);
    }
    cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> B(N-1);
  for(int i=0;i<N-1;i++)cin >> B[i];
  if(N==2){cout << 2*B[0] << endl; return 0;}
  if(N==3){cout << B[0]+B[1]+min(B[0],B[1]) << endl; return 0;}
  int sum=B[0]+B[N-2];
  for(int i=0;i<N-2;i++){
    sum+=min(B[i],B[i+1]);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    ans = [0] * 8
    a32 = 0
    for i in a:
        if(i >= 3200):
            a32 += 1
        else:
            if(i < 400):
                ans[0] +=1
            elif(400 <= i < 800):
                ans[1] +=1
            elif(800 <= i < 1200):
                ans[2] +=1
            elif(1200 <= i < 1600):
                ans[3] +=1
            elif(1600 <= i < 2000):
                ans[4] +=1
            elif(2000 <= i < 2400):
                ans[5] +=1
            elif(2400 <= i < 2800):
                ans[6] +=1
            elif(2800 <= i < 3200):
                ans[7] +=1

    if(ans.count(0) == 8):
        if(a32 > 0):
            print(1, a32)
        else:
            print(0, 0)
    else:
        print(8-ans.count(0), 8-ans.count(0)+a32)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define eps 0.000000001
using namespace std;
typedef long double ld;
typedef pair<int,int> p;
typedef pair<ld,p> P;

int n;
ld px[200],py[200],pz[200],vx[200],vy[200],vz[200],r[200],vr[200];

ld getlen(int a,int b,ld M){
  ld ax=px[a]+vx[a]*M,ay=py[a]+vy[a]*M,az=pz[a]+vz[a]*M,ar=r[a]-vr[a]*M;
  ld bx=px[b]+vx[b]*M,by=py[b]+vy[b]*M,bz=pz[b]+vz[b]*M,br=r[b]-vr[b]*M;
  ld dx=ax-bx,dy=ay-by,dz=az-bz;
  return sqrt(dx*dx+dy*dy+dz*dz)-(ar+br);
}

ld check(int a,int b){
  ld mt=min(r[a]/vr[a],r[b]/vr[b]);
  ld L=0,R=mt,M;
  int s=0;
  while(s++<50){
    M=(L+R)/2;
    ld M1=M+eps;
    ld len=getlen(a,b,M),len1=getlen(a,b,M1);
    if(len<len1||len<=0)R=M;
    else L=M;
  }
  if(R==mt||L==0||getlen(a,b,R)>0)return 1000;
  return R;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    priority_queue<P,vector<P>,greater<P> > q;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)
	q.push(P(check(i,j),p(i,j)));
      q.push(P(r[i]/vr[i],p(i,i)));
    }
    ld used[200]={};
    while(!q.empty()){
      ld t=q.top().first;
      int a=q.top().second.first,b=q.top().second.second;
      q.pop();
      if(used[a]||used[b])continue;
      used[a]=used[b]=t;
    }
    for(int i=0;i<n;i++)printf("%.10Lf\n",used[i]);
  }
  return 0;
}

Measured memory_bytes: 4496
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e15;

int main(){
    string s;
    cin>> s;
    ll cnt=0;
    ll n=s.length();
    rep(i,n){
        if(s[i]=='g') cnt++;
        else cnt--;
    }
    cout << cnt/2 <<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    int n;
    string s;
    cin >> s;
    if (s[0] == s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(void){
  string data;
  cin >> data;
  vector<char> num;
  for (int i = 0; i < (int)data.size(); i++){
    char ch = data.at(i);
    if(ch=='B'&&num.size()!=0){
      num.pop_back();
    }else if(ch=='B'&&num.size()==0){
      continue;
    }else{
      num.push_back(ch);
    }
  }
  for (int i = 0; i < num.size();i++){
    cout << num.at(i);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if ((A * B) % 2 == 0) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 22100
#include <iostream>
#include <queue>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  priority_queue<int> queue;

  int res = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    if (queue.empty() || -queue.top() >= a) {
      ++res;
    }
    queue.push(-a);
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for (int i=0;i<(n);i++)
#define rep3(i,a,b) for (int i=a;i<=(b);i++)
#define out(ans) cout << ans << endl;
#define outs(ans) cout << ans;
using ll = long long;

int main(){

    //imput n, a(n), b(n)
    vector <int> a(5);
    rep(5){ cin >> a[i]; }

    //main process
    int ans=0;
    int r=9;
    int time=0;

    rep(5){
        if(a[i]%10==0){
            ans=ans+a[i];
            
        }
        else{
            r=min(r,a[i]%10);
            ans=ans+10+(a[i]-(a[i]%10));
            time++;
        }
    }
    if(time==0){
        out(ans)
        
    }
    else{
        out(ans+r-10)
    }
    


    return 0;
}










Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <cmath>

using namespace std;

using ll = long long;
using vl = vector<long long>;
using vi = vector<int>;
using vvl = vector<vl>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

int main()
{
    string s, t;
    cin >> s >> t;
    vvi dp(s.size() + 1, vi(t.size() + 1, 0));
    for (int i = 1; i < s.size() + 1; i++)
        for (int j = 1; j < t.size() + 1; j++)
            if (s[i - 1] == t[j - 1])
                dp[i][j] = max(dp[i][j],dp[i - 1][j - 1] + 1);
            else
                dp[i][j] = max(dp[i][j], max(dp[i - 1][j], dp[i][j - 1]));
    vector<char> res;
    for (int i = s.size(), j = t.size(); i > 0 or j > 0;)
    {
        if (s[i - 1] == t[j - 1] and dp[i][j] > dp[i][j - 1] and dp[i][j] > dp[i - 1][j])
        {
            res.push_back(s[i - 1]);
            i--;
            j--;
        }
        else
            if (i > 0 and dp[i][j] == dp[i - 1][j])
                i--;
            else
                j = max(0, j - 1);
    }
    for (int i = res.size() - 1; i >= 0; i--)
        cout << res[i];
    return 0;
}

Measured memory_bytes: 35584
import java.util.*;
class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0) break;
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 32824
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {

	char N[3];
	int i=0;

	scanf("%s", N);

	while(N[i]!=NULL){
		if(N[i]=='7'){
			break;
		}
		i++;
	}

	if(N[i]=='7'){
		printf("Yes");
	}
	else{
		printf("No");
	}

	return 0;
}



Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
int n,a[100002],dp[100002],k;
int main()
{
    scanf("%d %d",&n,&k);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        dp[i]=INT_MAX;
    }
    dp[1]=0;
    dp[2]=fabs(a[2]-a[1]);
    for(int i=3; i<=n; i++)
    {
        for(int j=1; j<=k; j++)
        {
            if(i>j)
            {
                dp[i] = min(dp[i-j]+(int)fabs(a[i]-a[i-j]),dp[i]);
            }
            else break;

        }
    }
    printf("%d",dp[n]);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime)
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(1<<15, prime);

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        int ret = 0;
        for(int i=0; i<=n/2; ++i){
            if(prime[i] && prime[n-i])
                ++ ret;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    string s;
    cin>>s;
    int ans=0;
    rep(i,4){
        if(s[i]=='+')ans++;
        else ans--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.*;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		List day = Arrays.asList("","SAT","FRI","THU","WED","TUE","MON","SUN");
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		System.out.println(day.indexOf(str));
	}
}


Measured memory_bytes: 21844
#include<stdio.h>  

int main(void){  
  int n,x,que[11],i;  
  while(scanf("%d",&n),n){ 
    
    for(i=0;n>0;i++){
      x=n%8;
      if (x==4)que[i]=5;  
      else que[i]=(x<4)?x:x+2;  
      n=n/8;  
    }
    for(i--;i>=0;i--)
      printf("%d",que[i]);
    printf("\n");
  }  
  return 0;
}  

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------


int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<set<int>> se(26);
  for(int i=0; i<N; i++){
    se[S[i] - 'a'].insert(i);
  }
  for(int i=0; i<26; i++){
    se[i].insert(mod);
  }
  int Q;
  cin >> Q;
  for(int i=0; i<Q; i++){
    int id;
    cin >> id;
    if(id == 1){
      int pos;
      char c;
      cin >> pos >> c;
      pos--;
      for(int j=0; j<26; j++){
        if(se[j].count(pos)){
          se[j].erase(pos);
          break;
        }
      }
      se[c-'a'].insert(pos);
    }else{
      int l,r;
      cin >> l >> r;
      l--;
      r--;
      int cnt = 0;
      for(int j=0; j<26; j++){
        if(*se[j].lower_bound(l) <= r){
          cnt++;
        }
      }
      cout << cnt << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 26244
//
//  main.cpp
//  cpp
//
//  Created by Hao He on 8/13/17.
//  Copyright © 2017 Hao He. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <map>
#include <unordered_map>

using namespace std;
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define mp make_pair
#define maxn 3001
//const int mod = 1000000000 + 7;
//const long long inf = 1ll * 1000000000 * 300;

int n, m, k;
int sugar[maxn], water[maxn];

void solve(){
    int a,b,c,d,e,f,ii,jj;
    cin >> a >> b >> c >> d >> e >> f;
    sugar[0] = water[0] = 1;
    for(int i=0; i<=f-c; i++) sugar[i + c] |= sugar[i];
    for(int i=0; i<=f-d; i++) sugar[i + d] |= sugar[i];
    for(int i=0; i<=f/100-a; i++) water[i + a] |= water[i];
    for(int i=0; i<=f/100-b; i++) water[i + b] |= water[i];
    ii = 100*a;
    jj = 0;
    for(int i=1; i<=f/100; i++)if(water[i]){
        for(int j=0; j<=f; j++)if(sugar[j]){
//            cout << 100*i << " + " << j << endl;
            if(100 * i + j > f) break;
            if(j > e * i ) break;
            if(jj<=0 || j * ii > jj * i){
                ii = i, jj = j;
            }
        }
    }
    cout << (100 * ii + jj) << " " << jj;
}

int main(int argc, const char * argv[]) {
    std::ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*
 8
 1 1 1 3 4 5 5
 4 1 6 2 2 1 3 3
 
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;

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

// 7, 77, 777...
// 7, 7*10+7, (7*10+7)*10+7....
// x[0], x[0]*10+7, x[1]*10+7... x[i-1]*10+7
// mod(x[0],K), mod(x[1])
// 前の項のmodを保存しておけば良さそう
int main() {
  LL K; scanf("%lld", &K);
  vector<LL> mods = vector<LL>(K, -1);
  LL base = 7;
  LL now = 1;
  LL mod_before = 0%K;
  rep(i, K){
    now = (mod_before*10+7);
    mod_before = now%K;
    if(mod_before== 0){
      printf("%d", i+1);
      break;
    }
    if(mods[mod_before]>0){
      printf("%d",-1);
      break;
    }
    mods[mod_before] = 1;
  }
  return 0;
}



Measured memory_bytes: 11096
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

const long long INF = 1LL << 60;

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

int main(){
  int N,K; cin >> N >> K;
  vector<int>h(N + K);
  for(int i=0;i<N;i++){
    cin >> h.at(i);
  }

  vector<long long>dp(N + K,INF);
  dp.at(0) = 0;
  for(int i=0;i<N;i++){
    for(int j=1;j<=K;j++){
      chmin(dp.at(i+j),dp.at(i) + abs(h.at(i) - h.at(i+j)));
    }
  }
  cout << dp.at(N-1) << endl;
}


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

int main() {
  int N,X,count = 1;
  cin >> N >> X;
  int L[N];
  for(int i = 0; i<N; ++i){ cin >> L[i] ;}
  int d = 0;
  for(int i = 0;i<N;++i){
    d += L[i];
    if(d<=X) {count+=1;}
  }
  cout << count << endl;
}

Measured memory_bytes: 888
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
void solve(){
	string s;
	cin >> s;
	int q;
	cin >> q;
	bool isR = false;
	deque<char> d;
	for (char c : s) d.push_back(c);
	while (q--) {
		int t;
		cin >> t;
		if (t == 1) {
			isR = !isR;
		} else {
			int f;
			char c;
			cin >> f >> c;
			bool isB = false;
			if (f == 2) isB = true;
			if (isR) isB = !isB;
			if (isB) d.push_back(c);
			else d.push_front(c);
		}
	}
	s = "";
	while (!d.empty()) {
		s += d.front();
		d.pop_front();
	}
	if (isR) reverse(all(s));
	cout << s;
}
int main(){
	speed;
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,s=0,x,i;
    cin>>n;
    for(i=1; i<=n; ++i){
        cin>>x;
        if(x!=i)
            ++s;
    }
    cout<<(s<=2?"YES":"NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int INF = 1e9;

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

    cout << a + a * a + a * a * a << endl;

    return 0;
}

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

int main() {
  int N, min;
  cin >> N;
  min = 35;
  
  for (int i = 0; i < N; i++) {
    int A, x;
    cin >> A;
    x = 0;
    while (A % 2 == 0) {
      x++;
      A /= 2;
    }
    if (x < min) min = x;
  }
  
  cout << min << endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    P = [0, ] + list(map(float, input().split()))
    dp = [[0] * (n + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(1, n + 1):
        for j in range(i + 1):
            dp[i][j] = dp[i - 1][j] * (1 - P[i]) + dp[i - 1][j - 1] * P[i]
    print(sum(dp[n][n // 2 + 1:]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 273288
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using static System.Math;

namespace AtcoderSolve
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var a = ReadSplitInt();
            a.Insert(0, 0);

            var ans = 0;
            for (int i = 1; i <= N; i++)
            {
                if (i % 2 != 0 && a[i] % 2 != 0)
                    ans++;
            }

            Println(ans);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");
        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}



Measured memory_bytes: 28044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int l = 0, r = 1e9;
  while(r-l > 1){
    int x = (l+r) / 2;
    auto f = [&](int x){
      ll now = 0;
      rep(i,n) now += (a[i]-1)/x;
      return now <= k;
    };
    if (f(x)) r = x; else l = x;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 3896
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
#define INSIDE(i,j,H,W) ((i) >= 0 && (i) < (H) && (j) >= 0 && (j) < (W))
#define YesNo(b) (b ? "Yes" : "No")
#define YESNO(b) (b ? "YES" : "NO")
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }

// all_of
// partial_sum, adjacent_difference

#if _DEBUG
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#endif

#if 1234567891
#include <array>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

string s;
int main() {
	cin >> s;
	bool ok = 0;
	REP(i, 0, s.size() - 1) {
		if (s.substr(i, 2) == "AC") ok = 1;
	}
	cout << YesNo(ok) << endl;
	return 0;
}






Measured memory_bytes: 256
n, m = map(int, input().split())
c = []
for i in range(n):
  c.append(list(map(int, input().split())))
c.sort()
cost = 0
s = 0
for i in range(n):
  if s + c[i][1] >= m:
    print(cost + (m - s) * c[i][0])
    break
  s += c[i][1]
  cost += c[i][0] * c[i][1]


Measured memory_bytes: 27760
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,1,1,0,-1,-1,-1};
const static int ty[] = {-1,-1,0,1,1,1,0,-1};
 
static const double EPS = 1e-8;

int main(){
  int N;
  while(~scanf("%d",&N)){
    ll road_cost[100][100];

    for(int y=0;y<N;y++){
      for(int x=0;x<N;x++){
	ll cost;
	scanf("%ld",&cost);
	road_cost[y][x] = cost;
      }
    }

    bool visited[100][100];
    memset(visited,false,sizeof(visited));

    ll cost = 0;
    for(int y=0;y<N;y++){
      for(int x=0;x<N;x++){
	if(y==x) continue;
	if(visited[x][y]) continue;

	cost += min(road_cost[x][y],road_cost[y][x]);
	visited[x][y] = true;
	visited[y][x] = true;
      }
    }
    printf("%ld\n",cost);
  }
}

Measured memory_bytes: 1284
#include <stdio.h>
 
using namespace std;
 
 
int main(){
    int n,count;
    while(scanf("%d",&n)!=EOF){
        if(n >= 37){
            printf("0\n");
        }else{
            count = 0;
 
            for(int a=0;a<=9;a++){
                for(int b=0;b<=9;b++){
                    for(int c=0;c<=9;c++){
                        for(int d=0;d<=9;d++){
                            if(a+b+c+d==n)count++;
                        }
                    }
                }
            }
            printf("%d\n",count);
        }
    }
 
    return 0;
}


Measured memory_bytes: 2624
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

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

		BigDecimal a = sc.nextBigDecimal();
		BigDecimal b = sc.nextBigDecimal();

		BigDecimal ans = a.multiply(b);
		BigDecimal an = ans.setScale(0, RoundingMode.DOWN);

		System.out.println(an);
	}
}


Measured memory_bytes: 37492
#include <iostream>
using namespace std;
int main()
{
    int n;
    while(cin >> n)
    {
        int cnt = 0;
        for(int a = 0; a <= 9; a++)
            for(int b = 0; b <= 9; b++)
                for(int c = 0; c <= 9; c++)
                    for(int d = 0; d <= 9; d++)
                        if(a + b + c + d == n) cnt++;
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 

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

int N, M; cin >> N >> M;
VI a(M), b(M), c2(M, 0); //i 番目の鍵で　0bc2[i] の宝箱が開く
rep(i, 0, M){
    cin >> a[i] >> b[i];
    rep(j, 0, b[i]){
        int c; cin >> c;
        c2[i] |= (1 << (c-1));
    } 
}

// cost[key][opend] = key 個目までの鍵で、0b(opend)を開ける最小コスト
// opend は2進数N桁
VVI cost(M+1, VI(1LL<<N, INF));
rep(i, 0, M){
    cost[i][0] = 0;
    rep(j, 0, 1LL<<N){
        cost[i+1][j | c2[i]] = min(cost[i+1][j | c2[i]], cost[i][j] + a[i]);
        cost[i+1][j] = min(cost[i+1][j], cost[i][j]);
    }
}

if (cost[M][(1LL<<N)-1] < INF)
    cout << cost[M][(1LL<<N)-1] <<"\n";
else 
    cout << "-1\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 32384
#include <stdio.h>
int main(void){
    int h,i,j,w;
    while(1){
        scanf("%d%d",&h,&w);
        if(h==0&&w==0) break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2684
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;



int main(void){
	ll N,L[87];
	cin>>N;
	L[0]=2;
	L[1]=1;
	reg(i,2,N){
		L[i] = L[i-1]+L[i-2];
	}
	cout<<L[N]<<endl;
	return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

using mint = modint998244353;

struct S {
    mint a;
    int size;
};

struct F {
    mint b, c;
};

S op(S x, S y) { return S{x.a + y.a, x.size + y.size}; }
S e() { return S{0, 0}; }
S mapping(F f, S s) { return S{f.b * s.a + s.size * f.c, s.size}; }
F composition(F x, F y) { return F{x.b * y.b, x.b * y.c + x.c}; }
F id() { return F{1, 0}; }

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

    vector<S> A(N);
    for_(i,0,N) {
        int a;
        cin >> a;
        A[i] = S{a, 1};
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(A);
    for_(i,0,Q) {
        int t;
        cin >> t;
        if (t == 0) {
            int l, r, b, c;
            cin >> l >> r >> b >> c;
            seg.apply(l, r, F{b, c});
        }
        if (t == 1) {
            int l, r;
            cin >> l >> r;
            cout << seg.prod(l, r).a.val() << endl;
        }
    }
}

Measured memory_bytes: 19280
/* author: Tarek */ 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
int main()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int n;
cin>>n;
string s;
cin>>s;
int m=0;
for(int i=1;i<n-1;i++){
   if(s[i-1]=='A'&&s[i]=='B'&&s[i+1]=='C')m++;
}
cout<<m<<endl;
       	return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
  	public static int ds(int num){
      	int sum = 0;
      	while(num > 0){
          sum += num%10;
          num /= 10;
        }
      	return sum;
    }
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
      	int n = sc.nextInt();
		int a;
      	int b;
      	int stack;
      	int min = -1;
      
      	for(int i = 1; i <= n/2;i++){
          a = i;
          b = n-i;
          stack = ds(a)+ds(b);
          if(stack < min || min == -1) min = stack;
        }
      
      	System.out.println(min);
	}
}

Measured memory_bytes: 35304
#include<stdio.h>
#include<math.h>

int main(){
  int n, m;
  long long int x, c[12], a[12][12];
  long long int csum=0, asum[12]={0}, csum_min=1200001;
  // input
  scanf("%d %d %lld",&n,&m,&x);
  for(int i=0; i<n; i++){   
    scanf("%lld",&c[i]);
    for(int j=0; j<m; j++){
      scanf("%lld",&a[i][j]);
    }
  }
//  printf("%d %d %lld",n,m,x);
//  for(int i=0; i<n; i++){   
//    printf("\n%lld ",c[i]);
//    for(int j=0; j<m; j++){
//      printf("%lld ",a[i][j]);
//    }
//  }
  // 
  int comb_max = pow(2, n);
  for(int k=0; k<comb_max; k++){
    csum = 0;
    for(int j=0; j<m; j++)
      asum[j] = 0;
    // 
    for(int i=0; i<n; i++){
      if((k>>i)&1){
        csum += c[i];
        for(int j=0; j<m; j++)
          asum[j] += a[i][j];
      }  
    }
//    printf("\n%lld ",csum);
//    for(int j=0; j<m; j++){
//      printf("%lld ",asum[j]);
//    }
    // 
    int skill_ok=1;
    for(int j=0; j<m; j++){
      if(asum[j]<x){
        skill_ok=0;
      }
    }
    if(skill_ok==1){
      if(csum_min>csum)
        csum_min = csum;
    }
  }
  if(csum_min==1200001)
    printf("-1");
  else
    printf("%lld",csum_min);
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[200010],cnt[200010];
signed main()
{
	int n;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i]+i<=n)cnt[a[i]+i]++;
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
	if(i-a[i]>=0)ans+=cnt[i-a[i]];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6948
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
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,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n; cin >> n;
    double t, a;
    cin >> t >> a;
    vector<double> h(n);
    double res = 10000000;
    ll num;
    REP(i, n){
        double hin; cin >> hin;
        double temp = t - hin * 0.006;
        double diff = abs(a - temp);
        //cout << diff << endl; 
        if(diff <= res){
            res = diff;
            num = i+1;
        }
    }
    cout << num << endl;
}

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

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

int main()
{
  string s,t;
  cin >> s >> t;
  bool check = true;
  for (int i=0; i<s.size(); i++) check &= (s[i] == t[i]);
  if (check) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    ll a;
    long double b; cin >> a >> b; //long doubleはdouble型より精度が良い！！
    ll ans = a * b;
    cout << ans << endl;
}


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

#define ll long long
#define pb push_back
ll dp[2][2][200][1000], k;
vector <ll> num;

ll solve(ll isStart, ll isSmall, ll pos, ll val)
{
    if(pos == 0)
    {
		if(val==k) return 1;
		return 0;
	}
	
    ll &ret = dp[isStart][isSmall][pos][val];
    if(ret != -1 && isSmall)
        return ret;

    ll lim, pos2 = num.size() - pos;
    if(isSmall)
        lim = 9;
    else
        lim = num[pos2];

    ll rt = 0;
    if(!isStart) {
        for(ll i = 0; i <= lim; i++)
            rt += solve(0, isSmall | i < num[pos2], pos - 1, (i != 0) + val);
    }
    else {
        for(ll i = 1; i <= lim; i++)
            rt += solve(0, isSmall | i < num[pos2], pos - 1, val+1);

        rt += solve(1, 1, pos - 1, 0);
    }

    return ret = rt;
}

ll calc(string n)
{
    for(int i=0;i<n.size();i++)
		num.push_back(n[i]-'0');
		
    return solve(1, 0, num.size(), 0);
}

int main()
{
    memset(dp, -1, sizeof(dp));
    string n;
	cin >> n >> k;
	
	cout << calc(n) << endl;

    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <climits>

using namespace std;
using ll = long long int;

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

    vector<ll> A(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    map<ll, ll> odd;
    map<ll, ll> even;

    for (ll i = 0; i < N; i += 2)
    {
        odd[A[i]] += 1;
    }

    for (ll j = 1; j < N; j += 2)
    {
        even[A[j]] += 1;
    }

    vector<pair<ll, ll>> o;
    for (auto &&elem : odd)
    {
        o.push_back({elem.first, elem.second});
    }

    vector<pair<ll, ll>> e;
    for (auto &&elem : even)
    {
        e.push_back({elem.first, elem.second});
    }
    o.push_back({0, 0});
    e.push_back({0, 0});

    sort(o.begin(), o.end(), [](const pair<ll, ll> lhs, const pair<ll, ll> rhs) {
        return lhs.second > rhs.second;
    });
    sort(e.begin(), e.end(), [](const pair<ll, ll> lhs, const pair<ll, ll> rhs) {
        return lhs.second > rhs.second;
    });
    
    ll ans = INT_MAX;
    if (o[0].first != e[0].first) {
        ans = min(ans, N - o[0].second - e[0].second);
    }
    if (o[0].first != e[1].first) {
        ans = min(ans, N - o[0].second - e[1].second);
    }
    if (o[1].first != e[0].first) {
        ans = min(ans, N - o[1].second - e[0].second);
    }
    if (o[1].first != e[1].first) {
        ans = min(ans, N - o[1].second - e[1].second);
    }
    if (ans == INT_MAX) {
        ans = N / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12612
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    for (int i = -1000; i <= 1000; i++)
    {
        for (int j = -1000; j <= 1000; j++)
        {
            if(x==pow(i, 5)-pow(j, 5)) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
 
int main() {
    int N,M;
    cin >> N >> M;
    vector <int> k(M);
    vector < vector <int>> s(M,vector<int>(100));
    for(int i=0;i<M;i++){
        cin >> k[i];
        for(int j = 0; j<k[i];j++){
            cin >> s[i][j];
        }
    }
    vector <int> p(M);
    for(int i = 0;i<M;i++){
        cin >> p[i];
    }
    int ans = 0;
    bool swi=true;
    for(int bit=0; bit< (1<<N);bit++){
        bitset<10> bi(bit); //onなら１、offなら0
        //スイッチの点灯パターンは2^N
        //bi = "00"のとき
        //電球0のon数＝bi.test(s[0][0]-1)+bi.test(s[0][1]-1)=0
        //電球1のon数=bi.test(s[1][0]-1)=0
        //bi = "01"(スイッチ0だけon)の時
        /*電球0のon数 = bi.test(s[0][0]-1)+bi.test(s[0][1]-1)=1
        電球1のon数 = bi.test(s[1][0]-1)=0
        同様にすると、bi = "11"の時
        電球0のon数=2,電球1のon数=1で、条件p[0]=0,p[1]=1を満たすのはこの時だけ
        */
        swi = true;
        vector <int> on(M);
    
        for(int i = 0;i<M;i++){
            for(int j = 0;j<k[i];j++){
                on[i] += bi.test(s[i][j]-1);
            }
            on[i] = on[i]%2;
        }
        
        for(int i = 0;i<M;i++){
            if(on[i]!=p[i]){
                swi = false;
            }

            //cout << "on[" <<i<<"]="<<on[i]<<endl; 
        }
        if(swi){//on[i]とp[i]が全部同じ＝全部の電球が点灯
            ans++;
        }
        
    }
    cout << ans <<endl;
}


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

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

  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (mp.count(a)) {
      mp.erase(a);
    } else {
      mp[a] = 1;
    }
  }

  cout << mp.size() << endl;
  return 0;
}


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

int n,m;
int main(){
  int a,b,c,d,sum=0;
  cin >> a >> b >> c >> d;

  if(a>b)sum += b;
  else sum += a;

  if(c>d) sum += d;
  else sum += c;

  cout << sum << endl;
  

  
  return 0;
}


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

typedef long long ll;

#define INF 10e10
#define REP(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)
#define MAX 100

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

  for (int i = 0; i < S.size(); i += w) {
    cout << S[i];
  }

  printf("\n");
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include <cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include <bits/stdc++.h>
using namespace std;

int dfs(int h, int w, int k, int row, int col, vector<string> s){

    // row
    for(int i=0; i<h; i++){
        if(( row>>i )%2 == 1){
            for(int j=0; j<w; j++){ s[i][j] = '?';}
        }
    }
    // col
    for(int i=0; i<w; i++){
        if(( col>>i )%2 == 1){
            for(int j=0; j<h; j++){ s[j][i] = '?';}
        }
    }
    // sum
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            k -= s[i][j] == '#';
        }
    }
    if(k==0){
        return 1;
    }
    return 0;
}

int main()
{      
    int h, w, k;
    cin >> h >> w >> k;
    
    vector<string> s(h);
    
    for(int i=0; i<h; i++){
        cin >> s[i];
    }
    
    int sum = 0;
    for(int row=0; row<pow(2, h); row++){
        for(int col=0; col<pow(2, w); col++){
            sum += dfs(h, w, k, row, col, s);
        }
    }
    cout << sum << endl;

}


Measured memory_bytes: 4108
void f(int a[],int *b,int n,int s,int p){
  int i,j=0;
  if(p<n-1)
    for(i=a[p+1]+1;i<10;i++){
      a[p+2]=i;
      f(a,b,n,s,p+1);
    }
  else{
    for(i=1;i<n+1;i++)
      j+=a[i];
    if(j==s){
      (*b)++;
    }
  }
  return;
}
main(){
  int n,s;
  for(;;){
    scanf("%d %d",&n,&s);
    if(n==0&&s==0)
      break;
    int a[n+1],b=0;
    a[0]=-1;
    f(a,&b,n,s,-1);
    printf("%d\n",b);
  }
  return 0;
}

Measured memory_bytes: 0