akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long A = 0;
		long B = 0;

		BigDecimal n = new BigDecimal(N);
		BigDecimal p = new BigDecimal("0");

		for (int i=1;i<=N;i++) {
			int score = i;
			int num = 0;
			while(score < K) {
				score *= 2;
				num++;
			}
			if (i == 1) {
				A = (long) (Math.pow(2, num) * N);
			}
			B += A / (long) (Math.pow(2, num) * N);



//			p = p.add(new BigDecimal(1).divide( new BigDecimal(Math.pow(2, num)) ).divide(n, RoundingMode.HALF_EVEN));
		}
		p = new BigDecimal(B).divide(new BigDecimal(A),15, RoundingMode.HALF_UP);
		System.out.println(p);
	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 20820
def readints():
    return list(map(int, input().split()))


n = int(input())
p = readints()
# print(sorted(p))
q = sorted(p)

sum = 0
for i in range(n):
    if p[i] != q[i]:
        sum += 1
print("YES" if sum <= 2 else "NO")


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
using namespace std;

struct edge{
    int to, c, t;
};

typedef long long ll;

int main(){
    int n, m, s;
    cin >> n >> m >> s;
    s = min(s, 2500);
    vector<edge> v[n];
    while(m--){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--;
        v[a].push_back(edge({b, c, d}));
        v[b].push_back(edge({a, c, d}));
    }
    int ex[n][2];
    for(int i = 0; i < n; i++){
        cin >> ex[i][0] >> ex[i][1];
    }
    vector<vector<ll>> dp(50, vector<ll>(3000, 1ll<<62));
    dp[0][s] = 0;
    priority_queue<pair<ll, pair<int,int>>> pq;
    pq.push({-0, {0, s}});
    while(!pq.empty()){
        auto p = pq.top();  pq.pop();
        ll now = -p.first;
        int pos = p.second.first, gin = p.second.second;
        if(dp[pos][gin] != now) continue;
        for(edge e : v[pos]){
            ll nc = now + e.t;
            int npos = e.to;
            int ngin = gin-e.c;
            if(ngin >= 0 && dp[npos][ngin] > nc){
                dp[npos][ngin] = nc;
                pq.push({-nc, {npos, ngin}});
            }
        }
        if(gin != 2500){
            int ngin = min(gin+ex[pos][0], 2500);
            ll nc = now + ex[pos][1];
            if(dp[pos][ngin] > nc){
                dp[pos][ngin] = nc;
                pq.push({-nc, {pos, ngin}});
            }
        }
    }
    for(int i = 1; i < n; i++){
        ll ret = 1ll<<62;
        for(int j = 0; j <= 2500; j++)  ret = min(ret, dp[i][j]);
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 6560
#include<stdio.h>

int dp[50];

int fib(int n){
    if(n == 0 || n == 1) return dp[n]  = 1;
    if(dp[n] != -1) return dp[n];
    return dp[n] = fib(n - 1) + fib(n - 2);
}

int main(){
    int n,i;
    for(i = 0; i < 50; i++) dp[i] = -1;

    scanf("%d",&n);
    printf("%d\n",fib(n));

    return 0;
}


Measured memory_bytes: 2052
import sys
input = sys.stdin.readline
INF = 10**10
MOD = 10**9 + 7
sys.setrecursionlimit(100000000)
from functools import lru_cache
from copy import deepcopy 

def main():
    n,t  = map(int,input().split())
    time = list(map(int,input().split()))
    
    ans = t
    for i in range(n - 1):
        ans += min(t,time[i + 1] - time[i])
    
    print(ans)

if __name__=='__main__':
    main() 

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < n - 1; i++) {
    if (h[i] >= h[i + 1]) {
      cnt++;
    } else {
      cnt = 0;
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int dp[101][100005],n,W;
vector<int> v,w;
int solve(int i,int sum){
  if(i==n)return (sum==0?0:1e16);
  if(dp[i][sum]!=-1)return dp[i][sum];
  int ans=1e18;
  if(sum>=v[i])ans=min(ans,w[i]+solve(i+1,sum-v[i]));
  ans=min(ans,solve(i+1,sum));
  dp[i][sum]=ans;
  return ans;
}
int32_t main(){
   clr(dp,-1);
   cin>>n>>W;
   int sum=0;
  rep(i,0,n){
    int t;
    cin>>t; w.pub(t);
    cin>>t; v.pub(t);
    sum+=t;
  }
  int ans=0;
  repd(i,sum,0){
    if(solve(0,i)<=W){
      ans=i;
      break;
    }
  }
  cout<<ans<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


Measured memory_bytes: 82492
#include <stdio.h>

int main (void) {
    int n, m, c;
    scanf("%d%d%d", &n, &m, &c);
    int b[m], a[n][m];
    int i, j;
    int ans = 0, sum = 0;
    for (i = 0; i < m; i++) {
        scanf("%d", &b[i]);
    }
    for (i = 0; i < n; i++) {
        sum = c;
        for (j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
            sum += b[j] * a[i][j];
        }
        if ( sum > 0 ) {
            ans++;
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  n,k,x,y:Integer;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(n);
    Readln(k);
    Readln(x);
    Readln(y);

    Writeln(((n+k-abs(n-k))div 2 * x) + ((n-k+abs(n-k)) div 2 * y));//nとkの最小値*x、n-kと0の最大値*y
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef double dd;
const int MOD = 1e9 + 7;

void solve(){
  int n;
  cin >> n;
  int count = 0, ans = 0;
  for(int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if( x== y )
      count++;
    else 
      count = 0;
    if(count == 3)
      ans = 1;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1, tt = 0;
  //cin >> t;
  while(t--){
    //tt++;
    //cout << "Case #" << t << ": ";
    solve();
  }
  return 0;
}


Measured memory_bytes: 3660
pr :: [String] -> IO()
pr [] = do
  putStrLn ""
  return ()
pr (s:[]) = do
  putStrLn s
  return ()
pr (s:sx) = do
  putStr (s++" ")
  pr sx
  return ()

main = do
  l <- getContents
  let i = (lines l)!!1
      o = reverse $ words i
  pr o

Measured memory_bytes: 3540
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

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

    int count = 0;
    for (int i = 0; i < N - 2; ++i) {
        if (S.substr(i, 3) == "ABC") {
            ++count;
        }
    }
    
    cout << count << endl;
    return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

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



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

	while(true) {
		int n,m,a[1000];
		int ans=-1;
		cin>>n>>m;
		if(n==0) break;
		REP(i,n) cin>>a[i];

		REP(i,n) REP(j,i) if(a[i]+a[j]<=m) ans=max(ans,a[i]+a[j]);
		if(ans!=-1) cout<<ans<<endl;
		else cout<<"NONE"<<endl;
	}

	return 0;
}



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

int main(){
  string S;
  cin >> S;
  
  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  }else if(S == "Cloudy"){
    cout << "Rainy" <<endl;
  }else{
    cout << "Sunny" << endl;
  }
    
  
 return 0; 
}

Measured memory_bytes: 3584
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 55;

LL ec = 0,hed[N] = {0},nxt[N << 1],to[N << 1];
void add_edge(LL f,LL t){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec;
}

LL fa[N] = {0},dep[N] = {0},t[N] = {0};
LL u[N],v[N],lca[N],n,m,ans = 0;

void dfs(LL u,LL f){
	fa[u] = f;
	dep[u] = dep[f] + 1;
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(v == f) continue;
		dfs(v,u);
		t[u] += t[v];
	}
}

LL get_lca(LL x,LL y){
	if(dep[x] < dep[y]) swap(x,y);
	while(1){
		if(dep[x] == dep[y]) break;
		x = fa[x];
	}
	while(1){
		if(x == y) break;
		x = fa[x]; y = fa[y];
	}
	return x;
}

void solve(){
	for(LL s = 0;s < (1LL << m);s ++){
		memset(t,0,sizeof(t));
		LL tt = 0,cnt;
		for(LL j = 0;j < m;j ++){
			if(s & (1LL << j)){
				t[u[j]] ++; t[v[j]] ++; t[lca[j]] -= 2;
				tt ++; 
			}
		}
		dfs(1,0); cnt = n - 1;
		for(LL j = 2;j <= n;j ++) if(t[j]) cnt --;
//		cout << s << ' ' << tt << ' ' << cnt << endl;
		ans += ((tt & 1) ? -1 : 1) * (1LL << cnt);
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(LL i = 1;i < n;i ++){
		cin >> u[0] >> v[0];
		add_edge(u[0],v[0]);
		add_edge(v[0],u[0]);
	}
	dfs(1,0);
	cin >> m;
	for(LL i = 0;i < m;i ++){
		cin >> u[i] >> v[i];
		lca[i] = get_lca(u[i],v[i]);
	}
	solve();
	cout << ans << endl;
	return 0;
}

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

int main() {
int n;
  cin >> n;
vector<int> V(n);
vector<int> C(n);
  rep(i,n) cin >> V.at(i);
  rep(i,n) cin >> C.at(i);
int ans;
rep(i,n){
  int d = V.at(i)-C.at(i);
  if(d > 0) ans += d;
}
cout << ans << endl;

}
  


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int n,a[100100],b[100100];
int main()
{
  scanf ("%d",&n);
  for (int i=0;i<=n;i++) scanf ("%d",&a[i]);
  for (int i=0;i<n;i++) scanf ("%d",&b[i]);
  long long ans = 0;
  for (int i=0;i<n;i++){
    int v =  min(a[i],b[i]);
ans += v;
   	a[i] -= v;
    b[i] -= v;
    int w =  min(a[i+1],b[i]);
    ans += w;
    a[i+1]-=w;
    b[i] -= w;
  }
  printf ("%lld\n",ans);
return 0;
}

Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int cnt=0;
	cin>>s;
	if(s[0]=='1')cnt++;
	if(s[1]=='1')cnt++;
	if(s[2]=='1')cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);


int main()
{
    int n;
    cin >> n;
    int ans = 0;
    string a[3];
    for(int i = 0; i < 3; i++) cin >> a[i];
    for(int i = 0; i < n; i++){
        if(a[0][i] == a[1][i] && a[1][i] == a[2][i] && a[0][i] == a[2][i]);
        else if(a[0][i] != a[1][i] && a[1][i] != a[2][i] && a[0][i] != a[2][i]) ans += 2;
        else ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += c[i] < v[i] ? v[i] - c[i] : 0;
        }
        System.out.println(ans);
        sc.close();

    }

}


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

int main()
{
    ll N, Q;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    cin >> Q;
    vector<ll> B(Q), C(Q);
    rep(i, Q) cin >> B[i] >> C[i];

    vector<ll> cnt(1e5 + 1, 0);
    ll ans = 0;
    rep(i, N)
    {
        cnt[A[i]]++;
        ans += A[i];
    }

    rep(i, Q)
    {
        ans = ans + cnt[B[i]] * (C[i] - B[i]);
        cnt[C[i]] += cnt[B[i]];
        cnt[B[i]] = 0;
        cout << ans << "\n";
    }
    cout << flush;

    return 0;
}


Measured memory_bytes: 6360
#include <stdio.h>

int main(void)
{
	int n, pm, pe, pj;
	int i;
	
	while (1){
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		for(i = 0; i < n; i++){
			scanf("%d %d %d", &pm, &pe, &pj);
			
			if (pm == 100 || pe == 100 || pj == 100){
				printf("A\n");
			}
			 else if ((pe + pm) / 2 >= 90 || (pe + pm + pj) / 3 >= 80){
			 	printf("A\n");
			 }
			 else if ((pe + pm + pj) / 3 >= 70){
			 	printf("B\n");
			 }
			 else if((pe + pm + pj) / 3 >= 50 && (pe >= 80 || pm >= 80)){
			 	printf("B\n");
			 }
			 else {
			 	printf("C\n");
			 }
		}
	}
	return (0);
}
		
		

Measured memory_bytes: 584
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
vector<int> v1;
int main(){
	int n;
	int a,b,c;
	while(cin>>n){
		if(!n)break;
		v1.clear();
		for(int i=0;i<n;i++){
			cin>>a;
			v1.push_back(a);
		}
		sort(v1.begin(),v1.end());
		b=1e9;
		for(int i=0;i<n-1;i++){
			a=v1[i+1]-v1[i];
			if(b>a)b=a;
		}
		cout<<b<<endl;
	}
}



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

int main(){
  string s;
  cin >> s;
  map<char,int>m;
  for(auto&& a : s){
    m[a]++;
  }
  bool even = true;
  for(auto&& p : m){
    if(p.second % 2 == 1){
      even = false;
      break;
    }
  }
  cout << (even ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;


int main(){
	ll n;
	cin>>n;
	ll a[n];
	ll b[n];
	for(ll i =0; i <n; i++){
		cin>>a[i];
		b[i] = a[i];
	}
	if(n==1){
		cout<<"Yes";
		return 0;
	}
	sort(b,b+n);
	for(ll i = 0; i < n; i++){
		if(abs(b[i]-a[i]) > 1) {
			cout<<"No";
			return 0;
		}	
	}
		
	cout<<"Yes";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int a[10],x;
char c;
int main(){
    while(cin>>c){
        if(c=='0') a[x++]=0;
        else if(c=='1') a[x++]=1;
        else
            if(x) x--;
    }
    if(x){
        for(int i=0;i<x;i++) printf("%d",a[i]);
        printf("\n"); 
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;

const ll INF = 1e+3;
const int MAX_N = 100;
ll cost[MAX_N][MAX_N];
ll d[MAX_N];
bool used[MAX_N];
ll V;
vector<ll> H;

void dijkstra(ll s){
  fill(d, d+V, INF);
  fill(used, used+V, false);
  fill(cost[0], cost[MAX_N], INF);
  d[s] = 0;

  for (ll i = 0; i < V; i++)
  {
    cost[i][i+1] = abs(H[i] - H[i+1]);
    cost[i][i+2] = abs(H[i] - H[i+2]);
  }

  while (true)
  {
    int v = -1;
    for (int u = 0; u < V; u++)
    {
      if(!used[u] && (v == -1 || d[u] < d[v])) v=u;
    }
    if (v == -1) break;
    used[v] = true;

    for (int u = 0; u < V; u++)
    {
      d[u] = min(d[u], d[v] + cost[v][u]);
    }
  }
}

void solve_dijkstra(long long N, std::vector<long long> h){
  V = N;
  H = h;
  dijkstra(0);
  std::cout << d[V-1] << endl;
}

ll dfs(ll i){
  if(dp[i] >= 0) return dp[i];
  ll d1, d2;
  d1 = abs(H[i] - H[i-1]);
  if (i == 1) return d1;
  d2 = abs(H[i] - H[i-2]);
  if (i == 2) return d2;
  // dp[i] = min(dfs(i-1) + d1, dfs(i-2) + d2);
  dp[i] = min(dfs(i-2) + d2, dfs(i-1) + d1);
  return dp[i];
}

void solve_recur_memoize(long long N, std::vector<long long> h){
  H = h;
  dp = vector<ll> (N+1, -1);
  std::cout << dfs(N-1) << endl;
}

void solve(long long N, std::vector<long long> h){
  dp = vector<ll> (N+1, 0);
  dp[1] = abs(h[1]-h[0]);
  ll d1, d2;

  for (ll i = 2; i < N; i++)
  {
    d1 = abs(h[i] - h[i-1]);
    d2 = abs(h[i] - h[i-2]);
    dp[i] = min(dp[i-1]+d1, dp[i-2]+d2);
  }

  std::cout << dp[N-1] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, std::move(h));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(X) (X).begin(),(X).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

Measured memory_bytes: 256
s = input()
s_list = [c for c in s]
output = []

for i in range(len(s)):
    if s_list[i] == '0':
        output.append('0')
    elif s_list[i] == '1':
        output.append('1')
    else:
        if len(output) > 0:
            output.pop()

print(''.join(output))


Measured memory_bytes: 3060
#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = 1000000007;

int main(void)
{
	int a, b;
	cin >> a;
	cin >> b;
	set<int> s;
	s.insert(1);
	s.insert(2);
	s.insert(3);
	s.erase(a);
	s.erase(b);
	cout << *s.begin() << endl;
	return 0;
}


Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>

typedef long long ll;



int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int x;
    cin >> x;
    cout << ((x>=30)?"Yes":"No") << endl;
}

Measured memory_bytes: 3048
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int main(){

	int n,m,total_distance = 0,current,sum = 0,tmp,sum_tmp;
	scanf("%d %d",&n,&m);
	int table[n];

	for(int i = 0; i < n-1; i++){
		scanf("%d",&table[i]);
		total_distance += table[i];
	}

	current = 0;

	for(int loop = 0; loop < m; loop++){
		scanf("%d",&tmp);

		if(tmp < 0){
			sum_tmp = 0;
			if(abs(tmp) > (n-1)-abs(tmp)){
				for(int div = 0; div < (n-1)-abs(tmp); div++){
					if(current + div <= n-2){
						sum_tmp += table[current+div];
					}else{
						sum_tmp += table[current+div-(n-1)];
					}
				}
				sum += (total_distance - sum_tmp);
				sum %= 100000;
			}else{
				for(int div = 1; div <= abs(tmp); div++){
					sum_tmp += table[current-div];
				}
				sum += sum_tmp;
				sum %= 100000;
			}
			current += tmp;
		}else{
			sum_tmp = 0;
			if(tmp > (n-1)-tmp){
				for(int div = 1; div <= (n-1)-tmp; div++){
					if((current-div) < 0){
						sum_tmp += table[current-div+n-1];
					}else{
						sum_tmp += table[current-div];
					}
				}
				sum += (total_distance - sum_tmp);
				sum %= 100000;
			}else{
				for(int div = 0; div < tmp; div++){
					sum_tmp += table[current+div];
				}
				sum += sum_tmp;
				sum %= 100000;
			}
			current += tmp;
		}
	}

	printf("%d\n",sum);

    return 0;
}

Measured memory_bytes: 3092
n,k=map(int,input().split())
ans=0
MOD=(10**9)+7

fact_ans=[1 for _ in range(n+1)]
for i in range(1,n+1):
    fact_ans[i]=fact_ans[i-1]*i

def fact(n):
    if(n<0):
        return 1
    else:
        return fact_ans[n]

for i in range(1,k+1):
    blue=fact(k-1)//(fact(k-i)*fact(i-1))
    red=( fact(n-k+1)//( fact(i)*fact(n-k+1-i))  )
    print((blue*red)%MOD)


Measured memory_bytes: 5748
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    rep(i,0,n) cin>>h[i];
    
    int ans=0;
    int now=0;
    rep(i,0,n-1){
        if(h[i+1]<=h[i]) now++;
        else{
            ans=max(now,ans);
            now=0;
        }
    }
    ans=max(now,ans);
    
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int check(int x) {
	if (x == 2)
		return 1;
	else if ((x < 8 && x % 2 == 1) || (x >= 8 && x % 2 == 0)) {
		return 2;
	}
	else {
		return 3;
	}
}

int main() {
	int x, y;
	cin >> x >> y;
	cout << (check(x) == check(y) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 10000

int main()
{
  int i,j,n,q;
  int A[N],count=0,key;

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

  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&key);
      A[n]=key;
      for(j=0;A[j]!=key;j++){
      }
      if(j==n) continue;
      count++;
    }
  

  printf("%d\n",count);

  return 0;
}
	






  

  




Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mod 1000000007

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    set<pair<int, int>> s;
    for(int i=0; i<n; i++)
    {
        int a, b;
        cin>>a>>b;
        s.insert({a, b});
    }
    map<pair<int, int>, int> m;
    for(auto it1=s.begin(); it1!=s.end(); it1++)
    {
        auto it2=it1;
        for(it2++; it2!=s.end(); it2++)
        {
            int x1=it1->first, y1=it1->second, x2=it2->first, y2=it2->second;
            m[{x1-x2, y1-y2}]++;
        }
    }
    int c=0;
    for(auto x:m)
        c=max(c, x.second);
    // c++;
    cout<<n-c;
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


const int L = 128;
const int N_CHARS = 62;
const string CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

int LEN;

int query(string str) {
    cout << "? " << str << endl;
    int result;
    cin >> result;
    return result;
}

string interleave(string a, string b) {
    int n = int(a.size()), m = int(b.size());
    string result;
    int i = 0, j = 0;

    while (i < n && j < m) {
        string candidate = result;
        candidate += b[j];
        candidate += a.substr(i);

        if (query(candidate) == LEN - int(candidate.size()))
            result += b[j++];
        else
            result += a[i++];
    }

    while (i < n)
        result += a[i++];

    while (j < m)
        result += b[j++];

    return result;
}

int main() {
    ios::sync_with_stdio(false);

    assert(int(CHARS.size()) == N_CHARS);
    vector<string> strings;
    LEN = 0;

    for (int c = 0; c < N_CHARS; c++) {
        int freq = L - query(string(L, CHARS[c]));
        LEN += freq;

        if (freq > 0)
            strings.emplace_back(freq, CHARS[c]);
    }

    while (strings.size() > 1) {
        sort(strings.begin(), strings.end(), [](const string &x, const string &y) {
            return x.size() > y.size();
        });
        string a = strings.back(); strings.pop_back();
        string b = strings.back(); strings.pop_back();
        strings.push_back(interleave(a, b));
    }

    cout << "! " << strings.front() << endl;
}


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

#define MAX 200002

int n;

vector < pair<int, int> > v;

vector<pair<int, int> > vv;

int main() {
	cin >> n;
	bool ok = false;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		v.push_back(make_pair(a, b));
		if (a != b) {
			ok = true;
		}
	}
	if (ok == false) {
		puts("0");
		return 0;
	}
	long long int ans = 0;
	long long int rest = 0;
	for (int i = 0; i < v.size(); i++) {
		if (v[i].first == v[i].second) {
			ans += v[i].first;
			continue;
		}
		if (v[i].first < v[i].second) {
			ans += v[i].first;
			rest += v[i].second - v[i].first;
			continue;
		}
		vv.push_back(v[i]);
	}
	long long int sum2 = 0;
	long long int mint = LLONG_MAX;
	for (int i = 0; i < vv.size(); i++) {
		sum2 += vv[i].first;
		mint = min(mint, (long long int)vv[i].second);
	}
	sum2 -= mint;
	ans += sum2;
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 640
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N, K = map(int, input().split())
X = list(map(int, input().split()))

left = 0
right = K - 1

ans = INF
while right < len(X):
    if X[right] <= 0:
        ans = min(ans, abs(X[left]))
    elif X[left] >= 0:
        ans = min(ans, X[right])
    else:
        val1 = abs(X[left] - 0) * 2 + abs(X[right] - 0)
        val2 = abs(X[right] - 0) * 2 + abs(X[left] - 0)
        ans = min(ans, val1, val2)
    left += 1
    right += 1
print(ans)

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> B[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long ans = 0LL;
    for (int i = 0; i < N; i++)
    {
        auto a = lower_bound(A.begin(), A.end(), B[i]);
        int ans1 = distance(A.begin(), a);
        auto c = upper_bound(C.begin(), C.end(), B[i]);
        int ans2 = distance(c, C.end());
        ans += (long long)ans1 * ans2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
     
    int arr[]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n,x;
    cin >> n;
    
    cout << arr[n - 1];
;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int left = 0;
    ll ans = 0;
    rep(i, N) {
        if (A[i] > left)
            left = A[i];
        else
            ans += left - A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4044
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	int N;
	cin >> N;

	vector<char> S(N);
	FOR(i, 0, N) cin >> S[i];

	vector<int> black(N + 1);
	vector<int> rwhite(N + 1);

	FOR(i, 0, N) {
		black[i + 1] = black[i];
		if (S[i] == '#') black[i + 1]++;
		DMP(black[i]);
	}

	for (int i = N - 1; i >= 0; i--){

		rwhite[i] = rwhite[i + 1];
		if (S[i] == '.') rwhite[i]++;
		

		black[i] += rwhite[i + 1];
		DMP(rwhite[i]);
	}

	cout << *min_element(black.begin(), black.end() - 1);
	return 0;
}

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

using namespace std;

#define int long long

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

#ifdef DBG
#define log(item) cout << #item << " " << item << endl
#else
#define log(item)
#endif

typedef vector<int> VI;
typedef pair<int, int> PII;

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

int ans = 0;

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

    int ans = 0;

    for(int i = 1; i * i <= N; i++){
        if(N % i == 0){
            int m = N / i;
            m--;
            if(m > i){
                ans += m;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
   ll N,Q,a[100010]={0},b[100010]={0},c[100010]={0},s[100010]={0},cnt[100010]={0};
   cin>>N;
   rep(i,N) {
       cin>>a[i];
       cnt[a[i]-1]++;
   }
   cin>>Q;
   rep(i,Q){
       cin>>b[i]>>c[i];
   }
   rep(i,N){
       s[0]+=a[i];
   }
    rep(i,Q){
        s[i+1]=s[i]+(c[i]-b[i])*cnt[b[i]-1];
        cnt[c[i]-1]+=cnt[b[i]-1];
        cnt[b[i]-1]=0;
    }
    for(int i=1;i<=Q;i++){
        p(s[i]);
    }
}
  

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

static const int N = 4;
static const int N2 = 16;

static const int dx[] = {0,-1,0,1};
static const int dy[] = {1,0,-1,0};
int MDT[N2][N2];

struct Puzzle {
    int f[N2], space, MD;
    int cost;
    bool operator < (const Puzzle& p) const {
	for(int i=0; i<N2; i++) {
	    if( f[i] == p.f[i] ) continue;
	    return f[i] < p.f[i];
	}
	return false;
    }
};

struct State {
    Puzzle puzzle;
    int estimated;
    bool operator < (const State& s) const  {
	return estimated > s.estimated;
    }
};

int getAllMD(Puzzle pz) {
    int sum=0;
    for(int i=0; i<N2; i++) {
	if( pz.f[i] == N2 ) continue;
	sum += MDT[i][pz.f[i]-1];
    }
    return sum;
}

inline void dump(Puzzle& u) {
    for(int i=0; i<N; i++) {
	for(int j=0; j<N; j++)
	    cout << u.f[i*N+j] << " " ;
	cout << endl;
    }
}

int astar(Puzzle s) {
    priority_queue<State> PQ;
    s.MD = getAllMD(s);
    s.cost = 0;
    map<Puzzle, bool> V;
    Puzzle u,v;
    State initial;
    initial.puzzle = s;
    initial.estimated = getAllMD(s);
    PQ.push(initial);

    while( !PQ.empty() ) {
	State st = PQ.top(); PQ.pop();
	u = st.puzzle;
	if( u.MD == 0 ) return u.cost;
	V[u] = true;

	int sx = u.space / N;
	int sy = u.space % N;
	for(int r=0; r<4; r++) {
	    int tx = sx + dx[r];
	    int ty = sy + dy[r];
	    if( tx<0 or ty<0 or tx>=N or ty>=N ) continue;
	    v = u;

	    v.MD -= MDT[tx*N+ty][v.f[tx*N+ty]-1];
	    v.MD += MDT[sx*N+sy][v.f[tx*N+ty]-1];

	    swap(v.f[sx*N+sy], v.f[tx*N+ty]);
	    v.space = tx*N+ty;
	    if( !V[v] ) {
		v.cost++;
		State news;
		news.puzzle = v;
		news.estimated = v.cost + v.MD;
		PQ.push(news);
	    }
	}
    }
    return -1;
}


int main() {
    for(int i=0; i<N2; i++)
	for(int j=0; j<N2; j++)
	    MDT[i][j] = abs(i/N-j/N) + abs(i%N-j%N);

    Puzzle in;

    for(int i=0; i<N2; i++) {
	cin >> in.f[i];
	if(in.f[i] == 0) {
	    in.f[i] = N2;
	    in.space = i;
	}
    }
    cout << astar(in) << endl;
    return 0;
}

Measured memory_bytes: 257708
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
int main(){
    int n,m;
    cin>>n>>m;
  	bool ch[n+1];
  	rep(i,0,n+1)ch[i]=true;
  	rep(i,0,m){
  	    int a;
  	    cin>>a;
  	    ch[a]=false;
  	}
    ll dp[100010]={};
    dp[0]=1;
    if(ch[1])dp[1]=1;
    rep(i,2,n+1){
        if(ch[i]){
            dp[i]=(dp[i-1]+dp[i-2])%MOD;
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1152
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H =0;
    int W =0;
    while(true){
     H = sc.nextInt();
     W = sc.nextInt();

//  System.out.println("");
   if(H != 0 && W != 0){
    for(int i = 0; i < H ; i++){
      for(int j = 0; j < W ; j++){
        System.out.print("#");
      }
      System.out.print("\n");
    }
    System.out.println("");
  }else{
    return;
  }

}
//  sc.close();
  //System.exit(0);

  }

}


Measured memory_bytes: 35056
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::string;

int main(){
  int n;
  int i,j;
  int sum;
  int count = 0;
  while(cin >> n){
    count = 0;
    if(n == 0){
      break;
    }
    for(i = 1;i < n;i++){
      sum = 0;
      for(j = 0;j < n;j++){
        sum += i + j;
        if(sum == n){
          count += 1;
        }else if(sum > n){
          break;
        }
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 3096
#include <cstdio>
#include <utility>
#include <vector>
#include <complex>
#include <cmath>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;

using Point=complex<double>;
using Plane=vector<Point>;
using Polygon=vector<Point>;

bool operator<(const Point &a, const Point &b) {
    return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

enum {
    ONLINE_FRONT=-2,
    CLOCKWISE,
    ON_SEGMENT,
    COUNTER_CLOCKWISE,
    ONLINE_BACK,
};

int ccwise(Point a, Point b, Point c) {
    b -= a; c -= a;

    if (cross_prod(b, c) > 0) {
        return COUNTER_CLOCKWISE;
    } else if (cross_prod(b, c) < 0) {
        return CLOCKWISE;
    } else if (dot_prod(b, c) < 0) {
        return ONLINE_BACK;
    } else if (norm(b) < norm(c)) {
        return ONLINE_FRONT;
    } else {
        return ON_SEGMENT;
    }
}

bool is_convex(Polygon g) {
    size_t V=g.size();
    for (size_t i=0; i<V; ++i) {
        int state=ccwise(g[i], g[(i+1)%V], g[(i+2)%V]);
        if (state == CLOCKWISE)
            return false;
    }

    return true;
}

int main() {
    size_t n;
    scanf("%zu", &n);

    Polygon g(n);
    for (size_t i=0; i<n; ++i) {
        double x, y;
        scanf("%lf %lf", &x, &y);
        g[i] = Point(x, y);
    }

    printf("%d\n", is_convex(g));
    return 0;
}

Measured memory_bytes: 2812
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//(char-'0') 数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a,b;
  ci(a>>b);
  ll an=0;
  if(a==3)
    an+=100000;
  else if(a==2)
    an+=200000;
  else if(a==1)
    an+=300000;
  if(b==3)
    an+=100000;
  else if(b==2)
    an+=200000;
  else if(b==1)
    an+=300000;
  if(a==b&&a==1)
    an+=400000;
  co(an);
}

Measured memory_bytes: 256
N = input()
C = [0]*5
for _ in range(N):
  s = raw_input()[0]
  if s in "MARCH":
    C["MARCH".index(s)] += 1
ans = 0
for i in range(5):
  for j in range(i):
    for k in range(j):
      ans += C[i]*C[j]*C[k]
print ans


Measured memory_bytes: 5764
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]
  l2=[i for i in range(n)]

  sm=0
  for c in itertools.permutations(l2,n):
    _sm=0
    for i in range(n-1):
      a=l[c[i]]
      b=l[c[i+1]]

      _sm+=math.sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)
    sm+=_sm

  return sm/math.factorial(n)

# main()
print(main())


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

int main(void){

    int H;
    int W;

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

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int X,A,B;
  cin >> X >> A >> B;
  if(abs(X-A) > abs(X-B)){
    cout << "B" << endl;
  }
  else{
    cout << "A" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
} 
int a[1234567];
signed main(){
	ic(k) ic(n)
	rep(0,i,n)cin>>a[i];
	int ans=k-a[n-1]+a[0];
	rep(0,i,n-1)ans=max(ans,a[i+1]-a[i]);
	c(k-ans)
}		

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int D; cin >> D;
  if(D == 25){
    cout << "Christmas" << endl;
  }else if(D == 24){
    cout << "Christmas Eve" << endl;
  }else if(D == 23){
    cout << "Christmas Eve Eve" << endl;
  }else{
    cout << "Christmas Eve Eve Eve" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  int c[n],s[n],f[n];
  for(int i = 0; n-1 > i; i++){
    cin>>c[i]>>s[i]>>f[i];
  }
  for(int i = 0; n > i; i++){
    int nw = 0;
    for(int j = i; n-1 > j; j++){
      if(nw < s[j]){
        nw = s[j]+c[j];
      }else{
        if(nw%f[j]!=0)nw = nw/f[j]*f[j]+f[j];
        nw += c[j];
      }
    }
    cout << nw << endl;
  }
}
    
    

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<m;i++)
template <typename Container> void P(const Container &c) {
    for (const auto& x : c) cout << x << ' '; cout << '\n';
}
int main()
{
    int X, Y; cin >> X >> Y;
    cout << X + (Y / 2) << endl;
    return 0;
}


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

using namespace std;
int main(void)
{
	int n,i,j,c,ct,ch,max,flg,flg2;
	int t[201],h[201],x[201];
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=1;i<=n*2;i++) x[i]=0;
		for(i=1;i<=n;i++){
			scanf("%d",&t[i]);
			x[t[i]]=1;
		}
		sort(t+1,t+n+1);
		c=1;
		for(i=1;i<=n*2;i++){
			if(x[i]==0){
				h[c]=i; c++;
			}	
		}		
		ct=n; ch=n; flg=0; flg2=0; max=0;
		while(1){
			if(ct==0||ch==0) break;
			if(flg==0){
				for(j=1;j<=n;j++){
					if(max<t[j]){
						max=t[j]; flg=1; ct--; t[j]=-1;
						flg2=1; break;
					}
				}
				if(flg==0&&flg2==0){
					max=0; flg=1;
				}	
			}	
			else if(flg==1){
				for(j=1;j<=n;j++){
					if(max<h[j]){
						max=h[j]; flg=0; ch--; h[j]=-1;
						flg2=0; break;
					}
				}
				if(flg==1&&flg2==1){
					max=0; flg=0;
				}	
			}	
		}
		printf("%d\n",ch);
		printf("%d\n",ct);
	}
	return 0;
}

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

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

    int count = 0;
    int countMax = 0;
    bool countFlag = false;

    for(int i = 0; i < s.size(); i++)
    {
        if(s.at(i) == 'A')countFlag = true;

        if(countFlag)
        {
            count++;
        }
        
        if(s.at(i) == 'Z')
        {
            countMax = max(count,countMax);
        }

    }

    cout << countMax << endl;
}

Measured memory_bytes: 640