akhauriyash/Code-Regression huggingface dataset:
from itertools import combinations
from collections import Counter
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

count = []
for ((x1,x2),(x3,x4)) in combinations(xy, 2):
    count.append((x1-x3,x2-x4))
    count.append((x3-x1,x4-x2))
    
c = Counter(count)
m = 0
for i in c.values():
    m = max(m, i)

if N == 1:
    print(1)
else:
    print(N-m)


Measured memory_bytes: 40560
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C_Rally
{
    class Program
    {
        static void Main(string[] args)
        {
            int total = int.Parse(ReadLine());
            string input = ReadLine();
            string[] array = input.Split(' ');
            int[] n = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                n[i] = int.Parse(array[i]);
            }
            int result = 0;
            int sum = 0;
            for (int k = 0; k < total; k++)
            {
                sum += n[k];
            }
            sum = sum / total;
            int p = 0;
            for (int m = 0; m < 2; m++)
            {
                for (int j = 0; j < total; j++)
                {
                  
                    if (sum < n[j])
                    {
                        result += ((n[j] - sum) * (n[j] - sum));
                    }
                    else
                    {
                        result += ((sum - n[j]) * (sum - n[j]));
                    }
                   


                }
                 sum += m+1;
                if (result == 0) {
                    break;
                }
                if (p == 0)
                {
                    p = result;
                }
                if (p > result)
                {
                    p = result;
                }
                result=0;
            }
            WriteLine("{0}", p);
            ReadKey();


        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n,ans=0;
    cin >> n;
    for(int i=2;i*i<=n;i++){
        int c=0;
        while(n%i==0){
            n/=i;
            c++;
        }
        int k=0;
        for(int j=1;j<60;j++){
            if(j*(j+1)/2<=c)k=j;
        }
        ans+=k;
    }
    if(n>1)ans++;
    cout << ans;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
  ll n,a,b;
  std::cin >> n>>a>>b;
  if((b-a)%2==0)std::cout << (b-a)/2 << std::endl;
  else{
    std::cout << min({a+(b-a-1)/2,n-b+1+(n-(a+n-b+1))/2,b-1,n-a})  << std::endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c=0,d=0;
	cin >> a >> b;
	c+=a;d+=b;
	if(c==1){
		c+=13;
	}
	if(d==1){
		d+=13;
	}
	if(c>d){
		cout << "Alice" << endl; 
	}
	else if(c<d){
		cout << "Bob" << endl;
	}
	else{
		cout << "Draw" << endl;
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  string a="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string b;
  cin >> b;
  
  
  for(int i=0; i<b.size(); i++){
    for(int j=0; j<26; j++){
      if(b.at(i) == a.at(j)){
        b.at(i) = a.at(j+n);
        break;
      }
    }
  }
  cout << b <<endl;
}

Measured memory_bytes: 256
def RA():
    return list(map(int, input().split()))

def solve():
    n = int(input())
    h = RA()
    dp = [0] * n
    dp[1] = abs(h[1] - h[0])
    for i in range(2, n):
        dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2])
    print(dp[n - 1])

solve()

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<vector<int>> A;
bool f(int i, int j, int k) {
	if (i == N) {
		for (int j = 0; j < N; ++ j) {
			set<int> s;
			for (int i = 0; i < N; ++ i) if (A[i][j]) s.insert(A[i][j]);
			if (s.size() != K) return false;
		}
		return true;
	} else if (j == N) {
		set<int> s;
		for (int j = 0; j < N; ++ j) if (A[i][j]) s.insert(A[i][j]);
		if (s.size() != K) return false;
		return f(i+1, 0, k);
	} else {
		if (A[i][j] != 0) return f(i, j+1, k);
		if (f(i, j+1, k)) return true;
		if (j < N-1 && A[i][j+1] == 0) {
			A[i][j] = A[i][j+1] = k;
			if (f(i, j+2, k+1)) return true;
			A[i][j] = A[i][j+1] = 0;
		}
		if (i < N-1 && A[i+1][j] == 0) {
			A[i][j] = A[i+1][j] = k;
			if (f(i, j+1, k+1)) return true;
			A[i][j] = A[i+1][j] = 0;
		}
		return false;
	}
}
int main() {
	int n;
	cin >> n;
	if (n == 2) {
		cout << -1 << endl;
		return 0;
	}
	if (n == 3) {
		cout << "aab" << endl;
		cout << "d.b" << endl;
		cout << "dcc" << endl;
		return 0;
	}
	K = 3;
	vector<vector<vector<int>>> hoge;
	for (N = 4; N <= 7; ++ N) {
		A = vector<vector<int>>(N, vector<int>(N));
		if (!f(0, 0, 1)) throw 1;
		hoge.push_back(A);
	}
	vector<string> res(n, string(n, '.'));
	for (int p = 0; p < n; ) {
		int m = n-p <= 7 ? n-p : 4;
		for (int i = 0; i < m; ++ i) for (int j = 0; j < m; ++ j) {
			int x = hoge[m - 4][i][j];
			if (x) res[p+i][p+j] = 'a' + x;
		}
		p += m;
	}
	for (auto& x : res) cout << x << endl;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int main()
{
	int n,a[100005];
	bool vis[100005];
	LL ans=0;
	scanf("%d",&n);
	memset(vis,0,sizeof(vis));
	for(int i=0; i<n; i++)
	{
		scanf("%d",&a[i]);
		if(a[i])vis[i]=true;
		ans+=a[i]/2;
		a[i]%=2;
	}
	for(int i=1; i<n; i++)
	{
		if(a[i]&&a[i-1])
		{
			a[i]=0;
			a[i-1]=0;
			ans++;
		}
		else if(a[i]==0&&a[i-1])
			if(vis[i]) a[i]++,a[i-1]--;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 768
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<char>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>s1;
   l(i,0,s1.size())
   {
       s.in(s1[i]);
   }
    if(s.size()==2)cout<<"Yes";
    else{cout<<"No"<<endl;}
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define N 200005

multiset <int> v;
multiset <int> ::iterator it;
int main() {
	int n;
	cin >> n;
	int ans = 0;
	for(int i=1,x; i<=n; i++) {
		scanf("%d",&x);
		it = v.lower_bound(x);
		if(it == v.begin()) ans ++,v.insert(x);
		else {
			it --;
			v.erase(it);
			v.insert(x);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4992
w,h,n=map(int, input().split())

memox = [True]*(w+1)
memoy = [True]*(h+1)


for i in range(n):
    xi,yi,a=map(int, input().split())
    if a == 1:
        memox = [False] * xi + memox[xi:]
    elif a == 2:
        memox = memox[:xi+1] + [False] * (w - xi)
    elif a == 3:
        memoy = [False] * yi + memoy[yi:]
    elif a == 4:
        memoy = memoy[:yi+1] + [False] * (h - yi)
memox = [i for i in memox if i]
memoy = [i for i in memoy if i]

if memox and memoy:
    print(max([0, (len(memox) - 1) * (len(memoy) - 1)]))
else:
    print(0)

Measured memory_bytes: 3064
//According to all known laws of aviation, there is no way that a bee should be able to fly.
//Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway.
//Because bees don't care what humans think is impossible.
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
bigint arr[300011] ;
int main(){
    int H , W , K ; cin >> H >> W >> K ;
    char ch[10][10] ;
    for( int i = 0 ; i < H ; i++ )
        for( int j = 0 ; j < W ; j++ )
            cin >> ch[i][j] ;
    int ans = 0 ;
    for( int maskR = 0 ; maskR < ( 1 << H ) ; maskR++ ){
        for( int maskC = 0 ; maskC < ( 1 << W ) ; maskC++ ){
            int cnt = 0 ;
            for( int i = 0 ; i < H ; i++ ){
                for( int j = 0 ; j < W ; j++ ){
                    if( ( maskR & ( 1 << i ) ) || ( maskC & ( 1 << j )) )
                        continue ;
                    else if( ch[i][j] == '#' )
                        cnt++ ;
                }
            }
            if( cnt == K )
                ans++ ;
        }
    }
    cout << ans << endl ;
    return 0 ;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(){
  int n,m;
  cin >> n;
  cin >> m;
  int a[100];
  int all=0;
  for (int i = 0; i<n;i++){
    int p;
    cin >> p;
    a[i] = p;
    all+=p;
  }
  int ok = 0;
  for (int i = 0; i<n;i++)
    if (4 * m * a[i] >= all) ok++;
  if (ok >= m ) cout << "Yes";
  else cout << "No";
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a - b) % c << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
int GCD(int a, int b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
 
    int main(){
      int x;
      cin >> x;
      if(x<1200) cout << "ABC" << endl;
      else cout << "ARC" << endl;
      return 0;}

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


int main(){
  ll h,w,k;cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s.at(i);
  vector<string> tate(w);
  rep(i,w) rep(j,h) tate.at(i).push_back(s.at(j).at(i));

  ll ball = 0;//全体の黒色マスの数
  vector<ll> s_num(h);
  rep(i,h){
    s_num.at(i) =  count(s.at(i).begin(),s.at(i).end(),'#');
    ball += s_num.at(i);
  }
  vector<ll> tate_num(w);
  rep(i,w){
    tate_num.at(i) = count(tate.at(i).begin(),tate.at(i).end(),'#');
  }



  ll ans = 0;
  for(ll i=0;i<(1<<h);++i){
    for(ll j=0;j<(1<<w);++j){
      ll num = ball;
      rep(k,h) if( i>>k & 1 ) num -= s_num.at(k);
      rep(k,w) if( j>>k & 1 ) num -= tate_num.at(k);
      rep(k,h) rep(l,w) if( ((i>>k) & 1) && ((j>>l) & 1) ) if( s.at(k).at(l) == '#' ){
        num++;
      }
      //cout << num << " " << i << " " << j << endl;
      if( num == k ) ++ans;
    }
  }
  cout << endl;
  cout << ans << endl;


}


Measured memory_bytes: 3620
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,m,cnt[1 << 17],c[1 << 17],ans,a,b;

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n >> m;
    for(int i = 1;i <= n;i++)
    {
        cnt[i] = 1;
    }
    c[1] = 1;
    for(int i = 1;i <= m;i++)
    {
        cin >> a >> b;
        cnt[a]--;
        cnt[b]++;
        if(c[a]) c[b] = 1;
        if(cnt[a] == 0) c[a] = 0;
    }
    for(int i = 1;i <= n;i++) ans += c[i];
    rc(ans);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl


/*--------------------template--------------------*/

ll mp[100005] = { 0 };

int main() {
    cin >> n;
    vi v(n);
    REP(i, n) cin >> v[i];
    REP(i, n) {
        mp[v[i]]++;
    }
    REP(i, 100002) {
        ans = max(ans, mp[i] + mp[i + 1] + mp[i + 2]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int arr[105];
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> arr[i];
	sort(arr+1,arr+1+n);
	int ans = 0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			for(int k=j+1;k<=n;k++)
				if(arr[i] != arr[j] && arr[j] != arr[k] && arr[i] != arr[k] && arr[i] + arr[j] > arr[k])	
					ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define M 2005
using namespace std;
int n,m;
const int mod=1e9+7; 
long long ans=1,res=1,a[M*M],inv[M*M],f[M][M];
inline long long ksm(long long k,long long x)
{
	long long y=1;
	while(x)
	{
		if(x&1)y=y*k%mod;
		x>>=1;
		k=k*k%mod;
	}
	return y;
}
inline long long c(int n,int m)
{
	return a[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
	register int i,j;
	scanf("%d%d",&n,&m);
	if(m==1)
	{
		puts("1");
		return 0;
	}
	a[0]=1;inv[0]=1;
	for(i=1;i<=n*m;i++)a[i]=a[i-1]*i%mod,inv[i]=inv[i-1]*ksm(i,mod-2)%mod;
	for(i=1;i<=n;i++)
	{
		f[i][0]=1;
		for(j=1;j<=i;j++)
		{
			f[i][j]=(f[i-1][j]+f[i][j-1]*(n-j+1)%mod*c(n*m-i-(j-1)*(m-1)-1,m-2)%mod)%mod;
		}
	}
	printf("%lld",f[n][n]);
	return 0;
}

Measured memory_bytes: 88792
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#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 cand[52];
int n, p;

bool is_game_over (void ){
	rep (i, n ){
		if (cand[i] == p ) return true;
	} // end rep

	return false;
}

int main()
{
	ios_base::sync_with_stdio(0);
	while (cin >> n >> p, n ){
		memset (cand, 0, sizeof (cand ) );
		int res = -1;
		int i = 0, j = p;
		while (true ){
			if (j > 0 ){
				cand[i%n]++;
				j--;
				if (j == 0 && is_game_over () ){
					res = i%n;
					break;
				} // end if
				i++;
			}else{
				j = cand[i%n];
				cand[i%n] = 0;
				i++;
			} // end if
		} // end while
		cout << res << endl;
	} // end while		
		
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <boost/multiprecision//cpp_int.hpp>
using namespace std;

namespace mp = boost::multiprecision;
using Booint = mp::cpp_int;

#define endl "\n"
#define FSP(n) cout << fixed << setprecision(n);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define ilMAX 2147483647;
#define llMAX 9223372036854775807;
#define ullMAX 18446744073709551615;
#define SORT(v) sort((v).begin(), (v).end());
#define REV(v) reverse((v).begin(), (v).end());
#define prepare cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
signed main() {
    prepare
    string S; cin >> S;
    int n = S.length();
    if (S[n - 1] == 's') cout << S << "es" << endl;
    else cout << S << 's' << endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
#define per(i, a, b) for (int i = a; i >= b; -- i)
const int maxn = 100010;
using namespace std;
ll I, O, L, J;
int main() {
	scanf("%lld%lld%lld%lld%lld", &I, &O, &L, &J, &L);
	ll ret = O + I / 2 * 2 + L / 2 * 2 + J / 2 * 2;
	if (I && L && J) ret = max(ret, O + (I - 1) / 2 * 2 + 3LL + (L - 1) / 2 * 2 + (J - 1) / 2 * 2);
	printf("%lld", ret); 
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> a(m);
    rep(i,m) {
        cin >> a[i].first >> a[i].second;
    }
    rep(ni, 1000){
        int keta = 1;
        int x = ni/10;
        vector<int> num(1, ni%10);
        while(x){
            ++keta;
            num.push_back(x%10);
            x/=10;
        }
        reverse(all(num));
        if(keta!=n) continue;
        bool ok = true;
        rep(i,m){
            if(num[a[i].first-1]!=a[i].second) ok =false;
        }
        if(ok) {cout << ni << endl; return 0;}
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int flag=0,i1=0;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='C')
		{
			i1=i;
			flag=1;
			break;
		}
	}
	if(flag==0)
	{
		cout<<"No"<<endl;return 0;
	}
	int f0=0;
	for(int i=i1;i<s.length();i++)
	{
		if(s[i]=='F')
		f0=1;
	}
	if(f0)cout<<"Yes"<<endl;else cout<<"No"<<endl;
	fclose(stdin);fclose(stdout);
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()

	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)
	d := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = scanInt()
		b[i] = scanInt()
	}

	for i := 0; i < n; i++ {
		c[i] = scanInt()
		d[i] = scanInt()
	}

	pair := [100][100]bool{}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if a[i] < c[j] && b[i] < d[j] {
				pair[i][j] = true
			}
		}
	}

	ans := 0
	for {
		mi := 101
		index := -1
		for i := 0; i < n; i++ {
			cnt := 0
			for j := 0; j < n; j++ {
				if pair[i][j] {
					cnt++
				}
			}

			if cnt != 0 && mi > cnt {
				index = i
				mi = cnt
			}
		}

		if index == -1 {
			break
		}

		mi = 101
		blue := -1
		for i := 0; i < n; i++ {
			if pair[index][i] {
				cnt := 0
				for j := 0; j < n; j++ {
					if pair[j][i] {
						cnt++
					}
				}

				if cnt != 0 && mi > cnt {
					blue = i
					mi = cnt
				}
			}
		}

		// fmt.Fprintln(wr, index, blue, ans)

		ans++

		for i := 0; i < n; i++ {
			pair[index][i] = false
		}
		for i := 0; i < n; i++ {
			pair[i][blue] = false
		}
	}

	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long long long int
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
    int n;
    cin>>n;
    int i;
    vector<int> v(n-1);
    for(i=0;i<n-1;i++)
        cin>>v[i];
    map<int,int> mp;
    for(i=0;i<n-1;i++)
        mp[v[i]]++;
    for(i=1;i<=n;i++)
        cout<<mp[i]<<"\n";
}

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

template<typename t>inline t min_(t a,t b){return a<=b?a:b;}
template<typename t>inline t max_(t a,t b){return a>=b?a:b;}
template<typename t>inline void chkmin(t&a,t b){if(a>b)a=b;}
template<typename t>inline void chkmax(t&a,t b){if(a<b)a=b;}

typedef long long ll;
const int maxn=1e5+10,maxa=16;
int n,a[maxn],cnt[maxa],ans;
int tot,x[maxa],dp[1<<maxa];
bool vis[1<<maxa];

int main(){
	cin>>n;
	for(int i=1,u,v,x;i<n;++i){
		cin>>u>>v>>x;
		a[u]^=x;a[v]^=x;
	}
	for(int i=0;i<n;++i)
		++cnt[a[i]];
	for(int i=1;i<maxa;++i)
		ans+=cnt[i]/2,cnt[i]-=cnt[i]/2*2;
	for(int i=1;i<maxa;++i)
		if(cnt[i])
			x[tot++]=i;
	for(int i=0;i<(1<<tot);++i){
		int xxx=0;
		for(int j=0;j<tot;++j)
			if(i>>j&1)
				xxx^=x[j];
		if(xxx==0)
			vis[i]=true;
	}
	memset(dp,100,sizeof(dp));
	dp[0]=0;
	for(int i=0;i<(1<<tot);++i)
		for(int j=(i+1)|i;j<(1<<tot);j=(j+1)|i)
			if(vis[i^j])
				chkmin(dp[j],dp[i]+__builtin_popcount(i^j)-1);
	printf("%d\n",ans+dp[(1<<tot)-1]);
	return 0;
}


Measured memory_bytes: 896
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
	int n;
	cin >> n;
	if(n==0) {
		cout << 0 << endl;
		return;
	}
	vi ans;
	while(n != 0){
		if(n%2) {
			ans.pb(1);
			if(ans.size()%2) n = (n-1)/2;
			else n = (n+1)/2;
		}
		else {
			ans.pb(0);
			n = n/2;
		}
		// cout << n << endl;
	}
	reverse(all(ans));
	rep(i,ans.size()) cout << ans[i];
	cout << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
// C - Good Sequence

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	map<int, int> cnt;

	for (int i=0; i<N; i++) {
		int a;
		cin >> a;
		cnt[a]++;
	}

	int ans = 0;
	for (auto itr : cnt) {
		int x = itr.first;
		int c = itr.second;
		if (c < x) ans += c;
		else ans += c - x;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4736
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 1000005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1e8;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	ll a;
	cin >> a;
	ll ans = a + a * a + a * a * a;
	cout << ans << END;



// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int n, start;

// to, cost
using Edge = tuple<int, int>;
vector<vector<Edge>> G;
vi active;
 
vll dist;
 
bool bellman_ford(){
    dist = vll(n, INF);
    dist[start] = 0;

    rep(loop, n){
        rep(v, n){
            if(dist[v] == INF) continue;

            for(auto & e : G[v]){
                int nv, cost;
                tie(nv, cost) = e;
                if(not active[nv]) continue;

                if(dist[nv] > dist[v] + cost){
                    dist[nv] = min(dist[nv], dist[v] + cost);
                    if(loop == n - 1) return true;
                }
            }
        }
    }

    return false;
}

void dfs(vi& used, vector<vi>& T, int v){
    if(used[v]) return;
    used[v] = true;

    for(auto& nv : T[v]){
        dfs(used, T, nv);
    }
}

vi calc(vector<vi>& T, int sv){
    vi used(n);
    dfs(used, T, sv);
    return used;
}

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

    int m, P;
    cin >> n >> m >> P;
    start = 0;

    G = vector<vector<Edge>>(n);
    vector<vi> T1(n);
    vector<vi> T2(n);

    rep(_, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back(Edge(b, -(c - P)));
        T1[a].push_back(b);
        T2[b].push_back(a);
    }
    vi used1 = calc(T1, 0);
    vi used2 = calc(T2, n-1);
    active = vi(n);
    rep(i, n){
        active[i] = (used1[i] & used2[i]);
    }

    int res = (bellman_ford() ? -1LL : max(0LL, -dist[n-1]));
    cout << res << endl;

    return 0;
}


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

long long INF = 1001001001001001;

int main() {
  long long N;
  cin >> N;
  long long n = ceil(sqrt(N));


  long long L = 0;
  long long ans = INF;
  for(int i = 1; i<=n ; ++i) {
    if(i > 0 && N%i == 0) {
       L = i-1 + (N/i -1);
    }
    ans = min(ans, L);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

ll a,b,c,d,e,f,g,ans;

inline ll X(ll w,ll x,ll y,ll z)
{
	ll tmp=x;
	tmp+=(w/2)*2; tmp+=(y/2)*2; tmp+=(z/2)*2;
	return tmp;
}

int main()
{
	cin>>a>>b>>c>>d>>e>>f>>g;
	ans=X(a,b,d,e);
	if(a&&d&&e) ans=max(ans,X(a-1,b,d-1,e-1)+3); cout<<ans<<endl;
	return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

char s[30][30];
int dx[]{1,-1,0,0},dy[]{0,0,1,-1};
int d[30][30];

int main(){
	int h,w;cin>>h>>w;
	rep(i,h)scanf("%s",s[i]);
	int Max=0;
	rep(sx,h)rep(sy,w){
		if(s[sx][sy]=='#')continue;
		memset(d,-1,sizeof(d));
		d[sx][sy]=0;
		queue<P>que;
		que.push(P(sx,sy));
		while(!que.empty()){
			P p=que.front();que.pop();
			rep(k,4){
				int nx=p.first+dx[k],ny=p.second+dy[k];
				if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]=='.'&&d[nx][ny]==-1){
					d[nx][ny]=d[p.first][p.second]+1;
					que.push(P(nx,ny));
				}
			}
		}
		rep(i,h)rep(j,w){
			Max=max(Max,d[i][j]);
		}
	}
	cout<<Max<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int h1, h2, k1, k2, a, b, c, d;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;

    int hiroshi = h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d;
    int kenjiro = k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d;

    if (hiroshi < kenjiro) printf("kenjiro\n");
    else if (hiroshi == kenjiro) printf("even\n");
    else printf("hiroshi\n");
}


Measured memory_bytes: 3104
function* getDatasets(cin) {
    let [[n], ...data] = cin.split("\n").map(elt => elt.split(" ").map(e => parseInt(e)));
    for (let i = 0; i < n; ++i) {
        const end = data.findIndex(elt => elt.every(e => e === 0));
        yield data.slice(0, end);
        data = data.slice(end + 1);
    }
}

new Promise(function(resolve, reject) {
    let content = "";
    process.stdin.on("data", chunk => { content += chunk; });
    process.stdin.on("end", () => { resolve([content, process.stdout]); });
}).then(function([cin, cout]) {
    for (let d of getDatasets(cin)) {
        [d] = d.reduce(([cdr, pos], car) => {
            pos = pos.map((v, i) => v + car[i]);
            cdr.push(pos);
            return [cdr, pos];
        }, [[], [0, 0]]);
        d.sort((a, b) => {
            const sa = a.reduce((s, e) => s + e * e, 0);
            const sb = b.reduce((s, e) => s + e * e, 0);
            if (sa > sb) return -1;
            if (sb > sa) return 1;
            if (a[0] > b[0]) return -1;
            if (b[0] > a[0]) return 1;
            return 0;
        });
        cout.write(`${d[0].join(" ")}\n`)
    }
});



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

int main(void)
{
    int N;

    cin >> N;

    int A[200];
    for(int i = 0; i < N; i++)
    {
        A[i] = i+1;
    }

    int c = 0;
    int max_c = 0;
    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        while(true)
        {
            bool isOdd = false;
            if(A[i] % 2 != 0)
                isOdd = true;
            
            if(isOdd)
                break;

            A[i] /= 2;            
            c++;
        }
        if(c >= max_c)
            ans = i + 1;

        max_c = max(c, max_c);
        c = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S;cin>>S;
    int count=0,hoge=0;
    for(int i = 0; i <S.size(); i++)
    {
        /* code */
      count=0;
        if (S.at(i)=='A'||S.at(i)=='T'||S.at(i)=='G'||S.at(i)=='C') {
            for(int j=i;j<S.size();j++){
                
                if (S.at(j)=='A'||S.at(j)=='T'||S.at(j)=='G'||S.at(j)=='C') {
                    /* code */
                    count++;
                    hoge=max(count,hoge);
                    }
                    else{
                
                    break;
                }
                
            }
            
            
        }
        
    }
    cout<<hoge<<endl;
}

Measured memory_bytes: 256
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
ans=float("INF")
for i in range(2**n):
    var=[a for a in range(n) if (i>>a)%2]
    now=[0]*m

    y=0
    for j in var:
        y+=l[j][0]
        for h in range(m):
            now[h]+=l[j][h+1]
    if min(now)>=x:ans=min(ans,y)
print(ans) if ans!=float("INF") else print(-1)

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

int main() {
  int n,ans = 0,MAX = 0;
  cin >> n;
  vector<int> vec(n);
  for(int i = 0; i < n; i++){
    cin >> vec.at(i);
    if(vec.at(i) >= MAX){
      ans++;
      MAX = vec.at(i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import copy
N,u,v=map(int,input().split())
l=[set()for i in range(N)]
info=[[-1,-1,-1,-1]for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    l[a-1].add(b-1)
    l[b-1].add(a-1)
terminal=set()

s={u-1}
info[u-1][0]=0
info[u-1][1]=0
k=1
while len(s)>0:
    new_s=set()
    for t in s:
        for t2 in l[t]:
            if info[t2][0]==-1:
                info[t2][0]=t
                info[t2][1]=k
                new_s.add(t2)
    s=new_s
    k+=1

s={v-1}
info[v-1][2]=0
info[v-1][3]=0
k=1
while len(s)>0:
    new_s=set()
    for t in s:
        for t2 in l[t]:
            if  info[t2][2]==-1:
                info[t2][2]=t
                info[t2][3]=k
                new_s.add(t2)
    s=new_s
    k+=1
ans=-1
d=0
for i in range(N):
    if not len(l[i])==1:continue
    if info[i][1]<info[i][3]:
        if d<info[i][3]:
            d=info[i][3]
print(d-1)

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

vector<vector<int>> data;

bool input(){
  data.clear();
  data.resize(5);
  for(int i=0;i<5;i++){
    data[i].resize(2);
    cin>>data[i][0]>>data[i][1];
    if(data[i][0]==0&&data[i][1]==0)return false;
  }
  return true;
}

pair<char,int> solve(){
  char max_c;
  int max_n = 0;

  for(int i=0;i<data.size();i++){
    const int n = data[i][0] + data[i][1];
    if(max_n < n){
      max_c = 'A' + i;
      max_n = n;
    }
  }
  return make_pair(max_c,max_n);
}

int main(){
  while(input()){
    auto ans = solve();
    cout<<ans.first<<" "<<ans.second<<endl;
  }
}

Measured memory_bytes: 1196
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int x[51000];
int y[51000];
int r[51000];
map<pair<int,int>,int>M;
long long dp[110000][2];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int c;
		scanf("%d%d%d",x+i,y+i,&c);x[i]--;y[i]--;
		M[make_pair(x[i],y[i])]=c;
		r[i]=c;
	}
	long long t=0;
	for(int i=0;i<a-3;i++){
		t+=i+1;
	}
	for(int i=0;i<b;i++){
		if(ABS(x[i]-y[i])<=2)continue;
		if(M.count(make_pair(y[i],x[i]))){
			if(r[i]!=M[make_pair(y[i],x[i])]){
				printf("0\n");return 0;
			}
			if(x[i]<y[i])t--;
		}else t--;
	}
	if(M.count(make_pair(0,0))){
		dp[0][M[make_pair(0,0)]]=1;
	}else dp[0][0]=dp[0][1]=1;
	for(int i=1;i<a;i++){
		for(int j=0;j<32;j++){
			for(int k=0;k<2;k++){
				if(i<a-1&&j%2!=(j/2+j/4)%2)continue;
				if(i==a-1&&(j&6))continue;
				if((k+j/8+j/16+j)%2)continue;
				if(M.count(make_pair(i,i))&&M[make_pair(i,i)]!=j%2)continue;
				if(M.count(make_pair(i-1,i+1))&&M[make_pair(i-1,i+1)]!=j/2%2)continue;
				if(M.count(make_pair(i+1,i-1))&&M[make_pair(i+1,i-1)]!=j/4%2)continue;
				if(M.count(make_pair(i-1,i))&&M[make_pair(i-1,i)]!=j/8%2)continue;
				if(M.count(make_pair(i,i-1))&&M[make_pair(i,i-1)]!=j/16%2)continue;

				dp[i][j%2]=(dp[i][j%2]+dp[i-1][k])%mod;
			}
		}
	//	printf("%lld %lld\n",dp[i][0],dp[i][1]);
	}
	//printf("%lld %lld %lld\n",t,dp[a-1][0],dp[a-1][1]);
	long long ret=pw(2,t)*(dp[a-1][0]+dp[a-1][1])%mod;
	printf("%lld\n",ret);
}


Measured memory_bytes: 5504
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }


int main(){ 
    int a, b; cin >> a >> b;
    int res = -INF;
    chmax(res, a+b);
    chmax(res, a-b);
    chmax(res, a*b);
    cout << res << ln;
}

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

enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };

template<typename T>
struct Dice {
  T var[6]; int id[6];
  Dice() {
    id[0] = TOP, id[1] = FRONT, id[2] = LEFT;
    id[3] = RIGHT, id[4] = BACK, id[5] = BOTTOM;
  }
  T& operator[] (FACE f) { return var[id[f]]; }
  const T& operator[] (FACE f) const { return var[id[f]]; }
  bool operator ==(const Dice<T>& a) const {
    const Dice<T>& b = *this;
    for(int i = 0; i < 6; i++) {
      if(a[i] != b[i]) return false;
    }
    return true;
  }
  // a -> b, b -> c, c -> d, d -> a
  void roll(FACE a, FACE b, FACE c, FACE d) {
    int value = id[d];
    id[d] = id[c], id[c] = id[b], id[b] = id[a], id[a] = value;
  }
  // FRONT???RIGHT????§??????????
  void roll_r() { roll(FRONT, RIGHT, BACK, LEFT); }
  // FRONT???TOP????§??????????
  void roll_u() { roll(FRONT, TOP, BACK, BOTTOM); }
  // TOP, RIGHT, BOTTOM, LEFT???????¨???????????§??????????
  void roll_c() { roll(TOP, RIGHT, BOTTOM, LEFT); }
  // roll_r??¨roll_u????????????????????????????????????roll_c???4?????????
  bool eq(const Dice& d) {
    for(int k = 0; k < 6; k++) {
      for(int i = 0; i < 4; i++) {
        if(*this == d) return true;
        roll_c();
      }
      if(k % 2 == 0) roll_r();
      else roll_u();
    }
  }
};

int main() {
  Dice<int> dice;
  int num;
  cin >> num; dice[TOP] = num;
  cin >> num; dice[FRONT] = num;
  cin >> num; dice[RIGHT] = num;
  cin >> num; dice[LEFT] = num;
  cin >> num; dice[BACK] = num;
  cin >> num; dice[BOTTOM] = num;
  string s; cin >> s;
  for(int i = 0; i < (int)s.size(); ++i) {
    char c = s[i];
    if(c == 'E') {
      dice.roll_c();
    }
    else if(c == 'N') {
      dice.roll_u();
    }
    else if(c == 'S') {
      dice.roll_u();
      dice.roll_u();
      dice.roll_u();
    }
    else if(c == 'W') {
      dice.roll_c();
      dice.roll_c();
      dice.roll_c();
    }
  }
  cout << dice[TOP] << endl;
}

Measured memory_bytes: 1208
while True:
  n=int(input())
  if n==0: break
  g=[[] for _ in range(n)]
  for u in range(n):
    v1,w1,v2,w2=map(int,input().split())
    g[u].append((v1,w1))
    g[u].append((v2,w2))
  
  res=1
  vis=[False]*n
  for i in range(n):
    if vis[i]: continue
    ws=[]
    p,u=-1,i
    while True:
      vis[u]=True
      for v,w in g[u]:
        if v!=p:
          ws.append(w)
          p,u=u,v
          break
      if u==i: break
    res=res*ws.count(max(ws))%10007
  print(res)

Measured memory_bytes: 9876
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}
template <class T1, class T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& x) { return in >> x.first >> x.second; }

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    int n, k;
    std::cin >> n >> k;
    auto f = [=](int x) {
        for (int i = 0;; ++i) {
            if (x < k) {
                x *= 2;
                continue;
            }
            return i;
        }
    };
    long double res = 0;
    for (int i : boost::irange(1, n + 1)) {
        res += 1. / (1 << f(i));
    }
    out(res / n);
}

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    prog();
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,c,d = map(int,input())
    l = [b,c,d]
    for k in range(1<<3):
        s = a
        ans = []
        for i in range(3):
            if k&(1<<i):
                ans.append("+")
                s += l[i]
            else:
                ans.append("-")
                s -= l[i]
        if s == 7:
            k = [a]
            for i in range(3):
                k.append(ans[i])
                k.append(l[i])
            k.append("=7")
            print(*k,sep="")
            return
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> d(n);
for (int i = 0; i < n; ++i) cin >> d[i];
set<int> s(d.begin(), d.end());
cout << s.size() << endl;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int count = 0, ans = 0;
  char c;
  while(cin >> c) {
    if(c == 'A' || c == 'C' || c == 'G' || c == 'T') {
      ++count;
    } else {
      ans = max(ans, count);
      count = 0;
    }
  }cout << max(ans, count);
}
  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        String s;

        Scanner sc = new Scanner(System.in);
        s = sc.nextLine();

        int ans = 0;
        for(int i=0; i<4; i++) {
            if (s.charAt(i) == '+') ans++;
            else ans--;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23892