akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//互除法
ll GCD(ll a, ll b){
  return b ? GCD(b,a%b) : a;
}

ll LCM(ll a, ll b){
  return (a / GCD(a,b))*b;
}

ll power(ll x, ll y){//繰り返し2乗法
  if(y < 0){
    return 0;
  }else if(y == 0){
    return 1LL;
  }else if(y%2 == 0){//偶数
    return power(x,y/2)*power(x,y/2);
  }else{//奇数
    return power(x,y-1)*x;
  }
}

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N; cin >> N;
  vector<ll> a(N); FOR(i,N){ cin >> a[i]; }
  
  //main
  ll ans = 0;
  ll n = 1;
  for(int i=0; i<N; i++){
    if(a[i] == n){
      ans ++; n ++; 
    }
  }
  
  // output
  if(ans == 0){
    cout << -1 << endl;
  }else{
    cout << N-ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
vector<int>A[110000];
int n,x[110000],pd[110000],len,B[110000],num[110000],f[110000];
map<long long,int>M;
const int mo=1e9+7;
void dfs(int k){
	if (pd[k]) return;
	pd[k]=1; B[++len]=k;
	dfs(x[k]);
	for (int i=0;i<A[k].size();i++) dfs(A[k][i]);
}
int getans(int k1,int k2,int k3){
	long long st=1ll*k1*n+k2;
	if (M.count(st)) return M[st];
	int ans=0;
	if (A[k1].size()+A[k2].size()>2||A[k1].size()>1||(A[k1].size()==0&&A[k2].size()==0)){
		M[st]=0; return 0;
	}
	int flag=0;
	for (int i=0;i<A[k1].size();i++) if (A[k1][i]==k3) flag=1;
	for (int i=0;i<A[k2].size();i++) if (A[k2][i]==k3) flag=2;
	if (flag==1){
		ans=1;
		if (A[k2].size()>0&&A[A[k2][0]].size()>0) ans=0;
	//	cout<<"getans1 "<<k1<<" "<<k2<<" "<<k3<<" "<<ans<<endl;
		M[st]=ans; return ans;
	}
	if (flag==2){
		int ex=0; ans=1;
		if (A[k1].size()>0) ex=A[k1][0];
		if (ex) ans=0;
		if (A[k2].size()>1) ex=A[k2][0]+A[k2][1]-k3;
		if (ex&&A[ex].size()>0) ans=0;
	//	cout<<"getans2 "<<k1<<" "<<k2<<" "<<k3<<" "<<ans<<endl;
		M[st]=ans; return ans;
	}
	if (A[k1].size()==0){
		if (A[k2].size()==1){
			ans=(ans+getans(0,A[k2][0],k3))%mo;
		} else {
			ans=(ans+getans(A[k2][0],A[k2][1],k3))%mo;
			ans=(ans+getans(A[k2][1],A[k2][0],k3))%mo;
		}
	} else if (A[k2].size()==0) 
		ans=(ans+getans(0,A[k1][0],k3))%mo;
	else ans=(ans+getans(A[k1][0],A[k2][0],k3))%mo;
	M[st]=ans;
//	cout<<"getans "<<k1<<" "<<k2<<" "<<k3<<" "<<ans<<endl;
	return ans;
}
int solve(){
	int flag=0,where=0; M.clear();
	for (int i=1;i<=len;i++) if (A[B[i]].size()!=1) flag=1;
	//for (int i=1;i<=len;i++) cout<<B[i]<<" "; cout<<endl;
	if (flag==0){
		num[len]++; return 1;
	}
	for (int i=1;i<=len;i++) if (A[B[i]].size()==2) where=B[i];
	int ans=getans(0,where,where);
	return ans;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]),A[x[i]].push_back(i);
	for (int i=1;i<=n;i++) if (A[i].size()>2){
		printf("0\n"); return 0;
	}
	int ans=1;
	for (int i=1;i<=n;i++) if (pd[i]==0){
		len=0; dfs(i);
		ans=1ll*ans*solve()%mo;
	}
	//cout<<ans<<endl;
	for (int i=1;i<=n;i++){
		f[0]=1; f[1]=1;
		if ((i&1)&&(i>1)) f[1]=2;
		for (int j=2;j<=num[i];j++)
			f[j]=(1ll*f[j-2]*(j-1)%mo*i+1ll*f[j-1]*(1+(i&1)-(i==1)))%mo;
		ans=1ll*ans*f[num[i]]%mo;
	}
	cout<<ans<<endl;
	return 0;
}

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

int N;
int a, ans;

int main() {
  cin >> N;

  for (int i = 0;i < N; i++) {
    cin >> a;
    ans ^= a;
  }
 
  cout << ((ans) ? "No" : "Yes") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
string s[10005];
int main() {
	cin >> n;
	for (int i = 0; i < n; ++ i) cin >> s[i];
	int cnt1, cnt2, cnt3, ans;
	cnt1 = cnt2 = cnt3 = ans = 0;
	for (int i = 0; i < n; ++ i) {
		for (int j = 0; j + 1 < s[i].size(); ++ j) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B') ++ ans;
		}
		bool h, e;
		h = e = 0;
		if (s[i][0] == 'B') h = 1;
		if (s[i].back() == 'A') e = 1;
		if (h && e) ++ cnt1;
		else if (h && !e) ++ cnt2;
		else if (!h && e) ++ cnt3;
	}
	if (cnt1) {
		ans += cnt1 - 1;
		if (cnt2) -- cnt2, ans ++;
		if (cnt3) -- cnt3, ans ++;
	}
	ans += min(cnt2, cnt3);
	cout << ans;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
const int maxm = 1000*4;
const int maxn = 105;
const int inf = 100000000;
int n,m,c;
int dp[maxn][maxm];
bool vis[maxn][maxm];
struct node
{
    int to;
    int next;
    int w;
}edge[maxm];
int head[maxn];
int top;
void bfs()
{

    queue<pair <int,int> > Q;
    for(int i=0;i<=n;i++)
    for(int j=0;j<=m;j++)
    {
        dp[i][j]=inf;
    }
    vis[1][0]=1;
    dp[1][0]=0;
    Q.push(make_pair(1,0));
    while(!Q.empty())
    {

        int now = Q.front().first;
        int tim = Q.front().second;
        Q.pop();
        vis[now][tim]=0;
        for(int k=head[now];k!=-1;k=edge[k].next)
        {
            int to = edge[k].to;
            if(dp[now][tim] +edge[k].w < dp[to][tim])
            {
                  dp[to][tim] = dp[now][tim]+edge[k].w;
                  if (!vis[to][tim])
                    {
                        Q.push(make_pair(to,tim));
                        vis[to][tim] = 1 ;
                    }
            }
            if (dp[now][tim] < dp[to][tim+1])
            {
                dp[to][tim+1] = dp[now][tim];
                if (!vis[to][tim+1])
                {
                    Q.push(make_pair(to,tim+1));
                    vis[to][tim+1]= 1 ;
                }
            }
        }
    }
}
void init()
{
    top=0;
    memset(head,-1,sizeof(head));
    memset(vis,false,sizeof(vis));
}
void add(int from,int to,int w)
{
    edge[top].to=to;
    edge[top].w=w;
    edge[top].next = head[from];
    head[from]  =top++;
}
int main()
{
    while(scanf("%d%d%d",&n,&m,&c),n+m+c)
    {
        init();
        for(int i=1;i<=m;i++)
        {
            int a,b,c;
            scanf("%d%d%d",&a,&b,&c);
            add(a,b,c);
        }
        bfs();
        //cout<<"here"<<endl;
        for(int i=0;i<=n;i++)
        if(dp[n][i] <= c)
        {
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 2452
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from operator import mul
from functools import reduce
# a, b = [int(v) for v in input().split()]


def main():

    def modcmb(n, r, mod):
        if r < 0 or r > n:
            return 0
        r = min(r, n - r)
        over = 1
        under = 1
        for i in range(r):
            over = over * (n - i) % mod
            under = under * (i + 1) % mod

#        over = reduce(lambda v1, v2: (v1 * v2) % mod, range(n, n-r, -1))
#        under = reduce(lambda v1, v2: (v1 * v2) % mod, range(1, r+1))
        return (over * pow(under, mod - 2, mod)) % mod

    mod = 1000000007
    n, a, b = map(int, input().split())

    count = pow(2, n, mod) - 1
    count -= modcmb(n, a, mod)
    count -= modcmb(n, b, mod)

    while count < 0:
        count += mod
    print(count % mod)


main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;



int main(int argc, char const *argv[]) {
    ll n, a;
    bool flg=true;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if(a%2==0){
            if(a%3!=0&&a%5!=0){
                flg=false;
            }
        }
    }
    if(flg){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define mod 1000000007
 
#define p(x) cout<<x<<" ";
#define p2(x,y) cout<<x<<" "<<y<<" "
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<" "
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
 
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define pi pair<ll,ll>
#define ppi pair<ll,pi>
#define pb push_back
#define all(v) v.begin(), v.end() 

ll power(ll a,ll b){
  ll result=1;
  while(b){
    if(b&1)
      result=(result*a)%mod;
      a=(a*a)%mod;
      b=b/2;
  }
  return result;
}

ll gcd(ll a,ll b){
  if(b==0)
    return a;
  return gcd(b,a%b);
}


vi v(105),wt(105);
ll dp[105][100005];




int main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout<<fixed<<setprecision(6);

// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
  
    ll t=1;
    //cin>>t;
    
    while(t--)
    {
      ll n,capacity;
      cin>>n>>capacity;
      F(i,0,n-1) cin>>wt[i]>>v[i];
      vi dp(capacity+5,0);
      F(i,0,n-1){
        RF(j,capacity,wt[i]){
            dp[j]=max(v[i]+dp[j-wt[i]],dp[j]);
        }
      }
      ll ans=0;
      F(i,0,capacity){
        ans=max(ans,dp[i]);
      }
      cout<<ans<<"\n";

    }
        
}

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 100000
typedef long long L;
int n,k;
L T[MAX];
int check(L P){
  int i=0,j;
  L s;
  for(j=0;j<k;j++){
     s=0;
    while(s+T[i]<=P){
      s+=T[i];
      i++;
      if(i==n)return n;
    }
  }
  return i;
}
  
int solve(){
  L left=0,right=MAX*10000,mid;
  int v;
  while(right>left+1){
    mid=(right+left)/2;
    v=check(mid);
    if(v>=n)right=mid;
    else left=mid;
  }
  return right;
}
int main(){
  int i;
  L ans;
  scanf("%d %d",&n,&k);
  for(i=0;i<n;i++)scanf("%d",&T[i]);
  // ans=solve();
  printf("%llu\n",solve());
  return 0;
}


Measured memory_bytes: 2568
#include<iostream>
#include<algorithm>

using namespace std;

int main(void)
{
	int h,w;
	cin >> h >> w;
	int c[10][10];
	for(int i=1;i<=10;i++)
		for(int j=1;j<=10;j++)
			cin >> c[i-1][j-1];
	
	int dis[10];
	for(int i=1;i<=10;i++)
		dis[i-1]=10004;
	dis[1]=0;
	bool set[10]={};
	set[1]=true;

	int x=1;

	for(int abc=1;abc<=9;abc++)
	{
		int mini=10004;
		int id=-1;
		for(int i=0;i<=9;i++)
		{
			if(set[i]==true)
				continue;
			dis[i]=min(dis[i],c[i][x]+dis[x]);
			if(dis[i]<mini)
			{
				mini=dis[i];
				id=i;
			}
		}
		set[id]=true;
		x=id;
	}
	
	int ans=0;

	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
		{
			int a;
			cin >> a;
			ans+=(a==-1 ? 0:dis[a]);
		}
	cout << ans << endl;


}
			

Measured memory_bytes: 256
### C

def gcd(a, b):
    if a == 0:
        return b
    if b == 0:
        return a
    if b > a:
        a, b = b, a 
    return gcd(b, a%b)

N = int(input())
A = [int(x) for x in input().split()]

left = [0] * (N+1)
right = [0] *(N+1)

for i in range(N):
    left[i+1] = gcd(A[i], left[i])
for i in reversed(range(N)):
    right[i] = gcd(A[i], right[i+1])
    
res = 0
for i in range(N):
    l = left[i]
    r = right[i+1]
    res = max(gcd(l, r), res)

print(res)

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

int n,a[20];

bool dfs(int j,int t){
  if(!t)return 1;
  for(int i=j;i<n;i++)
    if(dfs(i+1,t-a[i]))return 1;
  return 0;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int q,m;
  cin>>q;
  while(q--){
    cin>>m;
    if(dfs(0,m))cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}

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

using namespace std;

int main(){
	long long i,n,x;
	
	cin>>n;
	
	for(i=1;i<=n;i++){
		x=i;
		if(x%3==0) cout<<" "<<i;
		  else while(x){
		  	if(x%10==3){
		  		cout<<" "<<i;
		  		break;
			  }
		  	  else x/=10;
		}
	}
	cout<<"\n";
}


Measured memory_bytes: 3108
#include <stdio.h>          // printf(), scanf(), getchar()
#include <stdbool.h>

const char NUL = '\0';

bool
ope_line()
{
	char train[52];
	int t = 25, s = 25;
	for (int i = 0; i < 52; ++i)
		train[i] = NUL;

	int c = getchar();
	train[t] = c;

	int a = getchar();
	while (a != '\n' && a != EOF)
	{
		int b = getchar();
		c = getchar();
		if (a == '<' && b == '-')
		{
			train[--t] = c;

			if (t < s)
				s = t;
		}

		else if (a == '-' && b == '>')
			train[++t] = c;

		a = getchar();
	}

	printf("%s\n", &train[s]);

	if (a == EOF)
		return false;

	return true;
}

int
main(int argc, char **argv)
{
	int n;
	scanf("%d\n", &n);

	for (int i = 0; i < n; ++i)
	{
		if (!ope_line())
			break;
	}

	return 0;
}

Measured memory_bytes: 1828
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
  
    ll n;
    cin>>n;
    ll a,b,c;
    ll ans = 0;
    for(a=1;a<=n;a++)
    {
        for(b=1;b<=n;b++)
        {
            for(c=1;c<=n;c++)
            {
                ans+=__gcd(a,__gcd(b,c));
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

// 1?????0

int N;
char S[100111];

void MAIN() {
    scanf("%s", S+1);
    S[0] = '?';
    N = strlen(S) - 1;

    if (S[1] == '0' || S[N-1] == '0' || S[N] == '1') {
	puts("-1");
	return;
    }
    for (int i=1; i<N; i++) {
	if (S[i] != S[N-i]) {
	    puts("-1");
	    return;
	}
    }

    int cur = 1;
    for (int i=2; i<=N; i++) {
	printf("%d %d\n", cur, i);
	if (S[i-1] == '1') {
	    cur = i;
	}
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 1536
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

bool comp(const string& i, const string& j){
	return (i > j);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	vector<string> s(3);
	rep(i,3){
		cin >> s[i];
	}
	cout << s[0][0] << s[1][1] << s[2][2] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int f[100];
 
int main(){
  int n, i;
  f[0] = f[1] = 1;
  scanf("%d", &n);
  for(i = 2; i <= n; ++i) f[i] = f[i - 1] + f[i - 2];
  printf("%d\n", f[n]);
  return 0;
}


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

string rev(string s) {
    reverse(s.begin(), s.end());
    return s;
}

int main() {
    int m;
    cin >> m;
    while (m--) {
        string s;
        cin >> s;
        vector<string> v;
        v.push_back(s);
        v.push_back(rev(s));
        string s1, s2, s3, s4;
        for (int i=1; i<(int)s.size(); ++i) {
            s1 = s.substr(0,i);
            s2 = s.substr(i);
            s3 = rev(s1);
            s4 = rev(s2);
            v.push_back(s3 + s2);
            v.push_back(s1 + s4);
            v.push_back(s3 + s4);
            v.push_back(s2 + s1);
            v.push_back(s4 + s1);
            v.push_back(s2 + s3);
        }
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
        cout << v.size() << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll dp[114514][4];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	dp[s.size()][3]=1;
	FORR(i, 0, s.size()){
		FORR(j, 0, 4){
			if(j==3){
				if(s[i]=='?'){
					dp[i][j]=(dp[i+1][j]*3)%MOD;
				}
				else{
					dp[i][j]=dp[i+1][j];
				}
			}
			else if(s[i]=='?'){
				dp[i][j]=(dp[i+1][j]*3+dp[i+1][j+1])%MOD;
			}
			else if(s[i]-'A'==j){
				dp[i][j]=(dp[i+1][j]+dp[i+1][j+1])%MOD;
			}
			else{
				dp[i][j]=dp[i+1][j];
			}
		}
	}
	cout<<dp[0][0]<<'\n';
	return 0;
}


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

using namespace std;

int main(){

    string input = "";

    cin >> input;

    long long digit_sum = 0;

    for(char x : input){

        digit_sum += x - '0';

    }

    if(digit_sum%9 == 0){
        cout <<"Yes\n";
    }else{
        cout <<"No\n";
    }

    
    return 0;
}

Measured memory_bytes: 3352
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
using namespace std;

int isPrime(long long n) {
	if(n == 1) return false;
	for(int i = 2; i <= sqrt(n); i++) {
		if(n % i == 0) return false;
	}
	return true;
}

int main () {
	long long n; 
	cin >> n;
	if(isPrime(n)) {
		cout << "1";
	}else {
		long long ans = 0;
		int s_root = sqrt(n);
		for(int i = 2; i <= s_root; i++) {
			if(n % i == 0) {
				if((isPrime(n / i)) && (i != (n / i))) {
					ans += 1;
				}
				if(isPrime(i)) {
					long long new_n = n;
					long long i_p = i;
					while(new_n % i_p == 0) {
						ans += 1;
						new_n /= i_p;
						i_p *= i;
					}
				}
			}
		}
		cout << ans;
	}
	return 0;
}  

Measured memory_bytes: 3688
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

bool prime(int x){
    if(x < 2){
        return false;
    }else if(x == 2){
        return true;
    }else if(x % 2 == 0){
        return false;
    }else{
        for(int i = 3 ; i <= sqrt(x) ; i += 2){
            if(x % i == 0){
                return false;
            }
        }
        return true;
    }
}

int main(){
    int n;
    cin >> n;
    int cnt = 0, ans = 3;
    while(true){
        if(prime(ans)){
            cout << ans;
            cnt++;
            if(cnt == n){
                cout << endl;
                break;
            }else{
                cout << " ";
            }
        }
        ans += 10;
    }
    return 0;
}

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

int main()
{
    ll a, b;
    int k;
    cin >> a >> b >> k;
    if(a + k - 1 > b - k - 1) {
        repl(i, a, b + 1) {
            cout << i << endl;
        }
    }
    else {
        repl(i, a, a + k) {
            cout << i << endl;
        }
        repl(i, b - k + 1, b + 1) {
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
s = '#' + input() + '#'
T = []
D = []
for t, d in [input().split() for _ in range(Q)]:
  T.append(t)
  D.append(-1 if d=='L' else 1)

#そのゴーレムがどちらかの端にたどりつけるかの関数
def canReachEnd(iL, dir):
  nowL = iL
  nowt = s[iL]
  for t, d in zip(T, D):
    if t == nowt:
      nowL += d
      nowt = s[nowL]
  if dir == 1 and nowL == N+1:
    return True
  elif dir == -1 and nowL == 0:
    return True
  else:
    return False

#1. iは左にたどり着くがi+1は辿りつかないようなiを探す
left = 0
right = N+1
while right > left+1:
  check = (left+right)//2
  if canReachEnd(check, -1):
    left = check
  else:
    right = check
leftborder = left

#2. jは右にたどり着くがj-1は辿りつかないようなjを探す
left = leftborder
right = N+1
while right > left+1:
  check = (left+right)//2
  if canReachEnd(check, 1):
    right = check
  else:
    left = check
rightborder = right

dropcnt = 0
dropcnt += leftborder
dropcnt += (N-(rightborder-1))
print(N-dropcnt)


Measured memory_bytes: 42600
n = int(input())
li = [list(map(int,input().split())) for _ in range(n)]

check = [[0]*10 for _ in range(12)]

for i in range(n):
    b = li[i][0]
    f = li[i][1]
    r = li[i][2] - 1
    check[(b-1)*3 + f-1][r] += li[i][3]
    
for i in range(12):
    for j in range(10):
        if j == 9:
            print(" " + str(check[i][j]))
        else:
            print(" " + str(check[i][j]), end="")
    else:
        if i == 2 or i == 5 or i == 8:
            print("#"*20)



Measured memory_bytes: 5624
package main

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

func main() {
	K, N := ReadInt(), ReadInt()
	A := ReadInts(N)
	max := K - A[len(A)-1] + A[0]
	for i := 0; i < N-1; i++ {
		max = Max(max, A[i+1]-A[i])
	}
	fmt.Println(K - max)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
 
    scanf("%d" ,&n);
    while (n--) {
	double h, m;
	scanf("%lf:%lf", &h, &m);
     
	double l = 30*h + m/2;
	double s = m * 6.0;
 
	double key = fabs(l - s);
	key = min(key, 360-key);
	if (0 <= key && key < 30) {
	    puts("alert");
	} else if (90 <= key && key <= 180) {
	    puts("safe");
	} else {
	    puts("warning");
	} 
    }
    return 0;
}

Measured memory_bytes: 3196
// to be build tomorrow
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<pair<int, int>, null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update> 
#include <bits/stdc++.h> 
using namespace std; 
ordered_set s[200005];
struct pt {
    long long x, y;
    pt() {}
    pt(long long _x, long long _y) : x(_x), y(_y) {}
    pt operator-(const pt& p) const { return pt(x - p.x, y - p.y); }
    long long cross(const pt& p) const { return x * p.y - y * p.x; }
    long long cross(const pt& a, const pt& b) const { return (a - *this).cross(b - *this); }
};

int sgn(const long long& x) { return x >= 0 ? x ? 1 : 0 : -1; }

bool inter1(long long a, long long b, long long c, long long d) {
    if (a > b)
        swap(a, b);
    if (c > d)
        swap(c, d);
    return max(a, c) <= min(b, d);
}

bool check_inter(const pt& a, const pt& b, const pt& c, const pt& d) {
    if (c.cross(a, d) == 0 && c.cross(b, d) == 0)
        return inter1(a.x, b.x, c.x, d.x) && inter1(a.y, b.y, c.y, d.y);
    return sgn(a.cross(b, c)) != sgn(a.cross(b, d)) &&
           sgn(c.cross(d, a)) != sgn(c.cross(d, b));
}
using pp = pair <ll, ll>;
ll dp[30][30][2];
ll valid(ll f1, ll pos, string s, string cur, ll count)
{
    if (pos == s.length())
    {
        // cout << cur << "\n";
        if (stoull(cur))
        return 1;
        return 0;
    }
    if (dp[pos][count][f1] != -1)
    return dp[pos][count][f1];
    if (f1 == 1)
    {
        dp[pos][count][f1] = valid(f1, pos+1,s, cur+'0', count) + valid(f1, pos+1,s, cur + '1', count+1);   
    }
    else 
    {
        if (s[pos] == '0')
        {
            dp[pos][count][f1] = valid (f1, pos+1, s, cur+'0', count);
        }
        else if (s[pos] == '1')
        dp[pos][count][f1] = valid(0, pos+1, s, cur+'1', count+1) + valid(1, pos+1, s, cur + '0', count);
        else 
        dp[pos][count][f1] = valid(1, pos+1, s, cur+'1',count+1) + valid(1, pos+1, s, cur+'0', count);
    }
    return dp[pos][count][f1];
}
int main ()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        string a;
        ll sum = 0;
        ll tp = 1;
        ll p = 0;
        ll x;
        while (sum < n)
        {
            x = sum;
            p++;
            tp *= 26;
            sum += tp;
        }
        n -= x;
        for (ll i = 0 ; i < p ; i++)
        {
            ll aage = powl(26, p-i-1);
            ll j;
            for (j = 1 ; j < 26 ; j++)
            {
                if (n <= aage*j)
                break;
            }
            a += ('a' + j - 1);
            n -= ((j-1)*aage);
        }
        cout << a ;
}
    return 0;
}

Measured memory_bytes: 22468
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
const int maxn = 1e6+10;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int main(){
	n=read();m=read();
	if(n<=9 && m<=9)printf("%d\n",n*m);
	else printf("-1");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
  ll n;
  cin >> n;
  string s,h;
  cin >> s >> h;
  string ans;
  for(ll i=0;i<n;i++){
    ans.push_back(s[i]);
    ans.push_back(h[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
from collections import Counter

N, K = map(int, input().split())
okasi = list()
for k in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    okasi.append([d, A])

sunuke = [0]*N
for i, A_list in okasi:
    for k in A_list:
        sunuke[k-1] += 1

print(Counter(sunuke)[0])

Measured memory_bytes: 68208
//                                                              ۡمِ ٱللهِ ٱلرَّحۡمَـٰنِ ٱلرَّحِيمِ‎
//created by --------> Aslan Nesipbay;

#include<bits/stdc++.h>

#define F first
#define S second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef stringstream SS;
typedef pair< ll, ll > pll;

const ll N = 10e5 + 5;
const ll NN = 105;
const double pi = 3.14159;
const ll MAX = 2e5 + 123;
const ll MOD = 1e9 + 7;
const ll INF = 1000000000000000000;
const ll pw = 31;

void speed()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll n, a[N], dp[N];

void hajime()
{
    cin >> n;
    for (ll i = 1; i <= n; i ++) cin >> a[i];
    dp[2] += abs (a[2] - a[1]);
    for (ll i = 3; i <= n; i ++)
    {
        dp[i] = min (dp[i - 1] + abs (a[i] - a[i - 1]), dp[i - 2] + abs (a[i - 2] - a[i]));
    }
    cout << dp[n];
}

int main()
{
    ll miyagi = 1;
    //scanf ("%I64d", &miyagi);
    speed();
    //cin >> miyagi;
    for (ll i = 1; i <= miyagi; i ++)
    {
        //cout << "Case " << i << ": ";
        hajime();
    }
}


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

int main() {

    int n;
    cin >> n;

    int a[n];
    rep(i, n) cin >> a[i];

    int ans = 0;

    rep(i, n-1) {
        for(int j = i+1; j < n; j++) {
            ans = max(ans, abs(a[i]-a[j]));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=610;
int n,m;
double f[maxn],a[maxn],b[maxn];
vector<int> G[maxn];
void solve(){
    scanf("%d%d",&n,&m);
    for(int i=1,u,v;i<=m;++i){
        scanf("%d%d",&u,&v);//confirm u is less than v
        G[u].push_back(v);
    }
    f[n]=0;
    for(int u=n-1;u;--u){
        for(auto v: G[u]){
            f[u]+=f[v]+1;
        }
        f[u]/=G[u].size();
    }
    double ans=f[1],Delta;
    //cout<<ans<<endl;//cerr<<ans<<endl;
    for(int s=1;s<n;++s){
        if(G[s].size()<=1)continue;
        a[s]=1;
        b[s]=0;
        for(int i=s+1;i<=n;++i){
            b[i]=f[i];
            a[i]=0;
        }
        for(int i=s-1;i;--i){
            a[i]=0;b[i]=0;
            if(G[i].size()<1)continue;
            for(auto v:G[i]){
                a[i]+=a[v];
                b[i]+=b[v]+1;
            }
            a[i]/=G[i].size();
            b[i]/=G[i].size();
        }
        for(auto v: G[s]){
            Delta=(f[s]*G[s].size()-f[v]-1)/(G[s].size()-1);
            ans=min(ans,a[1]*Delta+b[1]);
        }
    }
    printf("%lf\n",ans);
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct P{
  int t;
  int pc;
  int st;
  int lg;
};

int func(vector<P> vec, int ts, int te, int u)
{
  int r, s, p, q;
  r = s = q = 0;

  for(int i = 0; i < vec.size() && vec[i].t <= ts; i++, q++){
    if(vec[i].st == u){
      if(vec[i].lg == 1){
	s++;
      } else {
	s--;
      }
    }
  }
  if(s > 0){
    p = ts;
  } else {
    p = te;
  }

  for(int i = q; i < vec.size() && vec[i].t <= te; i++){
    if(s > 0){
      for(; i < vec.size() && vec[i].t <= te; i++){
	if(vec[i].st == u){
	  if(vec[i].lg == 1){
	    s++;
	  } else {
	    s--;
	    if(s == 0){
	      r += (vec[i].t - p);
	      break;
	    }
	  }
	}
      }
    } else {
      for(;i < vec.size() && vec[i].t <= te; i++){
	if(vec[i].st == u && vec[i].lg == 1){
	  s++;
	  p = vec[i].t;
	  break;
	}
      }
    }
  }

  if(s > 0){
    r += (te - p);
  }

  return r;
}

int main()
{
  int n, m, q, r, s, t, u;
  P p;

  while(cin>>n>>m && (n+m)){
    cin >> r;
    vector<P> vec;
    for(int i = 0; i < r; i+=1){
      cin >> p.t >> p.pc >> p.st >> p.lg;
      vec.push_back(p);
    }

    cin >> q;
    while(q--){
      cin >> s >> t >> u;
      cout << func(vec, s, t, u) << endl;
    }
  }

  return 0;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    int MOD = pow(10,9)+7;

    // 引き算したほうが早い
    // 0も9も使わない奴
    int temp1 = 1;
    for(int i=0;i<N;i++){
        temp1 = (temp1*8)%MOD;
    }
     int temp2 = 1;
    for(int i=0;i<N;i++){
        temp2 = (temp2*9)%MOD;
    }
    


    int ans = 1;

    for (int i=0;i<N;i++){
        ans = (ans*10)%MOD;
    }
    int temp3 = (temp2*2)%MOD;
    ans = ans-temp3;
    if(ans<0){
        ans+=MOD;
    }
    ans = ans + temp1;



//    ans = ans-temp2*2+temp1;
//    if(ans<0){
//        ans+=MOD;
//    }



    cout<<ans%MOD<<endl;




    return 0;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_C&lang=jp
AC
"""
import sys
input = sys.stdin.readline


def solve_knapsack(weight, items):
    dp = [[0]*(weight+1) for _ in range(len(items))]
    for i, item in enumerate(items[1:]):
        for w in range(1, weight+1):
            if item[1] <= w:
                # dp[i+1][w] = max((item[0] + dp[i][w-item[1]]),  dp[i][w], (item[0] + dp[i+1][w-item[1]]))
                dp[i+1][w] = max(dp[i][w], (item[0] + dp[i+1][w-item[1]]))
            else:
                dp[i+1][w] = dp[i][w]
    return dp[-1][-1]


def main(args):
    N, W = map(int, input().split())
    items = [[]]
    for _ in range(N):
        items.append([int(x) for x in input().strip().split()])
    result = solve_knapsack(W, items)
    print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 17872
a,b,c=map(int,input().split())
if 1<=a<=10000 and 1<=b<=10000 and 1<=c<=10000:
    if a>b:
        a,b=b,a
    if b>c:
        b,c=c,b
    if a>b:
        a,b=b,a
    print(a,b,c)




Measured memory_bytes: 5600
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

#define debug(x) cout << #x << "==" << x << endl;

using namespace std;

//??\???
#define MAX_LEN 1000
int N;
int dp[MAX_LEN + 1][MAX_LEN + 1];

void print_dp_table(int n, int m) {
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      cout <<setw(2) << dp[i][j];
    }
    cout << "\n";
  }
  cout << "\n";
}

int main() {
  ios::sync_with_stdio(false);

  cin >> N;

  string s1, s2;

  while( cin >> s1 >> s2 ) {

    std::vector<char> a;
    std::vector<char> b;
    for(char& c : s1) {
      a.push_back(c);
    }
    for(char& c : s2) {
      b.push_back(c);
    }


    // dp ????????????????????????
    fill(dp[0], dp[MAX_LEN + 1], 0);

    for( int i = 0; i < (int)a.size(); i++) {
      for( int j = 0; j < (int)b.size(); j++) {
        if( a[i] == b[j] ) {
          dp[i + 1][j + 1] = dp[i][j] + 1;
        } else {
          dp[i + 1][j + 1] = max( dp[i + 1][j], dp[i][j + 1]);
        }
      }
    }

    // print_dp_table(a.size(), b.size());
    cout << dp[a.size()][b.size()] << endl;

  }

  return 0;
}

Measured memory_bytes: 7072
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;
signed main(){
    int n;
    cin >> n;
    cout << n+n*n+n*n*n;
}


Measured memory_bytes: 3612
import java.math.*;
import java.text.*;
import java.util.*;
public class Main {
 
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        in.useDelimiter("\\n");
        while(in.hasNext()){
            String str = in.next();
            char[] s = str.toCharArray();
            for(int shift=0; shift<26; shift++){
                for(int i=0; i<s.length; i++){
                    if(Character.isLowerCase(s[i])){
                        s[i] = (char)(((int)s[i]-(int)'a'+1)%26 + (int)'a');
                    }
                }
                str = new String(s);
                if(str.indexOf("the")!=-1
                    || str.indexOf("this")!=-1
                    || str.indexOf("that")!=-1)
                    break;
            }
            System.out.println(new String(s));
        }
    }
 
}


Measured memory_bytes: 26304
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Random;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	int N = sc.nextInt();
    	int K = sc.nextInt();
    	if(K == 1) {
    		System.out.println(0);
    	} else {
    		System.out.println(N-K);
    	}
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }

    static void shuffleArray(long[] arr){
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            long tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
    }
}


Measured memory_bytes: 23124
import java.util.*;

class Main
{
    public static  void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a <= 5) {
            System.out.println(0);
            return;
        } else if (a >= 13) {
            System.out.println(b);
        } else {
            System.out.println(b / 2);
        }

        
    }
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

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

vector<ll> x;
vector<ll> xx;
vector<ll> y;
vector<ll> yy;

char mp[444][444];
char cmp[444][444];

void zaatu(){
	REP(i,x.size()){
		xx.PB(x[i]);
		xx.PB(x[i]+1);
		xx.PB(x[i]-1);
	}
	REP(i,y.size()){
		yy.PB(y[i]);
		yy.PB(y[i]+1);
		yy.PB(y[i]-1);
	}
	sort(ALL(xx));
	sort(ALL(yy));
	xx.erase(unique(ALL(xx)),xx.end());
	yy.erase(unique(ALL(yy)),yy.end());
	
	REP(i,x.size()){
		x[i] = lower_bound(ALL(xx),x[i]) - xx.begin();
		y[i] = lower_bound(ALL(yy),y[i]) - yy.begin();
	}
}
	
int main(){
	int n;
	while(cin >> n,n){
		REP(i,444)REP(j,444)mp[i][j] = '.';
		REP(i,444)REP(j,444)cmp[i][j] = '.';
		x.clear();
		y.clear();
		xx.clear();
		yy.clear();
		REP(i,n+4){
			int a,b;cin >> a >> b;
			x.PB(a);
			y.PB(b);
		}
		
		zaatu();
		
		REP(i,n){
			mp[y[i]][x[i]] = '#';
		}
		
		bool flag = false;
		REP(i,444){
			REP(j,444){
				if(mp[i][j] == '#')flag = !flag;
				if(flag)mp[i][j] = '#';
				else mp[i][j] = '.';
			}
			flag = false;
		}
		//SHOW2d(mp,3*n,3*n);
		
		flag = false;
		REP(j,444){
			REP(i,444){
				if(mp[i][j] == '#')flag = !flag;
				if(flag)mp[i][j] = '#';
				else mp[i][j] = '.';
			}
			flag = false;
		}
		//SHOW2d(mp,3*n,3*n);
		
		REP(i,4){
			cmp[y[i+n]][x[i+n]] = '!';
		}
		
		flag = false;
		REP(i,444){
			REP(j,444){
				if(cmp[i][j] == '!')flag = !flag;
				if(flag)cmp[i][j] = '!';
				else cmp[i][j] = '.';
			}
			flag = false;
		}
		
		flag = false;
		REP(j,444){
			REP(i,444){
				if(cmp[i][j] == '!')flag = !flag;
				if(flag)mp[i][j] = '!';
				else cmp[i][j] = '.';
			}
			flag = false;
		}
				
		REP(i,444){
			REP(j,444){
				if(cmp[i][j] == '!')mp[i][j] = '!';
			}
		}
		
		DBG(
		SHOW2d(mp,3*n,3*n);	
		SHOW1d(xx,xx.size());
		SHOW1d(yy,yy.size());
		)
		
		ll ans = 0;
		
		REP(i,444){
			REP(j,444){
				if(mp[i][j] == '#'){
					//cout << i << ' ' << j << ' '<< yy[i+1] << ' ' << yy[i] << ' ' << xx[j+1] << ' ' << xx[j] << endl;
					ans += (yy[i+1] - yy[i]) * (xx[j+1] - xx[j]);
				}
			}
		}
		
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3564
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
ab=t3(n-1)

d={i:[] for i in range(1,n+1)}
for a,b in ab:
    d[a].append(b)
    d[b].append(a)

l=list(d.items())
l.sort(key=lambda x:-len(x[1]))
m=len(l[0][1])

d2={line:0 for line in ab}
c={i:[] for i in range(1,n+1)}
for a1,list1 in l:
    color=1
    for b1 in list1:
        if a1>b1:
            a,b=b1,a1
        else:
            a,b=a1,b1
#         print(a,b)
        if d2[(a,b)]!=0:
            continue
        else:
            while color in c[a] or color in c[b]:
                color+=1 
            d2[(a,b)]=color
            c[a].append(color)
            c[b].append(color)
            color+=1
#     print(d2)
print(m)
ans=[]
for line in ab:
    ans.append(d2[line])
print(*ans,sep="\n")

Measured memory_bytes: 121556
#include <bits/stdc++.h>
using namespace std;
#define rep(i,h,t) for (int i=h;i<=t;i++)
int n;
int a[10000];
int main()
{
  cin>>n;
  rep(i,1,n) cin>>a[i];
  sort(a+1,a+n+1);
  int sum=0;
  rep(i,1,n-1) sum+=a[i];
  if (a[n]>=sum) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main(args: Array<String>) {
    var (r,d,x2000) =  readInts()
    var next = 0
    for (i in 1..10){
        next = r * x2000 - d
        x2000 = next
        println(next)
    }
}

Measured memory_bytes: 38072
#include<map>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<iostream>
    #define LLu unsigned long long
    using namespace std;
    char s[250010];
    LLu base=233,inv=7204522363551799129,f[250010],X=1,Y,ans=0;
    int n;
    map<LLu,int> mp;
    int main()
    {
    	scanf("%d",&n);getchar();
    	scanf("%s",s+1);
    	for(int i=1;i<=n;i++)
    	{
    		f[i]=f[i-1];
    		if(s[i]=='+') f[i]+=X;
    		if(s[i]=='-') f[i]-=X;
    		if(s[i]=='<') X*=base;
    		if(s[i]=='>') X*=inv;
    		mp[f[i]]++;
    	}
    	X=1;
    	for(int i=1;i<=n;i++)
    	{
    		ans+=mp[f[n]*X+Y];
    		if(s[i]=='+') Y+=X;
    		if(s[i]=='-') Y-=X;
    		if(s[i]=='<') X*=base;
    		if(s[i]=='>') X*=inv;
    		mp[f[i]]--;
    	}
    	printf("%llu",ans);
    }

Measured memory_bytes: 33664
#include <iostream>
#include <stack>

int main() {

	std::stack<int> st;
	int inp;//input

	while (std::cin >> inp)
	{
		if (inp == 0) {//output data and pop data
			std::cout << st.top() << std::endl;
			st.pop();
		}
		else {//push data
			st.push(inp);
		}
	}

	return 0;
}

Measured memory_bytes: 1200
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

static const double pi = 3.141592653589793;
int main(){
   long long a,b;
   cin>>a>>b;
   cout<<a*b<<endl;
}



Measured memory_bytes: 3636
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S := sc.nextStr()
	set := make(map[rune]bool)
	for _, r := range S {
		set[r] = true
	}

	if len(set) == 3 {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}
	wtr.Flush()
}


Measured memory_bytes: 640