akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];
    sort(v.begin(), v.end());
    vector<int> fact;
    for(int i = 1; i*i <= v[1]; i++){
        if(v[1]%i == 0){
            fact.push_back(i);
            if(i*i != v[1]) fact.push_back(v[1]/i);
        }
        if(v[0]%i == 0){
            fact.push_back(i);
            if(i*i != v[0]) fact.push_back(v[0]/i);
        }
    }
    sort(fact.rbegin(), fact.rend());
    int ans = 1;
    for(int i = 0; i < fact.size(); i++){
        int cnt = 0;
        int val = fact[i];
        for(int j = 0; j < n; j++){
            cnt += (v[j]%val == 0);
            if(cnt + n-1-j < n-1)   break;
        }  
        if(cnt >= n-1){
            ans = val;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

using namespace std;
using ll = long long;

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

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


//////////////////////////////////////////////////

ll dp[100010][15];
const ll mod = 1000000007;

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

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    for (int i = 0; i < len; i++)
    {
        if (s[i] == '?') {
            for (int j = 0; j < 13; j++)
            {
                for (int k = 0; k < 10; k++)
                {
                    int nextj = (j*10+k)%13;
                    dp[i+1][nextj] += dp[i][j];
                    dp[i+1][nextj] %= mod;
                }
            }
            
        } else {
            int d = s[i] - '0';
            for (int j = 0; j < 13; j++)
            {
                int nextj = (j*10+d)%13;
                dp[i+1][nextj] += dp[i][j];
                dp[i+1][nextj] %= mod;
            }
            
        }
    }
    
    ll ans = dp[len][5];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, z, w, i, a[2003], ans;

    scanf("%d%d%d", &n, &z, &w);
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    if (n == 1) {
        printf("%d\n", abs(a[0] - w));
        return 0;
    }

    ans = max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1]));

    printf("%d\n", ans);

    return 0;
}

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

using namespace std;

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

string reduce(string s2){
  string result;
  int last = 0;
  for(int i = 0; i < s2.size(); i++) {
    if(0 < result.size() && result.back() == 'S' && s2[i] == 'S')
      result.pop_back();
    else
      result += s2[i];
  }
  return result;
}

int powp(int n){
  int result = 1;
  for(int i = 0; i < n; i++)
    result *= 3;
  return result;
}

vector<int> solve(int n, string s){
  if(n == 0){
    vector<int> temp;
    temp.push_back(0);
    return temp;
  }
  s = reduce(s);
  int lim = powp(n);
  vector<int> sol(lim);

  for(int i = 0; i < 3; i++){
    int curr = i;
    string s0;
    for(int j = 0; j < s.size(); j++){
      if(s[j] == 'R')
        curr++;
      else {
        if(curr == 2)
          curr = 1;
        else if(curr == 1)
          curr = 2;
      }
      if(s[j] == 'S')
        s0 += "S";
      else if(curr == 3){
        curr = 0;
        s0 += "R";
      }
    }
    vector<int> sol0 = solve(n - 1, s0);
    for(int j = 0; j < lim / 3 ; j++)
      sol[j * 3 + i] = sol0[j] * 3 + curr;
  }
  return sol;
}

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> sol = solve(n, s);
  for(int i = 0; i < sol.size(); i++)
    cout << sol[i] << " ";
  return 0;
}


Measured memory_bytes: 7704
#include <stdio.h>

int min(int a, int b) {
   return a < b ? a : b;
}

int main(void) {
  int i, j, k, n, ans = 0;
  scanf("%d", &n);
  int a, mod[3];
  for(i = 0; i < 3; ++i) mod[i] = 0;
  for(i = 0; i < n; ++i) {
    scanf("%d", &a);
    a %= 3;
    mod[a]++;
  }
  if(!mod[1] && !mod[2]) ans = 1;
  else {
    ans = mod[0];
    if(mod[1] > mod[2]) ans += mod[2] + min(mod[2] + 3, mod[1]);
    else ans += mod[1] + min(mod[1] + 3, mod[2]);
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

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

	int N;
	cin >> N;

	vector<int> dp(3);

	for (int i = 0; i < N; i++) {
		vector<int> new_dp(3, 0);
		vector<int> c(3);
		for (int j = 0; j < 3; j++)
			cin >> c[j];
		
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j != k)
					new_dp[k] = max(new_dp[k], dp[j] + c[k]);
			}
		}
		dp = new_dp;
	}

    cout << max({dp[0], dp[1], dp[2]}) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <climits>
#include <vector>
using namespace std;

int main() {
    while(true) {
        int n,k; scanf("%d%d", &n, &k);
        if(n==0) break;
        static int a[100001];
        a[0] = 0;
        for(int i = 0; i < n; i++) {
            int x; scanf("%d", &x);
            a[i+1] = a[i] + x;
        }
        int max_sum = INT_MIN;
        for(int i = k; i <= n; i++) {
            max_sum = max(max_sum, a[i]-a[i-k]);
        }
        printf("%d\n", max_sum);
    }
    return 0;
}

Measured memory_bytes: 0
f=1
a,b=list(map(int,input().split()))
s=input()
if s[a]!="-":
  f=0

for i in range(a):
  if not s[i] in "1234567890":
    f=0
for i in range(b):
  if not s[i+a+1] in "1234567890":
    f=0
if f:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
# define N 20
#define endl "\n"
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
    IO;
    string s;
    cin>>s;
    char pre = s[0];

    for(int i = 0;i<s.length();i++){
        if(s[i]=='?'){
            s[i] = (pre=='P')? 'D':'D';
            pre = s[i];
        }
        else
            pre = s[i];
    }

    cout<<s<<endl;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int need[]={0,2,5,5,4,5,6,3,7,6};
// dp[i]:=i本で作れる最大
string dp[10010];
int main(){
    int n,m; cin>>n>>m;
    int a[m]; rep(i,m) cin>>a[i];
    rep(i,10010) dp[i]=".";
    dp[0]="";
    for(int i=1;i<=n;i++){
        for(auto j:a){
            if(i-need[j]<0) continue;
            if(dp[i-need[j]]==".") continue;
            string tmp=dp[i-need[j]]+(char)(j+'0');
            if((int)dp[i].size()<(int)tmp.size()){
                dp[i]=tmp;
            }else if((int)dp[i].size()==(int)tmp.size()){
                if(dp[i]<tmp){
                    dp[i]=tmp;
                }
            }
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


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

int main(){
	int n;scanf("%d",&n);
	int ans=0;
	for(int i=2;i<=n;++i){
		int pos=0;
		for(int j=2;j<=sqrt(i);++j){
			if(i%j==0){
				pos++;
				if(j*j!=i) pos++;
			}
		}
		if(pos==6&&i&1) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>

int main(void){

        int N, t_tmp, x_tmp, y_tmp;

        std::cin >> N;
        std::vector<int> time(N+1,0), x(N+1,0), y(N+1,0);
        time.at(0) = 0; x.at(0) = 0; y.at(0) = 0;

        int i=1;
        while( std::cin >> t_tmp >> x_tmp >> y_tmp){
                time.at(i) = t_tmp;
                x.at(i) = x_tmp;
                y.at(i) = y_tmp;
                i++;
        }

        for(i=0;i<N;i++){
                int t = time[i+1] - time[i];
                int d = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);

                if( (d > t) | (t%2 != d%2) ){
                        std::cout << "No" << std::endl;
                        return 0;
                }
        }
        std::cout << "Yes" << std::endl;
        return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
int k;
string s, t;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    cin >> s;
    rep(i,k) {
        bool end = true;
        rep(j,s.size()-1) {
            if (s[j] != s[j+1]) {
                end = false;
            }
        }
        if (end) break;
        t = s;
        for (int j = s.size()-1; j >= 0; j--) t.push_back(s[j]);
        if (i == k-1) {
            for (int j = 1; j <= n; j++) {
                bool ok = false;
                rep(u,n) {
                    if (s[u] > t[j+u]) {
                        ok = true;
                        break;
                    }
                    if (s[u] < t[j+u]) {
                        break;
                    }
                }
                if (ok) {
                    rep(u,n) s[u] = t[j+u];
                }
            }
        } else {
            for (int j = 2*n-1, _ = 0; j >= n; j--) {s[_] = t[j]; _++;}
            for (int j = 2*n-2; j >= n-1; j--) {
                bool ok = false;
                rep(u,n) {
                    if (s[u] > t[j-u]) {
                        ok = true;
                        break;
                    }
                    if (s[u] < t[j-u]) {
                        break;
                    }
                }
                if (ok) {
                    rep(u,n) s[u] = t[j-u];
                }
            }
            reverse(s.begin(), s.end());
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
def hanten(tairu):
    if tairu == 0:
        return 1
    else:
        return 0

def main():
    l = list(map(int, list(input())))
    
    if len(l) <= 1:
        print(0)
    else:
        cnt = 0
        move_cnt = 1
        if l[0] == l[move_cnt]:
            l[move_cnt] = hanten(l[move_cnt])
            cnt = 1
        
        while move_cnt + 1 <= len(l) - 1:
            if l[move_cnt] == l[move_cnt + 1]:
                l[move_cnt + 1] = hanten(l[move_cnt + 1])
                cnt += 1
                
            move_cnt += 1
    
        print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4652
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
typedef pair<int, int> P;

int main(){
    ll n, a, b, res;
    cin >> n >> a >> b;
    res = (n/(a+b)) * a + min((n%(a+b)), a);
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
T = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    if T[i+1] - T[i] > t:
        ans += t
    else:
        ans += T[i+1] - T[i]
        
ans += t
print(ans)

Measured memory_bytes: 26708
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s=="SUN") cout << '7';
    if(s=="MON") cout << '6';
    if(s=="TUE") cout << '5';
    if(s=="WED") cout << '4';
    if(s=="THU") cout << '3';
    if(s=="FRI") cout << '2';
    if(s=="SAT") cout << '1';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll i,o,t; cin >> i >> o >> t;
    ll j,l,s; cin >> j >> l >> s;
    ll z; cin >> z;
    ll ans = 0;
    ans += o * 2;
    if((i & 1) + (j & 1) + (l & 1) >= 2){
        if(i && j && l){
            i--;j--;l--;
            ans += 6;
        }
    }
    ans += (i / 2) * 4;
    ans += (j / 2) * 4;
    ans += (l / 2) * 4;

    cout << ans / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
  int N;
  cin >> N;
  string str;
  
  for(int i=1;i<=9;++i){
    for(int j=1;j<=9;++j){
      if(i*j==N)	str = "Yes";
      else str = "No";
      if(str=="Yes"){
        cout << str << endl;
        return 0;
      }
      else
        continue;
    }
  }
  
  cout << str << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const int inf = 1e+7;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int N; cin >> N;
    vector<int> Q(N);
    rep(i, N) {
        int x; cin >> x; x --;
        Q[x] = i;
    }
    
    int ans = 1, t = 1;
    rep1(i, N - 1) {
        if (Q[i] > Q[i - 1]) {
            t ++;
        } else {
            t = 1;
        }
        ans = max(ans, t);
    }
    
    cout << N - ans << "\n";
 
 
    return 0;
} 

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		byte min, count = 0, arrayLength = Byte.parseByte(in.readLine());
		byte[] array = new byte[arrayLength];
		String[] strData = in.readLine().split(" ");
		for (int i = 0; i < arrayLength; i++) {
			array[i] = Byte.parseByte(strData[i]);
		}
		for (byte x = 0; x < arrayLength; x++) {
			min = x;
			for (byte y = (byte) (x + 1); y < arrayLength; y++) {
				if (array[min] > array[y]) {
					min = y;
				}
			}
			if (array[x] > array[min]) {
				byte temp = array[x];
				array[x] = array[min];
				array[min] = temp;
				count++;
			}
		}
		for (int j = 0; j < arrayLength; j++) {
			if (j == arrayLength - 1) {
				System.out.println(array[j]);
			} else {
				System.out.print(array[j] + " ");
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 16964
#include<stdio.h>
#include<stdlib.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):-(a))
typedef long long ll;
ll dp[2020][2020];
ll n,a[2020],p[2020];
int cmp(const void*i,const void*j){
  return a[*(ll*)j] - a[*(ll*)i];
}
int main(){
  ll i,x,y, ans;
  bool moved[2020] = {false,};
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld",a+i);
    p[i] = i;
  }
  qsort(p,n,sizeof(ll),cmp);
  //for(i=0;i<n;i++){
  //  printf("p : %lld\n",p[i]);
  //}
  dp[0][0] = 0;
  for(i=0;i<n;i++){
    for(x=0;x<=i;x++){
      y = i-x;
      dp[x+1][y] = max(dp[x+1][y], dp[x][y] + a[p[i]]*abs(x-p[i])); 
      dp[x][y+1] = max(dp[x][y+1], dp[x][y] + a[p[i]]*abs(n-1-y-p[i]));
    }
  }
  ans = 0;
  for(x=0;x<=n;x++){
    y = n-x;
    //printf("[%lld][%lld] = %lld\n",x,y,dp[x][y]);
    ans = max(ans,dp[x][y]);
  }
  printf("%lld",ans);
}

Measured memory_bytes: 24456
#include <bits/stdc++.h>
#include "atcoder/all"
typedef long long int ll;
using namespace std;
using namespace atcoder;
#define mod 998244353
int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> a;
    vector<ll> b;
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        a.push_back(x);
    }
    for (int i = 0; i < m; i++) {
        ll y;
        cin >> y;
        b.push_back(y);
    }
    vector<ll> c = convolution<mod>(a, b);
    for (int i = 0; i < c.size(); i++) {
        cout << c[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 27380
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int ans = H2 * 60 + M2 - (H1 * 60 + M1) - K;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) ll(x.size())
using namespace std;

int main() {
  ll n,ans=0;
  cin >> n;
  vector<ll>d(n);
  rep(i,n) cin >> d.at(i);
  rep(i,n){
  	for(ll j=i+1; j<n; j++) ans+=d.at(i)*d.at(j);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include <cmath>
#include<cctype>
using namespace std;

int main()
{
	while (1){
		char ch;
		scanf("%c", &ch);
			if (isalpha(ch)){
				if (isupper(ch)) printf( "%c",  tolower(ch));
				else printf("%c", toupper(ch));
			}
			else printf("%c" ,ch);
			if(ch == '\n')break;
		}
	
	return 0;
}




Measured memory_bytes: 3096
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
    Node *cur = nil->next;
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while(1){
        if(cur == nil) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t){
    if(t == nil){
        return;
    }
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
    int key,n,i;
    int size = 0;
    char com[20];
    int np=0,nd=0;
    scanf("%d",&n);
    init();
    for (i=0;i<n;i++){
        scanf("%s%d",com,&key);
        if(com[0] == 'i'){
            insert(key);
            np++;
            size++;
        }
        else if (com[0] == 'd'){
            if(strlen(com)>6){
                if (com[6]=='F'){
                    deleteFirst();
                }
                else if (com[6] == 'L'){
                    deleteLast();
                }
            }
            else{
                    deleteKey(key);nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
}

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

using namespace std;
using i64 = int64_t;

signed main(){
    
    int c, n;
    cin >> c >> n;
    vector<vector<int>> a(n, vector<int>(n));
    for(auto& x : a){
        string s;
        cin >> s;
        for(int i = 0; i < n; ++i)
            x[i] = (s[i] == '1');
    }
        
    auto f = [&](int i, int j){
        return !(
            a[i][j] == a[i][n - 1 - j] &&
            a[i][j] == a[n - 1 - i][j] &&
            a[i][j] == a[n - 1 - i][n - 1 - j]);
    };
    
    int cnt = 0;
    int m = n >> 1;
    for(int i = 0; i < m; ++i)
        for(int j = 0; j < m; ++j)
            if(f(i, j))
                ++cnt;
    
    int ans = (cnt == 0);
    for(int _ = 0; _ < c - 1; ++_){
        int d;
        cin >> d;
        for(int i = 0; i < d; ++i){
            int x, y;
            cin >> x >> y;
            --x, --y;
            int bef = f(x, y);
            a[x][y] ^= 1;
            int aft = f(x, y);
            cnt += aft - bef;
        }
        ans += (cnt == 0);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 6872
// Author: πα

#include <bits/stdc++.h>
using namespace std;
#define long int64_t
const int MOD = 1000000007;

const int N = 1e5 + 5;
vector<int> g[N];
bool vis[N];
int dp[N];

void dfs(int u)
{
    if(vis[u])
        return;
    vis[u] = 1;
    int k = 2;
    for(auto v : g[u])
        if(not vis[v])
            dp[v] = k++, dfs(v);
}

int main()
{
    int n, i, k, u, v;
    cin >> n >> k;
    for(i = 1; i < n; ++i)
        cin >> u >> v, g[u].push_back(v), g[v].push_back(u);
    dfs(1);
    dp[1] = 0;
    for(auto v : g[1])
        dp[v]--;
    long ans = 1;
    for(int i = 1; i <= n; ++i)
        ans *= (k - dp[i]), ans %= MOD;
    cout << ans;
    return 0;
}


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

long long int N, K, b, i, r, m, n, a[20];
vector<bool> f;

int main(){
    scanf("%lld%lld", &N, &K);
    for(i = 0; i < N; ++i){
        scanf("%lld", a + i);
        f.push_back(i < K);
    }
    n = 1145141919810LL;
    do{
        r = 0;
        m = *a;
        for(i = 1; i < N; ++i){
            if(m >= a[i]){
                if(f[i]){
                    r += m - a[i] + 1;
                    ++m;
                }
            }else{
                m = a[i];
            }
        }
        n = min(r, n);
    }while(prev_permutation(f.begin(), f.end()));
    cout << n << endl;
    return 0;
}


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

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

const int INF = 1000000007;

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

	if(n % k == 0) printf("0\n");
	else printf("1\n");

	return 0;
}

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

int main() {
  int N, S, H, J, I, x, y;
  cin >> N;

  S = N / 1000;
  N = N % 1000;
  H = N / 100;
  N = N % 100;
  J = N / 10;
  N = N % 10;
  I = N / 1;
  if(((S == H) && (H == J))|| ((H == J) && (J == I))){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

template<typename A, size_t N, typename T>
void array_fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    vector<int> nums(5);
    rep(i, 5) cin >> nums[i];
    sort(all(nums));

    int big_ans = INF, n_time = 0;
    do{
        int ans = 0;
        rep(i, 5){
            if(ans % 10 == 0){
                ans += nums[i];
            }else{
                ans = (ans / 10 + 1) * 10;
                ans += nums[i];
            }
        }
        big_ans = min(ans, big_ans);
    }while(next_permutation(all(nums)));

    cout << big_ans << endl;
}

Measured memory_bytes: 256
N=int(input())
tuple=input()
list=tuple.split()
list_int=[int(i) for i in list]
list=sorted(list_int)
Alice_Score=0
Bob_Score=0
for num in list[-1::-2]:
    Alice_Score+=num
for num in list[-2::-2]:
    Bob_Score+=num
difference=Alice_Score-Bob_Score
print(difference)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int q; cin >> q;
    priority_queue<int> q1;
    priority_queue<int,vector<int>,greater<int>> q2;
    q1.push(-INF);
    q2.push(INF);
    ll sum = 0;
    ll q1_sum = 0;
    ll q2_sum = 0;
    while(q--) {
        int t; cin >> t;
        if(t == 1) {
            int a,b; cin >> a >> b;
            sum += b;
            int n = q1.size();
            int m = q2.size();
            int u = q1.top();
            int v = q2.top();
            if(n == m){
                if(a < u){
                    q1_sum += a;
                    q1.push(a);
                }else{
                    q2_sum += a;
                    q2.push(a);
                }
            }
            else if(n < m){
                if(a < v){
                    q1_sum += a;
                    q1.push(a);
                }else{
                    q2.pop();
                    q1.push(v);
                    q2.push(a);
                    q1_sum += v;
                    q2_sum += a-v;
                }
            }
            else{
                if(a > u){
                    q2.push(a);
                    q2_sum += a;
                }else{
                    q1.pop();
                    q2.push(u);
                    q1.push(a);
                    q1_sum += a-u;
                    q2_sum += u;
                }
            }
        }else{
            int n = q1.size();
            int m = q2.size();
            int x = 0;
            ll ans = 0;
            if(n >= m){
                x = q1.top();
                ans = (ll)x*(n-1)-q1_sum+q2_sum-(ll)x*(m-1)+sum;
            }else{
                x = q2.top();
                ans = (ll)x*(n-1)-q1_sum+q2_sum-(ll)x*(m-1)+sum;
            }
            cout << x << " " << ans << endl;
        }
    }
}



Measured memory_bytes: 4140
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	unsigned long long cntPerson, cntLife;
	cin >> cntPerson >> cntLife;

	unsigned long long cnt = 0;
	unsigned long long start, end;
	cin >> start;
	end = start + cntLife - 1;

	unsigned long long next;
	for(int i=1; i<cntPerson; i++)
	{
		cin >> next;

		if(next <= end)
			cnt += next - start;
		else
			cnt += cntLife;

		start = next;
		end = start + cntLife - 1;
	}

	cout << cnt+cntLife << endl;

	return 0;
}


Measured memory_bytes: 256
const bool TEST=1;
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
#include<sstream>
#include<stack>
const int inf=0x7fffffff;
#define IF if(TEST)
#define FI if(!TEST)
#define gts(s) fgets((s),sizeof(s),stdin)
#define ALL(s) (s).begin(),(s).end()
#define MK(a,b) make_pair((a),(b))
typedef long long int LL;
typedef unsigned int U;
typedef unsigned long long ULL;
using namespace std;
typedef pair<int,int> Point;
template <typename T>
void pA(T *begin,int n){ for(int i=0;i<n;i++){ cout<<*(begin++); } printf("\n"); }
ostream&  operator << (ostream &out,const Point &a){ out<<'('<<a.first<<','<<a.second<<')'; return out; }
const int M=1e5;
void sol(){
	int x,i;
	scanf("%d",&x);
	LL xx=x;
	xx*=2;
	LL sum = 0 ;
	for(i =1;i<M;i++){
		sum+=i;
		if(sum>=x)break;
	}
	printf("%d", i);
}
int main()
{
	sol();
	return 0;
}
//C.cc
//generated automatically at Sat Mar 18 20:05:30 2017
//by xsthunder


Measured memory_bytes: 256
s=list(input())
c=len(s)+10
n=len(s)
f=-len(s)
for i in range(len(s)):
    if s[n-1-i]=='F':
        f=n-1-i
        break
for i in range(n):
    if s[i]=="C":
        c=i
        break
if c<f:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>

using namespace std;
int N, K;
int a[5000];

bool is_needed(int i){

   if(a[i]>=K) return true;

   int memo[N+1][K];
   for(int j=0; j<N+1; j++)for(int k=0; k<K; k++) memo[j][k]=0;
   memo[0][0]=1;
   for(int j=0; j<N; j++){
      for(int k=0; k<K; k++){
         memo[j+1][k]|=memo[j][k];
         if(i!=j and k+a[j]<K) memo[j+1][k+a[j]]|=memo[j][k];
      }
   }
   bool need=false;
   for(int k=K-a[i]; k<K; k++) need|=memo[N][k];

   return need;
}

int main(){

   cin>> N>> K;
   for(int i=0; i<N; i++) cin>> a[i];

   sort(a, a+N);
   int l=-1, u=N;
   while(u-l>1){
      int m=(u+l)/2;
      if(is_needed(m)) u=m;
      else l=m;
   }

   cout<< l+1<< endl;

   return 0;
}


Measured memory_bytes: 97920
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int N=8;
int borad[N][N];
int r[N],c[N]={0},pd[2*N-1]={0},nd[2*N-1]={0};
void dfs(int x){
	if(x==N){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if(j==r[i]) printf("Q");
				else printf(".");
			}
			printf("\n");
		}
		return;
	}
	if(r[x]!=-1) dfs(x+1);
	else {
		for(int y=0;y<N;y++){
			if(c[y]==0 && pd[x+y]==0 && nd[x-y+N-1]==0){
				r[x]=y;c[y]=1;pd[x+y]=1;nd[x-y+N-1]=1;
				dfs(x+1);
				r[x]=-1;c[y]=0;pd[x+y]=0;nd[x-y+N-1]=0;
			}
		}
	}
}
int main(){
	int k;scanf("%d",&k);
	int x,y;
	memset(r,-1,sizeof(r));
	for(int i=0;i<k;i++){
		scanf("%d%d",&x,&y);
		r[x]=y;c[y]=1;pd[x+y]=1;nd[x-y+N-1]=1;
	}
	dfs(0);
	return 0;
}
/*
2
2 2
5 3
*/


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

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

  long long a, b, x;
  cin >> a >> b >> x;

  cout << (b < 0 ? 0 : (b / x) + 1) - (a - 1 < 0 ? 0 : ((a- 1) / x) + 1) << endl;
  return 0;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
	long long n,m;
	std::cin >> n >> m;
	if (n == 1 && m == 1) {
		std::cout << 1 << '\n';
		return 0;
	}
	if (n == 1) {
		std::cout << m-2 << '\n';
		return 0;
	}
	if (m == 1) {
		std::cout << n-2 << '\n';
		return 0;
	}
	std::cout << (n-2) * (m-2) << '\n';
	return 0;
}


Measured memory_bytes: 256
from itertools import permutations, combinations,combinations_with_replacement,product
n,m=map(int, input().split())

a=[list(map(int, input().split())) for i in range(m)]
p=list(map(int, input().split()))
count=0
for sw in product([0,1],repeat=n):
    flag=1
    for i in range(m):
        on=0
        for j in range(a[i][0]):
            on+=sw[a[i][j+1]-1]
        
        if on%2!=p[i]:
            flag=0
        #print(on,sw,p[i],flag, on%2!=p[i])
    count+=flag
print(count)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int n,m,sum;
int a[105];
int main()
{
    cin >> n;
    for(int i=1;i<=n;i++)
	{
        cin >> a[i];
        sum+=a[i];
    }
    cin >> m;
    while(m--)
	{
        int x,y;
        cin >> x >> y;
        cout << sum-a[x]+y << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<stack>
#include<iostream>
#include<algorithm>
#define MAX 1400
using namespace std;

struct Rectangle { int height; int pos; };

int getLargestRectangle(int size,int buffer[]){
    stack<Rectangle> S;
    int maxv=0;
    //???????????????????????¢?????????
    //????????¨??°???DP??§??????????????°getLargestRectangle?????¢????¢???????
    //????????¨??°?????´???????????´??§,????????????????????????,???????±?????????§???.
    buffer[size]=0;

    for(int i=0;i<=size;++i){
        Rectangle rect;
        rect.height=buffer[i];
        rect.pos=i;
        if(S.empty()){
            S.push(rect);
        }else{
            if(S.top().height < rect.height){
                S.push(rect);
            }else if(S.top().height > rect.height){
                int target=i;
                while(!S.empty() && S.top().height >= rect.height){
                    Rectangle pre=S.top();S.pop();
                    int area=pre.height*(i-pre.pos);
                    maxv=max(maxv,area);
                    target=pre.pos;
                }
                rect.pos=target;
                S.push(rect);
            }
        }
    }
    //printf("\nmaxv: %d\n",maxv);
    return maxv;
}

int H,W;
int buffer[MAX][MAX];
int T[MAX][MAX];

int getLargestRectangle(){
    //?¢?????????????????????????????????????????¢??±??????°????????????
    for(int j=0;j<W;++j){
        for(int i=0;i<H;++i){
            if(buffer[i][j]){
                T[i][j]=0;
            }else{
                T[i][j]=(i>0)?T[i-1][j]+1:1;
            }
        }
    }
    /*
    ???:
        0 0 1 0 0
        1 0 0 0 0
        0 0 0 1 0
        0 0 0 1 0

    After:
        1 1 0 1 1
        0 2 1 2 2
        1 3 2 0 3
        2 4 3 0 4
    */
    int maxv=0;
    //?????\????????? W,?????°,?????????T[i]?¬¬i???????????°???
    for(int i=0;i<H;++i){
        maxv=max(maxv,getLargestRectangle(W,T[i]));
    }

    return maxv;
}

int main(){
    scanf("%d %d",&H,&W);
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            scanf("%d",&buffer[i][j]);
        }
    }

    printf("%d\n",getLargestRectangle());
    return 0;
}

Measured memory_bytes: 18516
#include <iostream>

using namespace std;

int main(void) {

    int n; // input val
    cin >> n;   // get input 

    if (90 <= n && n < 100) {
        string ans("Yes");   
        cout << ans << endl;
    } else if ( n % 10 == 9 ) {
        string ans("Yes");   
        cout << ans << endl;
    } else {
        string ans("No");   
        cout << ans << endl;    
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,m=map(int,input().split())
a=[]
b=[]
for _ in [0]*m:
    l=list(map(int,input().split()))
    if l[0]==1:a.append(l[1])
    if l[1]==n:b.append(l[0])
print('POSSIBLE' if set(a)&set(b) else 'IMPOSSIBLE')

Measured memory_bytes: 21788
a,b,c,k=map(int,input().split())
ans=0
if(a>=k):
    ans+=k
  #print(k)
elif(a<k):
    ans+=a
    if(k-a<=b):
        ans+=(k-a)*0
    elif(k-a>b):
        ans+=b*0
        ans-=k-a-b
    #print(ans)
print(ans)


Measured memory_bytes: 9180
#include <iostream>

using namespace std;

int main(void)
{
  int m, f, r;
  while(1){
    cin >> m >> f >> r;
    if(m ==-1&&f==-1&&r==-1) break;
    if(m==-1 || f==-1){
      cout << "F";
    }else if(m+f >= 80){
      cout << "A";
    }else if(m+f < 80 && m+f >= 65){
      cout << "B";
    }else if(m+f < 65 && m+f >= 50){
      cout << "C";
    }else if(m+f < 50 && m+f >= 30){
      if(r >= 50){
	cout << "C";
      }else{
	cout << "D";
	  }

    }else if(m+f < 30){
      cout << "F";
    }
    cout << endl;
  }
}

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

int main() {
    //変数定義, 入力処理
    // vector<vector<int>> data(3, vector<int>(4)); //二次元配列
    int N;
    cin >> N;
    vector<int> members(N, 0);
    //処理
    rep(i, N-1) {
        int A;
        cin >> A;
        members.at(A - 1) += 1;
    }
    rep(i, N) {
        cout << members.at(i) << endl;
    }
    //出力処理
    return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int ans=0;
  rep(i,0,n-1){
    if(s[i]!=s[i+1]){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
//パラメータ値の最大公約数を求める式
function gcd(a, b) {
  if (b === 0){
    return a
  }
  return gcd(b, a % b)
}
function getDivisorList(n) {
  var divisorlist = [];
  var flg = 0;
  //約数の一覧を求める
  for ( var i = 1 ; i <= Math.floor(n/2) ; i++ ){
  	if ( n%i == 0) {
      //配列に登録していく
      divisorlist.push(i);
    }
  }
  //引数の値自体を配列の最後に登録する
  divisorlist.push(n);
  return divisorlist;
}
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var A = Number.parseInt(inputStr[0]);
  var B = Number.parseInt(inputStr[1]);
  var K = Number.parseInt(inputStr[2]);
  //AとBの最大公約数=gcdを求める
  var gcdval = gcd(A,B);
  //gcdの約数一覧を求める
  var results = getDivisorList(gcdval);
  //約数一覧の内、最大からK番目の値を求める。
  console.log(results[results.length - K]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
import numpy as np
n, k, q = map(int, input().split())
A = np.array([int(input()) - 1 for _ in range(q)])
score = np.zeros(n)
for i in A:
    score[i] += 1
score = k + score - q
print(*np.where(score > 0, 'Yes', 'No'), sep='\n')


Measured memory_bytes: 41640
N = int(input())
W = list(map(int, input().split()))
S1=0
S2=sum(W)
d=10001
for i in W:
        S1+=i
        S2-=i
        if abs(S1-S2)<d:
                d=abs(S1-S2)
        else:
                break
print(d)

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

using namespace std;

const int MAX_HORIZONTAL = 30;
const int MAX_VERTICAL = 30;

int main(){

	int VerticalLines;
	int HorizontalLines;
	int HorizonA[MAX_HORIZONTAL];
	int HorizonB[MAX_HORIZONTAL];
	int Results[MAX_VERTICAL];



	cin >> VerticalLines;
	cin >> HorizontalLines;
	for (int i = 0; i < HorizontalLines; ++i){ char c[32];  scanf("%d,%d", &HorizonA[i], &HorizonB[i]); }

	for (int i = 0; i < VerticalLines; ++i){ Results[i] = i + 1; }

	

	for (int i = 0; i < HorizontalLines; ++i){
		int Swap = Results[HorizonA[i] - 1];
		Results[HorizonA[i]-1] = Results[HorizonB[i] - 1];
		Results[HorizonB[i] - 1] = Swap;
	}

	
	for (int i = 0; i < VerticalLines; ++i){
		cout << Results[i] << endl;
	}





	return 0;
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------

int main(void) {
  ll a;
  string b;
  cin >> a >> b;

  ll seisu=b[0]-'0';
  ll shosu=(b[2]-'0')*10+(b[3]-'0');
  ll ans=a*seisu+(a*shosu)/100;

  prt(ans);


}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 810;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m,K;

char st[maxn][maxn];

int d[maxn][maxn];

queue<PII> Q;

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

void Work(){
	REP(i,1,n)REP(j,1,m)d[i][j]=K+1;
	REP(i,1,n)REP(j,1,m)if(st[i][j]=='S'){
		d[i][j]=0;
		Q.push(MP(i,j));
	}
	while(!Q.empty()){
		int x=Q.front().fi,y=Q.front().se;Q.pop();
		REP(k,0,3){
			int tx=x+dx[k],ty=y+dy[k];
			if(st[tx][ty]!='.')continue;
			if(d[tx][ty]>d[x][y]+1){
				d[tx][ty]=d[x][y]+1;
				Q.push(MP(tx,ty));
			}
		}
	}
	int ans=n+m;
	REP(i,1,n)REP(j,1,m)if(d[i][j]<=K){
		int x=min(min(i-1,j-1),min(n-i,m-j));
		ans=min(ans,(x+K-1)/K+1);
	}
	iout(ans);
}

void Init(){
	read(n,m,K);
	REP(i,1,n)scanf("%s",st[i]+1);
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>
#include <map>

using namespace std;

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

  vector<int> H(N,0);
  
  for (int n=0; n<N; ++n) {
    cin >> H[n];
  }

  multimap<int, int> X;
  vector<bool> canBeGood(N,true);
  
  for (int m=0; m<M; ++m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    X.emplace(a,b);
    X.emplace(b,a);
  }

  int ans = 0;

  for (int n=0; n<N; ++n) {
    auto er = X.equal_range(n);

    bool good = canBeGood[n];

    int ha = H[n];

    for (auto it = er.first; true && it!= er.second; ++it) {
      int b = it->second;
      int hb = H[b];
      if (hb >= ha) {
	good = false;
      }

      if (ha > hb)
	canBeGood[b] = false;
    }

    if (good) {
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13028
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, t;
    cin >> a >> b >> c;

    if(a > b)
    {
     t = a;
     a = b;
     b = t;   
    }

    if(b > c)
    {t = b;
     b = c;
     c = t;
    }

if(a > b)
    {
     t = a;
     a = b;
     b = t;   
    }


    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3120
N = int(input())
hn = list(map(int,input().split()))
dp = [10 ** 10] * (N)
dp[0] = 0
dp[1] = abs(hn[0]-hn[1])
for i in range(N-2):
    dp[i+2] = min(dp[i+1] + abs(hn[i+2]-hn[i+1]) ,dp[i] + abs(hn[i]-hn[i+2] ))

print(dp[-1])

Measured memory_bytes: 13924
MODE = "stdio"
require 'matrix'
include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '1 2 3 4 5 6
  3
  6 5
  1 3
  3 2'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end
class Dice
  attr_accessor :top, :front, :right, :left, :back, :bottom
  def initialize(arr)
    @top = arr[0]
    @front = arr[1]
    @right = arr[2]
    @left = arr[3]
    @back = arr[4]
    @bottom = arr[5]
  end

  def roll(s)
    case s
    when "E"
      @top, @right, @bottom, @left = @left,@top, @right, @bottom
    when "W"
      @top, @right, @bottom, @left = @right, @bottom, @left, @top
    when "N"
      @top, @back , @bottom, @front = @front,@top, @back , @bottom
    when "S"
      @top, @back , @bottom, @front = @back , @bottom, @front,@top
    end
    [@top, @front, @right, @left, @back, @bottom]
  end

  def rolls(s)
    s.chars.each do|s|
      roll(s)
    end
    [@top, @front, @right, @left, @back, @bottom]
  end

end

arr = line[0].split(" ").map(&:to_i)
num = line[1].to_i
cmd = ["E","W","N","S"]
  
dice = Dice.new(arr)
(2..num+1).each do |n|
  top,front = line[n].split(" ").map(&:to_i)
  while true
    dice.roll(cmd.sample)
    break if(dice.top == top) && (dice.front == front)
  end
  puts dice.right
end

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] str = sc.next().toCharArray();
        sc.close();
        if(str[2]==str[3] && str[4]==str[5]) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n;cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,n){
        if(i&1) sum -= a[i];
        else sum += a[i];
    }
    ll A = sum>>1;
    vl ans(n,0);
    ans[0] = A<<1;
    for(int i=1;i<n;i++){
        ans[i] = ((a[i-1]-(ans[i-1]>>1))<<1);
    }
    rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 2944
N=int(input())
S=str(input())
ans = S.count("R")*S.count("G")*S.count("B")
#print(ans)
for i in range(N-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        #print(i,j,k)
        if k <= N-1:
            if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
                ans -= 1
print(ans)


Measured memory_bytes: 73624