akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
x1 = 0
x1 = sum(a)-sum(a[1::2])*2
x = []
x.append(x1)
for i in range(n-1):
	xx = a[i]*2 - x[-1]
	x.append(xx)
print (*x)

Measured memory_bytes: 14092
n = gets.to_i
as = gets.split.map(&:to_i)

x = as.count(&:odd?)
y = as.count { |a| a % 4 == 0 }
z = n - x - y

if z == 0
  puts x <= y + 1 ? "Yes" : "No"
else
  puts x <= y ? "Yes" : "No"
end


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

const int maxn = 1e5+5;
int n, ans[maxn];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int ai; cin >> ai;
        ans[ai] = i;
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << ' ';
    }
    cout << '\n';
}



Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N;
	cin >> N;
	set<string>S;
	for (int n = 0;n<N;++n) {
		string str;
		cin >> str;
		S.insert(str);
	}

	cout << S.size() <<endl;
	return 0;
}

Measured memory_bytes: 19180
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n;
  string s, s1, s2;
  cin >> n >> s;
  if (n % 2 == 1){
    cout << "No" << endl;
  } else {
    s1 = s.substr(0, n / 2);
    s2 = s.substr(n / 2);
    if (s1 == s2){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


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

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

typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<ll> a(n), b(n);
    for(int i=0; i<n; i++) cin>>a[i]>>b[i];

    ll ans=0;
    for(int i=n-1; i>=0; i--){
        a[i]+=ans;
        ans+=((a[i]+b[i]-1)/b[i])*b[i]-a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MOD 100000007LL
using namespace std;

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

int n;
vector<int> xi;
vector<int> yi;
int x[101];
int y[101];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int fie[501][501];
int fie2[501][501];
int a[4],b[4];

void bfs(int y,int x,int c){
	fie[y][x]=c;
	queue<P> que;
	que.push(P(y,x));
	while(que.size()){
		P p=que.front();
		que.pop();
		for(int i=0;i<4;i++){
			int nx=p.second+dx[i];
			int ny=p.first+dy[i];
			if(nx>=0 && nx<=2*xi.size() && ny>=0 && ny<=2*yi.size()){
				if(fie[ny][nx]==-1){
					fie[ny][nx]=c;
					que.push(P(ny,nx));
				}
			}
		}
	}
}

void bfs2(int y,int x,int c){
	fie2[y][x]=c;
	queue<P> que;
	que.push(P(y,x));
	while(que.size()){
		P p=que.front();
		que.pop();
		for(int i=0;i<4;i++){
			int nx=p.second+dx[i];
			int ny=p.first+dy[i];
			if(nx>=0 && nx<=2*xi.size() && ny>=0 && ny<=2*yi.size()){
				if(fie2[ny][nx]==-1){
					fie2[ny][nx]=c;
					que.push(P(ny,nx));
				}
			}
		}
	}
}

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		xi.clear();
		yi.clear();
		for(int i=0;i<n;i++){
			scanf("%d%d",&x[i],&y[i]);
			xi.push_back(x[i]);
			xi.push_back(x[i]+1);
			xi.push_back(x[i]-1);
			yi.push_back(y[i]);
			yi.push_back(y[i]+1);
			yi.push_back(y[i]-1);
		}
		for(int i=0;i<4;i++){
			scanf("%d%d",&a[i],&b[i]);
			xi.push_back(a[i]-1);
			xi.push_back(a[i]);
			xi.push_back(a[i]+1);
			yi.push_back(b[i]-1);
			yi.push_back(b[i]);
			yi.push_back(b[i]+1);
		}
		sort(xi.begin(),xi.end());
		xi.erase(unique(xi.begin(),xi.end()),xi.end());
		sort(yi.begin(),yi.end());
		yi.erase(unique(yi.begin(),yi.end()),yi.end());
		for(int i=0;i<n;i++){
			x[i]=lower_bound(xi.begin(),xi.end(),x[i])-xi.begin();
			y[i]=lower_bound(yi.begin(),yi.end(),y[i])-yi.begin();
		}
		for(int i=0;i<4;i++){
			a[i]=lower_bound(xi.begin(),xi.end(),a[i])-xi.begin();
			b[i]=lower_bound(yi.begin(),yi.end(),b[i])-yi.begin();
		}
		memset(fie,-1,sizeof(fie));
		for(int i=0;i<n;i++){
			if(x[i]==x[(i+1)%n]){
				for(int j=min(y[i],y[(i+1)%n])*2;j<=max(y[i],y[(i+1)%n])*2;j++){
					fie[j][x[i]*2]=1;
				}
			}else{
				for(int j=min(x[i],x[(i+1)%n])*2;j<=max(x[i],x[(i+1)%n])*2;j++){
					fie[y[i]*2][j]=1;
				}
			}
		}
		bfs(0,0,0);
		for(int i=0;i<=2*yi.size();i++){
			for(int j=0;j<=2*xi.size();j++){
				if(fie[i][j]==-1){
					bfs(i,j,1);
				}
			}
		}
		memset(fie2,-1,sizeof(fie2));
		for(int i=0;i<4;i++){
			if(a[i]==a[(i+1)%4]){
				for(int j=min(b[i],b[(i+1)%4])*2;j<=max(b[i],b[(i+1)%4])*2;j++){
					fie2[j][a[i]*2]=1;
				}
			}else{
				for(int j=min(a[i],a[(i+1)%4])*2;j<=max(a[i],a[(i+1)%4])*2;j++){
					fie2[b[i]*2][j]=1;
				}
			}
		}
		bfs2(0,0,0);

		for(int i=0;i<=2*yi.size();i++){
			for(int j=0;j<=2*xi.size();j++){
				if(fie2[i][j]==-1){
					bfs2(i,j,1);
				}
			}
		}
		int res=0,res2=0;
		for(int i=0;i+1<yi.size();i++){
			for(int j=0;j+1<xi.size();j++){
				if(fie[i*2+1][j*2+1]==1 && fie2[i*2+1][j*2+1]!=1){
					res+=(yi[i+1]-yi[i])*(xi[j+1]-xi[j]);
				}
				if(fie[i*2+1][j*2+1]==1){
					res2+=(yi[i+1]-yi[i])*(xi[j+1]-xi[j]);
				}
			}
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 5216
def main():
    sa = input()
    sb = input()
    sc = input()

    turn = "a"
    winner = None

    a_i = 0
    b_i = 0
    c_i = 0

    while True:

        if turn == "a":
            if a_i >= len(sa):
                winner = "A"
                break
            turn = sa[a_i]
            a_i += 1

        elif turn == "b":
            if b_i >= len(sb):
                winner = "B"
                break
            turn = sb[b_i]
            b_i += 1

        elif turn == "c":
            if c_i >= len(sc):
                winner = "C"
                break
            turn = sc[c_i]
            c_i += 1

    print(winner)
main()

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

#define F first
#define S second
const long long mod = 1000000007;
#define ll long long
 
ll N, L;
string s;

struct Trie {
    Trie* zero;
    Trie* one;
    Trie() {
        one = zero = NULL;
    }
};

Trie *root = new Trie(), *troot = NULL;

void addTrie() {
    troot = root;
    for(char ch : s) {
        if(ch == '0') {
            if(troot->zero == NULL) {
                troot->zero = new Trie();
            }
            troot = troot->zero;     
        }
        if(ch == '1') {
            if(troot->one == NULL) {
                troot->one = new Trie();
            }
            troot = troot->one;
        }
    }
}

vector<ll> hts;
void update_hts(Trie* root, ll th) {
    if(root->one != NULL && root->zero != NULL) {
        update_hts(root->one, th-1);
        update_hts(root->zero, th-1);
    }
    if(root->one == NULL && root->zero != NULL) {        
        update_hts(root->zero, th-1);
        hts.push_back(th);
    }
    if(root->one != NULL && root->zero == NULL) {
        update_hts(root->one, th-1);
        hts.push_back(th);
    }
}

unordered_map<ll, ll> uma;

int main() {
    cin >> N >> L;
    for(int i = 0;i < N;i++) {
        cin >> s;
        addTrie();
    }
    update_hts(root, L);
    for(auto height : hts) {
        ll cnt = 0;
        while(height % 2 == 0) {
            height >>= 1;
            cnt++;
        }
        uma[cnt]++;
    }

    bool xor_zero = true;
    for(auto it = uma.begin(); it != uma.end();it++) {
        xor_zero = (xor_zero && (it->second % 2 == 0));
    }

    if(xor_zero) {
        cout << "Bob" << endl;
    } else {
        cout << "Alice" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 7800
from datetime import date
while True:
    m,d = map(int, input().split())
    if m == 0 or d == 0:
        break
    wDay = date(2004, m, d).weekday()
    if wDay == 0:
        print("Monday")
    elif wDay == 1:
        print("Tuesday")
    elif wDay == 2:
        print("Wednesday")
    elif wDay == 3:
        print("Thursday")
    elif wDay == 4:
        print("Friday")
    elif wDay == 5:
        print("Saturday")
    elif wDay == 6:
        print("Sunday")

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

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

vector<int> b[3];

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') a[i] = 0;
        else if (s[i] == 'G') a[i] = 1;
        else a[i] = 2;
        b[a[i]].push_back(i);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] == a[j]) continue;
            int need = 0;
            if (need == a[i]) need++;
            if (need == a[j]) need++;
            if (need == a[i]) need++;
            if (need == a[j]) need++;
            auto it = upper_bound(all(b[need]), j) - b[need].begin();
            ans += sz(b[need]) - it;
            if (j + (j - i) < n && a[j + (j - i)] == need) ans--;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3736
while true
  s = gets.chomp
  break if s == "-"
  m = gets.to_i
  m.times do
    h = gets.to_i
    arr = s.split("").values_at(0..h - 1)
    s = s.split("") + arr
    h.times do
      s.delete_at(0)
    end
    s = s.join("")
  end
  puts s
end

Measured memory_bytes: 9044
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

int main(){
int n ;cin>>n;
int J=5,K=2;
int f[100][10];

rep(i,n){
  rep(j,10){
      cin>>f[i][j];
    }
  }

long long p[100][20];
rep(i,n){
  rep(j,11){
    cin>>p[i][j];
  }
}
  long long  res= -1000000000;

  for(int bit=1;bit<(1<<10);bit++)
  {
        int sum=0;
        for(int i=0; i<n ; i++)
        {
          int cnt=0;
          for(int j=0;j<10;j++)
          {
             if((bit & (1<<j) ) && f[i][j] ) cnt++;
          }
          sum+=p[i][cnt];
        }
        if(res < sum) res=sum;
   }
   cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
short int n[3];

void input(string s){
	int x=0,l=0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != ',') {
			x = x * 10 + s[i] - '0';
			continue;
		}
		n[l++] = x;
		x = 0;
	}
	n[2] = x;
}


int main() {
	string s;
	short int cnt1 = 0, cnt2 = 0;
	while (cin >> s) {
		input(s);
		if (n[0]*n[0] + n[1] * n[1] == n[2] * n[2])
			cnt1++;
		if (n[0] == n[1])
			cnt2++;
	}
	cout << cnt1 << endl << cnt2 << endl;
	return 0;
}


Measured memory_bytes: 3016
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl

int main(){
  int n,x;cin>>n>>x;
  vector<ll> m(n);
  ll total=0,minimum=INF;
  rep(i,n){
    cin>>m[i];
    total+=m[i];
    minimum=min(minimum,m[i]);

  }
  x-=total;
  cout<<n+int(x/minimum)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

ll f(ll a){
    ll res = (a+1)/2 % 2;
    if(a%2 == 0){
        res ^= a;
    }
    return res;
}

int main(){
    ll a, b;
    cin >> a >> b;
    a = max(a-1, 0LL);
    cout << (f(a) ^ f(b)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int m[100][100];
int f[100];
int d[100];
int n;
int t;



void visit(int u){
  int v;
  d[u] = ++t;
  for(v=0;v<n;v++){
    if(m[u][v] && d[v] == 0){
      visit(v);
    }
  }
    f[u] = ++t;
}

int main (){
  int i,j,k,u,r;

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

  for(i=0;i<n;i++){
    scanf("%d",&r);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&u);
      m[r-1][u-1] = 1;
    }
  }
  t = 0;
  for(i=0;i<n;i++){
    if(d[i] == 0){
      visit(i);
    }
  }


  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}

Measured memory_bytes: 632
h, ｎ = map(int, input().split())
dp = [-1] * (h + 1)
dp[0]=0
ab = []

for i in range(n):
  temp = list(map(int, input().split()))
  ab.append(temp)

for i in range(h):
  if dp[i] == -1: continue
  for j in ab:
    ht = i + j[0]
    if ht >= h: ht = h
    if dp[ht] != -1:
      dp[ht] = min(dp[ht], dp[i] + j[1])
    else:
      dp[ht] = dp[i] + j[1]

print(dp[h])


Measured memory_bytes: 42332
import heapq

n,m=map(int,input().split())
ab=[]
for i in range(n):
    ab.append(list(map(int,input().split())))
ab.sort()

q=[]
ans=0
j=0
for i in range(m):
    while j <= n-1:
        if ab[j][0]<=i+1:
            heapq.heappush(q,-ab[j][1])
        else:
            break
        j+=1
    if len(q)!=0:
        ans-=heapq.heappop(q)
print(ans)

Measured memory_bytes: 31600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<pil> > G(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].eb(b, 1);
    G[b].eb(a, 1);
  }

  vector<int> from(n, -1);
  auto dijkstra = [&](int s) {
    vector<pll> d(n, pli(INF, 0)); // 最短距離, その本数
    vector<int> vis(n);
    //頂点、最短距離、小さい順に
    priority_queue<pli, vector<pli>, greater<pli> > q;

    d[s] = pll(0, 1);
    q.push(pli(0, s));

    while (!q.empty()) {
      pli p = q.top();
      q.pop();
      int v = p.S;

      if (vis[v]) continue;
      vis[v] = 1;

      for (pil np : G[v]) {
        int nv;
        ll cost;
        tie(nv, cost) = np;

        pll tmp = pli(d[v].F + cost, d[v].S);
        if (d[nv].F != tmp.F) {
          if (chmin(d[nv], tmp)) {
            // cout << "nv v " << nv << " " << v << endl;
            from[nv] = v;
          }
        }
        else d[nv] = pli(d[nv].F, (d[nv].S + d[v].S) % mod); // 最短距離の本数増やす
        q.push(pli(d[nv].F, nv));
      }
    }
    return d;
  };
  dijkstra(0);

  cout << "Yes" << endl;
  rep3(i, 1, n) cout << from[i] + 1 << endl;
}


Measured memory_bytes: 20176
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


template<typename T>
int lis(T s, T e, bool strict = true)
{
  using value_type = typename std::iterator_traits<T>::value_type;

  const value_type max = std::numeric_limits<value_type>::max();

  size_t N = e - s;

  value_type* dp = new value_type[N];

  std::fill(dp, dp + N, max);

  if (strict) {
    // strict: 0 0 1 1 2 2  ->  3
    for ( ; s != e; ++ s)
      *std::lower_bound(dp, dp + N, *s) = *s;
  }
  else {
    // not strict: 0 0 1 1 2 2  ->  6
    for ( ; s != e; ++ s)
      *std::upper_bound(dp, dp + N, *s) = *s;
  }

  int r = std::lower_bound(dp, dp + N, max - 1) - dp;

  delete[] dp;

  return r;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N;

  std::cin >> N;

  std::vector<int> d(N);

  for (auto& i : d)
    std::cin >> i;

  std::sort(ALL(d));

  std::cout << lis(ALL(d)) << std::endl;

  return 0;
}


Measured memory_bytes: 888
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn = 10;
int e[maxn][maxn];
int h, w;

void floyd()
{
    for (int k = 0; k < maxn; k++)
        for (int i = 0; i < maxn; i++)
            for (int j = 0; j < maxn; j++)
                e[i][j] = min(e[i][j], e[i][k] + e[k][j]);
}

int main(void)
{
    while (scanf("%d %d", &h, &w) != EOF && h != 0 && w != 0)
    {
        for (int i = 0; i < maxn; i++)
            for (int j = 0; j < maxn; j++)
                scanf("%d", &e[i][j]);
        floyd();

        int ans = 0;
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                int tmp;
                scanf("%d", &tmp);
                if (tmp != -1 && tmp != 1)
                {
                    ans += e[tmp][1];
                }
            }
        }
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vvi g(n, vi());
    vector<pair<int, int>> p;
    int a, b;
    REP(i, n - 1) {
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
        if (a > b) p.emplace_back(b, a); else p.emplace_back(a, b);
    }
    map<pair<int, int>, int> ans;

    function<void(int, int)> dfs = [&](int c, int p) {
        if (p != -1 && sz(g[c]) == 1) return;
        int nc = 1;
        for (auto e : g[c]) {
            if (e == p) continue;
            pair<int, int> key;
            key = p > c ? make_pair(c, p) : make_pair(p, c);
            if (nc == ans[key]) nc++;
            pair<int, int> key2;
            key2 = e > c ? make_pair(c, e) : make_pair(e, c);
            ans[key2] = nc++;
            dfs(e, c);
        }
    };

    dfs(0, -1);

    int mx = 1;
    for (auto q : ans) chmax(mx, q.second);
    cout << mx << endl;
    for (auto q : p) {
        cout << ans[q] << endl;
    }
}


Measured memory_bytes: 15868
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <numeric>
#include <queue>
#include <string.h>
#include <sstream>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(ll i = 0;i < n;i++)
#define rep1(i,n) for(ll i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<ll>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){

	int  h,w;
	cin >> h >> w;

	vector<string> s(h);
	vector<vector<int> > dist(h,vector<int>(w,-1));

	for(ll i = 0;i < h;i++){
		cin >> s[i];
	}

	queue<pair<ll,ll> > que;
	pair<ll,ll> tmp;
	int d1[] = {-1,1};
	ll ans = 0;

	for(ll i = 0;i < h;i++){
		for(ll j = 0;j < w;j++){

			if(s[i][j] == '#') continue;

			for(ll k = 0;k < h;k++) fill(dist[k].begin(),dist[k].end(),-1);

			que.push(make_pair(i,j));
			dist[i][j] = 0;

			while(!que.empty()){
				tmp = que.front();
				que.pop();
				for(ll k = 0;k < 2;k++){
					if(tmp.first + d1[k] >= 0 && tmp.first + d1[k] < h){
						if(s[tmp.first + d1[k]][tmp.second] == '.' && dist[tmp.first + d1[k]][tmp.second] == -1){
							dist[tmp.first + d1[k]][tmp.second] = dist[tmp.first][tmp.second] + 1;
							que.push(make_pair(tmp.first + d1[k],tmp.second));
						}
					}
					if(tmp.second + d1[k] >= 0 && tmp.second + d1[k] < w){
						if(s[tmp.first][tmp.second + d1[k]] == '.' && dist[tmp.first][tmp.second + d1[k]] == -1){
							dist[tmp.first][tmp.second + d1[k]] = dist[tmp.first][tmp.second] + 1;
							que.push(make_pair(tmp.first,tmp.second + d1[k]));
						}
					}
				}
				if(que.empty()){
					if(ans < dist[tmp.first][tmp.second]) ans = dist[tmp.first][tmp.second];
					break;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  int N,T;
  cin >> N >> T;
  
  int min = INF;
  rep(i,0,N){
    int c,t;
    cin >> c >> t;
    if(t <= T){
      if(min > c) min = c;
    }
  }
  if(min == INF) print("TLE");
  else print(min);


}


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

int main()
{
    double x;
    // scanf("%d", &x);
    cin >> x;
    double ans;
    ans = 2 * x * 3.141592;
    // printf("%d\n", x * x * x);
    cout << ans << endl;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a,b,c,d,e,f,a2,b2,c2,ansx,ansy; // ax+by=c  dx+ey=f
  while(cin >> a >> b >> c >> d >> e >> f){
    a2=a;
    b2=b;
    c2=c;

    a/=b; // (a/b)x+y=c
    c/=b; // (a/b)x+y=(c/b)
    a*=(-1); // y=(c/b)-(a/b)x
    c*=e; // dx+e(c)=f
    a*=e; // dx+e(c+ax)=f
    a+=d; // dx+(a*e)x+(c*e)=f
    f-=c; // dx+(a*e)x=f-(c*e)
    ansx=f/a;
    if(ansx > -0.0005 && ansx <= 0){
      printf("0.000 ");
    } else{
      printf("%.3f ",ansx);
    }
 
    a2*=ansx;
    c2-=a2;
    ansy=c2/b2;
    if(ansy >= -0.0005 && ansy <= 0){
      printf("0.000\n");
    } else{
      printf("%.3f\n",ansy);
    }
  }
  return 0;
}

Measured memory_bytes: 3068
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC121C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;
            var M = ReadInt;

            int[] A = new int[N];
            int[] B = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = ReadInt;
                B[i] = ReadInt;
            }

            Drink[] drinks = new Drink[N];
            for (int i = 0; i < N; i++)
            {
                drinks[i] = new Drink() { cost = A[i], num = B[i] };
            }

            drinks = drinks.OrderBy(x => x.cost).ToArray();

            //購入していく
            long cost = 0;
            for (int i = 0; i < N; i++)
            {
                int c = drinks[i].cost;
                int n = drinks[i].num;

                if (n <= M)
                {
                    cost += (long)c * n;
                    M -= n;
                }
                else
                {
                    cost += (long)c * M;
                    break;
                }
            }

            Console.WriteLine(cost);

        }

        struct Drink
        {
            public int cost;
            public int num;
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 33500
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - B +/- A
            var line = ReadLine();
            int a = line[0];
            int b = line[1];

            if (b % a == 0)
            {
                Console.WriteLine(a + b);
            }
            else
            {
                Console.WriteLine(b - a);
            }            
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');
            var numbers = new List<int>();

            foreach (var s in array)
            {
                int num = int.Parse(s);
                numbers.Add(num);
            }

            return numbers;
        }
    }
}

Measured memory_bytes: 13140
N=int(input())
A=input().split()
A=[int(n) for n in A]
B=input().split()
B=[int(n) for n in B]
C=input().split()
C=[int(n) for n in C]
ans=0
ans+=sum(B)
for i in range(N-1):
    if A[i]+1==A[i+1] and A[i]<len(C)+1:
        ans+=C[A[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,k,r,x,y,z,ans=0,ans2=0;
string s,S,t;
int main() {
  int n, m;
  cin >> n >> m;
    dsu d(n);
  REP(i,m){
    int a = 0,b=0;
    cin >> a >> b;
    d.merge(a-1, b-1);
  }
  REP2(i,n-1){
      if(!d.same(i-1,i)){
          d.merge(i-1, i);
          ans++;
      }
     }
  cout << ans;
}


Measured memory_bytes: 3824
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>

typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

int main(void) {
    int n;
    map<string, int> scores;
    cin >> n;
    REP(i, n) {
        string input;
        cin >> input;
        scores[input] += 1;
    }
    int m;
    cin >> m;
    REP(i, m) {
        string input;
        cin >> input;
        scores[input] -= 1;
    }

    int ans = 0;
    for (auto itr = scores.begin(); itr != scores.end(); ++itr) {
        ans = max(ans, itr->second);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<long long, long long> P;
//typedef pair<string, long long> Q;
//typedef tuple<string, string, long long> P;
int main(){
    int n;
    cin>>n;
    int ans=0;
    rep1(i,n){
        int co=0;
        int c=int(sqrt(i));
        rep1(j,c){
            if(i%j==0){
                co+=2;
             }
        }
        if(co==8 && i%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)
#define fi first
#define se second

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    string s;
    cin >> s;
    int res = 0;
    int first = 0, last = s.size() - 1;
    while(1) {
        if(first >= last) break;
        if(s[first] != s[last]) {
            if(s[last] == 'x') {
                ++res;
                --last;
            }
            else if(s[first] == 'x'){
                ++res;
                ++first;
            }
            else {
                res = -1;
                break;
            }
        }
        else {
            ++first;
            --last;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int INF = 1001001001;
const ll LINF = 1e18;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}

ll twoMod(ll in){
    ll count = 0;
    while(in % 2 == 0){
        count++;
        in /= 2;
    }
    return count;
}

int main() {
    ll N; cin >> N;
    vl m(N + 1, LINF), one_d;
    m[1] = 1; one_d.push_back(1);
    for(ll i = 0; pow(6, i) <= N; i++){
        m[pow(6, i)] = 1;
        one_d.push_back(pow(6, i));
    }
    for(ll i = 0; pow(9, i) <= N; i++){
        m[pow(9, i)] = 1;
        one_d.push_back(pow(9, i));
    }
    
    for (ll i = 2; i <= N; i++) {
        for (ll j = 0; (j < one_d.size() && i - one_d[j] > 0); j++) {
            m[i] = min(m[i], 1 + m[i - one_d[j]]);
        }
    }
    
    cout << m[N] << endl;
    return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public  static boolean check(int x) {
        for(int i=2;i*i<=x;i++) {
            if(x%i==0) return false;
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int x=in.nextInt();
        while(true) {
            if(check(x)) {
                System.out.println(x);
                break;
            }
            x++;
        }
    }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> contests = {111, 222, 333, 444, 555, 666, 777, 888, 999};
    auto ans = lower_bound(contests.begin(), contests.end(), n);
    cout << *ans << endl;  
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  string s;
  cin >> s;
  cout << ((s[0]=='9' || s[1]=='9') ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int dp[3005][3005];
int main()
{
     string s,t;
     cin>>s>>t;
     int ls=s.size(),lt=t.size();
     for(int i=1;i<=ls;i++)
     {
          for(int j=1;j<=lt;j++)
          {
             if(s[i-1]==t[j-1])
               dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
             else
               dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
          }
     }
    int index = dp[ls][lt];
    char lcs[index+1];
    lcs[index]='\0';
    int i=ls,j=lt;
    while(i>0 && j>0)
    {
      if(s[i-1]==t[j-1])
      {
          lcs[index-1] = s[i-1];
          i--; j--;
          index--;
      }
      else if (dp[i-1][j]>dp[i][j-1])
         i--;
      else
         j--;
   }
   cout<<lcs;
}



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

int n, a, J;
bitset<4000006> b;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	b[0] = 1;
	for(int i = 1; i <= n; ++i) {
		cin >> a;
		b |= b << a;
		J += a;
	}
	for(int i = (J + 1) / 2; true; ++i) {
		if(b[i]) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int score, id=0;
int nums[10001],isCheck[10001];
vector<vi> G(10001);
vi c(10001);
void dfs(int v, int parent){
  if(isCheck[v])return;
  isCheck[v] = 1;
  nums[v] = c[id];
  id++;
  for(auto u : G[v]){
    dfs(u,v);
  }
  if(parent>=0){
    score += min(nums[v],nums[parent]);
  }
  return;
}
int main() {
  int n;
  cin >> n;
  vector<P> p(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }  
  rep(i,n) p[i] = P(sz(G[i]),i);
  sort(rng(p),greater<P>());
  rep(i,n) cin >> c[i];
  sort(rng(c),greater<int>());
  nums[p[0].se] = c[0];
  dfs(p[0].se,-1);
  cout<<score<<endl;
  rep(i,n)cout <<nums[i]<< " ";
  cout<<endl;
  return 0;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int a;
    string s;
    cin>>a>>s;
    if(a>=3200)
    	cout<<s;
    else
    	cout<<"red";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<time.h>
#include<stack>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector<int>V;
typedef pair<int , int > P;
const int inf = 0x3f3f3f3f;
const ll INF = 2e18;
const double PI = acos(-1.0);
const double eps = 1e-9;
const int N = 5+1e4;

struct node
{
    ;
}a[N];

bool judge(int n)
{
    int res = n%10;
    n /= 10;
    while(n)
    {
        if(res != n%10+1 )    return false;
        res = n%10;
        n /= 10;
    }
    return true;
}

bool cmp(const int &a, const int &b)
{
    return a > b;
}

int main()
{
//    freopen("C:\\Users\\zhangab\\Desktop\\exercise\\1.txt", "r", stdin);
    int n;
    while(~scanf("%d", &n))
    {
        int a[N];
        for(int i = 0; i < n; i ++)
        {
            scanf("%d", a+i);
        }
        int ans = -1;
        sort(a, a+n, cmp);
        for(int i = 0; i < n; i ++)
            for(int j = i + 1; j < n; j ++)
        {
            if(a[i]*a[j]>ans)
            {
                if(judge(a[i]*a[j]))
                {
                    ans = a[i]*a[j];
                    goto x;
                }
            }
        }
        x : printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3304
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;

#define sumof(a, b, c, d) (sum[a-1][b-1] + sum[c][d] - sum[a-1][d] - sum[c][b-1])
#define INF (1<<28)
typedef pair<int, int> P;
int h, w, s;
int u[33][33];
int sum[33][33];
P dp[33][33][33][33];
bool solve(){
	cin >> h >> w >> s;
	if(h == 0 && w == 0 && s == 0)return false;

	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			cin >> u[i][j];
			sum[i][j] = u[i][j] - sum[i-1][j-1] + sum[i][j-1] + sum[i-1][j];
		}
	}

	int limit = sumof(1, 1, h, w) - s;
	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			for(int k = i;k <= h;k++){
				for(int l = j;l <= w;l++){
					int surplus = sumof(i, j, k, l) - limit;
					if(surplus < 0)
						dp[i][j][k][l] = P(-INF, 0);
					else
						dp[i][j][k][l] = P(1, surplus);

				}
			}
		}
	}

	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			for(int k = 1;k+i <= h;k++){
				for(int l = 1;l+j <= w;l++){
					P &tmp = dp[k][l][k+i][l+j];
					
					for(int mid = k;mid < k+i;mid++){
						int cnt, surplus;
						cnt = dp[k][l][mid][l+j].first + dp[mid+1][l][k+i][l+j].first;
						surplus = min(dp[k][l][mid][l+j].second, dp[mid+1][l][k+i][l+j].second);
						tmp = max(tmp, P(cnt, surplus));
					}

					
					for(int mid = l;mid < l+j;mid++){
						int cnt, surplus;
						cnt = dp[k][l][k+i][mid].first + dp[k][mid+1][k+i][l+j].first;
						surplus = min(dp[k][l][k+i][mid].second, dp[k][mid+1][k+i][l+j].second);
						tmp = max(tmp, P(cnt, surplus));
					}
				}
			}
		}
	}
	cout << dp[1][1][h][w].first << " " << dp[1][1][h][w].second << endl;
	return true;
}

int main(){
	while(solve());
	return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

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

Measured memory_bytes: 3632
n,m  = map(int,input().split())

balls = [1 for _ in range(n)]
red = [1] + [0 for _ in range(1,n)]

for _ in range(m):
  x, y = map(int,input().split())
  x,y = x-1, y-1
  
  if balls[x] ==0:
    continue
    
  balls[x] -= 1
  balls[y] += 1
  if red[x]:
    red[y] = 1
  if balls[x]==0:
    red[x] = 0
print(sum(red))
  
  



Measured memory_bytes: 5552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, t, a, b, s;
  in2(n, t);
  vector<ll> c(n), d(n), e(n), f(n - 1);
  rep(i, n)
    in(c[i]);
  d[0] = c[0];
  e[n - 1] = c[n - 1];
  rep(i, n - 1){
    d[i + 1] = min(d[i], c[i + 1]);
    e[n - 2 - i] = max(e[n - 1 - i], c[n - 2 - i]);
  }
  a = 0;
  rep(i, n - 1){
    f[i] = e[i + 1] - c[i];
    a = max(a, f[i]);
  }
  b = 0;
  rep(i, n - 1){
    if(a == f[i])
      b++;
  }
  out(b);
  memi;
}

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

signed main() {
  int X;
  cin >> X;
  
  for( int A = -150; A <= 150; A++ ){
    for( int B = -150; B <= 150; B++ ){
      if( pow(A, 5) - pow(B, 5) == X ){
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4092
# Python template 
from collections import defaultdict 
import sys
import math 

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

sys.setrecursionlimit(10**6) 
g = defaultdict(set)
(n,m) = get_ints()
visited = [0]*n 


def dfs(i,l,par):
    global visited
    visited[i] = True
    l.append(i)
    for j in g[i]:
        if j!=par and not visited[j]:
            dfs(j,l,i)

for i in range(m):
    (u,v) = get_ints()
    g[u-1].add(v-1)
    g[v-1].add(u-1)

ans = 0
for i in range(n):
    if not visited[i]:
        l = []
        dfs(i,l,-1)
        ans = max(ans,len(l))
        
print(ans)


Measured memory_bytes: 461800
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
int main() {
	int n, k[105], ans = 1;
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; }
	sort(k, k + n);
	for (int i = 1; i < n; ++i) {
		if (k[i] > k[i - 1]) { ++ans; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int T = sc.nextInt();
int A = sc.nextInt();
int ans=1;
double distance=-1.0;
  for(int i=1;i<=N;i++){
    int H = sc.nextInt();
    if(distance==-1){
      ans=i;
      distance=Math.abs(A-(T-0.006*H));
    }else{
      if(distance>Math.abs(A-(T-0.006*H))){
        ans=i;
        distance=Math.abs(A-(T-0.006*H));
      }
    }

  }

System.out.println(ans);
}
}


Measured memory_bytes: 24916
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
   int n,i;
   double s[1000],sum1,m,sum2,a;
   while(1){
       cin >> n;
       if(n==0)break;
       sum1=0;
       for(i=0;i<n;i++){
           cin >> s[i];
           sum1+=s[i];
       }
       m=sum1/(double)n;
       sum2=0;
       for(i=0;i<n;i++){
        sum2+= (pow(s[i]-m,2));  
       }
       a = sqrt(sum2/n);                                                 
    cout << fixed << setprecision(8) << a << endl; 
   }
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin>>n;
        map<string,int>mp;
        for(int i=0;i<n;i++)
        {
            string s;
            cin>>s;
            mp[s]++;
        }
        int mx=0;
        for(auto it=mp.begin();it!=mp.end();it++)
        {
            if(it->second>=mx)
            {
                mx=it->second;
            }
        }
        set<string>st;
        for(auto it=mp.begin();it!=mp.end();it++)
        {
            if(it->second==mx)
            {
                st.insert(it->first);
            }
        }
        for(auto it=st.begin();it!=st.end();it++)
            cout<<*it<<endl;
    }

Measured memory_bytes: 35840
#include <stdio.h>

int main(void)
{
    int a, b;
    int ans = 0;
    scanf("%d%d", &a, &b);

    if (a >= 13)
        ans = b;
    if (6 <= a && a <= 12)
        ans = b / 2;

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

Measured memory_bytes: 256
N = int(input())
S,T = input().rstrip().split(' ')
x = 0
y = 1
X = ""
Y = ""
Z = ""
for i in range(N):
    X = S[x:y]
    Y = T[x:y]
    Z = Z + X + Y
    x = x + 1
    y = y + 1
print(Z)

Measured memory_bytes: 2940