akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

D EPS = 1e-6;

int main() {
	int X, H;
	
	while (1) {
		cin >> X >> H; if (X==0 && H==0) break;
		
		D x = (D)X, h = (D)H;
		D y = sqrt((x/2.0)*(x/2.0) + h*h);
		D ans = (y*x/2.0)*4.0 + x*x;
		
		ans -= EPS;
		printf("%lf\n", ans);
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,a,b;
    cin >> x >> a >> b;
    x-=a;
    cout << x%b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
#define pb emplace_back
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}

ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1; 
    y = x1;
    return gcd;
}
ll power(ll a, ll b, ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinv(ll a , ll mod ){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}

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


int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vi pr(n+1,1);
    vll dp(n+1);
    dp[1] = 1;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(pr[i]==1)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                pr[j] = i;
            }
        }
    }
    for(int i=2;i<=n;i++)
    {
        if(pr[i]==1)
        {
            dp[i] = 2;
        }
    }
    for(int i=2;i<=n;i++)
    {
        if(dp[i]==2)
            continue;
        int f = i;int c = 1;
        while(f%pr[i]==0)
        {
            f/=pr[i];
            c++;
        }
        dp[i] = dp[f]*c;
    }
    ll ans = 0;
    for(int i=1;i<=n;i++)
    {
        ans+=dp[i]*i;
    }
    cout<<ans;
    
    
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var k = int.Parse(Console.ReadLine());
        var num = 1;

        for(int i = 0; i < n; i++)
        {
            if(num * 2 <= num + k)
            {
                num = num * 2;
            }
            else
            {
                num += k;
            }
        }

        Console.WriteLine(num);
    }
}

Measured memory_bytes: 11092
#include <climits>
#include <cstdio>
#include <cstdint>
#include <cstring>

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1);
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__);
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__);
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__);
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__);
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__);
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__);
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__);

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__);

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32")) return "%d";
  if(strcmp(fmt, "u32")) return "%u";
  if(strcmp(fmt, "f32")) return "%f";
  if(strcmp(fmt, "f64")) return "%lf";
  if(strcmp(fmt, "i64")) return "%lld";
  if(strcmp(fmt, "u64")) return "%llu";
  if(strcmp(fmt, "char*")) return "%s";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__);
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__);
#define RF(...)   _FCN(_R, f32, __VA_ARGS__);
#define RD(...)   _FCN(_R, f64, __VA_ARGS__);
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__);
#define RULL(...) _FCN(_R, u64, __VA_ARGS__);

#define PI(...)   _FCN(_P, i32, __VA_ARGS__);
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__);
#define PF(...)   _FCN(_P, f32, __VA_ARGS__);
#define PD(...)   _FCN(_P, f64, __VA_ARGS__);
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__);
#define PULL(...) _FCN(_P, u64, __VA_ARGS__);
#define PS(...)   _FCN(_P, char*, __VA_ARGS__);

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

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

  cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}


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

#define int long long
using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

int hn[300100], wn[300100];
set<int> ms[300100];
random_device _rnd;
int rnd(int n) {
  return ((double)_rnd() / UINT_MAX) * n;
}
signed main() {
  int H, W, M;
  cin >> H >> W >> M;
  repi(M) {
    int h, w;
    cin >> h >> w;
    --h;
    --w;
    ++hn[h];
    ++wn[w];
    ms[h].insert(w);
  }
  int hnmax = -1, wnmax = -1;
  repi(H) updatemax(hnmax, hn[i]);
  repi(W) updatemax(wnmax, wn[i]);
  vector<int> hms, wms;
  repi(H) if (hn[i] == hnmax) hms.push_back(i);
  repi(W) if (wn[i] == wnmax) wms.push_back(i);
  int result = hnmax + wnmax - 1;
  if (M < H * W) {
    int hmsl = hms.size(), wmsl = wms.size();
    if (hmsl * wmsl <= 1e5 * 3) {
      repi(hmsl) repj(wmsl) {
        int h = hms[i], w = wms[j];
        if (ms[h].find(w) == ms[h].end()) {
          ++result;
          goto end;
        }
      }
    } else {
      repi(1e5) {
        int h = hms[rnd(hmsl)], w = wms[rnd(wmsl)];
        if (ms[h].find(w) == ms[h].end()) {
          ++result;
          goto end;
        }
      }
    }
  }
end:
  cout << result << endl;
}


Measured memory_bytes: 44448
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {

	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()

	text := stdin.Text()

	slice := strings.Split(text, " ")
	var num []int
	var a int
	for i := 0; i < len(slice); i++ {
		a, _ = strconv.Atoi(slice[i])
		num = append(num, a)
	}

	divideNumber := 0

	if num[0] < num[1] {
		for i := num[0]; i <= num[1]; i++ {
			if num[2]%i == 0 {
				divideNumber++
			}
		}
	} else if num[0] > num[1] {
		for i := num[1]; i <= num[0]; i++ {
			if num[2]%i == 0 {
				divideNumber++
			}

		}
	} else if num[0] == num[1] {
		if num[2]%num[0] == 0 {
			divideNumber++
		}
	}

	fmt.Println(divideNumber)
}



Measured memory_bytes: 1124
import java.util.*;
import java.lang.*;

class Pair<E,F>{
    E first;
    F second;
    public Pair(E first, F second){
        this.first=first;
        this.second=second;
    }
    public E getFirst(){return first;}
    public F getSecond(){return second;}
    public String toString(){
        return "<"+first.toString()+","+second.toString()+">";
    }
    public int hashCode(){
        return first.hashCode()*30011+second.hashCode()+2;
    }
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pair another = (Pair) obj;
        return this.getFirst().equals(another.getFirst())&&this.getSecond().equals(another.getSecond());
    }
}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<Pair<Long,Long>> balls = new HashSet<>();
        for(int n=0; n<N; n++){
            balls.add(new Pair<>(sc.nextLong(), sc.nextLong()));
        }

        int ans = 500000;
        for(Pair<Long,Long> b1:balls)for(Pair<Long,Long> b2:balls)if(!b1.equals(b2)){
            int cur = 0;
            long p = b1.first-b2.first;
            long q = b1.second-b2.second;
            for(Pair<Long,Long> b:balls){
                if(!balls.contains(new Pair<>(b.first-p, b.second-q))) cur++;
            }
            ans = Math.min(ans,cur);
        }

        if(N==1) ans=1;
        System.out.println(ans);
    }
}

Measured memory_bytes: 32468
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <numeric>

using namespace std;
typedef long long ll;

bool is_prime(ll n){
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++){
        if (n % i == 0 ) return false;
    }
    return true;
}

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

    int mini = min(a, b);
    vector<int> vec;

    for (int i = 1; i <= mini; i++){
        if (a % i == 0 && b % i == 0) vec.push_back(i);
    }

    sort(vec.rbegin(), vec.rend());
    cout << vec[k-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,w;
std::vector<pair<ll,ll>> vp;
ll dp[101][100010];

ll fnc(ll idx,ll cap){
  if(cap == 0)return 0;
  if(cap < 0) return - (1<<30);
  if(idx == n){
    if(cap >= 0)return 0;
    else return -(1<<30);
  }
  if(dp[idx][cap] !=-1)return dp[idx][cap];

  ll res1 = vp[idx].second + fnc(idx+1,cap-vp[idx].first);
  ll res2 = fnc(idx+1,cap);
  dp[idx][cap] = max(res1,res2);
  return dp[idx][cap];
}

int main(int argc, char const *argv[]) {
  memset(dp,-1,sizeof(dp));
  cin >> n >> w;
  for(int i = 0;i < n;i++){
    ll a,c;
    cin >> a >> c;
    vp.push_back(make_pair(a,c));
  }
  cout << fnc(0,w) << endl;

  return 0;
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b;
lol i[100];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol c=1,d=1,e=0,f=0,g=0,h=0;
  cin >>a;
  char ch='A';
  string s;
  cin >>s;
  ch=s[0];
  for(int n=1;n<a;n++){
      if(ch==s[n]) s[n]=0;
      else ch=s[n],d++;
  }
  cout <<d<<'\n';
  return (0);
}


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

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            String S = Console.ReadLine();
            String[] Line = S.Split(' ');
            int[] d = new int[N];

            for(int i=0; i<N; i++)
            {
                d[i] = int.Parse(Line[i]);
            }

            int ans = 0;

            for(int i=0; i<N-1; i++)
            {
                for(int j=i+1; j<N; j++)
                {
                    ans = ans + d[i] * d[j];
                }
            }

            Console.WriteLine(ans);
    

        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
constexpr int MOD = 1000000007;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return x * m % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    constexpr int N = 62;
    int n; cin >> n;
    vector<int> c1(N) , c0(N);
    REP(i,n) {
        ll x;
        cin >> x;
        bitset<N> bs(x);
        REP(j,N) {
            if(bs[j]) c1[j]++;
            else c0[j]++;
        }
    }

    int ans = 0;
    REP(i,N) {
        ans = mod(ans + mod(modm(modm(c1[i],c0[i]),mod(1LL << i))));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;

vector<bool> d(10,true);
bool ok(int x) {
    bool ret = true;
    while(x > 0) {
        if(!d[x%10]) {  //dに値が存在していないとダメ
            ret = false;
            break;
        }
        x /= 10;    //次の桁の確認に移動
    }
    return ret;
}

int main() {
    int n,k;
    cin >> n >> k;
    int D;
    for(int i = 0; i < k; i++) {
        cin >> D;
        d[D] = false;
    }
    int ans = n;
    while(!ok(ans)) {
        ans++;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include<math.h>
#include<stdio.h>
#include<utility>
#include<algorithm>

int main() {
	double r, S, l;
	scanf("%8lf", &r);/////////////////////
	S = M_PI*r*r;
	l = M_PI * 2 * r;
	
	printf("%8lf %8lf\n", S, l);
	return 0;
}

Measured memory_bytes: 2760
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

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

	int y = x / 500;

	int z = x - 500 * y;

	int cnt = 0;
	while (z > 4) {
		z -= 5;
		cnt++;
	}

		

	cout << y*1000+cnt*5;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define endl "\n"


void solve()
{
    long double a, b;
    cin >> a >> b;
    int ans = 1.0 * a * b;
    cout << ans;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
#include <cctype>
#include <ctype.h>
#define ll long long
char toupper(char c);
char toupper(char c)
{
    return (c - 0x20);
}

using namespace std;
int main()
{
    string s, ss;
    cin >> s;
    int ans = 0;    
  for (int i=0;i<s.size();i++)
    {
        ss[i] = s[s.size()-1-i];
    }
    for (int i = 0; i < s.size()/2; i++)
    {
        if (s[i] != ss[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> ret;
  int n,m;
  vector<int> a,b;
  stringstream ss,ss2;
  cin >> n;
  a.resize(n);
  for(ii=0;ii<n;ii++){
    cin >> a[ii];
    ss << a[ii];
  }

  cin >> m;
  b.resize(m);

  for(ii=0;ii<m;ii++){
    cin >> b[ii];
    ss2 << b[ii];
  }

  if(ss.str() >= ss2.str()){
    cout << 0 << endl;
  }
  else{
    cout << 1 << endl;
  }
  return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n - 1);
  rep(i, n - 1)
    cin >> a.at(i);
  
  vector<int> sub(n);
  rep(i, n - 1)
    sub.at(a.at(i) - 1)++;
  
  rep(i, n)
    cout << sub.at(i) << endl;
  
  return 0;
}

Measured memory_bytes: 4844
#include <stdio.h>

int main(){

  int h, w;
  int i, j;

  while(1){
    scanf("%d %d", &h, &w);
    if(w == 0 && h == 0)
      break;

    for(i = 0; i < h; i++){
      for(j = 0; j < w; j++){
	if(i > 0 && i < h-1 && j > 0 && j < w-1)
	  printf(".");
	else
	  printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
int cou[4010],a,b,c,d,e,f,x,y,dp[6010],ans1,ans2;
double mx;
vector<int>v1,v2;
int main()
{
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	dp[0]=cou[0]=1;
	for(int i=0; i<=4010; i++)
		if(cou[i])
			cou[i+c]=cou[i+d]=1;
	for(int i=0; i<=f; i++)
		if(dp[i])
		{
			dp[i+a*100]=dp[i+b*100]=1;
			v2.push_back(i);
		}
	for(int i=4000; i; i--)
		if(cou[i])
			v1.push_back(i);
	for(int i:v2)
	{
		int x=*lower_bound(v1.begin(),v1.end(),min(f-i,i/100*e),greater<int>());
		double now=100.0*x/(x+i);
		if(now>mx)
		{
			mx=now;
			ans1=i;
			ans2=x;
		}
	}
	if(mx>0)
		printf("%d %d",ans1+ans2,ans2);
	else
		printf("%d %d",a*100,0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N;
double A, d;

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A;
		d += 1 / A;
	}
	d = 1 / d;
	printf("%.10f\n", d);
}


Measured memory_bytes: 256
from itertools import permutations
n = int(input())
p = list(map(lambda x: int(x) - 1, input().split()))
q = list(map(lambda x: int(x) - 1, input().split()))


def compare(a, b):
    for i in range(n):
        if a[i] != b[i]:
            return False
    return True


idx_p = -1
idx_q = -1
for i, x in enumerate(permutations(range(n))):
    if compare(p, x):
        idx_p = i
    if compare(q, x):
        idx_q = i

ans = abs(idx_p - idx_q)
print(ans)


Measured memory_bytes: 3064
# https://atcoder.jp/contests/abc132/tasks/abc132_e
# ぱっと思いつくのはダイクストラで3回で到達できる点を探索していくとかかなぁ
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# 距離を3で割ったときに0,1,2余る場合について各ノードの最短距離を求めればよい

N, M = read_ints()
graph = defaultdict(lambda: [])
for _ in range(M):
    u, v = mina(*read_ints())
    graph[u].append(v + N)
    graph[u + N].append(v + 2 * N)
    graph[u + 2 * N].append(v)

S, T = mina(*read_ints())

pq = deque([])
D = [-3] * (N * 3)
D[S] = 0
pq.append((0, S))  # (最短距離, 次のノード)
while pq:
    d, v = pq.popleft()
    for to in graph[v]:
        if D[to] != -3:
            continue
        D[to] = d + 1
        pq.append((D[to], to))

print(D[T] // 3)


Measured memory_bytes: 98648
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n,d; cin >> n >> d;
    auto x = make_vec<int>(n,d);
    rep(i, n) {
        rep(j, d) {
            cin >> x[i][j];
        }
    }
    int count = 0;
    for(int i = 0; i< n; i++){
        for(int j = i+1; j< n; j++) {
            double distance = 0;
            for(int k = 0; k< d; k++) {
                distance += (x[i][k] - x[j][k])*(x[i][k]- x[j][k]);
            }
            distance = sqrt(distance);
            if(floor(distance) == distance)
                count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
N=int(input())
b=[]
for _ in range(N):
  b.append(input())
M=int(input())
r=[]
for _ in range(M):
  r.append(input())

from collections import Counter
red=Counter(r)
blue=Counter(b)
ans=0
for k, v in blue.items():
  ans=max(ans, v-red[k])
print(ans)

Measured memory_bytes: 9476
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef long long ll;


//すぬけさんのラムダ式BFSを実装。今後のBFSは脳死でこれを書けるようにしたい。
int main(){
    int n, x, y; cin >> n >> x >> y; x--; y--;
    vector<int> ans(n);

    //全ての頂点を全探索
    rep(sv, n){
        // ループの最後にans(n)に代入するようにする。
        vector<int> dist(n,1002003004);

        //すぬけ式ラムダBFS-変数autoが決め手
        queue<int> q;
        auto push = [&] (int v, int d){
            if(dist[v] != 1002003004) return;
            dist[v] = d;
            q.push(v);
        };

        //初期push
        push(sv,0);

        //BFS内部
        while(!q.empty()){
            int v = q.front(); q.pop();
            int d = dist[v];
            if(v-1 >= 0) push(v-1, d+1);
            if(v+1 < n) push(v+1, d+1);
            if(v == x) push(y, d+1);
            if(v == y) push(x, d+1);
        }

        rep(i,n) ans[dist[i]]++;

    }
    //双方向で考慮しているため答えを2で割ること。
    rep(i,n) ans[i] /= 2;

    for(int i= 1; i<=n-1; i++){
        cout << ans[i] << endl;
    }
}

    


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB emplace_back
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int,int>;
using pll = pair<ll,ll>;

constexpr int IN = 55;
constexpr int INF = 1e9+5;
constexpr int INI = -1;

vector <double> v;
double ans, a;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for(int i=0; i<n; ++i)
    {
        cin >> a;
        v.PB(a);
    }
    sort(v.begin(), v.end());
    ans = v[0];
    for (int i = 0; i < n; i++) {
        ans = (ans + v[i]) / 2;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
    _ "sort"
	 "strconv"
	_ "strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
    sc.Split(bufio.ScanWords)
    var cnt int
    N := nextInt()
    D := nextInt()
    
    for i := 0; i < N; i++ {
        X := nextInt()
        Y := nextInt()
  
        out := int(math.Ceil(math.Sqrt(math.Pow(float64(X),2)+math.Pow(float64(Y),2))))
        if D >= out {
            cnt++
        }
    }
    fmt.Println(cnt)
}

Measured memory_bytes: 4916
import java.util.HashMap;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 HashMap<Character,Integer  > hm= new HashMap<Character,Integer>();

		String a=sc.next();
		int sum=700;
		for(int i=0;i<a.length();i++) {
			int v;
			char b=a.charAt(i);
			if(hm.containsKey(b)){
				v=hm.get(b)+1;
}
			else {
				v=1;
			}
hm.put(b, v);


		}

int ans=hm.getOrDefault('o', 0);
sum=sum+ans*100;
System.out.println(sum);

}

}

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

const int N = 1e6 + 10;
int a[N], n, k;

bool change() {
    static int d[N];
    for (int i = 1; i <= n; i++) d[i] = 0;
    for (int i = 1; i <= n; ++i) {
        ++d[max(1, i - a[i])];
        --d[min(n + 1, i + a[i] + 1)];
    }
    for (int i = 1; i <= n; ++i) {
        d[i] += d[i - 1];
        a[i] = d[i];
    }
    for (int i = 1; i <= n; ++i) if (a[i] < n) return true;
    return false;
}

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    while (k && change()) --k;
    for (int i = 1; i <= n; ++i) cout << a[i] << " ";
    return 0;
}

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

int main(){
	int a[5];

	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

	for ( int i = 0; i < 4; ++i ){
		for ( int j = 0; j < 4-i; ++j ){
			if ( a[ j ] < a[ j + 1 ] ){
				int t = a[ j ];
				a[ j ] = a[ j + 1 ];
				a[ j + 1 ] = t;
			}
		}
	}

	cout << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << " " << a[4] << endl;

	return 0;
}

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

struct start { start() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(10);
}; }start;

typedef long long ll;


int main(){
    int a,b;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        if(op == '?'){
            break;
        }
        else{
            switch(op){
                case '+':
                    cout << a+b << endl;
                    break;
                case '-':
                    cout << a-b << endl;
                    break;
                case '*':
                    cout << a*b << endl;
                    break;
                case '/':
                    cout << a/b << endl;
                    break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3188
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] d = new int[n];
    for(int i=0;i<n;i++)d[i]=sc.nextInt();
    int sum = 0;
    for(int i=0;i<n;i++)
      for(int j=0;j<i;j++){
        if(i!=j)sum+=d[i]*d[j];
      }
    System.out.println(sum);
  }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    ll a,b;
    cin >> n >> a >> b;
    if((b-a)%2==0){
        cout << (b-a)/2 << endl;
    }else{
        ll ans = LLINF;
        ll t = 0;
        t = n-b+1;
        ll ta = a+t;
        t = t+(n-ta)/2;
        ans = t;
        t = a;
        ll tb = b-t;
        t =  t+(tb-1)/2;
        cout << min(ans,t) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a) for (ll i = a; i >= 0; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    map<ll, ll> M;
    rep (i, N) {
        ll a;
        cin >> a;
        ++M[a];
    }
    vector<pair<ll, ll>> V;
    for (auto it : M) {
        V.pb({it.snd, it.fst});
    }
    sort(all(V));
    ll k = V.size();
    ll ans = 0;
    ll i = 0;
    while (k > K) {
        ans += V[i].fst;
        ++i;
        --k;
    }
    cout << ans << endl;
}



Measured memory_bytes: 18156
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 1000000000
#define ldb long double
#define pb push_back
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE ll i=p;i<=n;++i)
#define go(x) for(ll i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE ll i=n;i>=p;--i)
#define pii pair<ll,ll>
#define mk make_pair
#define RE register
#define P 1000000007
#define mod 1000000007
#define S second 
#define F first
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define ull unsigned long long
#define ui unsigned
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
    register ll x=0,f=1;register char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
    return x*f;
}
const ll MAXN=2010;
ll n,k,ans;
signed main()
{
	//freopen("1.in","r",stdin);
	get(n);get(k);
	rep(k,n+1,i)
	{
		ll w1=(i-1)*i/2;
		ll w2=(n-i+1+n)*i/2;
		ans+=(w2-w1+1);
	}
	putl(ans%mod);
	return 0;
}


Measured memory_bytes: 3764
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
    static void Main(string[] args)
    {
		string[] inputnq = Console.ReadLine().Split(' ');
		int n = int.Parse(inputnq[0]);
		int q = int.Parse(inputnq[1]);
		string S = Console.ReadLine();
		char[] s = new char[n];
		for (var i = 0; i < n; i++)
		{
			s[i] = S[i];
		}
		
		int[] l = new int[q];
		int[] r = new int[q];
        for(var i = 0; i < q; i++)
		{
			string[] input = Console.ReadLine().Split(' ');
			l[i] = int.Parse(input[0]);
			r[i] = int.Parse(input[1]);
		}
		int[] t = new int[n];
        for(var i = 0; i < n - 1; i++)
		{
			if (s[i] == 'A' && s[i + 1] == 'C')
			{
				s[i] = 'a';
			}
		}
        for(var i = 0; i < n; i++)
		{
			if (i == 0) { if (s[0] == 'a') { t[0] = 1; }
				else { t[0] = 0; }
			}
			else
			{
				if (s[i] == 'a') { t[i] = t[i - 1] + 1; }
				else { t[i] = t[i - 1]; }
			}

		}

        for(var i = 0; i < q; i++)
		{
			int ans = 0;
			if (r[i] == 1) { ans = 0; }
            else if (l[i] == 1) { ans = t[r[i] - 2]; }
			else {ans = t[r[i] - 2] - t[l[i] - 2]; } 
			Console.WriteLine(ans);
		}
    }
}



Measured memory_bytes: 17348
program prob3
    implicit none
    integer::i,cnt,le,N,Q,l,r
    integer, allocatable::c(:)
    character(len=100005)::S
    read(*,*) N,Q
    read(*,*) S
    le = len_trim(S)
    allocate(c(le))

    cnt = 0
    do i = 2, le
        if(S(i-1:i-1) .eq. "A" .and. S(i:i) .eq. "C") then
            cnt = cnt + 1
        end if
        c(i) = cnt
    end do

    do i = 1, Q
        read(*,*) l, r
        write(*,*) c(r) - c(l)
    end do
end program

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int ans=1,odd=1;
  int n;
  cin>>n;
  rep(i,n){
    int num;
    cin>>num;
    if(num%2==0){
      odd*=2;
    }
    ans*=3;
  }
  cout<<ans-odd<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A+B < C+D) cout << "Right" << endl;
    else if (A+B > C+D) cout << "Left" << endl;
    else cout << "Balanced" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

void dfs(vector<vector<int>> &G, vector<ll> &count, int node = 0,
         int from = -1) {
  for (auto v : G[node]) {
    if (v == from)
      continue;
    count[v] += count[node];
    dfs(G, count, v, node);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<int>> G(n);
  vector<ll> count(n, 0);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = 0; i < q; i++) {
    int p, x;
    cin >> p >> x;
    p--;
    count[p] += x;
  }
  dfs(G, count);
  for (auto i : count) {
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 30464
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
   int n, a, b;
   cin >> n >> a >> b;
   cout << min(b,n*a) << endl; 
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int di[4] = {0, 0, 1, 1};
int dj[4] = {0, 1, 0, 1};

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

    vi ans;
    rep(dd, 4) {
        ans.assign(n, 0);
        ans[0] = di[dd];
        ans[n-1] = dj[dd];

        rep(i, n-2) {
            if(ans[i] == 0) {
                if(s[i] == 'o') {
                    ans[(i+1)%n] = ans[(i-1+n)%n];
                } else {
                    ans[(i+1)%n] = ans[(i-1+n)%n]^1;
                }
            } else {
                if(s[i] == 'x') {
                    ans[(i+1)%n] = ans[(i-1+n)%n];
                } else {
                    ans[(i+1)%n] = ans[(i-1+n)%n]^1;
                }
            }
        }
        bool x = false, y = false;
        if(ans[n-2] == 0) {
            if(s[n-2] == 'o') {
                if(ans[n-3] == ans[n-1]) x = true;
            } else {
                if(ans[n-3] == (ans[n-1]^1)) x = true;
            }
        } else {
            if(s[n-2] == 'x') {
                if(ans[n-3] == ans[n-1]) x = true;
            } else {
                if(ans[n-3] == (ans[n-1]^1)) x = true;
            }
        }
        if(ans[n-1] == 0) {
            if(s[n-1] == 'o') {
                if(ans[0] == ans[n-2]) y = true;
            } else {
                if(ans[0] == (ans[n-2]^1)) y = true;
            }
        } else {
            if(s[n-1] == 'x') {
                if(ans[0] == ans[n-2]) y = true;
            } else {
                if(ans[0] == (ans[n-2]^1)) y = true;
            }
        }
        if(x and y) break;
        if(dd == 3) {
            cout << -1 << endl;
            return 0;
        }
    }

    rep(i, n) {
        cout << (ans[i] ? 'W':'S');
    }
    cout << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };

int main(void) {
    int n;
    std::vector<int> a(3);
    std::cin >> a[0] >> a[1] >> a[2] >> n;
    std::sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        a[2]=a[2]*2;
    }
    std::cout << a[1]+a[0]+a[2] <<std::endl;
    return 0;
}

Measured memory_bytes: 256
N, M= map(int, input().split())
L=[]
R=[]
for i in range(M):
    l_tmp, r_tmp = map(int, input().split())
    L.append(l_tmp)
    R.append(r_tmp)
    
if min(R) < max(L):
    ans = 0
else:
    ans = min(R) - max(L) + 1

print(ans)

Measured memory_bytes: 10996
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define REP(i, n) for(int i = 0; i < n; i++) //普通のループ
#define REPR(i, n) for(int i = n; i >= 0; i--) //逆ループ
#define FOR(i, m, n) for(int i = m; i < n; i++) //最初の数値を指定したループ

//型名省略
typedef long long ll;

using namespace std;

//#include "./lib/string.h"

int main(){
    //string s;
    //bool ans;
    ll n, k, ans;

    cin >> n >> k;

    if(0>n || n>1000000000000000000){
        return 0;
    }
    if(1>k || k>1000000000000000000){
        return 0;
    }

    ans = n;
    ll tmp, cnt;
    cnt = ans/k;
    ans = ans-cnt*k;
    
    tmp = ans-k;
    if(ans > abs(tmp)){
        ans = abs(tmp);
    }
    cout << ans;
    
    //ans = checkCharacterMatching(s, 2, 3);
    //cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


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


int main() {
    long long int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    long long int max = std::max(a * c, a * d);
    max = std::max(b * c, max);
    max = std::max(b * d, max);
    std::cout << max << std::endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int n;
int main()
{
	int a,b;
	scanf("%d%d%d",&n,&a,&b);
	printf("%d",((n-a)%b));
	putchar(10);
	return 0;
}

Measured memory_bytes: 256
import math

N, H = map(int, input().split())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort(reverse=True)
B.sort(reverse=True)

score = 0
for i in range(N):
    if B[i] <= A[0]:
        i = i - 1
        break
    score += B[i]
    if score >= H:
        print(i + 1)
        exit()

print(math.ceil((H - score) / A[0]) + i + 1)


Measured memory_bytes: 11264
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res


N,K,Q=LI()

RES=[K-Q]*N
for i in range(Q): RES[II()-1] += 1
for v in RES:
    print('Yes' if v > 0 else 'No')


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
 
int main(){
	string s;
    cin>>s;
    s[5]=' ';
    s[13]=' ';
    cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{␣"; for(auto nth : list){ cout << nth << "␣"; } cout << "}" << endl;

using namespace std;

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

    map<string, int> cnt;
    int ai, ans = 0;
    for (int nth = 0; nth < N; ++nth) {
        cin >> ai;
        ai -= 1;
        int i = nth;
        if (i > ai) {
            int tmp = ai;
            ai = i;
            i = tmp;
        }
        string p = to_string(i)+","+to_string(ai);
        if (!cnt.count(p)) {
            cnt[p] = 1;
        } else {
            cnt[p] += 1;
        }
        if (cnt[p] >= 2) ans += 1;
    }

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


Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define i64 long long
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x),v) - x.begin()
#define UB(x,v) upper_bound(all(x),v) - x.begin()
using namespace std;
int main() {
	// your code goes here
	int K,S;
	cin>>K>>S;
	vector<int>X_plus_Y;
	
	for(int x=0;x<=K;x++){
		for(int y=0;y<=K;y++){
			X_plus_Y.push_back(x+y);
		}
	}
	sort(all(X_plus_Y));
	
	/*for(int i=0;i< X_plus_Y.size();i++) printf("%d ",X_plus_Y[i]);
	printf("\n");*/
	
	int cnt;
	i64 ans = 0;
	for(int z=0;z<=K;z++){
		//printf("%d\n", s-z);
		int s = LB(X_plus_Y , S-z), e =  UB(X_plus_Y , S-z); 
		cnt = e-s;
		//printf("%d %d %d %d\n", S-z,s,e,cnt);
		if(cnt>0 and cnt<=X_plus_Y.size()) ans+=(i64)cnt;
	}
	//printf("%d %d\n", LB(X_plus_Y, 2),UB(X_plus_Y, 2));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 34148
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int a, b;
    cin >> a >> b;

    if(a > 9 or b > 9)
    {
        cout << -1 << endl;
    }else
    {
        cout << a * b << endl;
    }
}

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

namespace
{
  static std::array<int, 1000001> ng_nums = {};
  static std::array<int, 1000001> num_count = {};

}

namespace ABC170
{

  class D
  {
  public:
    D() = default;
    ~D() = default;


    void Run()
    {
      int N;
      std::cin >> N;

      std::vector<int>A = {};
      for (int i = 0; i < N; ++i)
      {
        int v;
        std::cin >> v;
        A.push_back(v);
      }
      std::sort(A.begin(), A.end());

      for(auto v : A)
      {
        if (ng_nums[v] == 0)
        {
          if (num_count[v] == 1) { ng_nums[v] = 1; }

          for (int i = v + v; i <= 1000000; i += v)
          {
//            if (ng_nums[i] == 1) { break; }
            ng_nums[i] = 1;
          }
        }

        num_count[v] = 1;
      }

      int count = 0;
      for (int i = 0; i < N; ++i)
      {
        if (ng_nums[A[i]] == 0) count++;
      }

      std::cout << count << std::endl;
    }
  };

}
int main()
{

  ABC170::D prob;
  prob.Run();

  return 0;
}



Measured memory_bytes: 11536
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


A = LIST()

A.sort()

if A == [5, 5, 7]:
	print("YES")
else:
	print("NO")

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

int main() {
  long long n;
  cin >> n;
  int minDigitSum = 100000;
  for (int i = 1; i <= (n + 1) / 2; i++) {
    int x = i;
    int digitSumX = 0;
    while (x > 0) {
      digitSumX += x % 10;
      x /= 10;
    }
    int y = n - i;
    int digitSumY = 0;
    while (y > 0) {
      digitSumY += y % 10;
      y /= 10;
    }
    if (minDigitSum > digitSumX + digitSumY)
      minDigitSum = digitSumX + digitSumY;
  }
  cout << minDigitSum << endl;
  return 0;
}

Measured memory_bytes: 256