akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<(k) ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=(k) ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef jayinnn
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 100005;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];        
    }
    for(int i=0;i<n;i++){
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}

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

int main(){
	int n,i,j,k,a,b,c,cost[101][101];
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a>>b;
		for(j=1;j<=n;j++) cost[a][j] = 1<<15;
		for(j=0;j<b;j++){
			cin >> c;
			cost[a][c]=1;
		}
	}
	for(k=1;k<=n;k++)for(i=1;i<=n;i++)for(j=1;j<=n;j++)
		cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b>>c;
		if(cost[a][b]<c && cost[a][b]<(1<<15)) cout << cost[a][b]+1 << endl;
		else cout << "NA" << endl;
	}
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);
    int left = 1, right = n;
    rep(i, m) {
        int2(a, b);
        left = max(left, a);
        right = min(right, b);
    }

    cout << max(0ll, right - left + 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n, in, ans;
	int mintmp;

	ans = 1;
	cin >> n;
	cin >> mintmp;
	for (int i = 1; i < n; i++) {
		cin >> in;
		if (mintmp > in) {
			mintmp = in;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define str string
#define sonic ios_base::sync_with_stdio(0)
using namespace std;
ll a[1001];
int main(){
	sonic;
	ll n,cnt=0;
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++){
			cnt+=a[i]*a[j];
		}
	}
	cout<<cnt;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  ll N;cin>>N;
  vector<pair<ll,ll> > pairs(N);
  ll i,j,k,l;
  ll x,y,tmp=0;
  rep(i,N){
    cin>>pairs[i].first>>pairs[i].second;
  }
  sort(pairs.begin(), pairs.end());
  ll cnt;
  rep(i,N){
    for(j=i+1;j<N;j++){
      cnt=0;
      x=pairs[j].first-pairs[i].first;
      y=pairs[j].second-pairs[i].second;
      //cout<<x<<y<<endl;
      for(k=0;k<N;k++){
        for(l=k+1;l<N;l++){
          if(pairs[l].first-pairs[k].first==x and pairs[l].second-pairs[k].second==y){
            cnt++;
          }
        }
      }
      //cout<<cnt<<endl;
      tmp=max(cnt,tmp);
    }
  }
  ll ans=N-tmp;
  if(N==1) ans=1;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b,c,d; cin>>a>>b>>c>>d;
	int e=lcm(c,d);
	int n1=b/c-(a-1)/c;
	int n2=b/d-(a-1)/d;
	int n3=b/e-(a-1)/e;
	cout<<(b-a+1-n1-n2+n3)<<"\n";
	return 0;
}















Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b;
  char ch;
  while(1){
    scanf("%d",&a);
    getchar();
    ch = getchar();
    scanf("%d",&b);
    if(ch == '?'){
      break;
    }
    switch(ch){
    case '+':
      printf("%d\n",a + b);
      break;
    case '-':
      printf("%d\n",a - b);
      break;
    case '*':
      printf("%d\n",a * b);
      break;
    case '/':
      printf("%d\n",a / b);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1032
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
using namespace std;

int main()
{
    set<int> a,b,d;
    int c;
    int n;
    cin>>n;
    while(n--){
        cin>>c;
        a.insert(c);
    }
    cin>>n;
    while(n--){
        cin>>c;
        b.insert(c);
    }
    set<int>::iterator it=d.begin();
    set<int>::iterator it1=a.begin(),it2=a.end(),it3=b.begin(),it4=b.end();
    //set_union(it1,it2,it3,it4,it);
    set_intersection(it1,it2,it3,it4,inserter(d,d.begin()));
    for(it=d.begin();it!=d.end();it++){
        cout<<*it<<"\n";
    }
}





Measured memory_bytes: 23712
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main() {
	int X; cin >> X;
	if (X == 7 || X == 5 || X == 3) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    string s, t;
    cin >> s;
    t = "CODEFESTIVAL2016";

    int ans = 0;
    REP(i,s.length()){
        if (s[i] != t[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 764
import math
import sys

N = int(input())
A = list(map(int, input().split()))
if min(A) == 0:
    print(0)
else:
    k = 1
    flag = True
    for a in sorted(A, reverse=True):
        k *= a
        if k > math.pow(10, 18):
            print(-1)
            flag = False
            break

    if flag:
        print(k)

 

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++)
        if(s[i]=='-')
        ans--;
    else ans++;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
a = []
n.times do |i|
  a[i] = gets.chomp.split.map(&:to_i)
end

ans = 0
short = m
a.sort.each do |money, count|
  if count >= short
    ans += short * money
    break
  else
    ans += count * money
    short -= count
  end
end
p ans


Measured memory_bytes: 11128
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int n = ir.nextInt();
		int m = ir.nextInt();
		out.println(n <= 9 && m <= 9 ? n * m : -1);
	}

	public static void main(String[] args) {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}

	static void tr(Object... o) {
		out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep2D(l, r, n) \
	for (int __repeat_gap = 0; __repeat_gap < n; ++__repeat_gap) \
		for (l = 1, r = l + __repeat_gap; r <= n; ++l, ++r)
#define per2D(l, r, n) \
	for (int __repeat_gap = n - 1; __repeat_gap > 0; --__repeat_gap) \
		for (l = 1, r = l + __repeat_gap; r <= n; ++l, ++r)

typedef unsigned char u8;
const int N = 187;

int R, C;
int sum[N][N];
u8 ri[16][N][N][N], dn[16][N][N][N];
// right[k][r1][r2][c], down[k][c1][c2][r]

inline void up(u8 &x, const u8 y) {x < y ? x = y : 0;}
inline int S(int r1, int c1, int r2, int c2) {return sum[r2][c2] - sum[r2][c1 - 1] - sum[r1 - 1][c2] + sum[r1 - 1][c1 - 1];}

int main() {
	int i, j, r1, r2, c1, c2, cur, la, ans;
	char tmp[N]; u8 *f, *g;
	scanf("%d%d", &R, &C);
	for (i = 1; i <= R; ++i)
		for (scanf("%s", tmp + 1), j = 1; j <= C; ++j)
			sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + (tmp[j] & 1);
	rep2D(r1, r2, R) {
		f = ri[0][r1][r2], la = -1;
		for (j = C; j; --j, la = cur)
			cur = S(r1, j, r2, j), f[j] = (cur && cur != r2 - r1 + 1 ? j - 1 : cur == la ? f[j + 1] : j);
	}
	rep2D(c1, c2, C) {
		f = dn[0][c1][c2], la = -1;
		for (i = R; i; --i, la = cur)
			cur = S(i, c1, i, c2), f[i] = (cur && cur != c2 - c1 + 1 ? i - 1 : cur == la ? f[i + 1] : i);
	}
	// main_loop
	for (ans = 0; ans < 15 && ri[ans][1][R][1] < C; ) {
		rep2D(r1, r2, R) {
			f = ri[ans][r1][r2], g = ri[ans + 1][r1][r2];
			for (j = 1; j <= C; ++j) up(g[j], f[j] == C ? C : f[f[j] + 1]), up(dn[ans + 1][j][g[j]][r1], r2);
		}
		rep2D(c1, c2, C) {
			f = dn[ans][c1][c2], g = dn[ans + 1][c1][c2];
			for (i = 1; i <= R; ++i) up(g[i], f[i] == R ? R : f[f[i] + 1]), up(ri[ans + 1][i][g[i]][c1], c2);
		}
		++ans;
		per2D(r1, r2, R)
			for (j = 1; j <= C; ++j)
				up(ri[ans][r1][r2 - 1][j], ri[ans][r1][r2][j]), up(ri[ans][r1 + 1][r2][j], ri[ans][r1][r2][j]);
		per2D(c1, c2, C)
			for (i = 1; i <= R; ++i)
				up(dn[ans][c1][c2 - 1][i], dn[ans][c1][c2][i]), up(dn[ans][c1 + 1][c2][i], dn[ans][c1][c2][i]);
	}
	ans += ri[ans][1][R][1] < C, printf("%d\n", ans);
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fo(i, n) for(int i = 1; i <= n; ++i)
#define rep(i, a, b) for(int (i) = (a); (i) < (b); ++(i))

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 200200;
const int mod = 1e9 + 7;
const ll INF = 1e18;

int n,m,Q;
vector<int> g[N];
int ans[N];
int was[N][11];
int u,v;
int st[N], dist[N], col[N];
int used[N][11];
deque< pair<int, pii > > q;


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

	cin>>n>>m;
	fo(i,m)
	{
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
	}
	cin>>Q;
	fo(i,Q)
	{
		cin>>st[i]>>dist[i]>>col[i];
		q.push_front(mp(st[i], mp(dist[i], col[i])));
	}
	while(!q.empty())
	{
		auto x=q.front();
		q.pop_front();
		int v=x.F, d=x.S.F, c=x.S.S;
		if(used[v][d])
			continue;
		if(!ans[v]) ans[v]=c;
		used[v][d]=1;
		if(d==0) continue;
		for(int to:g[x.F])
		{
			if(!used[to][d-1]&&!was[to][d-1])
			{
				was[to][d-1]=1;
				q.push_front(mp(to,mp(d-1,c)));	
			}
		}
	}
	for(int i=1;i<=n;++i)
		cout<<ans[i]<<'\n';
	return 0;	
}

Measured memory_bytes: 30712
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int[] arr = {A, B, A + B};
    
    for (int num : arr) {
      if (isPass(num)) {
        System.out.println("Possible");
        return;
      }
    }

    System.out.println("Impossible");
  }

  static boolean isPass(int num) {
    return (num >=3 && num % 3 == 0) ;
  }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll gcd (ll a,ll b){
    return b ? gcd(b,a%b) : a;
}
main(){
    int N;
    cin >> N;
    vector<int> V(N),left(N),right(N);
    rep(i,0,N)cin >> V[i];
    left[0] = V[0];
    right[N-1] = V[N-1];
    rep(i,1,N)left[i] = gcd(left[i-1], V[i]);
    for(int i = N-2;i >= 0;i--)right[i] = gcd(right[i+1], V[i]);
    ll ans = 0;
    rep(i,0,N){
        ll num = gcd(i==0?0:left[i-1], i==N-1?0:right[i+1]);
        ans = max(ans,num);
    }
    cout << ans << endl;
}

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

int main(){
  int n;
  int sum;
  cin >> sum >> n;
  int max = 0;
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    if(max < num) max = num;
  }
  sum -= max;
  if(max-1>sum){
    cout << max-1-sum << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int main(){
  ll n,m;
  cin>>n>>m;
  ll a,b;
  vector<ll> h(n+1);
  rep2(i,1,n+1) cin>>h[i];
  vector<pair<ll,ll>> p(m);
  rep(i,m){
    cin>>a>>b;
   p[i]=mk(a,b);
  }
vector<int> count(n+1);
  rep2(i,1,n+1) count[i]++;
  rep(i,m){
    if(h[p[i].first]==h[p[i].second]){
      count[p[i].first]--;
      count[p[i].second]--;
    }
   if(h[p[i].first]>h[p[i].second]) count[p[i].second]--;
   if(h[p[i].first]<h[p[i].second]) count[p[i].first]--;
  }  
  ll ans=0;
  rep2(i,1,n+1){
    if(count[i]>=1) ans++;
  }
  cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 5816
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#define int long long
using namespace std;
int N;
int pos[200100];
int bef[200100];
int arr[200100];
int a[200100];
vector<int>li[200100];
vector<int>p;
void dfs(int n,int pa)
{
	int i;
	pos[n] = lower_bound(p.begin(), p.end(), a[n])-p.begin();
	if (pos[n] < p.size())
	{
		bef[n] = p[pos[n]];
		p[pos[n]] = a[n];
	}
	else
		p.push_back(a[n]);
	arr[n] = p.size();
	for (i = 0; i < li[n].size(); i++)
	{
		if (li[n][i] == pa)
			continue;
		dfs(li[n][i], n);
	}
	if (bef[n])
	{
		p[pos[n]] = bef[n];
	}
	else
		p.pop_back();
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin >> N;
	int i;
	for (i = 1; i <= N; i++)
		cin >> a[i];
	for (i = 1; i < N; i++)
	{
		int a, b;
		cin >> a >> b;
		li[a].push_back(b);
		li[b].push_back(a);
	}
	dfs(1, 0);
	for (i = 1; i <= N; i++)
	{
		cout << arr[i]<<'\n';
	}
}

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

using namespace std;

vector<int> h(100005), dp(100005, -1);

long long int solve(int n)
{
    if(dp[n] != -1)
        return(dp[n]);
    if(n == 1)
        return(dp[n] = 0);
    if(n == 2)
        return(dp[n] = solve(n-1)+abs(h[n]-h[n-1]));
    if(n == 3)
        return(dp[n] = solve(n-2)+abs(h[n]-h[n-2]));
    return(dp[n] = min(solve(n-1) + abs(h[n]-h[n-1]), solve(n-2) + abs(h[n]-h[n-2])));
}

int main()
{
    int n;
    long long int ans;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> h[i];
    ans = solve(n);
    cout << ans << endl;
    return(0);
}

Measured memory_bytes: 3328
def resolve():
    N, M = list(map(int, input().split()))
    AB = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[0])
    #print(AB)
    import heapq
    cands = []
    abidx = 0
    ans = 0
    day = M
    while day > 0:
        #print(abidx)
        while abidx < N and AB[abidx][0] <= M-day+1:
            _, point = AB[abidx]
            heapq.heappush(cands, -point)
            abidx += 1
        if len(cands) > 0:
            ans += heapq.heappop(cands)
            #print(-ans)
        day -= 1
    print(-ans)


if '__main__' == __name__:
    resolve()

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int X,Y;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X>>Y;
	if(X+Y==15) cout<<"+"<<endl;
	else if(X*Y==15) cout<<"*"<<endl;
	else cout<<"x"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 512
def main():
    a, b, c = map(int, input().split())
    total = a + b + c
    sa =  max(a, b, c) * 3 - total

    if sa % 2 == 0:
        print(sa // 2)
    else:
        print(sa // 2 + 2)
        




if __name__ == "__main__":
    main()

Measured memory_bytes: 61620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC053A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x=int.Parse(Console.ReadLine());
            string s;
            if ( 1<=x && x<1200)
            {
                s = "ABC";
            }
            else
            {
                s = "ARC";
            }
            Console.WriteLine(s);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.math;

void main(){

    real[4] x;
    real[4] y;
    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	auto s1 = split(chomp(s),',');
	for(int i=0;i<4;i++) x[i] = to!real(s1[2*i]);
	for(int i=0;i<4;i++) y[i] = to!real(s1[2*i+1]);
	bool flg = true;
	bool u,u1;
	if(x[1] - x[3] == 0){
	    u = (x[1] - x[0]) * (x[1] - x[2]) > 0;

	}else {
	    real m = (y[1] - y[3] ) / (x[1] - x[3]);
	    u = (y[2] - m * (x[2] - x[1]) - y[1] ) * (y[0] - m * (x[0] - x[1]) - y[1] )> 0 ;
	}
	if(x[2] - x[0] == 0){
	    u1 = (x[2] - x[1]) * (x[2] - x[3]) > 0;
	}else {
	    real m = (y[0] - y[2] ) / (x[0] - x[2]);
	    u1 = (y[3] - m * (x[3] - x[2]) - y[2] ) * (y[1] - m * (x[1] - x[2]) - y[2] )> 0 ;
	}
	flg = (u1 != u);
	if(!flg) writeln("YES");
	else writeln("NO");
    }
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_V = 1000, MAX_N = 100;
int N,W;
ll dp[2][MAX_V*MAX_N+1]; // dp[_][v]: 価値vであるような最小の重さ

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> N >> W;

  forn(i,2) fill_n(dp[i],MAX_V*N+1,LLONG_MAX);
  dp[0][0] = 0;

  forn(i,N) {
    int w,v;
    cin >> w >> v;
    for (int j = 0; j <= MAX_V*N; j++) {
      chmin(dp[1-i&1][j],dp[i&1][j]);
      if (dp[i&1][j] < INT_MAX && j+v <= MAX_V*N) {
        chmin(dp[1-i&1][j+v], dp[i&1][j]+w);
      }
    }
  }

  for (int i = MAX_V*N; i >= 0; i--) {
    if (dp[N&1][i] <= W) {
      cout << i << endl;
      return 0;
    }
  }


  return 0;
}


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

def main():
  r = int(read())
  print(r**2)
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5588
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>

using namespace std;

#include <bits/stdc++.h>

using namespace std;

class DKnapsack1 {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int n, w;
        cin >> n >> w;
        vector<vector<int>> wv_vec(n, vector<int>(2, 0));
        for (int i = 0; i < n; ++i) {
            cin >> wv_vec[i][0];
            cin >> wv_vec[i][1];
        }
        vector<vector<long long>> dp(n + 1, vector<long long>(w + 1, 0));
        dp[0][0] = 0;
        for (int i = 0; i < n; ++i) {
            long long now_w = wv_vec[i][0];
            long long now_v = wv_vec[i][1];
            for (int j = 0; j < w+1; ++j) {
                if (j >= now_w)dp[i + 1][j] = max(dp[i][j - now_w] + now_v, dp[i][j]);
                else dp[i + 1][j] = dp[i][j];
            }
        }
        long long ans = *max_element(dp[n].begin(), dp[n].end());
        cout << ans << endl;
    }
};


int main() {
    DKnapsack1 solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 80256
#include <cstdio>
#include <iostream>
#include <string>
#define N 10000001
using namespace std;

int main(){
  int i,j,n;
  bool a[N];
  for(i=2;i<N;i++) a[i] = 1;
  for(i=2;i*2<=N;i++){
    if(a[i] == 1){
      for(j=i*2;j<=N;j+=i) a[j] = 0;
    }
  }

  while(1){
    cin >> n;
    if(n == 0) break;

    int ans = 0;
    for(i=n;i>=13;i--){
      if(a[i] == 1 && a[i-2] == 1 && a[i-6] == 1 && a[i-8] == 1){
	ans = i;
	break;
      }
    }

    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 10000
#include <stdio.h>
int main()
{
  int N;
  int i,q,count,max = 0,ans;
  
  scanf("%d",&N);
  for(i = N; i > N/2; i--)
  {
    q = i;
    while(q % 2 == 0)
    {
      q = q/2;
      count++;
    }
    if(max < count)
    {
      max = count;
      ans = i;
    }
    count = 0;
  }
  if(N == 1)
    ans = 1;
  printf("%d\n",ans);
    
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
  ll N,K; cin >> N >> K;
  ll num_of_nK;
  num_of_nK = (N/K) * (N/K) * (N/K);

  ll num_of_halfK = 0;
  if(K % 2 == 0){
    for(ll i = K/2;i <= N;i+=K){
      num_of_halfK++;
    }
  }

  num_of_halfK = num_of_halfK * num_of_halfK * num_of_halfK;
  ll ans = num_of_nK + num_of_halfK;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define LL long long 
#define LD long double
#define PI 3.14159265358979323846
#define MOD ((LL)1e9+7)
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;




	
int32_t main()
{
	int n,k;cin>>n>>k;
	string s;cin>>s;
	vector<int>Z(100011),O(100011);
	int i=0,c=0,t0=1,t1=1;
	while(i<n)
	{
		c=0;
		while(i<n && s[i]=='1'){i++;c++;}O[t1++]=c;
		c=0;
		while(i<n && s[i]=='0'){i++;c++;}Z[t0++]=c;
	}
	for(int i=1;i<=100010;i++)
	{
		Z[i]+=Z[i-1];
		O[i]+=O[i-1];
	}
	int ans=0;
	
	for(int i=0;i<=100011-k;i++)
	{
		int l,r;l=i;
		
		if(k+i+1<=100010)r=k+i+1;
		else r=min(k+i,100010LL);
		
		ans=max(Z[min(i+k,100010LL)]-Z[i] + O[r]-O[l] ,ans);
	}
	
	cout<<ans<<endl;
		
			
}
				
				   
	

	


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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr <<">>>>>>"<< #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif


int main()
{
	
	string s;
	cin>>s;
	cout<<(max(0,1+(int)s.find_last_of('Z')-(int)s.find_first_of('A')))<<endl;
	
}



Measured memory_bytes: 3708
using System;

namespace _3_B {
    class Program {
        static void Main (string[] args) {
            for (var i = 0;; ++i) {
                var input = Console.ReadLine ();
                if (input == null || input == "0") {
                    break;
                }
                Console.WriteLine ($"Case {i+1}: {input}");
            }
        }
    }
}


Measured memory_bytes: 17912
import math
N=1000000
prime=[1]*(N+1)
prime[0]=0
prime[1]=0
for i in range(2,int(math.sqrt(N))):
    if prime[i]==1:
        j=i
        while i*j<=N:
            prime[i*j]=0
            j+=1
prime=set([i for i in range(N+1) if prime[i]==1])

while True:
    a,d,n=map(int,raw_input().split())
    if a==d==n==0:break
    while n>0:
        if a in prime:
            n-=1
        a+=d
    print a-d

Measured memory_bytes: 44704
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define double long double
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353  
#define pi 3.14159265358979323846 

int solve(){
    int n,k,m=0,s=0;
    cin>>k>>n;
    int a[n];
    rep(i,0,n){
        cin>>a[i];
        if(i>0)s=s+a[i]-a[i-1];m=max(m,a[i]-a[i-1]);
    }
    s=s+k-a[n-1]+a[0];
    m=max(m,k+a[0]-a[n-1]);
    cout<<s-m;
    return 0;
}   
     
signed main(){
    IOS;
   // freopen("input.txt", "r" , stdin);
    //freopen("output4.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
      // cout<<" * "<<t<<"\n";
    }
//    return 0;
} 

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

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

  if(n==1){
    cout << 1 << endl;
  }else if(1<n &&n<4){
    cout << 2 <<endl;
  }else if(4<=n && n<8){
    cout << 4 << endl;
  }else if(8<=n && n<16){
    cout << 8 << endl;
  }else if(16<=n && n<32){
    cout << 16 << endl;
  }else if(32<=n && n<64){
    cout << 32 << endl;
  }else if(64<=n && n<101){
    cout << 64 << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        for(int i=0;i<n;i++){
            A[i] = scan.nextInt();
        }
        int count = 0;
        boolean flag = true;
        while(flag){
            flag = false;
            for(int i=n-1;i>=1;i--){
                if(A[i] < A[i-1]){
                    count++;
                    // 要素の交換
                    int tmp = A[i];
                    A[i] = A[i-1];
                    A[i-1] = tmp;
                    flag = true;
                }
            }
        }
        printArray(A, n);
        System.out.println(count);
    }

    // スペース区切りで表示
    public static void printArray(int A[], int n){
        int i;
        for(i=0;i<n-1;i++){
            System.out.print(A[i] + " ");
        }
        System.out.println(A[i]);
    }
}

Measured memory_bytes: 19296
def main():
    op = '+-'
    s = input()

    for x in op:
        for y in op:
            for z in op:
                t = s[0] + x + s[1] + y + s[2] + z + s[3]
                if eval(t) == 7:
                    return t + '=7'

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;
const int maxn = 2000 + 5;
const ll oo = 0x3f3f3f3f3f3f3f3f;
int N, M;
ll d1, d2;

int main()
{
	while (cin >> N >> M)
	{
		vector<int>a(M);
		vector<int>b(M);
		vector<ll>c(M);
		for (int i = 0; i < M; i++)
		{
			cin >> a[i] >> b[i] >> c[i];
			a[i]--,	b[i]--;
		}
		vector<ll>d(N, -oo);
		d[0] = 0LL;
		for (int i = 0; i < 2 * N; i++)
		{
			for (int j = 0; j < M; j++)
			{
				d[b[j]] = max(d[b[j]], d[a[j]] + c[j]);
			}
			if (i == N - 1)
				d1 = d[N - 1];
			if (i == 2 * N - 1)
				d2 = d[N - 1];
		}
		if (d1 == d2)
			cout << d1 << endl;
		else
			cout << "inf" << endl;
	}
	return 0;
}

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

int s[100005];

int main()
{
   	int n;
   	cin >>n;
   	
	for(int i = 0; i <= n; i++){
		cin >> s[i];
	}
 	long long sum = 0;
 	long long x;
 	for(int i = 0; i < n; i++){
 		cin >> x;
		if(x>=s[i]+s[i+1]){
			
			sum = sum+(s[i]+s[i+1]);
			s[i] = 0;
			s[i+1] = 0;
		}	
		else{
			sum = sum+x;
			if(x>s[i]){
				s[i+1] = s[i+1]-x+s[i];
			}
		}
	}
	printf("%lld", sum);
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//dp[i][j] = sum_0->A[i](dp[i-1][j-k])

int main() {
	io_init;
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	vector<vector<ll>> dp(N + 1, vector<ll>(K + 1, 0)), sum(N + 1, vector<ll>(K + 2, 0));
	dp[0][0] = 1;
	for (int j = 0; j <= K; j++) {
		sum[0][j + 1] = sum[0][j] + dp[0][j];
	}
	for (int i = 1; i <= N; i++){
		for (int j = 0; j <= K; j++) {
			dp[i][j] = (sum[i - 1][j + 1] - sum[i - 1][max(0, j - A[i - 1])]) % MOD;
		}
		for (int j = 0; j <= K; j++) {
			sum[i][j + 1] = sum[i][j] + dp[i][j];
		}
	}
	cout << dp[N][K] << endl;
}


Measured memory_bytes: 159088
#dfs試す
n,m,q=map(int, input().split( ))
qs=tuple(tuple(map(int, input().split( ))) for _ in range(q))
ans=0
def dfs(ll):
    global ans
    if len(ll)==n+1:
        sm=0
        for ai,bi,ci,di in qs:
            if ll[bi]-ll[ai]==ci:
                sm+=di 
        ans=max(ans,sm)
    else:
        for i in range(ll[-1],m):#+1
            ll2=ll+[i]
            dfs(ll2)
l=[0]
dfs(l)
print(ans)

Measured memory_bytes: 73096
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

int main(){
	int n;	
	while(~scanf("%d",&n)){	
		if(n==0) break;
		priority_queue<P> que;
		for(int i=0;i<n;i++){
			int p,d1,d2;
			scanf("%d %d %d",&p,&d1,&d2);
			que.push(P(d1+d2,p));
		}

		printf("%d %d\n",que.top().second,que.top().first);
	}
}

Measured memory_bytes: 3328
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

short_sum = 0
exceed_diffs = []
count = 0

for i in range(0, N):
    diff = A[i] - B[i]
    if diff < 0:
        short_sum += -diff
        count += 1
    elif diff > 0:
        exceed_diffs.append(diff)

exceed_diffs.sort(reverse = True)

for diff in exceed_diffs:
    if short_sum <= 0:
        break

    short_sum -= diff
    count += 1

if short_sum > 0:
    print(-1)
else:
    print(count)



Measured memory_bytes: 18492
# 最大公約数を返す
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
 
# 最小公倍数を返す
def lcm(a, b):
    return a * b // gcd(a, b)

N,M = map(int,input().split())
L = list(map(int,input().split()))

# ループを回しながら最小公倍数を計算していく
# 与えられたN個の偶数はすべて２で割っていく
leastCommonMultiple = L[0] // 2
for i in range(N):
    L[i] //= 2
    leastCommonMultiple = lcm(leastCommonMultiple, L[i])

# フラグ
c = 0

# Lに格納されているＮ個の数に含まれる素因数２の数が同じかどうかチェックする
while True:

    for i in range(N):
        # ２で割り切れない場合
        # L[i]に含まれている数すべてが２で割り切れないならＯＫ
        if L[i] % 2 == 1:
            c += 1
        # ２で割り切れるなら、２で割った数で上書き
        else:
            L[i] //= 2

    if not c == 0:
        break


if c == N:
    print( ((M // leastCommonMultiple) + 1) // 2 )
else:
    print(0)

Measured memory_bytes: 14400
#include <iostream>
using namespace std;
int main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(b-a<=0){
    cout<<"delicious"<<endl;
  }else if(b-a-x<=0){
    cout<<"safe"<<endl;
  }else{
    cout<<"dangerous"<<endl;
  }

  return 0;
}


Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2237&lang=jp
typedef long long ll;
const int INF = 1e9;
int M, N;
double p[16][16];
double dp[16][1 << 16];
double solve(int n, int bit) {
	if (n == N) return 1;
	double& ret = dp[n][bit];
	if (ret != -1)return ret;
	ret = 0;
	for (int i = 0; i < M;i++) {
		if (bit&(1 << i)) continue;
		double temp = 0, temp_p = 1;
		for (int j = n; j < N;j++) {
			temp += temp_p*(1 - p[i][j])*solve(j, bit | (1 << i));
			temp_p *= p[i][j];
		}
		temp += temp_p;
		ret = max(ret, temp);
	}
	return ret;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	cin >> M >> N;
	for (int i = 0; i < M;i++) for (int j = 0; j < N;j++) cin >> p[i][j];
	fill(dp[0], dp[16], -1);
	cout << fixed << setprecision(10)<< solve(0, 0) << endl;
	return 0;
}

Measured memory_bytes: 11480
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vvi a(n, vi(n - 1));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n - 1; ++j) {
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    vi idx(n, 0);
    // vi to_ch(n, 0);
    // iota(to_ch.begin(), to_ch.end(), 0);
    set<int> to_check;
    for (int i = 0; i < n; ++i) {
        to_check.insert(i);
    }
    int days = 0;
    int used = 0;
    while (used < n * (n - 1)) {
        days++;
        set<int> temp;
        for (auto &aidx : to_check) {
            if (idx[aidx] >= n - 1 || idx[a[aidx][idx[aidx]]] >= n - 1)
                continue;
            int tag = a[aidx][idx[aidx]];
            if (a[tag][idx[tag]] == aidx && temp.count(aidx) == 0) {
                // idx[aidx]++;
                // idx[tag]++;
                temp.insert(aidx);
                temp.insert(tag);
                used += 2;
            }
        }
        if (temp.size() == 0) {
            cout << -1 << "\n";
            return 0;
        } else {
            for (auto &t : temp) {
                idx[t]++;
            }
            to_check = temp;
        }
    }
    cout << days << "\n";
    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    
    rep(i,s.length()){
        if(s[i+1]==s[i]){
            s.erase(i,1);
          	i--;
        }
    }
    
   
     cout << s.length() <<endl;
   
    
    return 0;
    
}


















































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

int main(){
  int A,B;
  cin>>A>>B;
  int s=1;
  int c=0;
  while(1){
    if(s>=B){
      break;
    }
    s=s+A-1;
    c++;
  }
  cout<<c<<endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int ret = -1;

    for (int n = 9; n < 1010; n++) {
        if(floor((double)n * (double)0.08) == (double)a) {
            if(floor((double)n * (double)0.10) == (double)b) {
                ret = n;
                break;
            }
        }
    }

    cout << ret << endl;
}

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

using namespace std;

int check(int P, int N[], int n, int k) {

	int i = 0;
	for (int j = 0; j < k; ++j) {
		int w = 0;
		while (w + N[i] <= P) {
			w += N[i];
			++i;
			if (i == n)
				return n;
		}
	}
	return i;
}

int main() {

	int n, k;
	scanf("%d %d", &n, &k);

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

	int left = 0;
	int right = 1000000000;
	while (left < right) {
		int mid = (left + right) / 2;
		if (check(mid, N, n, k) == n) {
			right = mid;
		} else {
			left = mid + 1;
		}
	}
	cout << right << endl;

	return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<long long>;
using ld = long double;

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  int n;
  cin >> n;
  vi nums(n);
  map<int, int> cnts;
  for (int &x : nums) { cin >> x; ++cnts[x]; }

  bool ans = false;

  if (SZ(cnts) == 1) {
    ans = cnts.count(0);
  } else if (n % 3 != 0) {
    ans = false;
  } else {
    vi someans(n);
    someans[0] = nums[0];
    int ptr = 1;
    while (nums[ptr] == nums[0]) { ++ptr; }
    someans[1] = nums[ptr];

    for (int i = 2; i < n; ++i) {
      someans[i] = someans[i - 2] ^ someans[i - 1];
    }

    map<int, int> ocnts;
    for (int x : someans) { ++ocnts[x]; }
    ans = (cnts == ocnts);
  }

  cout << (ans ? "Yes\n" : "No\n");
}



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

int main() {
	int N,A;
	cin >> N;
	int j,k;
	k = 10000000;
	for (int i = 0; i < N - 1; i++) {
		cin >> A;
		j = 0;
		while (A % 2 == 0) {
			j++;
			A /= 2;
		}
		if (k > j) {
			k = j;
		}
	}
	cout << k << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main() {
  long tableau[100001] = {0};
  long altitude[100001];
  long n, m, a, b;
  scanf("%ld%ld", &n, &m);
  for (long i = 1; i <= n; i ++)
    scanf("%ld", &altitude[i]);
  for (long x = 1; x <= m; x ++) {
    scanf("%ld%ld", &a, &b);
    if (altitude[a] > altitude[b])
      tableau[b] = 1;
    else if (altitude[b] > altitude[a])
      tableau[a] = 1;
    else {
      tableau[a] = 1;
      tableau[b] = 1;
    }
  }
  long compteur = 0;
  for (long l = 1; l <= n; l ++) {
      if (tableau[l] == 0){
      	compteur ++;
      }
  }
  printf("%ld\n", compteur);
  return 0;
}

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

int main(){
	int A,B,C,X,Y; cin>>A>>B>>C>>X>>Y;
	int min=2000000000;
  	int p;
	for(int i=0;i<=max(X,Y)*2;i+=2){
		p=C*i;
		p+=max(0,X-i/2)*A;
		p+=max(0,Y-i/2)*B;
		if(p<min)min=p;
	}
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(){
  int A[N];
  int i,n,flag,x,count=0,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  j = 0;
  flag = 1;
  while(flag){
    flag = 0;
    for(i=n-1;i>=j+1;i--){
      if(A[i]<A[i-1]){
	x = A[i];
	A[i] = A[i-1];
	A[i-1] = x;
	flag = 1;
	count++;
      }
    }
    j++;
  }
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d",A[n-1]);
  printf("\n");
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2072
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        long N = cin.Long();
        long K = cin.Long();

        if(K % 2 != 0) {
            Console.WriteLine((N / K) * (N / K) * (N / K));
        }
        else {
            long num = N / (K / 2) - N / K;
            Console.WriteLine((N / K) * (N / K) * (N / K) + num * num * num);
        }
        Console.ReadLine();
    }
}

Measured memory_bytes: 11092