akhauriyash/Code-Regression huggingface dataset:
// 2020-08-29 17:20:16
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, ll>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
const int V = 210;
const ll inf = 1e12;
ll d[V][V];
void answer() {
  int n, m, rz;
  cin >> n >> m >> rz;
  vector<int> r(rz);
  rep(i, rz) {
    cin >> r[i];
    r[i]--;
  }
  rep(i, n) rep(j, n) {
    d[i][j] = inf;
    if (i == j) d[i][j] = 0;
  }
  rep(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  rep(k, n) rep(i, n) rep(j, n) { chmin(d[i][j], d[i][k] + d[k][j]); }
  ll ans = inf;
  sort(ALL(r));
  do {
    ll now = 0;
    rep(i, rz - 1) now += d[r[i]][r[i + 1]];
    chmin(ans, now);
  } while (next_permutation(ALL(r)));
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3936
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
template<int mod>
struct ModInt {
    using ll = long long; ll x;
    ModInt() : x(0) {}
    ModInt(int y) : x(y >= 0 ? ll(y % mod) : (ll)((mod - (-y) % mod))) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) { if((x += rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &rhs) { if((x += mod - rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &rhs) { x = x * rhs.x % mod; return *this; }
    ModInt &operator/=(const ModInt &rhs) { *this *= rhs.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.x; }
    friend istream &operator>>(istream &is, ModInt &rhs) { ll t; is >> t; rhs = ModInt<mod> (t); return (is); }
private:
    ModInt inverse() const { ll a = x, u = 1LL, v = 0LL, t, b = (ll)mod; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return  ModInt(u); }
};
using mint = ModInt<MOD>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<string> W(N);
    unordered_map<string, bool> used;
    string ans = "Yes";
    rep(i, N){
        string w;
        cin >> w;
        W[i] = w;
        if(i == 0){
            used[w] = true;
            continue;
        }
        if(used[w]) ans = "No";
        if(*(W[i-1].end()-1) != w[0]) ans = "No";
        used[w] = true;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
	string S[200];
	int x, y;
	cin >> y >> x;
	for (int i = 0; i < y; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < y + 2; i++) {
		if (i == 0 || i == y + 1) {
			for (int j = 0; j < x + 1; j++)cout << "#";
			cout << "#\n";
		}
		else {
			cout << "#";
			cout << S[i-1];
			cout << "#\n";
		}
	}
	cin >> x;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    int N;
    string S;
    cin>>N>>S;
    int flag=0, count=0;
    rep(i, N){
        if(S[i]=='A') flag=1;
        else if(S[i]=='B' && flag==1) flag++;
        else if(S[i]=='C' && flag==2) flag++;
        else flag=0;
        //cout<<flag<<endl;
        if(flag==3){
            count++;
            flag=0;
        }
    }
    cout<<count<<endl;
    return 0;
}


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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    RPT0(i, M) cin >> A[i];

    int total = 0;
    RPT0(i, M) total += A[i];

    int ans = (total > N) ? -1 : N - total;
    cout << ans << endl;
}

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


Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <vector>

#define rep(i,min,max) for(int i=min;i<max;i++)
#define rrep(i,min,max) for(int i=max;i>=min;i--)

using namespace std;

int main(){
  long long n;
  long long amin, tmp;
  cin >> n;
  cin >> amin;
  rep(i,1,5){
    cin >> tmp;
    amin = amin < tmp?amin:tmp;
  }
  long long ans = n/amin + 4;
  ans += n%amin != 0?1:0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  	public static void main(String[] args) {
      	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	if(a * b < c){
          System.out.println(a* b);
        } else {
          System.out.println(c);
        }
    }
}

Measured memory_bytes: 21844
# coding:utf-8


def main():
    X, Y = map(int, input().split())

    m = (Y-2*X)

    if (m >= 0 and m % 2 == 0 and (2*X - m) >= 0 and (2*X - m) % 2 == 0):
        print("Yes")
    else:
        print("No")

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 61676
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void){
    int N, A;
    double T;
    cin >> N;
    cin >> T >> A;
    double H[N];
    double temp[N];
    double re = 1000.000;
    int ans;


    for(int i = 0; i < N; i++){
        cin >> H[i];
        temp[i] = T - H[i]*0.006;
        if(re > min(re, abs(A-temp[i]))){
            ans = i+1;
            re = min(re, abs(A-temp[i]));
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll inf=1e18;
const ll mod=1e9+7;
const ll maxn=1e5;
bool srts(const pair<ll,ll> &a, 
              const pair<ll,ll> &b) 
{ 
    //if(a.second==b.second)return a.first>b.first;
    if(a.first==b.first)return a.second>b.second;
    return (a.first > b.first); 
}
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll>>v;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        v.push_back({x,y});
    }
    sort(v.begin(),v.end());
    ll ans=0;
    //for(int i=0;i<n;i++)cout<<v[i].first<<" "<<v[i].second<<"\n";
    priority_queue<ll>pq;
ll x=0;
    for(int i=1;i<=m;i++){
        while(  x<n and v[x].first<=i){
            pq.push(v[x].second);
            x++;
        }
        if(pq.size()){
            ans+=pq.top();
            pq.pop();
        }
    }
cout<<ans<<"\n";

    return 0;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
int n,q;

vector<int>graph[200200];
// bool graph[200200][200200];
vector<ll>tmp(200200);
 
void dfs(int v, int p){
	for (auto i : graph[v]){
		if(i == p) continue;
		tmp[i] += tmp[v];
		dfs(i, v);
	}
	//  for(int i = 1; i < n+1; i++){
	// 	 if(i == p) continue;
	// 	 if(graph[v][i]){
	// 		 tmp[i] += tmp[v];
	// 		 dfs(i, v);
	// 	 }
	//  }
 }

int main(){
	cin >> n >> q;
	int a,b;
	for(int i = 1; i < n; i++){
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
		// graph[a][b] = true;
		// graph[b][a] = true;
	}
	int p,x;
	for(int i = 0; i < q; i++){
		cin >> p >> x;
		tmp[p] += x;
	}
	dfs(1,0);
	for(int i = 1; i < n + 1; i++){
		cout << tmp[i] << " ";
	}

	return 0;
}


Measured memory_bytes: 24320
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;
#define LOCAL
const ll MX = 1e18;

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


Measured memory_bytes: 3584
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int state[100] = {};
    for(int i=A; i<B; i++) state[i]++;
    for(int i=C; i<D; i++) state[i]++;
    int ans = 0;
    for(int i=0; i<100; i++) if(state[i] == 2) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)

using namespace std;

int main(){
  int n;
  vector<int> h(501), tmp(501);
  while(scanf("%d", &n) && n){
    rep(i, n + 1) scanf("%d", &h[i]);
    rep(i, n + 1){
      int p = 0;
      rep(j, n + 1){
	if(j == i) continue;
	tmp[p++] = h[j];
      }

      bool judge = true;
      for(int j = 1; j < n - 1; ++j)
	if(tmp[j + 1] - tmp[j] != tmp[j] - tmp[j - 1]) judge = false;
      if(judge){
	printf("%d\n", h[i]);
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1036
package main

import (
	"fmt"
)

// go run ./main.go < in

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

	m := make(map[int]int)
	for i := 0; i < n; i++ {
		var num int
		fmt.Scan(&num)
		m[num] = num
	}

	var inputs []int
	for _, v := range m {
		inputs = append(inputs, v)
	}
	fmt.Println(len(inputs))
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a = 0; 
	while(n > 0){
		a += n % 10;
		n /= 10;
	}
	if(a == 1){
		a = 10;
	}
	cout << a;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.let(String::toInt)
    var an = readLine()!!.split(" ").map(String::toInt)

    var count = 0

    an.forEach {
        var n = it
        while (n % 2 == 0) {
            n /= 2
            count++
        }
    }
    println(count)
}

Measured memory_bytes: 39980
#include<iostream>
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define endl "\n"
#define MOD 1000000007
#define DEB(x) cout<<"##"<<x<<"##"<<endl;
void myfunc(int a,int b,int c,int d)
{
    int a1=min(a,b);
    int b1=max(a,b);
    int c1=min(c,d);
    int d1=max(c,d);
    if (b1>=c1)
    {
        cout<<"Yes";
        return;
    }
    else
        c1-=b1;
    if(d1>=a1)
    {
        cout<<"No";
        return;
    }
}
void solve()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    myfunc(a,b,c,d);
    cout<<endl;
}
void solve1()
{
    int n;
    cin>>n;  
    string q;
    set<string>sl;
    for(int i=0;i<n;i++)
    {
        cin>>q;
        sl.insert(q);
        
    }
    cout<<sl.size();

}

int main() 
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    solve1();
}


Measured memory_bytes: 19136
#include <bits/stdc++.h>
 
#define pb push_back
#define mp make_pair
 
#define all(x) (x).begin(), (x).end()
 
#define fi first
#define se second
 
using namespace std;
 
typedef long long ll;
 
const int MAXN = (int)1e5 + 5;
 
struct que {
    int v, d, col;
 
    que() {
        v = d = col = 0;
    }
} req[MAXN];
 
vector<int> adj[MAXN];
 
int col[MAXN];
 
int lim[MAXN];
 
int u[MAXN];
 
int n, m, q;
 
int timer;
 
int main(){
    scanf("%d %d", &n, &m);
 
    for (int i = 1; i <= n; ++i) {
        lim[i] = -1;
        col[i] = 0;
        u[i] = 0;
    }
 
    for (int i = 1, u, v; i <= m; ++i) {
        scanf("%d %d", &u, &v);
        adj[u].pb(v);
        adj[v].pb(u);
    }
 
    scanf("%d", &q);
 
    for (int i = 1; i <= q; ++i) {
        scanf("%d %d %d", &req[i].v, &req[i].d, &req[i].col);
    }
 
    queue<pair<int, int> > Q;
 
    for (int i = q; i > 0; --i) {
        Q.push(mp(req[i].v, req[i].d));
        ++timer;
 				
        while (!Q.empty()) {
            int v = Q.front().fi;
            int d = Q.front().se;
 
            Q.pop();
 
            u[v] = timer;
 
            if (d <= lim[v]) {
                continue;
            }
 
            if (!col[v]) {
                col[v] = req[i].col;
            }
 
            lim[v] = d;
 
            for (int to : adj[v]) {
                if (u[to] != timer) {
                    Q.push(mp(to, d - 1));
                }
            }
        }
    }
 
    for (int i = 1; i <= n; ++i) {
        printf("%d\n", col[i]);
    }
	return 0;
}

Measured memory_bytes: 9384
import java.util.ArrayDeque;
import java.util.Iterator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            final String s  = sc.next();
            final int q = sc.nextInt();

            ArrayDeque <String> deque = new ArrayDeque<>(300000);
            boolean reversed = false;

            deque.add(s);
            for (int i=0; i<q; i++) {
                int t = sc.nextInt();
                if (t == 1) {
                    reversed = !reversed;

                } else {
                    int f = sc.nextInt();
                    String c = sc.next();
                    if (f == 1) {
                        if (!reversed) {
                            deque.addFirst(c);
                        } else {
                            deque.addLast(c);
                        }
                    } else {
                        if (!reversed) {
                            deque.addLast(c);
                        } else {
                            deque.addFirst(c);
                        }
                    }
                }
            }

            if (!reversed) {
                Iterator<String> it = deque.iterator();
                while(it.hasNext()) {
                    System.out.print(it.next());
                }
            } else {
                Iterator<String> it = deque.descendingIterator();
                while(it.hasNext()) {
                    String next = it.next();
                    if (next.length() == 1) {
                        System.out.print(next);
                    } else {
                        StringBuilder sb = new StringBuilder(next);
                        sb.reverse();
                        System.out.print(sb);
                    }
                }
            }

            System.out.println();

        } finally {
            sc.close();
        }
    }
}


Measured memory_bytes: 167424
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
	
	public class Main {
	
		public static void main(String[] args) {
			execute16_3();
		}
		
		private static void execute16_3() {
			try 
			(Scanner sc = new Scanner(System.in)) {
				String s = sc.next();
				String t = sc.next();
			
			int ans=0;
			
			for(int i=0; i<s.length(); i++) {
				if(s.charAt(i)!=t.charAt(i)) {
					ans++;
				}
			}
			System.out.println(ans);
			}
			
		}
    }

Measured memory_bytes: 32040
#include <algorithm>  //min, max, sort, unique, fill
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;
using VB = vector<bool>;
using VP = vector<P>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

int main() {
  ll n;
  cin >> n;
  VI a(n + 2, 0);
  REP(i, n) cin >> a[i + 1];
  ll sum = 0;
  REP(i, n + 1) sum += abs(a[i + 1] - a[i]);
  VI save(n + 1, 0);
  REP(i, n)
  save[i + 1] =
      abs(a[i + 1] - a[i]) + abs(a[i + 2] - a[i + 1]) - abs(a[i + 2] - a[i]);

  REP(i, n) cout << sum - save[i + 1] << endl;

  return 0;
}


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

int main() {
  long long n; cin>>n;
  long long ans = 0;

  if (n % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  for (long long i = 10; i <= 1e18; i *= 5) {
    long long x = n / i;
    ans += x;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
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; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

ll X, Y, Z, K;
vll A, B, C, AB, ABC;

int main() {
	cin >> X >> Y >> Z >> K;
	A.resize(X);
	B.resize(Y);
	C.resize(Z);
	rep(i, X) cin >> A[i];
	rep(i, Y) cin >> B[i];
	rep(i, Z) cin >> C[i];

	sort(all(A), greater<ll>());
	sort(all(B), greater<ll>());

	AB.reserve(2 * K);
	rep(i, X) {
		rep(j, Y) {
			AB.emplace_back(A[i] + B[j]);
		}
	}

	sort(all(AB), greater<ll>());
	sort(all(C), greater<ll>());

	ABC.reserve(2 * K);
	rep(i, K) {
		rep(j, min(Z, K)) {
			ABC.emplace_back(AB[i] + C[j]);
		}
	}

	sort(all(ABC), greater<ll>());
	rep(i, K) write(ABC[i]);
}

Measured memory_bytes: 35216
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> a(N),b(N),c(N),d(N);
	rep(i,N)cin >> a[i] >> b[i];
	rep(i,N)cin >> c[i] >> d[i];
	vector<pair<int,int>> ab(N),cd(N);
	rep(i,N)ab[i] = make_pair(a[i],b[i]);
	rep(i,N)cd[i] = make_pair(c[i],d[i]);
	sort(ALL(ab));
	sort(ALL(cd));
	vector<bool> used(N);
	int ans = 0;
	for(int i=0;i<N;i++){
		pair<int,int> B = cd[i];
		int index = -1;
		int maxv  = INT_MIN;
		for(int j=0;j<N;j++){
			if(!used[j]&&ab[j].second < B.second && ab[j].first < B.first && maxv < ab[j].second){
				index = j;
				maxv = max(maxv,ab[j].second);
			}
		}
		if(index != -1){
			ans ++;
			used[index] = true;
		}
	}
	cout << ans << endl;
}

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  if(B - A < 2 * K){
    for(int i = A; i <= B; i++){
      cout << i << endl;
    }
  }else{
    for(int i = A; i < A + K; i++){
      cout << i << endl;
    }
    for(int i = B - K + 1; i <= B; i++){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int H,W,K;
const int MaxH=10;
const int MaxW=1000;
int main(){
	cin>>H>>W>>K;
	vector<string>S(H);
	rep(i,H)cin>>S[i];
	int ans=INF;
	rep(mask,1<<(H-1)){
		int nm=__builtin_popcount(mask)+1;
		int tmp=__builtin_popcount(mask);
		vector<int>cnt(nm);
		bool suc=false;
		rep(j,W){
			int now=0;
			rep(i,H){
				if(S[i][j]=='1')cnt[now]++;
				if(mask>>i&1)now++;
			}
			if(*max_element(all(cnt))>K){
				tmp++;
				if(suc){
					tmp=INF;break;
				}
				for(auto &x:cnt)x=0;
				j--;
				suc=true;
				continue;
			}
			suc=false;
		}
		chkmin(ans,tmp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

N, C = map(int, input().split())
x, v = (
    zip(*(map(int, input().split()) for _ in range(N))) if N else
    ((), ())
)

# 初期位置から時計回り／反時計回りに移動したときの利益の最大値に関する累積値を前計算しておく
acc_l = list(
    accumulate(
        (
            V - X
            for X, V in zip(
                [0] + [C - X for X in x[::-1]],
                accumulate((0,) + v[::-1])
            )
        ),
        max
    )
)
acc_r = list(
    accumulate(
        (
            V - X
            for X, V in zip(
                (0,) + x,
                accumulate((0,) + v)
            )
        ),
        max
    )
)
# 時計回りに移動した後に、反時計回りに移動 または
# 反時計回りに移動した後に、時計回りに移動 のどちらかの戦略に限ってよい
ans = max(
    max(
        V - 2 * X + acc_l[N - i]
        for i, X, V in zip(
            range(N + 1),
            (0,) + x,
            accumulate((0,) + v)
        )
    ),
    max(
        V - 2 * X + acc_r[N - i]
        for i, X, V in zip(
            range(N + 1),
            [0] + [C - X for X in x[::-1]],
            accumulate((0,) + v[::-1])
        )
    )
)

print(ans)


Measured memory_bytes: 59224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0135
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = RInt();
            for (int i = 0 ; i < n ; i++)
            {
                int[] HHMM = RIntAr(':');
                decimal shortAngle = HHMM[1] * (360 / 60M);
                decimal longAngle = HHMM[0] * (360 / 12M) + HHMM[1] * (30 / 60M);
                decimal diff = Math.Abs(shortAngle - longAngle);
                diff = Math.Min(diff, 360 - diff);

                string res;
                if (diff < 30) res = "alert";
                else if (diff >= 90) res = "safe";
                else res = "warning";
                Console.WriteLine(res);
            }

        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

int main(){
    string s;
    cin >> s;
    string t = "";
    for(auto&& c : s)
    {
        if (c == 'B' && t.size() > 0) {
            t.pop_back();
            continue;
        }
        else if (c == 'B' && t.size() == 0) {
            continue;
        }
        
        t.push_back(c);
    }
    cout << t << "\n";
}

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

using namespace std;

class node {
 public:
  bool has_left = false;
  bool has_right = false;
  bool hasParent = false;
  int left = -1;
  int right = -1;
  int parent = -1;
  int height = 0;
  int depth = 0;
};

int PopulateDepthAndHeight(vector<node>&, int, int);
int GetSibling(vector<node>&, int);

int main() {
  int n; cin >> n;
  vector<node> nodes(n);
  int nid, leftid, rightid;
  for (int i = 0; i < n; ++i) {
    cin >> nid >> leftid >> rightid;
    if (leftid != -1) {
      nodes[nid].has_left = true;
      nodes[nid].left = leftid;
      nodes[leftid].hasParent = true;
      nodes[leftid].parent = nid;
    }
    if (rightid != -1) {
      nodes[nid].has_right = true;
      nodes[nid].right = rightid;
      nodes[rightid].hasParent = true;
      nodes[rightid].parent = nid;
    }
  }

  int root_id = -1;
  for (int i = 0; i < n; ++i) {
    if (!nodes[i].hasParent) {
      root_id = i;
      break;
    }
  }
  if (root_id == -1) {
    cout << "No root!\n";
    exit(1);
  }
  PopulateDepthAndHeight(nodes, root_id, 0);

  // node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root
  for (int i = 0; i < n; ++i) {
    cout << "node " << i << ": parent = " << nodes[i].parent
      << ", sibling = " << GetSibling(nodes, i)
      << ", degree = " << (nodes[i].has_left + nodes[i].has_right)
      << ", depth = " << nodes[i].depth
      << ", height = " << nodes[i].height
      << ", " << (!nodes[i].hasParent ?
          "root" :
          (
           (!nodes[i].has_left and !nodes[i].has_right ) ?
           "leaf" :
           "internal node")
          )
      << endl;
  }
}

int GetSibling(vector<node>& nodes, int nid) {
  if (!nodes[nid].hasParent) return -1;
  else if (nid == nodes[nodes[nid].parent].left and nodes[nodes[nid].parent].has_right)
    return nodes[nodes[nid].parent].right;
  else if (nid == nodes[nodes[nid].parent].right and nodes[nodes[nid].parent].has_left)
    return nodes[nodes[nid].parent].left;
  else
    return -1;
}

// returns the height of the node; populates depth and height recursively
int PopulateDepthAndHeight(vector<node> &nodes, int curr_id, int curr_depth) {
  nodes[curr_id].depth = curr_depth;
  if (!nodes[curr_id].has_right and !nodes[curr_id].has_left) {
    nodes[curr_id].height = 0;
  } else {
    int right_height = 0, left_height = 0;
    if (nodes[curr_id].has_right) {
      right_height = PopulateDepthAndHeight(nodes, nodes[curr_id].right, curr_depth + 1);
    }
    if (nodes[curr_id].has_left) {
      left_height = PopulateDepthAndHeight(nodes, nodes[curr_id].left, curr_depth + 1);
    }
    nodes[curr_id].height = 1 + max(right_height, left_height);
  }
  return nodes[curr_id].height;
}



Measured memory_bytes: 3096
n=input()
s=input()
ans=s.count('.')
s1=s.split('#')
s2=[0]
for i in s1:
    s2.append(s2[-1]+len(i))
ans1=ans
for i in range(len(s2)-1):
    ans1=min(ans1,ans-s2[i+1]+i)
print(ans1)

Measured memory_bytes: 9704
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int, Int> pii;
typedef pair<Int, double> pid;
typedef pair<double, double> pdd;
typedef pair<Int, pii> pip;
typedef pair<pii, Int> ppi;
typedef pair<double, Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<ppi> vecppi;
typedef vector<veci> mati;
typedef vector<vecll> matll;
typedef vector<vecd> matd;
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i, a, b) for(int i = (a);i <= (b);i++)
#define FORO(i, n) REP(i,0,(int)n-1)
#define FORI(i, n) REP(i,1,(int)n)
#define FORIT(i, t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a, _b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DEBUG 1
#if DEBUG
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
#else
#define DUMP(a)
#define DUMPLN(a)
#endif
template<typename T, typename U>
inline void getMin(T &a, U b) { if (a > b) a = b; }
template<typename T, typename U>
inline void getMax(T &a, U b) { if (a < b) a = b; }
template<typename T>
vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T>
vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T>
vector<T> getEmptyVector() { return vector<T>(); }
template<typename T>
void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1 << 17;
const int inf = 1 << 27;
const ll llinf = 1LL << 50;
const int NIL = -inf;
int popcount(int x) { return __builtin_popcount(x); }

void solve() {
    int N;
    cin >> N;
    vector<pii> D(N);
    for(int i = 0;i < N;i++) cin >> D[i].first >> D[i].second;
    bool found = false;
    for(int i = 2;i < N;i++) {
        if(D[i].first == D[i].second && D[i - 1].first == D[i - 1].second && D[i - 2].first == D[i - 2].second) {
            found = true;
        }
    }
    cout << (found ? "Yes" : "No") << endl;
}

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

    int tc = 1;
    // cin >> tc;
    while(tc--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        vector<Int> A(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }

        Int l = 0, r = accumulate(all(A), 0ll);
        Int ans = r - l;

        for (int i = 0; i < N; ++i) {
            l += A[i];
            r -= A[i];
            Int tmp = abs(l - r);
            if (ans > tmp) ans = tmp;
        }
        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> repo;
    vector<string> newrepo;
    For(syu, 1, n) {
        if (syu == 1)
            newrepo.pb("a");
        else {
            repall (str, repo) {
                char ma = 'a';
                repall (c, str)
                    chmax(ma, c);
                for (char x = 'a'; x <= ma + 1; x++) {
                    if (x > 'z') break;
                    newrepo.pb(str + x);
                }
            }
        }
        repo = newrepo;
        newrepo.clear();
    }
    sort(all(repo));
    repall (str, repo)
        print(str);

    return 0;
}


Measured memory_bytes: 11852
from collections import defaultdict
n = int(input())

d = defaultdict(int)
si = input()
for j in range(len(si)):
    d[si[j]] += 1

for i in range(1, n):
    si = input()
    d2 = defaultdict(int)
    for j in range(len(si)):
        d2[si[j]] += 1

    for c in d:
        d[c] = min(d[c], d2[c])

ans = []
for c in sorted(list(d.keys())):
    for _ in range(d[c]):
        ans.append(c)
ans = ''.join(ans)

print(ans)


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

using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;

  cin >> n;
  for ( int i = 0; i < n; i++) cin >> R[i];

  int maxv = -2000000000;
  int minv = R[0];

  for ( int i = 1; i < n; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}



Measured memory_bytes: 3876
def gcd(a,b):
    l = max(a,b)
    s = min(a,b)
    if s == 0:
        return l
    else:
        return gcd(s, l%s)

n = int(input())
a = [0] + list(map(int, input().split())) + [0]
max_gcd = 1
L = [0] * (n+2)
R = [0] * (n+2)

for i in range(1,n+2):
    L[i] = gcd(a[i],L[i-1])
    R[n+1-i] = gcd(a[n+1-i], R[n+2-i])
for i in range(1,n+1):
    max_gcd = max(max_gcd,gcd(L[i-1], R[i+1]))

print(max_gcd)

Measured memory_bytes: 14400
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <time.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 2147483647


int main() {
	ios_base::sync_with_stdio(false);

	int n; cin >> n; 

	if (n < 10) {
		cout << "Yes\n";
		return 0;
	}

	int i = 2; 

	for (i = 2; i <= 9; i++) {
		if (n % i == 0 && n / i <=9) {
			cout << "Yes\n"; 
			break;
		}
	}
	if (i == 10) {
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL gcd(LL a, LL b) {
	return b != 0 ? gcd(b, a % b) : a;
}



int main() {
	LL a; cin >> a;
	string s; cin >> s;

	LL seisu = s[0] - '0';
	LL syousu = (s[2] - '0') * 10LL + (s[3] - '0');

	LL hyaku = 100;
	LL g = gcd(hyaku, syousu);

	LL bunbo = hyaku/ g;
	LL bunsi = syousu / g;

	LL ans = a * seisu + (a*bunsi) / bunbo;
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <ctype.h>
#include <stdio.h>
using namespace std;

int main(){
  string S;
  cin >> S;
  bool first  =true;
  bool second =true;
  bool third = true;
  first = (S[0] == 'A');
  int c=0;
  int r = 0;
  for (int i = 2 ; i< S.size()-1; i ++){
    if(S[i] == 'C') ++c;
  }
  for (int i = 2 ; i< S.size()-1; i ++){
    if(S[i] == 'C') {
      r=i;
      break;
    }
  }
  if(c != 1) second = false;
  for(int i = 1 ; i<r;i++ ){
    if(islower(S[i])== 0) third= false;
  }
  for(int i=r+1; i<S.size(); i++){
    if(islower(S[i]) == 0) third = false;
  }
  if(first && second && third) cout<< "AC";
  else cout << "WA";
  /*cout << first << second << third;
  cout << c;*/
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define pii pair<int, int>
using namespace std;
int main()
{
    map<int, vector<pii>> diag;
    for (int i = 1; i < 150; ++i) {
        for (int j = i + 1; j < 150; ++j) {
            int d = i * i + j * j;
            if (diag.count(d))
                diag[d].pb(mp(i, j));
            else
                diag[d] = vector<pii>{mp(i, j)};
        }
    }
    int w, h;
    while (cin >> h >> w, h && w) {
        int d = h * h + w * w;
        pair<int, int> *res = NULL;
        if (diag.count(d)) {
            for (auto p : diag[d]) {
                if (p.first > h) {
                    res = &p;
                    break;
                }
            }
        }
        if (!res) {
            while (++d) {
                if (diag.count(d)) {
                    res = &(diag[d].front());
                    break;
                }
            }
        }
        
        cout << res->first << " " << res->second << endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3940
from itertools import product

n, m = map(int, input().split())
ans = 0
S = [list(map(int, input().split())) for i in range(m)]
P = list(map(int, input().split()))
for combi in product([True, False], repeat=n):
    result = True
    for i in range(len(S)):
        p = sum([int(combi[s - 1]) for s in S[i][1:]])
        if p % 2 != P[i]:
            result = False
            break
    if result:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#include <limits>
#include <iomanip>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    ll cnt=0;
    bool frg = true; // all odd number
    for(int i=0;i<N;i++){
        if(A[i]%2==0){
            frg = false;
            break;
        }
    }
    // all odd number
    ll cnt1=1;
    if(frg){
        for(int i=0;i<N;i++){
            cnt1*=3;
        }
        cnt = cnt1-1;
    }
    //
    else{
        ll exclude =1;
        for(int i=0;i<N;i++){
            if(A[i]%2==0){
                exclude*=2;
            }
        }
        ll cnt2=1;
        for(int i=0;i<N;i++){
            cnt2*=3;
        }
        cnt = cnt2 - exclude;
    }
    cout << cnt << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 2000000000

using namespace std;

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

    vector<pair<char, int>> card1(n);
    vector<pair<char, int>> card2(n);

    char mark;    int num;  
    REP(i, n) {
        cin >> mark >> num;
        card1[i] = make_pair(mark, num);
        card2[i] = make_pair(mark, num);
    }

    for (int i = 0; i < n; i++) {
        for (int j = n-1; j > i; j--) {
            if (card1[j].second < card1[j-1].second) {
                card1[j].swap(card1[j-1]);
            }
        }
    }

    REP(i, n) {
        if (i != 0)  cout << " ";
        cout << card1[i].first << card1[i].second;
    }

    cout << endl << "Stable" << endl;

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

        for (int j = i; j < n; j++) {
            if (mini > card2[j].second) {
                mini = card2[j].second;
                j_tmp = j;
            }
        }

        card2[i].swap(card2[j_tmp]);
    }

    REP(i, n) {
        if (i != 0)  cout << " ";
        cout << card2[i].first << card2[i].second;
    }

    if (card1 == card2)
        cout << endl << "Stable" << endl;
    
    else
        cout << endl << "Not stable" << endl;
}


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

int main(){
	string s,t;
	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.rbegin(),t.rend());
	if(s<t) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
ln = [0]*n
for i in range(m):
  a,b = map(int,input().split())
  ln[a-1] += 1
  ln[b-1] += 1
  
for i in ln:
  if i%2:
    print('NO')
    exit()
print('YES')

Measured memory_bytes: 3828