akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

void solve(){
	//write here
    int n;
    cin>>n;
    vi arr(n);
    rep(i,0,n)cin>>arr[i];
    sort(all(arr));
    ll count = 0;
    rep(i,0,n-2){
        rep(j,i+1,n-1){
            rep(k,j+1,n){
                if (arr[i]!=arr[j] && arr[j]!=arr[k]){
                    if (arr[i]+arr[j]>arr[k])count++;
                }
            }
        }
    }
    cout<<count<<endl;
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	
		solve();
	return 0;
}

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

int main()
{
    int N;
    char c;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> c;
        if (c == 'Y')
        {
            cout << "Four" << endl;
            return 0;
        }
    }

    cout << "Three" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a[5] = {};
	REP(i, 6){
		int tmp;
		cin >> tmp;
		a[tmp]++;
	}

	REP(i, 5){
		if (a[i] >= 3){
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n, k, count=0;
  cin >> n >> k;
  while(true){
    count++;
    if(n / k > 0){
      n /= k;
    }else{
      break;
    }
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

vector<int> parent;

int root(int num) {
    if (num != parent.at(num)) parent.at(num) = root(parent.at(num));
    return parent.at(num);
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> p(n + 1);
    parent.resize(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> p.at(i);
        parent.at(i) = i;
    }
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        if (root(x) != root(y)) parent.at(parent.at(y)) = parent.at(x);
    }
    for (int i = 1; i <= n; ++i) root(i);
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (parent.at(i) == parent.at(p.at(i))) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>      
#define pb push_back 
#define fr first 
#define sc second
#define MOD 1000000007
#define len(s) s.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef map<int,int> mii; 

int main() {

   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
 */    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

    //int t; cin>>t; while(t--) { 
    int n; cin>>n;
    vi h(n);
    for(int& x : h) cin>>x;
    vi dp(n,MOD);
    dp[0]=0;
    f(i,0,n) {
        for(int j: {i+1,i+2}) {
            if(j<n) dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1];
    

    return 0 ;
}

Measured memory_bytes: 1152
/*
*  Author: windystreet
*  Date  : 2019-04-13 11:07:49
*  Motto : Think twice, code once.
*/
#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

long long A[maxn];
long long B[maxn];
long long C[maxn];
bool cmp(long long a,long long b){
	return a > b;
}
vector<long long>ans;
void solve(){
	long long x,y,z,k;
	cin>>x>>y>>z>>k;
	for(int i=1;i<=x;i++){
		cin>>A[i];
	}
	for(int i=1;i<=y;i++)
		cin>>B[i];
	for(int i=1;i<=z;i++)
		cin>>C[i];
	sort(A+1,A+1+x,cmp);sort(B+1,B+1+y,cmp);sort(C+1,C+1+z,cmp);
	
	for(int i=1;i<=x;i++){
		for(int j=1;j<=y;j++){
			for(int c=1;c<=z;c++){
				if(i*j*c>k)break;
				ans.pb(A[i]+B[j]+C[c]);
			}
		}
	}
	sort(ans.begin(), ans.end(),cmp);
	for(int i=0;i<k;i++){
		printf("%lld\n",ans[i] );
	}
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("F:/in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
    return 0;
}

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

//typedef long long ll;
using namespace std;

int main()
{

    int n;
    cin >> n;
    int a[n];

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

    int c = 0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            for(int k = j+1; k<n; k++)
            {
                if(a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k] && (a[i]+a[j]>a[k]) && (a[j]+a[k]>a[i]) && (a[i]+a[k]>a[j]))
                {
                    c++;
                }
            }
        }
    }

    cout << c << endl;

}


Measured memory_bytes: 3640
#include <stdio.h>

int F[50];

int fibo(int n){
  if(n==0||n==1)return F[n]=1;
  if(F[n] != -1)return F[n];
  return F[n] = fibo(n-1) + fibo(n-2);
}

int main(){
  int n,i;
  for(i=0;i<50;i++){
    F[i]=-1;
  }
  scanf("%d",&n);
  printf("%d\n",fibo(n));


  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<deque>
#include<list>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<iterator>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x3, x4, y3, y4;
	int Y = abs(y1 - y2);
	int X = abs(x1 - x2);
	if (x1<=x2&&y1>y2) {
		x3 = x2 + Y;
		y3 = y2 + X;
		x4 = x1 + Y;
		y4 = y1 + X;
	}
	if (x1 < x2&&y1 <= y2) {
		x3 = x2 - Y;
		y3 = y2 + X;
		x4 = x1 - Y;
		y4 = y1 + X;
	}
	if (x1 >= x2&&y1 < y2) {
		x3 = x2 - Y;
		y3 = y2 - X;
		x4 = x1 - Y;
		y4 = y1 - X;
	}
	if (x1 > x2&&y1 >= y2) {
		x3 = x2 + Y;
		y3 = y2 - X;
		x4 = x1 + Y;
		y4 = y1 - X;
	}
	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long int
    int main()
    {
     	int n,k;
      	cin>>n>>k;
      	ll arr[n],dp[n+2];
      	for(int i=0;i<n;i++)
        cin>>arr[i];
      	dp[0]=0;
      	dp[1]=abs(arr[0]-arr[1]);
      	for(int i=2;i<n;i++)
        {
          	int min = INT_MAX;int ans=INT_MAX;
     		for(int j=1;j<=k;j++)
            {
              if(i-j>=0)
              ans = dp[i-j]+abs(arr[i]-arr[i-j]);
              if(ans<min)
              min=ans;
     		}
          dp[i]=min;
        }
                cout<<dp[n-1];
    	return 0;
    }

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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(a>=k){
    cout << k << endl;
  }else{
    if(a+b>=k){
      cout << a << endl;
    }else{
      cout << a-(k-a-b) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{int s=0;
 char a[20],b[20]="CODEFESTIVAL2016";
 cin>>a;
 for(int i=0;i<strlen(a);i++)
    {if(a[i]!=b[i])
	   s++;
    }
 cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define MOD 1000000007
//#define MOD 998244353
#define EPS (1 >> 30)
//#define INF (1 << 30)
#define INF (1LL << 60)
#define ff first
#define se second
//#define int long long
const int dx[]={0,-1,0,1};
const int dy[]={1,0,-1,0};

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;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n;
    cin>>n;
    int dame=0;
    vector<int> a(n+1);
    vector<int> b(n+1);
    rep(i, n) cin >> a[i+1];
    for(int i=n;i>0;i--){
        int cnt =0;
        for(int j=2;i*j<=n;j++){
            if(b[i*j]==1){
                cnt++;
            }
        }
        if(cnt%2!=a[i]){
            b[i]=1;
        }
    }
    int ans=0;
    Rep(i,1,n+1){
        if(b[i]==1){
            ans++;
        }
    }
    cout<<ans<<endl;
    Rep(i,1,n+1){
        if(b[i]==1){
            cout<<i<<" ";
        }
    }
    cout<<endl;
    
    
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#include<queue>
#include<cmath>
#include<vector>
#define neko 1010
#define chkmin(a,b) ((a)<(b)?(a):(b))
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
int P[neko],n,ans,cnt,cntp,t=1,head[neko],cur[neko],dis[neko],inf=0x3f3f3f3f,S,T;
int prime[10000010],isnprime[10000010];
struct node
{
	int v,cap,nex;
}e[neko*neko*2];
void add(int x,int y,int z)
{
	e[++t].v=y;
	e[t].cap=z;
	e[t].nex=head[x];
	head[x]=t;
	e[++t].v=x;
	e[t].cap=0;
	e[t].nex=head[y];
	head[y]=t;
}
namespace NT
{
	void sieve(int num)
	{
		isnprime[1]=1;
		f(i,2,num)
		{
			if(!isnprime[i])prime[++cntp]=i;
			for(register int j=1;j<=cntp&&i*prime[j]<=num;++j)
			{
				isnprime[i*prime[j]]=1;
				if(i%prime[j]==0)break;
			}
		}
	}
}
namespace Netflow
{
	using namespace std;
	bool bfs()
	{
		queue<int>q;memset(dis,0,sizeof(dis));
		dis[S]=1,q.push(S);
		int u;
		while(!q.empty())
		{
			u=q.front(),q.pop();
			for(register int i=head[u],v=e[i].v;i;i=e[i].nex,v=e[i].v)
			{
				if(!dis[v]&&e[i].cap)
				{
					dis[v]=dis[u]+1;
					if(v==T)return 1;
					q.push(v);
				}
			}
		}return 0;
	}
	int dfs(int u,int flow)
	{
		if(u==T||(!flow))return flow;
		int rescap=0,up;
		for(register int &i=cur[u],v=e[i].v;i;i=e[i].nex,v=e[i].v)
		{
			if(dis[v]==dis[u]+1&&(up=dfs(v,chkmin(e[i].cap,flow))))
			{
				e[i].cap-=up,e[i^1].cap+=up;
				rescap+=up;
				if(!(flow-=up))break;
			}
		}return rescap;
	}
	void dinic()
	{while(bfs())memcpy(cur,head,sizeof(head)),ans+=dfs(S,inf);}
}
#define pb push_back
struct tag
{int a,b;};
std::vector<tag>C;
int abs(int x){return x<0?-x:x;}
int main()
{
	int now=0;
	NT::sieve(10000010);
	scanf("%d",&n);
	f(i,1,n)
	{
		scanf("%d",&P[i]);
		if(P[i-1]^(P[i]-1)||i==1){C.pb(tag{P[i],++cnt});if(i>1)C.pb(tag{P[i-1]+1,++cnt});}
	}C.pb(tag{P[n]+1,++cnt});
	S=cnt+1,T=cnt+2;
	for(tag x:C)
	{
		if(x.a&1)
		{
			add(S,x.b,1),++now;
			for(tag y:C)if((!(y.a&1))&&(!isnprime[abs(y.a-x.a)]))add(x.b,y.b,1);
		}
		else add(x.b,T,1);
	}Netflow::dinic();
	//printf("%d\n",ans);
	int A=now-ans,B=(cnt-now)-ans;
	ans=ans+A/2*2+B/2*2,A=A-A/2*2,B=B-B/2*2;
	if(A&&B)ans+=3;
	printf("%d\n",ans);
}

Measured memory_bytes: 45440
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000000;

int main()
{
    int n, m, R;
    cin >> n >> m >> R;
    vector<int> r(R);
    for(int i = 0; i < R; i++)
    {
        cin >> r[i];
    }
    sort(r.begin(), r.end());
    vector<vector<int>> d(n+1, vector<int>(n+1));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            d[i+1][j+1] = INF;
        }
    }
    for(int i = 0; i < m; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
    }

    for(int k = 1; k <= n; k++)
    {
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= n; j++)
            {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    int ans = INF;
    do
    {
        int now = 0;
        for(int i = 0; i < R-1; i++)
        {
            now += d[r[i]][r[i+1]];
        }
        ans = min(ans, now);
    }
    while (next_permutation(r.begin(), r.end()));
    cout << ans << endl;
}



Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  const int mod = 1e9 + 7;
  int n;
  cin >> n;
  vector<vector<int>> in(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++ ) {
      cin >> in[i][j];
    }
  }
  vector<int> dp(1 << n);
  dp[0] = 1;
  for (int i = 0; i < (1 << n); i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if ((1 << j) & i) cnt++;
    }
    for (int j = 0; j < n; j++) {
      if (!((1 << j) & i)) {
        if (in[cnt][j]) {
          dp[i | (1 << j)] += dp[i];
          dp[i | (1 << j)] %= mod;
        }
      }
    }
  }
  cout << dp[(1 << n) - 1] << endl;
  return 0;	
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    char c[3][3];
    rep(i, 3){
        rep(j, 3){
            cin >> c[i][j];
        }
    }

    cout << c[0][0] << c[1][1] << c[2][2] << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

VVI wb;
signed main(void)
{
  int n, p;
  cin >> n >> p;
  int W = 0, B = 0;
  REP(i, n) {
    int w, b;
    cin >> w >> b;
    wb.PB({w*(100-p)+b*p, w, b});
    B += b;
  }

  sort(ALL(wb));
  reverse(ALL(wb));

  REP(i, n) {
    W += wb[i][1], B -= wb[i][2];
    if(W*100 >= (W+B)*p) {
      cout << i+1 << endl;
      return 0;
    }
  }
  assert(false);

  return 0;
}


Measured memory_bytes: 6836
N = int(input())
A = list()
for i in range(N-1):
  A.append(list(map(int, input().split())))
for i in range(N):
  ans = 0
  j = i
  while(j < N-1):
    C = A[j][0]
    S = A[j][1]
    F = A[j][2]
    
    if(S > ans):
      ans = S
    else:
      if(ans % F != 0):
        ans = ((ans//F)+1)*F
    ans += C
    j += 1
    
  print(ans)

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>v(m);
    int sum=0;
    for(int i=0; i<m; i++){
        cin>>v.at(i);
        sum+=v.at(i);
    }
    if(sum>n)cout<<"-1"<<endl;
    else cout<<n-sum<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
 
using namespace std;
 
const double eps=1e-10;
 
int main()
{
	int c[101]={0};
	int fre=0;

	int d;
	while(cin>>d){
		c[d]++;
		fre=max(fre,c[d]);
	}

	for(int i=1;i<=100;i++){
		if(c[i]==fre) cout<<i<<endl;
	}


	return 0;
}

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

using namespace std;
int n,m,a[1001];
int main(){
    while(cin>>n>>m,n){
        int ans=0;
        rep(i,n)cin>>a[i];
        rep(i,n)rep(j,n)if(i!=j)
            if(a[i]+a[j]<=m)ans=max(ans,a[i]+a[j]);
        if(ans)cout<<ans<<endl;
        else cout<<"NONE"<<endl;
    }
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector <int>
#define vl vector <long long>
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	string s;
	cin>>s;
	a--;
	b--;
	c--;
	d--;
	int f=0;
	for(int i=a+1;i<=c;i++)
	{
		if(s[i]=='#'&&s[i-1]=='#')
		{
			f=1;
			break;
		}
	}
	for(int i=b+1;i<=d;i++)
	{
		if(s[i]=='#'&&s[i-1]=='#')
		{
			f=1;
			break;
		}
	}
	if(d<c)
	{
		int f1=0;
		for(int i=b+1;i<=d+1;i++)
		{
			if(s[i]=='.'&&s[i-1]=='.'&&s[i-2]=='.')
			{
				f1=1;
				break;
			}
		}
		if(f1==0)
			f=1;
	}
	if(f)
		cout<<"No\n";
	else
		cout<<"Yes\n";
}

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

int main()
{
  int A, B;
  cin >> A >> B;
  if(A>=1 && A <= 9 && B >=1 && B<=9)
    cout << A*B << endl;
  else
    cout << -1 << endl;
  return 0;
}


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

using static Input;
using static Util;
class Program
{
    static int N;
    static int K;
    static HashSet<int> a = new HashSet<int>();
    static void INPUT()
    {
        N = NextInt();
        K = NextInt();
        for (var k = 0; k < K; k++)
        {
            var d = NextInt();
            for (var i = 0; i < d; i++)
                a.Add(NextInt());
        }
    }

    static void OUT()
    {
        Console.WriteLine(N - a.Count);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
        //INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 20344
#include <bits/stdc++.h>
#define vi vector<int>
#define rep(i, xtz, n) for(int i=xtz; i<n; i++)
#define repx(i, xtz, n) for(int i=xtz; i>n; i--)
#define lli long long int

using namespace std;

vector<vector<int>> graph(1e5+1);
vector<int> dp(1e5+1, -1);

int filldp(int start){
    if(dp[start] != -1) return dp[start];
    else if(graph[start].size() == 0) {dp[start]=0; return dp[start];}
    else{
        int mx=-1;
        rep(i, 0, graph[start].size()){
            mx = max(mx, filldp(graph[start][i]));
        }
        dp[start] = mx + 1;
        return dp[start];
    }
}

int main(){
    //freopen("i.in", "r", stdin);
    int n, m;
    cin>>n>>m;
    rep(i, 0, m){
        int a, b;
        cin>>a>>b;
        graph[b].push_back(a);
    }
    rep(i, 1, n+1) filldp(i);
    int mx=-1;
    rep(i, 1, n+1) mx = max(mx, dp[i]);
    cout<<mx;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    ll a[n];
    rep(0,i,n)cin>>a[i];
    ll M=a[0],ans=0;
    rep(0,i,n){
        if(M<=a[i]){
            M=a[i];
        }else{
            ans+=M-a[i];
        }
    }
    cout<<ans;
    
}

Measured memory_bytes: 5112
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, ans;
    cin >> a >> b;
    for(int i = 1;; i++) {
        if((a * i - (i - 1)) >= b) {
            ans = i;
            break;
        }
    }
    if(b == 1) { ans = 0; }
    COUT(ans);
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N;
    string S;
    char re[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

    cin >> N >> S;

    int ans = 0;

    rep(i, 10){
        rep(j, 10){
            rep(k, 10){
                int now = 0;
                rep(l, N){
                    if(now == 0){
                        if(S[l] == re[i])
                            now++;
                    }else if(now == 1){
                        if(S[l] == re[j])
                            now++;
                    }else{
                        if(S[l] == re[k])
                            now++;
                    }
                }
                if(now >= 3)
                    ans++;
            }
        }
    }

    cout << ans << endl;
	
	return 0;
}

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

using namespace std;

int main() {
	string in {""};
	cin >> in;
	if (in == "ABC") {
		cout << "ARC" << "\n";
		}
	else if (in == "ARC") {
		cout << "ABC" << "\n";
		}
		
	return 0;
	}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const int inf=100000;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	int a=0;
	cin>>a;
	int ans=a+pow(a,2)+pow(a,3);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;

    int Y = 0;

    vector<char> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s.at(i);
        if (s.at(i) == 'Y') {
            Y++;
        }
    }
    
    if (Y == 0) {
        cout << "Three" << endl;
    }
    else {
        cout << "Four" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
int main() {
  int n , k;
  std::cin>>n>>k;
  int *a = new int[n];
  for(int i =0; i < n; i++) {
  	std::cin>>a[i];
  }
  std::sort(a, a+n);
  int ans = 0;
  for(int i = 0; i <k; i++) {
  	ans += a[i];
  }
  std::cout << ans << std::endl;
  delete[] a;
}


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

using namespace std;

int N;
vector<int> P;

bool isSorted() {
    for (int i = 1; i < N; ++i) {
        if (P[i - 1] > P[i]) {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> N;
    P.resize(N);
    for (int i = 0; i < N; ++i) {
        cin >> P[i];
    }

    if (isSorted()) {
        cout << "YES" << endl;
        return 0;
    }

    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            swap(P[i], P[j]);
            if (isSorted()) {
                cout << "YES" << endl;
                return 0;
            }
            swap(P[i], P[j]);
        }
    }

    cout << "NO" << endl;
    return 0;
}

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

box = [[0, 0], [1, 1]] + [[1, 0] for i in range(n-1)]

for i in range(m):
    x, y = map(int, input().split())
    box[x][0] -= 1
    flag = box[x][1]
    if flag == 1:
        box[y][1] = 1
    if box[x][0] == 0:
        box[x][1] = 0
    box[y][0] += 1

ans = 0
for b in box:
    ans += b[1]

print(ans)


Measured memory_bytes: 13940
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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() {
    string s; cin >> s;

    int nT = 0, nS = 0;
    rep(i, s.size()) {
        if (s[i] == 'T') {
            if (nS > 0) nS--;
            else nT++;
        } else {
            nS++;
        }
    }
    cout << nT + nS << endl;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan =new Scanner(System.in);

		int A=scan.nextInt();
		int B=scan.nextInt();
		int tap=1;
		int n=0;
		if  (tap<B) {
			tap=A;
			n+=1;
		}
		while (tap<B) {
			tap+=A-1;
			n+=1;
		}
		System.out.print(n);
	}

}

Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		long[] a=sc.La,b=sc.La,c=sc.La;
		long[] h=new long[s[0]*s[1]];
		for(int i = 0;i<s[0];i++) {
			for(int j = 0;j<s[1];j++) {h[i*s[1]+j]=a[i]+b[j];}
		}
		Array.Sort(h,Ca);
		if(s[0]*s[1]>s[3]){Array.Resize(ref h,s[3]);}
		long[] g=new long[h.Length*s[2]];
		for(int i = 0;i<h
			.Length;i++) {
			for(int j = 0;j<s[2];j++) {g[i*s[2]+j]=h[i]+c[j];}
		}
		Array.Sort(g,Ca);
		if(g.Length>s[3]){Array.Resize(ref g,s[3]);}
		Console.WriteLine(String.Join("\n",g));
		
	}
	static int Ca(long a,long b){
		if(a<b){return 1;}
		else if(a>b){return -1;}
		else{return 0;}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 44640
// {{{ by unolight
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i,a,b) for (int i = a; i <= (int)(b); i++)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template <class T, class F = less<T>>
void sort_uniq(vector<T> &v, F f = F()) {
    sort(begin(v), end(v), f);
    v.resize(unique(begin(v), end(v)) - begin(v));
}
// }}}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> g(n);
    REP(i,n) cin >> g[i];
    function<int(int)> Bfs = [&]( int s ) {
        vector<bool> vis(n);
        vector<int> q;
        vis[s]=1;
        q.PB(s);
        int res=0;
        while ( q.size() ) {
            res++;
            vector<int> nq;
            for ( int u:q ) {
                REP(v,n) {
                    if ( g[u][v]=='1' && !vis[v] ) {
                        nq.PB(v);
                        vis[v]=1;
                    }
                }                
            }
            for ( int i=0; i<nq.size(); i++ ) {
                for ( int j=i+1; j<nq.size(); j++ ) {
                    if ( g[nq[i]][nq[j]]=='1' ) return -1;
                }
            }
            q=nq;
        }
        return res;
    };
    int ans = -1;
    REP(i,n) chmax(ans, Bfs(i));
    cout << ans << '\n';
    return 0;
}


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

#define int long long

int32_t main(){
	int n ;
	string s; 
	cin >> n >> s;
	for(auto i : s){
		cout << char(((i-'A') + n)%26 + 'A');
	}
	return 0 ;
}



Measured memory_bytes: 256
#include<iostream>

int main()
{
    int X,Y=0;
    std::cin >> X >> Y;
    int clane,turtle=0;

    for(int i=0; i<(X+1); i++)
    {
        clane = (X-i)*2;
        turtle = i*4;
        if((clane+turtle)==Y)
        {
            std::cout << "Yes";
            return 0;
        }
    }
    std::cout << "No";
    return 0;
}

Measured memory_bytes: 3556
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if((a==1&&a!=b)||(a>b&&b!=1)){
        printf("Alice");
    }
    else if((b==1&&a!=b)||(b>a&&a!=1)){
        printf("Bob");
    }
    else if((a==b)||(a==b&&a==1&&b==1)){
        printf("Draw");
    }
    return 0;
}


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

int main()
{
    int N, M, c, ans=0, count=0;
    cin >> N >> M >> c;
    vector<int> b(M);
    vector<vector<int>> a(N, vector<int>(M));
    vector<vector<int>> tmp(N, vector<int>(M));

    for (int i = 0; i < M; i++){
        cin >> b.at(i);
    }
    for (int i = 0; i < N; i++){
        for (int j = 0; j < M; j++){
            cin >> a.at(i).at(j);
        }
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            ans += a.at(i).at(j) * b.at(j);
           // cout << ans << endl;
        }
        if(ans+c>0){
            count++;
        }
        ans = 0;
    }

    /* 
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            cout<< tmp.at(i).at(j)<<" ";
        }
        cout << endl;
    }
    */
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a,b;
	int i,j;
	for(;;){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0) break;
		for(i=0;i<a;i++){
			for(j=0;j<b;j++){
				printf("#");
			}
			puts("");
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 588
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int n;
	cin >> n;
	cout << n * 800 - 200 * (n / 15) << endl;
}


Measured memory_bytes: 4992
x1, y1, x2, y2 = map(int, input().split())
a = y2 - y1
b = x2 - x1
x3 = x2 - a
y3 = y2 + b
x4 = x1 - a
y4 = y1 + b
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] arr = new long[110000];
        long sum = 0;
        for(int i = 0; i < N; i++) {
            long A = sc.nextLong();
            sum += A;
            arr[(int)A]++;
        }
        int q = sc.nextInt();
        for(int i = 0; i < q; i++) {
            long B = sc.nextInt();
            long C = sc.nextInt();

            sum += (C-B) * arr[(int)B];
            arr[(int)C] += arr[(int)B];
            arr[(int)B] = 0;
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 62424
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int x;
        for (int i = 1; i <= n; i++) {
            x = i;
            if (checkNum(x, i)) continue;
            include3(x, i);
        }

        System.out.println("");

        sc.close();
    }

    static boolean checkNum(int x, int i) {
        if ((x % 3) != 0) return false;
        System.out.printf(" %d", i);
        return true;
    }

    static void include3(int x, int i) {
        if ((x % 10) == 3) {
            System.out.printf(" %d", i);
            return;
        }

        x /= 10;
        if (x != 0) include3(x, i);
    }
}


Measured memory_bytes: 42380
#include <stdio.h>

int main () {
  int i;
  int alreadyPrinted = 0;

  int N;
  scanf("%d", &N);

  char S[N];
  scanf("%s", S);

  if(N % 2 == 1){
    printf("No\n");
    return 0;
  }

  for(i = 0; i < N/2; i++) {
    if(S[i] != S[i + (N/2)]){
      printf("No\n");
      alreadyPrinted = 1;
      break;
    }
  }

  if(!alreadyPrinted){
    printf("Yes\n");
  }

  return 0;
}


Measured memory_bytes: 256
S = list(input())
N = len(S)-1

def cal(l):
    c = ''
    for i in range(len(l)):
        if i%2==0:
            c += l[i]
        else:
            if l[i]==1:
                c += '+'
    return eval(c)

ans = 0
for i in range(1<<N):
    cond = [0]*N
    for j in range(N):
        if 1&(i>>j):  # 右シフトして論理積（bit全探索）
            cond[j] = 1
    tmp = []
    for i in range(N):
        tmp.append(S[i])
        tmp.append(cond[i])
    tmp.append(S[-1])

    ans += cal(tmp)

print(ans)

Measured memory_bytes: 3064
r, c = map(int, input().split())
mat = [0]*(r+1)
for row in range(r):
    mat[row] = list(map(int, input().split()))
    mat[row].append(sum(mat[row]))

col_sum = [0]*(c+1)
for col in range(c+1):
    for row in range(r):
        col_sum[col] += mat[row][col]
for row in range(r):
    print(' '.join(map(str,mat[row])))
print(' '.join(map(str,col_sum)))


Measured memory_bytes: 5700
#include <iostream>
#include <math.h>
using namespace std;

int main ()
{
  ios::sync_with_stdio(false);
  int N;
  int x;
  int y;
  cin >> N;
  x = static_cast<int>(sqrt(N));
  y = pow(x, 2.0);
  cout << y << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

bool f[10003];

bool f2[10003];


int main(){

for(int i=0;i<10002;i++)
for(int j=2;j*j<=i;j++)
{if(i%j!=0)f[i]=true;
else{ f[i]=false;break;}
}
f[3]=true;f[5]=true;

for(int i=0;i<10002;i++) 
if(f[i]==true&&f[i+2]==true)f2[i]=true;
f2[5]=true;
int n;
while(1){
scanf("%d",&n);if(n==0)break;
int p=0,q=0;
for(int i=n-2;i>=5;i--)
if(f2[i]==true){q=i+2;p=i;break;}
if(n<=6){p=3;q=5;}
printf("%d %d\n",p,q);
}
return 0;
}

Measured memory_bytes: 1048
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    # N+1_C_l
    pow1 = [1, 1]
    for i in range(2, N+2):
        pow1.append(pow1[-1]*i % div)

    # pow2 = [1, 1]
    # for i in range(2, N+2):
    #     j = powquick(i, div-2, div)
    #     pow2.append(pow2[-1]*j % div)

    pow2 = [1, 1]
    inv = [0, 1]
    for i in range(2, N+2):
        inv.append((-inv[div % i]) *(div // i) % div)
        pow2.append(pow2[-1] * inv[-1] % div)

    for l in range(1, N+2):
        v = (pow1[N+1]*pow2[l]*pow2[N+1-l]) % div
        # print(v)
        if l <= M+1:
            v -= (pow1[M]*pow2[l-1]*pow2[M-l+1]) % div
        print(v % div)

# def powquick(x, y, div):
#         if y == 0: return 1
#         if y == 1: return x % div
#         if y % 2 == 0: return pow(powquick(x, y // 2, div), 2) % div
#         if y % 2 == 1: return pow(powquick(x, y// 2, div), 2) * x % div


if __name__ == '__main__':
    main()

Measured memory_bytes: 80200
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

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

int main() {
  int n=0;
  int ans=0;
  cin>>n;
  ans+=(n/500)*1000;
  n-=(n/500)*500;
  ans+=(n/5)*5;
  
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>
#include <queue>
#include <set>

using namespace std;

int main()
{
  int32_t N, u, v;
  cin >> N >> u >> v;

  vector<set<int32_t>> G(N+1,set<int32_t>());
  
  for (int n=0; n<N; ++n) {
    int a, b;
    cin >> a >> b;
    
    G[a].insert(b);
    G[b].insert(a);
  }

  vector<int32_t> distance_to_A(N+1,INT32_MAX);
  vector<int32_t> distance_to_T(N+1,INT32_MAX);

  distance_to_A[v] = 0;
  
  queue<pair<int32_t, int32_t>> Q_A;
  for (int32_t node : G[v])
    Q_A.push(make_pair(node,1));

  while(!Q_A.empty()) {
    auto node_distance = Q_A.front();
    Q_A.pop();
    int32_t node = node_distance.first;
    int32_t distance = node_distance.second;
    distance_to_A[node] = min(distance_to_A[node],distance);

    for (int32_t next_node : G[node]) {
      if (distance_to_A[next_node] < INT32_MAX)
	continue;
      Q_A.push(make_pair(next_node, distance+1));
    }
  }

  distance_to_T[u] = 0;

  queue<pair<int32_t, int32_t>> Q_T;
  for (int32_t node : G[u])
    Q_T.push(make_pair(node,1));

  while(!Q_T.empty()) {
    auto node_distance = Q_T.front();
    Q_T.pop();
    int32_t node = node_distance.first;
    int32_t distance = node_distance.second;

    distance_to_T[node] = min(distance_to_T[node],distance);

    for (int32_t next_node : G[node]) {
      if (distance_to_T[next_node] < INT32_MAX)
	continue;
      Q_T.push(make_pair(next_node, distance+1));
    }
  }

  int ans = 0;

  for (int n=1; n<=N; ++n) {
    if (distance_to_T[n] < distance_to_A[n]) {
      ans = max(ans, distance_to_A[n] - 1);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 15232
#include <iostream>
#include <vector>
#include <queue>

class Line {
 public:
  Line(unsigned t, unsigned c) : t(t), c(c), done(false) {}
  unsigned t;
  unsigned c;
  bool done;
  bool operator<(const Line &l) const { return c < l.c; }
};

class Town {
 public:
  Town() : rank(1000000), done(false) {}
  std::vector<Line> line;
  int rank;
  bool done;
  void sort() { std::sort(line.begin(), line.end()); }
};

void dfs(Line &l, std::queue<unsigned> &queue, std::vector<Town> &town) {
  if (l.done) { return; }
  else { l.done = true; }
  auto pl = std::lower_bound(town[l.t].line.begin(), town[l.t].line.end(), l);
  if (pl->done) { return; }
  auto pu = std::upper_bound(town[l.t].line.begin(), town[l.t].line.end(), l);
  for (auto p = pl; p < pu; ++p) {
    if (!town[p->t].done) {
      town[p->t].done = true;
      town[p->t].rank = town[l.t].rank;
      queue.push(p->t);
      dfs(*p, queue, town);
    } else if (town[p->t].rank == town[l.t].rank) {
      dfs(*p, queue, town);
    }
    p->done = true;
  }
}

int main() {
  unsigned N, M;
  std::cin >> N >> M;
  std::vector<Town> town(N + 1);
  for (unsigned i = 0; i < M; ++i) {
    unsigned p, q, c;
    std::cin >> p >> q >> c;
    town[p].line.push_back(Line(q, c));
    town[q].line.push_back(Line(p, c));
  }
  for (auto &i : town) { i.sort(); }
  std::queue<unsigned> queue;
  town[1].done = true;
  town[1].rank = 0;
  queue.push(1);
  while (!queue.empty()) {
    auto x = queue.front();
    queue.pop();
    for (auto &l : town[x].line) {
      if (l.done) { continue; }
      if (!town[l.t].done) {
        town[l.t].rank = town[x].rank + 1;
        town[l.t].done = true;
        queue.push(l.t);
        dfs(l, queue, town);
      } else if (town[l.t].rank == town[x].rank + 1) {
        dfs(l, queue, town);
      }
      l.done = true;
    }
  }
  std::cout << (town[N].rank == 1000000 ? -1 : town[N].rank) << std::endl;
  return 0;
}

Measured memory_bytes: 12032
/*
created on 21/4/2020
*/
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
void solve();
int main(int argc, char const *argv[]){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
int const mxlen = (1e5) + 5;
int dp[mxlen];
int h[mxlen];
void solve(){
  int n, k;
  cin>>n>>k;
  for(int i=0;i<n;i++)
    cin>>h[i];
  dp[0] = 0;
  for(int i=1;i<n;i++){
    dp[i] = INT_MAX;
    for(int j=i-1; j>=0 && j>=i-k;j--){
      dp[i]= min(dp[i], abs(h[j] - h[i]) + dp[j]);
    }
  }
  cout<<dp[n-1]<<Endl;
}


Measured memory_bytes: 1024
N,M = map(int,input().split())
G = []
for i in range(M):
  G.append(list(map(int,input().split())))
#print(G)

def dfs(E,visited,v):
  visited[v] = 1
  for u in E[v]:
    if not visited[u]:
      dfs(E,visited,u)
  return sum(visited)

ans = 0
for i in range(M):
  Gtmp = G[:]
  del Gtmp[i:i+1]
  #print(Gtmp)
  E = [set() for _ in range(N+1)]
  for g in Gtmp:
    E[g[0]].add(g[1])
    E[g[1]].add(g[0])
  #print(E)
  visited = [0] * (N+1)
  if dfs(E,visited,1) < N:
    ans += 1
print(ans)


Measured memory_bytes: 44508
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

#include <iostream>
using i64 = long long;
template<i64 M> struct modint { i64 a;
  constexpr modint(const i64 x = 0): a((x%M+M)%M){}
  constexpr i64 value() const { return a; }
  constexpr modint inv() const { return this->pow(M-2); }
  constexpr modint pow(i64 r) const {
    modint ans(1); modint aa = *this;
    while(r) { if(r & 1) ans *= aa; aa *= aa; r >>= 1; }
    return ans;
  }
  constexpr modint& operator=(const i64 r) { a = (r % M + M) % M; return *this; }
  constexpr modint& operator+=(const modint r) { a += r.a; if(a >= M) a -= M; return *this; }
  constexpr modint& operator-=(const modint r) { a -= r.a; if(a < 0) a += M; return *this; }
  constexpr modint& operator*=(const modint r) { a = a * r.a % M; return *this; }
  constexpr modint& operator/=(const modint r) { (*this) *= r.inv(); return *this; }
  constexpr modint operator+(const modint r) const { return modint(*this) += r; }
  constexpr modint operator-(const modint r) const { return modint(*this) -= r; }
  constexpr modint operator*(const modint r) const { return modint(*this) *= r; }
  constexpr modint operator/(const modint r) const { return modint(*this) /= r; }
  constexpr bool operator!=(const modint r) const { return this->value() != r.value(); }
};

template<const i64 M> std::ostream& operator<<(std::ostream& os, const modint<M>& m) { os << m.value(); return os; }

#include <vector>
#include <tuple>
using i64 = long long;

template<class T>
std::tuple<std::vector<T>, std::vector<T>> build_factorial(int N) {
  std::vector<T> fact(N);
  std::vector<T> finv(N);
  fact[0] = T(1);
  for(int i = 1;i < N;i++) {
    fact[i] = fact[i - 1] * T(i);
  }
  finv[N - 1] = T(1) / fact[N - 1];
  for(int i = N - 1; i --> 0;) {
    finv[i] = finv[i + 1] * T(i + 1);
  }
  return std::make_tuple(std::move(fact), std::move(finv));
}

const int mod = 1000003;
using fp = modint<mod>;

int main() {
  i64 Q;
  cin >> Q;
  vector<fp> fact, finv;
  std::tie(fact, finv) = build_factorial<fp>(mod);

  auto solve = [&](i64 x, i64 n) {
    if(x == 0 || x + n - 1 >= mod) return fp(0);
    return fact[x + n - 1] * finv[x - 1];
  };

  while(Q--) {
    i64 x, d, n;
    cin >> x >> d >> n;
    if(d == 0) {
      cout << fp(x).pow(n) << endl;
    }
    else {
      cout << solve((fp(x)/fp(d)).value(), n) * fp(d).pow(n) << endl;
    }
  }
}


Measured memory_bytes: 18048