akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

const int N = 2e5 + 5;
typedef long long LL;

int n, a[N], b[N];
LL ans;
map <int, int> M;

int main() {
	cin>>n;
	for(int i = 1; i <= n; i++) 
		cin>>a[i], b[i] = a[i];
	sort(b + 1, b + n + 1);
	for(int i = 1; i <= n; i++)
	    M[b[i]] = i;
	for(int i = 1; i <= n; i++)
	    a[i] = M[a[i]];
	for(int i = 1; i <= n; i += 2) 
		if(a[i]%2 != i%2) ans++; 
	cout<<ans<<endl;
	return 0;
}

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

const int mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (t == 0) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& i, mint& var) {
    ll tmp; i >> tmp;
    var.x = tmp;
    return i;
}
ostream& operator<<(ostream& o, const mint& var) {
    o << var.x;
    return o;
}
vector<mint> fac, fac_inv;
void init() {
    int MAX_N = 1e3+10;
    fac.assign(MAX_N,1);
    fac_inv.assign(MAX_N,1);
    for (int i = 0; i < MAX_N; ++i) {
        fac[i+1] = fac[i] * mint(i+1);
        fac_inv[i+1] = fac[i+1].inv();
    }
}
mint perm(int n, int r) {
    return fac[n] * fac_inv[n-r];
}

ll n, a, b, c, d;
mint dp[1010][1010];

int main() {
    cin >> n >> a >> b >> c >> d;
    init();
    dp[a][0] = 1;
    rng(i,a,b+1) {
        rep(j,n+1) {
            dp[i+1][j] += dp[i][j];
            rng(k,c,d+1) {
                if (j+i*k > n) break;
                mint mul = perm(n-j,i*k) * fac_inv[i].pow(k) * fac_inv[k];
                dp[i+1][j+i*k] += mul * dp[i][j];
            }
        }
    }

    mint ans = dp[b+1][n];
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll N,K;
    cin >>N >>K;
    ll n;
    ll ans = 0;
    rep(i,N){
        cin >> n;
        ans += min(n,abs(n - K));
    }
    cout << ans * 2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
        int c0=0;
        int c1=0;
        int c2=0;
        int c3=0;

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] str = new String[n];
        for(int i = 0; i<n; i++){
            str[i] = sc.next();
        }
         sc.close();
        for(int i = 0; i<n; i++){
            if(str[i].equals("AC")) {
                c0++;
            }else if(str[i].equals("WA") ){
                c1++;
            }else if(str[i].equals("TLE") ){
                c2++;
            }else if(str[i].equals("RE")){
                c3++;
            }
        }
       
        System.out.println("AC x "+c0);
        System.out.println("WA x "+c1);
        System.out.println("TLE x "+c2);
        System.out.println("RE x "+c3);


    }
}

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

#define MOD 1000000007

int main(void)
{
  int N, M;
  cin >> N >> M;
  long long ans = 1;

  if(N-M>1 || M-N>1) {
    cout << 0 << endl;
  } else {
    if(N==M) ans *= 2;
    while(N>0) {
      ans = (ans * N) % MOD;
      N--;
    }
    while(M>0) {
      ans = (ans * M) % MOD;
      M--;
    }
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math

N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()

s1 = S[: int(N / 2)]
s2 = S[int(N/2):]
if (s1 == s2):
    print('Yes')
else:
    print('No')


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

#define ll long long int
#define li int64_t

int main()
{
	int n;
	cin>>n;
	int ac = 0,wa = 0,tle = 0,re = 0;
	while(n--)
	{
		string s;
		cin>>s;
		if(s == "AC")ac++;
		else if(s == "WA")wa++;
		else if(s == "TLE")tle++;
		else{
			re++;
		}
	}	

	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
}

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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] != s[s.size() - i - 1]) cnt++;
    }
    cout << cnt / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}

int main(){
  fastIO();
  int n;
  cin>>n;
  vector<int>h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  for(int i=0;i<n-1;i++){
    if(h[i+1]<h[i]){
      h[i]--;
    }else if(i>0){
      if(h[i+1]==h[i]&&h[i]>h[i-1]){
        h[i]--;
      }
    }

  }
  bool yes=true;
  for(int i=0;i<n-1;i++){
    if(h[i+1]<h[i]){
      yes=false;
    }
  }
  if(yes){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 640
k = int(input())
val = [0]
for _ in range(k):
    if len(val) == 1:
        if val[0] != 9:
            val[0] += 1
        else:
            val.insert(0, 1)
            val[-1] = 0
    else:
        accept = False
        for i in range(1, len(val)):
            if val[-1*(i+1)] >= val[-1*i] and val[-1*i] != 9:
                val[-1*i] += 1
                for r in range(1,i):
                    val[-1*(i-r)] = max(0, val[-1*(i-r+1)]-1)
                accept = True
                break
        if not accept:
            if val[0] != 9:
                val[0] += 1
                for i in range(1, len(val)):
                    val[i] = max(val[i-1] - 1, 0)
            else:
                val.insert(0,1)
                for i in range(1, len(val)):
                    val[i] = 0

op = ""
for v in val:
    op += str(v)
print(op)



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


int main(){
    int ch, n;
    char input[12000] = "";
    scanf("%d", &n);
    scanf("%s", input);

    int len = strlen(input);

    for(int i = 0; i < len; i++){
  
        int ch = input[i] - 'A';
        ch += n;
        ch = (ch % 26) + 'A';
        putchar(ch);
    }
    printf("\n");
 
    return 0;
}

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

int main() {
  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);
  if(a%2==0) {
    printf("No\n");
  } else {
    if (b%2==0) {
      printf("No\n");
    } else {
      printf("Yes\n");
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n,m;cin>>n>>m;
    vvb ok(n,vb(4,true));
    rep(i,m){
        ll x,y;cin>>x>>y;ok[y][x]=false;
    }
    ll ans=0;
    vvi dp(n,vi(16));
    rep(i,n-1)rep(j,16)rep(k,3){
        if(ok[i][k]&&ok[i+1][k]&&ok[i][k+1]&&ok[i+1][k+1]&&(j>>k&1)==0&&(j>>(k+1)&1)==0){
            chmax(dp[i+1][(1<<k)+(1<<k+1)],dp[i][j]+1);
        }
        chmax(dp[i+1][0],dp[i][j]);
        bool b=true;
        if(j)b=false;
        rep(t,4)if((!ok[i][t])||(!ok[i+1][t]))b=false;
        if(b)chmax(dp[i+1][15],dp[i][j]+2);
    }
    rep(i,n)rep(j,16)chmax(ans,dp[i][j]);
    out(ans);
}


Measured memory_bytes: 5264
import scala.io.StdIn.readInt
import scala.collection.mutable.ArrayBuffer

object Main {
  def sieve(n:Int) = {
    val list = Array.tabulate(n+1) { _ % 2 }
    val primes = new ArrayBuffer[Int]
    list(1) = 0
    list(2) = 2
    primes += 2

    for( i <- 3 to Math.sqrt(n).toInt by 2 )
    {
      if(list(i) == 1) {
        (i*i to n by i*2).foreach { list(_) = 0 }
        primes += primes(primes.length-1)+i
      }
    }
    for(i<-Math.sqrt(n).toInt+1 to n if list(i)==1)
      primes += primes(primes.length-1)+i
    primes.toArray
  }

  def main(args:Array[String]) = {
    val p = sieve(200000)
    var n = 0
    while( { n = readInt; n} != 0 ) println(p(n-1))
  }
}

Measured memory_bytes: 53296
#include <iostream>
#include <string>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    set<int> ss;
    int r=0;
    for(int i=0;i<3;i++){
        int n;
        cin>>n;
        if(ss.find(n)==ss.end()){
            ss.insert(n);
            r++;
        }
    }
    cout<<r<<endl;
    return 0;
    // Your code here!
    
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			char a = in.nextChar();
			char b = in.nextChar();
			if(a == 'H' && b == 'H' || a == 'D' && b == 'D') {
				out.println('H');
			} else {
				out.println('D');
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}


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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var cin = GetIntArray();
            var max = cin.Max() % 2 == cin.Sum() % 2 ? cin.Max() : cin.Max() + 1;
            var ans = (max * 3 - cin.Sum()) / 2;


            Console.WriteLine(ans);
        }


        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

signed main() {
  string S;
  cin >> S;
  
  int N = (int)S.size();
  if( N == 1 ){
    cout << S << endl;
    return 0;
  }
  
  int ans = 0;
  for (int bit = 0; bit < (1<<N-1); ++bit) {
    int now = 0;
    for (int i = 0; i < N-1; ++i) {
      if (bit & (1<<i)) { // i番目のbitが立っていれば
        now = now*10 + ctoi(S.at(i));
        ans += now;
        now = 0;
      }else{
        now = now*10 + ctoi(S.at(i));
      }
    }
    now = now*10 + ctoi(S.at(N-1));
    ans += now;
  }
  
  cout << ans << endl;
}


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

int main(){
  int n,q;
  while(cin>>n>>q && n+q){
    int dates[100]={0};
    int max=-1;
    for(int i=0;i<n;i++){
      int m;
      cin>>m;
      for(int j=0;j<m;j++){
	int d;
	cin>>d;
	dates[d]++;
	if(dates[d] > max){
	  max = dates[d];
	}
      }
    }
    int date=0;
    for(int i=0;i<100;i++){
      if(dates[i]==max){
	date=i;
	break;
      }
    }
    if(max<q)
      cout<<0<<endl;
    else
      cout<<date<<endl;

  }
  return 0;
}

Measured memory_bytes: 1160
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC168
{
    class D
    {
        static void Main(string[] args)
        {
            //var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            //var abcd = Enumerable.Repeat(0, (int)Q).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var AB = Enumerable.Repeat(0, (int)M).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();            
            var NM = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = NM[0]; var M = NM[1];

            // node は 0index に変更する
            List<long>[] list = new List<long>[N];
            for (int i = 0; i < N; i++)
            {
                list[i] = new List<long>();
            }

            for (int i = 0; i < M; i++)
            {
                var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();
                var A = AB[0] - 1; var B = AB[1] - 1;
                list[A].Add(B);
                list[B].Add(A);
            }

            var res = new long[N];
            var visited = new bool[N];
            Queue<long> tq = new Queue<long>();
            tq.Enqueue(0);
            visited[0] = true;
            //dist[sx, sy] = 0;
            ///int[] vx = { 0, 1, 0, -1 };
            ///int[] vy = { 1, 0, -1, 0 };
            while (0 < tq.Count)
            {
                var next = tq.Dequeue();

                for (int i = 0; i < list[next].Count; i++)
                {
                    // int nx = x + vx[i];
                    // int ny = y + vy[i];

                    if (!visited[list[next][i]])
                    {
                        visited[list[next][i]] = true;
                        res[list[next][i]] = next + 1;
                        tq.Enqueue(list[next][i]);
                    }
                }
            }
            //Console.WriteLine(string.Join(" ", res));
            Console.WriteLine("Yes");
            for (int i = 1; i < N; i++)
            {
                Console.WriteLine(res[i]);
            }
        }
    }
}


Measured memory_bytes: 55152
#include <bits/stdc++.h>
using namespace std;
using sint = int64_t;

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

sint gcd(sint y, sint x) {
    while (x != 0) {
        sint t = y % x;
        y = x;
        x = t;
    }
		return y;
}

void run() {
	auto const A = read<sint>();
	auto const B = read<sint>();
	writeln(A / gcd(A, B) * B);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  cout << C - min(A-B, C) << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
ll n,d;
void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>d;
  ll dp[n][d];
  rep(i,n)rep(j,d)cin>>dp[i][j];
  ll cnt = 0;
  rep(i,n) rep(j,n){
    if(i==j) continue;
    else {
      float sum=0;
      rep(l,d) sum+=pow(abs(dp[i][l]-dp[j][l]),2);
      sum = sqrt(sum);
      if(sum==int(sum)) cnt++;
    }
  }
  cout<<cnt/2<<endl;

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


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    *A, = map(int, input().split())

    r = 1
    X = 0
    #上位から決めていかないと
    while (r <= K):
        r *= 2
    
    while (0 < r):
        count = 0
        for a in A:
            if (0 < (r & a)):
                count += 1
        #print(count)
        if (N//2 >= count):
            if ((X+r) <= K):
                X += r
        
        r //= 2
    #print(X)
    res = 0
    for a in A:
        res += X ^ a
    print(res)
main()


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

int freq[100010];
int main(){
	int i , j;
	for(i = 0; i < 100010; i++){
		freq[i] = 0;
	}
	int n,x;
	int ans = 0;
	cin>>n;
	for(i = 0; i < n ; i ++){
		cin>>x;
		freq[x]++;
	}
	i = 1; j = 100000;
	while(i != j){
		if(freq[i]==0 || freq[i]==1){
			i++;continue;
		}
		if(freq[j]==0 || freq[j]==1){
			j--;continue;
		}
		if(freq[i] > freq[j]){
			freq[i] = freq[i] - freq[j] + 1;
			freq[j] = 1;
			j--;
		}
		else if(freq[i] < freq[j]){
			freq[j] = freq[j] - freq[i] + 1;
			freq[i] = 1;
			i++;
		}
		else{
			freq[i] = freq[j] = 1;
			i++;j--;
		}
		if(i > j)break;
	}
	for(i = 0; i < 100010; i++){
		if(freq[i]%2 == 0)continue;
		else ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 640
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
d=list(map(int,input().split()))
d.sort()
res=24
if n==1 or 0 in d:
  print(d[0])
  exit()
for i in range(0,n-2):
    res=min(res,d[i+2]-d[i])
for i in range(n-1):
    res=min(res,d[i]+d[i+1],24-d[i]-d[i+1])
ans=min(d[0],res)
print(ans)

Measured memory_bytes: 65420
import java.util.Scanner;

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

        if ((b-a)%2==1){
                System.out.println("Borys");
        }else {
            System.out.println("Alice");
        }
    }
}


Measured memory_bytes: 23764
n,m,p=map(int,input().split())
y=list(map(int,input().split()))
x=list(list(map(int,input().split())) for _ in range(n))

import numpy as np

cnt=0

for i in range(n):
	if np.dot(np.array(y),np.array(x[i]).T)+p>0:
		cnt+=1

print(cnt)

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

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		while (true) {
			int W = sc.nextInt();
			int Q = sc.nextInt();
			if (W == 0 && Q == 0) break;
			int[] wall = new int[W];
			Arrays.fill(wall, -1);
			for (int i = 0; i < Q; ++i) {
				String q = sc.next();
				int id = sc.nextInt();
				if (q.equals("s")) {
					int width = sc.nextInt();
					int pos = -1;
					for (int j = 0; j <= W - width; ++j) {
						boolean ok = true;
						for (int k = 0; k < width; ++k) {
							if (wall[j + k] != -1) {
								ok = false;
								break;
							}
						}
						if (ok) {
							pos = j;
							for (int k = 0; k < width; ++k) {
								wall[j + k] = id;
							}
							break;
						}
					}
					System.out.println(pos == -1 ? "impossible" : pos);
				} else {
					for (int j = 0; j < W; ++j) {
						if (wall[j] == id) wall[j] = -1;
					}
				}
			}
			System.out.println("END");
		}
	}

}

Measured memory_bytes: 12000
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
      
		String[] slist = s.split("");
        int[] list = new int[s.length()];
        for(int tmp = 0; tmp < slist.length ; tmp++){
            list[tmp] = Integer.parseInt(slist[tmp]);
        }
        
        int result = 0;
        for(int tmp1 = 0; tmp1 < list.length - 2 ; tmp1++) {
        	int a = list[tmp1]*100 + list[tmp1+1]*10 + list[tmp1+2];
        	int absdiff = Math.abs(753 - a);
        	if(tmp1 == 0) {
        		result = absdiff;
        	} else {
        		result = result <= absdiff ? result : absdiff;
        	}
        }
        System.out.println(result);
	}
}

Measured memory_bytes: 22864
#include<cstdio>
#include<algorithm>

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

using namespace std;

const double EPS=1e-9;

struct Point{ double x,y; };

int n;
Point _f[100],_g[100];

double f(double x){
	if(x<_f[0].x) return 0;
	rep(i,n-1){
		double x1=_f[i].x,x2=_f[i+1].x;
		double y1=_f[i].y,y2=_f[i+1].y;
		if(x<x2) return (y2-y1)/(x2-x1)*(x-x1)+y1;
	}
	return 0;
}

double g(double x){
	if(x<_g[0].x) return 0;
	rep(i,n-1){
		double x1=_g[i].x,x2=_g[i+1].x;
		double y1=_g[i].y,y2=_g[i+1].y;
		if(x<x2) return (y2-y1)/(x2-x1)*(x-x1)+y1;
	}
	return 0;
}

int main(){
	for(double r;scanf("%d%lf",&n,&r),n;){
		double ev[200];
		rep(i,n){
			int x,y; scanf("%d%d",&x,&y);
			_f[i]=(Point){x,y};
			_g[i]=(Point){x+r,y};
			ev[2*i+0]=x;
			ev[2*i+1]=x+r;
		}
		sort(ev,ev+2*n);

		double ans=0;
		rep(i,2*n-1){
			double x1=ev[i],x2=ev[i+1];
			if(x2-x1<EPS) continue;

			double f1=f(x1),f2=f(x2),g1=g(x1),g2=g(x2);
			double af=(f2-f1)/(x2-x1),bf=f1-af*x1;
			double ag=(g2-g1)/(x2-x1),bg=g1-ag*x1;
			ans+=af*ag*(x2*x2*x2-x1*x1*x1)/3+(af*bg+bf*ag)*(x2*x2-x1*x1)/2+bf*bg*(x2-x1);
		}
		printf("%.15f\n",ans);
	}

	return 0;
}

Measured memory_bytes: 820
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
  ll ans=999999999999999999;
  if(k%2==0)ans=min(x,ans);
  ll steps=min(k,x/d);
  x-=steps*d;
  k-=steps;
  if(k%2==0)ans=min(ans,x);
  if(k>0){
    x-=d;
    k--;
    if(k%2==0)
    ans=min(ans,abs(x));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3588
import sys
import decimal # 10進法に変換，正確な計算

def input():
    return sys.stdin.readline().strip()

def main():
    n = int(input())
    n = decimal.Decimal(n)
    if n % 2 == 0:
        print(1/decimal.Decimal(2))
        return
    
    print(((n-1)/2+1)/n)

    
    
main()

Measured memory_bytes: 5076
import copy

def ok(len_4):    
    for i in range(3):
        alpha = list(copy.deepcopy(len_4))
        alpha[i], alpha[i + 1] = alpha[i + 1], alpha[i]
        if "AGC" in "".join(alpha):
            return False
    if "AGC"in len_4:
        return False
    return True


def check(len_3, n):
    if n == N:
        return 1
    if len_3 in memo[n]:
        return memo[n][len_3]
    ret = 0
    for alpha in "AGCT":
        t = len_3 + alpha
        if ok(t):
            temp = check(t[1:], n + 1)
            memo[n + 1][t[1:]] = temp % mod
            ret += temp % mod
    return ret % mod


mod = (10 ** 9) + 7
N = int(input())
memo = [{} for _ in range(N + 1)]
ans = check("TTT", 0)
print(ans)

Measured memory_bytes: 4272
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <chrono>
#include <random>
#include <functional>
#include <utility>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

vi adj[50];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for (int i = 0; i < n; i++) {
        cout << adj[i].size() << endl;
    }
}


Measured memory_bytes: 384
import sys
n, k = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(n)]
tmp = {}
for l in li:
    if l[0] in tmp:
        tmp[l[0]] += l[1]
    else:
        tmp[l[0]] = l[1]
sorted_tmp = sorted(tmp.items())
for s in sorted_tmp:
    if k > s[1]:
        k = k -s[1]
    else:
        print(s[0])
        sys.exit()

Measured memory_bytes: 35784
h, _ = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(h)]

N = 10
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])

ans = 0
for aa in A:
    for a in aa:
        if a != -1:
            ans += d[a][1]

print(ans)


Measured memory_bytes: 3316
package main
import (
  "fmt"
)

func gcd(a, b int) int {
  if b == 0 {
    return a
  }
  return gcd(b, a%b)
}

func primeFactorsCnt(n int) int {
  result := make(map[int]bool)
  result[1] = true
  for n%2 == 0 {
    result[2] = true
    n /= 2
  }
  
  for i := 3; i*i <= n; i += 2 {
    for n%i == 0 {
      result[i] = true
      n /= i
    }
  }
  
  if 2 < n {
    result[n] = true
  }
  return len(result)
}

func main() {
  var a, b int
  fmt.Scan(&a, &b)
  num := gcd(a, b)
  result := primeFactorsCnt(num)
  fmt.Println(result)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int A[100100];
map<int,int>mp;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]),mp[A[i]]++;
	sort(A+1,A+1+n);
	long long r1=-1,r2=-1;
	for(int i=n;i>=1;i--){
		if(r1==-1&&mp[A[i]]>=2)r1=A[i];
		else if(r2==-1&&1LL*A[i]!=r1&&mp[A[i]]>=2&&r1!=-1){
			cout<<1LL*A[i]*r1<<endl;
			return 0;
		}
		else if(r2==-1&&mp[A[i]]>=4){
			cout<<A[i]*r1<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
}



Measured memory_bytes: 5376
from collections import defaultdict

s = input()
x, y = map(int, input().split())

d = [len(x) for x in s.split('T')]

dx = d[0::2]
n_dx = len(dx)
dp = {0}
for i in range(n_dx):
    tmp = set()
    for j in dp:
        if i == 0:
            tmp.add(j + dx[i])
        else:
            tmp.add(j - dx[i])
            tmp.add(j + dx[i])
    dp = tmp
x_flag = x in dp

dy = d[1::2]
n_dy = len(dy)
dp = {0}
for i in range(n_dy):
    tmp = set()
    for j in dp:
        tmp.add(j - dy[i])
        tmp.add(j + dy[i])
    dp = tmp
y_flag = y in dp

if x_flag and y_flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3936
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<queue>
#include<cmath>
#include <string>
#include<map> 
#include<deque>  
#include<vector>
#include<bitset>
#include<string>  
#include<cstring> 
#include<stack>  
#include<set>
#include<functional>
#define mst(x,y) memset(x,y,sizeof x)
#define mp(x,y) make_pair((x),(y))
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;
int n,dis[203],hed[202],K,v[202],ans=-1234567890;
int a[1234],b[1234];
priority_queue<pii,vector<pii>,greater<pii> > q;
struct edge{
	int v,next,w;
}e[200005];
void adde(int u,int v,int w){
	e[K].w=w;
	e[K].v=v;
	e[K].next=hed[u];
	hed[u]=K++;
}
void g(int vl){
	q.push(mp(0,0));int u;
	dis[0]=0;
	while(!q.empty()){
		u=q.top().second;q.pop();
		for(int i=hed[u];~i;i=e[i].next){
		/*	if(vl<=v[e[i].v]&&vl+m>=v[e[i].v]&&dis[e[i].v]>dis[u]+e[i].w)
			{dis[e[i].v]=dis[u]+e[i].w;
			q.push(mp(dis[e[i].v],e[i].v));}//printf("%d:%d\n",e[i].v,dis[e[i].v])*/;
		}
	}
	return;
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		if(i) a[i]+=a[i-1];
	}
	for(int i=0;i<n;i++){
		scanf("%d",b+i);
	}
	for(int i=n-1;~i;i--){
		if(i<n-1)b[i]+=b[i+1];
	}
	for(int i=0;i<n;i++){
		ans=max(ans,a[i]+b[i]);
	}
	cout<<ans<<endl;
	return 0;
}                    

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a,b,c,t[10]={};
  scanf("%d%d%d",&a,&b,&c);
  t[a]++;
  t[b]++;
  t[c]++;
  printf("%s\n",(t[5]==2&&t[7]==1)? "YES":"NO");
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>

using namespace std;

int main() {
    int x;
    scanf("%d", &x);
    if (x < 600) {
        printf("8");
    } else if (x < 800) {
        printf("7");
    } else if (x < 1000) {
        printf("6");
    } else if (x < 1200) {
        printf("5");
    } else if (x < 1400) {
        printf("4");
    } else if (x < 1600) {
        printf("3");
    } else if (x < 1800) {
        printf("2");
    } else {
        printf("1");
    }
    return 0;
}

Measured memory_bytes: 1640
using System;

namespace atcorder
{
    class Program
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] In = Console.ReadLine().Split(' ');
            int[] X = new int[n];
            int max = 0;
            int min = Int32.MaxValue;
            for(int i=0; i<n; i++)
            {
                X[i] = int.Parse(In[i]);
                if (X[i] >= max) max = X[i];
                if (X[i] <= min) min = X[i];
            }
            int sum = Int32.MaxValue;
            for(int i=min; i<=max; i++)
            {
                int val = 0; 
                foreach(int x in X)
                {
                    val += (int)Math.Pow(x - i, 2);
                }
                if (val <= sum) sum = val;
            }
            Console.WriteLine(sum);
        }
    }
}


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

using namespace std;

int main()
{
    int n, k, a, L=-1, R, t, g=1;
    cin >> n >> k;
    int D[k+1];
    vector <int> A;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    R = n;
    while (R - L > 1)
    {
        g = 0;
        t = (L + R) / 2;
        for (int i = 0; i <= k; i++)
        {
            D[i] = 0;
        }
        D[0] = 1;
        for (int i = 0; i < n; i++)
        {
            if (i != t)
            {
                for (int y = k-1; y >= 0; y--)
                {
                    if (A[i] + y < k && D[y] == 1)
                    {
                        D[y + A[i]] = 1;
                        if (y + A[i] >= k - A[t])
                        {
                            g = 1;
                        }
                    }
                }
            }
        }
        if (0 >= k - A[t])
        {
            g = 1;
        }
        if (g == 0)
        {
            L = t;
        }
        else
        {
            R = t;
        }
    }
    cout << L + 1;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  string s;
  cin >> s;
  vector<int> v(26, 0);
  int ss = s.size();
  rep(i, 0, ss) {
    v[s[i]-'a']++;
  }
  rep(i, 0, 26) {
    if(v[i] % 2 != 0) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 50;

vector<vector<int>> g;
vector<int> h, p, pls;

void dfs(int v, int pr = -1) {
	for (int u : g[v]) {
		if (u != pr) {
			p[u] = v;
			h[u] = h[v] + 1;
			dfs(u, v);
		}
	}
}

int lca(int a, int b) {
	if (h[a] < h[b]) swap(a, b);
	while (h[a] > h[b]) a = p[a];
	while (a != b) {
		a = p[a];
		b = p[b];
	}
	return a;
}

int res1;

int dfs1(int v, int pr = -1) {
	int now = 0;
	for (int u : g[v]) {
		if (u != pr) {
			now += dfs1(u, v);
		}
	}
	now += pls[v];
	if (now) res1++;
	return now;
}

void solve() {
	int n;
	cin >> n;
	g.resize(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].pb(b);
		g[b].pb(a);
	}

	h.resize(n);
	p.resize(n);
	dfs(0);

	int m;
	cin >> m;
	vector<pair<int, int>> b(m);
	vector<int> c(m);
	for (int i = 0; i < m; i++) {
		int one, two;
		cin >> one >> two;
		one--; two--;
		b[i] = { one, two };
		c[i] = lca(one, two);
	}

	int res = 0;
	pls.resize(n);
	for (int mask = 1; mask < (1 << m); mask++) {
		fill(all(pls), 0);
		int cnt = 0;
		res1 = 0;
		for (int i = 0; i < m; i++) {
			if ((mask >> i) & 1) {
				cnt++;
				pls[b[i].first]++;
				pls[b[i].second]++;
				pls[c[i]] -= 2;
			}
		}
		dfs1(0);
 		res += (cnt % 2 ? 1 : -1) * (1LL << (n - 1 - res1));
	} 
	res = (1LL << (n - 1)) - res;
	cout << res;
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	solve();
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    double a,b, c, d, e, f, x,y;
    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF)
    {
        y=(a*f-c*d)/(a*e-d*b);
        x=(c-b*y)/a;
        printf("%.3f %.3f\n",x,y);
    }
}

Measured memory_bytes: 1076
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	long long ans=0;
	cin>>n;
	int a,b;
	cin>>a;
	for(int i=1;i<n;i++)
	{
		cin>>b;
		ans+=max(a-b,0);
		a=max(a,b);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
int main(void)
{
  int n1,n2,n3;
  scanf("%d",&n1);
  scanf("%d",&n2);
  scanf("%d",&n3);
  if(n1==n2&&n1==n3){
    printf("No");
  }
  else if(n1==n2||n1==n3||n2==n3){
    printf("Yes");
  }
  else {printf("No");}
  return 0;
}

Measured memory_bytes: 1692
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

const int MAX_N=100001;

// iツ嘉アツ姪堋づ泳ツ古つ連ツ堕アツつオツづ偲ヲツづェツづゥツ確ツ猟ヲツづーツ格ツ納
double dp[MAX_N][51];

int main(){

	double ret[MAX_N];
	fill(ret,ret+MAX_N,0.0);


	//vector<vector<double> > dp;
	//vector<double> v(51,0.0);
	//for(int i = 0; i < MAX_N; i++){
	//	dp.push_back(v);
	//}

	dp[1][1]=1.0;
	ret[1]=1.0;
	for(int i = 2; i < MAX_N; i++){
		double ss=0;
		// iツ嘉アツ姪堋づ泳ツ古つ連ツ堕アツつオツづ偲ヲツづェツづゥツ確ツ猟ヲツづーツ計ツ算
		for(int j = 0; j <= min(i,50); j++){
			// ツ債。ツ嘉アツミツス
			if(j==0){
				for(int k = 1; k <= min(i-1,50); k++)
					dp[i][j]+=dp[i-1][k]*(1-pow(0.5,k));
			}
			// ツ連ツ堕アツ偲ヲツ督セ
			else{
				dp[i][j]=dp[i-1][j-1]*(pow(0.5,j-1));
				ss+=dp[i][j];
			}
		}
		ret[i]=ss+ret[i-1];
	}

	int n;
	while(cin>>n&&n!=0){
		printf("%.3lf\n",ret[n]);
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
    int N,K,ans=0;
    cin>>N>>K;
    int H[N]={0};
    for(int i=0;i<N;i++){
        cin>>H[i];
        if(H[i]>=K)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int N;  cin >> N;
    vi L(N); REP(i, N) cin >> L[i];

    sort(L.begin(), L.end());
    int sum = 0;
    REP(i, N - 1) sum += L[i];

    string ans = sum > L[N - 1] ? "Yes" : "No";    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a > b && a > c)
	{
		cout << (b*c) / 2 << endl;
	}
	else if(b > c && b > a)
	{
		cout << (a*c) / 2 << endl;
	}
	else
	{
		cout << (a*b) / 2 << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <tuple>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
using namespace std;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main()
{

    ll x;
    cin>>x;
    
    ll h,m,s;
    h=x/3600;
    x=x%3600;
    m=x/60;
    s=x%60;
    
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll A, B;
    cin >> A >> B;
    cout << A * B << endl;
}


Measured memory_bytes: 3588
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  N = int(readline())
  A = list(map(int, readline().split()))
  B = list(map(int, readline().split()))
  count = 0
  for i in range(N):
    tmp = min(A[i],B[i])
    count += tmp
    A[i] -= tmp
    B[i] -= tmp
    tmp = min(A[i+1],B[i])
    count += tmp
    A[i+1] -= tmp
    B[i] -= tmp
  print(count)
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 19108
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll H, W;
  cin >> H >> W;
  vvl cij(10, vl(10));
  rep(i, 10){
    rep(j, 10){
      cin >> cij[i][j];
    }
  }
  vvl A(H, vl(W));
  rep(i, H){
    rep(j, W){
      cin >> A[i][j];
    }
  }

  vl cost(10, 1000000);
  cost[1] = 0;

  rep(i, 10){
    if(i == 1) continue;

    vl dist(10, 100000);
    vl vis(10, 0);

    priority_queue<pll, vector<pll>, greater<pll>> que;
    que.push({cij[i][i], i});

    while(!que.empty()){
      pll top = que.top();
      que.pop();
      if(vis[top.second] == 1) continue;
      vis[top.second] = 1;

      rep(j, 10){
	if(vis[j] == 1) continue;
	dist[j] = min(dist[j], top.first + cij[top.second][j]);
	que.push({dist[j], j});
      }
    }

    cost[i] = dist[1];
  }

  ll ans = 0;
  rep(i, H){
    rep(j, W){
      if(A[i][j] != -1) ans += cost[A[i][j]];
    }
  }

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


Measured memory_bytes: 512
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void test_case();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	string s;
	cin >> s;
	int res = 0;
	stack < char > stk;
	for (int i = 0; i < s.size(); ++i) {
		if (stk.empty()) {
			stk.push(s[i]);
		} else if (s[i] == '0' && stk.top() == '1') {
			stk.pop();
			res += 2;
		} else if (s[i] == '1' && stk.top() == '0') {
			stk.pop();
			res += 2;
		} else {
			stk.push(s[i]);
		}
	}
	cout << res << "\n";
}

Measured memory_bytes: 512