akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

ll N;
vector<ll> A(100000),B(100000);

bool can(int n){
    auto itr=upper_bound(A.begin(),A.begin()+N,2*B[n]);
    itr--;
    if (itr-A.begin()==N-1){
        return true;
    }
    else if (itr-A.begin()==n){
        return false;
    }
    else {
        return can(itr-A.begin());
    }
}

int main(){
    cin >> N;
    rep(i,N){
        cin >> A[i];
    }
    sort(A.begin(),A.begin()+N);
    B[0]=A[0];
    rep(i,N-1){
        B[i+1]=B[i]+A[i+1];
    }
    ll lb=-1,ub=N;
    while(ub-lb>1){
        ll mid=(ub+lb)/2;
        if (can(mid)){
            ub=mid;
        }
        else {
            lb=mid;
        }
    }
    cout << N-ub << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

class UnionFind {
private:
	vector<int> pastNode;

	class Node {
	public:
		int parent;
		int count;

		Node(int parent) {
			this->parent = parent;
			this->count = 1;
		}
	};

	vector<Node> node;
public:
	UnionFind(int size) {
		for (int i = 0; i < size; i++) {
			node.push_back(Node(i));
		}
	}

	int root(int x) {
		pastNode.clear();

		while (x != node[x].parent) {
			pastNode.push_back(x);
			x = node[x].parent;
		}
		rep(i, pastNode.size()) {
			node[pastNode[i]].parent = x;
		}
		return x;
	}

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

		node[root(y)].count += node[root(x)].count;
		node[root(x)].parent = root(y);
	}

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

	int countSames(int x) {
		return node[root(x)].count;
	}
};

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

	vector<pair<pair<int, int>, int>> v1, v2;
	rep(i, N) {
		int x, y;
		cin >> x >> y;
		v1.push_back(mp(mp(x, y), i));
		v2.push_back(mp(mp(y, x), i));
	}

	sort(all(v1));
	sort(all(v2));

	priority_queue<pair<int, pair<int, int>>> q;
	rep(i, N - 1) {
		int x1 = v1[i].first.first;
		int y1 = v1[i].first.second;
		int x2 = v1[i + 1].first.first;
		int y2 = v1[i + 1].first.second;
		int dist = min(abs(x2 - x1), abs(y2 - y1));

		q.push(mp(-dist, mp(v1[i].second, v1[i + 1].second)));
	}
	rep(i, N - 1) {
		int x1 = v2[i].first.first;
		int y1 = v2[i].first.second;
		int x2 = v2[i + 1].first.first;
		int y2 = v2[i + 1].first.second;
		int dist = min(abs(x2 - x1), abs(y2 - y1));

		q.push(mp(-dist, mp(v2[i].second, v2[i + 1].second)));
	}

	UnionFind uf(N);

	int ret = 0;
	while (!q.empty()) {
		auto now = q.top(); q.pop();
		int idx1 = now.second.first;
		int idx2 = now.second.second;
		if (uf.same(idx1, idx2)) continue;
		ret += -now.first;
		uf.unite(idx1, idx2);
	}

	cout << ret << endl;
}


Measured memory_bytes: 15264
package main

import (
	"fmt"
)

func main() {
	var n, k int64
	fmt.Scan(&n, &k)
	fmt.Println(Min(AbsInt(n%k, k), n%k))
}

func Min(n1, n2 int64) int64 {
	if n1 < n2 {
		return n1
	}
	return n2
}

func AbsInt(n1, n2 int64) int64 {
	if n1 > n2 {
		return n1 - n2
	}
	return n2 - n1
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            String a = sc.next();
            String b = sc.next();
            int result;
            String answer = "";
            int m = 0;
            if (a.length() > 80 || b.length() > 80) {
                System.out.println("overflow");
                continue;
            } else {
                for (int i = a.length() - 1, j = b.length() - 1; i >= 0 || j >= 0; i--, j--) {
                    result = (i < 0 ? '0' : a.charAt(i)) - '0' + (j < 0 ? '0' : b.charAt(j)) - '0' + m;
                    answer += result % 10;
                    m = result / 10;
                }
                answer += m == 1 ? m : "";
            }
            if (answer.length() <= 80)
                System.out.println(new StringBuffer(answer).reverse());
            else
                System.out.println("overflow");
        }
    }
}


Measured memory_bytes: 26300
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
INF = float("inf")


# update: node[x] を更新する
# segfunc: 半開区間 [a, b) での処理
def segfunc(a, b):
    return max(a, b)


class SegmentTree:
    def __init__(self, arr):
        size = len(arr)
        n = 2 ** (size - 1).bit_length()
        self.n = n
        self.node = [0] * (2*n)
        for i in range(size):
            self.node[i+n-1] = arr[i]
        for i in reversed(range(n-2)):
            self.node[i] = segfunc(self.node[2*i+1], self.node[2*i+2])
    

    def update(self, x, val):
        x += (self.n - 1)
        self.node[x] = val
        while x > 0:
            x = (x - 1) // 2
            self.node[x] = segfunc(self.node[2*x+1], self.node[2*x+2])
    
    
    def query(self, a, b):
        res = 0
        l = self.n - 1 + a
        r = self.n - 1 + (b-1)
        
        while l <= r:
            if l == r:
                res = segfunc(res, self.node[l])
                break

            if l % 2 == 0:
                res = segfunc(res, self.node[l])
            if r % 2 == 1:
                res = segfunc(res, self.node[r])
            l = l // 2
            r = r // 2 - 1
        
        return res
 

# 処理内容
def main():
    N, K = map(int, input().split())
    
    seg = SegmentTree([0]*300010)
    for _ in range(N):
        A = int(input())
        a = max(A-K, 0)
        b = min(A+K, 300000)
        tmp = seg.query(a, b+1) + 1
        seg.update(A, tmp)
    
    print(seg.query(0, 300000))


if __name__ == '__main__':
    main()

Measured memory_bytes: 85664
n = int(input())
T = list(map(int,input().split()))
A = list(map(int,input().split()))
mod = 10**9+7
if max(A)!=max(T):
    print(0)
    exit()
l = [True] + [False]*(n-1)
r = [False]*(n-1) + [True]

for i in range(1, n):
    if T[i] != T[i-1]:
        l[i] = True
for i in range(n-1):
    if A[i] != A[i+1]:
        r[i] = True
for i in range(n):
    if r[i] and A[i]>T[i]:
        print(0)
        exit()       
ans = 1
for i in range(n):
    if l[i]==False and r[i]==False:
        ans *= min(T[i], A[i])
        ans %= mod
print(ans%mod)

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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		char str[] = sc.next().toCharArray();

		Arrays.sort(str);

		System.out.println(new String(str).equals("abc") ? "Yes" : "No");
	}

}


Measured memory_bytes: 23252
#include <iostream>
#include <stdint.h>
#include <vector>

using namespace std;
static vector<uint32_t> Ts;
int32_t main()
{
  uint32_t N;
  cin >> N;

  for(uint32_t i = 0; i < N ; i++){
    int32_t t;
    cin >> t;
    Ts.push_back(t);
  }

  uint32_t M;
  cin >> M;
  for(uint32_t i = 0; i < M; i++){
    uint32_t p, m;
    cin >> p >> m;
    p--;
    uint32_t count = 0;
    for(uint32_t i = 0; i < Ts.size();i++){
      if(i == p){
        count += m;
      } else{
        count += Ts[i];
      }
    }
    cout << count << endl;
  }

  return 0;
}


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

int main()
{  
   string s;
   cin>>s;
   int n=s.size();
   for(int i=2;i<=n-2;i+=2){
       if(s.substr(0,(n-i)/2)==s.substr((n-i)/2,(n-i)/2)){
           cout<<n-i<<endl;
           return 0;
       }
   }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MAX 100000
#define parent(x) x / 2
#define left(x) 2 * x
#define right(x) 2 * x + 1

int main()
{
	int H, i, A[MAX + 1];
	cin >> H;
	for (i = 1; i <= H; i++)
		cin >> A[i];
	for (i = 1; i <= H; i++)
	{
		cout << "node " << i << ": key = " << A[i] << ", ";
		if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
		if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
		if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <stdio.h>
#include <stdlib.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 initialize(void){

  head = tail = 0;
}

int isEmpty(void){
  
  if(head == tail){
    return 1;
  }
  else return 0;
}

int isFull(void){

  if(head == (tail + 1) % LEN){
    return 1;
  }
  else return 0;
}

void enqueue(P x){
  
  if(isFull()){
    fprintf(stderr,"Overflow\n");
    exit(1);
  }
  Q[tail] = x;
  if(tail + 1 == LEN){
    tail = 0;
  }
  else 
    tail++;
}

P dequeue(){
  P x;

  if(isEmpty()){
    fprintf(stderr,"Underflow\n");
    exit(2);
  }
  x = Q[head];
  if(head + 1 == LEN){
    head = 0;
  }
  else 
    head ++;
  return x;
}

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

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

  head = 0;
  tail = n;
  while(head != tail){
    u = dequeue();
    if(q > u.t)c = u.t;
    else c = q;
    u.t = u.t - c;
    elaps = 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>
using namespace std;
int main()
{
    int arr[1000],i,n,cnt=0,j,mini,maxi,cnt1=0;
    cin>>n;
    for(i=0;i<n;i++)
    {cin>>arr[i];

    }


     for(i=0;i<n;i++)
   {
      if(arr[i]==(i+1))
      {
          cnt++;
      }
      else
     {
       cnt1++;
     }

    }
    if(cnt==(n-2) ||cnt == (n))
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define maxn 100100
using namespace std;
typedef long long ll;
ll A[maxn],X,Y;
int n,fp,gp,tr[2][maxn],q[2][maxn*30],tp[2];
void add(int p,int x,int a){
	for(x++;x<=n+1;x+=x&-x)
		tr[p][x]=(tr[p][x]+a)%mod,q[p][++tp[p]]=x;
}
int qry(int p,int x){
	int ans=0;
	for(x++;x;x-=x&-x)
		ans=(ans+tr[p][x])%mod;
	return ans;
}
void clear(int p){
	while(tp[p])
		tr[p][q[p][tp[p]--]]=0;
}
int main(){
	scanf("%d%lld%lld",&n,&X,&Y);
	for(int i=1;i<=n;++i)
		scanf("%lld",&A[i]);
	A[0]=(ll)-3e18;
	add(0,0,1),add(1,0,1);
	for(int i=2;i<=n;++i){
		while(fp+1<i&&A[i]-A[fp+1]>=X)fp++;
		while(gp+1<i&&A[i]-A[gp+1]>=Y)gp++;
		int p=qry(1,fp),q=qry(0,gp);
		if(A[i]-A[i-1]<X)clear(0);
		if(A[i]-A[i-1]<Y)clear(1);
		add(0,i-1,p),add(1,i-1,q);
	}
	printf("%d",(qry(0,n-1)+qry(1,n-1))%mod);
}

Measured memory_bytes: 12928
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }
constexpr long long INF = 1e18;

int main() {
    int x, y, n, m, l;
    cin >> x >> y >> n >> m >> l;
    vector<long long> a(n), b(m), c(l);
    for (auto &e : a) cin >> e;
    for (auto &e : b) cin >> e;
    for (auto &e : c) cin >> e;
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());
    
    vector<long long> sa(n+1, 0), sb(m+1, 0), sc(l+1, 0);
    for (int i = 0; i < n; i++) sa[i+1] = sa[i] + a[i];
    for (int i = 0; i < m; i++) sb[i+1] = sb[i] + b[i];
    for (int i = 0; i < l; i++) sc[i+1] = sc[i] + c[i];
    
    auto f = [&] (int red) {
        long long res = -INF;
        for (int g = 0; g <= y; g++) {
            int w = x + y - (red + g);
            if (l < w) continue;
            long long val = sa[red] + sb[g] + sc[w];
            chmax(res, val);
        }
        return res;
    };
    
    int low = 0, high = x;
    while (abs(low - high) > 2) {
        int c1 = (low * 2 + high) / 3;
        int c2 = (low + high * 2) / 3;
        if (f(c1) > f(c2)) high = c2;
        else low = c1;
    }
    
    long long ans = -INF;
    for (int i = low; i <= high; i++) chmax(ans, f(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>

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

    int h[N + 1] = {0};
    for (int i = 1; i <= N; ++i) {
        std::cin >> h[i];
    }

    int c[N+1] = {0};

    for (int i = 1; i <= N; ++i) {
        if (i == 1) {
            c[i] = 0;
        } else if (i == 2) {
            c[i] = std::abs(h[i-1] - h[i]);
        } else {
            const int c1 = c[i-1] + std::abs(h[i-1] - h[i]);
            const int c2 = c[i-2] + std::abs(h[i-2] - h[i]);
            c[i] = std::min(c1, c2);
        }
    }

    std::cout << c[N] << std::endl;

    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

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

    int N;
    cin >> N;

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

    int now = 1;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (a[i] == now) {
            ++now;
        }
        else {
            ++ans;
        }
    }

    if (now == 1) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		String[] array = s.split("");

		int ans = 0;
		for(int i=0;i<array.length;i++) {
			String tmp1 = array[i];
			if(tmp1.equals("A")||tmp1.equals("C")||tmp1.equals("G")||tmp1.equals("T")) {
				int ans1 = 0;
				for(int j=i;j<array.length;j++) {
					tmp1 = array[j];
					if(tmp1.equals("A")||tmp1.equals("C")||tmp1.equals("G")||tmp1.equals("T")) {
						ans1++;
						ans = Math.max(ans, ans1);
					}else {
						ans = Math.max(ans, ans1);
						ans1 = 0;
					}
				}
			}
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 35572
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
 
#define int long long int
#define ld long double
#define mod 1000000007 
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define forn(i,s, e) for (int i = s; i <= e; i++)
#define fornd(i,s, e) for (int i = s ; i >= e; i--)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define print(x) for(auto el: x) cout<<el<<" ";cout<<"\n"
#define PSET(x,y) fixed<<setprecision(y)<<x
#define bits(x) __builtin_popcount(x)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

 
template <typename T> 
void swap(T& a, T& b){
    T temp = a;
    a = b;
    b = temp;
}

const int N = 100005; 

vector<int> * adj;

int dp[N][2];


void dfs(int a, int p){
    int flag = 0;
    for(int to: adj[a]){
        if(to==p) continue;
        dfs(to,a);
        flag = 1;
    }

    if(flag == 0){
        dp[a][0] = 1;
        dp[a][1] = 1;
    }else{
        int white =1;
        int black =1;
        for(int to: adj[a]){
            if(to==p) continue;
            black = (black*dp[to][0])%mod ;
            white = (white*((dp[to][0]+dp[to][1])%mod))%mod;
        }
        dp[a][1] = black;
        dp[a][0] = white;
    }
}



void solve(){
    int n;
    cin>>n;

    adj = new vector<int>[n];

    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        adj[a-1].push_back(b-1);
        adj[b-1].push_back(a-1);
    }
    memset(dp,0,sizeof(dp));
    dfs(0,-1);

    cout<<((dp[0][0]+dp[0][1])%mod);

}   
 
int32_t main()
{
    fast;
    // int t;
    // cin>>t;
    // for(int y=1;y<=t;y++)
    {
        // cout<<"Case #"<<y<<": ";
        solve();
    }
    return 0;
} 

Measured memory_bytes: 11520
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const ll INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

const ll MAX = 1e6;

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

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


	cout << (abs(a-b)<=1?"Brown":"Alice") << endl;
	return 0;
}


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

int main(){
    string a, s, c;
    cin >> a >> s >> c;
    
    printf("A%cC\n", toupper(s[0]));
    return 0;
}

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

using namespace std;

int main() {
   int n , k ; cin>>n>>k;
   vector<double> pref(n + 1),E(n + 1);
   for(int i = 1 ; i <= n; ++i){
     int x ; cin>>x;
     E[i] = (1.0 + x) / 2.0;
   }
   for(int i = 1 ; i <= n; ++i){
     pref[i] = pref[i - 1] + E[i];
   }
   double ans = 0.0;
   for(int i = 0 ; i <= n - k ; ++i){
     ans = max(ans , pref[i + k] - pref[i]);
   }
   printf("%.10f\n" , ans);


}

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

#define pb push_back
#define ll long long

using namespace std;

const ll inf = 1e12 + 10;
const int maxn =1e5 + 10;
const int MOD = 1e9 + 7;

vector <int>adj[maxn];
vector <int>adjx[maxn];
int dp[maxn];
int h[maxn];
bool visited[maxn];
int maxCost = 1e9 + 10;

int main(){
	int n , k;
	int a[maxn];
	cin >> n;
    for(int i = 1 ; i <= n ; i++){
        cin >>a[i];
        dp[i] = maxCost;
    }
    dp[1]=0;
    for(int i = 2; i <= n ; i++)
        for (int j = i-1 ; j >= max(1,i - 2); j--)
            dp[i] = min(dp[i] , dp[j] + abs(a[i] - a[j]));
    cout << dp[n] << endl;
	return 0;
}


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

#define fast ios_base::sync_with_stdio; cin.tie(0); cout.tie(0)
#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
//#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

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

int main()
{fast;
 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 #endif
 int t=1,n;
 //cin>>t;
 while(t--)
 {cin>>n;
  if((n%1000==0)){
    cout<<0<<endl;
  }
  else{
    cout<<1000-(n%1000)<<endl;
  }
 }
 return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,k;
cin>>a>>b>>k;
set<int> s;
for(int i=a;i<=a+k-1&&i<=b;i++)
s.insert(i);
for(int i=b-k+1;i<=b&&i>=a;i++)
s.insert(i);
for(auto i:s)
cout<<i<<endl;

return 0;
}
 


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		Map<String , Integer> blue = new HashMap<>();

		for (int i = 0; i < N; i++) {
			String s = sc.next();
			if (!blue.containsKey(s)) {
				blue.put(s, 1);
			}else {
				blue.put(s, blue.get(s) + 1);
			}
		}

		int M = sc.nextInt();
//		Map<String, Integer> red = new HashMap<>();

		for (int i = 0; i < M; i++) {
			String t = sc.next();
			if (!blue.containsKey(t)) {
				blue.put(t, -1);
			} else {
				blue.put(t,blue.get(t) - 1);
			}
		}

		int max = 0;
		for (Map.Entry<String, Integer> entry : blue.entrySet()) {
			max = Integer.max(max, entry.getValue());
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
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; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int n;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  vii p(n);
  int ma = 0, sum = 0;
  rep(i, 0, n) {
    cin >> p[i];
    sum += p[i];
    ma = max(ma, p[i]);
  }
  cout << sum - ma / 2 << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

ll vertice;
ll n;
map<pll,ll> pairtovert;
map<ll,pll>verttopair;
vector<ll> graph[500010];
ll indegree[500010];

void initialise()
{
    vertice=(n*(n-1)/2);
    ll count1=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i+1;j<=n;j++)
        {
            pairtovert[{i,j}]=count1;
            verttopair[count1]={i,j};
            count1++;
        }
    }
    return;
}

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

    memset(indegree,0,sizeof(indegree));
    cin>>n;
    initialise();
    ll vert1,vert2;
    pll store;
    ll neighbour[n-1];
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<n-1;j++)
        {
            cin>>neighbour[j];
        }
        for(ll j=1;j<n-1;j++)
        {
            store={i,neighbour[j-1]};
            if(store.first>store.second)
            {
                swap(store.first,store.second);
            }   
            vert1=pairtovert[store];
            store={i,neighbour[j]};
            if(store.first>store.second)
            {
                swap(store.first,store.second);
            }   
            vert2=pairtovert[store];
            indegree[vert2]++;
            graph[vert1].push_back(vert2);
        }
    }
    queue<ll> store1,q1;
    ll countzero=0;
    for(ll i=1;i<=vertice;i++)
    {
        if(indegree[i]==0)
        {
            countzero++;
            store1.push(i);
        }
    }
    ll ans=0,front,size;
    while(!store1.empty())
    {
        ans++;
        while(!store1.empty())
        {
            front=store1.front();
            store1.pop();
            size=graph[front].size();
            for(ll i=0;i<size;i++)
            {
                indegree[graph[front][i]]--;
                if(!indegree[graph[front][i]])
                {
                    q1.push(graph[front][i]);
                    countzero++;
                }
            }
        }
        store1=q1;
        while(!q1.empty())
        {
            q1.pop();
        }
    }
    if(countzero!=vertice)
    {
        cout<<"-1";
    }
    else
    {
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 93952
#include<bits/stdc++.h>
using namespace std;
int c1,c2,c3,c4,c5,c6;
int main()
{
	long long n,m;
	cin>>n>>m;
	long long cnt=0;
	if(n==m/2)
	{
		cnt+=n;
		cout<<cnt<<endl;
		return 0;
	}
	if(n<m/2)
	{
		cnt+=n,m-=2*n,cnt+=m/4;
		cout<<cnt<<endl;
		return 0;
	}
	if(n>m/2)
	{
		cnt+=m/2;
		cout<<cnt<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import math
def sign(x):
    if x>=0:
        return 1.0
    else:
        return -1.0

pi = math.pi
deg = 0.0
pos_x = 0.0
pos_y = 0.0

lines = sys.stdin.readlines()
for line in lines:
    line = line.split(",")
    inp = []
    for i in line:
        inp.append(int(i))
    if inp[0]>0:
        dist = inp[0]
        pos_x += dist*math.sin(deg/180*pi)
        pos_y += dist*math.cos(deg/180*pi)
        deg += inp[1]
    else:
        print ("%d" % (sign(pos_x)*math.floor(math.fabs(pos_x))))
        print ("%d" % (sign(pos_y)*math.floor(math.fabs(pos_y))))

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

using namespace std;

int main() {
    long long N, K;
    cin >> N >> K;
    bool is_con = true;
    int ans = 0;
    while(is_con) {
        ans ++;
        is_con = N >= pow(K, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
using namespace std;
int A[105];
int main()
{
    // std::ios::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
	string s;
	int i;
	cin>>s;
	if(sz(s)==2 and s[0]==s[1]){
		cout<<"1 2";
		return 0;
	}
	for(i=0;i<sz(s)-2;i++){
		set<char> tmp;
		tmp.insert(s[i]);
		tmp.insert(s[i+1]);
		tmp.insert(s[i+2]);
		if(sz(tmp)<3){
			cout<<i+1<<" "<<i+3;
			return 0;
		}
	}
	cout<<"-1 -1";
    return 0;
}

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

int main() {
	int N; cin >> N;
	char S[110]; cin >> S;
	char S1[55], S2[55];

	for (int i = 0; i < (N / 2); ++i) {
		S1[i] = S[i];
		S2[i] = S[i + N / 2];
	}

	int k = 0;
	while (1) {
		if (N % 2 == 1) {
			printf("No\n");
			break;
		}
		if (k == N / 2) {
			printf("Yes\n");
			break;
		}
		if (S1[k] != S2[k]) {
			printf("No\n");
			break;
		}
		k++;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

int main(){

  int a,b,c;
  cin>>a>>b>>c;
  cout<<min(c,b/a)<<endl;
  
  return 0;
}



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

int main() {
    int N; cin >> N;
    vector<int> v(N);
    vector<int> c(N);
    rep(i, N) cin >> v.at(i);
    rep(i, N) cin >> c.at(i);

    int ans = 0;
    rep(i, N){
        if(v.at(i)-c.at(i)>0) ans += v.at(i)-c.at(i); 
    }

    cout << ans << endl;

}


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


int main(){

  int bt[50][50] , bt2[50][50] = {{0}} , N , K , R , n[50] , p , q ,cnt = 0;

  cin >> N >> K;
  for( int i = 0; i < K; i++ ){
    cin >> n[i];
    for( int j = 0; j < n[i]; j++ ){
      cin >> bt[i][j];
    }
  }

  cin >> R;
  //cout << R << endl; 
  for( int i =0; i < R; i++ ){
    cin >> p >> q;
    for( int j = 0; j < K; j++ ){
      for( int s = 0; s < n[j]; s++ ){
	if( bt[j][s] == p ){
	  for( int t =0; t < n[j]; t++ ){
	    if( bt[j][t] == q ){
	      bt2[j][s] = 1;
	      bt2[j][t] = 1;
	    }
	  }
	}
      }
    }
  }


  for( int i = 0; i < K; i++ ){
    for( int j = 0; j < n[i]; j++ ){
      if( bt2[i][j] == 1 ){
	cnt++;
	//cout << i << j << bt[i][j] << endl;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}

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

int n,a[20],x[20][20],y[20][20];

signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        rep(j,a[i])cin>>x[i][j]>>y[i][j],x[i][j]--;
    }
    int ans=0;
    rep(i,1<<n){
        int X=0;
        rep(J,n){
            if((i>>J)&1){
                X++;
                rep(k,a[J]){
                    if(((i>>x[J][k])&1)!=y[J][k])X=-1e9;
                }
            }
        }
        ans=max(ans,X);
    }
    cout<<ans<<endl;
}

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


vector<LL> p;
LL n;

void f(int k,LL now){
    if(k==18) return;
    if(now&&n%now==0) p.push_back(now);
    f(k+1,now*10+8);
    f(k+1,now*10+2);
    return;
}

map<LL,int> ma;

int dfs(LL x,int k,int count){
    if(k>=p.size()) return -1;
    int ret=-1;
    if(x==1){
        return count;
    }
    if(x%p[k]==0) ret=dfs(x/p[k],k,count+1);
    ret=max(ret,dfs(x,k+1,count));
    return ret;
}

int main(){
    cin >> n;
    if(n==1){
        puts("-1");
        return 0;
    }
    f(0,0);
    int ans=dfs(n,0,0);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

template <class T>
void chmin(T &a, T b) {
    if (b < a) a = b;
}

struct P {
    int x[2], z;
};

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

    P p[15];
    for (int i = 0; i < n; i++) {
        int x, y, z;
        cin >> x >> y >> z;

        p[i] = { x, y, z };
    }

    vector<array<array<int, 2>, 15>> v(1 << n);
    for (int i = 0; i < n; i++) {
        for (int h = 0; h < 2; h++) {
            v[0][i][h] = min(abs(p[i].x[0]), abs(p[i].x[1]));
        }
    }
    for (int k = 1; k < 1 << n; k++) {
        int i = __builtin_ctz(k);
        auto u = v[k ^ 1 << i];
        for (int j = 0; j < n; j++) {
            for (int h = 0; h < 2; h++) {
                chmin(u[j][h], abs(p[i].x[h] - p[j].x[h]));
            }
        }
        v[k] = u;
    }

    ll r[15 + 1];
    for (int i = 0; i <= n; i++) {
        r[i] = 1LL << 60;
    }

    for (int k = 0; k < 1 << n; k++) {
        for (int l = k; l >= 0; l--) {
            l &= k;
            int m = k ^ l;

            ll s = 0;
            for (int i = 0; i < n; i++) {
                s += (ll)min(v[l][i][0], v[m][i][1]) * p[i].z;
            }
            chmin(r[__builtin_popcount(k)], s);
        }
    }

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

    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int n, m;
    cin >> n >> m;
    V<V<int>> g(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> q;
    q.push(0);
    V<int> ans(n, -1);
    ans[0] = 0;
    while(sz(q)) {
        int v = q.front(); q.pop();
        for(int nv : g[v]) {
            if(ans[nv] != -1) continue;
            ans[nv] = v;
            q.push(nv);
        }
    }
    cout << "Yes" << endl;
    Rep(i,n-1) cout << ans[i]+1 << endl;
}

Measured memory_bytes: 10220
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int min = a[0];
		int max = 0;
		int cnt = 0;
		for (int i = 1; i < n; i++) {
			min = Math.min(min, a[i - 1]);
			int d = a[i] - min;
			if (d > max) {
				max = d;
				cnt = 1;
			} else if (d == max) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 38236
<?php
$f = fopen( 'php://stdin', 'r' );
$line1 = str_replace(array("\n", "\r"), '', fgets($f));
$line2 = str_replace(array("\n", "\r"), '', fgets($f));

$stringParts1 = str_split($line1);
sort($stringParts1);
$count_pre1 = count($stringParts1);
$stringParts1 = array_unique($stringParts1);
$count_post1 = count($stringParts1);

$stringParts2 = array_filter(str_split($line2));
sort($stringParts2);
$count_pre2 = count($stringParts2);
$stringParts2 = array_unique($stringParts2);
$count_post2 = count($stringParts2);
if ($stringParts1[0] > end($stringParts2)) {
    echo('No');
    exit();
} elseif ($stringParts1[0] === end($stringParts2)) {
    if ($count_post1 === 1 && $count_post2 === 1 && $count_pre1 < $count_pre2) {
        echo('Yes');
    } else {
        echo('No');
    }
    exit();
} else {
    echo('Yes');
}

Measured memory_bytes: 4604
#
# abc055 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 6"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """12345 678901"""
        output = """175897"""
        self.assertIO(input, output)


def resolve():
    N, M = map(int, input().split())

    if M >= 2*N:
        print(N+(M-2*N)//4)
    else:
        print(M//2)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16140
using System;
using System.Linq;

class Task6
{
   public static void Main(string[] args)
   {
        int N = int.Parse(Console.ReadLine());
        int[] V = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Array.Sort(V);
        double X = V[0];

        for (int i = N - 1; i < N; i++)
        {
            foreach (int Y in V)
            {
                X = (X + Y) / 2;
            }        
        }
        Console.WriteLine(X);
   }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n - 1;i++){
    ans += (n - 1) / i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

using ll = long long int;

int main(void) {
  int a, b, t;
  cin>>a>>b>>t;
  std::cout << b*(t/a) << std::endl;
  return 0;
}



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

int main()
{
    int A, B, C, X, Y, ans1, ans2, ans3;
    cin >> A >> B >> C >> X >> Y;
    pair<int, int> a, b;
    a = make_pair(X, A);
    b = make_pair(Y, B);

    ans1 = C * 2 * max(X, Y);
    ans2 = C * 2 * min(X, Y) + abs(Y - X) * max(a, b).second;
    ans3 = A * X + B * Y;
    cout << min(ans1, min(ans2, ans3)) << endl;
}

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

int main(){
	int arr[102];//0 to 101
	int X,N,num=101;
	cin>>X>>N;
	for(int i=0; i<N; i++)cin>>arr[i];
	for(int i=0; i<=101; i++){
		int stat=1;
		for(int j=0; j<N; j++){
			if(arr[j]==i){
				stat=0;
				break;
			}
		}if(stat==0){
			continue;
		}if(abs(X-i)<abs(X-num))num=i;
		else if(abs(X-i)==abs(num-X))num=min(num,i);
	}cout<<num<<'\n';
}

Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;
const int mod= 1e+9+7;

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

	vector<vector<int>> vec(M);

	for (int i = 0; i < M; ++i) {
		int k; cin >> k;
		vec[i].resize(k);
		for (int j = 0; j < k; ++j) {
			cin >> vec[i][j];
			//--vec[i][j];
		}
	}

	vector<int> p(M);
	for (int i = 0; i < M; ++i) cin >> p[i];

	int ans = 0;
	for (int i = 0; i < (1 << N); ++i) {

		bool ok = true;
		for (int j = 0; j < M; ++j) {
			int c = 0;
			for (int id : vec[j]) {
				if ((i >> (id-1)) & 1) {

					++c;
				}
			}
			if (c%2 != p[j]) {
				ok = false;
			}
		}
		if (ok) {
			++ans;
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k,cnt=0;
    cin>>n>>k;
    int a[n];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]>=k)
        cnt++;
    }
    cout<<cnt;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
  long int a, b, d, r;
  double f;

  scanf("%ld %ld", &a, &b);

  d = a/b;
  r = a%b;
  f = (double)a/(double)b;

  printf("%ld %ld %.5lf\n",d, r, f);

  return 0;
}

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

int R, C, N;
vector<P> edge1, edge2, edge3, edge4;

void append(int x, int y, int i)
{
    if (y == 0)
        edge1.push_back(make_pair(x, i));
    else if (x == R)
        edge2.push_back(make_pair(y, i));
    else if (y == C)
        edge3.push_back(make_pair(R - x, i));
    else if (x == 0)
        edge4.push_back(make_pair(C - y, i));
}

bool ontheedge(int x, int y)
{
    if (x == 0 || x == R || y == 0 || y == C)
        return true;
    else
        return false;
}

int main()
{
    cin >> R >> C >> N;
    for (int i = 0; i < N; i++)
    {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if (ontheedge(x1, y1) && ontheedge(x2, y2))
        {
            append(x1, y1, i);
            append(x2, y2, i);
        }
    }

    sort(edge1.begin(), edge1.end());
    sort(edge2.begin(), edge2.end());
    sort(edge3.begin(), edge3.end());
    sort(edge4.begin(), edge4.end());
    edge1.insert(edge1.end(), edge2.begin(), edge2.end());
    edge1.insert(edge1.end(), edge3.begin(), edge3.end());
    edge1.insert(edge1.end(), edge4.begin(), edge4.end());

    std::vector<int> s;

    for (auto v : edge1)
    {
        if (s.empty() || v.second != s.back()) s.push_back(v.second);
        else s.pop_back();
    }

    if (s.empty()) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 5240
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  double N,K;
	long double tempp;
	long double ans=0;
	cin>>N>>K;
	for(int i=1;i<=N;i++){
		tempp=1.0/N;
		int a=i;
		while(a<K){
			a*=2;
			tempp/=2.0;
		}
		ans+=tempp;
	}
	printf("%.16Lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x[3]={};
  int a,b;
  
  cin>>a>>b;
  
  x[0]=a+b;
  
  x[1]=a-b;
  
  x[2]=a*b;
  
  int max=x[0];
  
  for(int i=0;i<2;i++){
    if(max<x[i+1]){
      max=x[i+1];
    }
  }
  
  cout<<max<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    ans = inf
    s = input()
    n = len(s)
    for i in range(n-2):
        num = int(s[i:i+3])
        ans = min(ans, abs(num - 753))
    print(ans)


if __name__ == "__main__":
    main()


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

int main()
{
	int N;
	while (cin >> N) {
		vector<int> res;
		for (int i = 0; i < 10; i++) {
			if (N & (1 << i)) {
				res.push_back(1 << i);
			}
		}
		for (int i = 0; i < (int)res.size(); i++) {
			cout << res[i] << " \n"[i + 1 == (int)res.size()];
		}
	}
	return 0;
}

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

vector<int> dxs = {-1, 1, 0, 0}, dys = {0, 0, -1, 1};

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++)
    {
        cin >> s.at(i);
    }

    int res = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s.at(i).at(j) == '#')
            {
                continue;
            }

            int mx = 0;
            vector<vector<int>> v(h, vector<int>(w, -1));
            v.at(i).at(j) = 0;
            queue<pair<int, int>> q;
            q.push({i, j});
            while (!q.empty())
            {
                int pi = q.front().first, pj = q.front().second;
                int l = v.at(pi).at(pj);
                q.pop();

                v.at(pi).at(pj) = false;
                mx = max(mx, l);

                for (int k = 0; k < 4; k++)
                {
                    int dx = dxs.at(k), dy = dys.at(k);
                    if (0 <= pi + dy && pi + dy < h && 0 <= pj + dx && pj + dx < w)
                    {
                        if (s.at(pi + dy).at(pj + dx) == '.' && v.at(pi + dy).at(pj + dx) < 0)
                        {
                            q.push({pi + dy, pj + dx});
                            v.at(pi + dy).at(pj + dx) = l + 1;
                        }
                    }
                }
            }

            res = max(res, mx);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256