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

#define MAX_N 100010

int pe[MAX_N];
int bu[MAX_N];

void init(int n){
  for(int i = 0; n >i; i++){
    pe[i] = i;
    bu[i] = 0;
  }
}

int find(int x){
  if(pe[x] == x){
    return x;
  }else{
    return pe[x] = find(pe[x]);
  }
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x==y)return;
  if(x < y){
    pe[y] = x;
  }else{
    pe[x] = y;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}






int main(){
  int n,m,k;cin>>n>>m>>k;
  init(n);
  for(int i = 0; k > i; i++){
    int q;cin>>q;
    if(q==1){
      int a,b;cin>>a>>b;a--;b--;a=find(a);b=find(b);
      if(bu[a] != 0 && bu[b] != 0){
        if(bu[a]!=bu[b]){
          cout << i+1 << endl;
          return 0;
        }
      }
      unite(a,b);
      if(bu[a]!=0||bu[b]!=0){
        bu[find(a)] = (bu[a]==bu[b]?bu[a]:bu[a]+bu[b]);
      }
    }else{
      int c,x;cin>>c>>x;c--;
      if((bu[find(c)] == 0 || bu[find(c)] == x) && bu[c] == 0 || bu[c] == x){
        bu[find(c)] = x;
        bu[c] = x;
      }else{
        
        cout << i+1 << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;
  return 0;
}


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

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

    rep(i, n) {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ++ans;
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    //ll lb = (k) * (k-1)/2 % mod;
    //ll ub = (n) * (n+1) /2 % mod;
    for (ll i = k ; i <= n + 1 ; i++) {
        ll lb = i * (i-1) / 2;
        ll ub = (n + (n - i + 1)) * i / 2;
        ans += ub - lb + 1;
        ans %= mod;
        ans += mod;
        ans %= mod;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define cs const 
#define int long long
#define low(i) (i&(-i))
#define mid ((l+r)>>1)
#define ls (now<<1)
#define rs (now<<1|1)
#define par pair<int,int>
#define mp make_pair
#define pb push_back
#define fr first 
#define se second
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define drep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
#define dbg cout << "---------------------------------\n"
cs int base = 233;
cs int ff = 1e6+1;
cs int mod = 1e9+7;
cs int inf = 1e17+1;
inline int read() { int x; scanf("%lld", &x); return x; }
int fir[ff], nex[ff], to[ff], va[ff], tot;
void add(int x, int y, int z)
{
    nex[++tot] = fir[x];
    fir[x] = tot;
    to[tot] = y;
    va[tot] = z;
}
int ksm(int a, int b) { return ( b % 2 == 1 ? a : 1 ) * ( b? ksm( a * a % mod, b>>1 ) : 1 ) % mod; }
int getinv(int x) { return ksm(x, mod-2); }
int n, a[ff];
int calc(int pos, int s = 0) { rep(i, 1, n) s += (a[i]-pos) * (a[i]-pos); return s; }
void init()
{
	cin >> n; int ans = inf;
	rep(i, 1, n) cin >> a[i];
	rep(i, 1, 100) ans = min(ans, calc(i));
	cout << ans;
}
signed main()
{
    int T = 1;
    while(T--) 
        init();
} 

Measured memory_bytes: 2304
#include <stdio.h>
#include <stdlib.h>

int main()
{
int i , j , result=0 , k=0  ;
int distance[5];
for(i=0;i<5;i++)
    scanf("%d\n",&distance[i]);
scanf("%d",&k);
for(i=0;i<5;i++)
    {
    for(j=i+1;j<5;j++)
        {
        if(distance[j]-distance[i]<=k)
            result++;
        }
    }
    if(result==10)
        printf("Yay!");
    else
        printf(":(");
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

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

int main() {
    cin >> n >> m;
    vl a(m), b(m);
    set<ll> search;
    MREP() {
        cin >> a[j] >> b[j];
        if (b[j] == n) search.insert(a[j]);
    }

    MREP() {
        if (search.find(b[j]) != search.end()) {
            if (a[j] == 1){
                END("POSSIBLE")
            }
        }
    }
    MSG("IMPOSSIBLE")
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;

const int MAX_N = 51;
int a[MAX_N];

vector<P> ans;

int main(){
  int N; cin >> N ;
  int _min = INF, _max = -INF;
  int argmin,argmax;
  rep(i,N){
    scanf("%d",a+i);
    if(a[i]<_min){
      _min = a[i];
      argmin = i;
    }
    if(a[i]>_max){
      _max = a[i];
      argmax = i;
    }
  }
  if(_min<0 && _max>0){
    if(abs(_min)>abs(_max)){
      // 全部負にする
      rep(i,N){
        if(a[i]<0) continue;
        ans.pb(P(argmin+1,i+1));
      }
    }else{
      // 全部正にする
      _min = 1;
      rep(i,N){
        if(a[i]>0) continue;
        ans.pb(P(argmax+1,i+1));
      }
    }
  }
  if(_min>=0){
    rep(i,N-1) ans.pb(P(i+1,i+2));
  }else{
    for(int i=N;i>1;i--) ans.pb(P(i,i-1));
  }
  cout << ans.size() << endl;
  rep(i,ans.size()) cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
s = input()

btow = [0 for _ in range(N+1)]
wtob = [0 for _ in range(N+1)]

for i in range(N):
    if s[i]=='#':
        btow[i+1]=btow[i]+1
    else:
        btow[i+1]=btow[i]
    if s[-1-i]=='.':
        wtob[i+1]=wtob[i]+1
    else:
        wtob[i+1]=wtob[i]

ans = float('inf')

for i in range(N+1):
    ans = min(ans,btow[i]+wtob[-1-i])

print(ans)

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

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++)
    cin >> h[i];
  int ans = 0, t = 0;
  for (int i = 0; i < N; i++)
    if (t <= h[i])
      t = h[i];
    else
    {
      ans += t - h[i];
      t = h[i];
    }
  cout << ans + t << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a) for(int i = 0; i < a; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b,c; cin>>a>>b>>c;
    if(b/a>c) cout<<c<<endl;
    else cout<<b/a<<endl;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main implements Runnable {
	public static void main(String[] args) throws FileNotFoundException {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n - 1];
		int[] b = new int[n - 1];
		for (int i = 0; i < n - 1; ++i) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
		}
		solve(n, a, b);
	}

	ArrayList<Integer>[] g;

	public void solve(int n, int[] a, int[] b) {
		Scanner sc = new Scanner(System.in);
		g = new ArrayList[n];
		for (int i = 0; i < n; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < n - 1; ++i) {
			g[a[i]].add(b[i]);
			g[b[i]].add(a[i]);
		}
		parent = new int[n];
		depth = new int[n];
		sz = new int[n];
		sz2 = new int[n];
		Arrays.fill(parent, -1);
		dfs(0, -1);
		int cur = n - 1;
		boolean[] f = new boolean[n];
		int cnt = 0;
		while (parent[cur] != 0) {
			cur = parent[cur];
			f[cur] = true;
			++cnt;
		}
		int F = 0;
		int S = n - 1;
		int[] col = new int[n];
		Arrays.fill(col, -1);
		col[F] = 0;
		col[S] = 1;
		while (cnt > 0) {
			for (int dst : g[F]) {
				if (f[dst]) {
					col[dst] = 0;
					F = dst;
					--cnt;
					f[dst] = false;
					break;
				}
			}
			if (cnt == 0)
				break;
			col[parent[S]] = 1;
			S = parent[S];
			--cnt;
			if (cnt == 0)
				break;
		}
		for (int i = 0; i < n; ++i) {
			if (col[i] == -1)
				continue;
			sz2[i] = 1;
			for (int dst : g[i]) {
				if (col[dst] == -1) {
					sz2[i] += sz[dst];
				}
			}
		}

		int[] h = new int[2];
		for (int i = 0; i < n; ++i) {
			if (col[i] != -1) {
				h[col[i]] += sz2[i];
			}
		}
		if (h[0] <= h[1]) {
			System.out.println("Snuke");
		} else {
			System.out.println("Fennec");
		}
	}

	int[] parent;
	int[] depth;
	int[] sz;
	int[] sz2;

	void dfs(int cur, int par) {
		parent[cur] = par;
		sz[cur] = 1;
		for (int dst : g[cur]) {
			if (dst == par)
				continue;
			depth[dst] = depth[cur] + 1;
			dfs(dst, cur);
			sz[cur] += sz[dst];
		}
	}

	class DJSet {
		int n;
		int[] upper;

		public DJSet(int n) {
			this.n = n;
			upper = new int[n];
			Arrays.fill(upper, -1);
		}

		boolean equiv(int x, int y) {
			return root(x) == root(y);
		}

		int root(int x) {
			return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
		}

		void setUniont(int x, int y) {
			x = root(x);
			y = root(y);
			if (x == y) {
				return;
			}

			if (upper[x] < upper[y]) {
				int tmp = x;
				x = y;
				y = tmp;
			}

			upper[y] += upper[x];
			upper[x] = y;
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 98532
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 1e3 + 9;
const ll mod = 1e9 + 7;
typedef pair<ll,ll> LL;

ll n,m,a,b,ans[N][N];
void Fill(ll x,ll y,ll p,ll q){
    ll i,j;
    //cout<<x<<" "<<y<<" "<<p<<" "<<q<<"\n";
    for (i = x;i <= p;i++){
        for (j = y;j <= q;j++) ans[i][j] = 1;
    }
}
void out(){
    for (ll i = 1;i <= n;i++){
        for (ll j = 1;j <= m;j++) cout<<ans[i][j];
        cout<<"\n";
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>n>>m>>a>>b;
    ll q = m - a,p = n - b;
    ll curx = 1,cury = 1;
    while(curx <= n&&cury <= m){
        ll x = min(n,curx + p - 1),y = min(m,cury + q - 1);
        //cout<<x<<" "<<y; return 0;
        Fill(curx,cury,x,y);
        //out(); return 0;
        curx = x + 1,cury = y + 1;
    }
    out();
}



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

int main(){
    ll n, x, ans = 0;
    cin >> n >> x;
    vector<ll> a(n, 0);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    for(int i = 0; i < n - 1; i++){
        ll sa = a[i] + a[i + 1] - x;
        if(sa > 0){
            a[i + 1] = a[i + 1] - sa;
            if(a[i + 1] < 0){
                a[i] += a[i + 1];
                a[i + 1] = 0;
            }
            ans += sa;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4016
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
class disjointset {
private:
	int sz;
	vector<int> par;
public:
	disjointset() : sz(0), par(vector<int>()) {};
	disjointset(int sz_) : sz(sz_) {
		par.resize(sz);
		for (int i = 0; i < sz; ++i) par[i] = i;
	}
	int root(int x) {
		if (x == par[x]) return x;
		return par[x] = root(par[x]);
	}
	void connect(int x, int y) {
		x = root(x);
		y = root(y);
		par[x] = y;
	}
};
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M), B(M), C(M), perm(M);
	for (int i = 0; i < M; ++i) {
		cin >> A[i] >> B[i] >> C[i]; --A[i], --B[i];
		perm[i] = i;
	}
	sort(perm.begin(), perm.end(), [&](int i, int j) { return C[i] < C[j]; });
	map<int, vector<int> > g;
	for (int i = 0; i < M; ++i) {
		g[C[i]].push_back(i);
	}
	disjointset uf(N);
	vector<int> ans;
	for (pair<int, vector<int> > i : g) {
		vector<int> e = i.second;
		vector<vector<pair<int, int> > > gs(N);
		for (int j : e) {
			gs[uf.root(A[j])].push_back(make_pair(uf.root(B[j]), j));
			gs[uf.root(B[j])].push_back(make_pair(uf.root(A[j]), j));
		}
		vector<bool> vis(N);
		vector<int> eli;
		function<void(int)> dfs = [&](int pos) {
			vis[pos] = true;
			for (pair<int, int> j : gs[pos]) {
				if (vis[j.first]) continue;
				eli.push_back(j.second);
				dfs(j.first);
			}
		};
		for (int j = 0; j < N; ++j) {
			if (!vis[j]) dfs(j);
		}
		for (int j : eli) {
			disjointset uf2 = uf;
			for (int k = 0; k < N; ++k) {
				for (pair<int, int> l : gs[k]) {
					if (l.second != j) {
						uf2.connect(k, l.first);
					}
				}
			}
			if (uf2.root(A[j]) != uf2.root(B[j])) {
				ans.push_back(j);
			}
			uf.connect(A[j], B[j]);
		}
	}
	int sum = 0;
	for (int i : ans) sum += C[i];
	cout << ans.size() << ' ' << sum << endl;
	return 0;
}


Measured memory_bytes: 5368
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>

#include <assert.h>

using namespace std;
#define MAX 1e18
#define MAXN 400+1

long long F[MAXN][MAXN];

int main(){
  int N;

  cin >> N;
  assert(N >= 2 && N <= 400);

  vector<long long> A(N+1);
  for(auto i=1; i<= N; i++) cin >> A.at(i);


  vector<long long> cumsum(N+1, 0);
  for(auto i=1; i<= N; i++)  cumsum.at(i) = cumsum.at(i-1) + A[i];

  // vector< vector<long long> > F(   N+1 );

  // F[i][j], from i to j slime
  // F[l][i], length l, from i
  for (int i = 1; i <= N; i++) {
    F[1][i] = 0;// A.at(i);
  }

  for (int l = 2; l <= N; l++) {
    for (int i = 1; i <= N-l+1; i++) {
      int j = i + l - 1;
      F[l][i] = MAX;
      for (int la = 1; la < l; la++) {
        int lb = l - la;
        int pb = i + la;
        long long cost = F[la][i] + F[lb][pb];
        F[l][i] = min( F[l][i], cost);
      }
      F[l][i] +=  cumsum.at(j) - cumsum.at(i-1);
    }
  }

  cout << F[N][1] << endl;

  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  
  int num = 0;
  
  for(int i = 0; i < (int)str.size(); ++i){
    num +=(int)(str[i] - '0');
  }
  
      int N = atoi(str.c_str());
  
  if(N % num == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  
}

Measured memory_bytes: 3608
'''
import sys
input=sys.stdin.readline
n,m,c = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
from math import ceil
from collections import defaultdict ,Counter
'''
n = int(input())
a = list(map(int,input().split()))
su=0
for i in range(n):
    for j in range(i+1,n):
        su+=a[i]*a[j]
print(su)


Measured memory_bytes: 38512
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  string s;
  long k;
  cin >> s;
  cin >> k;
  for(int i=0;i<s.length();i++){
    if(i==k){
      cout << s[i-1] << endl;
      return 0;
    }
    if(s[i]!='1'){
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << "1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

int
days(int y, int m, int d)
{
	const int md[12] = {0, 31, 59, 90,120,151,181,212,243,273,304,334};

	int y1 = y - 1;
	int u = y1 * 365 + md[m - 1] + d + (y1 / 4 - y1 / 100 + y1 / 400);
	if (m >= 3 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0))
		u++;

	return u;
}

int
main(int argc, char **argv)
{
	int y2, m2, d2;
	int y1, m1, d1;

	while (true)
	{
		scanf("%d%d%d%d%d%d", &y1, &m1, &d1, &y2, &m2, &d2);
		if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0)
			break;

		printf("%d\n", days(y2, m2, d2) - days(y1, m1, d1));
	}

	return 0;
}

Measured memory_bytes: 1672
N,M=map(int,input().split())
A=[0]*N
for i in range(N):
    A[i] =[int(i) for i in input().split()]
A.sort()
mysum=0
i=0
while M>0:
    if A[i][1]>0:
        A[i][1]-=1
        M-=1
        mysum+=A[i][0]
    else:
        i+=1
print(mysum)
    

Measured memory_bytes: 21616
//HSI

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n,m;cin>>n>>m;
    int bai = 1;
    rep(i,0,m)bai*=2;
    int ans = m*1900+(n-m)*100;
    cout<<ans*bai<<nnn;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

typedef long long ll; //64bit型
using namespace std;
const ll INF = 1LL << 20;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main()
{
        int ans = 0;
        vector<int> time(5);
        for (int i = 0; i < 5; i++)
        {
                cin >> time[i];
        }

        vector<int> order(5);
        for (int i = 0; i < 5; i++)
        {
                order[i] = time[i] % 10;
        }
        int num;
        int res = 200;
        for (int i = 0; i < 5; i++)
        {
                if (order[i] != 0 && order[i] < res)
                {
                        res = order[i];
                        num = i;
                }
        }
        debug(res);

        for (int i = 0; i < 5; i++)
        {
                if (i == num || order[i] == 0)
                {
                        ans += time[i];
                }
                else
                {
                        ans += time[i] + (10 - order[i]);
                }
        }

        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int N;
  cin >> N;
  vector<ll> a;
  ll w;
  for (int i=1; i<=9; i++) a.push_back(i);//まずは欲しい数を集めた配列を用意する
  while(1){
    if (N <= a.size()){
      cout << a.at(N-1) << endl;//例えば８が欲しければindex7を取り出せばよい
      return 0;
    }
    N -= a.size();
    vector<ll> old;//調べ終わった数は別の配列に格納し、次の数の生成に使う
    swap(old, a);
    for (ll x:old){
      for (int y=-1; y <=1; y++){
        int d = x%10 + y;//まず１の位を設定
        if (d<0|| d > 9) continue;//１の位であるという指定をクリアできなければ飛ばす
        ll nx = x*10 + d;//1の位分を開けるために元の数を10倍して、できた1の位の枠にdを入れる
        a.push_back(nx);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.DDCC2019_qual
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] xy = ReadInts();
            int x = xy[0];
            int y = xy[1];
            int res = 0;
            int[] scores = new int[3] { 300000, 200000, 100000 };
            if (x >= 1 && x <= 3) res += scores[x - 1];
            if (y >= 1 && y <= 3) res += scores[y - 1];
            if (x == 1 && y == 1) res += 400000;
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
// using namespace boost::multiprecision;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define mll map<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define srta(a) sort(all(a))
#define srtd(a) sort(all(a),greater<型>())
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back
#define ers erase
#define isu isupper
#define isl islower
#define lb(a,k) lower_bound(all(a),k)
#define ub(a,k) upper_bound(all(a),k)
#define bs(a,k) binary_search(all(a),k)
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

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

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

void Main() {
    ll N, X, T;
    cin >> N >> X >> T;

    ll cnt = 0;
    while (N > 0) {
        N -= X;
        cnt++;
    }

    cout << T*cnt << endl;
}

int main() {
    Main();
    return 0;
}


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

int main()
{
ll x ;
cin >> x ;
bitset<100001> b;
b[0]=1;
rep(i,1000){
  b=b|(b<<100)|(b<<101)|(b<<102)|(b<<103)|(b<<104)|(b<<105);
}
if(b[x])ans=1;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 384
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

m = []
def dfs(depth, x, y, z, count):
  if depth == n:
    if min(x, y, z) > 0:
       return abs(a-x)+abs(b-y)+abs(c-z)+10*count-30
    else:
      return float('Inf')
  ret0 = dfs(depth+1, x, y, z, count)
  ret1 = dfs(depth+1, x+l[depth], y, z, count+1)
  ret2 = dfs(depth+1, x, y+l[depth], z, count+1)
  ret3 = dfs(depth+1, x, y, z+l[depth], count+1)
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0, 0))




  
        
  

Measured memory_bytes: 45148
import std.array;
import std.conv;
import std.string;
import std.algorithm;
import std.stdio;

void main() {
	int n, k;
	readf("%s %s\n", &n, &k);
	auto a = readln.chomp.split(' ').map!(to!int).array;

	foreach (i;0..n - k) {
		if (a[i] < a[k + i]) {
			writeln("Yes");
		} else {
			writeln("No");
		}
	}
}


Measured memory_bytes: 10108
X[]={1,0,-1,0},Y[]={0,1,0,-1},s[19][19];char *D="RDLU";
main(x,y,i,j,z){
	x=y=5;
	for(j=0;j<2*y;j++)for(i=0;i<2*x;i++)s[i][j]=0;
	for(j=1;j<2*y;getchar(),j++)
		for(i=(j&1)?2:1;i<2*x;i+=2){
			s[i][j]=getchar()-'0';
		}
	putchar('R');
	for(z=0,x=3,y=1;x!=1||y!=1;){
		z=(z+3)%4;
		for(;!s[x+X[z]][y+Y[z]];z=(z+1)%4);
		x+=X[z]*2,y+=Y[z]*2;
		putchar(D[z]);
	}
	puts("");exit(0);
}

Measured memory_bytes: 524
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

int main() {
	int N; cin >> N;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int x; cin >> x;
		if (i % 2 == 0 && x % 2 == 1) cnt++;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define LL unsigned long long
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

const int N = 100050; const LL INF = 1ll<<62;
int n,a[N];
LL cnt[N];
LL rr[N];
LL now;
int main(){
	int i;
	read(n);
	for (i = 0; i <= n; ++i) read(a[i]);
	if (n == 0){
		if (a[0] == 1) cout << 1 << '\n'; else puts("-1");
		return 0;
	}
	if (a[0] > 0){ puts("-1"); return 0; }
	rr[0] = 1;
	for (now = i = 1; i <= n; ++i){
		now <<= 1;
		if (a[i] > now){ puts("-1"); return 0; }
		now -= a[i];
		rr[i] = now;
		if (now > INF) now = INF;
	}
	//a solution exist!
	for (i = n; i >= 0; --i){
		cnt[i] = a[i];
		if (i < n){
			cnt[i] += min(rr[i],cnt[i+1]);
		}
	}
	LL ans = 0;
	for (i = 0; i <= n; ++i){
		ans += cnt[i];
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> n;
    cin >> str;
    int r = 0,b = 0;
    for(i = 0;i < str.length();i++){
        if(str[i] == 'R') r++;
        else b++;
    }
    if(r>b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
using vs= vector<string>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

ll nC2(ll n){
  ll ans=1;
  rep(i,0,2){
    ans*= n-i;
  }
  return ans/2;
}

int main(){
  ll n,m,ans;
  cin >> n >> m;
  ans= nC2(n);
  ans+= nC2(m);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 998244353;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}
void YES(bool condition){
	if(condition){
		p("YES");
	}else{
		p("NO");
	}
	return;
}
void Yes(bool condition){
	if(condition){
		p("Yes");
	}else{
		p("No");
	}
	return;
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l,num,sum,ok,ng,mid;
ll x[500005],y[500005],z[500005];
ll dp[100005];
char s[500005],t[500005],u[500005];
bool dame,flag;
//string s;
int main(){
	cin >> n >> m;
	vector<ll> use;
	y[1] = 2;y[2] = 5;y[3] = 5;
	y[4] = 4;y[5] = 5;y[6] = 6;
	y[7] = 3;y[8] = 7;y[9] = 6;
	for(i=0;i<m;i++){
		cin >> a;
		use.pb(a);
		x[a]++;
	}
	dp[0] = 0;
	for(i=1;i<=n;i++){
		dp[i] = -INF;
		for(j=0;j<use.size();j++){
			if(i-y[use[j]]>= 0){
				dp[i] = max(dp[i],dp[i-y[use[j]]] + 1);
			}
		}
	}
	for(i=1;i<=20;i++){
		//pe(i);p(dp[i]);
	}
	a = n;
	while(a > 0){
		for(j=9;j>=1;j--){
			if(!x[j])continue;
			if(dp[a] == dp[a-y[j]] + 1 && a >= y[j]){
				a -= y[j];
				pu(j);
				break;
			}
		}
	}
	el;

	return 0;
}

Measured memory_bytes: 29568
#include <sstream>
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include <cstdlib>
using namespace std;

int main(){
  int k,x;
  cin>>k>>x;
  if(k*500 >=x)
    cout<<"Yes";
  else
    cout<<"No";
  
  return 0;
}

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

int main() {
	string s1,s2,s3;
  	cin >> s1 >> s2 >> s3;
  	string ans;
  	ans += s1.at(0);
  	ans += s2.at(0);
  	ans += s3.at(0);
  	transform(ans.begin(),ans.end(),ans.begin(),::toupper);
  	cout << ans << endl;
}

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

bool IsPrime(long long num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (long long i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

std::vector<long long> enum_div(long long n)
{
	std::vector<long long> ret;
	for(long long i=2 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

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

    if (IsPrime(N)) {
        cout << N -1;
        return 0;
    } else {
        vector<long long> r = enum_div(N);
        vector<long long> a;
        for(auto i : r) {
            for (auto j : r) {
                if (j*i == N) {

                a.push_back(i+j);
                }
            }
        }
        sort(a.begin(), a.end());
        // for (auto i : a) cout << i << ",";
        cout << a[0] -2 << endl;
    }
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

int h,w;
string mp[55];
int nx[] = {-1,-1,-1, 0, 0, 1, 1, 1};
int ny[] = {-1, 0, 1,-1, 1,-1, 0, 1};

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

  cin >> h >> w;
  for(int i=0;i<h;i++){
    cin >> mp[i];
    for(int j=0;j<w;j++)if(mp[i][j] == '.')mp[i][j] = '0';
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(mp[i][j] == '#'){
        for(int k=0;k<8;k++){
          int y = ny[k] + i;  
          int x = nx[k] + j;
          if(y<0 || x<0 || y>=h || x>=w)continue;
          if(mp[y][x] != '#')mp[y][x]++;
        }
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
//inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));


int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<pair<int64_t, int64_t>> a(n);

    for (auto& pa : a)
        cin >> pa.second >> pa.first;

    sort(begin(a), end(a));

    int64_t cur = 0;
    for (const auto& pa : a) {
        cur += pa.second;
        if (cur > pa.first)
            FINAL_OUT("No");
    }
    FINAL_OUT("Yes");
}


Measured memory_bytes: 3456
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    string s;
    cin >> s;
    cout << s[0] << s.length()-2 << s[s.length()-1] << endl;
}


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

#define INF 1e9 + 5

// for using in pairs
#define F first
#define S second

// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

#define int long long

void solve(int tc)
{
	int k;
	cin >> k;

	int prev = 7;
	int x = 10;

	for (int i = 1; i <= 1000000; i++)
	{
		if (prev % k == 0)
		{
			cout << i;
			return;
		}

		prev = 7 * x + prev;
		prev %= k;

		x *= 10;
		x %= k;
	}
	cout << "-1\n";
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;

	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}
	return 0;
}


Measured memory_bytes: 3688
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<map>
#include<bitset>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
int gcd_(int a, int b)
{
     return b ==0? a : gcd_(b, a % b);
}
int a[maxn];
int main()
{
    int n,x;
    cin>>n>>x;
    for(int i=0;i<n;i++) cin>>a[i];
    a[n]=x;
    sort(a,a+n+1);
    int g=0;
    for(int i=1;i<=n;i++)
    {
        g=gcd_(g,a[i]-a[i-1]);
    }
    cout<<g<<endl;
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	auto csf = vector<tuple<int, int, int>>(n - 1);
	for(auto&& a : csf){
		int c, s, f;
		cin >> c >> s >> f;
		a = tie(c, s, f);
	}
	for(auto i = 0; i < n - 1; ++i){
		int c, s, f;
		tie(c, s, f) = csf[i];
		int ans = s + c;
		for(auto j = i + 1; j < n - 1; ++j){
			tie(c, s, f) = csf[j];
			ans = max(s, ((ans - 1) / f + 1) * f) + c;
		}
		cout << ans << endl;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from itertools import combinations_with_replacement


def read_int_n():
    return list(map(int, input().split()))


def slv(N, M, Q, ABCD):
    ans = 0
    for a in combinations_with_replacement(range(1, M+1), r=N):
        t = 0
        for A, B, C, D in ABCD:
            if a[B-1] - a[A-1] == C:
                t += D
        ans = max(ans, t)
    return ans


def main():
    N, M, Q = read_int_n()
    ABCD = [read_int_n() for _ in range(Q)]
    print(slv(N, M, Q, ABCD))


if __name__ == '__main__':
    main()


Measured memory_bytes: 67728
#include<iostream> 
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<vector> 
#include<array>
#include<deque>
#include<list>
#include<forward_list>
#include<stack>
#include<queue>
#include<algorithm>
#include<numeric>
#include<iterator>
#include<functional>
#include<map>
#include<unordered_map>
#include<set>
#include<utility>
#include<unordered_set>
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define sort_all(v) sort(v.begin(), v.end())
#define fill(a) memset(a, 0, sizeof(a))

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


void test() {
    ll a, b;
    int f;
    scanf("%lld %lld.%d", &a, &b, &f);
    b = b * 100 + f;
    ll ans = (a * b) / 100;
    cout << ans;
}   
 
int main ()     
{
    // int t;
    // cin >> t;
    // while(t--) 
        test();
}


Measured memory_bytes: 3684
def warshall_floyd(d):
	for k in range(n):
		for i in range(n):
			for j in range(n):
				d[i][j]=min(d[i][j],d[i][k]+d[k][j])
	return d
n,m,l=map(int,input().split())
d=[[10**10 for _ in range(n)]for _ in range(n)]
for i in range(n):
	d[i][i]=0
for i in range(m):
	a,b,c=map(int,input().split())
	d[a-1][b-1]=c
	d[b-1][a-1]=c
p=[[10**5 for _ in range(n)]for _ in range(n)]
d=warshall_floyd(d)
for i in range(n):
	for j in range(n):
		if d[i][j]<=l:
			p[i][j]=1
p=warshall_floyd(p)
q=int(input())
for i in range(q):
	s,t=map(int,input().split())
	if p[s-1][t-1]==10**5:
		print(-1)
		continue
	print(p[s-1][t-1]-1)



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

int index(int y, int x) {
    return y * (y + 1) / 2 + x;
}

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

    vector<int> nail(index(N, N));
    for(int i = 0; i < M; ++i) {
        int A, B, X;
        cin >> A >> B >> X;
        --A; --B;
        nail[index(A, B)] = max(nail[index(A, B)], X + 1);
    }

    int answer = 0;
    for(int i = 0; i < N; ++i) for(int j = 0; j <= i; ++j) {
        if(0 <= j - 1) nail[index(i, j)] = max(nail[index(i, j)], nail[index(i - 1, j - 1)] - 1);
        if(j < i) nail[index(i, j)] = max(nail[index(i, j)], nail[index(i - 1, j)] - 1);
        if(nail[index(i, j)]) ++answer;
    }
    cout << answer << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

void fail() {
	cout << "No" << endl;
	exit(0);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--, b--, c--, d--;
	string s; cin >> s;
	
	FOR(i,a,c-1) {
		if (s[i] == '#' && s[i+1] == '#') fail();
	}
	FOR(i,b,d-1) {
		if (s[i] == '#' && s[i+1] == '#') fail();
	}
	
	if (c > d) {
		bool ok = false;
		FOR(i,b,d+1) {
			if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') ok = true;
		}
		cout << (ok ? "Yes" : "No") << endl;
	} else {
		cout << "Yes" << endl;
	}


}



Measured memory_bytes: 592
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline int ri() {int x; scanf("%d", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/


string s[100];
int h, w;
int main() {
  #ifdef _TEST_
  freopen("input.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  #endif
  cin >> h >> w;
  rep(i, h) cin >> s[i];
  rep(i, h - 1) {
    rep(j, w - 1) {
      if ((s[i][j] == '#' && s[i][j + 1] == '#' && s[i + 1][j] == '#') || 
          (s[i+1][j+1] == '#' && s[i][j + 1] == '#' && s[i + 1][j] == '#')) {
        cout << "Impossible" << endl;
        return 0;
      }
    }
  }
  cout << "Possible" << endl; 
  return 0;
}


Measured memory_bytes: 256
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  string a,b,c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2] <<  endl;
}


Measured memory_bytes: 256
N = int(input())
n =2*N

S, T = input().split(" ")

s = 0
t = 0

for a in range(n):
    if a%2 == 0:
        print(S[s], end="")
        s = s +1
    else:
        print(T[t], end="")
        t = t + 1


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
int main() {
	int N;
	cin >> N;
	int x = 0, y = 0;
	rep(i, N) {
		int a;
		cin >> a;
		if (a % 4 == 0) x++;
		else if (a % 2 == 1) y++;
	}
	bool OK = 0;
	if ((x + y == N&&x >= y - 1) || (x + y < N&&x >= y)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main() {
	int A, B, C;

	cin >> A >> B >> C;

	string ans = "No";
	if( A <= C && C <= B || A >= C && C >= B ) {
		ans = "Yes";
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    int M;
    int C;
    cin >> N >> M >> C;
    
    int B[M];
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }
    int A[N][M];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    
    int ans = 0;
    int temp = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            temp = temp + A[i][j]*B[j];
        }
        temp = temp + C;
        if (temp > 0) {
            ans++;
        }
        temp = 0;
    }
    
    cout << ans;
    
    return 0;
}

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

void print(string str, int a, int b){
	cout << str.substr(a, b - a + 1) << endl;
}

string reverse(string str, int a, int b){
	string tmp = str.substr(a, b - a + 1);
	reverse(tmp.begin(), tmp.end());
	return str.replace(a, b - a + 1, tmp);
}

string replace(string str, int a, int b, string p){
	return str.replace(a, b - a + 1, p);
}


int main() {
	string str;
	int q;
	string command, p;
	int a, b;

	cin >> str;
	cin >> q;

	for (int i = 0; i < q; i++){
		cin >> command >> a >> b;
		if (command == "replace") cin >> p;

		if (command == "print") {
			print(str, a, b);
		} else if (command == "reverse") {
			str = reverse(str, a, b);
		}else if (command == "replace"){
			str = replace(str, a, b, p);
		}
	}

	return 0;
}


Measured memory_bytes: 3160