akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
    int h,w;cin>>h>>w;
    vector<string> s(h);
    rep(i,h)cin>>s[i];
    int ans=0;
    vector<vector<int>>lh(h,vector<int>(w)),lw(h,vector<int>(w));
    ////lw/////
    rep(i,h){
        int leng=0;
        rep(j,w){
            if(s[i][j]=='#'){
                rep(k,leng)lw[i][j-1-k]=leng;
                leng=0;
                lw[i][j]=0;    
            }
            else leng++;
            if(j==w-1)rep(k,leng)lw[i][j-k]=leng;
        }
    }
    //////lh/////
    rep(i,w){
        int leng=0;
        rep(j,h){
            if(s[j][i]=='#'){
                rep(k,leng)lh[j-1-k][i]=leng;
                leng=0;
                lh[j][i]=0;    
            }
            else leng++;
            if(j==h-1)rep(k,leng)lh[j-k][i]=leng;
        }
    }
    ////////
    rep(i,h){
        rep(j,w){
            ans=max(ans,lw[i][j]+lh[i][j]-1);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 35712
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
m = 0
for i in range(N):
    p = min(A[i], B[i])
    B[i] -= p
    m += p
    q = min(A[i+1], B[i])
    A[i+1] -= q
    m += q
print(m)

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

int main() {
  int a, b, c, count;
  count = 0;

  cin >> a >> b >> c;
  for (int i = a; i <= b; i++) {
    if (c % i == 0) {
      count++;
    }
  }

  cout << count << endl;
}


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

using namespace std;

//const int INF = -1e5 + 5;

int max_self(int &a , int b){
    a = max(a , b);
return a;
}

int main (){
    int N;
scanf("%d" , &N);
    vector<int> dp(3);
    for(int day = 0; day < N; ++day){
        vector<int> cost(3);
        for(int i = 0; i < 3; ++i){
            scanf("%d" , &cost[i]);
        }
        vector<int> new_dp(3 , 0);
        for(int i = 0; i < 3; ++i){
            for(int j = 0; j < 3; ++j){
                if(i != j){
                    max_self(new_dp[j] , dp[i] + cost[j]);
                }
            }
        }
        dp = new_dp;
    }
    //cerr << dp[0] << " " << dp[1] << ' ' << dp[2] << endl;
    printf("%d" , max(dp[0] , max(dp[1] , dp[2])));
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> id(n + 1);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
        id[p[i]] = i;
    }
    multiset<int> se;
    se.insert(-1);
    se.insert(-1);
    se.insert(n);
    se.insert(n);
    ll ans = 0;
    for(int num = n; num >= 1; num--) {
        int i = id[num];
        auto it = se.lower_bound(i);
        int y = *it;
        int z = *(++it);
        it--;
        int x = *(--it);
        int w = *(--it);
        ans += (ll)num * ((ll)(x - w) * (y - i) + (ll)(i - x) * (z - y));
        se.insert(i);
    }
    print(ans);
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long int
#define lld  double
#define pb push_back
#define mp make_pair
#define Maxn 1007
#define ff first
#define ss second
#define inf 100000000
using namespace std;
//vector <ll> vi;
int main(){
    ll i,cnt=0,x,a,b;
   string s;
   cin>>s;
    stack <ll> st;
   
    for(i=0;i<s.size();i++){
         x=s[i]-'0';
        if(st.empty()){
            st.push(x);
        }
        else{
            if(st.top()!=x){
                cnt+=2;
                st.pop();
            }
            else{
                st.push(x);
            }
        }
       // x=s[i]-'0';
        
        
    }
    cout<<cnt;
}


Measured memory_bytes: 1152
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

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

#define EPS 1e-9

using namespace std;

int main(){

	int n;
	cin >>n;

	double xa,ya,ra,xb,yb,rb;
	rep(i,n){

	cin >> xa >> ya >> ra >> xb >> yb >> rb;

	double AB=sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));

	if(AB>ra+rb) cout << 0 << endl;
	else if(AB<ra-rb) cout << 2 << endl;
	else if(AB<rb-ra) cout << -2 << endl;
	else  cout << 1 << endl;
	}


return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>

using namespace std;

int main(){
    int count = 0;
    bool even = true;
    int num;
    cin >> num;
    int temp[num];

    for (int i = 0; i < num; i++) {
        cin >> temp[i];
    }


    while (even) {
    for (int i = 0; i < num; i++) {

        if ((temp[i] % 2) != 0) {
            even = false;
        }
    }

    if (even) {
        for (int i = 0; i < num; i++) {
        temp[i] = temp[i] / 2;
        }
        count++;
    }
    

    
    }

    cout << count;

    return 0;
}

Measured memory_bytes: 256
import sys

S = list(input())
    
for i in range(len(S)):
    S[i] = ord(S[i]) - ord("a")

if len(S) == 26:
    t = 26
    for i in range(len(S)-1)[::-1]:
        for j in range(i+1,26):
            if S[i] < S[j] and t > S[j]:
                t = S[j]
        if t != 26:
            S = S[:i] + [t]
            for k in range(len(S)):
                S[k] = chr(S[k] + ord("a"))
            print("".join(S))
            sys.exit()
    print(-1)

else:
    n = set(range(26)) - set(S)
    S.append(min(n))
    for i in range(len(S)):
        S[i] = chr(S[i] + ord("a"))
    print("".join(S))

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

using namespace std;

const int N = 3010;
int dp[N][N];
pair<int, int> p[N][N];

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

  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      if (i < n and j < m and s[i] == t[j] and dp[i + 1][j + 1] <= dp[i][j] + 1) {
        dp[i + 1][j + 1] = dp[i][j] + 1;
        p[i + 1][j + 1] = {i, j};
      }
      if (dp[i + 1][j] <= dp[i][j]) {
        dp[i + 1][j] = dp[i][j];
        p[i + 1][j] = {i, j};
      }
      if (dp[i][j + 1] <= dp[i][j]) {
        dp[i][j + 1] = dp[i][j];
        p[i][j + 1] = {i, j};
      }
    }
  }
  string ans;
  int i = n, j = m;
  while (i or j) {
    int ni, nj;
    tie(ni, nj) = p[i][j];
    if (i - ni + j - nj == 2) {
      ans += s[ni];
    }
    i = ni, j = nj;
  }
  reverse(ans.begin(), ans.end());
  cout << ans;

  return 0;
}

Measured memory_bytes: 106368
# 解法 おそらくアルゴリズムの授業で出た，単純に締め切りが近いものからやっていくのが正しいのではないかと思われる．
#
N = int(input())
AB = []
for _ in range(N):
    a,b = map(int,input().split())
    AB.append([a,b])

AB.sort(key=lambda x: x[1])

# 最速でタスクをクリアしつつ，もし最短時間でも締め切りを過ぎた場合はだめ．
now = 0
for ab in AB:
    a,b = ab
    now += a
    if now>b:
        print('No')
        exit()

print('Yes')



Measured memory_bytes: 40704
#include<stdio.h>
#include<string.h>
int main(void){
  char w[110];
  int a[30]={},i;
  
  scanf("%s",w);
  for(i=0;i<strlen(w);i++) a[w[i]-'a']++;
  for(i=0;i<26;i++){
    if(a[i]%2!=0){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 128
if __name__ == '__main__':
    S = list(input())
    T = list(input())

    num = -1
    for i in range(len(S) - len(T) + 1):
        flg = True
        for j in range(1, len(T) + 1):
            if S[-(i + j)] == "?":
                continue
            if S[-(i + j)] == T[-j]:
                continue
            flg = False
            break

        if flg:
            num = i
            break

    if num == -1:
        print("UNRESTORABLE")
    else:
        start = len(S) - (len(T) + num)
        end = len(S) - num
        S[start:end] = T
        mojiretu = "".join(S)
        ans = mojiretu.replace("?", "a")
        print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    // in(n);

    char a;
    cin >> a;
    if (a >= 'a' && a <= 'z')
    {
        cout << 'a' << endl;
    }
    else
    {
        if (a >= 'A' && a <= 'Z')
        {
            cout << "A"<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
#define SMIN 3
#define SMAX 1000000
#define NMIN 1
#define NMAX 100
#define BMIN 1
#define BMAX 10000
#define LIM 10000
#define TCASE 20

bool valid[SMAX+1];

bool check(vector<int> v){
  if ( v[0] != 1 ) return false;
  for ( int i = 1; i < v.size(); i++ ){
    if ( v[i-1]+1 != v[i] ) return false;
  }
  return true;
}

int simulate(vector<int> v, int sum){
  assert( SMIN <= sum && sum <= SMAX );
  //if ( !valid[sum]) return -1;
  int cnt = 0;
  while(1){
    if ( check(v) ) return cnt;
    int r = v.size();
    for ( int i = 0; i < v.size(); i++ ) v[i]--;
    vector<int> nv;
    for ( int i = 0; i < v.size(); i++ ) {
      if ( v[i] ) nv.push_back(v[i]);
    }
    v = nv;
    v.push_back(r);
    cnt++;
    if ( cnt > LIM ) return cnt;
  }
}

main(){
  for ( int i = 0; i <= SMAX; i++ ) valid[i] = false;
  int cur = 3, d = 3;
  while( cur <= SMAX ){
    valid[cur] = true;
    cur += d;
    d++;
  }

  int n;
  int tcase = 0;
  while(1){
    cin >> n;
    if ( n == 0 ) break;
    tcase++;
    assert( NMIN <= n && n <= NMAX);
    vector<int> v;
    int x;
    int sum = 0;
    for ( int i = 0; i < n ;i++) {
      cin >> x;
      assert( BMIN <= x && x <= BMAX);
      v.push_back(x);
      sum += x;
    }
    int ans = simulate(v, sum);
    if ( ans > 10000 ) cout << -1 << endl;
    else cout << ans << endl;
  }
  assert( tcase <= TCASE );
}

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

int main() {
	long long int h,n,sum=0;
	cin>>h>>n;
	long long int temp;
	for(int i=0;i<n;i++)
	{
	    cin>>temp;
	    sum=sum+temp;
	}
	if(sum>=h)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

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

using ld = long double;
using pii = pair<int,int>;
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)
#define Max(a,b) a=max(a,b)
#define IN(i,a,b) (a<=i&&i<=b)
#define pb push_back

const int mxn = 3e5;

struct BIT {
	int tree[mxn];
	BIT() { f(i,0,mxn) tree[i] = 0; }
	void add(int i, int v) {
		for (; i<mxn; i|=i+1)
			Max(tree[i],v);
	}
	int sum(int i) {
		int ans = 0;
		for (; i >= 0; i = (i&(i+1))-1) {
			Max(ans,tree[i]);
		}
		return ans;
	}
		
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int x1,x2,y1,y2,n;
	cin>>x1>>y1>>x2>>y2>>n;
	vector<pii> points;
	f(i,0,n) {
		int x,y; cin>>x>>y;
		if ((IN(x,x1,x2)||IN(x,x2,x1))&&
			(IN(y,y1,y2)||IN(y,y2,y1)))
				points.pb({x,y});
	}
	n = points.size();
	if (x1>x2) {
		x1 *= -1; x2 *= -1;
		f(i,0,n) points[i].first *= -1;
	}
	if (y1>y2) {
		y1 *= -1; y2 *= -1;
		f(i,0,n) points[i].second *= -1;
	}
	sort(begin(points),end(points));
	map<int,int> fi;
	f(i,0,n) fi[points[i].second] = 0;
	int t = 0;
	for (pii pp : fi)
		fi[pp.first] = t++;

	bool inc = 1;
	f(i,1,n) if (points[i].second < points[i-1].second)
		inc = 0;

	ld ans = 100LL*(abs(x1-x2)+abs(y1-y2));
	if (inc && n && points[0].first + n - 1 == points[n-1].first &&
			x1 == points[0].first && x2 == points[n-1].first)
		ans += M_PI * 5;
	else if (inc && n && points[0].second + n - 1 == points[n-1].second &&
			y1 == points[0].second && y2 == points[n-1].second)
		ans += M_PI * 5;
	int num = 0;
	BIT ds;
	f(i,0,n) {
		int z = ds.sum(fi[points[i].second])+1;
		ds.add(fi[points[i].second],z);
		Max(num,z);
	}
	ans += 1LL*num*(M_PI*5-20);
	cout << setprecision(30) << ans << endl;


#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 12400
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;

int cnt[100010];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		cnt[a]++;
		cnt[b]++;
	}
	for (int i = 0; i < N; i++) {
		cout << cnt[i] << endl;
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x, k;
    cin >> x >> k;
    int r[k+1];
    for(int i = 0; i<k; i++){
        cin >> r[i];
    }
    r[k] = 1000000002;
    int queries;
    cin >> queries;
    int p = 0;
    bool atop = true;
    int lb = 0;
    int lv = 0;
    int rb = x;
    int rv = x;
    int last = 0;
    for(int i = 0; i<queries; i++){
        int t, a;
        cin >> t >> a;
        while(r[p]<=t){
            last = r[p];
            int len = r[p];
            if(p>0){
                len -= r[p-1];
            }
            //progress
            if(atop){
                if(len>=lv){
                    
                    lb += (len-lv);
                    lb = min(lb,x);
                    lv = 0;
                    if(rv<=len){
                        rv = 0;
                        rb = 0;
                    }
                    else{
                        rv -= len;
                    }
                }
                else{
                    lv -= len;
                    rv -= len;
                }
            }
            else{
                if(len>=x-rv){
                    
                    rb -= len-(x-rv);
                    rb = max(0,rb);
                    rv = x;
                    if(len>=(x-lv)){
                        lv = x;
                        lb = x;
                    }
                    else{
                        lv += len;
                    }
                }
                else{
                    lv += len;
                    rv += len;
                }
            }
            atop = !atop;
            p++;
        }
        int delt = t-last;
        int now = lv;
        if(a<=lb){
            now = lv;
        }
        else if(a>=rb){
            now = rv;
        }
        else{
            now += a-lb;
        }
        if(atop){
            now -= delt;
        }
        else{
            now += delt;
        }
        now = min(now,x);
        now = max(now,0);
        cout << now << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    vector<ll> A(7);
    for(auto &i:A){cin>>i;}
    ll ans=A[1];
    if(A[0]%2+A[3]%2+A[4]%2>=2 && A[0]>0 && A[3]>0 && A[4]>0){ans+=3; A[0]--; A[3]--; A[4]--;}
    ans+=(A[0]/2+A[3]/2+A[4]/2)*2;
    cout<<ans<<endl;
    
    
    
    return 0;
}


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

using namespace std;
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
#define pint(x) printf("%d",x)
#define ps printf(" "); 
#define plint(x) printf("%lld",x)
//#define sort(a,n) qsort(a,n,sizeof(int),cmpfunc)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bg begin()
#define ed end()
#define Set(a, s) memset(a, s, sizeof (a))
#define mod 1000000007
#define tmod(k) if ((k) >= mod) k %= mod;
#define endl '\n'
#define nl printf("\n");
#define fors(i,n) for(int i=0; i<n; i++)
#define fore(i,n) for(int i=n-1; i>=0; i--)
#define forv(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
const int INF = 0x3f3f3f3f;
int cmpfunc (const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}

class node{
public:
	int id;
	int prio;
	int prd;
};

class compare{
public:
	bool operator()(node &n1, node &n2){
		if(n1.prio>n2.prio)//ascending
			return true;
		else if(n1.prio==n2.prio){
			return n1.id>n2.id;
		}
		return false;
	}
};
//priority_queue<node, vector<node>, compare> pq;

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*#ifdef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #else
    // online submission
    #endif*/
    
    int n; int1(n);
   printf("ABC%d",n);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a;
    int ans = 0;
    rep(i, 5){
        int t;cin>>t;
        if(t==0){
            ans = i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3580
#include <algorithm>
#include <array>
#include <bitset>
#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)


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

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

  int N, K, d, A;

  std::cin >> N >> K;

  std::set<int> set;

  for (int i = 0; i < K; i ++) {
    std::cin >> d;

    for (int j = 0; j < d; j ++) {
      std::cin >> A;

      set.insert(A);
    }
  }

  std::cout << N - set.size() << std::endl;

  return 0;
}


Measured memory_bytes: 3648
n = int(input())
S = [int(x) for x in input().split()]
q = int(input())
T = [int(x) for x in input().split()]

res = 0

for key in T:
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if S[mid] == key:
            res += 1
            right = -1
        elif key < S[mid]:
            right = mid
        else:
            left = mid + 1

print(res)

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

void solve(){
    int N;
    cin >> N;

    int sumd = 0, sumsquared = 0;
    for (int i = 0; i < N; i++) {
        int d; cin >> d;
        sumd += d;
        sumsquared += d*d;
    }

    cout << (sumd*sumd - sumsquared) / 2 << endl;

    return;

}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i,c;
  int ans=0;

  for(int i=0;;i++){
    while((c=getchar())!=EOF){
      if(c=='\n')break;
      ans+=c-'0';
    }
    if(ans==0)break;
    printf("%d\n",ans);
    ans=0;
  }
  return 0;
}



Measured memory_bytes: 2092
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
idx = [0]*(n+1)
taboo = set()
ans = n
for _ in range(m-1):
  part = [0]*(m+1)
  for i in range(n):
    while a[i][idx[i]] in taboo:
      idx[i] += 1
    part[a[i][idx[i]]] += 1
  cm = 0
  for j in range(1,m+1):
    if cm < part[j]:
      t = j
      cm = part[j]
  ans = min(ans,cm)
  taboo.add(t)
print(ans)

Measured memory_bytes: 4304
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int N = sc.nextInt();
				int M = sc.nextInt();
				int P = sc.nextInt();
				if(N + M + P == 0) break;
				
				int w = 0;
				int sum = 0;
				boolean win = true;
				for(int i=1; i<=N; i++) {
					int X = sc.nextInt();
					if(i == M) {
						if(X == 0) win = false;
						else  w = X;
					}
					sum += X * 100;
				}
				if(!win) System.out.println(0);
				else {
					sum = sum * (100 - P) / 100;
					System.out.println(sum / w);
				}
			}
		}
	}
}


Measured memory_bytes: 36800
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main() {
 int n,m,c,ans,sum;
  sum=0;
  ans=0;
  cin >> n >> m >> c;
  vector<int> b(m);
  for(int i=0;i<m;i++){
    cin >> b.at(i);
  }
  vector<int> a(m);
  for(int i=0;i<n;i++){
    
    for(int j=0;j<m;j++){
      
      cin >> a.at(j);
      sum=sum+a.at(j)*b.at(j);
    }
    if(sum+c>0){
      ans++;
    }
    sum=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-10-24
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

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

    int base1,base2,base3;
    cin >> base1 >> base2 >> base3;
    bool ans = true;
    for (int i = 0; i < 2; ++i) {
        int a,b,c;
        cin >> a >> b >> c;
        int dif = a - base1;
        if (b - dif != base2 || c - dif != base3) ans = false;
    }

    if (ans) cout << "Yes" << "\n";
    else cout << "No" << "\n";

    return 0;
}



Measured memory_bytes: 256
s=input()
a=[]
b=[]
for i in range(len(s)):
  if i%2==0:
    a.append(0)
  else:
    a.append(1)
    
for i in range(len(s)):
  if i%2==0:
    b.append(1)
  else:
    b.append(0)

a_count=0
b_count=0

for i in range(len(s)):
  if s[i]!=str(a[i]):
    a_count+=1
for i in range(len(s)):
  if s[i]!=str(b[i]):
    b_count+=1
ans=[a_count,b_count]
print(min(ans))




Measured memory_bytes: 47156
from collections import deque
H, W = map(int, input().split())
area = [['#']*(W+2)]
space = 0
for i in range(H):
    temp = ['#']+list(input())+['#']
    for t in temp:
        if t=='.': space+=1 
    area.append(temp)
area.append(['#']*(W+2))
move = ((1, 0), (-1, 0), (0, 1), (0, -1))
    
dq = deque([(1,1)])
dist = [[-1]*(W+2) for _ in range(H+2)]
dist[1][1] = 1
    
while dq:
    nowx, nowy = dq.popleft()
    if (nowx, nowy) == (W, H): break
    for dx, dy in move:
        nxtx, nxty = nowx+dx, nowy+dy
        if not 0<=nxtx<W+2 and 0<=nxty<H+2: continue
        if dist[nxty][nxtx]>=0 or area[nxty][nxtx]=='#': continue
        dist[nxty][nxtx] = dist[nowy][nowx]+1
        dq.append((nxtx, nxty))
if dist[H][W]==-1: print(-1)
else: print(space-dist[H][W])

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

namespace ForATCODER
{
    public class Program
    {
        public static void Main(string[] args)
        {
            long res = 0;
                long[] kn = s2larray(Console.ReadLine().Split(' '));
              int[] am = s2iarray(Console.ReadLine().Split(' '));
            for(int i = 0;i < kn[1];i++)
            {
                kn[0] -= am[i];
            }
            if (kn[0] < 0) { RESULT(-1); return; }
            RESULT(kn[0]);


        }
      
      
        static int s2i(String s)
        {
            return Convert.ToInt32(s);
        }
        static void RESULT(double res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(long res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(ulong res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(int res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(String res)
        {
            Console.WriteLine(res);
        }
        static String[] ReadLineAll(int count)
        {
            String[] res = new String[count];
            for (int i = 0; i < count; i++)
            {
                res[i] = Console.ReadLine();
            }
            return res;
        }

        static int[] s2iarray(String[] src)
        {
            int len = src.Length;
            int[] res = new int[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt32(src[i]);
            }
            return res;
        }
        static long[] s2larray(String[] src)
        {
            int len = src.Length;
            long[] res = new long[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt64(src[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 28560
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>
#include<queue>
#include<cmath>

typedef long long ll;

#define debug(x) cout << #x << '=' << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++){cout << a[i] << ' ';} cout << "\n" << endl;
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)
#define graph vector<vector<ll>>
#define P pair<ll,ll>

using namespace std;

struct step{
    int b,c;
};

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

    vector<int> a(n);
    vector<step> s(m);

    loop(i,n){
        cin >> a[i];
    }

    sort(a.begin(),a.end());

    loop(i,m){
        cin >> s[i].b >> s[i].c;
    }

    sort(s.begin(),s.end(),[](const step& l, const step& r){
        return l.c > r.c;
    });

    int cnt = 0;
    int tmpA = 0;
    int tmpS = 0;
    int tmpB = 0;

    while(1){
        if(a[tmpA] > s[tmpS].c){
            break;
        }
        a[tmpA] = s[tmpS].c;
        tmpA++;
        tmpB++;
        if(tmpB == s[tmpS].b){
            tmpB = 0;
            tmpS++;
        }
        if(tmpS == m)break;
    }

    ll result = 0;
    loop(i,n){
        // debug(a[i]);
        result += a[i];
    }

    cout << result << endl;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int a, b;
    cin >> a >> b;
    if(a <= b){
        puts("unsafe");
    }else{
        puts("safe");
    }
}


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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v ) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
    int n; cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }

    int ans = 0;
    for (int i = 1; i < n-1; ++i) {
        vector<int> tmp{p[i-1],p[i],p[i+1]};
        sort(tmp.begin(), tmp.end());
        if (p[i] == tmp[1]) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int a,b,c,n;
int main() {
while(1){
	bool ok[301]={};
	bool ng[301]={};
	int p[1000][3];
	int s[1000];
	cin >> a >> b >> c >> n;
	if(a==0&&b==0&&c==0)return 0;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin >> p[i][j];
		}
		cin >> s[i];
		if(s[i]){
			for(int j=0;j<3;j++){
				ok[p[i][j]]=true;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(s[i])continue;
		for(int j=0;j<3;j++){
			if(ok[p[i][(j+1)%3]]&&ok[p[i][(j+2)%3]]){
				ng[p[i][j]]=true;
			}
		}
	}
	for(int i=1;i<=a+b+c;i++){
		if(ng[i]){
			cout << 0 << endl;
		}
		else if(ok[i]){
			cout << 1 << endl;
		}
		else{
			cout << 2 << endl;
		}
	}
}
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    string s; cin >> s;
    s += "R";
    vector<int> v(s.size(),0);

    int even = 0;
    int odd = 0;
    int lrpos = 0;
    char lr = 'R';

    REP(i,s.size()) {
        if (lr != s[i]) {
            if (lr == 'R') {
                if (even == odd) {
                    v[i-1] += even;
                    v[i] += odd;
                } else {
                    v[i] += even;
                    v[i-1] += odd;
                }
            } else {    // L
                if (even == odd) {
                    v[lrpos] += even;
                    v[lrpos-1] += odd;
                } else {
                    v[lrpos-1] += even;
                    v[lrpos] += odd;
                }
            }
            odd = 0;
            even = 0;
            lr = s[i];
            lrpos = i;
        }
        
        if (even < odd) {
            even++;
        } else {
            odd++;
        }
    }

    REP(i,s.size()-1) {
        cout << v[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 1104
import sys
import bisect

N = int(sys.stdin.readline())
L = list(map(int, sys.stdin.readline().split()))
L.sort()

count = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        c = bisect.bisect_left(L, L[i]+L[j])
        if c > j:
            count += c - j - 1
        else:
            pass
        
print(count)

Measured memory_bytes: 3188
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	m := make(map[string]int)
	for i := 0; i < N; i++ {
		s := getString()
		m[s]++
	}

	out("AC x", m["AC"])
	out("WA x", m["WA"])
	out("TLE x", m["TLE"])
	out("RE x", m["RE"])
}


Measured memory_bytes: 2080
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	q := getNextInt(scanner)
	m := map[string]int{}
	for i := 0; i < q; i++ {
		t := getNextInt(scanner)
		k := getNextString(scanner)
		switch t {
		case 0:
			m[k] = getNextInt(scanner)
		case 1:
			fmt.Fprintln(writer, m[k])
		case 2:
			delete(m, k)
		}
	}
}



Measured memory_bytes: 19796
#include <bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long
#define ff first
#define ss second
#define pi pair<int,int>

int32_t main() {
	boost;
	int n, m;
	cin >> n >> m;
	pi a[n];
	for(int i = 0; i < n; i++) 
		cin >> a[i].ff >> a[i].ss;
	sort(a , a + n);
	int j = 0, ans = 0;
	priority_queue < int > pq;
	for(int i = 1; i <= m; i++) {
		while(j  < n && a[j].ff <= i) {
			pq.push(a[j].ss);
			j++;
		}

		if(!pq.empty()) {
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}

};

struct union_find {
	vector<int> rnk, par;
	union_find(int n) {
		rnk.resize(n);
		par.resize(n);
		rep(i, rnk.size()) {
			par[i] = i;
			rnk[i] = 0;
		}
	}
	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rnk[x] < rnk[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rnk[x] == rnk[y])rnk[x]++;
		}
	}
	bool same(int x, int y) {
		return (find(x) == find(y));
	}
};

int main() {
	int n, k, l, in1, in2;
	cin >> n >> k >> l;
	union_find u1(n), u2(n);
	rep(i, k) {
		cin >> in1 >> in2;
		u1.unite(in1-1, in2-1);
	}
	rep(i, l) {
		cin >> in1 >> in2;
		u2.unite(in1-1, in2-1);
	}
	map<pii, int> mp;
	rep(i, n) {
		mp[pii(u1.find(i), u2.find(i))]++;
	}
	rep(i, n) {
		cout<<mp[pii(u1.find(i), u2.find(i))]<<(i!=n-1?" ":"\n");
	}
}


Measured memory_bytes: 15104
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<unordered_set>
#include<set>
#include<stack>
using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string A;
	cin >> A;
	int n = A.size();
	unordered_set<char> us;
	stack<int,vector<int>> index;
	index.push(n);
	for (int i = n - 1; i >= 0; --i) {
		us.insert(A[i]);
		if (us.size() == 26) {
			index.push(i);
			us.clear();
		}
	}
	
	string ans;
	int i = 0;
	set<char> s;
	while (index.size()) {
		s.clear();
		for (char c = 'a'; c <= 'z'; ++c) {
			s.insert(c);
		}
		int j = index.top(); index.pop();
		for (int k = i; k < j; ++k) {
			s.erase(A[k]);
		}
		char c = *(s.begin());
		ans += c;
		i = A.find(c, j)+1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
const [A, B, H, M] = input[0].split(' ').map(Number)

const degA = (H * 30) + (M / 60 * 30)
const degB = M * 6

const deg = Math.abs(degA - degB)
const rad = deg * ( Math.PI / 180 )

const height = A * Math.sin(rad)
const width  = A * Math.cos(rad) - B

const ans = Math.sqrt(Math.pow(height, 2) + Math.pow(width, 2))
console.log(ans)


Measured memory_bytes: 29648
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

//int solve() {
//	ll a;
//	double b;
//	cin >> a >> b;
//
//	ll ll_b = ll(b * 100.0);
//	ll ll_b0 = ll_b / 100LL;
//	ll ll_b1 = (ll_b - ll_b0 * 100LL) / 10LL;
//	ll ll_b2 = ll_b - ll_b0 * 100LL - ll_b1 * 10LL;
//
//	ll res = 0;
//	res += a * ll_b1 * 10LL + a * ll_b2;
//	res /= 100LL;
//	res += a * ll_b0;
//
//	cout << res << endl;
//
//	return 0;
//}

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

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

	solve();

	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <cstring>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
using namespace std;
signed main(){
    int n;
    cin>>n;
    vector<pair<int, int> > a(n);
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        a[i]=make_pair(x, y);
    }
    int ans=n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)continue;
            int p=a[i].first-a[j].first;
            int q=a[i].second-a[j].second;
            int t=n;
            for(int k=0;k<n;k++){
                if(k==j)continue;
                for(int l=0;l<n;l++){
                    if(a[k].first-p==a[l].first&&a[k].second-q==a[l].second)t--;
                }
            }
            ans=min(ans,t);
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>


int main(void)
{
	int n,a[200],b[200];
	int i,j,k,s=0,m=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){scanf("%d",&a[i]);}
	for(i=1;i<=n;i++){scanf("%d",&b[i]);}
	for(i=1;i<=n;i++){
		s=0;
		for(j=1;j<=i;j++){s+=a[j];}
		for(j=i;j<=n;j++){s+=b[j];}
		if(s>m){m=s;}
	}
	
	printf("%d\n",m);
	
	return 0;
}




Measured memory_bytes: 128
N=int(input())

ans=[]
NN=10**7

for _ in range(NN):
    if (abs(N))%2==1:
        ans.append("1")
        N-=1
    else:
        ans.append("0")
    if N==0:
        break
    N=(abs(N)//2)*-1*(N//abs(N))
    
print(''.join(map(str, ans[::-1])))


Measured memory_bytes: 38384
import java.util.Scanner;
import java.io.IOException;
public class Main {
	private final static int WHITE=0;
	private final static int GRAY=1;
	private final static int BLACK=2;
	private static int[][] M;
	private static int n;
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		int i,j;
		n=sc.nextInt();
		M = new int[n][n];

//??????????????????
		for(i=0;i<n;i++)
			for(j=0;j<n;j++) M[i][j]=Integer.MAX_VALUE;
		int u,k,v,c;

		for(i=0;i<n;i++){
			u=sc.nextInt();
			k=sc.nextInt();
			for(j=0;j<k;j++){
				v=sc.nextInt();
				c=sc.nextInt();
				M[u][v]=c;
			}
		}

		dicstra();

	}

	public static void dicstra(){
		int[] color = new int[n];
		int[] depth = new int[n];
		int i,j;
		for(i=0;i<n;i++){
			depth[i]=Integer.MAX_VALUE;
			color[i]=WHITE;
		}

		depth[0]=0;
		color[0]=GRAY;
		int mincost;
		int u;
		while(true){
			mincost=Integer.MAX_VALUE;
			u=-1;
			for(i=0;i<n;i++){
				if(color[i]!=BLACK && depth[i]<mincost){
					mincost = depth[i];
					u=i;
				}
			}
			if(mincost==Integer.MAX_VALUE) break;
			color[u]=BLACK;

			for(j=0;j<n;j++){
				if(color[j]!=BLACK && M[u][j]!=Integer.MAX_VALUE){
					if(depth[j]>depth[u]+M[u][j]){
						depth[j]=depth[u]+M[u][j];
						color[j]=GRAY;
					}
				}
			}

		}
		for(i=0;i<n;i++){
			System.out.println(i+" " + (depth[i]==Integer.MAX_VALUE ? -1 : depth[i]));
		}
	}
}

Measured memory_bytes: 31840