akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

#define mod 998244353
#define inf 0x7f7f7f7f
#define maxn 500005
#define N 300005
typedef long long ll;
typedef struct{
    int u,v, next;
}Edge;
Edge e[2*maxn];

int cnt,head[300005];

inline void add(int u,int v){
    e[cnt].u=u;
    e[cnt].v=v;
    //e[cnt].w=w;
    //e[cnt].f=f;
    e[cnt].next=head[u];
    head[u]=cnt++;
    e[cnt].u=v;
    e[cnt].v=u;
    //e[cnt].w=0;
    //e[cnt].f=-f;
    e[cnt].next=head[v];
    head[v]=cnt++;
}

inline ll quick_pow(int a, int b) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans = (ans * a) % mod;
        a = (1ll * a * a) % mod;
        b >>= 1;
    }
    return ans;
}
inline int read()
{
    int x = 0;
    int f = 1;
    char c = getchar();
    while (c<'0' || c>'9')
    {    
        if (c == '-')
            f = -1;
        c = getchar();
    }
    while (c >= '0'&&c <= '9')
    {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x*f;
}

//_scc[u]存u点所在强连通分量的标号,out[x]存标号为x的强连通分量的出度,
//cot[x]存标号为x的连通量的点的数目
int n,k;
int a[100000+120];

int main() {
    cin >> n>>k;
    int res = 0;
    for (int i = 0,x; i < n;i++){
        cin >> x;
        if (x >= k) res++;
    }
    cout << res << endl;
    return 0;
}   

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[3];
	int i, j, cnt = 0, temp;

	for (i = 0; i < 3; i++)
	{
		scanf("%d", &a[i]);
	}

	for (i = 0; i < 2; i++)
	{
		for (j = 1; j >= i; j--)
		{
			if (a[j] > a[j + 1])
			{
				temp = a[j];
				a[j] = a[j + 1];
				a[j + 1] = temp;
			}
		}
	}

	for (i = 2; i > 0; i--)
	{
		cnt += a[i] - a[i - 1];
	}

	printf("%d", cnt);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;

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;}

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))
//#define int long long int //dont forget to change int to signed
int main() {
	int N;
	scanf("%d", &N);
	int ary[100009];
	for (int i = 0; i < N; i++) {
		scanf("%d", &ary[i]);
	}
	sort(ary, ary+N, greater<int>());

	lli ans1 = 0l, ans2 = 0l;
	int cnt = 0, index = -1;
	for (int i = 0; i < N; i++) {
		if (index != ary[i]) {
			cnt = 1;
			index = ary[i];
		} else {
			cnt++;
			if (cnt == 2) {
				cnt = 0;
				if (ans1 == 0l) {
					ans1 = index;
				} else {
					ans2 = index;
					break;
				}
			}
		}
		eprintf("%d %d \n", index, cnt);
	}
	printf("%lld\n", ans1 * ans2);
	return 0;
}


Measured memory_bytes: 640
n,g[21][21],i,f;x,X;c[21],t,T;D(S){for(memset(c,1,84),f=c[S]=0;T=S;)for(f|=1<<T,S=i=0;++i<=n;S=f&1<<i|c[i]>c[S]?S:i)t=c[T]+g[T][i],t<c[i]?c[i]=t:0;}main(y,Y){for(memset(g,scanf("%d%d",&n,&i),1764);~i--;~i?g[g[x][X]=y,X][x]=Y:0)scanf("%d,%d,%d,%d",&x,&X,&y,&Y);D(x),y-=c[X],D(X);exit(!printf("%d\n",y-Y-c[x]));}

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

using namespace std;
#define int long long
#define float double
#define INF 1ll<<60

int32_t main(){
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	int M, D, count=0;
	cin >> M >> D;

	for (int i = 1; i <= D; i++){
		if (i >= 10 && (i%10) >= 2 && (i/10) >= 2){
			if ((i % 10) * (i/10) <= M) {
				count++;
			}
		}
	}
	cout << count << "\n";
}

Measured memory_bytes: 256
/* ABC095 - C
 */
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {

	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	bool first = true;
	int current = 0;
	int z = max(X, Y) * 2;

	for (int i = 0; i <= z; i += 2) {
		int x = max(0, X - (i / 2));
		int y = max(0, Y - (i / 2));

		int total = A * x + B * y + C * i;
		if (first) {
			first = false;
			current = total;
		} else {
			if (total < current) {
				current = total;
			}
		}

	}

	cout << current << endl;

	return 0;
}



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

int main(){
  int n,s;
  s=0;
  cin>>n;
  if(n%10==1) s += 9;
  else s += 1;
  if(n/10%10==1) s+= 90;
  else s += 10;
  if(n/100%10==1) s += 900;
  else s += 100;
  
  cout<<s<<endl;
  return 0;
}
  

Measured memory_bytes: 256
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-01-11 19:41:55

---------------------------------*/

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define clr(s, x) memset(s, x, sizeof(s))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define debug(...) cerr<<"["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"<<"\n"
inline int read(){int r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll readll(){ll r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
inline ll gcd(ll a,ll b){while(b^=a^=b^=a%=b);return a;}
const double eps = 1e-8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
const int MAXN = 1e5;
const int MAXM = 1e5;

int a[MAXN+7], dp[MAXN+7];
int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	for(int i=1;i<=n;++i)	cin >> a[i];
	dp[1] = 0;
	dp[2] = abs(a[2]-a[1]);
	for(int i=3;i<=n;++i){
		dp[i] = min(dp[i-1]+abs(a[i-1]-a[i]), dp[i-2]+abs(a[i-2]-a[i]));
	}
	printf("%d\n", dp[n]);
	return 0;
}

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

int main() {
    while (true) {
        int n, q;
        cin >> n >> q;
        if ((n | q) == 0) {
            break;
        }
        int attendeePerDay[101] = {};
        for (int i = 0; i < n; i++) {
            int m;
            cin >> m;
            for (int j = 0; j < m; j++) {
                int day;
                cin >> day;
                attendeePerDay[day]++;
            }
        }
        int maxAttendee = 0, day;
        for (int i = 1; i < 101; i++) {
            if (maxAttendee < attendeePerDay[i]) {
                maxAttendee = attendeePerDay[i];
                day = i;
            }
        }
        if (q <= maxAttendee) {
            cout << day << endl;
        } else {
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var r, g, b int
	fmt.Scanf("%d %d %d", &r, &g, &b)
	if val := 100*r + 10*g + b; val%4 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
 
int main(void){
    int siz,time;
    string name;
    while(true){
        cin >> name;
        if(name[0] == '-')break;
        cin >> time;
        for(int abc=0;abc<time;abc++){
            cin >> siz;
            name = name.substr(siz) + name.substr(0,siz);
        }
        cout << name << endl;
    }
}


Measured memory_bytes: 3192
n = int(input())
rates = [int(input()) for _ in range(n)]

max_dif = -(10**9)
min_rate = rates[0]

for i in range(1, n):
    max_dif = max(max_dif, rates[i]-min_rate)
    min_rate= min(min_rate, rates[i])

print(max_dif)


Measured memory_bytes: 13592
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type Edge struct {
	from, to, cost int
}

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M := sc.nextInt(), sc.nextInt()
	D := make([]int, N)
	for i := 0; i < N; i++ {
		D[i] = -INF
	}
	E := make([]Edge, M)
	for i := 0; i < M; i++ {
		a, b, c := sc.nextInt()-1, sc.nextInt()-1, sc.nextInt()
		E[i] = Edge{a, b, c}
	}
	D[0] = 0
	for i := 0; i < N-1; i++ {
		for j := 0; j < M; j++ {
			e := E[j]
			if D[e.to] < D[e.from]+e.cost {
				D[e.to] = D[e.from] + e.cost
			}
		}
	}
	roop := make([]bool, N)
	for i := 0; i < N; i++ {
		for j := 0; j < M; j++ {
			e := E[j]
			if D[e.to] < D[e.from]+e.cost {
				D[e.to] = D[e.from] + e.cost
				roop[e.to] = true
			}
			if roop[e.from] {
				roop[e.to] = true
			}
		}
	}

	if roop[N-1] {
		fmt.Fprintln(wtr, "inf")
	} else {
		fmt.Fprintln(wtr, D[N-1])
	}
}


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

int main(){
    string s;
    cin>>s;
    int a=count(s.begin(),s.end(),'a');
    int b=count(s.begin(),s.end(),'b');
    int c=count(s.begin(),s.end(),'c');
    cout<<(max({a,b,c})-min({a,b,c})<=1 ?  "YES" : "NO")<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define in insert

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

    ll k, a, b;
    cin >> k >> a >> b;
    bool ans = false;
    for(int i = a; i <= b; i++) {
        if(i % k == 0) {
            ans = true;
            break;
        }
    }
    if(ans) {
        cout << "OK";
    } else {
        cout << "NG";
    }
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int N;
	cin>>N;
	double arr[N];
	for(auto &it:arr)
	{
		cin>>it;
	}
	vector<vector<double>> dp(N+1,vector<double> (N+1,0));
	dp[0][0]=1.0;
	for(int i=1;i<=N;i++)
	{
		for(int j=0;j<=N;j++)
		{
			if(j==0)
			dp[i][j]=dp[i-1][j]*(1-arr[i-1]);
			else
			dp[i][j]=dp[i-1][j]*(1-arr[i-1])+dp[i-1][j-1]*arr[i-1];
		}
	}
	double ans=0;
	for(int i=(N+1)/2;i<=N;i++)
	{
		ans+=dp[N][i];
	}
	cout<<fixed<<setprecision(10)<<ans;

}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

ll A, B;

signed main()
{
    cin >> A >> B;
    cout << A / __gcd(A, B) * B << endl;
    return 0;
}

Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    println!("{}",if (b*2+c)%4<1{"YES"}else{"NO"})
}

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

#define     pb              push_back
#define     ll              long long
#define     rep(i,a,b)      for( i=a;i<b;++i)
#define     F               first
#define     S               second
#define     mod7            1000000007
#define     vii             vector<long long >
#define     vvii            vector<vector<long long >>
#define     mii             map<int,int>
#define     mp              make_pair
using namespace std;
long long  k,n;

int32_t main()
{
   
     ll n,w;
     cin>>n>>w;
     vector<ll>val(n),W(n);
     int i;
     for(int i=0;i<n;i++)
     {
         cin>>W[i]>>val[i];
     }
     vvii dp(w+1,vii(n+1,0));

     for(int i=1;i<=w;i++)
     {
         for(int j=1;j<=n;j++)
         {
            if(W[j-1]<=i)
            {
                dp[i][j]=max(dp[i][j-1],val[j-1]+dp[i-W[j-1]][j-1]);
            }
            else
            {
                dp[i][j]=dp[i][j-1];
            }
         }
     }
     cout<<dp[w][n];



}


Measured memory_bytes: 82304
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>

#include <unordered_map>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<29
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define _DEBUG(x) cout<<#x<<": "<<x<<endl
#define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

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

    map<char, int> mp;
    string line;
    cin >> line;

    for(int i = 0; i < line.length(); i++) {
        char c = line.at(i);
        mp[c] = mp.find(c) != mp.end() ? mp[c] + 1 : 1;
    }

#if DEBUG
    cout << "** RESULT **" << endl; // debug
#endif
    for(auto elem : mp) {
        if(elem.second % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M;/* your task */ }
	int h2(int key){ return 1 + (key % ( M -1 ));/* your task */}

int find(char str[]){
    long long key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0)return 0;
		}
	return 0;

}

int insert(char str[]){
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0){
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 15400
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int D, check = 0, count = 0 ;
  int C[27] ;
  cin >> D ;
  int S[27][D+1], choice[D+1] = {}, history[27] = {} ;
  for(int i=1;i<27;i++){
    cin >> C[i] ;
    history[i] = D ;
  }  
  for(int i=1;i<(D+1);i++){
    for(int j=1;j<27;j++){
      cin >> S[j][i] ;
    }
  }
  for(int date=D;date>0;date--){
    int search = 0, maxi = -1 ;
    for(int i=1;i<27;i++){
      if(maxi <= ( S[i][date] + (history[i] - date) * C[i] ) ){
        search = i ;
        maxi = S[i][date] + (history[i] - date) * C[i] ;
      }
    }
    choice[date] = search ;
    history[search] = date ;
  }
  for(int date=1;date<(D+1);date++){
    cout << choice[date] << endl ;
  }
  return 0 ;
}  

Measured memory_bytes: 3676
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,N = map(int,readline().split())
m = map(int,read().split())
AB = zip(m,m)

INF = 10 ** 18
U = 20000
dp = np.full(U, INF, np.int64)
dp[0] = 0

for a,b in AB:
    n = (U + (-U) % a) // a
    dp = np.resize(dp, U + (-U) % a).reshape(-1,a)
    dp -= (np.arange(n) * b)[:,None]
    dp = np.minimum.accumulate(dp, axis=0)
    dp += (np.arange(n) * b)[:,None]
    dp = dp.ravel()[:U]

answer = min(dp[H:])
print(answer)


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

int main() {
  int N , A , O ;
  cin >> N >> A ;
  
  O = N - (N / 500) * 500 ;

  if(O <= A) {
    cout << "Yes" << endl;
  }
  
  else if(O > A) {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<cmath>
#include<string.h>
#include<cstring>
#include<string> 
using namespace std;
#pragma warning(disable:4996)

string s;

int main() {
	
	cin >> s;
	int q;
	cin >> q;
	int t, f;
	char c;
	int cou = 0;
	for (int i = 1; i <= q; i++) {
		cin >> t;
		if (t == 1)
			cou++;
			
		else {
			cin >> f >> c;
			if (cou % 2 == 0) {
				if (f == 1) s.insert(s.begin(), c);
				else s.insert(s.end(), c);
			}
			else {
				if (f == 2) s.insert(s.begin(), c);
				else s.insert(s.end(), c);
			}
		}
	}
	if(cou%2==1)reverse(s.begin(), s.end());
	cout << s << endl;
	return 0;
}

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

#define	inrange(x,y)	(0<=(x) && (x)<=5000 && 0<=(y) && (y)<=5000)

using namespace std;

char pole[5001][626];

int main(){
	for(int n;scanf("%d",&n),n;){
		for(int i=0;i<=5000;i++)for(int j=0;j<=625;j++)	pole[i][j]=0;
		static int x[3000],y[3000];
		for(int i=0;i<n;i++){
			scanf("%d%d",x+i,y+i);
			pole[y[i]][x[i]>>3]|=(1<<(x[i]&7));
		}

		int area=0;
		for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
			int ax=x[i],ay=y[i];
			int bx=x[j],by=y[j];
			int cx,cy,dx,dy,ex,ey,fx,fy;
			cx=ax-(by-ay);	cy=ay+(bx-ax);
			dx=bx-(by-ay);	dy=by+(bx-ax);
			ex=ax+(by-ay);	ey=ay-(bx-ax);
			fx=bx+(by-ay);	fy=by-(bx-ax);
			if((inrange(cx,cy) && inrange(dx,dy) && pole[cy][cx>>3]&(1<<(cx&7)) && pole[dy][dx>>3]&(1<<(dx&7)))
			|| (inrange(ex,ey) && inrange(fx,fy) && pole[ey][ex>>3]&(1<<(ex&7)) && pole[fy][fx>>3]&(1<<(fx&7))))
				area=max(area,(bx-ax)*(bx-ax)+(by-ay)*(by-ay));
		}

		printf("%d\n",area);
	}

	return 0;
}

Measured memory_bytes: 3844
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int> >
#define VPII vector<pair<int,int> >

#define INT ll

using namespace std;
/*........................................Define functions.........................................*/


/*....................................Define global variables .....................................*/



/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	/*.........................................kemkemG0................................................*/

	// A*N-(N-1)>=B
	int A,B;
	cin>>A>>B;
	int i=0;
	while(1){
		if(A*i-(i-1) >=B){cout<<i<<endl; return 0;}
		i++;
	}











	return 0;
}




Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    s = s + s;
    // pos[i] : 文字 i が出現する位置リスト
    vvll pos(26);
    REP(i, 2 * n){
        pos[s[i] - 'a'].push_back(i);
    }
    ll cnt = 0, cur = -1;
    REP(i, m){
        if(pos[t[i] - 'a'].size() == 0){
            cout << -1 << endl;
            return 0;
        }
        ll itr = upper_bound(ALL(pos[t[i] - 'a']), cur) - pos[t[i] - 'a'].begin();
        ll nxt = pos[t[i] - 'a'][itr];
        if(nxt >= n) cnt++;
        cur = nxt % n;
    }
    ll res = cnt * n + cur + 1;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2916
package main

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

func main() {
	s := IOInitialize()
	N := Int(s)
	x := Int(s)
	nums := scanNums(s, N)
	sort.Ints(nums)
	cnt := 0
	for i, num := range nums {
		x -= num
		if x >= 0 {
			if i == len(nums)-1 {
				if x == 0 {
					cnt++
				}
			} else {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


Measured memory_bytes: 640
N = int(input())
AC, WA, TLE, RE = 0, 0, 0, 0
for _ in range(N):
    s = input()
    if s == "AC":
        AC += 1
    if s == "WA":
        WA += 1
    if s == "TLE":
        TLE += 1
    if s == "RE":
        RE += 1

print("AC x", AC)
print("WA x", WA)
print("TLE x", TLE)
print("RE x", RE)


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

LL bigmod(LL b, LL p, LL mod) {
  LL res = 1%mod, x = b%mod;
  while (p) {
    if (p&1) res = (res * x)%mod;
    x = (x * x)%mod;
    p >>= 1;
  }
  return res%mod;
}

LL modinv(LL x, int mod) {
  return bigmod(x, mod - 1, mod);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  string s;
  cin >> s;

  int len = s.size();
  reverse(s.begin(), s.end());

  int pref = 0;
  LL ans = 0;
  map <int,int> dp;
  dp[0] = 1;

  for (int i = 0; i < len; i++) {
    pref = pref + (s[i] - '0') * bigmod(10, i, 2019);
    pref %= 2019;
    ans += dp[pref];
    dp[pref]++;
  }

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



Measured memory_bytes: 3768
#define _CRT_SECURE_NO_DEPRECATE
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; // 注意必要时改类型
typedef vector<int> vi;
const int N = 1e5 + 5;
int n;
vi a(3);
ll dp[N][3];
void Process() {
	memset(dp, -1, sizeof(dp));
	cin >> n;
	for (Rint i = 0; i < n; ++i) {
		for (Rint j = 0; j < 3; ++j) {
			cin >> a[j];
			if (i == 0) dp[i][j] = a[j];
		}
		if (i) {
			for (Rint j = 0; j < 3; ++j) {
				for (Rint k = 0; k < 3; ++k) {
					if (j == k) continue;
					else {
						dp[i][j] = max(dp[i - 1][k] + a[j], dp[i][j]);
					}
				}
			}
		}
	}
	cout << *max_element(dp[n - 1], dp[n - 1] + 3) << endl;
	return;

}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef _DEBUG
	int tt = clock();
	freopen("in.txt", "r", stdin);
#endif 
	int Tcase = 1;
	// cin >> Tcase;
	while (Tcase--) {
		Process();
	}

#ifdef _DEBUG
	cerr << "\nTIME = " << clock() - tt << endl;
	tt = clock();
#endif
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n, M;
	cin >> n;
	map<int, int> m;
	int tmp;
	REP(i,0,n){
		cin >> tmp;
		++m[tmp];
	}
	cin >> M;
	string ans = "YES";
	REP(i, 0, M){
		cin >> tmp;
		if(m[tmp] == 0){
			ans = "NO";
			break;
		}
		--m[tmp];
	}
	cout << ans;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll a, b, c, x;
    cin >> a >> b >> c >> x;
    ll ans = 0;
    rep(i, a + 1) {
        rep(j, b + 1) {
            rep(k, c + 1) {
                if (500 * i + 100 * j + 50 * k == x) ans++;
            }
        }
    }

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

Measured memory_bytes: 3588
#include <iostream>
#include <vector>


using namespace std;


using ll = long long;


void dump_array(vector<ll>& A, ll N)
{
    for (auto i = 0; i < N - 1; i++)
        cout << A[i] << " ";
    cout << A[N - 1] << endl;
}


int main()
{
    vector<ll> A;
    ll N;

    cin >> N;
    for (auto i = 0; i < N; i++) {
        ll x;
        cin >> x;
        A.push_back(x);
    }

    for (auto i = 1; i < N; i++) {
        dump_array(A, N);

        auto j = i;
        auto tmp = A[j];
        while (j > 0 && !(A[j - 1] <= tmp)) {
            A[j] = A[j - 1];
            j--;
        }
        A[j] = tmp;
    }

    dump_array(A, N);
}



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

int main(){
    char a,b;
    cin>>a>>b;
    if(a=='H'){
        if(b=='D')cout<<'D'<<"\n";
        else cout<<'H'<<"\n";
    }else{
        if(b=='H')cout<<'D'<<"\n";
        else cout<<'H'<<"\n";
    }
    return 0;
}

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

#define int int64_t
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<=(n); i++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define ll long long
#define re(s) reverse((s).begin(),(s).end())
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

int q,cnt=0;
int lcs[3010][3010];
string s,v;
char sv[3005];

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

    cin>>s>>v;

    rep(i,s.size()){
        rep(j,v.size()){
            if(s[i] == v[j]){
                lcs[i+1][j+1] = lcs[i][j]+1;
            }else{
                lcs[i+1][j+1] = max(lcs[i+1][j],lcs[i][j+1]);
            }
        }
    }

    int i = s.size();
    int j = v.size();

    while(lcs[i][j]!=0){
        if(lcs[i][j] == lcs[i-1][j]){
            --i;
        }else if(lcs[i][j] == lcs[i][j-1]){
            --j;
        }else{
            --i;
            --j;
            sv[cnt] = s[i];
            ++cnt;
        }
    }

    reverse(sv,sv+cnt);
    cout<<sv<<'\n';
}

Measured memory_bytes: 70784
N = int(input())
H = list(map(int, input().split()))

#調べっていってmaxのところでカウントアップ。minで保持。
H.append(0)

res = 0
up = True
bottom = 0
for i in range(N):
    if (up):
    	if H[i] > H[i+1]:
            #ピークを発見
            res += (H[i] - bottom)
            up = False
    else:
        if H[i] < H[i+1]:
            #ボトムを発見
            bottom = H[i]
            up = True
print(res)


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

int main(void){
    double a, b, x;
    cin>>a>>b>>x;
    double ans=0;
    if(a*a*b/2<=x){
       double c=2*x/a/a-b;
        ans=atan((b-c)/a);
    }
    else{
        ans=atan(a*b*b/(2*x));
    }
    printf("%.10f\n", ans/3.14159265359*180);
}

Measured memory_bytes: 256
int main()
{
  int n;
  scanf("%d", &n);
  int a[n], b[n], c[n - 1], i;
  for (i = 0; i < n ;i++)
    scanf("%d", &a[i]);
  for (i = 0; i < n ;i++)
    scanf("%d", &b[i]);
  for (i = 0; i < n - 1 ;i++)
    scanf("%d", &c[i]);
  int sum = 0;
  for (i = 0; i < n; i++)
  {
    sum += b[a[i] - 1];
    if (i < n - 1)
      if (a[i] + 1 == a[i + 1])
        sum += c[a[i] - 1];
  }
  printf("%d", sum);
}

Measured memory_bytes: 128
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <queue>
using namespace std;

int GCD(int A, int B){
  if(A < B) return GCD(B, A);
  if(B == 0) return A;
  else return GCD(B, A%B);
}  

int main(){
  int N, M, ans = 0, primer = 0, maker = 0, setG = 0 ;
  cin >> N ;
  int A[N], prime[1000005], gotprime[1000005] = {} ;
  for(int i=0;i<N;i++){
    cin >> A[i] ;
  }
  setG = A[0] ;
  for(int i=1;i<N;i++){
    setG = GCD(setG,A[i]) ;
  }
  if(setG != 1){
    cout << "not coprime" << endl ;
    return 0 ;
  }
  for(int i=1;i<1000003;i++){
    prime[i] = i ;
  }
  for(int i=2;i<1003;i++){
    if(prime[i] == i){
      maker = i ;
      while((maker)<1000003 ){
        prime[maker] = i ;
        maker += i ;
      }
    }
  }
  for(int i=0;i<N;i++){
    while(A[i] > 1){
      primer = prime[A[i]] ;
      if(gotprime[primer] == 1){
        cout << "setwise coprime" << endl ;
        return 0 ;
      }
      else{
        gotprime[primer] = 1 ;
        while(prime[A[i]] == primer){
          A[i] /= primer ;
        }
      }
    }
  }
  cout << "pairwise coprime" << endl ;
  return 0 ;
}  

Measured memory_bytes: 15344
M=2019;L,R=map(int,input().split())
l=L%M;r=R%M;a=M-1
if l<r and R-L<672:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a=min(a,i*j%M)
      if a<2: break
    if a<2: break
else: a=0
print(a)

Measured memory_bytes: 3060
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
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; }
typedef unsigned long ul;
const ul INF = 1LL<<60;
long i,N,A[100002],sum;

inline void solve2(){
  IN(N);
  REP(i,N)cin>>A[i+1];
  UP(i,1,N+1)sum+=abs(A[i]-A[i-1]);
  UP(i,1,N){
    if(A[i-1]<=A[i]&&A[i]<=A[i+1])OUT(sum);
    else if(A[i-1]>=A[i]&&A[i]>=A[i-1])OUT(sum);
    else OUT(sum-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]));
  }
}

// O(N^2)のウンコ解法
// inline void solve(){
//   IN(N);
//   REP(i,N){
//     cin>>A[i+1];
//   }
//   UP(i,1,N){
//     ans=0;
//     from=0;
//     UP(j,1,N){
//       if(j==i)continue;
//       ans+=abs(A[j]-A[from]);
//       from=j;
//     }
//     ans+=abs(A[from]);
//     OUT(ans);
//   }
// }

int main(int argc,char**argv){
  BEGIN;
  solve2();
  END;
}


Measured memory_bytes: 2048
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int aI,aO,aT,aJ,aL,aS,aZ;
    cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ;

    int ans0 = 0;
    ans0 += aO;
    ans0 += aJ/2*2;
    ans0 += aL/2*2;
    ans0 += aI/2*2;

    int ans1 = 0;
    ans1 += aO;
    if(aI>0 && aL>0 && aJ>0){
        ans1 += 3;
        aI--;
        aL--;
        aJ--;
    }
    ans1 += aJ/2*2;
    ans1 += aL/2*2;
    ans1 += aI/2*2;

    cout << max(ans1,ans0) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n, b, f, r, v, i, j, k;
  int num[4][3][10] = {};

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d %d %d", &b, &f, &r, &v);
    num[b - 1][f - 1][r - 1] += v;
  }

  for(i=0;i<4;i++){
    if(i) printf("####################\n");

    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d", num[i][j][k]);
      }
      printf("\n");
    }
  }

return 0;
}



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

int main() {
  int N,L;
  cin>>N>>L;
  vector<string>S(N);
  for(int i=0;i<N;i++){
    cin>>S[i];
  }
  string ans;
  sort(S.begin(),S.end());
  for(int i=0;i<N;i++){
    ans+=S[i];
  }
  cout<<ans<< endl;
}
  

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  vector<double> xs(N);
  cin >> xs;

  vector<double> dp(N+1);
  dp[0] = 1;

  for(auto p: xs){
    for(int i=N;i>=0;--i){
      dp[i] = (i ? dp[i-1] * p : 0) + dp[i] * (1 - p);
    }
  }

  cout << fixed << setprecision(12) << accumulate(begin(dp)+(N/2+1), end(dp), 0.) << endl;

  return 0;
}


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

int main(){
	int n,k;
	cin>>n>>k;
	int ans = 0;
	string s;
	cin>>s;
	for(int i=1;i<n;i++)
		if(s[i] == s[i-1])
			ans++;
	int i = 0;
	while(ans < n-1 && k > i++)
		ans += 2;
	cout<<min(ans, n-1);
	return 0;
}

Measured memory_bytes: 512
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC opatimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }

int main() {
//    freopen("in.txt","r", stdin);
//    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);


    int n;
    cin >> n;
    string a,b;
    cin >> a >> b;


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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){

    int n,k;
    string str;
    char chara[50];

    cin >> n >> k;
    cin >> str;

    const char* ch = str.c_str();
    FOR(i,0,n)chara[i] = ch[i];

    chara[k-1] = tolower(ch[k-1]);

    FOR(i,0,n)cout << chara[i];

    return 0;
}

char tolower(char c) {
  return (c + 0x20);
}


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

int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if((H==0)&&(W==0))break;
        for(int i = 1;i<=H;i++){
            for(int j = 1;j<=W;j++){
                if((i%2==1&&j%2==1)||(i%2==0&&j%2==0)){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define  pii pair<int,int>
ll N,M;

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

  stack<int> st;
  int cnt=0;
  for(int i=0;i<s.size();i++){
    if(st.empty()) st.push(s[i]);
    else{
      
      if(st.top()==s[i]) {st.push(s[i]);}
      else {st.pop();cnt+=2;}
    }
  }
  cout<<cnt;
    
}

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include <math.h>
#include<algorithm>
#include<functional>
#define ll long long
#define inf  999999999
#define pa pair<int,int>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

class Point{
	public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y) {}
	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
	Point operator * (double a) {return Point(x*a,y*a);}
	Point operator / (double a) {return Point(x/a,y/a);}
	double absv() {return sqrt(norm());}
	double norm() {return x*x+y*y;}
	bool operator < (const Point &p) const{
		return x != p.x ? x<p.x: y<p.y;
	}
	bool operator == (const Point &p) const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};
typedef Point Vector;

struct Segment{
Point p1,p2;
};


double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

//----------------kokomade temple------------


int main(){
int n;
cin>>n;
double a1,a2,a3,a4,a5,a6,a7,a8;
Point p0,p1,p2,p3,d2,d3,ans;
Vector l;
for(int i=0;i<n;i++){
cin>>a1>>a2>>a3>>a4>>a5>>a6>>a7>>a8;
p0.x=a1,p0.y=a2;
p1.x=a3,p1.y=a4;
p2.x=a5,p2.y=a6;
p3.x=a7,p3.y=a8;
l=(p1-p0)/(p1-p0).absv();
d2=p0+l*dot(p2-p0,l);
d3=p0+l*dot(p3-p0,l);
double r2=(d2-p2).absv(),r3=(d3-p3).absv();
ans=p2*r3/(r2+r3) + p3*r2/(r2+r3);
printf("%.10f %.10f\n",ans.x,ans.y);
}



return 0;
}

Measured memory_bytes: 1248
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main(void)
{
	int n, k;
	int a = 1;
	
	scanf("%d %d", &n, &k);

	for (int i=1;i<= n;i++) {
		if (a + k <= a * 2) a = a + k;

		else a = a*2;
		

	}

	printf("%d",a);

	return 0;
}

Measured memory_bytes: 128
#EDPC_A
n=int(input())
h=list(map(int,input().split()))
dp=[10**5 for _ in range(n)]
dp[0]=0

for i in range(1,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]) , (dp[i-2]+abs(h[i]-h[i-2])))
    
print(dp[n-1])

Measured memory_bytes: 13976
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(ll &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
ll a,b,k;
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(a);in(b);in(k);
	if(k>=a){
		k-=a;a=0;
		if(b-k>0)b-=k;else b=0;
		printf("%lld %lld\n",a,b);
	}
	else printf("%lld %lld\n",a-k,b);
	return 0;
}

Measured memory_bytes: 256
import sys

S = input()

if len(S) % 2 == 1:
    print('No')
    sys.exit()

for i in range(0, len(S), 2):
    if S[i:i + 2] == 'hi':
        continue
    else:
        print('No')
        sys.exit()
else:
    print('Yes')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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 main() {
	int X,Y;
	cin >> X >> Y;
	int a,b;
	for(int i=0; i<=100; i++) {
		a = i;
		b = X-i;
		if(b < 0) break;
		if(2*a + 4*b == Y) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3620
import math
n = int(input())
ratio = 1.08
# orig_price_lower <= orig_price < orig_price_upper
orig_price_lower = n / ratio
orig_price_upper = (n + 1) / ratio
orig_price = math.ceil(orig_price_lower)
if orig_price < orig_price_upper:
    print(orig_price)
else:
    print(':(')

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
	int a[4],b[4];
	while(~scanf("%d %d %d %d\n%d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])){
		int hit=0,blow=0;
		for(int i=0;i<4;i++)if(a[i]==b[i])hit++;
		for(int i=0;i<4;i++)
			for(int j=0;j<4;j++)
				if(a[i]==b[j])blow++;
		blow-=hit;
		printf("%d %d\n",hit,blow);}
	return 0;}


Measured memory_bytes: 2768
#include <stdio.h>
int min(int, int);
int middle(int, int, int);
int max(int, int);
int ab_val(int);

int main(void){
  int a, b, c;
  int first, second, last;
  int task1, task2;;
  scanf("%d%d%d", &a, &b, &c);
  first=min(a, min(b, c));
  second=middle(a, b, c);
  last=max(a, max(b, c));

  task1=ab_val(second-first);
  task2=ab_val(last-second);

  printf("%d\n", task1+task2);
         
  return 0;
}

int min(int x, int y){
  if(x<=y)
    return x;
  else
    return y;
}

int max(int x, int y){
  if(x<=y)
    return y;
  else
    return x;
}

int middle(int x, int y, int z){
  if(x<=y){
    if(y<=z){
      return y;
    }else
      return (x<=z)? z: x;
  }else{
    if(z<=y)
      return y;
    else
      return (x<=z)? x: z;
  }
  return 0;
}

int ab_val(int x){
  if(x<0)
    return -x;
  else
    return x;
}


Measured memory_bytes: 128
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

int32_t Exhaust(vector<int32_t> X, int32_t P) {
  int32_t sum = 0;
  for (const int32_t x : X) {
    sum += (x - P) * (x - P);
  }
  return sum;
}

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

  int32_t N;
  cin >> N;
  vector<int32_t> X(N);
  for (int32_t i = 0; i < N; ++i) {
    cin >> X[i];
  }

  int32_t min_sum = INT32_MAX;
  for (int32_t P = 0; P <= 100; ++P) {
    const int32_t sum = Exhaust(X, P);
    if (sum < min_sum) {
      min_sum = sum;
    }
  }
  cout << min_sum << endl;
  return 0;
}


Measured memory_bytes: 256