akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) (((long long)mod_x)%modulo)

struct Data{
	long long b,l,u;
	long long value;
	long long sum;
};


int main(){
	
	long long N,X;
	cin>>N>>X;
	
	long long ans = 0;
	long long aoki = 0;
	
	vector<Data> V(0);
	
	for(int i=0;i<N;i++){
		Data D;
		long long b,l,u;
		cin>>D.b>>D.l>>D.u;
		
		aoki += D.b*D.l;
		D.value = (X*D.u)-(D.u-D.l)*D.b;
		V.push_back(D);
		
	}
	
	sort(V.begin(),V.end(),[&](Data a,Data b){
		return a.value>b.value;
	});

	long long mini = 999999999999999;

	for(int i=0;i<V.size();i++){
		if(i==0)V[i].sum=V[i].value;
		else V[i].sum = V[i].value+V[i-1].sum;
	}

	for(int i=0;i<V.size();i++){
		int ng = -1;
		int ok = N-1;
		long long S=aoki;
		while(abs(ok-ng)>1){
			int mid = (ng+ok)/2;
			long long a = V[mid].sum;
			if(mid>=i)a-=V[i].value;
			if(a>=aoki)ok=mid;
			else{
				ng=mid;
				S=aoki-a;
			}
		}
		if(ng>=i)ng--;
		ng++;
		long long a = X*ng;
		for(int j=0;j<2;j++){
			long long x;
			if(j==0)x= V[i].l;
			else x=V[i].u;
			S+=(x-V[i].l)*V[i].b;
			long long b =(S+x-1)/x;
			if(b<=X)mini = min(mini,a+b);
		}
	}
	
	cout<<mini<<endl;
	
	return 0;
}

Measured memory_bytes: 7536
S = input()
if 1 <= int(S[:2]) <= 12 and not (1 <= int(S[2:]) <= 12):
    print('MMYY')
elif not (1 <= int(S[:2]) <= 12) and 1 <= int(S[2:]) <= 12:
    print('YYMM')
elif 1 <= int(S[:2]) <= 12 and 1 <= int(S[2:]) <= 12:
    print('AMBIGUOUS')
else:
    print('NA')

Measured memory_bytes: 61772
Q, H, S, D = [int(i) for i in input().split()]                                                       
N = int(input())                                                                                     
                                                                                                     
price = [Q, H, S, D]                                                                                 
vol = [0.25, 0.5, 1, 2]                                                                              
unit = [Q*4, H*2, S, D//2]                                                                           
                                                                                                     
p = 0                                                                                                
idx = 4                                                                                              
while True:                                                                                          
    idx = unit.index(min(unit[:idx]))                                                                
                                                                                                     
    p += int(N / vol[idx]) * price[idx]                                                              
    N -= vol[idx]*int(N / vol[idx])                                                                  
                                                                                                     
    if N == 0:                                                                                       
        break;  

print(int(p))

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

int main(void)
{
    IOS
    const int M = 1e5;
    int n,m; cin >> n >> m;
    vector<vector<int>> ab(M+1);
    REP(i,n) {
        int a,b;
        cin >> a >> b;
        ab[a].push_back(b);
    }
    
    priority_queue<pii> pq;
    ll ans = 0;
    FOR(i,1,m+1) {
        for(auto x:ab[i]) pq.push({x,i});
        if (!pq.empty()) {
            ans += pq.top().first;
            pq.pop();
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5632
public class Main {

  private static void solve() {
    int a = ni();
    int b = ni();

    for (int k = 1; k < 1000000; k++) {
      int x = k * 108 / 100 - k;
      int y = k * 110 / 100 - k;

      if (x == a && y == b) {
        System.out.println(k);
        return;
      }
    }
    System.out.println(-1);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 23636
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    # dp[i] - is True if i gram of sugar is obtainable
    A, B, C, D, E, F = read_ints()
    dp = [0]*(F+1)
    for i in range(1, F+1):
        dp[i] = dp[i-1]
        if i-C >= 0:
            dp[i] = max(dp[i], dp[i-C]+C)
        if i-D >= 0:
            dp[i] = max(dp[i], dp[i-D]+D)

    highest_ratio = [0, 100*A]

    for a in range(31):
        for b in range(31):
            water = 100*A*a+100*B*b
            if water < F:
                sugar_limit = min(E*water//100, F-water)
                sugar = dp[sugar_limit]
                if sugar*highest_ratio[1] > water*highest_ratio[0]:
                    highest_ratio = [sugar, water]
    return sum(highest_ratio), highest_ratio[0]


if __name__ == '__main__':
    print(*solve())


Measured memory_bytes: 65380
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

int main() {
    ll a;
    ll sum=0;
    double b;
    cin>>a>>b;
    string sa="";
    if(a<100)sa+="0";
    if(a<10)sa+="0";
    sa+=to_string(a);
    double ss=(sa[sa.length()-1]-'0')*b+(sa[sa.length()-2]-'0')*b*10+(sa[sa.length()-3]-'0')*b*100;
    sum+=ss;
    
    string sb=to_string(b);
    int bbb=(sb[0]-'0')*100+(sb[2]-'0')*10+(sb[3]-'0');
    
    for(int i=sa.length()-4,c=1;i>=0;i--,c++){
        ll bb=bbb;
        for(int j=0;j<c;j++){
            bb*=10;
        }
        sum+=(sa[i]-'0')*bb;
    }
    cout<<sum;
}

Measured memory_bytes: 3824
new Promise(function(resolve, reject) {
    let cin = "";
    process.stdin
        .on("data", chunk => { cin += chunk; })
        .on("end", () => { resolve([cin, process.stdout]); });
}).then(function([cin, cout]) {
    for (const b of cin.split(/[ \n]/).map(elt => parseInt(elt))) {
        if (b === 0) {
            break ;
        }
        let opt = "\n";
        for (let m = 1; m * (m - 1) < 2 * b; ++m) {
            const det = 2 * b - m * (m - 1);
            if (det % (2 * m) === 0) {
                opt = `${det / (2 * m)} ${m}\n`;
            }
        }
        cout.write(opt);
    }
});



Measured memory_bytes: 21544
#include <iostream>

using namespace std;

unsigned long factorial(unsigned long n)
{
	unsigned long result = 1;
	for (unsigned long i = n; i > 0; --i) {
		result *= i;
	}
	return result;
}

int main()
{
	unsigned long value = 0;
	cin >> value;
	cout << factorial(value) << endl;

	return 0;
}

Measured memory_bytes: 1156
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc081/tasks/arc086_a

"""
import sys
from sys import stdin
from collections import Counter
input = stdin.readline


def solve(A, K):
    ans = 0

    c = Counter(A)
    divs = c.most_common()
    divs.reverse()

    diff = len(divs) - K
    for d in divs[:diff]:
        ans += d[1]
    return ans


def main(args):
    N, K = map(int, input().split())
    A = [int(x) for x in input().split()]
    ans = solve(A, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 39524
from itertools import combinations as cb
n,x,y = map(int, input().split())
pair = list(cb(range(1,n+1), 2))
dist = [0]*n
for a in pair:
  if a[1] <= x or a[0] >= y:
    dist[a[1]-a[0]] += 1
  else:
    dist[min(abs(x-a[0])+abs(y-a[1])+1,a[1]-a[0])] += 1
for i in range(1, n):
  print(dist[i])

Measured memory_bytes: 146084
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

ll cnt[100005] ;
int main(){
  ll n ;cin>> n ;
  vector<ll> A(n) ;
  ll sum=0 ;
  rep(i,100005) cnt[i]=0 ;
  rep(i,n){
    cin>>A[i] ;
    cnt[A[i]] ++ ;
    sum+=A[i] ;
  }
  ll q;cin>>q ;
  rep(i,q){
    ll a,b ; cin>>a>>b ;
    ll kosuu= cnt[a] ;
     sum+= kosuu*(b-a) ;
    cout<<sum<<endl ;
    cnt[b]+=kosuu ;
    cnt[a]=0 ;
  }
  return 0;
  }

Measured memory_bytes: 4840
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
struct data{
	int x1,x2,y1,y2,v;
}d[2000001];
struct tnode{
	int l,r,ls,rs;
	ll v,d;
}t[20001];
ll w[6001],x[6001],ans;
int i,j,k,n,m,b[6001][301],a[6001],p[6001],tot,num,q1[2000001],q2[2000001],t1,t2,q[6001];
bool cmp(int x,int y){
	return b[x][i]<b[y][i]||b[x][i]==b[y][i]&&x<y;
}
bool cmp2(int x,int y){
	return d[x].x1<d[y].x1;
}
bool cmp3(int x,int y){
	return d[x].x2<d[y].x2;
}
void mt(int l,int r){
	int p=++tot,m;
	t[p].v=0;t[p].l=l;t[p].r=r;
	if (l<r){
		m=(l+r)>>1;
		t[p].ls=tot+1;mt(l,m);
		t[p].rs=tot+1;mt(m+1,r);
	}else t[p].ls=t[p].rs=0;
}
void down(int p){
	t[p].v+=t[p].d;
	if (t[p].ls){
		t[t[p].ls].d+=t[p].d;t[t[p].rs].d+=t[p].d;
	}
	t[p].d=0;
}
void change(int p,int l,int r,int v){
	if (l<=t[p].l&&t[p].r<=r){
		t[p].d+=v;return;
	}
	down(p);
	int m=(t[p].l+t[p].r)>>1;
	if (l<=m) change(t[p].ls,l,r,v);
	if (r>=m+1) change(t[p].rs,l,r,v);
	down(t[p].ls);down(t[p].rs);
	t[p].v=max(t[t[p].ls].v,t[t[p].rs].v);
}
void query(int p){
	down(p);
	if (!t[p].ls){
		w[t[p].l]=t[p].v;return;
	}
	query(t[p].ls);query(t[p].rs);
}
int main(){
	while (scanf("%d%d",&n,&m)!=EOF){
		ans=tot=0;num=n*m;
		for (i=2,x[1]=0;i<=n;i++) scanf("%d",&k),x[i]=x[i-1]+k;
		for (i=1;i<=n;i++)
		 for (j=1;j<=m;j++) scanf("%d",&b[i][j]);
		for (i=1;i<=m;i++){
			for (j=1;j<=n;j++) a[j]=j,d[j+n*(i-1)].x2=d[j+n*(i-1)].y1=j,d[j+n*(i-1)].v=b[j][i];
			sort(a+1,a+1+n,cmp);
			for (j=1;j<=n;j++) p[a[j]]=j;
			for (j=1,q[0]=0;j<=n;j++){
				for (;q[0]&&p[q[q[0]]]<p[j];q[0]--);
				d[j+n*(i-1)].x1=q[q[0]]+1;
				q[++q[0]]=j;
			}
			for (j=n,q[0]=0;j;j--){
				for (;q[0]&&p[q[q[0]]]<p[j];q[0]--);
				d[j+n*(i-1)].y2=((q[0])?q[q[0]]-1:n);
				q[++q[0]]=j;
			}
		}
		for (i=1;i<=num;i++) q1[i]=q2[i]=i;
		sort(q1+1,q1+1+num,cmp2);sort(q2+1,q2+1+num,cmp3);
		mt(1,n);
		for (i=t1=t2=1;i<=n;i++){
			for (;t1<=num&&d[q1[t1]].x1<=i;t1++) change(1,d[q1[t1]].y1,d[q1[t1]].y2,d[q1[t1]].v);
			for (;t2<=num&&d[q2[t2]].x2<i;t2++) change(1,d[q2[t2]].y1,d[q2[t2]].y2,-d[q2[t2]].v);
			query(1);
			for (j=i;j<=n;j++) ans=max(ans,w[j]-(x[j]-x[i]));
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 33920
#include <iostream>
#include <vector>
using namespace std;
int n,m;
int dp[100005];
vector <int>g[100005];

int solve(int a){
  if (dp[a]==-1){
    int ret=0;
    for (int i=0;i<g[a].size();i++){
      ret=max(ret,solve(g[a][i]));
    }
    dp[a]=ret+1;
  }
  return dp[a];
}

int main(){
scanf("%d%d",&n,&m);
for (int i=0;i<m;i++){
  int x,y;
  scanf("%d%d",&x,&y);
  x--;
  y--;
  g[x].push_back(y);
}
for (int i=0;i<n;i++){
  dp[i]=-1;
}
int ret=0;
for (int i=0;i<n;i++){
  ret=max(ret,solve(i));
}
printf("%d\n",ret-1);
return 0;
}


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

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

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

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
        	int A = in.nextInt();
        	int B = in.nextInt();
        	String str = "No";
        	for(int i = 1; i <= 3; i++) {
        		if((A * B * i) % 2 == 1) {
        			str = "Yes";
        		}
        	}
        	out.println(str);
        }
    }

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

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

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

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

    }
}



Measured memory_bytes: 22740
#include<iostream>
#include<string>
using namespace std;
int d[1001][8]={};
int n,man;
string str;

int num(char m){
	switch(m){
		case 'J': return 1;
		case 'O': return 2;
		case 'I': return 4;
	}
}

int f(int day,int i){
	if(day>=n)return 1;
	if(d[day][i]!=0)return d[day][i];
	man=num(str[day]);
	int ans=0;
	for(int j=1;j<=7;j++){
		if((i&j) && (j&num(str[day]))){
			ans+=f(day+1,j);
			ans%=10007;
		}
	}
	return d[day][i]=ans;
}
int main(){
	cin>>n;
	cin>>str;
	cout<<f(0,1)<<endl;
	return 0;
}

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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

void solve()
{
    ll n,x,t,temp=0,final=0;
    cin>>n>>x>>t;
    while(temp<n)
    {
        temp+=x;
        final+=t;
    }
    cout<<final;
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

int N;

int main(int argc, const char * argv[]) {
    
    cin >> N;
    
    if (N==10 || N==100 || N==1000 || N==10000 || N==100000) {
        cout << 10 << endl;
        return 0;
    }
    
    int Ans = 0;
    while (N>0) {
        Ans += N%10;
        N /= 10;
    }
    cout << Ans << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(4);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
template <typename T>
struct ST{//1index query l,r lが開区間
  using F = function<T(T,T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;
  ST(){};
  ST(F f,T ti):f(f),ti(ti){}
  void init(int n_){    
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }
  void build(const vector<T> &v){
    int n_=v.size();
    init(n_);
    for(int i=0;i<n_;i++) dat[n+i]=v[i];
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }
  void set_val(int k,T x){//kは0-index
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);    
  }
  T query(int a,int b){
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }
};
const int M=300005;
int main(){
    auto f=[&](int a,int b){
        return max(a,b);
    };
    int n,k;
    cin>>n>>k;
    ST<int> dp(f,0);
    V<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    dp.init(300005);
    for(int i=0;i<n;i++){
        int v=dp.query(max(a[i]-k,0),min(a[i]+k+1,M));
        dp.set_val(a[i],max(v+1,dp.query(a[i],a[i]+1)));
    }
    cout<<dp.query(0,M)<<"\n";
}


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

using namespace std;

#define ll long long

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

  int x;
  cin >> x;
  if (x >= 30)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}

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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int dp[1001][1001] = {0};
char grid[1001][1001];


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w;
    cin >> h >> w;
    rep(i, h){
        rep(j, w){
            cin >> grid[i][j];
        }
    }

    dp[0][0] = 1;
    rep(i, h){
        rep(j, w){
            if(i+1 < h and grid[i+1][j] == '.'){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
            if(j+1 < w and grid[i][j+1] == '.'){
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] %= MOD;
            }
        }
    }

    ppp(dp[h-1][w-1]);






    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;


typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

// ¹öª¢çÈ¢ê
vector<Weight> dijkstra2(const Graph &g, int s) {
  vector<Weight> dist(g.size(), INF);
  dist[s] = 0;
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (dist[e.dst] < e.weight) continue;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
  return dist;
}

int main() {
  int n, m;
  while(cin>>n>>m,n||m) {
    map<string, int> mp;
    int cnt = 0;
    string s, t, u;
    cin >> s >> t >> u;
    mp[s] = cnt++; mp[t] = cnt++; mp[u] = cnt++;
    Graph g(n);
    REP(i, m) {
      string a, b;
      int d, e;
      cin >> a >> b>>d>>e;
      if (!mp.count(a)) mp[a] = cnt++;
      if (!mp.count(b)) mp[b] = cnt++;
      g[mp[a]].push_back(Edge(mp[a], mp[b], d/40+e));
      g[mp[b]].push_back(Edge(mp[b], mp[a], d/40+e));
    }
    int res = dijkstra2(g, mp[s])[mp[t]];
    res += dijkstra2(g, mp[t])[mp[u]];
    cout << res << endl;
  }
}

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

ll gcd(ll a, ll b) {
    if(a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

ll f(ll x, ll c, ll d, ll e) { return x - x / c - x / d + x / e; }

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll e = c / gcd(c, d) * d;
    ll ans = f(b, c, d, e) - f(a - 1, c, d, e);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,f,g,h,i,j;
	scanf("%d",&a);
	s=1;
	while(1){
		if(s*2>a) break;
		s*=2;
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 15;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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

	fread_unlocked(cn, 1, cm, stdin);
	int N = getint(), K = getint(), Q = getint();
	ll A[2002];
	int LR[2002];
	rep1(i, N) A[i] = ((ll)getint() << 16) + i;
	rep(i, N + 2) LR[i] = -1;

	priority_queue<int> q;
	priority_queue<int, vector<int>, greater<int>> q2[1001];
	int q3[2002] = {};
	int kotae = 1e9;
	int saishou = 2e9;
	sort(A + 1, A + N + 1);
	const int m = (1 << 16) - 1;
	int qn = 1;

	for (int i = N; i >= 1; i--) {
		int a = A[i] >> 16;
		int k = A[i] & m;

		int l = (LR[k - 1] == -1) ? k : LR[k - 1];
		int r = (LR[k + 1] == -1) ? k : LR[k + 1];
		LR[l] = r;
		LR[r] = l;

		if (l == r) q3[l] = qn++;
		int kosuu = max(min(K - 1, k - l), min(K - 1, r - k));
		if (k + k < l + r) swap(q3[l], q3[k + 1]);

		auto L = q2 + q3[l];
		auto R = q2 + q3[k + 1];

		while ((*R).size()) {
			(*L).push((*R).top());
			(*R).pop();
			if (kosuu == K - 1) {
				q.push((*L).top());
				(*L).pop();
			}
			else kosuu++;
		}
		(*L).push(a);
		if (kosuu == K - 1) {
			q.push((*L).top());
			(*L).pop();
		}
		while (q.size() >= Q) {
			int tmp = q.top();
			chmin(saishou, tmp);
			q.pop();
		}
		chmin(kotae, saishou - a);
	}

	printf("%d", kotae);

	Would you please return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	vector<int> h(n);
	for(auto &x : h){
		cin>>x;
	}
	reverse(h.begin(), h.end());
	int ans = 0, hp = 0, cur = -1;
	for(auto x : h){
		if(x >= hp){
			cur++;
		}else{
			cur = 0;
		}
		ans = max(ans, cur);
		hp = x;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 640
n = int(input())
lh = list(map(int, input().split()))

ct = 0
ans = 0

for i in range(n-1):
    if lh[i] >= lh[i+1]:
        ct += 1
    else:
        if ans < ct:
            ans = ct
        ct = 0

if ans < ct:
    ans = ct

print(ans)


Measured memory_bytes: 14252
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define maxn 100005
using namespace std;
typedef long long ff;
int fo[2*maxn+5];
long long kx[2*maxn+5],ty[2*maxn+5];

int fin(int x)
{
       if(fo[x]==x)
       return x;
       else
       return fo[x]=fin(fo[x]);

}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<2*maxn;i++)
    {fo[i]=i;
    ty[i]=0;
    kx[i]=0;
    }
    long long ans=0;
    int x,y;
    for(int i=0;i<n;i++)
    {
       scanf("%d %d",&x,&y);
       fo[fin(x)]=fin(y+maxn);
     //  printf("%d\n",fo[fin(x)]);
      // fo[find(y+maxn)]=y;
    }
     for(int i=1;i<maxn;i++)
     kx[fin(i)]++;
     for(int i=maxn;i<maxn*2;i++)
     ty[fin(i)]++;

     for(int i=1;i<=2*maxn;i++)
     {
     ans+=kx[i]*ty[i];
    // if(kx[i]*ty[i]!=0)
     //printf("%d %d\n",i,kx[i]*ty[i]);
     }
     printf("%lld",ans-n);

}


Measured memory_bytes: 4096
#include <stdio.h>

int n,k;
long long int w[100000];
int search(long long int mid){
  int a,b;
  int c=0;
  int count=0;
  
  for(a=0;a<n;a++){
    if(c+w[a]<=mid)c=c+w[a];
    else {c=w[a];count++;}
    
    if(count==k) {
        return 0;
    }
  }

  
  return 1;
}
int main(){
  int i;
  long long int mini=1,maxi=1000000000;
  long long int mid;
  
  scanf("%d %d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&w[i]);
    if(mini<w[i])mini=w[i];
  }
  while(mini<maxi){
    mid=(mini+maxi)/2;
    if(search(mid))maxi=mid;
    else mini=mid+1;
  }
  printf("%lld\n",mini);

  
  return 0;
}




Measured memory_bytes: 2636
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    long k = sc.nextLong();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt() - 1;
    }

    int step = 0;
    int pos = 0;
    int[] flg = new int[n];
    flg[pos] = -1;
    int len = 0; //サイクルの長さ

    while (true) {
      pos = a[pos];
      if (++step == k) {
        System.out.println(pos + 1);
        return;
      }

      if (flg[pos] != 0) {
        if (pos == 0) {
          len = step;
        } else {
          len = step - flg[pos];
        }
        break;
      }

      flg[pos] = step;
    }

    if (pos != 0) {
      k -= flg[pos];
    }

    k %= len;

    for (int i = 0; i < k; i++) {
      pos = a[pos];
    }

    System.out.println(pos + 1);
  }
}


Measured memory_bytes: 50504
#include<cstdio>
#include<cstring>
#include<iostream>
#define lowbit(x) ((x)&(-x))
using namespace std;
typedef unsigned long long ull;
const int N=2e3+100,maxn=31;
struct edge{
	int x,y,next;
}a[2*N];int len,last[N];
ull g[N][35],d[70];
void ins(int x,int y){
	a[++len].x=x;a[len].y=y;
	a[len].next=last[x];last[x]=len;
}
ull h[N][35],Son[N][35];
bool pd=true,bk[N];int fa[N],tot=0,dfn[N],si[N],LCA[N][N],LC[N][N];
void dfs(int x){
	bk[x]=false;dfn[x]=++tot;
	for(int i=0;i<=maxn;i++) h[dfn[x]][i]=h[fa[dfn[x]]][i];
	h[dfn[x]][(dfn[x]-1)/64]^=d[(dfn[x]-1)%64];
	si[dfn[x]]++;
	for(int k=last[x];k;k=a[k].next){
		int y=a[k].y;
		if(bk[y]){
			fa[tot+1]=dfn[x];
			dfs(y);
			for(int i=dfn[x];i<dfn[x]+si[dfn[x]];i++)
				for(int j=dfn[y];j<dfn[y]+si[dfn[y]];j++)
					LCA[i][j]=LCA[j][i]=dfn[x];
			for(int j=dfn[y];j<dfn[y]+si[dfn[y]];j++)
				LC[dfn[x]][j]=dfn[y];
			si[dfn[x]]+=si[dfn[y]];
		}
	}
}
int list[N*N][2],sum=0,ID[110];
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	len=0;memset(last,0,sizeof(last));
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		ins(x,y);ins(y,x);
	}
	d[0]=1;for(int i=1;i<=63;i++) d[i]=d[i-1]*2;
	for(int i=0;i<=63;i++) ID[d[i]%101]=i;
	memset(bk,true,sizeof(bk));
	dfs(1);
	ull Maxn=0;for(int i=0;i<=63;i++) Maxn^=d[i];
	for(int i=1;i<=n;i++)
		for(int j=i;j<si[i]+i;j++)
			Son[i][(j-1)/64]^=d[(j-1)%64];
	while(m--){
		int x,y;
		scanf("%d%d",&x,&y);
		x=dfn[x];y=dfn[y];
		g[x][(y-1)/64]^=d[(y-1)%64];
		g[y][(x-1)/64]^=d[(x-1)%64];
		list[++sum][0]=x;list[sum][1]=y;
	}
	int id=1;
	while(id<=sum){
		int x=list[id][0],y=list[id][1];
		if(x>y) swap(x,y);
		for(int i=0;i<=maxn;i++){
			ull t;
			if(x+si[x]>y) t=((Son[y][i]|(Maxn-Son[LC[x][y]][i])|(h[y][i]-h[fa[x]][i]))&((g[x][i]&(Maxn-g[y][i]))|(g[y][i]&(Maxn-g[x][i]))));
			else t=((Son[y][i]|Son[x][i]|(h[x][i]-h[fa[LCA[x][y]]][i])|(h[y][i]-h[fa[LCA[x][y]]][i]))&((g[x][i]&(Maxn-g[y][i]))|(g[y][i]&(Maxn-g[x][i]))));
			while(t){
				ull t2=lowbit(t);
				int t3=i*64+ID[t2%101]+1;
				if((g[y][i]&t2)==0){
					g[y][i]|=t2;list[++sum][0]=y;list[sum][1]=t3;
					g[t3][(y-1)/64]|=d[(y-1)%64];
				}
				if((g[x][i]&t2)==0){
					g[x][i]|=t2;list[++sum][0]=x;list[sum][1]=t3;
					g[t3][(x-1)/64]|=d[(x-1)%64];
				}
				t^=t2;
			}
		}
		id++;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if((g[i][(j-1)/64]&d[(j-1)%64])) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 51892
import math
def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a


a,b = [int(i) for i in input().split(' ')]
xs = [int(i) for i in input().split(' ')]
#a = pow(10, 5)

temp = 0
result = 0
for i, x in enumerate(xs):
    if i == 0:
        result = abs(x - b)
    else:
        result = gcd(abs(x - temp), result)
    temp = x
print(result)


Measured memory_bytes: 58656
N = int(input())
A = [0 * x for x in range(N)]
B = [0 * x for x in range(N-1)]

for i in range(N):
  A[i] = int(input())

flag = False
M = max(A)
if A.count(M) > 1:
  flag = True
for i in range(N):
  if A[i] == M:
    if flag:
      print (M)
    else:
      print(max(A[:i]+A[i+1:]))
  else:
    print (M)


Measured memory_bytes: 17136
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//Mobile Computing
public class Main{

	double r, best;
	int n;
	int[] ws, w;
	Set<String>[] trees;

	int bit(int s){
		int c = 0;
		for(int j=0;j<n;j++)if(((s>>j)&1)>0)c++;
		return c;
	}
	boolean sub(int s, int t){
		for(int j=0;j<n;j++)if(((t>>j)&1)>0&&((s>>j)&1)==0)return false;
		return true;
	}
	
	
	class M{
		double x;
		boolean leaf;
		int w;
		M left, right;
		public M(double x, boolean leaf, int w) {
			this.x = x;
			this.leaf = leaf;
			this.w = w;
			left = right = null;
		}
		int get(){
			if(leaf)return w;
			return left.get()+right.get();
		}
		void val(){
			if(leaf){
				min = Math.min(min, x); max = Math.max(max, x); return;
			}
			int w1 = left.get(), w2 = right.get();
			double a = w2*1.0/(w1+w2);
//			System.out.println("A:"+a+" X:"+x);
			left.x = x-a;
			right.x = x+1-a;
			left.val();
			right.val();
		}
		void f(){
			if(leaf){
				System.out.print("x"); return;
			}
			System.out.print("(");
			left.f();
			System.out.print(",");
			right.f();
			System.out.print(")");
		}
	}
	
	double min, max;
	boolean[] used;
	int[] order;
	void dfs(int k){
		if(k==n){
			for(String t:trees[n]){
				s = (t+"$").toCharArray();
				id = 0;
				int a = 0;
				for(int i=0;i<s.length;i++){
					if(s[i]=='?'){
						s[i] = (char)(order[a++]+'0');
					}
				}
//				System.out.println("S:"+new String(s));
				M root = exp();
//				root.f();
//				System.out.println();
				min = max = 0;
				if(!root.leaf){
					root.x = 0;
					root.val();
				}
				double res = max-min;
//				System.out.println(min+" - "+max+" RES:"+res);
				
				if(res<r)best = Math.max(best, res);
				root.val();
			}
			return;
		}
		for(int i=0;i<n;i++){
			if(used[i])continue;
			used[i]=true;
			order[k] = i;
			dfs(k+1);
			used[i]=false;
		}
	}
	
	char[] s;
	int id;
	char get(){
		return s[id++];
	}
	M exp(){
		char ch = get();
		if(ch=='('){
			M res = new M(0, false, 0);
			res.left = exp();
			get();
			res.right = exp();
			get();
			return res;
		}
		M res = new M(0, true, ws[ch-'0']);
		return res;
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		trees = new Set[7];
		for(int i=1;i<=6;i++)trees[i] = new HashSet<String>();
		trees[1].add("?");
		for(int i=2;i<=6;i++){
			for(int j=1;j<i;j++){
				for(String left:trees[j])for(String right:trees[i-j])trees[i].add("("+left+","+right+")");
			}
//			System.out.println("Size:"+trees[i].size());
//			debug(trees[i]);
		}
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T--!=0){
			r = sc.nextDouble(); n = sc.nextInt();
			ws = new int[n];
			for(int i=0;i<n;i++)ws[i]=sc.nextInt();
			w = new int[1<<n];
			for(int i=0;i<1<<n;i++){
				int s = 0;
				for(int j=0;j<n;j++)if(((i>>j)&1)>0)s+=ws[n-1-j];
				w[i] = s;
			}
//			if(n==1){
//				System.out.printf("%.8f\n", 0.0);
//				continue;
//			}
			best = -1;
			used = new boolean[n];
			order = new int[n];
			dfs(0);
			System.out.printf("%.8f\n", best);
		}
	}
	void debug(Object...o){
		System.out.println(Arrays.deepToString(o));
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
A,B,Q = map(int, input().split())
s = [-(10**11)]+[int(input()) for _ in range(A)]+[10**11]
t = [-(10**11)]+[int(input()) for _ in range(B)]+[10**11]
s.sort()
t.sort()
 
import bisect
import itertools
for _ in range(Q):
    pos = int(input())
    near_s = bisect.bisect_left(s, pos)-1
    near_t = bisect.bisect_left(t, pos)-1
    s1, s2 = s[near_s], s[near_s+1]
    t1, t2 = t[near_t], t[near_t+1]
    print(min(
        pos - min(s1,t1),
        max(s2,t2) - pos,
        (s2 - pos) + (s2 - t1),
        (pos - t1) + (s2 - t1),
        (t2 - pos) + (t2 - s1),
        (pos - s1) + (t2 - s1)
    ))


Measured memory_bytes: 13952
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int C = scan.nextInt();
        int[] B = new int[M];
        for(int i = 0; i<M; i++){
            B[i] = scan.nextInt();
        }

        int count = 0;
        int[][] A = new int[N][M];
        for(int row = 0; row < N; row++){
            for(int col = 0; col < M; col++){
                A[row][col] = scan.nextInt();
            }

            int sum = 0;
            for(int i = 0; i < M; i++){
                sum += A[row][i] * B[i];
            }
            sum += C;

            if(sum > 0){
                count++;
            }
        }

        System.out.print(count + "\n");
    }

    
}

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

long long a, b, c, d;

long long f(long long n, map<long long, long long> &m) {
  if (m.find(n) != m.end()) {
    return m[n];
  }
  if (n == 0) {
    m[0] = 0;
    return 0;
  }
  if (n == 1) {
    m[1] = d;
    return d;
  }
  if (n == 2) {
    m[2] = min(a, d) + d;
    return m[2];
  }
  pair<long long, long long> ks[3] = {{2, a}, {3, b}, {5, c}};
  long long ret = LLONG_MAX;
  for (auto p: ks) {
    long long k = p.first;
    long long n1 = (n - 1) / k + 1;
    long long n2 = n / k;
    long long cost1 = f(n1, m) + (n1 * k - n) * d;
    if (d < p.second && n1 * k - n1 < p.second) {
      cost1 += min(p.second, d * (n1 * k - n1));
    } else {
      cost1 += p.second;
    }
    long long cost2 = f(n2, m) + (n - n2 * k) * d;
    if (d < p.second && n2 * k - n2 < p.second) {
      cost2 += min(p.second, d * (n2 * k -  n2));
    } else {
      cost2 += p.second;
    }
    if (n2 == 0) {
      ret = min(cost1, ret);
    } else {
      ret = min(cost1, min(cost2, ret));
    }
  }
  m[n] = ret;
  return ret;
}
long long solve() {
  long long n;
  cin>>n>>a>>b>>c>>d;
  map<long long, long long> m;
  return f(n, m);
}
int main() {
  int t;
  cin>>t;
  for (int i=0; i<t; i++) {
    cout<<solve()<<endl;
  }
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	vector<int> rew(N);
	for (int i = 0; i < N; i++)rew[A[i] - 1] = i + 1;
	for (int i = 0; i < N; i++)cout << rew[i] <<' ';
	cout << endl;
	return 0;
}

Measured memory_bytes: 1664
' Imports System.Collections.Generic
' Imports System.Globalization
' Imports System.IO
' Imports System.Linq
' Imports System.Text
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim N, D As Integer
        Dim arr() As String
        arr = Split(Console.ReadLine())
        N = arr(0) : D = arr(1)
        Console.WriteLine(Math.Ceiling(N / (2 * D + 1)))
        Return
    End Sub
End Class

Measured memory_bytes: 28264
#include<iostream>
#include<string>
#include<cstdlib>
#include <typeinfo>
using namespace std;


int main(){
    int N = 99;
    string result;
    string S;
    cin >> S;
    int flag = 0;

    int pre = stoi(S.substr(0, 2));
    int post = stoi(S.substr(2));


    if (pre <= 0 || 13 <= pre){ // MMYYではない
        if (post <= 0 || 13 <= post){ //YYMMではない
            result = "NA";
        }else {
            result = "YYMM";
        }
    } else if ( (1 <= pre && pre <= 12) && (1 <= post && post <= 12)){
        result = "AMBIGUOUS";
    } else {
        result = "MMYY";
    }

    cout << result << endl; 
    
}

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

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

  vector<double> v;

  for (int i = 0; i < n; i++) {
    int input;
    cin >> input;
    v.push_back(input);
  }

  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  double x, y;

  for (int i = n; i > 0 ; i--) {
    double x = v.back();
    v.pop_back();

    double y = v.back();
    v.pop_back();

    v.push_back((x + y) / 2.0);
    if (v.size() == 1) break;

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

  }

  double ans = v.back();
  cout << ans << endl;

}

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;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    ll a=0,b=0,ab=0;
    ll cnt = 0;
    rep(i,n){
        rep(j,s[i].size()-1){
            if(s[i][j]=='A' && s[i][j+1]=='B'){
                cnt++;
            }
        }
        int h = s[i].size()-1;
        if(s[i][0]=='B') b++;
        if(s[i][h]=='A') a++;
        if(s[i][0]=='B' && s[i][h]=='A') ab++;
    }
    ll ans = cnt + min(a,b);
    //cout << a << " " << b << " " << ab << endl;
    if(ab>0 && a+b==0) ans--;
    if(a == ab && b == ab && ab>0) ans--;
    cout << ans << endl;
}

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

using namespace std;

int n,s[50];

int solve(int i,int m)
{
	if(m==0){
		return 1;
	}
	if(i>=n){
		return 0;
	}
	int res=solve(i+1,m)||solve(i+1,m-s[i]);
	return res;
}

int main()
{
	int q,m;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%d",&m);
		if(solve(0,m)){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
	return 0;
}
/*
5
1 5 7 10 21
4
2 4 17 8
*/


Measured memory_bytes: 3136
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
using namespace std;

int main()
{
	int a, b, c, t = 0, h = 0;
	while(scanf("%d,%d,%d", &a, &b, &c) != EOF){
		if(a * a + b * b == c * c){
			t++;
		}else if(a == b){
			h++;
		}
	}
	cout << t << endl << h << endl;
}

Measured memory_bytes: 1208
#include<stdio.h>

int main() {
	int n, a, b;
	int ans = 0;

	scanf("%d %d %d", &n,&a,&b);
	ans = n * a;
	if (ans > b) {
		ans = b;
	}

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

Measured memory_bytes: 128
S = list(input())
if len(S)%2 == 0:
    del S[-1]
    del S[-1]
    for i in range(len(S)):
        if S[0:(len(S))//2] == S[(len(S))//2::]:
            print(len(S))
            break
        else:
            del S[-1]
            del S[-1]
else:
    del S[-1]
    for i in range(len(S)):
        if S[0:(len(S))//2] == S[(len(S))//2::]:
            print(len(S))
            break
        else:
            del S[-1]
            del S[-1]

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007
#define ll long long
#define db double
#define pb push_back
#define F first
#define S second
#define vl vector<ll>
#define vvl vector<vl>
#define pii pair<int,int>
#define mkp make_pair

const ll N=305;
db dp[N][N][N];
bool vis[N][N][N];
db n,ans;
ll a[N];

db calc(ll x, ll y, ll z)
{
	if(vis[x][y][z]) return dp[x][y][z];
	vis[x][y][z]=true;
	db temp=(db)(n/((db)(x+y+z)));
	db sum=0.0;
	if(z>0) sum+=((db)z*calc(x,y+1,z-1)*1.0);
	if(y>0) sum+=((db)y*calc(x+1,y-1,z)*1.0);
	if(x>0) sum+=((db)x*calc(x-1,y,z)*1.0);
	temp+=(sum/((db)(x+y+z)));
	dp[x][y][z]=temp;
	return dp[x][y][z];
}

int main()
{
	cin >> n;
	ll x=0,y=0,z=0;
	for(ll i=0;i<n;i++)
	{
		ll temp;		cin >> temp;
		if(temp==1) x++; if(temp==2) y++; if(temp==3) z++;
	}
	vis[1][0][0]=true;
	dp[1][0][0]=(db)(n*1.0);
	
	ans=calc(x,y,z);
	
	cout << fixed << setprecision(15) << ans << endl;
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

int main()
{

    ll a, b, k;
    cin >> a >> b >> k;
    if(a >= k)
    {

        a-=k;
        k=0;
    }
    else
    {

        k-=a;
        a=0;
    }
    if(b >= k)
    {

        b-=k;
        k=0;
    }
    else b=0;
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main( String[] args ) {
        Scanner scanner = new Scanner(System.in);
        int balls = scanner.nextInt();
        int persons = scanner.nextInt();
        int temp = persons;
        while (temp-- > 0) {
            balls--;
        }

        if (balls > persons)
            System.out.println(0);
        else
            System.out.println(balls);
        //System.out.println("balls : " + balls + " Persons : " + persons);
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main{
	public static void main(String[] args) throws Exception{

		int a,b;
		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();
		b = sc.nextInt();

		if(a > b){
			System.out.println("a > b");
		}
		else if(a == b){
			System.out.println("a == b");
		}
		else if(a < b){
			System.out.println("a < b");
		}

	}
}

Measured memory_bytes: 26052
#include<stdio.h>

int main()
{
	int height[10];

	for (int i = 0; i < 10; ++i)
		scanf("%d", height + i);

	for (int i = 0; i < 3; ++i)
	{
		int j_max = i;
		for (int j = i + 1; j < 10; ++j)
			if (height[j] > height[j_max])
				j_max = j;
		if (j_max != i)
		{
			int tmp = height[j_max];
			height[j_max] = height[i];
			height[i] = tmp;
		}
	}

	for (int i = 0; i < 3; ++i)
		printf("%d\n", height[i]);

	return 0;
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

const int INF = 1e9;

void solve(istream& cin, ostream& cout) {
  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--, cw--, dh--, dw--;

  char field[h][w];
  int cnt[h][w];
  REP(i, h) REP(j, w) cin >> field[i][j];
  REP(i, h) REP(j, w) cnt[i][j] = INF;
  cnt[ch][cw] = 0;

  queue<int> q0, q1;
  q0.push(ch), q0.push(cw);

  while (!q0.empty() || !q1.empty()) {
    int nx, ny;
    if (!q0.empty()) {
      nx = q0.front(); q0.pop();
      ny = q0.front(); q0.pop();
    } else {
      nx = q1.front(); q1.pop();
      ny = q1.front(); q1.pop();
    }
    int now_cost = cnt[nx][ny];
    if (nx == dh && ny == dw) {
      cout << now_cost << endl;
      return;
    }

    REP(i, 4) {
      int nh = nx + dx[i];
      int nw = ny + dy[i];
      if (nh < 0 || nh >= h || nw < 0 || nw >= w) continue;
      if (field[nh][nw] == '#') continue;
      if (cnt[nh][nw] <= now_cost) continue;
      q0.push(nh), q0.push(nw);
      cnt[nh][nw] = now_cost;
    }

    FOR(dx, -2, 2) FOR(dy, -2, 2) {
      int nh = nx + dx;
      int nw = ny + dy;
      if (nh < 0 || nh >= h || nw < 0 || nw >= w) continue;
      if (field[nh][nw] == '#') continue;
      if (cnt[nh][nw] <= now_cost + 1) continue;
      q1.push(nh), q1.push(nw);
      cnt[nh][nw] = now_cost + 1;
    }
  }
  cout << -1 << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 8584