akhauriyash/Code-Regression huggingface dataset:
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

// -----------------------------------------------------------------------------------------------------

// -----------------------------------------------------------------------------------------------------

let main() =
    let [| A; B; M |] = reada int
    let ass = reada int64
    let bs = reada int64
    let xycs = Array.zeroCreate M
    for i in 0 .. M - 1 do
        let [| x; y; c |] = reada int64
        let x, y = int x - 1, int y - 1
        xycs.[i] <- x, y, c

    let naxa = ass |> Array.min
    let naxb = bs |> Array.min
    let mutable ans = naxa + naxb
    for i in 0 .. M - 1 do
        let x, y, c = xycs.[i]
        let a, b = ass.[x], bs.[y]
        let tmp = a + b - c
        if ans > tmp then ans <- tmp

    puts ans
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


Measured memory_bytes: 37212
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m, d;
  cin >> m >> d;
  int ans = 0;
  for(int i = 4; i <= m; i++){
    for(int j = 22; j <= d; j++){
      if(i == (j%10)*(j/10) && (j%10) >= 2 && (j/10) >= 2) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll> z(n), w(n);
  REP(i, n){
    ll x, y;
    cin >> x >> y;
    z[i] = x+y;
    w[i] = x-y;
  }
  ll ans = max(*max_element(ALL(z))-*min_element(ALL(z)), *max_element(ALL(w))-*min_element(ALL(w)));
  cout << ans << endl;
  return 0;
}

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

int main () {

    int  D, N;
    cin >> D >> N;

    if (D == 0) {
        if (N == 100) cout << N + 1 << endl;
        else cout << N << endl;

    } else if (D == 1) {
        if (N == 100) cout << 100 * N + 100 << endl;
        else cout << 100 * N << endl;
        
    } else {
        if (N == 100) cout << 10000 * N + 10000 << endl;
        else cout << 10000 * N << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    long long a, b, c; cin >> a >> b >> c;
    long long d = c - a - b;
    if (d < 0 || d > 2e9) cout << "No\n";
    else if (4 * a * b < d * d) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Feb  3 23:01:46 2018
//
package main

import (
	"fmt"
)

func main() {
	var X, Y int
	fmt.Scan(&X, &Y)

	if X%Y == 0 {
		fmt.Println(-1)
		return
	}

	for i := 2; ; i++ {
		if X*i%Y != 0 {
			fmt.Println(X * i)
			return
		}
	}
}


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

int main(){
	int n,m,x;
	vector<bool> prime(1000001,true);
	prime[0]=prime[1]=false;
	/*ツづ督づゥツつ「*/
	for(int i=2;i<=1000;i++)if(prime[i])for(int j=i+i;j<=1000000;j+=i)prime[j]=0;
	while(cin >> n >> x && n && x){
		vector<int> item(n);
		vector<bool> able(x+1,false);
		able[0]=true;
		
		for(int i=0;i<n;i++)cin >> item[i];
		
		for(int i=0;i<n;i++){
			for(int j=0;j+item[i]<=x;j++){
				able[j+item[i]] = able[j+item[i]] | able[j];
			}
		}
		for(int i=x;i>=0;i--){
			if(able[i] && prime[i]){
				cout << i << endl;
				break;
			}
			if(!i)cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 1148
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val n = sc.nextInt()
        val a = sc.intList()

        val b = IntArray(n)
        for (i in 0 until n) {
            if (i % 2 == 0) {
                b[i / 2] = a[n - i - 1]
            } else {
                b[n - i / 2 - 1] = a[n - i - 1]
            }
        }

        println(b.joinToString(" "))
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        while (l.size <= ptr) {
            l = readLine()!!.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        return readLine()!!.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 70832
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll dp[222222];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  vi A(n);

  for(auto &a:A)cin>>a;
  for(int i=0;i<k;i++){
    if(dp[i]==0){
      for(auto a:A)
	dp[i+a]=1;
    }
  }

  if(dp[k]==1){
    cout<<"First"<<endl;
  }else{
    cout<<"Second"<<endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    vector <int> data1(100010),data2(100010);
    int saihin12=0,saihin11=0,x12=0,x11=0,x22=0,x21=0,saihin22=0,saihin21=0;
    for(int i=0;i<n/2;i++){
        int v1,v2;
        cin>>v1>>v2;
        data1[v1]++; data2[v2]++; 
    }
    for(int i=0;i<100010;i++){
        if(data1[i]>=saihin11){
            saihin11=data1[i];  x11=i;
        }
        if(data2[i]>=saihin21){
            saihin21=data2[i];  x21=i;
        }
    }
    for(int i=0;i<100010;i++){
        if(i!=x11){
            if(data1[i]>=saihin12){
                saihin12=data1[i]; x12=i;
            }
        }
        if(i!=x21){
            if(data2[i]>=saihin22){
                saihin22=data2[i]; x22=i;
            }
        }
    }
    if(saihin12==0) x12=0;
    if(saihin22==0) x22=0;
    if(x11!=x21)
    cout<<n-saihin11-saihin21<<endl;
    else{
        cout<<min(n-saihin11-saihin22,n-saihin12-saihin21)<<endl;
    }
    
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)

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

  int m;//辺の本数
  if(n%2==1){
    m = (n-1)*(n-1)/2;
  }else{
    m = n*(n-2)/2;
  }
  cout << m << endl;

  if(n%2==0){//偶数の時の出力
    for(int i=1; i<=n; i++){//行
      for(int j=i+1; j<=n; j++){//列
        if(j!=n-i+1){
          cout << i << " " << j << endl;
        }
      }
    }
  }else{//奇数の時の出力
    for(int i=1; i<=n-1; i++){//行
      for(int j=i+1; j<=n-1; j++){//列
        if(j!=n-i){
          cout << i << " " << j << endl;
        }
      }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>

using namespace std;

int main(){
    
    int n;
    cin >> n;
    
    char s[n];
    cin >> s;
    
    int ans=0;
    
    for(int i=0;i<n-2;i++){
        while(s[i]=='A'){
            if(s[i+1]=='B'){
                if(s[i+2]=='C'){
                    ans++;
                }
            }
            break;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
m =  int(input())
t = [input() for i in range(m)]
cnt = {}
for word in s:
    if word in cnt: cnt[word] += 1
    else:cnt[word] = 1
for word2 in t:
    if word2 in cnt:cnt[word2] -= 1
    else : cnt[word2]= -1
ls = [v for k,v in cnt.items()]
if max(ls) <0 :print(0)
else:print(max(ls))


Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
    int total = 0;
    int n;
    scanf("%d", &n);
    int a[n];
    int pre;
    for (pre = 0; pre < n; pre++)
    {
        scanf("%d", &a[pre]);
    }
    for (pre = 0; pre < n; pre++)
    {
        if (hantei(a[pre]) == 1)
        {
            total += 1;
        }
    }
    printf("%d\n", total);
    return 0;
}

int hantei(int get)
{
    if (get == 2)
    {
        return 1;
    }
    if (get % 2 == 0)
        return 0;
    double sq = pow(get, 0.5);
    int pre;
    for (pre = 3; pre <= sq; pre += 2)
    {
        if (get % (int)pre == 0)
            return 0;
    }
    return 1;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n;
void solve(){
	cin >> n;
	int a = 1000-n%1000;
	if(a == 1000) cout << 0 << endl;
	else cout << a << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 200010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
int n,m;
int main(){
	int n;
	in(n);
	int tt=0,xx=0,yy=0;
	FOR(i,1,n){
		int t,x,y;
		in3(t,x,y);
		if(abs(xx-x)+abs(yy-y)>t-tt){outn;return 0;}
		if((t-tt-abs(xx-x)-abs(yy-y))%2){outn;return 0;}
		tt=t,xx=x,yy=y;
	}
	outy;
}

Measured memory_bytes: 256
import numpy as np
n = int(input())
X = np.array(list(map(int,input().split())))
mean = np.mean(X)
koho1 = int(mean)
koho2 = int(mean+1)
ans1 = np.sum((X - koho1)**2)
ans2 = np.sum((X - koho2)**2)
print(min(ans1,ans2))

Measured memory_bytes: 12508
// package abc123.B;

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] times = new int[5];
        for (int i = 0; i < 5; i += 1) {
            times[i] = sc.nextInt();
        }

        Integer[] indices = new Integer[5];
        for (int i = 0; i < 5; i += 1) {
            indices[i] = i;
        }
        List<List<Integer>> perms = permute(indices);

        int minTime = Integer.MAX_VALUE;
        for (List<Integer> perm : perms) {
            int time = 0;
            for (int index : perm) {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            }
            if (minTime > time) {
                minTime = time;
            }
        }

        System.out.println(minTime);
    }

    private static <T> List<List<T>> permute(T[] items) {
        List<List<T>> perms = new LinkedList<>();
        permuteHelper(perms, items, 0);
        return perms;
    }

    private static <T> void permuteHelper(List<List<T>> perms, T[] items, int n) {
        if (n == items.length - 1) {
            List<T> perm = new LinkedList<>();
            for (T item : items) {
                perm.add(item);
            }
            perms.add(perm);
        } else {
            for (int m = n; m < items.length; m += 1) {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            }
        }
    }

    private static <T> void swap(T[] items, int index1, int index2) {
        T tmp = items[index1];
        items[index1] = items[index2];
        items[index2] = tmp;
    }

}


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

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  a = abs(x-a);
  b = abs(x-b);
  if(a < b) cout << "A" << '\n';
  else cout << "B" << '\n';
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	long long ret=inf;
	if(a%3==0||b%3==0){
		printf("0\n");return 0;
	}
	ret=min(a,b);
	for(int i=1;i<a;i++){
		long long L=(long long)i*b;
		long long R1=(long long)(a-i)*(b/2);
		long long R2=(long long)(a-i)*((b+1)/2);
		ret=min(ret,max(L,R2)-min(L,R1));
	}
	for(int i=1;i<b;i++){
		long long L=(long long)i*a;
		long long R1=(long long)(b-i)*(a/2);
		long long R2=(long long)(b-i)*((a+1)/2);
		ret=min(ret,max(L,R2)-min(L,R1));
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    int64_t n = x / 100;
    int64_t m = x % 100;

    int64_t k = 0;
    for (auto p : {5, 4, 3, 2, 1}) {
        k += m / p;
        m -= (m / p) * p;
    }

    if (k > n) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n:i64,
    }
    let base = (n / 11) * 2;
    let ans = base
        + if n % 11 == 0 {
            0
        } else if n % 11 <= 6 {
            1
        } else {
            2
        };
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
//long long INF = 1e19;

int r[100], l[100];
int a, b;

#define MAX 9223372036854775807
/*********************** */

int main() {
	string s;cin >> s;
	int a = (s[0] - '0') * 10 + (s[1] - '0');
	int b = (s[2] - '0') * 10 + (s[3] - '0');
	
	bool x,y;
	x = (a > 0 && a <= 12);
	y = (b > 0 && b <= 12);
	if(x && y){
		cout << "AMBIGUOUS" << endl;
		return 0;
	}else if(x && !y){
		cout << "MMYY" << endl; return 0;
	}else if(!x && y){
		cout << "YYMM" << endl; return 0;
	}else{
		cout << "NA" << endl; return 0;
	}
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,m,o=0,p=0,q=0; 
	cin>>n;
	m=n; 
	
	c:;
	if(m==1) goto a;
	if(m>1&&m<10) goto b;
	if(m%10==9) p++;
	m/=10; 
	o++; 
	goto c; 
	
	a:;
	for(int i=0;i<o;i++) q+=9;
	if(o==p) q+=1;
	cout<<q<<endl; 
    return 0;
    
    b:;
    for(int i=0;i<o;i++){ q+=9;}
    q+=m-1;
	if(o==p) q+=1;
	cout<<q<<endl; 
    return 0;
}


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


public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            boolean pn = true;
            if (x == 1) {
                pn = false;
            }
            for (int j = 2; j <= Math.sqrt(x); j++) {
                if (x % j == 0) {
                    pn = false;
                    break;
                }
            }
            if (pn) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 41204
using System;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    int c = int.Parse(input[2]);
    Console.WriteLine((b - a) == (c - b) ? "YES" : "NO");
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define cont continue  
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 2147483646;
const double pi = 3.141592653589793;


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

  ll N, K;
  cin >> N >> K;

  vector<ll> pos;

  for(int i = 0 ; i < N ; i++) {
    ll a;
    cin >> a;
    pos.pb(a);
  }

  for(ll i = 0 ; i < N ; i++) {
    pos.pb(-300000001);
  }
  for(ll i = 0 ; i < N ; i++) {
    pos.pb(300000001);
  }
  pos.pb(0);
  sort(pos.begin(), pos.end());
  ll idx = lower_bound(pos.begin(),pos.end(), 0) - pos.begin();
//  cout << "start idx : " << idx << endl;
  ll left = idx - K;
  ll right = idx;
  ll ans = INF;
  ll cur = 0;
  while(right <= pos.size() - 1) {
//    cout << "left : " << pos[left] << ' ' << "right : " << pos[right] << endl;
    cur = 0;
    if(pos[left] * pos[right] < 0) { // 둘이 부호 반대
      cur = min(abs(pos[left]), abs(pos[right])) * 2 + max(abs(pos[left]), abs(pos[right])); 
    }
    else {
      cur = max(abs(pos[left]), abs(pos[right]));
    }
    ans = min(ans, cur);
    left++;
    right++;
  }
  cout << ans << endl;
} 

Measured memory_bytes: 6512
#include<stdio.h>
int main()
{
	int N,K,a[1010],i,j,k,t,s=0;
	scanf("%d %d",&N,&K);
	for(i=0;i<N;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i = 0; i < N - 1; i++)
	{
		for(j = 0; j < N - i - 1; j++)
		{
			if(a[j] > a[j + 1])
			{
				t = a[j];
				a[j] = a[j + 1];
				a[j + 1] = t;
			}
		}
	}
	for(k=0;k<K;k++)
	{
		s+=a[k];
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 2144
from heapq import heapify, heappop, heappush, heappushpop, heapreplace


def diameter(tonodes, n):
    visited = [False for _ in range(n)]
    queue = []
    max_weight = 0
    max_node = 0
    for i, node in enumerate(tonodes):
        if len(node) > 0:
            visited[i] = True
            max_node = i
            for edge in node:
                heappush(queue, (-edge[0], edge[1]))
            break

    while len(queue) > 0:
        weight, node = heappop(queue)
        visited[node] = True
        if max_weight < -weight:
            max_weight = -weight
            max_node = node
        for edge in tonodes[node]:
            if not visited[edge[1]]:
                heappush(queue, (weight - edge[0], edge[1]))

    for i in range(n):
        visited[i] = False

    visited[max_node] = True

    for edge in tonodes[max_node]:
        heappush(queue, (-edge[0], edge[1]))

    max_weight = 0

    while len(queue) > 0:
        weight, node = heappop(queue)
        visited[node] = True
        if max_weight < -weight:
            max_weight = -weight
            max_node = node
        for edge in tonodes[node]:
            if not visited[edge[1]]:
                heappush(queue, (weight - edge[0], edge[1]))

    return max_weight


def main():
    n = int(input())
    tonodes = [[] for _ in range(n)]
    for _ in range(n - 1):
        s, t, w = map(int, input().split())
        tonodes[s].append((w, t))
        tonodes[t].append((w, s))
    max_weight = diameter(tonodes, n)
    print(max_weight)


if __name__ == "__main__":
    main()



Measured memory_bytes: 38200
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int __int128

const int mod=1e9+7;
const int N=1e5+5;
int n,k,ans,pre[N],a[N],fac[N],inv[N];

int calc(int l,int r){
	return pre[r]-pre[l-1];
}

int C(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
	return res;
}

signed main(){
	read(n);read(k);
	for(int i=1;i<=n;i++)
		read(a[i]);
	if(k==1){
		write(0);
		return 0;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++) pre[i]=pre[i-1]+a[i];
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	inv[n]=fpow(fac[n],mod-2);
	for(int i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	for(int i=k;i<=n;i++)
		ans=(ans+C(i-2,k-2)*(calc(i,n)-calc(1,n-i+1))%mod)%mod;
	write(ans);
}

Measured memory_bytes: 6528
S=input()
l=len(S)

import itertools as it
a=0
for i in range(l):
 for j in it.combinations(range(1,l), i):
  t='';p=0
  for k in j:
    t+=S[p:k]+'+'
    p=k
  t+=S[p:]
  a+=eval(''.join(t))
print(a)

Measured memory_bytes: 9072
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

n = int(input())
rest = []

for i in range(n):
    t = input().split()
    rest.append([t[0],int(t[1]),i+1])

rest.sort(key=lambda x:(x[0],-x[1]))
#print(rest)


for i in range(n):
    print(rest[i][2])








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

#define int long long
typedef pair<int, int> P;

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

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

signed main() {
    char S[3];
    cin >> S;
    sort(S, S + 3);
    if (S[0] == 'a'&&S[1] == 'b'&&S[2] == 'c') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
template<typename T>
void pr(T a){
  cout<<a<<endl;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  string s,t;cin>>s>>t;
  ll a,b,c;cin>>a>>b;
  string u;cin>>u;
  if(s==u)cout<<a-1 spa b<<endl;
  else cout<<a spa b-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  ll h, w, a, b; cin >> h >> w >> a >> b;
  if (w < 2*a || h < 2*b) {
    cout << "No" << endl;
    return 0;
  }

  rep(i, h) {
    rep(j, w) {
      if ((i < b && j < a) || (i >= b && j >= a)) cout << 1;
      else cout << 0;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;


int main(void) {
  int num[4] = {10, 50, 100, 500};
  int n;
  bool f = true;
  while(cin >> n){
    if( n == 0 ) break;
    if( !f ) cout << endl;
    f = false;
    vector<int> c(4);
    vector<int> a(4, 0);
    for(int i=0; i<4; i++) cin >> c[i];

    int ans = 100;
    for(int i=0; i<=c[0]; i++){
      for(int j=0; j<=c[1]; j++){
        for(int k=0; k<=c[2]; k++){
          for(int l=0; l<=c[3]; l++){
            vector<int> tmp = c;
            int p = i * 10 + j * 50 + k * 100 + l * 500;
            if( p < n ) continue;
            tmp[0] -= i; tmp[1] -= j; tmp[2] -= k; tmp[3] -= l;
            int r = p - n;
            while( r >= 500 ){r -= 500; tmp[3]++;}
            while( r >= 100 ){r -= 100; tmp[2]++;}
            while( r >= 50 ){r -= 50; tmp[1]++;}
            while( r >= 10 ){r -= 10; tmp[0]++;}
            int sum = accumulate(tmp.begin(), tmp.end(), 0);
            if( ans == sum ){
              if( accumulate(a.begin(), a.end(), 0) > i + j + k + l ){
                a[0] = i; a[1] = j; a[2] = k; a[3] = l;
              }
            }else if( ans > sum ){
              ans = sum;
              a[0] = i; a[1] = j; a[2] = k; a[3] = l;
            }

          }
        }
      }
    }
    for(int i=0; i<4; i++){
      if( a[i] == 0 ) continue;
      cout << num[i] << " " << a[i] << endl;
    }

  }

  return 0;
}

// EOF

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

int main(){
  int i,j;
  int c[3][3];
  int a[3];
  int b[3];
  int flag = 0;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++)
      cin >> c[i][j];
  }
  int tc = c[0][0];
  
  for(i = 0;i<=tc;i++){
  a[0] = i;
  b[0] = c[0][0] - i;
  b[1] = c[0][1] - a[0];
  if(b[1]<0)
    continue;
  b[2] = c[0][2] - a[0];
  if(b[2]<0)
    continue;
  a[1] = c[1][0] - b[0];
  if(a[1]<0)
    continue;
  a[2] = c[2][0] - b[0];
  if(a[2]<0)
    continue;
  if(c[1][1]==a[1]+b[1]&&c[1][2]==a[1]+b[2]&&c[2][1]==a[2]+b[1]&&c[2][2]==a[2]+b[2]){
    flag=1;
    break;
  }
}

if(flag==1)
  cout << "Yes" << endl;
 else
   cout<< "No" << endl;
return 0;
}
    
  


Measured memory_bytes: 256
package main

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

type Card struct {
	symbol string
	rank   int
}

func (c Card) String() string {
	return fmt.Sprintf("%s %d", c.symbol, c.rank)
}

func NewCard(s string) (card Card) {
	var err error
	arr := strings.Split(string(s), " ")
	card.symbol = arr[0]
	card.rank, err = strconv.Atoi(arr[1])
	if err != nil {
		panic(err)
	}
	return
}

func readStringIntArray(rd *bufio.Reader, n int) ([]int, error) {
	nums := make([]int, 0, n)
	s, _, err := rd.ReadLine()
	if err != nil {
		return nums, err
	}

	arr := strings.Split(string(s), " ")
	for _, i := range arr {
		n, err := strconv.Atoi(i)
		if err != nil {
			return nums, err
		}
		nums = append(nums, n)
	}
	return nums, nil
}

func main() {
	cards := make([]Card, 0, 52)
	for _, s := range [4]string{"S", "H", "C", "D"} {
		for r := 1; r <= 13; r++ {
			cards=append(cards, Card{s, r})
		}
	}

	rd := bufio.NewReader(os.Stdin)
	nums, err := readStringIntArray(rd, 1)
	if err != nil {
		panic(err)
	}
	n := nums[0]

	found := make([]int, 52)
	for i := 0; i < n; i++ {
		s, _, err := rd.ReadLine()
		if err == io.EOF {
			break
		}
		for j, c := range cards {
			if string(s) == c.String() {
				found[j]++
				break
			}
		}
	}

	for i, v := range found {
		if v == 0 {
			fmt.Println(cards[i])
		}
	}
}



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

int main() {
    int p=700;
    string S;
    cin >> S;

    rep(i,3)
        if(S.at(i) == 'o')
            p += 100;
    cout << p << endl;
}

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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

signed main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  flag = true;

  string w; cin >> w;
  vector<int> a(26);
  for (auto it = w.begin(); it != w.end(); ++it) ++a[*it - 'a'];

  for (auto it = a.begin(); it != a.end(); ++it) if (*it % 2 != 0) flag = false;
  
  // cout << num << endl;
  cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
 
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
 
using namespace std;
 
 
int main(void) {
	int n;
	int a[20];
	int dp = 0;
	int ki = 0;
	int gu = 0;
 
	cin >> n;
	FOR(i, 1, n) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			gu++;
		}
		else {
			ki++;
		}
	}
		cout << pow(3, n) - pow(2, gu) << endl;
	
 
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int A[610000],B[610000];
void calcZ(string s,int *A){
	A[0]=s.size();
	int i=1,j=0;
	while(i<s.size()){
		while(i+j<s.size()&&s[j]==s[i+j]) ++j;
		A[i]=j;
		if(j==0){
			++i;
			continue;
		}
		int k=1;
		while(i+k<s.size()&&k+A[k]<j) A[i+k]=A[k],++k;
		i+=k,j-=k;
	}
}
int main(){
	string s,t;
	cin>>s>>t;
	calcZ(t+"$"+s,A);
	reverse(all(s));
	reverse(all(t));
	calcZ(t+"$"+s,B);
	int N=s.size(),K=t.size();
	int ans=0;
	rep(i,N-K+1){
//		show(A[K+1+i]);
//		show(B[K+1+(N-K-i)]);
		int v=A[K+1+i]+B[K+1+(N-K-i)];
		if(v==K-1) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6060
/*
 * src.cpp
 *
 *  Created on: 2016/09/04
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_N=2e3;

typedef long long ll;

int N;
ll a[MAX_N],x;
ll mtable[MAX_N][MAX_N];

ll f(int m){
	ll res=0;
	REP(i,N){
		res+=mtable[i][m];
	}
	return res+x*m;
}

int main(){
	scanf("%d %lld",&N,&x);
	REP(i,N){
		scanf("%lld",&a[i]);
	}
	REP(i,N){
		mtable[i][0]=a[i];
		FOR(j,1,N){
			mtable[i][j]=min<ll>(mtable[i][j-1],a[(i-j+N)%N]);
		}
	}
	ll ans=f(0);
	FOR(i,1,N){
		ans=min<ll>(ans,f(i));
	}
	printf("%lld\n",ans);
	return 0;
}




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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 10000000

using namespace std;

int main(){
  int n,m;cin>>n>>m;
  vector<int> g3[3*n];
  rep(i, m){
    int u,v;cin>>u>>v; u--; v--;
    int from = u;
    int to = v;
 
    g3[from].push_back(n+to);
    g3[n+from].push_back(2*n+to);
    g3[2*n+from].push_back(to);
  }
  int s,t;cin>>s>>t;s--;t--;

  vector<int>d(3*n);
  rep(i, 3*n)d[i]=INF;
  d[s]=0;
  queue<pi>q;
  q.push({0,s});
  while(q.size()){
    auto p = q.front(); q.pop();
    int count = p.first;
    int now = p.second;

    if(d[now] < count)continue;

    for(auto c:g3[now]){
      if(d[c]<=count+1)continue;
      d[c]=count+1;
      q.push({d[c], c});
    }
  }

  if(d[t]==INF)cout<<-1<<endl;
  else cout<<d[t]/3<<endl;

  return 0;
}


Measured memory_bytes: 20912
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
    int n;

    scanf("%d", &n);
    while (n--) {
        double m, dec;
        int x, v, md;
        char buf[10];
        md = (int)pow(2, 8);
        m = 2 * md * md;
        v = 0;
        for (int i = 0; i < 4; i++) {
            scanf("%2x", &x);
            if (i == 0) {
                if (x & 0x80) putchar('-');
                x = x & 0x7f;
            }
            if (i <= 2) {
                v += x * m;
            }
            else {
                v += (x & 0x80) > 0;
                printf("%d", v);
                x = x & 0x7f;
                if (x > 0) {
                    sprintf(buf, "%.7g", (double)x * m);
                    printf("%s\n", &buf[1]);
                }
                else {
                    printf(".0\n");
                }
            }
            m /= md;
        }
    }

    return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 3e5 + 5;
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)

clock_t start = clock();

void solve() {  
    int mx = 0;
    int n;
    cin >> n;
    LL ans = 0;
    for (int i=0;i<n;++i) {
        int x; 
        cin >> x;
        if (i > 0) ans += max(0, mx - x);
        mx = max(mx, x);
    }
    cout << ans << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    while(T--) {
        solve();
    }
    // cerr << fixed << setprecision(10);
    // cerr << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
    return 0;
} 

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


int main()
{
  int a, b;
  cin >> a >> b;
  cout << max({a + b, a - b, a * b}) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f[100001]={0},a[101];
int main()
{
	int i,j,n,k,flag=0;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	f[0]=1;
	for(i=1;i<=k;i++)
	{
		flag=1;
		for(j=1;j<=n;j++)
		{
			if(a[j]<=i)
			{
				if(f[i-a[j]]==1)
				{
					flag=0;
					break;
				}
			}	
		}
		if(flag==1)
			f[i]=1;
		else
			f[i]=0;
	}
	if(f[k]==0)
		printf("First");
	else
		printf("Second");
	return 0;
}

Measured memory_bytes: 640
import numpy as np

def main():
    n = int(input())
    a = np.array([int(i) for i in input().split()])
    mod = 10**9 + 7
    c = 0
    for k in range(60):
        kc = len(a[a & 1 == 1])
        c = (c + kc * (n - kc) * pow(2, k, mod)) % mod
        a //= 2
    print(c)

if __name__ == '__main__':
    main()

Measured memory_bytes: 48856
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

from itertools import combinations as c
add = lambda x,y: [i+j for i,j in zip(x,y)]
n,m,x = mp()
cost,mat = {},{}
for i in range(1,n+1):
    xx = ip()
    cost[i] = xx[0]
    mat[i] = xx[1:]
ans = []
rows = [i for i in range(1,n+1)]
for i in range(1,n+1):
    for j in list(c(rows,i)):
        t = [0]*m
        for k in j:
            t = add(t,mat[k])
        if all(ii>=x for ii in t):
            ans.append(sum([cost[ii] for ii in j]))
if ans == []:
    print(-1)
else:
    print(min(ans))





    

Measured memory_bytes: 69308
// DP F

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

typedef long long 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; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

void dump(const vector<pair<int, int>>& a)
{
  for (auto v : a) {
    cerr << v.first << " " << v.second << endl;
  }
}

void dump(const vector<int>& a)
{
  for (auto v : a) {
    cerr << v << " ";
  }
  cerr << endl;
}

int main()
{
  map<ll, ll> m;
  int n;
  cin >> n;
  rep(i, n) {
    ll a;
    cin >> a;
    if (m.find(a) == m.end()) {
      m.insert(make_pair(a, 1));
    } else {
      m[a] += 1;
    }
  }

  ll ans = 0;
  for (auto itr = m.begin(); itr != m.end(); itr++) {
    if (itr->second != 0 && itr->first != itr->second) {
      if (itr->first > itr->second) {
        ans += itr->second;
      } else {
        ans += itr->second - itr->first;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {

	int n, m;
	int sum = 0;
	int t[100] = { 0 };
	int p[100] = { 0 };
	int x[100] = { 0 };

	//問題数
	cin >> n;
	
	//解くのにかかる時間
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}

	//ドリンク数
	cin >> m;
	

	//問題番号と解くのにかかる時間を指定
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> x[i];
	}
	
	for (int i = 0; i < m; i++) {
		int copy = t[p[i] - 1];
		t[p[i] - 1] = x[i];

		for (int j = 0; j < 100; j++) {
			sum += t[j];
		}
		cout << sum << endl;
		sum = 0;
		t[p[i] - 1] = copy;
	}

	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n + 1), c(n + 1);
	for (int i = 0; i < n; i++)
	{	
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++)
	{
		cin >> b[i];
	}
	for (int i = 2; i <= n; i++)
	{
		cin >> c[i];
	}

	long long ans = b[a[0]];
	for (int i = 1; i < n; i++)
	{
		ans += b[a[i]];
		if (a[i] == a[i - 1] + 1) ans += c[a[i]];
	}
	
	cout << ans;
}

Measured memory_bytes: 256
<?php

$a = "a";
$numOfAlphabet = 26;
for($i=0; $i<$numOfAlphabet; $i++){
    $counter[$a] = 0;
    $a++;
}

while($inStrRaw = fgets(STDIN)){
    $inStr = strtolower($inStrRaw);
    for($i=0; $i<strlen($inStr); $i++){
        $ch = $inStr[$i];
        if(isIn($counter, $ch)){
            $counter[$ch]++;
        }
    }
}

// output
foreach($counter as $key => $value){
    echo $key . " : " . $value . PHP_EOL;
}

function isIn($counter, $ch){
    foreach($counter as $key => $value){
        if($key === $ch){
            return true;
        }
    }
    return false;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<string> A(N), B(M);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < M; ++i) {
    cin >> B[i];
  }

  bool ok = false;
  for (int i = 0; i + M <= N; ++i) {
    string::size_type pos = -1;
    while ((pos = A[i].find(B[0], pos + 1)) != string::npos) {
      ok = true;
      for (int j = 0; j < M; ++j) {
        if (A[i + j].find(B[j], pos) != pos) {
          ok = false;
          break;
        }
      }
      if (ok) { break; }
    }
    if (ok) { break; }
  }
  printf("%s\n", ok ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;
int memo[366];

int dfs(int num)
{
	
	int sum = 0;

	if(memo[num] != -1)
	{
		return memo[num];
	}

	if(num == n)
	{
		return 1;
	}

	if(num < n)
		sum += dfs(num + 1);

	if(num < n)
		sum += dfs(num + 2);

	if(num < n)
		sum += dfs(num + 3);

	memo[num] = sum;

	return sum;
}

int main()
{

	while(1)
	{
		cin >> n;

		for(int i = 0; i <= 31; i++)
		{
			memo[i] = -1;
		}

		if(n == 0)
		{
			break;
		}

		cout << dfs(0)/10/365+1 << endl;
	}
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
import sys


def solve(N: int, x: "List[float]", u: "List[str]"):
    ans = 0
    for y, v in zip(x, u):
        if v == "JPY":
            ans += y
        else:
            ans += y*380000
    print(ans)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [float()] * (N)  # type: "List[float]"
    u = [str()] * (N)  # type: "List[str]"
    for i in range(N):
        x[i] = float(next(tokens))
        u[i] = next(tokens)
    solve(N, x, u)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.awt.AWTError;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] in = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		
		int aw = in[0] + in[1];
		int min = 0;
		if (aw < in[2]) 
			min = in[2] - aw;
		else if (in[0] >= in[1])
			min = 0;
		else if (aw > in[2])
			min = in[1] - (in[0] + in[2]);
		
		System.out.println(min);		
	}
}


Measured memory_bytes: 28496