akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main() {
  int i = 0;
  int total = 0;
  int point = 0;
  for(i = 0; i < 5; ++i) {
    scanf("%d", &point);
    (point < 40) ? (total += 40) : (total += point);
  }
  printf("%d\n", total / 5);
  return 0;
}

Measured memory_bytes: 600
n,a,b,*h=map(int,open(0).read().split());i,j=0,-(-max(h)*n//a)
while j-i>1:
 k=c=(j+i+1)//2
 for t in h:c+=min(0,(b*k-t)//(a-b))
 if c>=0:j=k
 else:i=k
print(j)

Measured memory_bytes: 14092
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().run();
	}
	public int maximum(int a,int b){
		return (a > b)?a:b;
	}
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int D = scan.nextInt();
			int[] w = new int[20];
			int[] v = new int[20];
			int p = 0;
			int x = scan.nextInt();
			for(int i = 0;i < x;i++){
				w[i] = 1;
				v[i] = (scan.next().equals("D"))?scan.nextInt():0*scan.nextInt();
			}
			p = x;
			int y = scan.nextInt();
			for(int i = 0;i < y;i++){
				w[i+p] = 2;
				v[i+p] = (scan.next().equals("DD"))?scan.nextInt():0*scan.nextInt();
			}
			p+=y;
			int[] dp = new int[D+1];
			for(int i = 0;i < p;i++){
				for(int j = D;j >= w[i];j--){
					dp[j] = maximum(dp[j],dp[j-w[i]] + v[i]);
				}
			}
			System.out.println(dp[D]);
		}
	}
}

Measured memory_bytes: 17372
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict

def main():
    N = II()
    xy = []
    for _ in range(N):
        xy.append(LI())
    xy2g = defaultdict(int)
    g2xy = defaultdict(set)
    for x, y in xy:
        y = -y
        gx = xy2g[x]
        gy = xy2g[y]
        if gx == gy != 0:
            continue
        elif gx != 0 and gy != 0:  # merge
            if len(g2xy[gx]) < len(g2xy[gy]):
                gx, gy = gy, gx
            for xy in g2xy[gy]:
                xy2g[xy] = gx
            g2xy[gx] |= g2xy[gy]
            g2xy[gy].clear()
        else:
            g = gx or gy or x
            xy2g[x] = xy2g[y] = g
            g2xy[g] |= {x, y}
    ans = -N
    for xys in g2xy.values():
        nx = sum(xy > 0 for xy in xys)
        ny = len(xys) - nx
        ans += nx * ny
    return ans

print(main())

Measured memory_bytes: 114524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
/*
ll modpow(ll x,ll y,ll mod){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}*/
long long modpow( long long a,  long long n,  long long mod) {
    long long res = 1;
    for(ll i=0;i<n;i++){
        res=res*a%mod;
    }
    return res;
}
int main(){
    ll N;
    cin>>N;
    ll ans=(modpow(10,N,1000000007)-2*modpow(9,N,1000000007)%1000000007+modpow(8,N,1000000007))%1000000007;
    ans%=1000000007;
    ans=(ans+1000000007)%1000000007;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  scanf("%d",&n);
  if(n==25)
    printf("Christmas");
  else if(n==24)
    printf("Christmas Eve");
  else if(n==23)
    printf("Christmas Eve Eve");
  else if(n==22)
    printf("Christmas Eve Eve Eve");
  return 0;
}  

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(),c = sc.nextInt(), d = sc.nextInt();
		System.out.println(Math.min(a, b)+Math.min(c, d));
	}
}

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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
#define MAX_C 2001

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

int n, k;

llint Com[MAX_C][MAX_C];

void calc_com()
{
    memset(Com, 0, sizeof(Com));
    Com[0][0] = 1;
    for (int i = 1; i < MAX_C; ++i) {
        Com[i][0] = 1;
        for (int j = 1; j < MAX_C; ++j) {
            Com[i][j] = (Com[i-1][j-1] + Com[i-1][j]) % MOD;
        }
    }
}

int main()
{
    ci >> n >> k;

    calc_com();
    
    rep(i, 1, k + 1) {
	llint cnt = 0;
	
	int red = n - k;
	int blue = i;
	int free_blue = k - i;

	if(blue - 1 > red) {
	    co << 0 << en;
	    continue;
	}

	red -= blue - 1;
	
	co << Com[red + blue][blue] * Com[blue - 1 + free_blue][blue - 1] % MOD << en;
    }
    
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	string t;
	vi pos, xpos;
	REP(i, s.size()) {
		if (s[i] != 'x') {
			t += s[i];
			pos.push_back(i);
		}
		else {
			xpos.push_back(i);
		}

	}
	int flag = 1;
	
	REP(i, t.size() / 2)if (t[i] != t[t.size() - 1 - i])flag = 0;
	if (!flag)cout << "-1" << endl;
	else {
		int cnt1 = 0, cnt2 = 0;
		REP(i, (s.size()+cnt1+cnt2)/2) {
			if (s[i-cnt1] != s[n + cnt2 - i - 1]) {
				if (s[i-cnt1] == 'x')cnt2++;
				else if (s[n + cnt2 - i - 1] == 'x')cnt1++;
				else abort();
			}
		}
		cout << cnt1 + cnt2 << endl;
	}
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    Int x = 26;
    Int cnt = 1;
    string s = "";
    while (true) {
        if (n <= x) {
            n--;
            for (Int i = 0; i < cnt; i++) {
                s = (char)('a' + (n % 26)) + s;
                n /= 26;
            }
            break;
        } else {
            n -= x;
            x *= 26L;
            cnt++;
        }
    }
    print(s);
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int a;
	cin >> a;

	string s;
	cin >> s;

	if (a < 3200)
	{
		cout << "red";
	}
	else
	{
		cout << s;
	}

	return 0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
Int printX(Int r, Int D, Int X, int count){
    if(count == 10){
        return 0;
    }
    Int nextX = r*X - D;
    cout<< nextX <<endl;
    printX(r,D,nextX,count+1);

}

int myPow(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    return x * myPow(x, p-1);
}

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

    char dict[52] = {
            'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
            'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
    };

    string ans = "";

    rep(i,S.size()){
        rep(j,52){
            if (S[i] == dict[j]){
                ans = ans + dict[j+N];
                break;
            }
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true
n = gets.to_i
v = gets.split.map &:to_f
v.sort!
sum = (v[0] + v[1]) / 2.0
if v.size > 2
  (2..n - 1).each do |i|
    sum = (sum + v[i]) / 2.0
  end
end
puts sum

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

int main()
{
    std::string S;
    std::cin >> S;

    int N = S.size();
    int left, right;
    bool flag = true;
    bool flag_l = true;
    bool flag_r = true;

    left = 0;
    right = S.size() - 1;
    while (right - left > 0)
    {
        if (S[left] != S[right])
        {
            flag = false;
            break;
        }
        left++;
        right--;
    }

    left = 0;
    right = (N - 1) / 2 - 1;
    while (right - left > 0)
    {
        if (S[left] != S[right])
        {
            flag_l = false;
            break;
        }
        left++;
        right--;
    }

    left = (N + 3) / 2 - 1;
    right = N - 1;
    while (right - left > 0)
    {
        if (S[left] != S[right])
        {
            flag_r = false;
            break;
        }
        left++;
        right--;
    }

    if (flag == true && flag_l == true && flag_r == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000001
#define ll long long
using namespace std;
using pll = pair<ll, ll>;



int main()
{
  string S, T;
  cin >> S >> T;
  // cout << S << endl;
  // cout << T << endl;
  for (ll i = S.size() - T.size(); i >= 0; --i)
  {
    if (S[i] == T[0] || S[i] == '?')
    {
      // cout << "in" << endl;
      // cout << S[i] << endl;
      bool ok = true;
      for (ll j = 0; j < T.size(); ++j)
      {
        if (T[j] == S[i + j] || S[i + j] == '?')
        {
          continue;
        }
        ok = false;
      }
      if (ok)
      {
        for (ll j = 0; j < T.size(); ++j)
        {
          S[i + j] = T[j];
        }
        for (ll j = 0; j < S.size(); ++j)
        {
          if (S[j] == '?')
          {
            cout << 'a';
          }
          else
          {
            cout << S[j];
          }
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << "UNRESTORABLE" << endl;
}
// ??tc?????
// coder


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            //bool ret = false;
            //var read = c2i(RL());
            var KN = spr(RL()).Select(x => c2i(x)).ToList();
            var AList = spr(RL()).Select(x => c2i(x)).ToList();
            var NextList = new List<int>();
            for (int i = 0; i < KN[1] - 1; i++)
            {
                NextList.Add(AList[i + 1] - AList[i]);
            }
            NextList.Add(KN[0] - AList.Last()+AList.First());
            NextList.Sort();
            int ret = KN[0] - NextList.Last();

            Console.WriteLine(ret);
            //Console.ReadLine();


        }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static int c2i(string c) { return int.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 34780
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll a[100001] = {};
ll b[100001] = {};
int main() {
	ll n, h; cin >> n >> h;
	ll maxA = 0;
	rep(i, 0, n) {
		cin >> a[i] >> b[i];
		maxA = max(maxA, a[i]);
	}
	sort(b, b + n);
	reverse(b, b + n);

	ll ans = 0;
	rep(i, 0, n) {
		if (maxA <= b[i]) {
			ans++;
			h -= b[i];
			if (h <= 0) {
				cout << ans << endl;
				return 0;
			}
		}
		else {
			break;
		}
	}
	if (h % maxA != 0) {
		ans++;
	}
	ans += h / maxA;

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

Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	int n = s.size();
	int cnt = 0;
	int ans = 0;
	rep(i, n){
		if(s[i] == 'S') cnt++;
		else{
			if(cnt) cnt--;
			else ans++;
		}
	}
	cnt = 0;
	for(int i = n - 1; i >= 0; i--){
		if(s[i] == 'T') cnt++;
		else{
			if(cnt) cnt--;
			else ans++;
		}
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main(){
  int count =0;
  int n,m;
  cin >> n >> m;
  
  vector<uint64_t> h(n);
  for(auto &it: h){
    cin >> it;
  }
  
  vector<vector<int>> v(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a>>b;
    a--; b--;
    v.at(a).push_back(b);
    v.at(b).push_back(a);
  }
  
  for(int i=0; i<n;i++){
    bool good=true;
    for(int j=0; j<v.at(i).size(); j++){
      if(h.at(i)<=h.at( v.at(i).at(j) ) )
         good = false;
    }
    if(good)  count ++;
  }
         cout << count <<endl;
}


Measured memory_bytes: 8940
import math as m
N = int(input())
F_ab = 0
for i in range(1, int(m.sqrt(N))+1):
    if N%i != 0:
        continue
    if i == 1:
        F_ab = len(str(N//i))
    else:
        F_ab = min(F_ab, max(len(str(i)), len(str(N//i))))

print(F_ab)


Measured memory_bytes: 39152
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;

}

P dequeue(){
  P x = Q[head];
  head = (head+1) % LEN;
  return x;

}

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

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1; tail = n + 1;

  while(head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;

    if(u.t > 0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  
  return 0;
}

Measured memory_bytes: 10756
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(a))
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	ll n,ans=0;
	cin>>n;
	for(ll i=1;i*i<=n;i++) if((n-i)%i==0&&(n-i)/i>i)ans+=(n-i)/i;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long k=sc.nextInt();
		int ans=0;
		while(n>0){
			ans++;
			n/=k;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
int n,c,cnt,L[10];
double Ans,dp[500][1<<7];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),c=read();
	for(int i=0;i<n;i++)L[i]=read();sort(L,L+n);
	while(true){
		memset(dp,0,sizeof(dp)),cnt++;
		dp[L[n-1]*n][0]=1;
		for(int i=0;i<=n*c;i++)
		for(int j=i;j<=n*c;j++)
		for(int S=0;S<(1<<n-1);S++){
			int k=i%n;
			if(!k||(S>>k-1&1))continue;
			int t=min(n*c,max(j,i+L[k-1]*n));
			dp[t][S|(1<<k-1)]+=dp[j][S];
		}Ans+=dp[n*c][(1<<n-1)-1];
		if(!next_permutation(L,L+n-1))break;
	}
	printf("%.15lf",Ans/cnt/pow(c,n-1));
	return 0;
}


Measured memory_bytes: 4652
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                           //     #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };
int a[60];
           signed main(){
        
           	int m,n;
           	cin>>n>>m;
           	for(int i=0;i<n;i++)cin>>a[i];
           	sort(a,a+n);
           	int ans=0;
           	for(int i=n-m;i<n;i++)ans+=a[i];
           	cout<<ans<<endl;
           	
           	return 0;
           	
           	
           }
             

Measured memory_bytes: 256
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>

int main()
{   long long p,n,base=1,ans;
    scanf("%lld%lld",&n,&p);
    if(n==1){
        printf("%lld",p);
        return 0;
    }
    while(pow(base,n)<=p){
        if(p%(long long)(pow(base,n))==0){
            ans=base;
        }
        base++;
    }
    
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>

int main() {
	int n;

	std::cin >> n;

	long long ans = 180;

	for (size_t i = 3; i < n; i++)
	{
		ans += 180;
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n,m=map(int,input().split())
lst=[]
for i in range(n):
    lst.append(list(map(int,input().split())))
    del lst[i][0]
ans=[flatten for inner in lst for flatten in inner]
a=Counter(ans)
count=0
result=list(a.values())
for i in result:
    if i==n:
        count += 1
print(count)

Measured memory_bytes: 3316
import java.util.*;

public class Main {

    class Node {
        int value;
        Node parent, left, right;

        public Node(int value) {
            this.value = value;
        }
    }

    Node root;
    void insert(Node z) {
        Node y = null;
        Node x = root; // nodesの根
        while (x != null) {
            y = x;
            if (z.value < x.value) {
                x = x.left;
            } else {
                x = x.right;
            }
        }
        z.parent = y;

        if (y == null) {
            root = z;
        } else if (z.value < y.value) {
            y.left = z;
        } else {
            y.right = z;
        }
    }

    void print() {
        inorder(root);
        System.out.println();
        preorder(root);
        System.out.println();
    }

    void inorder(Node node) {
        if (node == null) return;
        inorder(node.left);
        System.out.print(" " + node.value);
        inorder(node.right);
    }
    void preorder(Node node) {
        if (node == null) return;
        System.out.print(" " + node.value);
        preorder(node.left);
        preorder(node.right);
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();

        for (int i = 0; i < m; i++) {
            switch(sc.next()) {
                case "insert":
                    int val = sc.nextInt();
                    insert(new Node(val));
                    break;
                case "print":
                    print();
            }
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }

}


Measured memory_bytes: 205116
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };

//AAAAAAAAAAAAAAAAAAAAAAAAAAAA

int main() {
	int A,B;
	scanf("%d%d", &A,&B);

	
	


	printf("%d",max(A*B ,max(A+B,A-B) ));

}





/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
・文字列の＜＜スペル＞＞は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
#include <iostream> 
using namespace std;
 int main() { 
long long a,b,x,count=0;
 cin>>a>>b>>x;
 if(a==0) { 
count=(b/x)+1; 
} 
else {
 count=(b/x)-(a-1)/x;
 } 
cout<<count;
 return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a;
int main()
{
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&a);
		if((a&1)==0)if(a%3&&a%5)
		{
			puts("DENIED");
			return 0;
		}
	}
	puts("APPROVED");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    int T, A;
    cin >> T >> A;

    int dmax = 1000000;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        int temp = T*1000 - x*6;
        int d = abs(A*1000-temp);
        if (d < dmax) {
            dmax = d;
            ans = i+1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
   int n, sum = 0; cin >> n;
	string S; cin >> S;
	for(int i = 1; i < n - 1; i++)
		if(S[i - 1] == 'A' && S[i] == 'B' && S[i + 1] == 'C')
			sum++;
	cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<tr1/unordered_set>
#include<tr1/unordered_map>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007
#define Pi 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define IN(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printPI(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define PI pair<int,int>
#define PL pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<VI>
#define vvl vector<VL>
#define vvvi vector<VVI>
#define vvvl vector<VVL>
#define vpi vector<PI>
#define vpl vector<PL>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
#define asort(x) sort(all(x));
#define dbg(x, y) cout << x << " = " << y << endl

//namespace
using namespace std;

//const
const int Ntest = 1e5 + 5;

//useful function
ll gcd(ll a, ll b) {ll temp; while (b > 0) {temp = a % b; a = b; b = temp;} return a;}
ll lcm(ll a, ll b) {return a * b / gcd(a, b);}
ll fpow(ll  b, ll exp, ll mod) {if (exp == 0) return 1; ll t = fpow(b, exp / 2, mod); if (exp & 1) return t * t % mod * b % mod; return t * t % mod;}
ll divmod(ll i, ll j, ll mod) {i %= mod, j %= mod; return i * fpow(j, mod - 2, mod) % mod;}
// --clock function
clock_t time_p = clock();
void TimeTaken()
{
	time_p = clock() - time_p;
	cerr << "Completion time : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}


void sol() {
	int n, k, tmp, min0;
	vector<int> p;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		p.push_back(tmp);
	}
	asort(p);
	min0 = 0;
	for (int i = 0; i < k; i++) {
		min0 += p[i];
	}

	cout << min0 << endl;

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
		sol();

	return 0;
}

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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;


int main() {
  ll N,K; cin >> N >> K;
  map <int, int> mp;
  rep(i, N) {
    int input;
    cin >> input;
    mp[input]++;
  }
  vector<int> values(mp.size());
  int i=0;
  for(auto x:mp) {
    values[i] = x.second;
    i++;
  }
  sort(values.begin(), values.end());
  int ans=0;
  if (mp.size() > K) {
    rep(i, values.size()) {
      ans += values[i];
      if (mp.size() - (i+1) == K) break;
    }
  }
  dump(ans);
}


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

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

using namespace std;

int main() {
  int N, M;
  cin >> N;
  vector<string> arr_N(N);
  rep(i, N) { cin >> arr_N[i]; }
  cin >> M;
  vector<string> arr_M(M);
  rep(i, M) { cin >> arr_M[i]; }
  vector<int> arr_cnt;
  rep(i, N) {
    int cnt = 0;
    for (int j = i; j < N; j++) {
      if (arr_N[i] == arr_N[j]) {
        cnt++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (arr_N[i] == arr_M[j]) {
        cnt--;
      }
    }
    arr_cnt.push_back(cnt);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, arr_cnt[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int r, g, b;
	cin >> r >> g >> b;
	if ((g * 10 + b) % 4)
	{
		cout << "NO" << endl;
	}
	else
	{
		cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int n,a[N],ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		if(a[i]==i){
			ans++;
			if(a[i+1]==i+1) i++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();

        n = n % 10;
        if (n == 2
            || n == 4
            || n == 5
            || n == 7
            || n == 9) {
            System.out.println("hon");
        } else if (n == 0
        || n == 1
        || n == 6
        || n == 8) {
            System.out.println("pon");
        } else {
            System.out.println("bon");
        }
    }
}


Measured memory_bytes: 27024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}

void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    go();
    return 0;
}
/****************ackun*********************/
const int MAXN=1e5+10;
int a[MAXN];
ll dp[MAXN][2];
void go(){
    int n;
    R(n);
    rep(i,1,n){
        R(a[i]);
    }
    dp[2][0]=a[1]+a[2];
    dp[2][1]=-a[1]-a[2];
    rep(i,3,n){
        dp[i][0]=max(dp[i-1][0],dp[i-1][1])+a[i];
        dp[i][1]=max(dp[i-1][0]-a[i-1]+(-a[i-1]),dp[i-1][1]-(-a[i-1])+a[i-1])-a[i];
    }
    W(max(dp[n][0],dp[n][1]));
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(void)
{
	char s[100][100],c[100];
	int n,m,i,a[100],flg2[100],q,p,flg,k,w,z,j,l;
	scanf("%d",&n);
	scanf("%s",c);
	m=strlen(c);
	for(i=0;i<n;i++){
		scanf("%s",&s[i]);
	}
	w=0;
	for(i=0;i<n;i++){
		z=strlen(s[i]);
		flg=0;
		for(j=0;j<z-1;j++){
			if(s[i][j]==c[0]){
				for(l=j+1;l<z;l++){
					if(s[i][l]==c[1]){
						a[q]=l-j;
						q++;
					}
				}
//				printf("%d %d\n",i,q);
				for(l=0;l<q;l++){
					flg=0;
					for(k=0;k<m;k++){
						if(j+a[l]*k>100||k>100){
							flg=0;
							break;
						}
						if(j+a[l]*k>z-1){
							flg=0;
							break;
						}
						if(s[i][j+a[l]*k]==c[k]){
							flg=1;
							//printf("%d %d %d %d %c %c\n",i,j,j+a[l]*k,k,s[i][j+a[l]*k],c[k]);
						}
						else {
							flg=0;
							break;
						}
					}
					if(flg==1) break;
				}
			}
			q=0;
			if(flg==1) break;
		}
		if(flg==1) w++;
	}
	printf("%d\n",w);
	return 0;
}

Measured memory_bytes: 2740
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
//#define revstr(s) reverse(s.begin(),s.end())
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
int n; vector<int>G[1 << 18];
bool used[1 << 18];
int out[1 << 18];
int pma[1 << 18];
int main() {
	cin >> n;
	rep(i, n - 1) {
		int u, v; cin >> u >> v; u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	used[0] = true;
	queue<P> q;
	rep(i, G[0].size()) {
		int to = G[0][i];
		used[to] = true;
		q.push({ to,0 }); pma[to] = 1;
	}
	while (!q.empty()) {
		P nex = q.front(); q.pop();
		int id = nex.first; int c = nex.second;
		//cout << id << " " << c << endl;
		sort(G[id].begin(), G[id].end());
		vector<vector<int>> v;
		vector<int> num;
		int els = 0;
		queue<P> horyu;
		rep(j, G[id].size()) {
			int cc = G[id][j];
			if (used[cc])continue;
			if (cc > id) {
				horyu.push({ cc,id }); used[cc] = true;
			}
			else{
				queue<P> que; vector<int> cv;
				cv.push_back(cc);
				used[cc] = true;
				int z = 0;
				if (cc < pma[id]) {
					els++; z++; que.push({ cc,1 });
				}
				else {
					que.push({ cc,0 });
				}
				while (!que.empty()) {
					P nnx = que.front(); que.pop();
					int nx = nnx.first;
					rep(k, G[nx].size()) {
						int to = G[nx][k];
						if (used[to])continue;
						used[to] = true;
						if (to > id)horyu.push({ to,nx });
						else {
							if (nnx.second&&to < pma[id]) {
								z++;
								els++; que.push({ to,1 });
							}
							else {
								que.push({ to,0 });
							}
							cv.push_back(to);
						}
					}
				}
				v.push_back(cv); num.push_back(z);
			}
		}
		out[id] = c + els + 1;
		rep(i, v.size()) {
			rep(j, v[i].size()) {
				out[v[i][j]] = c + els - num[i]+v[i].size() + 1;
			//	cout << v[i][j] << " " << c<<els << num[i] << v[i].size() << endl;
			}
		}
		while (!horyu.empty()) {
			P next = horyu.front(); horyu.pop();
			int x = next.first; int y = next.second;
			pma[x] = id;
			q.push({ x,out[y] });
		}
	}
	rep1(i, n - 1) {
		if (i > 1)cout << " ";
		cout << out[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 17780
#include<iostream>
using namespace std;
int main()
{
	int p,q,r;
	cin>>p>>q>>r;
	int temp;
	if(p>q)
	{
		temp=q;
		q=p;
		p=temp;
	}
	if(q>r)
	{
		temp=r;
		r=q;
		q=temp;
	}
	if(p>q)
	{
		temp=q;
		q=p;
		p=temp;
	}
	cout<<p+q;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H=sc.nextInt(),W=sc.nextInt();
		String[] ary = new String[H];
		for(int i=0;i<H;i++) {
			ary[i]=sc.next();
		}

		boolean [] row = new boolean[H];
		boolean [] col = new boolean[W];
		Arrays.fill(row, false);
		Arrays.fill(col, false);

		for(int i=0; i<H;i++) {
			for(int j=0; j<W; j++) {
				if(ary[i].charAt(j) == '#') {
					row[i]=true;
					col[j]=true;
				}
			}
		}

		for(int i=0; i<H; i++) {
			if(row[i]) {
				for(int j=0; j<W; j++) {
					if(col[j]) {
						System.out.print(ary[i].charAt(j));
					}
				}
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 27052
#include <iostream>
#include <bits/stdc++.h>
#include<math.h>
#include<string>
#include<vector>
#include<map>
using namespace std;
#define debug(a) cout<<a<<'\n'
typedef pair<int,int> pii;
typedef long long ll;
#define PB push_back
#define II second
#define I first
#define MP make_pair
int main() {
	//code
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
        cin>>a[i];
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++)
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    cout<<dp[n-1]<<endl;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  set<string> s;
  rep(i, n) {
    string S;
    cin >> S;
    s.insert(S);
  }
  cout << s.size() << endl;
  return 0;
}
      

Measured memory_bytes: 19152
#include <stdio.h>


int main( int argc, char *argv[] )
{
	int N,M,ans=0;
	int T[100],P[100],X[100];
	scanf("%d",&N);
	for(int i=0; i<N; i++){
		scanf("%d", &T[i]);
		ans+=T[i];
	}
	scanf("%d",&M);
	for(int i=0; i<M; i++){
		scanf("%d%d", &P[i],&X[i]);
	}
	for(int i=0; i<M; i++){
		printf("%d\n",ans-T[P[i]-1]+X[i]);
	}
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(int argc, char** argv)
{
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	while(1)
	{
		if((c -= b) <= 0)
		{
			puts("Yes");
			return 0;
		}
		if((a -= d) <= 0)
		{
			puts("No");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1644
#define N 100001 
long p[N],r[N],n,m,i,b[N],a[N][2];int f(int x){if(p[x]==x)return x;return p[x]=f(p[x]);}int u(int x,int y){x=f(x);y=f(y);if(r[x]<r[y])p[x]=y;else p[y]=x;r[y]+=r[x];r[x]=r[y];}int main(){scanf("%ld%ld",&n,&m);for(i=0;i<m;i++)scanf("%d%d",a[i],&a[i][1]);b[m]=n*(n-1)/2;for(i=0;i<N;i++){p[i]=i;r[i]=1;};for(i=m-1;i>=0;i--){if(f(a[i][0])==f(a[i][1]))b[i]=b[i+1];else{b[i]=b[i+1]-r[f(a[i][0])]*r[f(a[i][1])];u(a[i][0],a[i][1]);}}for(i=1;i<=m;i++)printf("%ld\n",b[i]);}

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

using namespace std;

using ll = long long;

ll maxans = 1e18;

int main()
{
    ll a;
    double b;
    cin >> a >> b;
    a *= (int)(b * 100 + 0.5); // to avoid conversion of 1.00 to 99 instead of 100 since C++ may store 1.00 as .999999999
    cout << a/100;
    return 0;
}


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

using namespace std;

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

  const int mod = 1000 * 1000 * 1000 + 7;

  auto power = [&](int x, int n) {
    int y = 1;
    while (n > 0) {
      if (n & 1) {
        y = (long long)y * x % mod;
      }
      x = (long long)x * x % mod;
      n >>= 1;
    }
    return y;
  };

  int n, k;
  cin >> n >> k;

  vector<int> cnt(k + 1);

  for (int i = k; i > 0; i--) {
    cnt[i] = power(k / i, n);
    for (int j = i + i; j <= k; j += i) {
      cnt[i] -= cnt[j];
      if (cnt[i] < 0) {
        cnt[i] += mod;
      }
    }
  }

  int ans = 0;
  for (int i = 1; i <= k; i++) {
    ans += (long long)i * cnt[i] % mod;
    if (ans >= mod) {
      ans -= mod;
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


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




int main() {

	ll r, g, b;
	cin >> r >> g >> b;
	if ((100 * r + 10 * g + b) % 4 == 0) { cout << "YES"; }
	else { cout << "NO"; }


	system("PAUSE");
}


Measured memory_bytes: 504
n = int(input())
s = input()

left = [0] * n
right = [0] * n

tmp = 0
for i in range(1, n):
    if s[i - 1] == "W":
        tmp += 1
        left[i] = tmp
    else:
        left[i] = tmp

tmp = 0
for i in range(n - 2, -1, -1):
    if s[i + 1] == "E":
        tmp += 1
        right[i] = tmp
    else:
        right[i] = tmp

res = 10**9
for i in range(n):
    res = min(res, left[i] + right[i])
print(res)


Measured memory_bytes: 17600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>



using namespace std;


int main() {
	
	string str;
	cin >> str;

	
	string sub = str.substr(0, 2);
	int num = atoi(sub.c_str());
	string sub2 = str.substr(2, 2);
	int num2 = atoi(sub2.c_str());
	string ans;

	if (num <= 12&&num>0) {
		if (num2 <= 12&&num2>0) {
			ans = "AMBIGUOUS";
		}
		else {
			ans = "MMYY";
		}
	}
	else {
		if (num2 <= 12&&num2>0) {
			ans = "YYMM";
		}
		else {
			ans = "NA";
		}
	}

	cout << ans << endl;


	

}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int a, b;

    a = sc.nextInt();
    b = sc.nextInt();

    if(a>b) System.out.printf("a > b\n");
    else if(a<b) System.out.printf("a < b\n");
    else System.out.printf("a == b\n");
  }
}



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


int main(){
	
	int n;
	scanf("%d", &n);
	vector <int> arr(3), ans(3, 0);

	for(int i = 0; i < n; i++){
		for(int& i : arr){
			scanf("%d", &i);
		}
		vector <int> dp(3, 0);
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(j!=k)
					dp[j] = max(dp[j], ans[k]+arr[k]);
			}
		}
		ans = dp;
	}
	printf("%d", max({ans[0], ans[1], ans[2]}));
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd              double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vll             vector<long long>
#define vdd             vector<double>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long,long long>>
#define vvi             vector<vector<int>>
#define vvl             vector<vector<long long>>
#define mii             map<int,int>
#define mll             map<long long,long long>
#define umii            unordered_map<int,int>
#define umll            unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep2(i,a,b)     for(int i=a;i<b;i++)
#define rev(i,n)        for(int i=n;i>=0;i--)
#define rev2(i,a,b)     for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fio             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
#define all(x)          x.begin(),x.end()
#define d0(x)           cout <<x<<" "
#define d1(x)           cout <<x<<endl
#define d2(x,y)         cout <<x<<" "<<y<<endl
#define d3(x,y,z)       cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)     cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define read2(x,y)      cin>>x>>y
#define read3(x,y,z)    cin>>x>>y>>z
#define read4(x,y,z,w)  cin>>x>>y>>z>>w
#define read5(x,y,z,w,a)cin>>x>>y>>z>>w>>a
#define sz(a)           (int)a.size()
const ll mod=1e9+7;
const double PI = 3.14159265359;
const ll MOD=998244353;
void i_o()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
}
string k;
ll d,n;
ll dp[10005][102][2];
ll mem(ll i,ll sum,int flag){
   if(i==n){
      if(sum==0) return 1;
      else return 0;
   }
   ll& res=dp[i][sum][flag];
   if(res!=-1) return res;
   res=0;
   ll lim;
   if(flag) lim=k[i]-'0';
   else lim=9;
   for(int j=0;j<=lim;j++){
      int flg;
      if(j==lim&&flag) flg=1;
      else flg=0;
      ll sum1=(sum+j)%d;
      res+=mem(i+1,sum1,flg);
   }
   res%=mod;
   return res;
}

int main() {
   fio
  // i_o();
   cin>>k;
   cin>>d;
   n=k.length();
   memset(dp,-1,sizeof(dp));
   ll ans=mem(0,0,1);
   ans--;
   ans+=mod;
   d1(ans%mod);
   return 0;
}



Measured memory_bytes: 17024