akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }

void solve(long long A, long long B){
    cout<<A*B<<endl;
}
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3268
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

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

    ll n;
    cin>>n;
    ll ar[n];
    ll x=0;
    for(ll i=0;i<n;++i){
        cin>>ar[i];
        x=x^ar[i];
    }
    for(ll i=0;i<n;++i){
        ll r=x^ar[i];
        cout<<r<<" ";
    }

    return (0);
}


Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;
	int n;
	cin>>n;
	cout<<(n+1)/2<<endl;
}

Measured memory_bytes: 256
import random

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum += c[i]*(d-last_d[i])
        
    return (score - sum)

def main():
    D = int(input())

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

    s = [list(map(int, input().split())) for i in range(D)]

    #print(c)

    #print(s)

    last_d = [0 for i in range(26)]
    
    ans = []
    
    score = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])) and c[j] != 0:
                x = random.random()
                if x < 0.5:
                    idx = j
        last_d[idx] = i+1
        score += s[i][j]
        down_score(i+1,c,last_d,score)
        
        ans.append(idx)

    for i in range(D):
        print(ans[i]+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9828
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
int A[100010];
int q;
void swap(int g,int y)
{
	int t;
	t=A[g];
	A[g]=A[y];
	A[y]=t;
	return;
}
void partition(int p,int r)
{
	int i,j,k,x;
	i=p-1;
	j=p;
	x=A[r];
	for(k=p;k<=r-1;k++)
	{
		if(x<A[j])
			j++;
		else
		{
			i++;
			swap(i,j);
			j++;
		}
	}
	swap(i+1,r);
	q=i+1;
	return;
}
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&A[i]);
	partition(1,n);
	for(i=1;i<=q-1;i++)
		printf("%d ",A[i]);
	printf("[%d]",A[q]);
	for(i=q+1;i<=n;i++)
		printf(" %d",A[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
int p[1003];
int main(){
 int k,n;
 cin>>n>>k;
 for(int i=0;i<n;i++){
   cin>>p[i];}
    sort(p,p+n);
    int tot=0;
    for(int i=0;i<k;i++){
    tot+=p[i];}
    cout<<tot<<endl;

 return 0;
}

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

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define RFOR(i,e,s) for(int (i)=(e)-1;(i)>=(int)(s);(i)--)
#define RREP(i,e) RFOR(i,e,0)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;
typedef priority_queue<int> PQI;
typedef priority_queue<PII> PQII;

const double EPS = 1e-10;
const int N = 200000;
const int M = 200000;
int n, m, a, d, k;
int x[M], y[M], z[M], s[N], tmp[N];

int main() {
  scanf("%d ", &n);
  scanf("%d%d ", &a, &d);
  scanf("%d ", &m);
  REP(i,m) {
    scanf("%d%d%d ", x+i, y+i, z+i);
    y[i]--; z[i]--;
  }
  scanf("%d ", &k); k--;

  memset(s, 0, sizeof(s));
  s[0] = a;
  FOR(i,1,n) s[i] = s[i-1] + d;
  
  int rev_k = k;
  REP(i,m) {
    if (!x[m-1-i] && y[m-1-i]<=rev_k && rev_k<=z[m-1-i])
      rev_k = z[m-1-i]-(rev_k-y[m-1-i]);
  }

  REP(i,m) {
    if (y[i]<=rev_k && rev_k<=z[i]) {
      if (!x[i]) {
        swap(s[rev_k], s[z[i]-(rev_k-y[i])]); 
        rev_k = z[i]-(rev_k-y[i]); 
      } else
        s[rev_k] = (x[i]==1) ? s[rev_k]+1 : s[rev_k]/2;
    }
  }

  printf("%d\n", s[k]);

  return 0;
}

Measured memory_bytes: 4148
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec) {
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#define solvsh
//#define multi
#ifdef solvsh

#define LOG(FMT...) fprintf(stderr, FMT)

const int MAXN = 1e3 + 20;
const int INF = 1e9;

ll mod = 1e9 + 7;

ll ml(ll a, ll b){
    return(a * b) % mod;
}

ll add(ll a, ll b) {
    return (a + b) % mod;
}

void solve() {

    int n, m;
    cin >> n >> m;

    vector<ll> a;
    vector<ll> b;
    vector<ll> pref;
    pref.push_back(0);

    ll k;
    cin >> k;

    int answr = 0 ;

    for (int i = 0; i < n; ++ i){
        ll curr;
        cin >> curr;
        a.push_back(curr);
    }

    for (int i = 0; i < m; ++ i) {
        ll curr;
        cin >> curr;
        b.push_back(curr);
        pref.push_back(pref.back() + curr);
    }


    for (int i = 0; i <= n; ++i){

        if (i != 0) {
            k -= a[i -  1];
        }
        if (k < 0)
            break;
        int curr = i;

        if (pref.back() <= k) {
            curr += m;
        } else {  int j = lower_bound(all(pref), k + 1) - pref.begin();
            curr += j - 1;
        }
        answr = max(answr, curr);
    }


    cout << answr;
}


#else

void solve() {

}

#endif


void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Mission #" << (i++) << ": \n";

        solve();
//        cout << "\n";
    }
}



#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
//    gen();

//    doo();

    multisolve();
#else
    solve();
    //    gen();
#endif

}


Measured memory_bytes: 9784
n = int(input())
S = list(input())

#0：まだ.　1：もう#
dp = [[0, 0] for _ in range(n+1)]

for i in range(n):
  if S[i] == '.':
    dp[i+1][0] = dp[i][0]
    dp[i+1][1] = min(dp[i][0], dp[i][1])+1
  else:
    dp[i+1][0] = dp[i][0]+1
    dp[i+1][1] = min(dp[i][0], dp[i][1])
    
#print(dp)
print(min(dp[n]))

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

int main() {
  int n;
  cin>>n;
  long long a[n+1];
  for (int i=0; i<n; i++) cin>>a[i+1];
  long long dp[n+1][3];
  for (int i=0; i<n+1; i++) {
    dp[i][0] = -1e16;
    dp[i][1] = -1e16;
    dp[i][2] = -1e16;
  }
  dp[1][2] = a[1];
  dp[2][1] = a[2];
  if (n > 2) {
    dp[3][1] = a[3];
  }
  if (n > 4) {
    dp[4][0] = a[4];
  }
  for (int i=3; i<n+1; i++) {
    for (int j=2;;j++) {
      if ((i - j) / 2 + 1 < i / 2 - 1) {
        break;
      }
      if (i - j < 0) {
        break;
      }
      for (int k=0; k<3; k++) {
        if (dp[i-j][k] == -1e16) {
          continue;
        }
        int cnt = (i - j) / 2 + k;
        if (cnt == i / 2 - 1) {
          dp[i][0] = max(dp[i-j][k] + a[i], dp[i][0]);
        } else if (cnt == i / 2) {
          dp[i][1] = max(dp[i-j][k] + a[i], dp[i][1]);
        } else if (cnt == i / 2 + 1) {
          dp[i][2] = max(dp[i-j][k] + a[i], dp[i][2]);
        }
      }
    }
  }
  // for (int i=0; i<3; i++) {
  //   for (int j=0; j<n; j++) {
  //     if (dp[j+1][i] == -1e16) {
  //       printf("-INF ");
  //     } else {
  //       printf("%4d ", dp[j+1][i]);
  //     }
  //   }
  //   cout<<endl;
  // }
  if (n % 2 == 0) {
    cout<<max(dp[n][1], dp[n-1][2])<<endl;
  } else {
    cout<<max(dp[n][1], max(dp[n-1][1], dp[n-2][2]))<<endl;
  }
}

Measured memory_bytes: 9884
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	string s; cin >> s;
	int n=s.size();
	deque<char> x;
	rep(i,n){
		if(s[i]=='S') x.push_back(s[i]);
		if(s[i]=='T'){
			if(x.empty()||x.back()=='T') x.push_back(s[i]);
			else x.pop_back();
		}
	}
	cout << x.size() << endl;
}




Measured memory_bytes: 644
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                int A = sc.nextInt();
                int B = sc.nextInt();
                sc.close();
                int r = ((B - 1) + (A - 2)) / (A - 1);
                System.out.println(r) ;
        }
}


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

int main(void){
  int n, rank;
  int C[4][13];
  char art;

  cin >> n;

  for ( int i = 0; i < 4; i++ ){
    for ( int j = 0; j < 13; j++ ){
      C[i][j] = 0;
    }
  }

  for ( int i = 0; i < n; i++ ){
    cin >> art >> rank;
    if ( art == 'S'){
      C[0][rank-1] = 1;
    }else if ( art == 'H'){
      C[1][rank-1] = 1;
    }else if ( art == 'C'){
      C[2][rank-1] = 1;
    }else if ( art == 'D'){
      C[3][rank-1] = 1;;
    }
  }

  for ( int i = 0; i < 4; i++){
    for ( int j = 0; j < 13; j++){
      if ( C[i][j] == 0 ){
	switch(i){
	case 0: cout << "S " << j+1 << endl; break;
	case 1: cout << "H " << j+1 << endl; break;
	case 2: cout << "C " << j+1 << endl; break;
	case 3: cout << "D " << j+1 << endl; break;
	}
      }
    }
  }
	  
  
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
int main() {
  
  int N,K;
  cin>>N>>K;
  
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  
  cout<<(N-2)/(K-1)+1<<endl;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll L, R;
    cin >> L >> R;

    if(R>=L+2018){
        cout << 0 << endl;
    }
    else{
        ll m = 2018;
        REP(i, L, R+1){
            REP(j, i+1, R+1){
                ll t = ((i*j) % 2019 + 2019) % 2019;
                if(t<m) m = t;
            }
        }
        cout << m << endl;
    }
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<stack>
#include<vector>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
#include<sstream>
#define ll long long
const int inf = 0x3f3f3f3f;
const int N = 1e-6;
const ll M = 1e9+7;

using namespace std;



int main()
{
	ios::sync_with_stdio(false);
	ll ans = 0;
	ll a;
	double b;
	cin>>a>>b;
         b+=(1e-6);
	ans=b*100;
	ans = a*ans/100;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3700
#include<cstdio>
#define REP(i,n) for(int i=0;i<(int)(n);i++)

void hoge(int* a){
  int cards[13]{0};
  REP(i,5) cards[a[i]-1]++;
  REP(i,13){
    if(cards[i]==4){
      puts("four card");
      return;
    }
  }
  REP(i,13){
    if(cards[i]==3){
      REP(j,13){
	if(cards[j]==2){
	  puts("full house");
	  return;
	}
      }
      puts("three card");
      return;
    }
  }
  REP(i,13){
    if(cards[i]==2){
      for(int j=i+1;j<=13;j++){
	if(cards[j]==2){
	  puts("two pair");
	  return;
	}
      }
      puts("one pair");
      return;
    }
  }
  REP(i,13){
    if(cards[i]==1){
      if(cards[i+1]==1&&
	 cards[i+2]==1&&
	 cards[i+3]==1&&
	 cards[i+4]==1){
	puts("straight");
	return;
      }
    }
  }
  if(cards[0]==1&&
     cards[9]==1&&
     cards[10]==1&&
     cards[11]==1&&
     cards[12]==1){
    puts("straight");
    return;
  }
  puts("null");
  return;
}

int main(){
  int a[5];
  while(scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4])>0){
    hoge(a);
  }
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int N,M;
	cin >> N >> M;
	vector<int> a(M), b(M), town(N,0);

	for (int i = 0; i < M; ++i) {
		cin >> a.at(i) >> b.at(i);
		town.at(a.at(i)-1)++;
		town.at(b.at(i)-1)++;
	}
	for (int i = 0; i < N; ++i) {
		cout << town.at(i) << endl;
	}
}

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

const int MAX = 100005;
int n, length;
int A[MAX], L[MAX];

void LIS()
{
    L[0] = A[0];
    length = 1;
    for(int i=1; i<n; i++)
    {
        if(L[length-1]>=A[i])
        {
            int *p = lower_bound(L,L+length,A[i]);
            *p = A[i];
        }
        else
        {
            L[length++] = A[i];
        }
    }
}
int main()
{

    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> A[i];
    }
    LIS();
    cout << length << endl;
    return 0;
}



Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> A(n);
    for(ll i=0;i<n;i++)
    cin>>A[i];
    vector<ll>B;
    B.push_back(A[0]);
    for(ll i=1;i<n;i++)
    {
        if(A[i]!=B[B.size()-1])
        {
            B.push_back(A[i]);
        }
    }
    map<ll,ll> ma;
    vector<ll> C(B.size(),-1);
    for(ll i=B.size()-1;i>=0;i--)
    {
        if(ma.find(B[i])==ma.end())
        ma[B[i]] = i;
        else
        {
            //cout<<i<<" "<<B[i]<<" "<<ma[B[i]]<<endl;
            C[i] = ma[B[i]];
            ma[B[i]] = i;
        }
    }

    vector<ll> dp(B.size(),1);
    ll mod = 1000000007;
    for(ll i=B.size()-2;i>=0;i--)
    {
        if(C[i]==-1)
        dp[i] = dp[i+1];
        else
        {
            dp[i] = dp[i+1]+dp[C[i]];
        }
        dp[i]%=mod;
    }
    cout<<dp[0];
    return 0;
}


Measured memory_bytes: 19056
#include <iostream>
using namespace std;
int main()
{
	int n ,y;
	bool ans = false;
	cin >> n >> y;
	for (int a = 0; a <= n; a++)
	{
		if (ans)
		{
			break;
		}
		for (int b = 0; b <= n; b++)
		{
			int c = y - ((a * 10000) + (b * 5000));
			if (c < 0) {
				continue;
			}
			c /= 1000;
			if ((a + b + c) == n && (a*10000 + b*5000 + c*1000) == y)
			{
				ans = true;
				cout << a << " " << b << " " << c << endl;
				break;
			}

		}
	}
	if (!ans)
	{
		cout << "-1 -1 -1" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s;
	cin >> s;
	if (s.at(0) == s.at(1) && s.at(1) == s.at(2))
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

}

Measured memory_bytes: 3628
def abc075_d():
    n, k = map(int, input().split())
    P = []
    xarr = []
    yarr = []
    for _ in range(n):
        x, y = (int(x) for x in input().split())
        P.append((x, y))
        xarr.append(x)
        yarr.append(y)
    xarr.sort()
    yarr.sort()

    ans = 5*10**18
    for s, xi in enumerate(xarr):
        for xj in xarr[s+1:]:
            cand = [(x, y) for x, y in P if xi <= x and x <= xj]
            for t, yi in enumerate(yarr):
                for yj in yarr[t+1:]:
                    cnt = len([y for x, y in cand if yi <= y and y <= yj])
                    if cnt >= k:
                        area = (xj - xi) * (yj - yi)
                        ans = min(ans, area)
    print(ans)

if __name__ == '__main__':
    abc075_d()

Measured memory_bytes: 9044
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 1e9+7;
const lint INF = mod*mod;
const int MAX = 1<<20;

lint powmod(lint x, lint n){
    lint ret = 1;
    while(n > 0){
        if(n&1) ret *= x, ret %= mod, n -= 1;
        else x *= x, x %= mod, n >>= 1;
    }
    return ret;
}

lint dp[MAX], zero[MAX], cnt[MAX], now;

int main(){
    int n;
    scanf("%d", &n);
    int a[n], s[n+1];
    s[0]=0;
    rep(i, n){
        scanf("%d", &a[i]);
        s[i+1]=s[i]^a[i];
    }
    rep(i, MAX){
        zero[i]=cnt[i]=0;
        dp[i]=1;
    }
    now=0;
    rep(i, n+1){
        if(s[i]==0) ++now;
        else{
            (dp[s[i]]+=zero[s[i]]*(now-cnt[s[i]])%mod)%=mod;
            (zero[s[i]]+=dp[s[i]])%=mod;
            cnt[s[i]]=now;
        }
    }
    if(s[n]!=0){
        printf("%lld\n", dp[s[n]]);
        return 0;
    }
    lint ans=0;
    rep(i, MAX)if(cnt[i]) (ans+=zero[i])%=mod;
    (ans+=powmod(2, now-2))%=mod;
    printf("%lld\n", ans);
}

Measured memory_bytes: 28672
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

vector<int> to[2505];
vector<int> rto[2505];
bool reachablefrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachablefrom1[v]) return;
  reachablefrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  int n = in();
  vi a(n), b(n), c(n - 1);
  cin >> a >> b >> c;
  rep(i, n) a[i]--;
  a.pb(0);
  int ans = 0;
  rep(i, n) {
    ans += b[a[i]];
    if (a[i + 1] - a[i] == 1) {
      ans += c[a[i]];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint x(N+2);
    for(int i=1;i<=N;i++) cin>>x[i];
    x[0]=x[N+1]=0;

    int sum=0;
    for(int i=0;i<=N;i++) sum+=abs(x[i+1]-x[i]);

    for(int i=1;i<=N;i++){
        int cost=sum-(abs(x[i]-x[i-1])+abs(x[i+1]-x[i]))+abs(x[i+1]-x[i-1]);
        cout<<cost<<endl;
    }
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ok = LINF, ng = 0, mid;
    while (ok - ng > 1) {
        mid = (ok + ng) / 2;
        ll cnt = 0;
        rep(i, n) cnt += (a[i] + mid - 1) / mid - 1;
        (cnt <= k ? ok : ng) = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
struct UnionFind{
    vector<int> par;//親(根)
    vector<int> rank;//木の深さ

    //UnionFind(int n) { init(n); };
    UnionFind(int n){//初期化関数
        par.resize(n);
        rank.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;//初めはノード一個の木なので根は自身
            rank[i] = 1;
        }
    }

    int root(int x){//木の根を求める
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
    }

    bool same(int x, int y){//同じ木かどうか判定
        return root(x) == root(y);//同じ木ならtrue
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;//もし同じ木に属していたら何もしない
        if(rank[x] < rank[y]) swap(x, y);//数が大きい方に小さい方を結合させる
        par[y] = x;
        rank[x] += rank[y];//深さが同じ時だけ結合後深さが増える
    }

    int size(int x) {//深さを返す関数
        return rank[root(x)];
    }
};
int main(){
    int N, M;
    cin >> N >> M;
    vector<long long> A(M), B(M);
    UnionFind U(N);
    for(int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        U.unite(A[i], B[i]);
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans = max(ans, U.size(i));
    }
    cout << ans << endl;
}

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




void solve(long long X, long long K, long long D){
    ll ans = 0;
    if( log10(abs(K))+log10(abs(D)) > 16 or K*D > abs(X) ){
        if( ((K-abs(X)/D)&1) == 1 )
            if( X >= 0 ) 
                ans = X - (X/D+1)*D;
            else
                ans = X + (abs(X)/D+1)*D;
        else
            if( X >= 0 ) 
                ans = X - (X/D)*D;
            else
                ans = X + (abs(X)/D)*D;
    }
    else{
        ans =  abs(X) - abs(K) * abs(D) ;
    }
    cout << abs(ans) << endl;
    
}


signed main(){
    long long X;
    scanf("%lld",&X);
    long long K;
    scanf("%lld",&K);
    long long D;
    scanf("%lld",&D);
    solve(X, K, D);
    return 0;
}


Measured memory_bytes: 3992
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define print(x) cerr <<"\033[1;33m" << x << "\033[0m" << '\n'
#define int long long
#define LL __int128_t
const int xx = 2e5;
const int MOD = 1e9 + 7;

void subset(vector<int>&a , vector<int>&p){
  int N = a.size();
  int mask = 1 << N;

  for(int i=0;i<mask;i++){
    int sum = 0;
    for(int j=0;j<N;j++) {
      if(i & (1 << j)){
        sum += a[j];
      }
    }
    p.push_back(sum);
  }
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  int n;
  cin >> n;
  set<int>st;
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    st.insert(x);
  }
  if(st.size() == n){
    cout << "YES" << '\n';
  }
  else cout << "NO" << '\n';
}

Measured memory_bytes: 9600
n = int(input())
mokuhyo = list(map(int, input().split()))
#
# n = 8
# s = "4 23 75 0 23 96 50 100"
# mokuhyo = list(map(int, s.split()))

i = 0
count = 0

while(i < n):
    if mokuhyo[i] == 0:
        i += 1
        continue
    r = 999999
    for j in range(i+1, n):
        if mokuhyo[j] == 0:
            r = j
            break

    if r == 999999:
        r = n

    gensyo = min(mokuhyo[i:r])
    count += gensyo
    for k in range(i, r):
        mokuhyo[k] -= gensyo


print(count)


Measured memory_bytes: 3064
i,j,c,b,v,u,D[10000];main(N,K,T,U,V,L,x){
scanf("%d%d%d%d%d%d",&N,&K,&T,&U,&V,&L);
for(;i<N;i++)scanf("%d",&x),D[x]=1;
for(;j<L;b?v++,b--:u++,j++)if((c+=D[j])>K||(c&&!b))c--,b=T*V;
printf("%f\n",1.*v/V+1.*u/U);
exit(0);}

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

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	int N, M, L[200000], R[200000], D[200000];
	vector<pair<int, int>>vec[100000];
	
	
	cin >> N >> M;
	REP(i, M) {
		cin >> L[i] >> R[i] >> D[i];
		vec[L[i] - 1].push_back(make_pair(R[i] - 1, D[i]));
		vec[R[i] - 1].push_back(make_pair(L[i] - 1, -1 * D[i]));
	}

	int pos[100000] = { 0 };
	int c[100000] = { 0 };
	REP(i, N) {
		stack<int>s;
		if (c[i] == 0) {
			s.push(i);
			c[i] = 1;
			while (!s.empty()) {
				int t = s.top();
				s.pop();
				REP(j, vec[t].size()) {
					if (c[vec[t][j].first] == 0) {
						s.push(vec[t][j].first);
						c[vec[t][j].first] = 1;
						pos[vec[t][j].first] = pos[t] + vec[t][j].second;
					}
				}
			}
		}
	}

	bool f = true;
	int r = 0, l = 0;
	REP(i, N) {
		r = max(r, pos[i]);
		l = min(l, pos[i]);
	}
	ll dis = (ll)r - (ll)l;
	if (dis > 1000000001) {
		f = false;
	}


	REP(i, M) {
		if (pos[R[i] - 1] - pos[L[i] - 1] != D[i]) {
			f = false;
			break;
		}
	}

	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 12032
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		ll n,m;cin>>n>>m;
		ll sum=0;
		for(int i=0;i<m;i++){
			ll x;cin>>x;
			sum+=x;
		}     
		if(sum>n)cout<<"-1";
		else cout<<n-sum;
		cout<<endl;
    }
    return 0;
        
}


Measured memory_bytes: 3648
n = int(input())

def f(p,q):
    res = 0
    if p == q and n >= p:
        res += 1
    

    for k in range(2,7):
        t = p*pow(10,k-1) + q
        if t > n:
            continue
        for w in range(10**(k-2)):
            if t+w*10 <= n:
                res += 1
            else:
                break
    return res

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += f(i,j)*f(j,i)
print(ans)


Measured memory_bytes: 39408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int a,b;cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}

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

int main(){
	int a,b; cin>>a>>b;
	string ans="Yay!";
	if(a>8||b>8) ans=":(";
	cout<<ans<<endl;
	return 0;
}


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

# refered to
# rank : http://at274.hatenablog.com/entry/2018/02/02/173000
# size : abc120 kaisetsu
class UnionFind:
    def __init__(self, n):
        # par = Parent Number or NoV
        self.par = [-1] * (n+1)
        # rank = Tree Height
        self.rank = [0] * (n+1)
    
    # Returns the number of sets to which x belongs
    def size(self, x):
        return -1*self.par[self.find(x)]
    
    def size_list(self):
        return [x*(-1) for x in self.par[1:] if x < 0]

    # Returns number if root
    def find(self, x):
        if(self.par[x] < 1):
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    # Are the parents of x and y the same?
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        # find root 
        x = self.find(x)
        y = self.find(y)

        # Already x connect to y
        if(x == y):
            return False

        # Reconnect
        if(self.size(x) < self.size(y)):
            x,y = y,x
        
        # update x size
        self.par[x] += self.par[y]
        # set parent number of y to x
        self.par[y] = x

        return True 
    
    # def root_nodes(self):
    #     return [-i for i in self.par[1:] if i <= -1]
    
    

def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    ans = []

    uf = UnionFind(N)
    ans.append((N-1)*N//2)
    for i in range(M-1, 0, -1):
        if uf.find(A[i]) != uf.find(B[i]):
            ans.append(max(0, ans[-1]-uf.size(A[i])*uf.size(B[i])))
            uf.union(A[i], B[i])
        else:
            ans.append(ans[-1])
    
    for i in reversed(range(len(ans))):
        print(ans[i])

    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
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]" 
    B = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17792
# ABC129B

n = int(input())
w = list(map(int, input().split()))
s = sum(w)
Min = s
for i in range(n - 1):
    # s1 = sum(w[:i + 1])
    # Min = min(abs(s1 - (s - s1)), Min)
    Min = min(abs(2*sum(w[:i + 1]) - s), Min)
print(Min)


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

int main(){
	string s,t;
  	cin>>s>>t;
	sort(s.begin(),s.end());
  	sort(t.begin(),t.end());
  	for(int i=0;i<t.size();++i){
    	if(s[i]>t[t.size()-1-i]){cout<<"No"<<endl;return 0;}
      	else if(s[i]<t[t.size()-1-i]){cout<<"Yes"<<endl;return 0;}
      	if(s[i]=='\0'){cout<<"Yes"<<endl;return 0;}
    }
  	cout<<"No"<<endl;
  	return 0;
}

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

#define ll long long
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define setbits(x) __builtin_popcount(x)
#define setbits_ll(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctz(x)
#define zrobits_ll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x //set precision of double x to y decimal places \
                                               //ps(1.254754, 4) -> 1.2547

using namespace std;

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

    int n, d, ans =0; cin>>n>>d;
    while (n--) {
        double x, y; cin>>x>>y;

        if (sqrt(x*x + y*y) <= d) ans++;
    }

    cout<<ans<<'\n';
}
//functions

int getpow(int a, int b)
{
    if (b == 0)
        return 1;

    int x = getpow(a, b / 2);
    if (b & 1)
        return x * x * a;
    else
        return x * x;
}


Measured memory_bytes: 3808
#include<iostream>
using namespace std;
int main(){
  int x;
  cin>>x;
 if(x>=400 && x<=599)
   cout<<8<<endl;
 else if(x>=600 && x<=799)
   cout<<7<<endl;
 else if(x>=800 && x<=999)
   cout<<6<<endl;
  else if(x>=1000 && x<=1199)
   cout<<5<<endl;
 else if(x>=1200 && x<=1399)
   cout<<4<<endl;
 else if(x>=1400 && x<=1599)
   cout<<3<<endl;
 else if(x>=1600 && x<=1799)
   cout<<2<<endl;
 else if(x>=1800 && x<=1999)
   cout<<1<<endl;
}

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

int main()
{
	int A=0,B=0,O=0,AB=0;
	int n;
	char dot,blood[3];
	while(cin >> n >> dot >> blood){
		if(blood[0] == 'A' && blood[1] == 'B')
			AB++;
		else if(blood[0] == 'A')
			A++;
		else if(blood[0] == 'B')
			B++;
		else if(blood[0] == 'O')
			O++;
	}
	cout << A << endl;
	cout << B << endl;
	cout << AB << endl;
	cout << O << endl;
	return 0;
}

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

int main() {
  int64_t N,a,ans;
  cin >> N;
  a = sqrt(N);
  for (int64_t i = a; i > 0; i--) {
    if (N % i == 0) {
      ans = i + (N/i) -2;
      break;
    }
  }
  cout << ans << endl;
}


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

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

typedef long long ll;
 
int main() {
    ll a;
    double b;
    cin>>a>>b;
    ll lb = b*100 + 0.05;
    ll c = (a*lb)/100;
    cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" <<; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	// 入力
	ll N;
	cin >> N;

	vec W(N);

	ll S1 = 0, S2 = 0;
	REP(i, N) {
		cin >> W[i];
		S2+=W[i];
	}

	ll ans = INF;
	REP(i, N) {
		S1 += W[i];
		S2 -= W[i];
		ans = min(ans, abs(S1 - S2));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const vector<int> dx{0,0,1,-1};
    const vector<int> dy{-1,1,0,0};
    int h, w;
    cin >> h >> w;
    vector<string> ss(h);
    REP(i,h) cin >> ss[i];

    bool ans = true;
    REP(y,h) REP(x,w) {
        if (ss[y][x] == '.') continue;
        REP(i,5) {
            if (i == 4) {
                ans = false;
                break;
            }
            int x2 = x + dx[i];
            int y2 = y + dy[i];
            if (x2 < 0 || x2 >= w) continue;
            if (y2 < 0 || y2 >= h) continue;
            if (ss[y2][x2] == '#') break;
            
        }
        if (!ans) break;
    }

    ATYN(ans)

    return 0;
}

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

int main(void){
    int N;
    int numAC = 0;
    int numWA = 0;
    int numTLE = 0;
    int numRE = 0;
    string Sbuf;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> Sbuf;
        if(Sbuf == "AC"){
            numAC++;
        }else if(Sbuf == "WA"){
            numWA++;
        }else if(Sbuf == "TLE"){
            numTLE++;
        }else if(Sbuf == "RE"){
            numRE++;
        }
    }
    cout << "AC x " << numAC << endl;
    cout << "WA x " << numWA << endl;
    cout << "TLE x " << numTLE << endl;
    cout << "RE x " << numRE << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
long long ans,i,n,a[2000005],p[2000005],q[2000005];
int main(){

	long long int mini = 1e18;

	cin >> n;

	for(i = 1; i <= n; i++)
		cin >> a[i];

	for(i = 1; i <= n; i++){
		p[i] = p[i-1] + a[i];

		q[n-i+1] = q[n-i+2] + a[n-i+1];
	}
	//for(i = 1; i <= n; i++){
	//	cout << p[i] << ' ' << q[i] << endl; 
	//}

	for(i = 1; i < n; i++){
		ans = abs(p[i] - q[i+1]);
		mini = min(mini, ans);
	}

	cout << mini << endl;

	return 0;
}


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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007



int main() {
    ll N, M; cin >> N >> M;
    vector<pair<ll, ll>> P(N);
    rep(i, N) {
        ll a, b; cin >> a >> b;
        P[i] = mp(a, b);
    }
    sort(all(P));
    ll ans = 0;
    int n = 0;
    int i = 0;
    while (n < M) {
        ll a = P[i].first, b = P[i].second;
        if (n + b < M) {
            n += b;
            ans += a * b;
            i++;
        }
        else {
            ans += a * (M - n);
            break;
        }
    }
    cout << ans << endl;
}







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

using namespace std;

typedef long long ll;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    ll m = 999999999999;
    for (int i = 0;; i++) {
        int a = max(0, X - i);
        int b = max(0, Y - i);
        int c = i * 2;
        ll cost = a * A + b * B + c * C;
        m = min(m, cost);
        if (a == 0 && b == 0) { break; }
    }

    cout << m << endl;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n,m;
	cin >> n >> m;
	VL x(m),y(m);
	for (int i = 0; i < m; i++) {
		cin >> x[i] >> y[i];
	}
	VL red(n,0),numb(n,1);
	red[0] = 1;
	for (int i = 0; i < m; i++) {
		numb[x[i]-1]--;
		numb[y[i]-1]++;
		if (red[x[i]-1] == 1) {
			red[y[i]-1] = 1;
			if (numb[x[i]-1] == 0) {
				red[x[i]-1] = 0;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (red[i] == 1 and numb[i] > 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
/*
 © 2020-06-27 07:00:49 Franco1010 All Rights Reserved
*/

#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
#define deb(x) cout << #x": " << (x) << endl;
lli bs(vector<lli> &v, lli k){
  lli pos = 0;
  for(lli p = sz(v); p > 0; p /= 2) while(pos + p < sz(v) and v[pos + p] <= k) pos += p;
  return pos;
}
int main(){ _
  lli n, m, k; cin >> n >> m >> k;
  vector<lli> a(n + 1, 0), b(m + 1, 0);
  fore(i, 0, n){
    cin >> a[i + 1];
    a[i + 1] += a[i];
  }
  fore(i, 0, m){
    cin >> b[i + 1];
    b[i + 1] += b[i];
  }
  lli res = 0;
  fore(i, 0, n + 1){
    if(a[i] <= k){
      res = max(res, i + bs(b, k - a[i]));
    }
  }
  cout << res << ENDL;
  return 0;
}


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

#define up(i,j,k) for (int i = (j); i <= (k); i++)
#define down(i,j,k) for (int i = (j); i >= (k); i--)
#define DEBUG printf("Passing [%s] in LINE %d\n", __FUNCTION__, __LINE__)

#define lb long double
#define ll long long
#define ull unsigned long long

#define mp std::make_pair
#define pb push_back

#define all(x) (x).begin(), (x).end()
#define mem(a) memset((a), 0, sizeof(a))
#define File(x)                       \
    freopen("" #x ".in", "r", stdin); \
    freopen("" #x ".out", "w", stdout);

#define int long long

inline int read() {
    int data = 0, w = 1; char ch = 0;
    while (ch != '-' && (ch > '9' || ch < '0')) ch = getchar();
    if (ch == '-') w = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') { data = data * 10 + ch - '0'; ch = getchar(); }
    return data * w;
}

inline void print (int v) {
    if (v < 0) { putchar('-'); v = -v; }
    if (v > 9) print(v / 10);
    putchar(v % 10 + '0');
}

const int C = 1000;

std::string str;
int vis[C];

signed main () {
    std::cin >> str;
    vis['A'] = vis['G'] = vis['C'] = vis['T'] = 1;
    int n = str.length(); str = " " + str;
    int l = 1, r = 1, ans = 0;
    while (l <= n) {
        r = std::max(r, l);
        while (r <= n && vis[str[r]]) r++;
        ans = std::max(ans, r - l);
        l = r + 1;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256