akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<map>

#define For(i,a,b) for(int i=a;i<=b;i++)
#define ForD(i,a,b) for (int i=a;i>=b;i--)
#define LL long long
#define INF (2147483647)
#define sqr(x)	((x)*(x))

using namespace std;

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

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

int main(){	
	char s1[1000],s2[1000];
	scanf("%s",s1),scanf("%s",s2);
	if (strlen(s1)<strlen(s2))
		puts("LESS");
	else if (strlen(s2)<strlen(s1))
		puts("GREATER");
	if (strlen(s1)==strlen(s2)){
		int t=0;
		For(i,0,strlen(s1)){
			if (s1[i]<s2[i]){
				t=1;break;
			}
			if (s1[i]>s2[i]){
				t=2;break;
			}
		}
		if (t==1)
			puts("LESS");
		if (t==2)	puts("GREATER");
		if (t==0)	puts("EQUAL");			
	}
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main (String[]args){
        try(Scanner sc = new Scanner(System.in)){
            String l=sc.nextLine();
            int length=l.length();
            String ans="";
            for(int a=0;a<length;a++){
                char c=l.charAt(a);
               
                if(Character.isLowerCase(c)){
                    ans+=Character.toUpperCase(c);
                }
                else ans+=Character.toLowerCase(c);
            }       
            System.out.println(ans);         
        }  
    }
}


Measured memory_bytes: 31464
def dense(w, s):
	if w + s == 0:
		return 0
	return s / (w + s)

def resolve():
	a, b, c, d, e, f = map(int, input().split())
	water_set = set()
	sugar_set = set()
	for i in range(31):
		for j in range(31):
			s = 100*a*i + 100*b*j
			if s <= f:
				water_set.add(100*a*i + 100*b*j)
	for i in range(1001):
		for j in range(1001):
			s = i*c + j*d
			if s <= f:
				sugar_set.add(s)
	wv, sv = 0, 0
	for w in water_set:
		for s in sugar_set:
			if f < (w + s) or (w//100*e) < s:
				continue
			if dense(wv, sv) <= dense(w, s):
				wv, sv = w, s
	print(wv+sv, sv)
resolve()

Measured memory_bytes: 40560
local insert = table.insert
local n, m = io.read('*n', '*n')
local ret = {}
for i = 1, m do
	local p, y = io.read('*n', '*n')
	ret[p] = ret[p] or {}
	insert(ret[p], {idx = i, val = y})
end
local ans = {}
for i, v in pairs(ret) do
	table.sort(v, function(a, b)
		return a.val < b.val
	end)
	for j, vv in ipairs(v) do
		ans[vv.idx] = string.format("%06d%06d", i, j)
	end
end
for i = 1, m do
	print(ans[i])
end


Measured memory_bytes: 35680
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<usize>();
    let (n, k) = (input[0], input[1]);

    let mut win_rate = vec![];

    for i in 1..n+1 {
        if i > k {
            win_rate.push(1.);
        } else {
            let d = ((k as f64).log2() - (i as f64).log2()).ceil();
            win_rate.push((1f64/2f64).powf(d));
        }
    }

    let ans = win_rate.into_iter().sum::<f64>() / n as f64;

    println!("{}", ans);
}

Measured memory_bytes: 4604
q = int(input())
l = [0]*(10**5+1)
p = set()
for i in range(2,10**5+1):
  if l[i] == 0:
    l[i] = 1
    p.add(i)
    for j in range(2*i,10**5+1,i):
      l[j] = -1
l = [0]*(10**5+1)
for x in p:
  if (x+1)//2 in p:
    l[x] = 1
for i in range(1,10**5+1):
  l[i] += l[i-1]
for _ in range(q):
  s,r = map(int, input().split())
  print(l[r]-l[s-1])

Measured memory_bytes: 7248
down_positions = []
ponds = []
for index, value in enumerate(raw_input()):
    if value == '\\':
        down_positions.append(index)
    elif value == '/' and down_positions:
        right = index
        left = down_positions.pop()
        area = right - left
        candidate_area = 0
        while ponds and left < ponds[-1][0]:
           candidate_area += ponds.pop(-1)[1]

        ponds.append((left, area + candidate_area))

print sum(x[1] for x in ponds)
print len(ponds), 
for pond in ponds:
    print pond[1], 

Measured memory_bytes: 6860
# import sys
# input = sys.stdin.readline

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

n = int(input())
point = []
p = []
m = []
for i in range(n):
    a,b = mp()
    point.append((a,b))
    p.append(a+b)
    m.append(a-b)
print(max(max(p)-min(p), -min(m)+max(m), max(m)-min(m), -min(p)+max(p)))





Measured memory_bytes: 114500
#include<iostream>
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
int n,k;
int ans=0,poi=0;
signed main(){
scanf("%lld%lld",&n,&k);

for(int i=1;i<=n;i++)ans+=(i%k==0);

if(k%2==0){
    for(int i=1;i<=n;i++)poi+=(i%k==k/2);
}
cout<<ans*ans*ans+poi*poi*poi;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main(){
		new AOJ0212().doIt();
	}

	class AOJ0212{
		int C,N,M,S,D;
		int[][] cost;
		
		void solve(){
			int[][] closed = new int[N][C+1];
			for(int i=0;i<N;i++)Arrays.fill(closed[i],Integer.MAX_VALUE/2);
			PriorityQueue<State> q = new PriorityQueue<State>();
			q.add(new State(S-1,0,C));
			closed[S-1][C] = 0;
			int result = -1;
			while(q.size()>0){
				State now = q.remove();
				int v = now.v;
				int c = now.cost;
				int w = now.wari;
//				System.out.println(v+" "+c+" "+w);
				if(v==D-1){
					result = c;
					break;
				}
				for(int i=0;i<N;i++)if(cost[v][i]>0){
					//割引券を使用しない場合
					if(closed[i][w]>cost[v][i]+c){
						q.add(new State(i, c+cost[v][i], w));
						closed[i][w] = cost[v][i]+c;
					}
					//使用する場合
					if(w>0){
						if(closed[i][w-1]>cost[v][i]/2+c){
							q.add(new State(i, c+(cost[i][v]/2), w-1));
							closed[i][w-1] = c+(cost[v][i]/2);
						}
					}
				}
			}
			System.out.println(result);
		}
		
		void doIt(){
			while(in.hasNext()){
				C = in.nextInt();
				N = in.nextInt();
				M = in.nextInt();
				S = in.nextInt();
				D = in.nextInt();
				if(C+N+D+S==0)break;
				cost = new int[N][N];
				for(int i=0;i<M;i++){
					int a = in.nextInt()-1;
					int b = in.nextInt()-1;
					cost[a][b] = cost[b][a] = in.nextInt();
				}
				solve();
			}
			
		}
		class State implements Comparable<State>{
			int v,cost,wari;
			public State(int v,int cost,int wari) {
				this.v = v;
				this.cost = cost;
				this.wari = wari;
			}
			public int compareTo(State o) {
				return cost-o.cost;
			}
		}
	}

}

Measured memory_bytes: 55572
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;


    UnionFind(ll N): par(N), siz(N, 1LL) {
        for (ll i = 0; i < N; ++i) par[i] = i;
    }

    void init(ll N) {
        par.resize(N);
        siz.assign(N, 1LL);
        for (ll i = 0; i < N; ++i) par[i] = i;
    }


    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }


    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N,M; cin >> N >> M;
    vector<ll> A(M);
    vector<ll> B(M);
    for(int i=0;i<M;i++){
        ll a,b; cin >> a >> b;
        a--; b--;
        A[i] = a;
        B[i] = b;
    }
    ll sum = N*(N-1)/2;
    UnionFind tree(N);

    vector<ll> ans;
    for(int i=0;i<M;i++){
        ans.push_back(sum);
        ll a = A[M-1-i];
        ll b = B[M-1-i];
        if(tree.same(a,b)) continue;

        ll s = tree.size(a);
        ll t = tree.size(b);
        sum -= s*t;
        tree.unite(a,b);
    }
    reverse(ans.begin(),ans.end());

    for(int i=0;i<ans.size();i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 5364
#include <stdio.h>
#include <string.h>
int main()
{
  char s[4];
  scanf("%s", &s);
  
  if(strcmp(s, "SAT") == 0)
    printf("1");
  if(strcmp(s, "FRI") == 0)
    printf("2");  
  if(strcmp(s, "THU") == 0)
    printf("3");  
  if(strcmp(s, "WED") == 0)
    printf("4");
  if(strcmp(s, "TUE") == 0)
    printf("5");
  if(strcmp(s, "MON") == 0)
    printf("6");
  if(strcmp(s, "SUN") == 0)
    printf("7");
  
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String []args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] mp = new int[n+1];
		while(sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a==b) mp[a]++;
			else {
				mp[a]++;
				mp[b]++;
			}
		}
		for(int i=1; i<mp.length; i++) {
			System.out.println(mp[i]);
		}
	}
}

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


int main() {
	int N;
	cin >> N;
	vector<int64_t>A(N);
	for(int i=0;i<N;i++){
		cin >> A.at(i);
	}
	int q;
	cin >> q;
	vector<int64_t>B(q);
	vector<int64_t>C(q);
	for(int i=0;i<q;i++){
		cin >> B.at(i);
		cin >> C.at(i);
	}
	int64_t sum = 0;
	for(int i=0;i<N;i++){
		sum+= A.at(i);
	}
	vector<int64_t>number(100000);
	for(int i=0;i<N;i++){
		number.at(A.at(i)-1)++;
	}
	for(int i=0;i<q;i++){
		int k = C.at(i)-B.at(i);
		sum += k*number.at(B.at(i)-1);
		cout << sum << endl;
		int s = number.at(B.at(i)-1);
		number.at(B.at(i)-1)=0;
		number.at(C.at(i)-1)+= s;

	}


}






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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int s, w;
    cin >> s >> w;
    if (w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, m, x; cin >> n >> m >> x;
    ll cntl = 0, cntr = 0;
    rep(i, m){
        ll a; cin >> a;
        (a < x) ? cntl++ : cntr++;
    }
    cout << min(cntl, cntr) << endl;
}

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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> A(N);
	int now,ind = -1;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		if (ind < 0) {
			ind = i;
			now = A[i];
		}
		else if (A[i] < now) {
			ind = i;
			now = A[i];
		}
	}
	bool stop = false;
	while (!stop) {
		stop = true;
		int ni = ind;
		int nm = now;
		for (int i = 0; i < N; ++i) {
			if (A[i] != 0 && i != ind) {
				stop = false;
				A[i] %= now;
				if (A[i] != 0 && A[i] < nm) {
					ni = i;
					nm = A[i];
				}
			}
		}
		ind = ni;
		now = nm;
	}
	cout << now << endl;
	return 0;
}

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

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

    int N;
    cin >> N;
    int minP = INT_MAX;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int P;
        cin >> P;
        if (P <= minP) {
            minP = P;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> vec(n+1);
    for(int i=0;i<m;i++){
        int a;
        cin >> a;
        vec[a]++;
    }
    int ans1=0,ans2=0;
    for(int i=0;i<x;i++){
        ans1+=vec[i];
    }
    for(int i=x;i<n;i++){
        ans2+=vec[i];
    }
    int ans=min(ans1,ans2);
    cout << ans << endl;
}


Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
m=int(input())
s=0
for i in range(a+1):
  for j in range(b+1):
    x,y=divmod(m-i*500-j*100,50)
    if y==0 and 0<=x<=c:
      s+=1
print(s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int m,n,k,p;
int ans;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=4;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			int p=j%10,q=j/10;
			if (p>=2&&q>=2&&p*q==i) ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import math

n = input()
while n != 0:
    if n == 0:
        break
    tmp = map(float, raw_input().split())
    ave = 0
    for i in xrange(len(tmp)):
        ave += tmp[i] / n
    u = 0
    for i in xrange(n):
        u += (tmp[i] - ave)**2
    print "%.8f" % math.sqrt(u/n)
    n = input()

Measured memory_bytes: 6540
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.EducationalDP
{
    class K
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nk = ReadInts();
            int n = nk[0];
            int k = nk[1];
            int[] array = ReadInts();
            bool[] dp = new bool[k + 1];
            for(int i = array[0]; i <= k; i++)
            {
                bool win = false;
                for(int j = 0; j < n; j++)
                {
                    if (i - array[j] < 0) break;
                    if (!dp[i - array[j]])
                    {
                        win = true;
                        break;
                    }
                }
                dp[i] = win;
            }
            Console.WriteLine(dp[k] ? "First" : "Second");
        }

        private static string Read() { return Console.ReadLine(); }
        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: 13164
N, A = map(int, input().split())
x= [int(i) for i in input().split()]
X = max(x)
dp = [[[0]*(X*N+1) for i in range(N+1)] for j in range(N+1)]
dp[0][0][0] = 1
ans = 0

for j in range(1,N+1):
  for k in range(j+1):
    for s in range(X*N+1):
      dp[j][k][s] = dp[j-1][k][s]
      if s >= x[j-1]:
        dp[j][k][s] += dp[j-1][k-1][s-x[j-1]]
      
for i in range(N+1):
  ans += dp[-1][i][i*A]
  if (i+1)*A > X*N:
    break
print(ans-1)

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

static const int Max = 36;

struct Card {
	char suit;
	int value;
};

void BubbleSort(Card* C, int N) {
	for (int i = 0; i < N; ++i) {
		for (int j = N - 1; j > i; --j) {
			if (C[j].value < C[j - 1].value) {
				Card c = C[j];
				C[j] = C[j - 1];
				C[j - 1] = c;
			}
		}
	}
}

void SelectionSort(Card* C, int N) {
	for (int i = 0; i < N; ++i) {
		int minj = i;
		for (int j = i; j < N; ++j) {
			if (C[j].value < C[minj].value) {
				minj = j;
			}
		}
		Card c = C[i];
		C[i] = C[minj];
		C[minj] = c;
	}
}

void show(Card* C, int N) {
	for (int i = 0; i < N; ++i) {
		if (i > 0) { cout << ' '; }

		cout << C[i].suit << C[i].value;
	}
	cout << endl;
}

bool isStable(Card* C,Card* c, int N) {
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			for (int a = 0; a < N; ++a) {
				for (int b = a + 1; b < N; ++b) {
					if (C[i].value == C[j].value&&C[i].suit==c[b].suit&&C[i].value==c[b].value&&C[j].suit==c[a].suit&&C[j].value==c[a].value) {
						return false;
					}
				}
			}
		}
	}
	return true;
}

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

	Card C[Max];

	for (int i = 0; i < N; ++i) {
		cin >> C[i].suit >> C[i].value;
	}

	Card c1[Max];
	Card c2[Max];
	for (int i = 0; i < N; ++i) {
		c1[i] = C[i];
		c2[i] = C[i];
	}

	BubbleSort(c1, N);
	show(c1, N);
	if (isStable(C, c1, N)) { cout << "Stable" << endl; }
	else { cout << "Not stable" << endl; }

	SelectionSort(c2, N);
	show(c2, N);
	if (isStable(C, c2, N)) { cout << "Stable" << endl; }
	else {
		cout << "Not stable" << endl;
	}
	

	
}


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

using namespace std;

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

	vector<int> p(N);

	for (int i = 0; i < N; i++) 
	{
		cin >> p[i];
	}

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

	sort(p.begin(), p.end());

	int halfu, halfl;
	halfu = p[N / 2 - 1];
	halfl = p[N / 2];

	if (halfl != halfu) 
	{
		if (halfu == p[N / 2] && halfl == p[N / 2 + 1])
		{
			cout << halfl - halfu - 2 << endl;
		}
		else if (halfu != p[N / 2] && halfl != p[N / 2 + 1])
		{
			cout << halfl - halfu << endl;
		}
		else
		{
			cout << halfl - halfu << endl;
		}
		return 0;
	}

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

Measured memory_bytes: 640
import sys
import numpy as np

read = sys.stdin.read
readline = sys.stdin.readline

N, *S = map(str, read().split())
S = np.array(list(map(list, S)), np.str)
S = np.hstack((S, S))
S = np.vstack((S, S))
N = int(N)
answer = 0
for y in range(N):
    for i in range(N):
        a = S[i, y:y + N]
        b = S[:N, i + y]
        if np.any(a != b):
            break
    else:
        answer += N

print(answer)


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

using namespace std;

int main(){
	string in_str;
	string out_str;
	cin >> in_str;
	for(int i = in_str.size() - 1; i >= 0; i--){
		out_str += in_str[i];
	}
	cout << out_str << endl;
	return 0;
}

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

int main()
{
    int a,b,c,n;
    
    string s;
    
    cin >> s;
    
    if(s=="Sunny")cout << "Cloudy" << endl;
    
    else if(s=="Cloudy")cout << "Rainy" << endl;
    
    else cout << "Sunny" << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
int main(){
	ll val;
	vector< ll > from,to,cost;
	cin>>val;
	ll cnt = 0, cur =1;
	while(cur*2<=val){
		cur = cur *2;
		cnt++;
	}
	ll n = cnt+1;
	ll m=0;
	for(int i=1;i<=n-1;i++){
		from.pb(i);to.pb(i+1);cost.pb(0);m++;
		from.pb(i);to.pb(i+1);cost.pb( (1<<(i-1)) );m++;
	}
	ll c = val - 1;
	for(int i=n-1;i>=1;i--){
		if( c - (1<<(i-1))+1 >= (1<<(n-1)) ){
			from.pb(i);to.pb(n);cost.pb(c - (1<<(i-1))+1);m++;
			c = c-(1<<(i-1));
		}
	}
	cout<<n<<" "<<m<<endl;
	for(int i=0;i<m;i++){
		cout<<from[i]<<" "<<to[i]<<" "<<cost[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll a,ll b,ll c)
{
	ll clen;
	if(a%c==0&&b%c==0)
	{
		clen=b/c-a/c+1;
	}
	else if(a%c!=0)
	{
		clen=b/c-a/c;
	}
	else if(b%c!=0)
	{
		clen=b/c-a/c+1;
	}
	else
	{
		clen=b/c-a/c;
	}
	return clen;
}
ll gcd(ll m,ll n)
{  
 	if (m < n)
	{
		ll tmp = m;
		m = n;
		n = tmp;
	}
	if (n == 0)
		return m;
	else
		return gcd(n,m % n);
}
int main()
{
	ll a,b,c,d;
	ll x,y,z;
	cin>>a>>b>>c>>d;
	x=f(a,b,c);
	y=f(a,b,d);
	ll cd=(c*d)/gcd(c,d);
	z=f(a,b,cd);
	cout<<(b-a+1)-(x+y-z);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);
static const int MAX = 2005;

string S[MAX];
int ans[MAX][MAX];
int H, W;

int main() {
  cin >> H >> W;
  rep(i, H) cin >> S[i];

  rep(i, H) {
    bool flag = false;
    int tmp;
    rep(j, W) {

      if (S[i][j] == '.') {
        if (!flag) {
          flag = true;
          tmp = j;
        }
      } else {
        if (flag) {
          for (int k = tmp; k < j; k++) {
            ans[i][k] = j - tmp;
          }
        }
        ans[i][j] = 0;
        flag = false;
      }
      if (j == W - 1 && flag) {
        for (int k = tmp; k <= j; k++) {
          ans[i][k] = j - tmp + 1;
        }
      }

      if (j == W - 1) flag = false;

    }
  }

  int res = 0;
  rep(j, W) {
    bool flag = false;
    int tmp;
    rep(i, H) {
      if (S[i][j] == '.') {
        if (!flag) {
          flag = true;
          tmp = i;
        }
      } else {
        if (flag) {
          for (int k = tmp; k < i; k++) {
            ans[k][j] += i - tmp;
          }
        }
        ans[i][j] = 0;
        flag = false;
      }

      if (i == H - 1 && flag) {
        for (int k = tmp; k <= i; k++) {
          ans[k][j] += i - tmp + 1;
        }
      }

      res = max(res, ans[i][j] - 1);

      if (i == H - 1) flag = false;


    }
  }

  rep(i, H) {
    rep(j, W) {
      res = max(res, ans[i][j] - 1);
    }
  }


  cout << res << endl;

  return 0;
}

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



int main() {
    int n, r;
    cin >> n >> r;
    
    if(n < 10)
        cout << r + 100 * (10 - n) << endl;
    else
        cout << r << endl;
    
    
    return 0;
}




Measured memory_bytes: 3572
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] b = new int[a];
        int count = 0;
        for (int i = 0; i < a; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 1; i < a - 1; i++) {
            if (b[i] > b[i - 1] && b[i] < b[i + 1]) {
                count++;
            } else if (b[i] < b[i - 1] && b[i] > b[i + 1]) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){ 
    string s, t; cin >> s >> t;
    int a, b; cin >> a >> b;
    string u; cin >> u;
    if(s == u)cout << a - 1 << " " << b << endl;
    else cout << a << " " << b - 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
int main(){
    ll n,ans=0;
    cin>>n;
    for(ll i=1;i*i<n;i++){
        ll tmp=(n-i)/i;
        if(n/tmp==n%tmp)ans+=tmp;
    }
    cout<<ans;
}

Measured memory_bytes: 256
N=int(input())
t=[]
x=[]
y=[]
for i in range(N):
    t1, x1, y1=map(int, input().split())
    t.append(t1)
    x.append(x1)
    y.append(y1)
for j in range (N):
    if t[j]%2==(x[j]+y[j])%2 and x[j]+y[j]<=t[j]:
        continue
    else:
        print('No')
        exit()
print('Yes')

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

using namespace std;

#define EPS 1e-9
#define For(i,N) FOR(i,N)
#define Forr(i,a,b) FORR(i,a,b)
#define Fotr(i,a,b,c) FOTR(i,a,b,c)
#define FOR(i,N) FORR(i, 0, N)
#define FORR(i,a,b) FOTR(i, a, b, 1)
#define FOTR(i,a,b,c) for(int i=(a);i<(b);i+=(c))
#define FOREACH(i,x) for(__typeof__((x).begin())i=(x).begin();i!=(x).end();i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define BCHK(a,x) (((a)>>(x))&1)
#define BSET(a,x) ((a)|(1<<(x)))
#define BCLR(a,x) ((a)&(~(1<<(x))))
#define BTGL(a,x) ((a)^(1<<(x)))
#define FMT(...) (sprintf(CRTBUFF, __VA_ARGS__)?CRTBUFF:0)
#define read() freopen("input.txt","r",stdin)
#define write() freopen("output.txt","w",stdout)
#define cpp_io() {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define BUFFSIZE 30000
#define INF 1000000000
#define MAX 300010
#define MOD 1000000007
#define pb push_back
#define mkpr make_pair
#define pii pair<int, int>
#define PI acos(-1)
#define ll long long
#define fi first
#define si second
#define all(x) x.begin(), x.end()
#define double long double

char CRTBUFF[BUFFSIZE];
#define dbg(args...) {cerr<<"-->";debugger::call(#args,args);cerr<<"\n";}
struct debugger {
    static void call(const char* it) {}
    template<typename T, typename ... aT>
    static void call(const char* it, T a, aT... rest) {
        string b;
        for (; *it&&*it != ','; ++it) if (*it != ' ')b += *it;
        cerr << b << "=" << a << " ";
        call(++it, rest...);
    }
};

ll A[1000];
ll B[1000];

int main(){
    cpp_io();
    #ifdef LOCAL
        read();
        //write();
    #endif

    string s;

    B['M'] = 0;
    B['A'] = 1;
    B['R'] = 2;
    B['C'] = 3;
    B['H'] = 4;

    int n;
    cin>>n;
    while(n--){
        cin>>s;
        if(s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H'){
            A[B[s[0]]]++;
        }
    }
    ll ans = 0;
    int lim = 1<<5;
    FOR(i, lim){
        if(__builtin_popcount(i) == 3){
            int j = 1, k = 0;
            ll t = 1;
            FOR(x, 5){
                if(i&j) t *= A[k];
                j<<=1;
                k++;
            }
            //dbg(i, t);
            ans += t;
        }
    }
    cout<<ans<<endl;

}





















Measured memory_bytes: 256
n=int(input());s=[list(map(int,input().split())) for _ in range(int(n*(n-1)/2))];p=[0]*n
for a,b,c,d in s: 
    if c>d:p[a-1]+=3 
    elif c<d:p[b-1]+=3 
    else:p[a-1]+=1;p[b-1]+=1
r=sorted(p,reverse=True)
for q in p:print(r.index(q)+1)

Measured memory_bytes: 7496
/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/
 
#include <bits/stdc++.h>
using namespace std;
 
const int mx=1e5+5;
vector <int> tree[mx];
int cnt,level[mx],dist[mx];
bool vis[mx];
void bfs1 ()
{
    memset(vis,0,sizeof(vis));
    queue<int> myQ;
    myQ.push(1);
    level[1]=0;
    vis[1]=true;
    int m;
    while (!myQ.empty()) {
        int u=myQ.front();
        myQ.pop();
        m=tree[u].size();
        for (int i=0;i<m;i++) {
            int v=tree[u][i];
            if (vis[v]) continue;
            vis[v]=true;
            level[v]=1+level[u];
            myQ.push(v);
        }
    }
}
void bfs2(int n)
{
    memset(vis,0,sizeof(vis));
    queue<int> myQ;
    myQ.push(n);
    dist[n]=0;
    vis[n]=true;
    int m;
    while (!myQ.empty()) {
        int u=myQ.front();
        if (dist[u]<level[u]) cnt++;
        myQ.pop();
        m=tree[u].size();
        for (int i=0;i<m;i++) {
            int v=tree[u][i];
            if (vis[v]) continue;
            vis[v]=true;
            dist[v]=1+dist[u];
            myQ.push(v);
        }
    }
}
int main ()
{
    int i,n,a,b;
 
    scanf ("%d",&n);
    for (i=1;i<n;i++) {
        scanf ("%d %d",&a,&b);
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    bfs1();
    bfs2(n);
    int m=n-cnt;
    if (m>cnt) printf ("Fennec\n");
    else printf("Snuke\n");
 
    return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M;
  cin >> N >> M;
  comb_init();
  auto vec = prime_factorize(M);
  ll res = 1;
  for(auto pa:vec){
    int num = pa.second;
    ll tmp = comb(num+N-1,num);
    res = (res * tmp) % MOD;
  }
  cout << res << endl;
}


Measured memory_bytes: 12160
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct UnionFind {
    vector<int> id;
    vector<vector<int> > groups;
    int gn; //number of groups
    UnionFind(int n){
        id = vector<int>(n);
        groups = vector<vector<int> >(n);
        gn = n;
        for(int i=0;i<n;++i){
            id[i]=i;
            groups[i]={i};
        }
    }
    void unite(int a, int b) {
        if(same(a,b)) return;
        gn--;
        int x = id[a];
        int y = id[b];
        if(groups[x].size()<groups[y].size()) swap(x,y);
        for(int j : groups[y]){
            id[j] = x;
            groups[x].push_back(j);
        }
        groups[y].clear();        
    }
    bool same(int a, int b) {
        return id[a] == id[b];
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    REP(i,m){
        int x,y,z;
        cin >> x >> y >> z;
        x--;
        y--;
        uf.unite(x,y);
    }
    cout << uf.gn << endl;

    return 0;
}

Measured memory_bytes: 9720
N = int(input())
s = []
for _ in range(N):
    s.append(int(input()))
S=sum(s)
candicate=[S]
for i in range(N):
    candicate.append(S-s[i])

candicate=[val for val in candicate if val % 10 != 0]

if candicate:
    print(max(candicate))
else:
    print(0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  int Q;
   cin >> S >> Q ;
  int i;
  vector<vector<int>> dataT(Q, vector<int>(1));
  vector<vector<int>> dataF(Q, vector<int>(1));
  vector<vector<char>> dataC(Q, vector<char>(1));
  for(i=0;i<Q;i++){
    cin >> dataT.at(i).at(0);
    //cout << dataT.at(i).at(0) << endl;
    if(dataT.at(i).at(0) == 2){
    cin >> dataF.at(i).at(0);
      cin >> dataC.at(i).at(0);
     //cout << dataF.at(i).at(0) << endl;
    //cout << dataC.at(i).at(0) << endl;
    }else{
    dataF.at(i).at(0)= 0;
      dataC.at(i).at(0)= '0';
      //cout << dataF.at(i).at(0) << endl;
    //cout << dataC.at(i).at(0) << endl;
    }
  }
  int joutai;
  joutai = 1;
  
  deque<char> ushiro;
  deque<char> mae;
  //ushiro.push(1);
 
  
  
  for(i=0;i<Q;i++){
    if(dataT.at(i).at(0)==1){
     joutai = joutai * (-1);
                            } else{
    if(dataF.at(i).at(0)== 1){
      if(joutai == 1){/*S = dataC.at(i).at(0) +S*/ mae.push_front(dataC.at(i).at(0));}
      else{/*S = S + dataC.at(i).at(0)*/ushiro.push_back(dataC.at(i).at(0));}     
                             }else{
      if(joutai == 1){/*S = S + dataC.at(i).at(0)*/ushiro.push_back(dataC.at(i).at(0));}
      else{/*S = dataC.at(i).at(0) +S*/ mae.push_front(dataC.at(i).at(0));} 
                             }                             
                                  }
                             }  
 
  
   if(joutai == 1 ) {
     // 空でない間繰り返す
  while (!mae.empty()) {
    cout << mae.front();  // 先頭の値を出力
    mae.pop_front();  // 先頭の値を削除
  }
     cout << S;
    // 空でない間繰り返す
  while (!ushiro.empty()) {
    cout << ushiro.front();  // 先頭の値を出力
    ushiro.pop_front();  // 先頭の値を削除
  }   
   }
  else{
    while (!ushiro.empty()) {
    cout << ushiro.back();  // 先頭の値を出力
    ushiro.pop_back();  // 先頭の値を削除
  }   
    for(i=S.size()-1;i>-1;i--){
    cout << S.at(i) ;
  }
    while (!mae.empty()) {
    cout << mae.back();  // 先頭の値を出力
    mae.pop_back();  // 先頭の値を削除
  }       
  }
}                  
  
  


Measured memory_bytes: 33664
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT=mp::cpp_int;
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
INT LCM(INT x,INT y){
  INT z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
INT modinv(INT a, INT m) {
    INT b = m, u = 1, v = 0;
    while (b) {
        INT t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
  cout << fixed << setprecision(30);
  ll n;
  cin>>n;
  vector<INT> a(n);
  loop(i,n)cin>>a[i];
  INT exa=1;
  loop(i,n)exa=LCM(exa,a[i]);
  INT ans=0;
  INT d=exa%1000000007;
  loop(i,n){
    ans+=d*modinv(a[i],1000000007)%1000000007;
  }
  putout(ans%1000000007);
}


Measured memory_bytes: 848
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int A = nextInt();
		int B = nextInt();
		int C = nextInt();
		int D = nextInt();
		System.out.println(Math.min(A, B)+Math.min(C, D));

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

int main(){
    string a, b;
    cin >> a >> b;

    string c = a + b;

    int ci = stoi(c);
    if(ci % int(sqrt(ci)) == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
A, B, C, D = gets.split.map(&:to_i)
#x/C.lcm(D) = (x==9の時)9
#数学力?
def calc(x)
    x - x/C - x/D + x/C.lcm(D)
end
#求める解はBまでの解からA-1までの解を引いたもの;
puts calc(B) - calc(A-1)

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
#include <iostream>
using namespace std;

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mpl = boost::multiprecision;

using Bint = mpl::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mpl::number<mpl::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  Real a;
  Real b;
  cin >> a >> b;
  Real c = a * b;
  cout << (ll)floor(c) << endl;
}
//////////////////////////////////////////////



Measured memory_bytes: 3912
MOD = 10 ** 9 + 7


class ModInt:

    def __init__(self, x):
        self.x = x.x if isinstance(x, ModInt) else x % MOD

    def __str__(self): return str(self.x)
    __repr__ = __str__

    def __int__(self): return self.x
    __index__ = __int__

    def __add__(self, other): return ModInt(self.x + ModInt(other).x)

    def __sub__(self, other): return ModInt(self.x - ModInt(other).x)

    def __mul__(self, other): return ModInt(self.x * ModInt(other).x)

    def __pow__(self, other): return ModInt(pow(self.x, ModInt(other).x, MOD))

    def __truediv__(self, other): return ModInt(
        self.x * pow(ModInt(other).x, MOD - 2, MOD))

    def __floordiv__(self, other): return ModInt(self.x // ModInt(other).x)

    def __radd__(self, other): return ModInt(other + self.x)

    def __rsub__(self, other): return ModInt(other - self.x)

    def __rpow__(self, other): return ModInt(pow(other, self.x, MOD))

    def __rmul__(self, other): return ModInt(other * self.x)

    def __rtruediv__(self, other): return ModInt(
        other * pow(self.x, MOD - 2, MOD))

    def __rfloordiv__(self, other): return ModInt(other // self.x)

    def __lt__(self, other): return self.x < ModInt(other).x

    def __gt__(self, other): return self.x > ModInt(other).x

    def __le__(self, other): return self.x <= ModInt(other).x

    def __ge__(self, other): return self.x >= ModInt(other).x

    def __eq__(self, other): return self.x == ModInt(other).x

    def __ne__(self, other): return self.x != ModInt(other).x


def cmb(n, r):  # nCr = n!/(n-r)!r!
    retVal = ModInt(1)
    for i in range(n-r+1, n+1):
        retVal *= i
    for i in range(2, r+1):
        retVal /= i
    return retVal


n, a, b = map(int, input().split())


def twopow(p):
    if p == 0:
        return ModInt(1)
    if p % 2 == 0:
        t = twopow(p // 2)
        return t * t
    return 2 * twopow(p - 1)


nC = [ModInt(1)]
for i in range(1, 200005):
    nC.append(nC[-1] * (n - i + 1) / i)

print((twopow(n) - nC[a] - nC[b] - 1))
# print((twopow(n) - cmb(n, a) - cmb(n, b)-1))


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const double PI = acos(-1);

//const int MAX_W = 101010;
//ll dp[101][MAX_W] = { 0 };

const int MAX_NN = 101;
const int MAX_V = 101010;
ll dp[MAX_NN][MAX_V];

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

	ll N, W;
	cin >> N >> W;

	vector<ll> w(N), v(N);
	rep(i, N) {
		cin >> w[i] >> v[i];
	}

	//重さW(10^5)
	//rep(i, N) {
	//	for (int sum_w = 0; sum_w <= W; sum_w++) {
	//		//i番目の品物を選ぶ場合
	//		if (sum_w - w[i] >= 0) {
	//			chmax(dp[i + 1][sum_w], 
	//				dp[i][sum_w - w[i]] + v[i]);
	//		}

	//		//i番目の品物を選ばない場合
	//		chmax(dp[i + 1][sum_w], dp[i][sum_w]);
	//	}
	//}
	//
	//out(dp[N][W]);

	for (int i = 0; i < MAX_NN; i++) {
		for (int j = 0; j < MAX_V; j++) {
			dp[i][j] = INF;
		}
	}

	dp[0][0] = 0;

	//重さ(10^9)
	rep(i, N) {
		for (int sum_v = 0; sum_v < MAX_V; sum_v++) {
			//i番目の品物を選ぶ場合
			if (sum_v - v[i] >= 0) {
				chmin(dp[i + 1][sum_v], 
					dp[i][sum_v - v[i]] + w[i]);
			}

			//i番目の品物を選ばない場合
			chmin(dp[i + 1][sum_v], dp[i][sum_v]);
		}
	}

	ll res = 0;
	for (int sum_v = 0; sum_v < MAX_V; sum_v++) {
		if (dp[N][sum_v] <= W) {
			res = sum_v;
		}
	}

	out(res);

	return 0;
}

Measured memory_bytes: 80000
import sys
sys.setrecursionlimit(10000000)
readline = sys.stdin.readline

N , Q = map(int,readline().rstrip().split())
G = [[] for _ in range(N)]
for n in range(N-1):
    a , b = map(int,readline().rstrip().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
query = [0] * N
for q in range(Q):
    p , x = map(int,readline().rstrip().split())
    query[p-1] += x
counter = [0] * N 
visit = [0] * N

def dfs(root , x ):
    if visit[root] == 0:
        visit[root] = 1
        x += query[root]
        counter[root] += x
    else:
        return 0
    
    for g in G[root]:
        dfs( g, x )

    return 0

def solve():
    dfs(0 , 0)
    [print(c , end = " " ) for c in counter]
    print("")

if __name__ == "__main__":
    solve()

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

	typedef long long ll;
	using namespace std;

	int main(){
		string s;
		cin >> s;
		stack <char> st;
		ll count = 0;
		for(ll i=0; i < s.size(); i++){
			char c;
			c = s[i];
			if(st.size() == 0){
				st.push(c);
			}else{
				if((c == '1'  && st.top() == '0' )  || (c == '0' && st.top() == '1') ) {
					st.pop();
					count += 2;
				}else{
					st.push(c);
				}
			}
		}
		cout << count <<endl;
		return 0;
	}

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

typedef long long ll;

int n;
int a[200005];
map<int,int> mp;
ll tot;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
        tot+=((ll)it->second)*(it->second-1)/2;
    }
    for(int i=1;i<=n;i++){
        cout<<tot-mp[a[i]]+1<<'\n';
    }

    return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll x,k,d,ans;
signed main(){
	cin>>x>>k>>d;
	x=abs(x);
	ll calc=floor((long double)x/d);
	if(k<=calc){
		ans=x-k*d;
		cout<<ans<<endl;return 0;
	}
    ll num1=x-calc*d;k-=calc;
    ll num2=num1-d;num1=abs(num1),num2=abs(num2);
    if(num1>=num2){
    	k--;swap(num1,num2);
	}
    if(k%2==0)cout<<abs(num1)<<endl;
    if(k%2==1)cout<<abs(num2)<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;

struct Node{
    int key;
    Node *right,*left,*parent;
};

Node *root,*NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    if(y == NIL){
        root = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    string com;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        cin >> com;
        if(com == "insert"){
            scanf("%d",&x);
            insert(x);
        }else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 26716