akhauriyash/Code-Regression huggingface dataset:
/*---> 11 January 2020 <--- > 05:06:05 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i+2<n;i++){
		if(s.substr(i,3)=="ABC")
			ans++;
	}
	cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 256
"""
BellmanFord
"""

INF = 10 ** 20

v_num, e_num, r = map(int, input().split())
dist_lst = [INF for _ in range(v_num)]
edges_lst = [[] for _ in range(e_num)]
negative_cycle_flag = False

for _ in range(e_num):
  s, t, dist = map(int, input().split())
  edges_lst[s].append((dist, t))

dist_lst[r] = 0

if e_num != 0:
  for _ in range(v_num):
    for v in range(v_num):
      if dist_lst[v] != INF:
        for dist, to in edges_lst[v]:
          if dist_lst[v] + dist < dist_lst[to]:
            dist_lst[to] = dist_lst[v] + dist
  
  for v in range(v_num):
    if dist_lst[v] != INF:
      for dist, to in edges_lst[v]:
        if dist_lst[v] + dist < dist_lst[to]:
          negative_cycle_flag = True
          break
      if negative_cycle_flag:
        break

if negative_cycle_flag:
  print("NEGATIVE CYCLE")
else:
  for dist in dist_lst:
    if dist == INF:
      print("INF")
    else:
      print(dist)


Measured memory_bytes: 6108
[A, B, K] = list(map(int, input().split(' ')))

smaller = min(A, B)
divisor = [1]
for divisor_cdd in range(2, smaller + 1):
    if A % divisor_cdd == 0 and B % divisor_cdd == 0:
        divisor.append(divisor_cdd)

print(divisor[-K])


Measured memory_bytes: 2940
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;
typedef long double ld;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=998244353;

void solve(){
	ll n,m;
	cin>>n>>m;

	vector<vector<ll>> gra(n);
	for(ll i=0;i<m;i++){
		ll a,b;
		cin>>a>>b;
		a--;
		b--;
		gra[a].push_back(b);
		gra[b].push_back(a);
	}

	vector<ll> sign(n,0);
	queue<ll> que;

	vector<ll> seen(n,-1);
	seen[0]=0;
	que.push(0);

	while(!que.empty()){
		ll v=que.front();

		for(ll next:gra[v]){
			if(seen[next]!=-1){
				continue;
			}

			seen[next]=seen[v]+1;
			sign[next]=v+1;
			que.push(next);

		}

		que.pop();
	}

	cout<<"Yes"<<endl;
	for(ll i=1;i<n;i++){
		cout<<sign[i]<<endl;
	}

}


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


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

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b - a - b + 1 << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

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

    vector<long long> a(n);
    set<long long> T;

    for(long long i = 0; i < n; i++){
        cin >> a[i];
        T.insert(a[i]);
    }

    if(T.size() % 2 != 0){
        cout << T.size() << endl;
    }
    else{
        cout << T.size()-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 8680
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main() {

	int n, count = 0;

	cin >> n;

	vector<int> p(n);

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

	for (int i = 1; i < n - 1; i++) {
		if (p[i] < p[i + 1] && p[i] > p[i - 1]) {
			count++;
		}
		else if
			(p[i] > p[i + 1] && p[i] < p[i - 1]) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/agc034/tasks/agc034_b

s = input()
s = s.replace('BC', 'X')
ans = 0
a = 0
for i in range(len(s)):
    if s[i] == 'A':
        a += 1
    elif s[i] == 'X':
        ans += a
    else:
        a = 0
print(ans)

Measured memory_bytes: 41968
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
	double x1,y1,x2,y2;
	double a,b,c;
	cin>>x1>>y1>>x2>>y2;;
	
	b = fabs( x1-x2 );
	c = fabs( y1-y2 );
	
	a = sqrt( pow( b, 2 ) + pow( c, 2 ) );
	cout.setf( ios::fixed );
	cout<<a<<endl;

	return 0;
}



Measured memory_bytes: 3284
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
A =[-a for a in A]

heapq.heapify(A)
  
for i in range(M):
  curr = -heapq.heappop(A)
  heapq.heappush(A, -(curr//2))
  
print(-sum(A))

Measured memory_bytes: 14180
import math
A, B, N = map(int, input().split())

if (B == 1):
  print(0)
elif (B > N+1):
  x = N
  print((A*x)//B-A*(x//B))
else:
  x = N-N%(B-1)
  print((A*x)//B-A*(x//B))

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> cnt1(100005), cnt2(100005);
	rep(i, n) {
		int a;
		cin >> a;
		if (i % 2 == 1) cnt2[a]++;
		else cnt1[a]++;
	}
	vector<int> p(100005);
	iota(p.begin(), p.end(), 0);
	vector<int> p_(100005);
	iota(p_.begin(), p_.end(), 0);
	sort(p.begin(), p.end(), [&](const auto& x, const auto& y) {
		return cnt1[x] > cnt1[y];
		});
	sort(p_.begin(), p_.end(), [&](const auto& x, const auto& y) {
		return cnt2[x] > cnt2[y];
		});
	if (p.front() == p_.front()) {
		int ans = n - cnt1[p[0]];
		if (cnt1[p[1]] >= cnt2[p_[1]]) ans -= cnt1[p[1]];
		else ans -= cnt2[p_[1]];
		cout << ans << endl;
	}
	else {
		int ans = n - cnt1[p.front()] - cnt2[p_.front()];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4760
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static int h, w;
	static char[][] t;

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

	static int ny(int y, int dir) {
		int ny = y + dy[dir] + h;
		return ny%h;
	}

	static int nx(int x, int dir) {
		int nx = x + dx[dir] + w;
		return nx%w;
	}

	static String rec(int cy, int cx, int sy, int sx, int dir) {
		if (cy == sy && cx == sx) return "";
		int ny = ny(cy, dir);
		int nx = nx(cx, dir);
		return t[cy][cx] + rec(ny, nx, sy, sx, dir);
	}

	static boolean solve() {
		h = in.nextInt();
		w = in.nextInt();
		if (h + w == 0) return false;

		t = new char[h][w];
		for (int i=0; i<h; i++) {
			t[i] = in.next().toCharArray();
		}
		ArrayList<String> list = new ArrayList<>();

		for (int i=0; i<h; i++) {
			for (int j=0; j<w; j++) {
				for (int k=0; k<8; k++) {
					String s = t[i][j] + rec(ny(i, k), nx(j, k), i, j, k);
					list.add(s);
				}
			}
		}

		Collections.sort(list);
		String ans = "";
		int max = 0;
		for (int i=0; i<list.size()-1; i++) {
			int n = list.get(i).length();
			int m = list.get(i+1).length();
			int l = Math.min(n, m);
			int x = 0;
			for (int j=0; j<=l; j++) {
				if (j == l || list.get(i).charAt(j) != list.get(i+1).charAt(j)) {
					x = j;
					break;
				}
			}
			if (max <= x) {
				String s = list.get(i).substring(0, x);
				if (max < x || ans.compareTo(s) > 0) {
					ans = s;
				}
				max = x;
			}
		}


		if (max < 2) {
			out.println(0);
		} else {
			out.println(ans);
		}

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 159412
#include<queue>
#include<cstdio>

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

using namespace std;

typedef	pair<int,int>	pii;

int n,a[2][100];

pii climb(pii p){
	int bldg=p.first,pos=p.second;
	for(int y=pos;y<n-1;y++) if(!(a[bldg][y]==1 && a[bldg][y+1]==1)) return mp(bldg,y);
	return mp(bldg,n-1);
}

pii slip(pii p){
	int bldg=p.first,pos=p.second;
	for(int y=pos;y>0;y--) if(a[bldg][y]!=2) return mp(bldg,y);
	return mp(bldg,0);
}

int main(){
	for(;scanf("%d",&n),n;){
		rep(i,2)rep(j,n)	scanf("%d",a[i]+j);

		int ans=-1;
		bool visited[2][100]={};
		queue< pair<int,pii> > qu;	qu.push(mp(0,mp(0,0))),qu.push(mp(0,mp(1,0)));
		while(!qu.empty()){
			pair<int,pii> aa=qu.front();	qu.pop();
			int cnt=aa.first;
			pii p=aa.second;
			p=slip(climb(p));
			int bldg=p.first,pos=p.second;
			if(pos==n-1){ ans=cnt; break; }
			if(visited[bldg][pos])	continue;
			visited[bldg][pos]=true;

			rep(h,3)if(pos+h<n){
				int nextpos=pos+h;
				qu.push(mp(cnt+1,mp(!bldg,nextpos)));
			}
		}

		if(~ans)	printf("%d\n",ans);
		else		puts("NA");
	}

	return 0;
}

Measured memory_bytes: 0
# include <string.h>
# include <iostream>
#include <bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
    vector<int> v;
	int N = 0;
	int ticket = 0;
	cin >> N >> ticket;
	
	int temp = -1;
	
	for ( int i = 0; i < N; i++ ) {
		cin >> temp;
		v.push_back(temp);
	} // for
	
	sort(v.begin(), v.end());
 
	
	for ( int i = 0; i < ticket; i++ ) {
		int now = v.back();
		v.pop_back();
		now /= 2;
		v.insert(std::lower_bound(v.begin(), v.end(), now), now);
	} // for
	 
	long long int total = 0; 
    for ( int i = 0; i < N ; i++ ) 
        total += v[i];
		
	cout << total; 
  
} // main()

Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int A[] = new int[(n < q ? q : n)];
		int AC[] = new int[(n < q ? q : n)];

		for (int i = 0; i < q; i++)
			A[i] = sc.nextInt();
		for (int i = 0; i < (n < q ? q : n); i++)
			AC[i] = k - q;
		for (int i = 0; i < (n < q ? q : n); i++)
			if (i < q)
				AC[A[i] - 1] += 1;
		for (int i = 0; i < n; i++) {
			if (AC[i] <= 0)
				System.out.println("No");
			else
				System.out.println("Yes");
		}
	}
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define vint vector<int>
#define vvint vector<vector<int>>

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  int r;cin >> r;
  if(r<1200) cout << "ABC" << endl;
  else if(r<2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;

  return 0;
}


Measured memory_bytes: 256
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
cnt=0
cnt2=0
for x in a:
	cnt+=x**2
	cnt2+=x
	cnt%=mod
	cnt2%=mod
ans=cnt2**2%mod-cnt
if ans%2==1:
	ans+=mod
ans=ans//2%mod
print(ans)

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

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

    int n;
    cin >> n;
    int p[static_cast<int>(2 * 1e5 + 1)] = {};
    int tmp;
    for (int i = 0; i < n; ++i) {
        cin >> tmp;
        p[tmp] = p[tmp - 1] + 1;
        p[tmp - 1] = 0;
    }
    sort(p + 1, p + n + 1);

    cout << n - p[n] << '\n';

    return 0;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  int a[m];
  int sum = 0;
  
  for(int i=0; i<m; ++i){
    cin >> a[i];
    sum += a[i];
  }

  if(sum > n){
    cout << "-1";
    return 0;
  }

  cout << n - sum;
  
  return 0;
}


Measured memory_bytes: 3660
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

const int max_n=10,max_d=10;
int n,d;
int x[max_n+1][max_d+1];
int ans=0;

void solve(){
    int sum=0;
    rep(i,n-1){
        for(int j=i+1;j<n;j++){
            sum=0;
            rep(k,d){
                sum+=pow(x[i][k]-x[j][k],2);
            }
            for(int k=0;k*k<=sum;k++){
                if(k*k==sum) ans++;
            }
        }
    }
    cout<<ans;
}

int main(){
    cin>>n>>d;
    rep(i,n){
        rep(j,d) cin>>x[i][j];
    }
    solve();
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    vector<vector<int>>xy(n,vector<int>(n,-1));

    rep(i,n){
        int a;
        cin>>a;

        rep(j,a){
            int x,y;
            cin>>x>>y;

            x--;

            xy[i][x]=y;
        }
    }

    int ans=0;

    rep(i,1<<n){
        bool jdg=true;
        int cnt=0;

        rep(j,n){
            if (i&(1<<j)){
                cnt++;
                rep(k,n){
                    if(xy[j][k]==1){
                        if(!(i&(1<<k)))jdg=false;
                    }

                    else if(xy[j][k]==0){
                        if(i&(1<<k))jdg=false;
                    }
                }
            }
        }

        if(jdg){
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;

ll ans,mx,mn=1e10,sum;
int main(){
	ll n;
	cin>>n;
	for(int i=0; i<n; i++){
		ll a;
		cin>>a;
		mx=max(mx,a);
		mn=min(mn,a);
	}
	cout<<abs(mx-mn);
} 

Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int,input().split()))
l = [1]*n
for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if h[a] <= h[b]:
        l[a] = 0
    if h[b] <= h[a]:
        l[b] = 0
ans = sum(l)
print(ans)

Measured memory_bytes: 20064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef vector<vector<int>> MX;

const ll MOD=1e9+7;
const int INF = 100000000;

int main()
{
	int N,M,K;
	bool ok=false;
	cin>>N>>M>>K;
	for(int i=0;i<=N;i++)
	{
		int cnt=i*M;
		for(int j=0;j<=M;j++)
		{
			cnt=cnt-i+(N-i);
			if(cnt==K)ok=true;
		}
	}
	cout<<(ok?"Yes":"No")<<endl;
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i = 1;;i++){
            int x = sc.nextInt();
            if(x != 0){
                System.out.println("Case "+i+": "+x);
            }
            else{
                break;
            }
        }
    }
}


Measured memory_bytes: 41772
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int S;
		int h, m ,s;
		
		S = scan.nextInt();
		
		h = S / 3600;
		m = S % 3600 / 60;
		s = S % 3600 % 60;	
		System.out.println(h + ":" + m + ":" + s);
	}

}

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

using ll = long long;

// 各桁の数の和
int digitSum(ll x) {
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int k;
  cin >> k;
  
  vector<ll> x;
  for (ll i = 0; i < 15; i++) {
    ll keep = pow(10, i);
    for (ll j = 1; j <= 150; j++) {
      x.emplace_back(keep * j + keep - 1);
    }
  }
  
  sort(x.begin(), x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  
  vector<bool> judge(x.size(), true);
  for (int i = 0; i < x.size() - 1; i++) {
    for (int j = i + 1; j < x.size(); j++) {
      if ((double) x.at(i) / digitSum(x.at(i)) > (double) x.at(j) / digitSum(x.at(j))) {
        judge.at(i) = false;
        break;
      }
    }
  }
  
  int it = 0;
  for (int i = 0; i < k; i++) {
    while (!judge.at(it)) it++;
    cout << x.at(it) << '\n';
    it++;
  }
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nr = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nr[0];
        var r = nr[1];

        Console.WriteLine(n < 10 ? r + 100 * (10 - n) : r);
    }
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> cnt(M,0);
  for ( int i = 0; i < N ; ++ i ) {
    int K; cin >> K ;
    for ( int j = 0; j < K ; ++ j ) {
      int A; cin >> A ; --A ; //配列cntは0〜M-1なのでここで-1している
      ++ cnt [ A ]; //M種類の食べ物に対して好きな人数をcnt
    }
  }
  int ans = 0;
  for ( int i = 0; i < M ; ++ i ) {
    if ( cnt [ i ] == N ) {
      ++ ans ;
    }
  }
  cout << ans << endl ;
  return(0);
}

Measured memory_bytes: 256
/*
 
*/ 
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // FOR QUERY PROBLEM DON'T FORGET TO UNCOMMENT THIS
    string str;
    cin >> str;
    int rem = 0;
    for(auto& ch : str)
    {
        rem += (ch-'0');
        rem %= 9;
    }
    (rem == 0) ? cout << "Yes\n" : cout << "No\n";
    return 0;
}
 
/*
 
*/  

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


int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        for(int i = 1; i <= N; i++) {
            if(!(bits & (1 << (i-1)))) continue;
            for(int j = 1; j <= A[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 256
using System;
using System.Linq;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            var x = int.Parse(string.Join("",s));  

            Console.WriteLine(x % 4 == 0 ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 11092
n = gets.to_i
a = n.times.map{gets.split.map(&:to_i)}

total_games = n * (n - 1) / 2
games = 0
today_games = 0
day = -1
today_played = {}
yesterday_played = {}
played_count = Array.new(n, 0)

for i in 0...n do
  if !today_played.include?(i)
    j = a[i][played_count[i]] - 1
    if !today_played.include?(j) && a[j][played_count[j]] - 1 == i
      today_played[i] = 1
      today_played[j] = 1
      played_count[i] += 1
      played_count[j] += 1
      today_games += 1
    end
  end
end

if today_games > 0
  games += today_games
  day = 1
  while games < total_games do
    yesterday_played = today_played
    today_played = {}
    today_games = 0
    yesterday_played.each_key do |i|
      if played_count[i] < n - 1 && !today_played.include?(i)
        j = a[i][played_count[i]] - 1
        if played_count[j] < n - 1 && !today_played.include?(j) && a[j][played_count[j]] - 1 == i
          today_played[i] = 1
          today_played[j] = 1
          played_count[i] += 1
          played_count[j] += 1
          today_games += 1
        end
      end
    end
    if today_games == 0
      day = -1
      break
    else
      games += today_games
    end
    day += 1
  end
end
puts day


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

typedef __int128 ll;
typedef long double ld;

const ll P = 75161927681ll;
const int N = (1 << 20);

inline ll add(ll x, ll y) {x += y; return x >= P ? x - P : x;}
inline ll sub(ll x, ll y) {x -= y; return x < 0 ? x + P : x;}
inline ll mul(ll x, ll y) {return x * y % P;}
ll mpow(ll b, ll p) {
    ll r; for(r = 1; p; p >>= 1, b = mul(b, b))
        if( p & 1 ) r = mul(r, b);
    return r;
}

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

ll w[N + 5], iv[N + 5]; int lg[N + 5];
void ntt(ll *A, int n, int type) {
	for(int i=0,j=0;i<n;i++) {
		if( i < j ) swap(A[i], A[j]);
		for(int k=(n>>1);(j^=k)<k;k>>=1);
	}
	for(int s=2,t,u,p;s<=n;s<<=1) {
		t = (s >> 1), u = N / s;
		for(int i=0;i<n;i+=s) {
			p = (type == 1 ? 0 : N); ll q = A[i + t];
			for(int j=0;j<t;j++,p=(type==1?p+u:p-u),q=mul(A[i+j+t],w[p]))
				A[i + j + t] = sub(A[i + j], q), A[i + j] = add(A[i + j], q);
		}
	}
	if( type == -1 ) rep(i, 0, n) A[i] = mul(A[i], iv[n]);
}

const int G = 2;
const int PK = 200003;

int ind[PK + 5], pw[PK + 5];

void init() {
	w[0] = iv[1] = 1, w[1] = mpow(3, (P - 1) / N);
	for(int i=2;i<=N;i++) {
		w[i] = mul(w[i - 1], w[1]), lg[i] = lg[(i + 1) >> 1] + 1;
		iv[i] = sub(0, mul(P / i, iv[P % i]));
	}
	
	for(int i=0,p=1;i<PK-1;p=G*p%PK,i++)
		ind[p] = i, pw[i] = p;
}

ll res[N + 5], cnt[N + 5];

int main() {
	init(); int n; scanf("%d", &n);
	for(int i=1,x;i<=n;i++) {
		scanf("%d", &x);
		if( x ) cnt[ind[x]]++;
	}
	int l = (1 << lg[PK + PK]);
	ntt(cnt, l, 1);
	for(int i=0;i<l;i++) res[i] = mul(cnt[i], cnt[i]);
	ntt(res, l, -1), ntt(cnt, l, -1);
	
	ll ans = 0;
	for(int i=0;i<=2*PK;i++)
		ans += res[i] * pw[i % (PK - 1)];
	for(int i=0;i<=PK;i++)
		ans -= cnt[i] * pw[(2 * i)%(PK - 1)];
	printf("%lld\n", (long long)(ans / 2));
}

Measured memory_bytes: 58508
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    int r, c;
    while(cin >> r >> c, r||c) {
        if (r % 2 == 0 || c % 2 == 0) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	string s;
	long long k,a[100],i,len;
	while(cin>>s>>k){
		len=s.length();
		for(i=0;i<len;i++){
			a[i]=s[i]-'0';
		}
		for(i=0;i<len;i++){
			k-=pow(a[i],5e15);
			if(k<=0){
				cout<<a[i]<<endl;
				break;
			}
		} 
	}
	return 0;
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
  val (k, s) = readLine()!!.split(" ").map(String::toInt)
  var count = 0

  for(i in 0..k) {
    for(j in 0..k) {
      if(s >= i + j && s <= i + j + k)
        count++
    }
  }

  println(count)
}


Measured memory_bytes: 36232
n = int(input())
monsters = list(map(int, input().split()))
savers = list(map(int, input().split()))
ko = 0

for i in range(n):
    left = min(monsters[i], savers[i])
    ko += left
    monsters[i] -= left
    savers[i] -= left

    right = min(monsters[i+1], savers[i])
    ko += right
    monsters[i+1] -= right
    savers[i] -= right

print(ko)

Measured memory_bytes: 19116
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N, a;
    cin >> N;
    vector<int> student(N);
    for (int i = 0; i < N; i++){
        cin >> a;
        student[a - 1] = i+1;
    }
    for(int s : student)
        cout << s << " ";
    cout << endl;
}

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

using namespace std;

int N, Q;
int const INF = INT_MAX;

set<char> setMerge(set<char> &a,set <char> &b){
	set<char> rtn;
	for(auto &e:a)rtn.insert(e);
	for(auto &e:b)rtn.insert(e);
	return rtn;
}

struct SegmentTree {
private:
    int n;
    vector<set<char>> node;

public:
    SegmentTree(string &s) {
        int sz = s.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        for(int i=0; i<sz; i++) node[i+n-1].insert(s.at(i));
        for(int i=n-2; i>=0; i--) node[i] = setMerge(node[2*i+1], node[2*i+2]);
    }

    void update(int x, char val) {
        x += (n - 1);
        node[x].clear();
        node[x].insert(val);
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = setMerge(node[2*x+1], node[2*x+2]);
        }
    }

    set<char> getmin(int a, int b, int k=0, int l=0, int r=-1) {
    	set<char> s;
    	s.clear();
        if(r < 0) r = n;
        if(r <= a || b <= l) return s;
        if(a <= l && r <= b) return node[k];

        set<char> vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        set<char> vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return setMerge(vl, vr);
    }
};
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n;
	string s;
	cin>>n>>s;

	SegmentTree tree(s);

	lli q;
	cin>>q;

	REP(i,0,q){
		lli k;
		cin>>k;
		if(k==1){
			lli index;
			char a;
			cin>>index>>a;
			tree.update(index-1,a);
		}
		else{
			lli x,y;
			cin>>x>>y;
			x--,y--;
			cout<<tree.getmin(x,y+1).size()<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 190596
#include <bits/stdc++.h>
#define N 50000

using namespace std;

typedef long long int ll;

ll i,j,k,x,z,p,q,M,co,b,c;
double a,y;
string str,str1;
vector<ll>veca;
ll suma[N+5];

void sum()
{
    z = 0;
    for (i=1;i<=N;i++)
    {
        z += (i*i*i);
        suma[i]=z;
    }
}

int main()
{
    //sum();
    cin >> str >> str1;
    for (i=0;i<3;i++)
    {
        if (str[i]==str1[i])
            c++;
    }
    cout << c << endl;
    //fclose(stdout);
}


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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  string s;cin>>s;
  map<char,int> map;
  int cnt=0;
  rep(i,4){
    auto itr = map.find(s[i]);
    if(itr == map.end() && cnt>=2) {
      cout<<"No"<<endl;
      return 0;
    } else if(itr != map.end() ) {
      map[s[i]]++;
      if(map[s[i]]>=3){
        cout<<"No"<<endl;
        return 0;
      }
    } else if(itr == map.end() ) {
      map[s[i]]=1;
      cnt++;
    }
  }
  cout<<"Yes"<<endl;
}


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

typedef pair<int, int> PII;

const int MAX_N = 110;
const int MAX_H = 25;
const int INF = 1e9;

struct edge{
  int to, cost, hour, r;
  edge(int to, int cost, int hour, int r):
    to(to), cost(cost), hour(hour), r(r){}
};

struct State{
  int v, hour, cost;
  State(int v, int hour, int cost):
    v(v), hour(hour), cost(cost){}
};

int N, M, H, K;
vector<edge> G[MAX_N];
vector<PII> V;
int S, T, P;
int money[(1<<8)];
int dp[MAX_H][MAX_N];

void init(){
  for(int i = 0 ; i < MAX_N ; i++) G[i].clear();
  V.clear();
  fill(money, money+(1<<8), INF);
}

int solve(int bit){
  for(int i = 0 ; i < MAX_H ; i++)
    for(int j = 0 ; j < MAX_N ; j++) dp[i][j] = INF;

  queue<State> que;
  que.push(State(S, 0, 0));  

  dp[0][S] = 0;
  
  while(!que.empty()){
    State q = que.front(); que.pop();
    
    int v = q.v;
    for(int i = 0 ; i < (int)G[v].size() ; i++){

      int r = G[v][i].r;
      int nexv = G[v][i].to;
      int nexh = q.hour + G[v][i].hour;      
      int nexc;
      
      nexc = q.cost + G[v][i].cost;
      if((bit>>r) & 1) nexc = q.cost;
      
      if(nexh > H) continue;
      
      if(dp[nexh][nexv] > nexc){     
	dp[nexh][nexv] = nexc;
	
	que.push(State(nexv, nexh, nexc));
      }
    }    
  }
  int ret = INF;
  for(int i = 0 ; i <= 24 ; i++) ret = min(ret, dp[i][T]);
  return ret;
}

void rec(int bit, int cost){
  if(money[bit] <= cost) return;
  money[bit] = cost;
  for(int i = 0 ; i < (int)V.size() ; i++){
    int t = bit | V[i].first;
    if(t == bit) continue;
    rec(t, cost + V[i].second);
  }
}

int main(){
  while(cin >> N >> M >> H >> K, N|M|H|K){
    init();
    
    int from, to, cost, hour, r;
    for(int i = 0 ; i < M ; i++){
      cin >> from >> to >> cost >> hour >> r;
      from--, to--, r--;
      G[from].push_back(edge(to, cost, hour, r));
      G[to].push_back(edge(from, cost, hour, r));
    }
    
    cin >> S >> T;
    S--, T--;
    cin >> P;
    
    for(int i = 0 ; i < P ; i++){
      int l, d;
      cin >> l >> d;
      int k;
      int bit = 0;
      for(int j = 0 ; j < l ; j++){
	cin >> k;
	k--;
	bit += (1<<k);
      }      
      V.push_back(PII(bit, d));
    }
    
    rec(0, 0);
    
    int ans = INF;
    for(int i = 0 ; i < (1<<K) ; i++){
      ans = min(ans, solve(i) + money[i]);
    }
    
    cout << (ans == INF ? -1 : ans) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int count;
  for(int i=1;i<=n;i++){
    if(i%2==1){
      count++;
    }
  }
  cout << (double)count/n << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC085A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            s = Console.ReadLine();
            char[] cs = s.ToCharArray();
            cs[3] = '8';
            Console.WriteLine(cs);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let m:usize = read();
    let mut arr = vec![0; m];
    for _ in 0..n {
        let k:usize = read();
        for _ in 0..k {
            let x:usize = read();
            arr[x-1] += 1;
        }
    }
    println!("{}", arr.iter().filter(|&&x| x == n).count());
}


Measured memory_bytes: 2124
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define ed "\n";
typedef long long ll;
//最大公約数
ll e_gcd(ll a, ll b) {
  if(a < b) return e_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >>d;
    cerr << e_gcd(c,d) << ed;
    cout << (b-((b/c)+(b/d)-(b/((c*d)/e_gcd(c,d))))) -((a-1)-(((a-1)/c)+((a-1)/d)-(a-1)/((c*d)/e_gcd(c,d)))) << ed;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S; cin >> S;
	int n = (int)S.length();
	int res = 0;
	rep (i, n){
		for (int j = i; j < n; ++j){
			string curr = S.substr(i, j-i+1);
//			cerr << "curr: " << curr << endl;
			int m = (int)curr.length();
			bool ok = true;
			rep (k, m){
				if (curr[k] == 'A' || curr[k] == 'C' || curr[k] == 'G' || curr[k] == 'T'){
					ok &= true;
				}else{
					ok = false;
				} // end if
			} // end rep
			if (ok){
				if (res < m){
//					cerr << "curr: " << curr << endl;
					res = m;
				} // end if
			} // end if
		} // end for
	} // end rep

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (ll)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0, m = 0;
	rep(i,n) {
		if (m > a[i]) ans += m - a[i];
		else m = a[i];
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int N, min=INT_MAX, max=INT_MIN, P=INT_MAX;
	cin>>N;
	vector<int> X(N);
	for(int i=0; i<N; i++)
	{
		cin>>X[i];
		
		if(X[i]<min) min=X[i];
		if(X[i]>max) max=X[i];
	}
	
	for(int i=min; i<=max; i++)
	{
		int currCost=0;
		for(int j=0; j<N; j++)
		{
			currCost+=(X[j]-i)*(X[j]-i);
		}
		
		if(currCost<P) P=currCost;
	}
	
	cout<<P;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;





int main(void) {
    
    int n;
    cin>>n;
    vpii r(n),b(n);
    rep(i,n){
        int aa,ba;
        cin>>aa>>ba;
        r[i]=mp(aa,ba);
    }
    rep(i,n){
        int aa,ba;
        cin>>aa>>ba;
        b[i]=mp(ba,aa);
    }
    Sort(b);
    Rort(r);
    rep(i,n)swap(b[i].first,b[i].second);
    int ans=0;
    for(int i=0;i<n;i++){
        //rのループ
        for(int j=0;j<n;j++){
            // cout<<b[j].first<<" "<<r[i].first<<" "<<b[j].second<<" "<<b[j].second<<endl;
            if(b[j].first>r[i].first&&b[j].second>r[i].second){
                // cout<<r[i].first<<" "<<r[i].second<<" "<<b[j].first<<" "<<b[j].second<<endl;
                b[j].first=-1;
                b[j].second=-1;
                ans++;
                break;
            }
        }
    }
    fin(ans);


    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>

#define pb push_back
#define int long long
#define ld long double
using namespace std;
const int M = 1000000007;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, a;
    cin >> n >> a;
    __int128 ANS = n + a;
    for (int x = 2; x <= min(n, (int) 2000000); x++) {
        int p = 1;
        int lol = 0;
        while (p <= n) {
            int rest = (n + p - 1) / p;
            int kek = 0;
            int heh = 1;
            while (heh < rest) {
                heh *= x;
                kek++;
            }
            __int128 bruh = x * kek + (x - 1) * lol + a * (kek + lol);
            ANS = min(ANS, bruh);
            p *= (x - 1);
            lol++;
            if (x == 2) break;
        }
    }
    ANS -= a;
    cout << (int) ANS << '\n';
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#define endl "\n"

using namespace std;
const unsigned long long c=1e18;
void solve()
{
    int n,d=-1; cin >> n; unsigned long long a=1;
    unsigned long long arr[n];
    for (int i=0;i<n;++i){
    cin >> arr[i];}
    sort(arr,arr+n);
    if(arr[0]==0){ cout<<0; return;}
    else for (int i=0;i<n;++i){
    if(arr[i]>c/a)
    {
        cout << d;return;
    }
    a*=arr[i];
    }
    cout <<a;
}

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


Measured memory_bytes: 4440
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <numeric>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int gcd(int a,int b){
	int tmp;
	if(a<b){
		tmp = a;
		a = b;
		b = tmp;
	}
	int r;
	while(a%b){
		r = a % b;
		a = b;
		b = r;
	}
	return b;
}

int main(){
	int N;
	cin >> N;
	int A[N];
	rep(i,0,N) cin >> A[i];
	int ans = A[0];
	rep(i,1,N) ans = gcd(ans,A[i]);
	cout << ans << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

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

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

const ll MOD = 1000000007;
const ll INF = 10000000;

int n;

int main(void){
 
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++){
        ll a;
        cin >> a;

        for (int j = 0; j < 100; j++){
            if (a % 2 == 0){
                a /= 2;
                ans++;
            }

        }
    }

    cout << ans << endl;

  




}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        a[i] = i + 1;
    }
    do
    {
        for (int i = 0; i < n; i++)
        {
            cout << a[i] << " \n"[i == n - 1];
        }
    } while (next_permutation(a, a + n));
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

char fi[100][100];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b; cin >> a >> b;
    cout << 100 << " " << 100 << endl;
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            if(i<50)fi[i][j]='#';
            else fi[i][j]='.';
        }
    }
    a--; b--;
    for(int i=0;i<50;i++){
        for(int j=0;j<100;j++){
            if(a==0)break;
            if(i%2==0&&j%2==0){
                fi[i][j]='.';
                a--;
            }
        }
        if(a==0)break;
    }
    for(int i=51;i<100;i++){
        for(int j=0;j<100;j++){
            if(b==0)break;
            if(i%2==0&&j%2==0){
                fi[i][j]='#';
                b--;
            }
        }
        if(b==0)break;
    }
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            cout << fi[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
using ll = long long;
const ll mxn = 100010;
ll dp[mxn], tmp[mxn], ans[mxn], mod;
ll N;

vector<ll> adj[mxn], pre[mxn], suff[mxn], children[mxn];

void dfs_dp(ll node, ll parent) {
	for(auto x:adj[node])
		if(x!=parent) dfs_dp(x, node);

	dp[node] = 1ll; 
	for(auto x:adj[node])
		if(x!=parent) {
			dp[node]*=(dp[x]+1ll);
			dp[node]%=mod;
			children[node].push_back(x);
		}
}

void calc_pre_suff() {
	for(ll node=1; node<=N; node++) {
		ll sz = (ll) children[node].size();
		if(!sz or sz==1) continue;
		pre[node].resize(sz);
		suff[node].resize(sz);
		pre[node][0] = (dp[children[node][0]]+1)%mod;
		for(ll i=1; i<sz; i++)
			pre[node][i] = pre[node][i-1]*(dp[children[node][i]]+1)%mod;
		suff[node][sz-1] = dp[children[node][sz-1]]+1;
		for(ll i=sz-2; i>=0; i--)
			suff[node][i] = suff[node][i+1]*(dp[children[node][i]]+1)%mod;
	}
}

ll get_range(ll node, ll idx) {
	ll sz = (ll) children[node].size();
	if(sz==1) return 1ll;
	if(idx==0) return suff[node][1]%mod;
	if(idx==sz-1) return pre[node][sz-2]%mod;
	return suff[node][idx+1]*pre[node][idx-1]%mod;
}


void dfs_ans(ll node, ll parent, ll val_of_parent=0ll) { 
	ans[node] = (val_of_parent+1)%mod;
	for(auto x:adj[node])
		if(x!=parent) ans[node]*=(dp[x]+1), ans[node]%=mod;

	for(ll i=0; i<(ll) children[node].size(); i++) {
		ll next = children[node][i];
		ll new_val = ((val_of_parent+1)%mod)*get_range(node, i)%mod;
		dfs_ans(next, node, new_val%mod);
	}
}

void process(ll root) {
	dfs_dp(root, -1);
	calc_pre_suff();
	dfs_ans(root, -1);
}

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

	cin>>N>>mod;
	for(ll i=0; i<N-1; i++) {
		ll x, y; cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	process(N);

	for(ll i=1; i<=N; i++)
		cout << ans[i]%mod << '\n';

	return 0;
}

Measured memory_bytes: 26112
# -*- coding:utf-8 -*-
"""解説
Union-Find

i番目の辺(ai, bi)を除く全ての辺を使ってUnion-Find木を作る。

その後、ai と bi がつながっているかを判定する。つながっていないならば、ai,biの辺は橋である。

この操作をすべてのiにおいて全探索する。

【計算量】
たぶんO(M(N+M))

Union-Findによるあるノード(a, b)が同じグループかどうか（今回では、同じグループ＝繋がっている）
の判定は高速でできる。

"""
class UnionFind():
    def __init__(self, N):
        """ N個のノードのUnion-Find木を作成する """
        # 親の番号を格納する。自分が親だった場合は、自分の番号になり、それがそのグループの番号になる
        self.parent = [n for n in range(0, N)]
        # グループの深さ
        self.depth = [1] * N

    def find(self, x):
        """ 木の根(どのグループか)を求める """
        if self.parent[x] == x: return x
        self.parent[x] = self.find(self.parent[x]) # 縮約
        return self.parent[x]

    def unite(self, x, y):
        """ xとyの属する集合を併合する """
        gx = self.find(x)
        gy = self.find(y)
        if gx == gy: return

        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self.depth[gx] < self.depth[gy]:
            self.parent[gx] = gy
        else:
            self.parent[gy] = gx
            if self.depth[gx] == self.depth[gy]: self.depth[gx] += 1

    def is_same_group(self, x, y):
        """ xとyが同じ集合に属するか否か """
        return self.find(x) == self.find(y)


def solve():
    N, M = list(map(int, input().split()))
    edges = []

    for i in range(M):
        a, b = list(map(int, input().split()))
        edges.append([a-1, b-1])

    # 各辺について、その辺が存在しない時、aとbが連結になるかをUnion-Findで判定する
    ans = 0
    for i in range(M):
        uf = UnionFind(N)
        for j, edge in enumerate(edges):
            if i == j: continue
            
            a, b = edge
            uf.unite(a, b)
        
        # i番目の辺を除くすべての辺をつないだあとで、i番目の辺(a, b)がつながるかを判定する
        # つながらないならば、そのi番目の辺は橋である
        a, b = edges[i]
        if not uf.is_same_group(a, b): ans += 1
    
    print(ans)
    

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3192