akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 202020;
vector<int> g[N];
int col[N];
vector<int> v[2];
void dfs (int cur, int par) {
  for (int child : g[cur]) if (child != par) {
    col[child] = col[cur] ^ 1;
    dfs (child, cur);
  }
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  fill(col, col + n, -1);
  col[0] = 0;
  dfs (0, -1);
  for (int i = 0; i < n; i++) v[col[i]].push_back(i);
  if ((int) v[0].size() < (int) v[1].size()) v[0].swap(v[1]);
  int cnt[] = {n / 3 + ((n % 3) > 0), n / 3 + ((n % 3) > 1), n / 3};
  vector<int> ans(n);
  for (int i = 0; i < n && v[0].size(); i += 3, v[0].pop_back()) {
    ans[v[0].back()] = i;
  }
  if ((int) v[0].size() >= cnt[1]) {
    for (int i = 1; i < n && v[0].size(); i += 3, v[0].pop_back()) {
      ans[v[0].back()] = i;
    }
  } else {
    for (int i = 1; i < n && v[1].size(); i += 3, v[1].pop_back()) {
      ans[v[1].back()] = i;
    }
  }
  for (int i = 2; i < n; i += 3) {
    if (v[1].size()) ans[v[1].back()] = i, v[1].pop_back();
    else ans[v[0].back()] = i, v[0].pop_back();
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << ans[i] + 1;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 19956
#include<stdio.h>
typedef long long ll;
int main()
{
	int num, p;
	scanf("%d%d", &num, &p);
	int c0 = 0, c1 = 0;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		if (z % 2 == 0)c0++;
		else c1++;
	}
	if (c1 == 0)
	{
		if (p == 0)printf("%lld\n", 1LL << num);
		else printf("0\n");
	}
	else printf("%lld\n", 1LL << (num - 1));
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        int tax8pricemin = (int)(((double)a) / 0.08);
        int tax8pricemax = (int)(((double)a + 1) / 0.08);

        for(int i = tax8pricemin ; i < tax8pricemax; i++){
            int tax8 = (int)(i * 0.08);
            int tax10 = (int)(i * 0.1);

            if(tax8 == a && tax10 == b){
                System.out.println(i);
                System.exit(0);
            }
        }
        System.out.println(-1);
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt,a[100010];
long long now,ans=1e18;
vector<int> v[100010],g[100010];
void add(int x)
{
	cnt+=v[x].size();
}
void del(int x)
{
	for (int i=0;i<g[x].size();i++)
	{
		int y=g[x][i];
		cnt--;
		int d=x-y;
		if (d<0)
		{
			d+=m;
		}
		now+=d-1;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i=0;i<n-1;i++)
	{
		v[a[i]].push_back(a[i+1]);
		g[a[i+1]].push_back(a[i]);
		if (a[i]>a[i+1])
		{
			cnt++;
			now+=a[i+1];
		}
		else
		{
			now+=a[i+1]-a[i];
		}
	}
	ans=now;
	for (int i=1;i<m;i++)
	{
		del(i);
		now-=cnt;
		ans=min(ans,now);
		//cout<<i+1<<" "<<cnt<<" "<<now<<endl;
		add(i);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    vector<ll> m(1,0);
    ll tc=1;
    ll d=2;
    while(tc<=1000000){
        m.emplace_back(tc);
        tc+=d;
        ++d;
    }
    //cout<<m.size()<<endl;
    ll n;
    cin>>n;
    int ans=0;
    ll t=n;
    for(ll i = 2;i*i <= n;++i) {
        if(t%i==0) {
            ll cnt=0;
            while(t%i==0){
                t/=i;
                ++cnt;
            }
            auto itl=lower_bound(m.begin(),m.end(),cnt);
            if(cnt!=*itl)--itl;
            ans+=itl-m.begin();
            //cerr<<ans<<endl;
        }
    }

    if(t!=1)++ans;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3656
s = raw_input()

if s[0] != 'A':
	print 'WA'
	quit()

ans = 0
for i in range(2,len(s)-1):
	if s[i] == 'C':
		ans += 1



if ans != 1:
	print 'WA'
	quit()

count = 0
for i in range(len(s)):
	if ord('a') <= ord(s[i]) <= ord('z') :
		count += 1

if count != len(s) - 2:
	print "WA"
	quit()

print "AC"

Measured memory_bytes: 2568
#include <stdio.h>

int n, arr[100010];
int max, min, sum[100010], max2, min2;

int abs(int n){
	return n>0 ? n:-n;
}

int main(){
	scanf("%d", &n);
	
	for(int i=1; i<=n; i++){
		scanf("%d", &arr[i]);
		sum[i] = sum[i-1] + abs(arr[i]-arr[i-1]);
	}
	
	sum[n+1] = sum[n] + abs(arr[n+1]-arr[n]);
	
	for(int i=1; i<=n; i++){
		printf("%d\n", sum[n+1] - abs(arr[i+1]-arr[i]) - abs(arr[i]-arr[i-1]) + abs(arr[i+1]-arr[i-1]));
	}
	
	return 0;
}


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


int main(){
  ll n;cin >> n;
  vector<ll> a(n*3);
  rep(i,n*3) cin >> a.at(i);
  sort(a.begin(),a.end());
  ll ans = 0;
  ll cnt = 0;
  for(ll i=3*n-2;i>0;i-=2){
    ans += a.at(i);
    ++cnt;
    if( cnt == n ) break;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5576
#include <stdio.h>
#include <stdlib.h>

#define zh(x,y) ((y)*1000+(x))

int go(int,int,int,int,int,int,char[1000][1001]);

int main(int argc,char* argv[]) {
	/*declare values*/
	int h,w;
	int n;
	char map[1000][1001];
	int factpos[10][2];
	int x,y;
	int i;
	int timesum;
	/*do work*/
	scanf("%d %d %d",&h,&w,&n);
	for(i=0;i<h;i++)scanf("%s",map[i]);
	for(x=0;x<w;x++) {
		for(y=0;y<h;y++) {
			if(map[y][x]=='S') {
				factpos[0][0]=x;
				factpos[0][1]=y;
			} else if(map[y][x]>='1' && map[y][x]<='9') {
				factpos[map[y][x]-'0'][0]=x;
				factpos[map[y][x]-'0'][1]=y;
			}
		}
	}
	timesum=0;
	for(i=0;i<n;i++) {
		timesum+=go(factpos[i][0],factpos[i][1],
			factpos[i+1][0],factpos[i+1][1],h,w,map);
	}
	printf("%d\n",timesum);
	return 0;
}

int go(int sx,int sy,int dx,int dy,int h,int w,char map[1000][1001]) {
	int *zikan;
	int *togox;
	int *togoy;
	int *nexttogox;
	int *nexttogoy;
	int *tempp;
	int togonum;
	int nexttogonum;
	int x,y;
	int saitan=0;
	int i;
	zikan=calloc(1000*1000,sizeof(int));
	zikan[zh(sx,sy)]=1;
	/*É²×é×«ê*/
	togox=calloc(1000*1000,sizeof(int));
	togoy=calloc(1000*1000,sizeof(int));
	togonum=1;
	togox[0]=sx;
	togoy[0]=sy;
	/*»ÌÉ²×é×«ê*/
	nexttogox=calloc(1000*1000,sizeof(int));
	nexttogoy=calloc(1000*1000,sizeof(int));
	while(saitan==0) {
		nexttogonum=0;
		/*»ê¼êÌs«æð²×é*/
		for(i=0;i<togonum;i++) {
			x=togox[i];y=togoy[i];
			if(map[y][x]=='X')continue;
			if(x==dx && y==dy) {
				saitan=zikan[zh(x,y)]-1;
				break;
			}
			if(x>0) {
				if(zikan[zh(x-1,y)]==0) {
					nexttogox[nexttogonum]=x-1;
					nexttogoy[nexttogonum]=y;
					nexttogonum++;
					zikan[zh(x-1,y)]=zikan[zh(x,y)]+1;
				}
			}
			if(y>0) {
				if(zikan[zh(x,y-1)]==0) {
					nexttogox[nexttogonum]=x;
					nexttogoy[nexttogonum]=y-1;
					nexttogonum++;
					zikan[zh(x,y-1)]=zikan[zh(x,y)]+1;
				}
			}
			if(x<w-1) {
				if(zikan[zh(x+1,y)]==0) {
					nexttogox[nexttogonum]=x+1;
					nexttogoy[nexttogonum]=y;
					nexttogonum++;
					zikan[zh(x+1,y)]=zikan[zh(x,y)]+1;
				}
			}
			if(y<h-1) {
				if(zikan[zh(x,y+1)]==0) {
					nexttogox[nexttogonum]=x;
					nexttogoy[nexttogonum]=y+1;
					nexttogonum++;
					zikan[zh(x,y+1)]=zikan[zh(x,y)]+1;
				}
			}
		}
		/*|C^ÌüêÖ¦*/
		tempp=togox;
		togox=nexttogox;
		nexttogox=tempp;
		tempp=togoy;
		togoy=nexttogoy;
		nexttogoy=tempp;
		togonum=nexttogonum;
	}
	free(togox);
	free(togoy);
	free(nexttogox);
	free(nexttogoy);
	free(zikan);
	return saitan;
}

Measured memory_bytes: 5312
#include<stdio.h>
int a[110];
int main()
{
    int n,sum=0,t;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        for(int j=n;j>=i+1;j--)
        {
            if(a[j]<a[j-1])
            {
                t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
                sum++;
            }
        }
    }
    printf("%d",a[1]);
    for(int k=2;k<=n;k++)
        printf(" %d",a[k]);
    printf("\n%d\n",sum);
    return 0;
}



Measured memory_bytes: 2676
def f(s):
    #print(len(s) != len(set(s)) or s[-1] >= 123)
    return len(s) != len(set(s)) or s[-1] >= 123


S = input()
if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit(0)
S_lis = list(map(ord, S))
#print(S_lis)

S_lis += [97]
#print(S_lis)
while f(S_lis):
    if S_lis[-1] == 123:
        S_lis.pop()
    S_lis[-1] += 1
print(''.join(map(chr, S_lis)))

Measured memory_bytes: 3064
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define each(i, ctn) for (auto &&i : (ctn))
#define all(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(12);*/ } } pre__;


int main() {
	int M;
	cin >> M;
	cout << 24 + (24 - M) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n; cin >> n;
  map<string,ll> mp;
  for(int i=0;i<n;i++){
    string s; cin >> s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  ll res=0;
  for(auto v : mp){
    if(v.second!=1)res+=v.second*(v.second-1)/2;
  }
  cout << res << endl;
}


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

int main(){
  
  long N,T,ans=0;
  cin>>N>>T;
  long t[N];
  rep(i,N)cin>>t[i];
  
  for(int i=1;i<N;i++){
    cin>>t[i];
        
    if(t[i]-t[i-1]>=T)ans+=T;
    else ans+=t[i]-t[i-1];
  
  
  }
  
  cout<<ans+T;

}

Measured memory_bytes: 1792
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1]=="A" and S[i]=="C":
        count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])

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

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    int sx, sy;
    cin >> sx >> sy;
    string s, t;
    cin >> s >> t;

    queue<char> T, A;
    for (int i = 0; i < N; i++) {
        T.push(s[i]);
        A.push(t[i]);
    }

    int x, y;
    queue<char> subT = T;
    queue<char> subA = A;
    // 上から
    x = sx, y = sy;
    for (int i = 0; i < 2 * N; i++) {
        if (i % 2 == 0) {
            if (T.front() == 'U') {
                x--;
            }
            T.pop();
        } else {
            if (A.front() == 'D' && x + 1 <= H) {
                x++;
            }
            A.pop();
        }
        if (x <= 0) {
            cout << "NO" << endl;
            return 0;
        }
    }

    // 下から
    x = sx, y = sy;
    T = subT;
    A = subA;
    for (int i = 0; i < 2 * N; i++) {
        if (i % 2 == 0) {
            if (T.front() == 'D') {
                x++;
            }
            T.pop();
        } else {
            if (A.front() == 'U' && x - 1 > 0) {
                x--;
            }
            A.pop();
        }
        if (x > H) {
            cout << "NO" << endl;
            return 0;
        }
    }

    // 左から
    x = sx, y = sy;
    T = subT;
    A = subA;
    for (int i = 0; i < 2 * N; i++) {
        if (i % 2 == 0) {
            if (T.front() == 'L') {
                y--;
            }
            T.pop();
        } else {
            if (A.front() == 'R' && y + 1 <= W) {
                y++;
            }
            A.pop();
        }
        if (y <= 0) {
            cout << "NO" << endl;
            return 0;
        }
    }

    // 右から
    x = sx, y = sy;
    T = subT;
    A = subA;
    for (int i = 0; i < 2 * N; i++) {
        if (i % 2 == 0) {
            if (T.front() == 'R') {
                y++;
            }
            T.pop();
        } else {
            if (A.front() == 'L' && y - 1 > 0) {
                y--;
            }
            A.pop();
        }
        if (y > W) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 1416
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  long long x;
  cin>>n>>x;
  vector<long long>lyr(n+1);
  vector<long long>p(n+1);
  p[0]=1;
  lyr[0]=1;
  for(int i=1;i<=n;i++)
  {
    p[i]=(2*p[i-1])+1;
    lyr[i]=(2*lyr[i-1])+3;
  }
  long long ans=0;
  long long l=1;
  long long r=lyr[n];
  long long mid=(l+r)/2;
  int level=n;
  while(l<r)
  {
    --level;
    if(x==mid)
    {
      ans+=p[level]+1;
      break;
    }
    else if(x==l)break;
    
    else if(x==r)
    {
      ans+=p[level+1];
      break;
    }
    
    else if(x>mid)
    {
      l=mid+1;
      r--;
      ans+=p[level]+1;
    }
    else if(x<mid)
    {
      r=mid-1;
      l++;
    }
    mid=(l+r)/2;
  }
  if(l==r)ans++;
  cout<<ans<<endl;
  return 0;
}
      
      
      
      

Measured memory_bytes: 3584
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

p = []
m = []
zero = 0
for i in range(N) :
  if A[i] > 0 :
    p.append(A[i])
  elif A[i] < 0 :
    m.append(-A[i])
  else :
    zero += 1

p.sort()
m.sort()

ng, ok = -(10 ** 18)-1, 10 ** 18+1
while ok - ng > 1 :
  mid = (ok + ng) // 2
  s = 0 
  if mid < 0 :
    j = 0
    for i in range(len(m) - 1, -1, -1) :
      while j < len(p) and m[i] * p[j] < -mid :
        j += 1
      s += len(p) - j
      
  else :
    j = len(p) - 1
    for i in range(len(p)) :
      while j >= 0 and p[i] * p[j] > mid :
        j -= 1
      s += max(0, j - i)
      
    j = len(m) - 1
    for i in range(len(m)) :
      while j >= 0 and m[i] * m[j] > mid :
        j -= 1
      s += max(0, j - i)
      
    s += (len(p) + len(m)) * zero + len(p) * len(m) + zero * (zero - 1) // 2

  if s < K :
    ng = mid
  else :
    ok = mid
    
print(ok)

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    ll n;
    cin >> n;
    vl a(n);
    rep(i, n) cin >> a[i];

    vl kane(n + 1, 0);
    vl kabu(n + 1, 0);
    vl amari(n + 1, 0);
    kane[0] = 1000;
    kabu[0] = 0;
    amari[0] = 0;

    repp(i, n) {
        rep(j, i) {
            umax(kane[i], kane[j]);
            umax(kane[i], kabu[j] * a[i - 1] + amari[j]);
        }
        kabu[i] = kane[i] / a[i - 1];
        amari[i] = kane[i] % a[i - 1];
    }

    prt(kane[n]);

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main(){

    string s;
    cin >> s;

    int length = 0;
    int lengthMax = 0;
    for(int i = 0; i <s.size(); i++){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T' ){
            length += 1;
        }
        else{
            if(length > lengthMax){
                lengthMax = length;
                length = 0;
            }
        }
    }

    if(length > lengthMax){
        lengthMax = length;
        length = 0;
    }

    cout << lengthMax << endl;


}

Measured memory_bytes: 256
import sys
from collections import deque
import copy
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    for i in range(N):
        if A[i] == 0:
            print(0)
            sys.exit()
    count = 1
    for i in range(N):
        count *= A[i]
        if count > 10 ** 18:
            print(-1)
            sys.exit()
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 22780
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int a = 0, b = 0, total = 0;
    
    scanf("%d %d %d", &a, &b, &total);

    if ((total-a) <= b && ((total - a) >= 0)) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
	int n,t;
	while(cin>>n,n){
		int c[10]={0};
		for(int i=0;i<n;i++)cin>>t,c[t]++;
		for(int i=0;i<10;i++){if(!c[i])cout<<'-';else for(int j=0;j<c[i];j++)cout<<'*';cout<<endl;}
	}
}

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

int n, A[200];

int main(){
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
        int count = 0;

        while(true){
            bool flag = false;

            for(int i = 0; i < n; i++){
                if(A[i] % 2 != 0){
                    flag = true;
                }
            }
                if(flag == true){
                    break;
                }
            
                for(int i = 0; i < n; i++){
                    A[i] /= 2;
                }
                count++;
        }
    cout << count << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

int main(){fastio
    ll h,w;cin>>h>>w;
    ll N=10;
    ll c[N][N];
    rep(i,0,N-1)rep(j,0,N-1)cin>>c[i][j];
    ll d[N];
    rep(sta,0,N-1){
        ll dis[N];rep(i,0,N-1)dis[i]=inf;
        dis[sta]=0;
        queue<ll>q;q.push(sta);
        while(!q.empty()){
            ll t=q.front();q.pop();
            rep(i,0,N-1){
                if(dis[t]+c[t][i]<dis[i]){
                    q.push(i);
                    dis[i]=dis[t]+c[t][i];
                }
            }
        }
        d[sta]=dis[1];
    }
    //rep(i,0,N-1)cout<<d[i]<<" ";cout<<endl;
    ll ans=0;
    rep(i,0,h*w-1){
        ll x;cin>>x;
        if(x==-1)continue;
        ans+=d[x];
        
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

LL dsum(LL n)
{
    LL res = 0;
    while(n!=0)
    {
        res += n%10;
        n /= 10;
    }
    return res;
}

LL snuke(LL n)
{
    priority_queue<pair<double,LL>, vector<pair<double,LL>>, greater<pair<double,LL>>> val;

    LL dig = 0; // 9が連続する下の桁

    while(LL(pow(10,dig)) <= n*100)
    {
        FOR(i,1,11)
        {
            LL v = max(n - n % LL(pow(10,dig+1)),0LL) + i * LL(pow(10,dig)) - 1;

            if(v >= n) val.push(make_pair(double(v)/dsum(v), v));
        }

        dig++;
    }

    LL ans = val.top().second;
    return ans;

}


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL K; cin>>K;
    LL pre = 1;
    REP(i,K)
    {
        cout << pre << endl;
        pre = snuke(pre+1);
    }



}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}


void solve(){
    int n;
    cin >> n;
    string S;
    cin >> S;
    int count = 0;
    int i = 0, j = n - 1;
    while(i < j){
        while(S[i] == 'R') i++;
        while(S[j] == 'W') j--;
        if( i > j) break;
        i++;
        j--;
        //swap
        count++;
    }
    cout << count << "\n";
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    solve();

    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = (1 << 30);

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<int>> dist(h, vector<int>(w, INF));
  vector<string> grid(h);
  int sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  sx--, sy--, gx--, gy--;
  rep(i, h) cin >> grid[i];
  dist[sx][sy] = 0;
  queue<P> que;
  que.push(P(sx, sy));
  while (!que.empty()){
    P p = que.front();
    que.pop();
    rep(i, 4){
      for (int j = 1; j <= k; j++){
        int nx = p.first + j * dx[i], ny = p.second + j * dy[i];
        if(nx < 0 || ny < 0 || nx >= h || ny >= w)break;
        if(grid[nx][ny] == '@')break;
        if(dist[nx][ny] <= dist[p.first][p.second])break;
        if(dist[nx][ny] != INF && dist[p.first][p.second] >= dist[nx][ny])break;
        if(dist[nx][ny] != INF)continue;
        dist[nx][ny] = dist[p.first][p.second] + 1;
        que.push(P(nx, ny));
      }
    }
  }
  if(dist[gx][gy] == INF){
    cout << -1 << endl;
  }else{
    cout << dist[gx][gy] << endl;
  }
}


Measured memory_bytes: 11164
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;
char map[12][6];
char color[5]={'R','G','B','Y','P'};
int d1[4]={0,1,0,-1};
int d2[4]={1,0,-1,0};
int flg,c,dep;
void swap(char *map1,char *map2){
	char t;
	t=*map1;
	*map1=*map2;
	*map2=t;
	return;
}
void fall(){
	int i,j,fl;	
	for(j=0;j<6;j++){
		while(1){	
			fl=0;
			for(i=11;i>0;i--){
				if(map[i][j]=='.'&&map[i-1][j]!='.'){
					swap(&map[i][j],&map[i-1][j]);fl=1;
				}
			}
			if(fl==0)break;
		}
	}
	return;
}
void dfs(char cl,int depth,int y,int x){
	int ny,nx;
	for(int i=0;i<4;i++){
		ny=y+d1[i];nx=x+d2[i];
		if(0<=ny&&ny<12&&0<=nx&&nx<6&&map[ny][nx]==cl){
			if(dep>=3){
				map[ny][nx]='@';dep++;
			}else{
				map[ny][nx]='#';dep++;
			}
			dfs(cl,depth+1,ny,nx);
		}
	}
	return;
}
void dfs2(int y,int x){
	int ny,nx;
	for(int i=0;i<4;i++){
		ny=y+d1[i];nx=x+d2[i];
		if(0<=ny&&ny<12&&0<=nx&&nx<6&&map[ny][nx]=='#'){
			map[ny][nx]='*';dfs2(ny,nx);
		}
	}
	return;
}
void vanish(char cl){
	int i,j,k;
	for(i=0;i<12;i++){
		for(j=0;j<6;j++){
			dep=0;
			if(map[i][j]==cl){
				dfs(cl,1,i,j);
			}
		}
	}
	for(i=0;i<12;i++){
		for(j=0;j<6;j++){
			if(map[i][j]=='@'){
				dfs2(i,j);
			}
		}
	}
	for(i=0;i<12;i++){
		for(j=0;j<6;j++){
			if(map[i][j]=='*'||map[i][j]=='@'){
				for(int k=0;k<4;k++){
					if(map[i+d1[k]][j+d2[k]]=='O'&&0<=i+d1[k]&&i+d1[k]<12&&0<=j+d2[k]&&j+d2[k]<6){
						map[i+d1[k]][j+d2[k]]='.';
					}
				}
				map[i][j]='.';flg=1;
			}else if(map[i][j]=='#'){
				map[i][j]=cl;
			}
		}
	}
}
int main(){
	int set;
	cin>>set;
	for(set;set>0;set--){
		c=0;
		for(int i=0;i<12;i++){
			cin>>map[i];
		}
		while(1){
			flg=0;
			for(int i=0;i<5;i++){
				vanish(color[i]);
			}
			fall();
			if(flg==0)break;
			c++;
		}
		cout<<c<<endl;
	}
    return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <climits>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int word[1000];
int memo[1000];
int w, h;

int solve(int pos){
  if(pos == h) return 0;
  if(memo[pos] != -1) return memo[pos];

  int ret = INT_MAX;
  for(int i = pos; i < h; i++){
    int ww = word[i];
    if(pos != 0) ww -= word[pos - 1];

    if(i == h - 1){
      ret = min(ret, max(0, ww - w));
    }else{
      ret = min(ret, std::abs(ww - w) + solve(i + 1));
    }
  }

  return memo[pos] = ret;
}

int main(){
  int cc = 1;

  while(true){
    h = getInt();
    w = getInt();

    if(h + w == 0) break;

    REP(i,h){
      word[i] = getInt();
      if(i != 0) word[i] += word[i - 1];
      memo[i] = -1;
    }

    printf("Case %d: %d\n", cc++, solve(0));
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int n;
    cin >> n;
    int m = __INT_MAX__;
    vint p(n);
    int ans =0;
    rep(i,n) {
        cin >> p[i];
        if(p[i]<m){
            m=p[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

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


int main() {
  int x, y, a, b, c; cin>>x>>y>>a>>b>>c;
  vector<long long> p(a), q(b), r(c);
  rep(i, a) cin>>p[i];
  rep(i, b) cin>>q[i];
  rep(i, c) cin>>r[i];

  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  sort(r.begin(), r.end());

  long long ans = 0;
  priority_queue<long long, vector<long long>, greater<long long>> que;
  RREP(i, a, a-x) que.push(p[i]);
  RREP(i, b, b-y) que.push(q[i]);
  int pos = c-1;
  while (pos >= 0) {
    long long t = que.top();
    if (t < r[pos]) {
      que.pop();
      que.push(r[pos]);
      --pos;
    } else {
      break;
    }
  }
  while (!que.empty()) {
    long long t = que.top();
    ans += t;
    que.pop();
  }
  print(ans);

  return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    int a[100003] = {};

    Scd(n);
    Rep(i,n){
        Scd(a[i]);
    }

    sort(a,a+n);

    int l = 0, r = n-1;
    ll ans1 = 0, ans2 = 0;
    int k[100003] = {};
    int to = 0;
    if( n % 2 ){
        k[0] = a[n/2];
        to++;
        while( to < n ){
            k[to++] = a[l++];
            if( to == n ) break;
            k[to++] = a[r--];
        }
        Repe(i,n,0){
            if( i == 0 ) continue;
            ans1 += abs(k[i]-k[i-1]);
        }
        to = 1;
        l = 0;
        r = n-1;
        while( to < n ){
            k[to++] = a[r--];
            if( to == n ) break;
            k[to++] = a[l++];
        }
        Repe(i,n,0){
            if( i == 0 ) continue;
            ans2 += abs(k[i]-k[i-1]);
        }
    }else{
        k[0] = a[n/2];
        k[n-1] = a[n/2-1];
        to = 1;
        while( to < n-1 ){
            k[to++] = a[l++];
            if( to == n-1 ) break;
            k[to++] = a[r--];
        }
        Repe(i,n,0){
            if( i == 0 ) continue;
            ans1 += abs(k[i]-k[i-1]);
        }
        to = 1;
        l = 0;
        r = n-1;
        while( to < n-1 ){
            k[to++] = a[r--];
            if( to == n-1 ) break;
            k[to++] = a[l++];
        }
        Repe(i,n,0){
            if( i == 0 ) continue;
            ans2 += abs(k[i]-k[i-1]);
        }
    }

    printf ("%llu\n", max(ans1, ans2) );

    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int main(void) {
  int n, i;
  scanf("%d", &n);
  printf("%d:", n);
  for(i = 2; i <= sqrt(n); ) {
    if(!(n % i)) {
      n /= i;
      printf(" %d", i);
    } else ++i;
  }
  printf(" %d\n", n);
  return 0;
}


Measured memory_bytes: 2752
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define minf -100000000000000
#define maxi 200005
ll n,height[maxi],tree[4*maxi],val[maxi];
void update(ll ptr,ll beg,ll last,ll ind,ll val)
{
	if(beg==last)
	{
		tree[ptr]=val;
		return;
	}
	ll mid=(beg+last)/2;
	if(ind<=mid)
		update(2*ptr+1,beg,mid,ind,val);
	else
		update(2*ptr+2,mid+1,last,ind,val);
	tree[ptr]=max(tree[2*ptr+1],tree[2*ptr+2]);
}
ll query(ll ptr,ll beg,ll last,ll l,ll r)
{
	if(beg>=l&&last<=r)
		return tree[ptr];
	if(beg>r||last<l)
		return 0;
	ll mid=(beg+last)/2;
	return max(query(2*ptr+1,beg,mid,l,r),query(2*ptr+2,mid+1,last,l,r));
}
int main()
{
    fastread;
    cin>>n;
    for(int i=0;i<n;i++)
    	cin>>height[i];
    for(int i=0;i<n;i++)
    	cin>>val[i];
    ll dp[n];
    memset(tree,0,sizeof(tree));
    dp[n-1]=val[n-1];
    ll ans=val[n-1];
    update(0,0,n-1,height[n-1],dp[n-1]);
    for(ll i=n-2;i>=0;i--)
    {
    	dp[i]=query(0,0,n-1,height[i],n-1)+val[i];
    	update(0,0,n-1,height[i],dp[i]);
    	ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11136
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N;
  std::cin >> N;

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

  std::vector<int> B = A;
  std::sort(B.begin(), B.end(), std::greater<int>());

  for (int i = 0; i < N; ++i) {
    if (A[i] == B[0])
      std::cout << B[1] << std::endl;
    else
      std::cout << B[0] << std::endl;
  }

  return 0;
}


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

int main() {
	int K, X;
	cin >> K >> X;

	int minPos = (X - (K-1));
	minPos = minPos<-1000000?-1000000:minPos;
	int maxPos = (X + (K-1));
	maxPos = maxPos>1000000?1000000:maxPos;

	for(int i=minPos; i<=maxPos; ++i){
		cout << i;
		if(i < maxPos){
			cout << " ";
		}
		if(i == (maxPos)){
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int, input().split()))

from itertools import combinations

cnt = 0
for i in combinations(L, 3):
    longest = max(i)
    rest = sum(i) - max(i)
    if longest < rest and i[0] != i[1] and i[0] != i[2] and i[1] != i[2] :
        cnt += 1
print(cnt)

Measured memory_bytes: 8912
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

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


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

int main()
{
    LL n,k;
    cin >> n >>k;
    int ans = 0;
    while(n)
    {
        ++ans;
        n/=k;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    
    int n,m;
    cin >> n;
    vector<int> p(n);
    rep(i,n)cin >> p[i];
    int cnt = 0;
    for(int i = 1;i<n-1;i++){
        int a = p[i-1];
        int b = p[i];
        int c = p[i+1];
        if((a < b && b < c )|| (c < b && b < a) )cnt++;
    }
    cout << cnt<< endl;
    

    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc132.contest.atcoder.jp/tasks/abc132_b

Measured memory_bytes: 256
from collections import deque

N = 100
n = 0
M = None
WHITE = 0
GRAY = 1
BLACK = 2
INF = float('inf')
d = None


def main():
    global n, M, d
    M = [[0 for _ in range(N)] for _ in range(N)]
    n = int(input())
    d = [INF for _ in range(n)]

    for _ in range(n):
        u, k, *v_s = map(int, input().split(' '))
        for j in range(k):
            M[u-1][v_s[j-1]-1] = 1

    bfs()

    for i in range(n):
        print('{} {}'.format(i+1, d[i] if d[i] != INF else -1))


def bfs():
    q = deque()
    q.appendleft(0)
    d[0] = 0

    while len(q) > 0:
        u = q.pop()
        for v in range(n):
            if M[u][v] == WHITE:
                continue
            if d[v] != INF:
                continue
            d[v] = GRAY
            d[v] = d[u] + 1
            q.appendleft(v)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		boolean[] flg = new boolean[26];
		String line = readLine();
		for (int i = 0; i < line.length(); i++) {
			int idx = (int) (line.charAt(i) - 'a');
			flg[idx] = true;
		}
		for (int i = 0; i < 26; i++) {
			if (!flg[i]) {
				pln((char) (i + 'a'));
				return;
			}
		}
		pln("None");
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 1000000007

int main(){
  string S;
  cin>>S;
  int N=S.size();
  vector<int> a(N);
  for(int i=0;i<N;i++){
    a.at(i)=S.at(i)-'0';
  }
  vector<vector<ll>> dp(N,vector<ll>(2,0));
  dp.at(0).at(0)=2;
  dp.at(0).at(1)=1;
  for(int i=1;i<N;i++){
    if(a.at(i)==1){
      dp.at(i).at(1)=dp.at(i-1).at(0)+3*dp.at(i-1).at(1);
      dp.at(i).at(0)=2*dp.at(i-1).at(0);
    }else{
      dp.at(i).at(1)=3*dp.at(i-1).at(1);
      dp.at(i).at(0)=dp.at(i-1).at(0);
    }
    dp.at(i).at(0)%=MOD;
    dp.at(i).at(1)%=MOD;
  }
  cout<<(dp.at(N-1).at(0)+dp.at(N-1).at(1))%MOD<<endl;
}


Measured memory_bytes: 6272
import java.util.Arrays;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	int [] in = new int[10];

        //input
        Scanner sc = new Scanner(System.in); //.useDelimiter(System.getProperty("line.separator"));

        for(int i=0;i<10;i++){
        	in[i]= sc.nextInt();
        }

        //calculation
        Arrays.sort(in);

        //output
        for(int i=9;i>6;i--){
        	System.out.println(in[i]);
        }
    }
}

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

int main() {
  int A,B;
  cin >> A >> B;
  if (A==B){
    cout<< 2*A <<endl;
  }
  else if(A>B){
    cout <<2*A-1 << endl;
  }
  else{
    cout << 2*B-1 << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    
	int S[3]={0};
	scanf("%d %d %d", &S[0], &S[1], &S[2]);
	for (int i=1; i<3; i++) {
		int j=i;
		do {
		if (S[j] > S[j-1]) {
			int temp =S[j];
			S[j] = S[j-1];
			S[j-1] = temp;
			j--;
	    }
		else break;
		}while (j>0);
	}
	int count =0;
	if (S[0]==S[1]==S[2]) count=0; 
	if (S[0]==S[1] && S[1]>S[2]) {
		do {
			S[2]+=2;
			count +=1;
		}while (S[1]>S[2]);
		if (S[2]-S[1]==1) count +=1;
		if (S[2]-S[1]==0) count +=0;
	
	}
	if (S[0]> S[1]&& S[1]==S[2]) {
	    do {
			S[2]+=1;
	    	S[1]+=1;
			count +=1;
		}while (S[2]!=S[0]);
	}
	if (S[0]> S[1]&& S[1]>S[2]) {
	    do {
			S[2]+=1;
	    	S[1]+=1;
			count +=1;
		}while (S[1]!=S[0]);
		do {
			S[2]+=2;
			count +=1;
		}while (S[1] > S[2]);
		if (S[2]-S[1]==0) count +=0;
		else count+=1; 
		
	}
	printf("%d", count);
    return(0);
}

Measured memory_bytes: 128